r45879 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45878‎ | r45879 | r45880 >
Date:17:00, 18 January 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
removed obsolete (commented-out) code after recent changes, added more documentation on data value representation
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Bool.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Import.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -12,10 +12,33 @@
1313 */
1414
1515 /**
16 - * Objects of this type represent all that is known about
17 - * a certain user-provided data value, especially its various
18 - * representations as strings, tooltips, numbers, etc.
 16+ * Objects of this type represent all that is known about a certain user-provided
 17+ * data value, especially its various representations as strings, tooltips,
 18+ * numbers, etc. Objects can be created as "emtpy" containers of a certain type,
 19+ * but are then usually filled with data to present one particular data value.
1920 *
 21+ * Data values have two chief representation forms: the user-facing syntax and the
 22+ * internal representation. In user syntax, every value is (necessarily) a single
 23+ * string, however complex the value is. For example, a string such as "Help:editing"
 24+ * may represent a wiki page called "Editing" in the namespace for "Help". The
 25+ * internal representation may be any numerical array of strings and numbers. In the
 26+ * example, it might be array("Editing",12), where 12 is the number used for identifying
 27+ * the namespace "Help:". Of course, the internal representation could also use a single
 28+ * string value, such as in array("Help:Editing"), but this might be less useful for
 29+ * certain operations (e.g. filterng by namespace). Moreover, all values that are
 30+ * restored from the database are given in the internal format, so it wise to choose a
 31+ * format that allows for very fast and easy processing without unnecessary parsing.
 32+ *
 33+ * The main functions of data value objects are:
 34+ * - setUserValue() which triggers parseUserValue() to process a user-level string.
 35+ * - getDBkeys() which provides an array that represents the current value for internal
 36+ * processing
 37+ * - setDBkeys() which triggers parseDBkeys() to process an array with the internal
 38+ * representation
 39+ *
 40+ * In addition, there are a number of get-functions that provide useful output versions
 41+ * for displaying and serializing the value.
 42+ *
2043 * @ingroup SMWDataValues
2144 */
2245 abstract class SMWDataValue {
@@ -77,22 +100,11 @@
78101 }
79102
80103 /**
81 - * Set the xsd value (and compute other representations if possible).
82 - * The given value is a string that was provided by getXSDValue() (all
83 - * implementations should support round-tripping).
84 - * @deprecated Use setDBkeys().
85 - */
86 - public function setXSDValue($value, $unit = '') {
87 - $this->setDBkeys(array($value, $unit));
88 - }
89 -
90 - /**
91104 * Initialise this object based on an array of values. The contents
92105 * of the array depends on the given datatype. All implementations
93106 * should support round-tripping between this function and getDBkeys().
94107 */
95108 public function setDBkeys($args) {
96 -// wfProfileIn('SMWDataValue::setXSDValue-' . $this->m_typeid . ' (SMW)');
97109 $this->m_errors = array(); // clear errors
98110 $this->m_infolinks = array(); // clear links
99111 $this->m_hasssearchlink = false;
@@ -100,11 +112,6 @@
101113 $this->m_caption = false;
102114 $this->m_stubvalues = $args;
103115 $this->m_isset = true;
104 -// global $bugcount; // DEBUGGING
105 -// if (!isset($bugcount)) $bugcount = 0;// DEBUGGING
106 -// print "Set ($bugcount): $value\n---\n";// DEBUGGING
107 -// $bugcount++;// DEBUGGING
108 -// wfProfileOut('SMWDataValue::setXSDValue-' . $this->m_typeid . ' (SMW)');
109116 }
110117
111118 /**
@@ -210,16 +217,6 @@
211218 /**
212219 * Initialise the datavalue from the given value string and unit.
213220 * The format of both strings strictly corresponds to the output
214 - * of this implementation for getXSDValue() and getUnit().
215 - * @deprecated Use parseDBkeys()
216 - */
217 - protected function parseXSDValue($value, $unit) {
218 - $this->parserDBkeys(array($value, $unit));
219 - }
220 -
221 - /**
222 - * Initialise the datavalue from the given value string and unit.
223 - * The format of both strings strictly corresponds to the output
224221 * of this implementation for getDBkeys().
225222 */
226223 abstract protected function parseDBkeys($args);
@@ -340,17 +337,6 @@
341338 }
342339
343340 /**
344 - * Return the XSD compliant version of the value, or FALSE if parsing the
345 - * value failed and no XSD version is available. If the datatype has units,
346 - * then this value is given in the unit provided by getUnit().
347 - * @deprecated Use getDBkeys()
348 - */
349 - public function getXSDValue() {
350 - $keys = $this->getDBkeys();
351 - return array_key_exists(0,$keys)?$keys[0]:'';
352 - }
353 -
354 - /**
355341 * Return an array of values that characterize the given datavalue completely,
356342 * and that are sufficient to reproduce a value of identical content using the
357343 * function setDBkeys(). The value array must use number keys that agree with
@@ -374,29 +360,21 @@
375361 abstract public function getWikiValue();
376362
377363 /**
378 - * Return the numeric representation of the value, or FALSE
379 - * is none is available. This representation is used to
380 - * compare values of scalar types more efficiently, especially
381 - * for sorting queries. If the datatype has units, then this
382 - * value is to be interpreted wrt. the unit provided by getUnit().
383 - * Possibly overwritten by subclasses.
 364+ * Return the numeric representation of the value that can be
 365+ * used for ordering values of this datatype. The given number
 366+ * can be approximate and need not completely reflect the contents
 367+ * of a data value. It merely is used for comparing two such
 368+ * values. NULL is returned if no such number is provided, but
 369+ * it is recommended to use isNumeric() to check for this case.
 370+ * @note Storage implementations can assume numerical values to
 371+ * be completely determined from the given datavalue (i.e. from the
 372+ * vector returned by getDBkeys().
384373 */
385374 public function getNumericValue() {
386375 return NULL;
387376 }
388377
389378 /**
390 - * Return the unit in which the returned value is to be interpreted.
391 - * This string is a plain UTF-8 string without wiki or html markup.
392 - * Returns the empty string if no unit is given for the value.
393 - * Possibly overwritten by subclasses.
394 - * @deprecated Use getDBkeys()
395 - */
396 - public function getUnit() {
397 - return ''; // empty unit
398 - }
399 -
400 - /**
401379 * Return a short string that unambiguously specify the type of this value.
402380 * This value will globally be used to identify the type of a value (in spite
403381 * of the class it actually belongs to, which can still implement various types).
@@ -449,7 +427,8 @@
450428 }
451429
452430 /**
453 - * Return TRUE if values of the given type generally have a numeric version.
 431+ * Return TRUE if values of the given type generally have a numeric version,
 432+ * i.e. if getNumericValue returns a meaningful numeric sortkey.
454433 * Possibly overwritten by subclasses.
455434 */
456435 public function isNumeric() {
@@ -529,6 +508,49 @@
530509 }
531510 }
532511
 512+
 513+ /**
 514+ * Set the xsd value (and compute other representations if possible).
 515+ * The given value is a string that was provided by getXSDValue() (all
 516+ * implementations should support round-tripping).
 517+ * @deprecated Use setDBkeys(). This function will vanish before SMW 1.6.
 518+ */
 519+ public function setXSDValue($value, $unit = '') {
 520+ $this->setDBkeys(array($value, $unit));
 521+ }
 522+
 523+ /**
 524+ * Initialise the datavalue from the given value string and unit.
 525+ * The format of both strings strictly corresponds to the output
 526+ * of this implementation for getXSDValue() and getUnit().
 527+ * @deprecated Use parseDBkeys(). This function will vanish before SMW 1.6.
 528+ */
 529+ protected function parseXSDValue($value, $unit) {
 530+ $this->parserDBkeys(array($value, $unit));
 531+ }
 532+
 533+ /**
 534+ * Return the XSD compliant version of the value, or FALSE if parsing the
 535+ * value failed and no XSD version is available. If the datatype has units,
 536+ * then this value is given in the unit provided by getUnit().
 537+ * @deprecated Use getDBkeys(). This function will vanish before SMW 1.6.
 538+ */
 539+ public function getXSDValue() {
 540+ $keys = $this->getDBkeys();
 541+ return array_key_exists(0,$keys)?$keys[0]:'';
 542+ }
 543+
 544+ /**
 545+ * Return the unit in which the returned value is to be interpreted.
 546+ * This string is a plain UTF-8 string without wiki or html markup.
 547+ * Returns the empty string if no unit is given for the value.
 548+ * Possibly overwritten by subclasses.
 549+ * @deprecated Use getDBkeys(). This function will vanish before SMW 1.6.
 550+ */
 551+ public function getUnit() {
 552+ return ''; // empty unit
 553+ }
 554+
533555 }
534556
535557
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -216,63 +216,40 @@
217217 }
218218 $res = $db->select( $from, $select, $where, 'SMW::getSemanticData' );
219219 while($row = $db->fetchObject($res)) {
220 -// $dv = NULL;
221220 $valuekeys = false;
222221 if ($task & (SMW_SQL2_RELS2 | SMW_SQL2_ATTS2 | SMW_SQL2_TEXT2) ) {
223 -// $property = SMWPropertyValue::makeProperty($row->prop);
224222 $propertyname = $row->prop;
225 -// $dv = SMWDataValueFactory::newPropertyObjectValue($property);
226223 }
227224 // The following cases are very similar, yet different in certain details:
228225 if ($task == SMW_SQL2_RELS2) {
229226 if ( ($row->iw === '') || ($row->iw{0} != ':') ) { // filter "special" iws that mark internal objects
230227 $valuekeys = array($row->title, $row->namespace,$row->iw,'');
231228 }
232 -// if ($dv instanceof SMWWikiPagevalue) { // may fail if type was changed!
233 -// $dv->setValues($row->title, $row->namespace, false, $row->iw);
234 -// } else {
235 -// $dv = NULL;
236 -// }
237229 } elseif ($task == SMW_SQL2_ATTS2) {
238 -// $dv->setXSDValue($row->value, $row->unit);
239230 $valuekeys = array($row->value, $row->unit);
240231 } elseif ($task == SMW_SQL2_TEXT2) {
241 -// $dv->setXSDValue($row->value, '');
242232 $valuekeys = array($row->value);
243233 } elseif ($task == SMW_SQL2_SPEC2) {
244234 $pid = array_search($row->p_id, SMWSQLStore2::$special_ids);
245235 if ($pid != false) {
246 -// $property = SMWPropertyValue::makeProperty($pid);
247236 $propertyname = $pid;
248237 } else { // this should be rare (only if some extension uses properties of "special" types)
249238 $proprow = $db->selectRow('smw_ids', array('smw_title'), array('smw_id' => $row->p_id), 'SMW::getSemanticData');
250239 /// TODO: $proprow may be false (inconsistent DB but anyway); maybe check and be gentle in some way
251 -// $property = SMWPropertyValue::makeProperty($proprow->smw_title);
252240 $propertyname = $proprow->smw_title;
253241 }
254 -// $dv = SMWDataValueFactory::newPropertyObjectValue($property);
255 -// $dv->setXSDValue($row->value, '');
256242 $valuekeys = array($row->value);
257243 } elseif ( ($task == SMW_SQL2_SUBS2) || ($task == SMW_SQL2_INST2) ) {
258 -// $property = SMWPropertyValue::makeProperty($specprop);
259244 $propertyname = $specprop;
260 -// $dv = SMWWikiPageValue::makePage($row->value, $namespace);
261245 $valuekeys = array($row->value,$namespace,'','');
262246 } elseif ($task == SMW_SQL2_REDI2) {
263 -// $property = SMWPropertyValue::makeProperty('_REDI');
264247 $propertyname = '_REDI';
265 -// $dv = SMWWikiPageValue::makePage($row->title, $row->namespace);
266248 $valuekeys = array($row->title, $row->namespace,'','');
267249 } elseif ($task == SMW_SQL2_CONC2) {
268 -// $property = SMWPropertyValue::makeProperty('_CONC');
269250 $propertyname = '_CONC';
270 -// $dv = SMWDataValueFactory::newPropertyObjectValue($property);
271 -// $dv->setValues($row->concept, $row->docu, $row->features, $row->size, $row->depth);
272251 $valuekeys = array($row->concept, $row->docu, $row->features, $row->size, $row->depth);
273252 }
274 -// if ($dv !== NULL) {
275253 if ($valuekeys !== false) {
276 -// $this->m_semdata[$sid]->addPropertyObjectValue($property, $dv);
277254 $this->m_semdata[$sid]->addPropertyStubValue($propertyname, $valuekeys);
278255 }
279256 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
@@ -125,17 +125,6 @@
126126 return true;
127127 }
128128
129 -// protected function parseXSDValue($value, $unit) {
130 -// $this->m_value = $value;
131 -// $this->m_caption = $value;
132 -// if ($this->m_mode == SMW_URI_MODE_EMAIL) {
133 -// $this->m_url = 'mailto:' . $value;
134 -// } else {
135 -// $this->m_url = $value;
136 -// }
137 -// $this->m_uri = $this->m_url;
138 -// }
139 -
140129 protected function parseDBkeys($args) {
141130 $this->m_value = $args[0];
142131 $this->m_caption = $this->m_value;
@@ -187,10 +176,6 @@
188177 }
189178 }
190179
191 -// public function getXSDValue() {
192 -// return $this->m_value;
193 -// }
194 -
195180 public function getDBkeys() {
196181 $this->unstub();
197182 return array($this->m_value);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -14,8 +14,8 @@
1515 */
1616 class SMWStringValue extends SMWDataValue {
1717
18 - protected $m_value = ''; // Wiki-compatible value representation, possibly unsafe for plain HTML
19 - // however, this string might contain HTML entities such as &
 18+ /// Wiki-compatible value representation, possibly unsafe for plain HTML.
 19+ protected $m_value = '';
2020
2121 protected function parseUserValue($value) {
2222 wfLoadExtensionMessages('SemanticMediaWiki');
@@ -33,11 +33,6 @@
3434 return true;
3535 }
3636
37 -// protected function parseXSDValue($value, $unit) {
38 -// $this->parseUserValue($value); // no units, XML compatible syntax
39 -// $this->m_caption = $this->m_value; // this is our output text
40 -// }
41 -
4237 protected function parseDBkeys($args) {
4338 $this->parseUserValue($args[0]);
4439 $this->m_caption = $this->m_value; // this is our output text
@@ -75,10 +70,6 @@
7671 }
7772 }
7873
79 -// public function getXSDValue() {
80 -// return $this->m_value;
81 -// }
82 -
8374 public function getDBkeys() {
8475 $this->unstub();
8576 return array($this->m_value);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Import.php
@@ -110,22 +110,6 @@
111111 return true;
112112 }
113113
114 -// protected function parseXSDValue($value, $unit) {
115 -// $parts = explode(' ', $value, 3);
116 -// if (array_key_exists(0,$parts)) {
117 -// $this->m_namespace = $parts[0];
118 -// }
119 -// if (array_key_exists(1,$parts)) {
120 -// $this->m_section = $parts[1];
121 -// }
122 -// if (array_key_exists(2,$parts)) {
123 -// $this->m_uri = $parts[2];
124 -// }
125 -// $this->m_value = $this->m_namespace . ':' . $this->m_section;
126 -// $this->m_caption = $this->m_value; // not as pretty as on input, don't care
127 -// $this->m_wikilink = $this->m_value; // not as pretty as on input, don't care
128 -// }
129 -
130114 protected function parseDBkeys($args) {
131115 $parts = explode(' ', $args[0], 3);
132116 if (array_key_exists(0,$parts)) {
@@ -166,10 +150,6 @@
167151 }
168152 }
169153
170 -// public function getXSDValue() {
171 -// return $this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri;
172 -// }
173 -
174154 public function getDBkeys() {
175155 return array($this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri);
176156 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php
@@ -74,11 +74,6 @@
7575 return true;
7676 }
7777
78 -// protected function parseXSDValue($value, $unit) {
79 -// // very lazy processing, lets store implementations prefetch more data, even if not needed
80 -// $this->m_stubdata = array($value, $unit);
81 -// }
82 -
8378 protected function parseDBkeys($args) {
8479 $this->m_value = $args[0];
8580 $this->m_unit = array_key_exists(1,$args)?$args[1]:'';
@@ -162,12 +157,6 @@
163158 return $this->getLongWikiText($linker);
164159 }
165160
166 -// public function getXSDValue() {
167 -// $this->unstub();
168 -// $this->convertToMainUnit();
169 -// return $this->m_value;
170 -// }
171 -
172161 public function getDBkeys() {
173162 $this->unstub();
174163 $this->convertToMainUnit();
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Bool.php
@@ -57,11 +57,6 @@
5858 return true;
5959 }
6060
61 -// protected function parseXSDValue($value, $unit) {
62 -// $this->parseUserValue($value); // no units, XML compatible syntax
63 -// $this->m_caption = $this->m_stdcaption; // use default for this language
64 -// }
65 -
6661 protected function parseDBkeys($args) {
6762 $this->parseUserValue($args[0]);
6863 $this->m_caption = $this->m_stdcaption; // use default for this language
@@ -112,10 +107,6 @@
113108 }
114109 }
115110
116 -// public function getXSDValue() {
117 -// return $this->m_value?'1':'0';
118 -// }
119 -
120111 public function getDBkeys() {
121112 $this->unstub();
122113 return $this->m_value?array('1'):array('0');
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php
@@ -28,13 +28,6 @@
2929 return true;
3030 }
3131
32 -// protected function parseXSDValue($value, $unit) {
33 -// // normally not used, store should use setDBkeys
34 -// $this->clear();
35 -// $this->m_concept = $value;
36 -// $this->m_caption = $this->m_concept; // this is our output text
37 -// }
38 -
3932 protected function parseDBkeys($args) {
4033 $this->m_concept = $args[0];
4134 $this->m_caption = $args[0]; // is this useful?
@@ -77,10 +70,6 @@
7871 }
7972 }
8073
81 -// public function getXSDValue() {
82 -// return $this->getWikiValue(); // no XML encoding in DB for concepts, simplifies direct access in store
83 -// }
84 -
8574 public function getDBkeys() {
8675 $this->unstub();
8776 return array($this->m_concept, $this->m_docu, $this->m_queryfeatures, $this->m_size, $this->m_depth);
@@ -185,16 +174,6 @@
186175 return $result;
187176 }
188177
189 - /// @deprecated Use setDBkeys().
190 - public function setValues($concept, $docu, $queryfeatures, $size, $depth) {
191 - $this->setDBkeys(array($concept, $docu, $queryfeatures, $size, $depth));
192 -// $this->setUserValue($concept); // must be called to make object valid (parent implementation)
193 -// $this->m_docu = $docu?smwfXMLContentEncode($docu):'';
194 -// $this->m_queryfeatures = $queryfeatures;
195 -// $this->m_size = $size;
196 -// $this->m_depth = $depth;
197 - }
198 -
199178 public function getDocu() {
200179 $this->unstub();
201180 return $this->m_docu;
@@ -215,4 +194,9 @@
216195 return $this->m_queryfeatures;
217196 }
218197
 198+ /// @deprecated Use setDBkeys(). This method will vanish before SMW 1.6
 199+ public function setValues($concept, $docu, $queryfeatures, $size, $depth) {
 200+ $this->setDBkeys(array($concept, $docu, $queryfeatures, $size, $depth));
 201+ }
 202+
219203 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php
@@ -255,17 +255,6 @@
256256 }
257257 }
258258
259 -// protected function parseXSDValue($value, $unit) {
260 -// list($date,$this->m_time) = explode('T',$value,2);
261 -// $d = explode('/',$date,3);
262 -// if (count($d)==3) list($this->m_year,$this->m_month,$this->m_day) = $d;
263 -// elseif (count($d)==2) list($this->m_year,$this->m_month) = $d;
264 -// elseif (count($d)==1) list($this->m_year) = $d;
265 -// $this->makePrintoutValue();
266 -// $this->m_caption = $this->m_printvalue;
267 -// $this->m_wikivalue = $this->m_printvalue;
268 -// }
269 -
270259 protected function parseDBkeys($args) {
271260 list($date,$this->m_time) = explode('T',$args[0],2);
272261 $d = explode('/',$date,3);
@@ -299,13 +288,6 @@
300289 return $this->getLongWikiText($linker);
301290 }
302291
303 -// public function getXSDValue() {
304 -// if ($this->m_xsdvalue === false) {
305 -// $this->m_xsdvalue = $this->m_year."/".$this->m_month."/".$this->m_day."T".$this->m_time;
306 -// }
307 -// return $this->m_xsdvalue;
308 -// }
309 -
310292 public function getDBkeys() {
311293 $this->unstub();
312294 if ($this->m_xsdvalue === false) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -6,9 +6,13 @@
77
88 /**
99 * This datavalue implements special processing suitable for defining
10 - * wikipages as values of properties. This value container currently
11 - * behaves somewhat special in that its xsdvalue is not contained all
12 - * relevant information (it just gives the DB-Key, not the namespace).
 10+ * wikipages as values of properties. In contrast to most other types
 11+ * of values, wiki pages are determined by multiple components, as
 12+ * retruned by their getDBkeys() method: DBkey, namespace, interwiki
 13+ * prefix and sortkey. The last of those has a somewhat nonstandard
 14+ * behaviour, since it is not attached to every wiki page value, but
 15+ * only to those that represent page subjects, which define the sortkey
 16+ * globally for all places where this page value occurs.
1317 *
1418 * @author Nikolas Iwan
1519 * @author Markus Krötzsch
@@ -97,13 +101,6 @@
98102 }
99103 }
100104
101 -// protected function parseXSDValue($value, $unit) { // (ignore "unit")
102 -// // This method in its current for is not really useful for init, since the XSD value is just
103 -// // the (dbkey) title string without the namespace.
104 -// /// FIXME: change this to properly use a prefixed title string, in case someone wants to use this
105 -// $this->m_stubdata = array($value,(($this->m_fixNamespace!=NS_MAIN)?$this->m_fixNamespace:$this->m_namespace),false,'','');
106 -// }
107 -
108105 protected function parseDBkeys($args) {
109106 global $wgContLang;
110107 $this->m_dbkeyform = $args[0];
@@ -129,40 +126,6 @@
130127 }
131128 }
132129
133 -// protected function unstub() {
134 -// if (is_array($this->m_stubdata)) {
135 -// global $wgContLang;
136 -// $this->m_dbkeyform = $this->m_stubdata[0];
137 -// $this->m_namespace = $this->m_stubdata[1];
138 -// $this->m_interwiki = $this->m_stubdata[3];
139 -// $this->m_sortkey = $this->m_stubdata[4];
140 -// $this->m_textform = str_replace('_', ' ', $this->m_dbkeyform);
141 -// if ($this->m_interwiki == '') {
142 -// $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform);
143 -// $this->m_prefixedtext = $this->m_title->getPrefixedText();
144 -// } else { // interwiki title objects must be built from full input texts
145 -// $nstext = $wgContLang->getNSText($this->m_namespace);
146 -// $this->m_prefixedtext = $this->m_interwiki . ($this->m_interwiki != ''?':':'') .
147 -// $nstext . ($nstext != ''?':':'') . $this->m_textform;
148 -// $this->m_title = Title::newFromText($this->m_prefixedtext);
149 -// }
150 -// $this->m_caption = $this->m_prefixedtext;
151 -// $this->m_value = $this->m_prefixedtext;
152 -// if ($this->m_stubdata[2] === NULL) {
153 -// $this->m_id = 0;
154 -// $linkCache =& LinkCache::singleton();
155 -// $linkCache->addBadLinkObj($this->m_title); // prefill link cache, save lookups
156 -// } elseif ($this->m_stubdata[2] === false) {
157 -// $this->m_id = false;
158 -// } else {
159 -// $this->m_id = $this->m_stubdata[2];
160 -// $linkCache =& LinkCache::singleton();
161 -// $linkCache->addGoodLinkObj($this->m_id, $this->m_title); // prefill link cache, save lookups
162 -// }
163 -// $this->m_stubdata = false;
164 -// }
165 -// }
166 -
167130 public function getShortWikiText($linked = NULL) {
168131 $this->unstub();
169132 if ( ($linked === NULL) || ($linked === false) || (!$this->isValid()) || ($this->m_caption == '') ) {
@@ -221,11 +184,6 @@
222185 }
223186 }
224187
225 -// public function getXSDValue() {
226 -// $this->unstub();
227 -// return $this->m_dbkeyform;
228 -// }
229 -
230188 public function getDBkeys() {
231189 $this->unstub();
232190 return array($this->m_dbkeyform, $this->m_namespace, $this->m_interwiki, $this->getSortkey());
@@ -395,24 +353,6 @@
396354 }
397355
398356 /**
399 - * Set all basic values for this datavalue to the extent these are
400 - * available. Simplifies and speeds up creation from stored data.
401 - *
402 - * @todo Rethink our standard set interfaces for datavalues to make wikipage
403 - * fit better with the rest.
404 - * @deprecated Use setDBkeys()
405 - */
406 - public function setValues($dbkey, $namespace, $id = false, $interwiki = '', $sortkey = '') {
407 - $this->setDBkeys(array($dbkey,$namespace,$interwiki,$sortkey));
408 -// $this->setXSDValue($dbkey,''); // just used to trigger standard parent class methods!
409 -// if ( ($this->m_fixNamespace != NS_MAIN) && ( $this->m_fixNamespace != $namespace) ) {
410 -// wfLoadExtensionMessages('SemanticMediaWiki');
411 -// $this->addError(wfMsgForContent('smw_notitle', str_replace('_',' ',$dbkey)));
412 -// }
413 -// $this->m_stubdata = array($dbkey, $namespace, $id, $interwiki, $sortkey);
414 - }
415 -
416 - /**
417357 * Init this data value object based on a given Title object.
418358 */
419359 public function setTitle($title) {
@@ -420,5 +360,12 @@
421361 $this->m_title = $title;
422362 }
423363
 364+ /**
 365+ * @deprecated Use setDBkeys()
 366+ */
 367+ public function setValues($dbkey, $namespace, $id = false, $interwiki = '', $sortkey = '') {
 368+ $this->setDBkeys(array($dbkey,$namespace,$interwiki,$sortkey));
 369+ }
 370+
424371 }
425372
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php
@@ -41,11 +41,6 @@
4242 }
4343 }
4444
45 -// protected function parseXSDValue($value, $unit) {
46 -// $this->m_xsdvalue = $value; // lazy parsing
47 -// $this->m_isalias = false;
48 -// }
49 -
5045 protected function parseDBkeys($args) {
5146 $this->m_xsdvalue = $args[0]; // lazy parsing
5247 $this->m_isalias = false;
@@ -200,26 +195,6 @@
201196 }
202197 }
203198
204 -// public function getXSDValue() {
205 -// if ($this->isValid()) {
206 -// if ($this->m_xsdvalue === false) {
207 -// $first = true;
208 -// $this->m_xsdvalue = '';
209 -// foreach ($this->m_typelabels as $label) {
210 -// if ($first) {
211 -// $first = false;
212 -// } else {
213 -// $this->m_xsdvalue .= ';';
214 -// }
215 -// $this->m_xsdvalue .= SMWDataValueFactory::findTypeID($label);
216 -// }
217 -// }
218 -// return $this->m_xsdvalue;
219 -// } else {
220 -// return false;
221 -// }
222 -// }
223 -
224199 public function getWikiValue() {
225200 return implode('; ', $this->getTypeLabels());
226201 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
@@ -17,19 +17,11 @@
1818
1919 private $m_count = 0;
2020
21 - /**
22 - * The array of the data values within this container value
23 - */
 21+ ///The array of the data values within this container value
2422 private $m_values = array();
25 -
26 - /**
27 - * TypeObject as we received them when datafactory called us
28 - */
 23+ /// TypeObject as we received them when datafactory called us
2924 private $m_type;
30 -
31 - /**
32 - * Should this DV operate on query syntax (special mode for parsing queries in a compatible fashion)
33 - */
 25+ /// Should this DV operate on query syntax (special mode for parsing queries in a compatible fashion)
3426 private $m_querysyntax = false;
3527
3628 private $m_comparators;
@@ -103,14 +95,10 @@
10496 }
10597
10698 /// Parsing from a value array is not supported for this datatype. Use setDVs() to initialize this datatype.
107 - protected function parseDBkeys($args) {
108 -// trigger_error("parseDBkeys() cannot be used for initializing n-ary datavalues (SMWNAryValue). Use SMWNAryValue->setDVs() instead.", E_USER_WARNING);
109 -// debug_print_backtrace();
110 - }
 99+ protected function parseDBkeys($args) {}
111100
112101 /// No unstubbing required for this datatype. Contained data will be unstubbed if needed.
113 - protected function unstub() {
114 - }
 102+ protected function unstub() {}
115103
116104 public function getShortWikiText($linked = NULL) {
117105 if ($this->m_caption !== false) {
@@ -166,25 +154,9 @@
167155 }
168156 }
169157
170 -// public function getXSDValue() {
171 -// $first = true;
172 -// $result = '';
173 -// foreach ($this->m_values as $value) {
174 -// if ($first) {
175 -// $first = false;
176 -// } else {
177 -// $result .= ';';
178 -// }
179 -// if ($value !== NULL) {
180 -// $result .= $value->getXSDValue();
181 -// }
182 -// }
183 -// return $result;
184 -// }
185 -
186158 /// @note This function does not return a useful result for n-ary values. Use getDVs() to access the individual values of this n-ary.
187159 public function getDBkeys() {
188 - return array();
 160+ return array('');
189161 }
190162
191163 public function getWikiValue() {
@@ -205,29 +177,6 @@
206178 return $result;
207179 }
208180
209 -// public function getUnit() {
210 -// $first = true;
211 -// $result = '';
212 -// $hasunit = false;
213 -// foreach ($this->m_values as $value) {
214 -// if ($first) {
215 -// $first = false;
216 -// } else {
217 -// $result .= ';';
218 -// }
219 -// if ($value !== NULL) {
220 -// $result .= $value->getUnit();
221 -// if ( (!$hasunit) && ($value->getUnit() != '') ) {
222 -// $hasunit = true;
223 -// }
224 -// }
225 -// }
226 -// if (!$hasunit) {
227 -// $result = '';
228 -// }
229 -// return $result;
230 -// }
231 -
232181 public function getHash() {
233182 $first = true;
234183 $result = '';
@@ -352,9 +301,8 @@
353302 return $result;
354303 }
355304
356 - protected function checkAllowedValues() {
357 - return; // not implemented yet
358 - }
 305+ /// @todo Allowed values for multi-valued properties are not supported yet.
 306+ protected function checkAllowedValues() {}
359307
360308 }
361309

Status & tagging log