r23123 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23122‎ | r23123 | r23124 >
Date:11:36, 20 June 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Added feature for re-serrialising queries (still partial)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -121,6 +121,11 @@
122122 public function addPrintRequest(SMWPrintRequest $printrequest) {
123123 return $this->m_printreqs[$printrequest->getHash()] = $printrequest;
124124 }
 125+
 126+ /**
 127+ * Return a string expressing this query.
 128+ */
 129+ abstract public function getQueryString();
125130 }
126131
127132 /**
@@ -131,6 +136,9 @@
132137 * SMWValueDescription objects.
133138 */
134139 class SMWThingDescription extends SMWDescription {
 140+ public function getQueryString() {
 141+ return '+';
 142+ }
135143 }
136144
137145 /**
@@ -147,6 +155,14 @@
148156 public function getCategory() {
149157 return $this->m_title;
150158 }
 159+
 160+ public function getQueryString() {
 161+ if ($this->m_title !== NULL) {
 162+ return '[[' . $this->m_title->getPrefixedText() . ']]';
 163+ } else {
 164+ return '';
 165+ }
 166+ }
151167 }
152168
153169 /**
@@ -166,6 +182,15 @@
167183 public function getIndividual() {
168184 return $this->m_title;
169185 }
 186+
 187+ public function getQueryString() {
 188+ if ($this->m_title !== NULL) {
 189+ return '[[:' . $this->m_title->getPrefixedText() . ']]';
 190+ } else {
 191+ return '';
 192+ }
 193+ }
 194+
170195 }
171196
172197 /**
@@ -195,6 +220,30 @@
196221 public function getComparator() {
197222 return $this->m_comparator;
198223 }
 224+
 225+ public function getQueryString() {
 226+ if ($this->m_datavalue !== NULL) {
 227+ switch ($m_comparator) {
 228+ case SMW_CMP_EQ:
 229+ $comparator = '';
 230+ break;
 231+ case SMW_CMP_LEQ:
 232+ $comparator = '<';
 233+ break;
 234+ case SMW_CMP_GEQ:
 235+ $comparator = '>';
 236+ break;
 237+ case SMW_CMP_NEQ:
 238+ $comparator = '!'; // not supported yet?
 239+ break;
 240+ case SMW_CMP_ANY: default:
 241+ return '+';
 242+ }
 243+ return $comparator . $datavalue->getShortWikiText(); // TODO: this fails if tooltips are used
 244+ } else {
 245+ return '+';
 246+ }
 247+ }
199248 }
200249
201250 /**
@@ -217,6 +266,14 @@
218267 public function addDescription(SMWDescription $description) {
219268 $this->m_descriptions[] = $description;
220269 }
 270+
 271+ public function getQueryString() {
 272+ $result = '';
 273+ foreach ($this->m_descriptions as $desc) {
 274+ $result .= $desc->getQueryString() . ' ';
 275+ }
 276+ return $result;
 277+ }
221278 }
222279
223280 /**
@@ -239,6 +296,20 @@
240297 public function addDescription(SMWDescription $description) {
241298 $this->m_descriptions[] = $description;
242299 }
 300+
 301+ public function getQueryString() {
 302+ $result = '';
 303+ // TODO: this is not quite correct ... (many disjunctions have || abbreviations)
 304+ foreach ($this->m_descriptions as $desc) {
 305+ if ($first) {
 306+ $first = false;
 307+ } else {
 308+ $result .= ' OR ';
 309+ }
 310+ $result .= $desc->getQueryString();
 311+ }
 312+ return $result;
 313+ }
243314 }
244315
245316 /**
@@ -265,6 +336,10 @@
266337 public function getDescription() {
267338 return $this->m_description;
268339 }
 340+
 341+ public function getQueryString() {
 342+ return '[[' . $this->m_relation->getText() . '::' . $this->m_description->getQueryString() . ']]';
 343+ }
269344 }
270345
271346 /**
@@ -291,6 +366,10 @@
292367 public function getDescription() {
293368 return $this->m_description;
294369 }
 370+
 371+ public function getQueryString() {
 372+ return '[[' . $this->m_attribute->getText() . '::' . $this->m_description->getQueryString() . ']]';
 373+ }
295374 }
296375
297376

Status & tagging log