r44255 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44254‎ | r44255 | r44256 >
Date:17:36, 5 December 2008
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Fixed bug 16556 (problems with setting printout label for ?Category printouts)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -13,7 +13,7 @@
1414 * @ingroup SMWQuery
1515 */
1616 class SMWPrintRequest {
17 - const PRINT_CATS = 0; // print all direct cateories of the current element
 17+ const PRINT_CATS = 0; // print all direct categories of the current element
1818 const PRINT_PROP = 1; // print all property values of a certain attribute of the current element
1919 const PRINT_THIS = 2; // print the current element
2020 const PRINT_CCAT = 3; // check whether current element is in given category
@@ -62,7 +62,7 @@
6363 return htmlspecialchars($this->m_label);
6464 }
6565 switch ($this->m_mode) {
66 - case SMWPrintRequest::PRINT_CATS:
 66+ case SMWPrintRequest::PRINT_CATS:
6767 return htmlspecialchars($this->m_label); // TODO: link to Special:Categories
6868 case SMWPrintRequest::PRINT_CCAT:
6969 return $linker->makeLinkObj($this->m_data->getTitle(), htmlspecialchars($this->m_label));
@@ -81,7 +81,8 @@
8282 return $this->m_label;
8383 } else {
8484 switch ($this->m_mode) {
85 - case SMWPrintRequest::PRINT_CATS: return $this->m_label; // TODO: link to Special:Categories
 85+ case SMWPrintRequest::PRINT_CATS:
 86+ return $this->m_label; // TODO: link to Special:Categories
8687 case SMWPrintRequest::PRINT_PROP:
8788 return $this->m_data->getShortWikiText($linked);
8889 case SMWPrintRequest::PRINT_CCAT:
@@ -99,7 +100,7 @@
100101 }
101102
102103 /**
103 - * @deprecated Use SMWPrintRequest::getData().
 104+ * @deprecated Use SMWPrintRequest::getData(). This method will vanish in SMW 1.5.
104105 */
105106 public function getTitle() {
106107 if ($this->m_data instanceof Title) {
@@ -140,7 +141,7 @@
141142 * print requests.
142143 */
143144 public function getHash() {
144 - $hash = $this->m_mode . ':';
 145+ $hash = $this->m_mode . ':' . $this->m_label . ':';
145146 if ($this->m_data instanceof Title) {
146147 $hash .= $this->m_data->getPrefixedText() . ':';
147148 } elseif ($this->m_data instanceof SMWDataValue) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -171,20 +171,14 @@
172172 $propparts = explode('#',$parts[0],2);
173173 if (trim($propparts[0]) == '') { // print "this"
174174 $printmode = SMWPrintRequest::PRINT_THIS;
175 - if (count($parts) == 1) { // no label found, use empty label
176 - $parts[] = '';
177 - }
178 - $label = '';
 175+ $label = ''; // default
179176 $title = NULL;
180177 $data = NULL;
181178 } elseif ($wgContLang->getNsText(NS_CATEGORY) == ucfirst(trim($propparts[0]))) { // print categories
182179 $title = NULL;
183180 $data = NULL;
184 - $label = '';
185181 $printmode = SMWPrintRequest::PRINT_CATS;
186 - if (count($parts) == 1) { // no label found, use category label
187 - $parts[] = $showmode?'':$wgContLang->getNSText(NS_CATEGORY);
188 - }
 182+ $label = $showmode?'':$wgContLang->getNSText(NS_CATEGORY); // default
189183 } else { // print property or check category
190184 $title = Title::newFromText(trim($propparts[0]), SMW_NS_PROPERTY); // trim needed for \n
191185 if ($title === NULL) { // too bad, this is no legal property/category name, ignore
@@ -194,19 +188,19 @@
195189 $printmode = SMWPrintRequest::PRINT_PROP;
196190 $property = SMWPropertyValue::makeProperty($title->getDBKey());
197191 $data = $property;
198 - $label = $showmode?'':$property->getWikiValue();
 192+ $label = $showmode?'':$property->getWikiValue(); // default
199193 } elseif ($title->getNamespace() == NS_CATEGORY) {
200194 $printmode = SMWPrintRequest::PRINT_CCAT;
201195 $data = $title;
202 - $label = $showmode?'':$title->getText();
 196+ $label = $showmode?'':$title->getText(); // default
203197 } //else?
204 - if (count($parts) > 1) { // no label found, use property/category name
205 - $label = trim($parts[1]);
206 - }
207198 }
208199 if (count($propparts) == 1) { // no outputformat found, leave empty
209200 $propparts[] = '';
210201 }
 202+ if (count($parts) > 1) { // label found, use this instead of default
 203+ $label = trim($parts[1]);
 204+ }
211205 $printouts[] = new SMWPrintRequest($printmode, $label, $data, trim($propparts[1]));
212206 } else { // parameter or query
213207 $parts = explode('=',$param,2);

Status & tagging log