r60734 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60733‎ | r60734 | r60735 >
Date:14:49, 6 January 2010
Author:mkroetzsch
Status:deferred
Tags:
Comment:
include a function from old SMWNAryValue that created queries; not used yet but probably the basis for new query parsing code in list types
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_List.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_List.php
@@ -18,7 +18,6 @@
1919
2020 /// cache for datavalues of types belonging to this object
2121 private $m_typevalues = NULL;
22 -
2322 /// Should this DV operate on query syntax (special mode for parsing queries in a compatible fashion)
2423 private $m_querysyntax = false;
2524 /// Array of comparators as might be found in query strings (based on inputs like >, <, etc.)
@@ -131,7 +130,11 @@
132131 $this->m_typevalues = NULL;
133132 }
134133
135 - ///@todo Update (implementation below still from SMWNAryValue)
 134+ /**
 135+ * @todo Since containers are always exported in a similar fashion, it
 136+ * would be preferrable to have their export controlled where it happens,
 137+ * and minimize the below special code.
 138+ */
136139 public function getExportData() {
137140 if (!$this->isValid()) return NULL;
138141
@@ -139,7 +142,7 @@
140143 $ed = new SMWExpData(SMWExporter::getSpecialElement('swivt','Container'));
141144 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdf','type'), $ed);
142145 $count = 0;
143 - foreach ($this->m_values as $value) {
 146+ foreach ($this->getDVs() as $value) {
144147 $count++;
145148 if ( ($value === NULL) || (!$value->isValid()) ) {
146149 continue;
@@ -238,5 +241,23 @@
239242 return $this->m_typevalues;
240243 }
241244
 245+ /**
 246+ * If valid and in querymode, build a suitable SMWValueList description from the
 247+ * given input or return NULL if no such description was given. This requires the
 248+ * input to be given to setUserValue(). Otherwise bad things will happen.
 249+ */
 250+ public function getValueList() {
 251+ $vl = new SMWValueList();
 252+ if (!$this->isValid() || !$this->m_querysyntax) {
 253+ return NULL;
 254+ }
 255+ for ($i=0; $i < $this->m_count; $i++) {
 256+ if ($this->m_values[$i] !== NULL) {
 257+ $vl->setDescription($i,new SMWValueDescription($this->m_values[$i], $this->m_comparators[$i]));
 258+ }
 259+ }
 260+ return $vl;
 261+ }
 262+
242263 }
243264

Status & tagging log