r40506 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40505‎ | r40506 | r40507 >
Date:20:28, 5 September 2008
Author:vrandezo
Status:old
Tags:
Comment:
Added special properties in Browser
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -138,11 +138,31 @@
139139 $properties = $data->getProperties();
140140 $noresult = true;
141141 foreach ($properties as $property) {
 142+ $displayline= false;
142143 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";
147167
148168 // display value
149169 $body = "<td>\n";
@@ -155,7 +175,10 @@
156176 $body .= '<a href="' . $skin->makeSpecialUrl('SearchByProperty', 'property=' . urlencode($property->getPrefixedText()) . '&value=' . urlencode($data->getSubject()->getLongWikiText())) . '">' . wfMsg("smw_browse_more") . "</a>\n";
157177 } else {
158178 $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);
160183 $body .= "</span>";
161184 }
162185 $count--;
@@ -172,9 +195,6 @@
173196 }
174197 $html .= "</tr>\n";
175198 $noresult = false;
176 - } else {
177 - // @todo Add special property, Categories, Instances, ...
178 - //$noresult = false;
179199 }
180200 } // end foreach properties
181201 if ($noresult) $html .= "<tr class=\"smwb-propvalue\"><th> &nbsp; </th><td><em>" . wfMsg('smw_result_noresults') . "</em></td></th></table>\n";
@@ -204,7 +224,27 @@
205225 $html .= $value->getInfolinkText(SMW_OUTPUT_HTML, $skin);
206226 return $html;
207227 }
 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 .= "&nbsp;" . SMWInfolink::newBrowsingLink('+',$value->getLongWikiText())->getHTML($skin);
 243+ else
 244+ $html .= $value->getInfolinkText(SMW_OUTPUT_HTML, $skin);
 245+ return $html;
 246+ }
208247
 248+
209249 /**
210250 * Displays the subject that is currently being browsed to.
211251 *
@@ -319,7 +359,6 @@
320360 foreach ($values as $value) {
321361 $indata->addPropertyObjectValue($property, $value);
322362 }
323 - // @todo Add special properties and such
324363 }
325364 return array($indata, $more);
326365 }
@@ -379,4 +418,3 @@
380419 }
381420
382421 }
383 -

Status & tagging log