r23205 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23204‎ | r23205 | r23206 >
Date:11:19, 22 June 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Minor fixes/improvements in query API/execution
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -62,9 +62,9 @@
6363 return htmlspecialchars($this->m_label);
6464 }
6565 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);
 66+ case SMW_PRINT_CATS: return htmlspecialchars($this->m_label); // TODO: link to Special:Categories
 67+ case SMW_PRINT_RELS: return $linker->makeLinkObj($this->m_title, htmlspecialchars($this->m_label));
 68+ case SMW_PRINT_ATTS: return $linker->makeKnownLinkObj($this->m_title, htmlspecialchars($this->m_label));
6969 case SMW_PRINT_THIS: default: return htmlspecialchars($this->m_label);
7070 }
7171
@@ -73,8 +73,18 @@
7474 /**
7575 * Obtain a Wiki-formatted representation of the label.
7676 */
77 - public function getWikiText() {
78 - return $this->m_label;
 77+ public function getWikiText($linked = false) {
 78+ if ( ($linked === NULL) || ($linked === false) || ($this->m_label == '') ) {
 79+ return $this->m_label;
 80+ } else {
 81+ switch ($this->m_mode) {
 82+ case SMW_PRINT_CATS: return $this->m_label; // TODO: link to Special:Categories
 83+ case SMW_PRINT_RELS: case SMW_PRINT_ATTS:
 84+ return '[[' . $this->m_title->getPrefixedText() . '|' . $this->m_label . ']]';
 85+ case SMW_PRINT_THIS: default: return $this->m_label;
 86+ }
 87+ }
 88+
7989 }
8090
8191 public function getTitle() {
@@ -216,8 +226,8 @@
217227 protected $m_datavalue;
218228 protected $m_comparator;
219229
220 - public function SMWValueDescription(SMWDataValue $datavalue, $comparator = SMW_CMP_EQUAL) {
221 - $this->m_datavalue = $datavalue;
 230+ public function SMWValueDescription($datavalue, $comparator = SMW_CMP_EQ) {
 231+ $this->m_datavalue = $datavalue; // might be NULL for SMW_CMP_ANY
222232 $this->m_comparator = $comparator;
223233 }
224234
@@ -231,7 +241,7 @@
232242
233243 public function getQueryString() {
234244 if ($this->m_datavalue !== NULL) {
235 - switch ($m_comparator) {
 245+ switch ($this->m_comparator) {
236246 case SMW_CMP_EQ:
237247 $comparator = '';
238248 break;
@@ -247,7 +257,7 @@
248258 case SMW_CMP_ANY: default:
249259 return '+';
250260 }
251 - return $comparator . $datavalue->getShortWikiText(); // TODO: this fails if tooltips are used
 261+ return $comparator . $this->m_datavalue->getWikiValue();
252262 } else {
253263 return '+';
254264 }
@@ -317,7 +327,7 @@
318328 }
319329 $result .= $desc->getQueryString();
320330 }
321 - return '(' . $result . ')';
 331+ return '<q>' . $result . '</q>';
322332 }
323333 }
324334
@@ -347,7 +357,7 @@
348358 }
349359
350360 public function getQueryString() {
351 - return '[[' . $this->m_relation->getText() . '::<q>' . $this->m_description->getQueryString() . '<q/>]]';
 361+ return '[[' . $this->m_relation->getText() . '::<q>' . $this->m_description->getQueryString() . '</q>]]';
352362 }
353363 }
354364
@@ -377,7 +387,7 @@
378388 }
379389
380390 public function getQueryString() {
381 - return '[[' . $this->m_attribute->getText() . '::' . $this->m_description->getQueryString() . ']]';
 391+ return '[[' . $this->m_attribute->getText() . ':=' . $this->m_description->getQueryString() . ']]';
382392 }
383393 }
384394
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php
@@ -189,7 +189,7 @@
190190 $object = current($this->content);
191191 next($this->content);
192192 if ($object instanceof SMWDataValue) { //print data values
193 - return $object->getShortWikiText($linker);
 193+ return $object->getShortWikiText($linked);
194194 } elseif ($object instanceof Title) { // print Title objects
195195 if ( ($linked === NULL) || ($linked === false) ) {
196196 return $object->getPrefixedText();
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -566,12 +566,12 @@
567567 } // else: sortkey given but not found: do not sort
568568 }
569569
570 - print $from . "<br />\n" . $where . "<br />\n"; //DEBUG
571 - foreach ($sql_options as $key => $val) { //DEBUG
572 - print "$key => $val, ";
573 - }
574 - print "<br />\n";
575 - print $this->m_sortkey . " --> " . $this->m_sortfield . "<br />\n"; //DEBUG
 570+// print $from . "<br />\n" . $where . "<br />\n"; //DEBUG
 571+// foreach ($sql_options as $key => $val) { //DEBUG
 572+// print "$key => $val, ";
 573+// }
 574+// print "<br />\n";
 575+// print $this->m_sortkey . " --> " . $this->m_sortfield . "<br />\n"; //DEBUG
576576
577577 // Execute query and format result as array
578578 $res = $db->select($from,

Status & tagging log