r17721 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17720‎ | r17721 | r17722 >
Date:12:57, 16 November 2006
Author:mkroetzsch
Status:old
Tags:
Comment:
Fixed bug that disabled link="subject", more efficient generation of links
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php
@@ -35,6 +35,7 @@
3636 */
3737
3838 require_once( "$IP/includes/Title.php" );
 39+require_once( "$IP/includes/Linker.php" );
3940
4041 /* The variables below define the default settings. Changes can be made by
4142 setting new values in SMW_LocalSettings.php */
@@ -195,6 +196,9 @@
196197 // Note: the strings before the first and after the last row are printed with the header and footer
197198 private $mSeparators; // array of separator strings to be printed *before* each column content, format 'column_id' => 'separator_string'
198199 private $mValueSep; // string between two values for one property
 200+
 201+ // other stuff
 202+ private $mLinker; // we make our own linker for creating the links -- TODO: is this bad?
199203
200204 function SMWInlineQuery($param = array(), $inline = true) {
201205 global $smwgIQDefaultLimit, $smwgIQDefaultLinking;
@@ -215,6 +219,8 @@
216220 $this->mMainLabel = NULL;
217221 $this->mShowDebug = false;
218222
 223+ $this->mLinker = new Linker();
 224+
219225 $this->setParameters($param);
220226 }
221227
@@ -392,8 +398,9 @@
393399 $result .= $this->makeRow($row, $sq->mPrint);
394400 $row = $nextrow;
395401 }
396 - if ($row) // there are more results
 402+ if ($row) { // there are more results
397403 $this->mFurtherResults = true;
 404+ }
398405
399406 $this->dbr->freeResult($res); // Things that should be free: #42 "Possibly large query results"
400407
@@ -934,21 +941,16 @@
935942 * settings for linking apply).
936943 * If $label is NULL the standard label of the given article will be used.
937944 */
938 - private function makeTitleString($text,$subject,$label=NULL) {
 945+ private function makeTitleString($text,$subject,$label='') {
939946 $title = Title::newFromText( $text );
940947 if ($title == NULL) {
941948 return $text; // TODO maybe report an error here?
942949 } elseif ( ($this->mLinkObj) || (($this->mLinkSubj) && ($subject)) ) {
943 - // TODO links should be created by the skin-object, not manually
944 - if ($title->exists()) {
945 - $classnew = '';
946 - } else {
947 - $classnew = 'class="new" ';
948 - }
949 - if ($label === NULL) $label = $title->getText();
950 - return '<a href="'. $title->getLocalURL() .'" '. $classnew .'title="'. $title->getText() .'">'. $label .'</a>';
 950+ if ($subject)
 951+ return $this->mLinker->makeKnownLinkObj($title, $label); //subjects must exist, don't check
 952+ else return $this->mLinker->makeLinkObj($title, $label);
951953 } else {
952 - return $title->getText();
 954+ return $title->getText(); // TODO: shouldn't this default to $label?
953955 }
954956 }
955957

Status & tagging log