Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php |
— | — | @@ -138,11 +138,31 @@ |
139 | 139 | $properties = $data->getProperties(); |
140 | 140 | $noresult = true; |
141 | 141 | foreach ($properties as $property) { |
| 142 | + $displayline= false; |
142 | 143 | if ($property instanceof Title) { |
143 | | - // display property |
144 | | - $head = "<th>\n"; |
145 | | - $head .= $skin->makeLinkObj($property, $this->getPropertyLabel($property, $incoming)) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility |
146 | | - $head .= "</th>\n"; |
| 144 | + $proptext = $skin->makeLinkObj($property, $this->getPropertyLabel($property, $incoming)) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility |
| 145 | + $displayline = true; |
| 146 | + $special = false; |
| 147 | + } else { |
| 148 | + $special = true; |
| 149 | + global $smwgContLang; |
| 150 | + $proptext = $smwgContLang->findSpecialPropertyLabel( $property ); |
| 151 | + if ($proptext != '') { |
| 152 | + $p = Title::newFromText($proptext, SMW_NS_PROPERTY); |
| 153 | + $proptext = $skin->makeLinkObj($p, $proptext); |
| 154 | + $displayline = true; |
| 155 | + } |
| 156 | + if (SMW_SP_INSTANCE_OF == $property) { |
| 157 | + $proptext = $skin->specialLink( 'Categories' ); |
| 158 | + $displayline = true; |
| 159 | + } |
| 160 | + if (SMW_SP_REDIRECTS_TO == $property) { |
| 161 | + $proptext = $skin->specialLink( 'Listredirects', 'isredirect' ); |
| 162 | + $displayline = true; |
| 163 | + } |
| 164 | + } |
| 165 | + if ($displayline) { |
| 166 | + $head = "<th>" . $proptext . "</th>\n"; |
147 | 167 | |
148 | 168 | // display value |
149 | 169 | $body = "<td>\n"; |
— | — | @@ -155,7 +175,10 @@ |
156 | 176 | $body .= '<a href="' . $skin->makeSpecialUrl('SearchByProperty', 'property=' . urlencode($property->getPrefixedText()) . '&value=' . urlencode($data->getSubject()->getLongWikiText())) . '">' . wfMsg("smw_browse_more") . "</a>\n"; |
157 | 177 | } else { |
158 | 178 | $body .= "<span class=\"smwb-" . $inv . "value\">"; |
159 | | - $body .= $this->displayValue($property, $value, $incoming); |
| 179 | + if ($special) |
| 180 | + $body .= $this->displaySpecialValue($property, $value, $incoming); |
| 181 | + else |
| 182 | + $body .= $this->displayValue($property, $value, $incoming); |
160 | 183 | $body .= "</span>"; |
161 | 184 | } |
162 | 185 | $count--; |
— | — | @@ -172,9 +195,6 @@ |
173 | 196 | } |
174 | 197 | $html .= "</tr>\n"; |
175 | 198 | $noresult = false; |
176 | | - } else { |
177 | | - // @todo Add special property, Categories, Instances, ... |
178 | | - //$noresult = false; |
179 | 199 | } |
180 | 200 | } // end foreach properties |
181 | 201 | if ($noresult) $html .= "<tr class=\"smwb-propvalue\"><th> </th><td><em>" . wfMsg('smw_result_noresults') . "</em></td></th></table>\n"; |
— | — | @@ -204,7 +224,27 @@ |
205 | 225 | $html .= $value->getInfolinkText(SMW_OUTPUT_HTML, $skin); |
206 | 226 | return $html; |
207 | 227 | } |
| 228 | + |
| 229 | + /** |
| 230 | + * Displays a value for a special property, including all relevant links (browse and search by property) |
| 231 | + * |
| 232 | + * @param[in] $property int A constant representing the special value |
| 233 | + * @param[in] $value SMWDataValue The actual value |
| 234 | + * @param[in] $incoming bool If this is an incoming or outgoing link |
| 235 | + * @return string HTML with the link to the article, browse, and search pages |
| 236 | + */ |
| 237 | + private function displaySpecialValue($property, SMWDataValue $value, $incoming) { |
| 238 | + global $wgUser; |
| 239 | + $skin = $wgUser->getSkin(); |
| 240 | + $html = $value->getLongHTMLText($skin); |
| 241 | + if ($value->getTypeID() == '_wpg') |
| 242 | + $html .= " " . SMWInfolink::newBrowsingLink('+',$value->getLongWikiText())->getHTML($skin); |
| 243 | + else |
| 244 | + $html .= $value->getInfolinkText(SMW_OUTPUT_HTML, $skin); |
| 245 | + return $html; |
| 246 | + } |
208 | 247 | |
| 248 | + |
209 | 249 | /** |
210 | 250 | * Displays the subject that is currently being browsed to. |
211 | 251 | * |
— | — | @@ -319,7 +359,6 @@ |
320 | 360 | foreach ($values as $value) { |
321 | 361 | $indata->addPropertyObjectValue($property, $value); |
322 | 362 | } |
323 | | - // @todo Add special properties and such |
324 | 363 | } |
325 | 364 | return array($indata, $more); |
326 | 365 | } |
— | — | @@ -379,4 +418,3 @@ |
380 | 419 | } |
381 | 420 | |
382 | 421 | } |
383 | | - |