Index: trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | */ |
37 | 37 | |
38 | 38 | require_once( "$IP/includes/Title.php" ); |
| 39 | +require_once( "$IP/includes/Linker.php" ); |
39 | 40 | |
40 | 41 | /* The variables below define the default settings. Changes can be made by |
41 | 42 | setting new values in SMW_LocalSettings.php */ |
— | — | @@ -195,6 +196,9 @@ |
196 | 197 | // Note: the strings before the first and after the last row are printed with the header and footer |
197 | 198 | private $mSeparators; // array of separator strings to be printed *before* each column content, format 'column_id' => 'separator_string' |
198 | 199 | 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? |
199 | 203 | |
200 | 204 | function SMWInlineQuery($param = array(), $inline = true) { |
201 | 205 | global $smwgIQDefaultLimit, $smwgIQDefaultLinking; |
— | — | @@ -215,6 +219,8 @@ |
216 | 220 | $this->mMainLabel = NULL; |
217 | 221 | $this->mShowDebug = false; |
218 | 222 | |
| 223 | + $this->mLinker = new Linker(); |
| 224 | + |
219 | 225 | $this->setParameters($param); |
220 | 226 | } |
221 | 227 | |
— | — | @@ -392,8 +398,9 @@ |
393 | 399 | $result .= $this->makeRow($row, $sq->mPrint); |
394 | 400 | $row = $nextrow; |
395 | 401 | } |
396 | | - if ($row) // there are more results |
| 402 | + if ($row) { // there are more results |
397 | 403 | $this->mFurtherResults = true; |
| 404 | + } |
398 | 405 | |
399 | 406 | $this->dbr->freeResult($res); // Things that should be free: #42 "Possibly large query results" |
400 | 407 | |
— | — | @@ -934,21 +941,16 @@ |
935 | 942 | * settings for linking apply). |
936 | 943 | * If $label is NULL the standard label of the given article will be used. |
937 | 944 | */ |
938 | | - private function makeTitleString($text,$subject,$label=NULL) { |
| 945 | + private function makeTitleString($text,$subject,$label='') { |
939 | 946 | $title = Title::newFromText( $text ); |
940 | 947 | if ($title == NULL) { |
941 | 948 | return $text; // TODO maybe report an error here? |
942 | 949 | } 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); |
951 | 953 | } else { |
952 | | - return $title->getText(); |
| 954 | + return $title->getText(); // TODO: shouldn't this default to $label? |
953 | 955 | } |
954 | 956 | } |
955 | 957 | |