r22792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22791‎ | r22792 | r22793 >
Date:09:27, 6 June 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Enabled linking of result headers in query printing.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -52,6 +52,31 @@
5353 return $this->m_label;
5454 }
5555
 56+ /**
 57+ * Obtain an HTML-formatted representation of the label.
 58+ * The $linker is a Linker object used for generating hyperlinks.
 59+ * If it is NULL, no links will be created.
 60+ */
 61+ public function getHTMLText($linker = NULL) {
 62+ if ( ($linker === NULL) || ($this->m_label == '') ) {
 63+ return htmlspecialchars($this->m_label);
 64+ }
 65+ switch ($this->m_mode) {
 66+ case SMW_PRINT_CATS: return htmlspecialchars($this->m_label);
 67+ case SMW_PRINT_RELS: return $linker->makeLinkObj($this->m_title, $this->m_label);
 68+ case SMW_PRINT_ATTS: return $linker->makeKnownLinkObj($this->m_title, $this->m_label);
 69+ case SMW_PRINT_THIS: default: return htmlspecialchars($this->m_label);
 70+ }
 71+
 72+ }
 73+
 74+ /**
 75+ * Obtain a Wiki-formatted representation of the label.
 76+ */
 77+ public function getWikiText() {
 78+ return $this->m_label;
 79+ }
 80+
5681 public function getTitle() {
5782 return $this->m_title;
5883 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php
@@ -131,7 +131,7 @@
132132 if ($this->mShowHeaders) { // building headers
133133 $result .= "\n\t\t<tr>";
134134 foreach ($res->getPrintRequests() as $pr) {
135 - $result .= "\t\t\t<th>" . $pr->getLabel() . "</th>\n";
 135+ $result .= "\t\t\t<th>" . $pr->getHTMLText($this->mLinker) . "</th>\n";
136136 }
137137 $result .= "\n\t\t</tr>";
138138 }
@@ -264,7 +264,7 @@
265265 if ($first_value) { // first value in any column, print header
266266 $first_value = false;
267267 if ( $this->mShowHeaders && ('' != $field->getPrintRequest()->getLabel()) ) {
268 - $result .= $field->getPrintRequest()->getLabel() . ' ';
 268+ $result .= $field->getPrintRequest()->getHTMLText($this->mLinker) . ' ';
269269 }
270270 }
271271 $result .= $text; // actual output value

Status & tagging log