r17787 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17786‎ | r17787 | r17788 >
Date:17:42, 18 November 2006
Author:mkroetzsch
Status:old
Tags:
Comment:
Changed link creation to simplify use of empty captions for hiding headers selectively.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php
@@ -437,7 +437,7 @@
438438 return new SMWAttributeIterator($this->dbr, $res, $print_data[3]);
439439 case SMW_IQ_PRINT_RSEL:
440440 global $wgContLang;
441 - return new SMWFixedIterator($this->makeTitleString($wgContLang->getNsText($row[$print_data[2] . 'namespace']) . ':' . $row[$print_data[2] . 'title'],'',$linked,$subject));
 441+ return new SMWFixedIterator($this->makeTitleString($wgContLang->getNsText($row[$print_data[2] . 'namespace']) . ':' . $row[$print_data[2] . 'title'],NULL,$linked,$subject));
442442 case SMW_IQ_PRINT_ASEL: // TODO: allow selection of attribute conditionals, and print them here
443443 return new SMWFixedIterator('---');
444444 }
@@ -586,9 +586,10 @@
587587 $qparts[2] = mb_substr($qparts[2],0,$altpos);
588588 } else {
589589 $label = ucfirst($qparts[0]);
 590+ if ( '' === $label) $label = NULL;
590591 }
591592 if ($cat_sep == $op) { // eventually print all categories for the selected subjects
592 - if ('' == $label) $label = $wgContLang->getNSText(NS_CATEGORY);
 593+ if (NULL === $label) $label = $wgContLang->getNSText(NS_CATEGORY);
593594 $result->mPrint['C'] = array($label,SMW_IQ_PRINT_CATS);
594595 } elseif ( '::' == $op ) {
595596 $result->mPrint['R:' . $qparts[0]] = array($this->makeTitleString($wgContLang->getNsText(SMW_NS_RELATION) . ':' . $qparts[0],$label,true),
@@ -890,16 +891,19 @@
891892 *
892893 * $subject states whether the given title is the subject (to which special
893894 * settings for linking apply).
894 - * If $label is empty the standard label of the given article will be used.
 895+ * If $label is null the standard label of the given article will be used.
 896+ * If $label is the empty string, an empty string is returned.
895897 * $linked states whether the result should be a hyperlink
896898 * $exists states whether $text is known to be anexisting article, in which
897899 * case we can save a DB lookup when creating links.
898900 */
899 - public function makeTitleString($text,$label='',$linked,$exists=false) {
 901+ public function makeTitleString($text,$label,$linked,$exists=false) {
 902+ if ( '' === $label) return ''; // no link desired
900903 $title = Title::newFromText( $text );
901 - if ($title == NULL) {
 904+ if ($title === NULL) {
902905 return $text; // TODO maybe report an error here?
903906 } elseif ( $linked ) {
 907+ if ( NULL === $label ) $label = $title->getText();
904908 if ($exists)
905909 return $this->mLinker->makeKnownLinkObj($title, $label);
906910 else return $this->mLinker->makeLinkObj($title, $label);
@@ -943,7 +947,7 @@
944948 global $wgContLang;
945949 $row = $this->mDB->fetchRow($this->mRes);
946950 if ($row)
947 - return array($this->mIQ->makeTitleString($wgContLang->getNsText(NS_CATEGORY) . ':' . $row['cl_to'],'',$this->mLinked));
 951+ return array($this->mIQ->makeTitleString($wgContLang->getNsText(NS_CATEGORY) . ':' . $row['cl_to'],NULL,$this->mLinked));
948952 else return false;
949953 }
950954 }
@@ -991,7 +995,7 @@
992996 global $wgContLang;
993997 $row = $this->mDB->fetchRow($this->mRes);
994998 if ($row) {
995 - return array($this->mIQ->makeTitleString($wgContLang->getNsText($row['object_namespace']) . ':' . $row['object_title'],'',$this->mLinked));
 999+ return array($this->mIQ->makeTitleString($wgContLang->getNsText($row['object_namespace']) . ':' . $row['object_title'],NULL,$this->mLinked));
9961000 } else return false;
9971001 }
9981002 }

Status & tagging log