Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php |
— | — | @@ -12,10 +12,33 @@ |
13 | 13 | */ |
14 | 14 | |
15 | 15 | /** |
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. |
19 | 20 | * |
| 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 | + * |
20 | 43 | * @ingroup SMWDataValues |
21 | 44 | */ |
22 | 45 | abstract class SMWDataValue { |
— | — | @@ -77,22 +100,11 @@ |
78 | 101 | } |
79 | 102 | |
80 | 103 | /** |
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 | | - /** |
91 | 104 | * Initialise this object based on an array of values. The contents |
92 | 105 | * of the array depends on the given datatype. All implementations |
93 | 106 | * should support round-tripping between this function and getDBkeys(). |
94 | 107 | */ |
95 | 108 | public function setDBkeys($args) { |
96 | | -// wfProfileIn('SMWDataValue::setXSDValue-' . $this->m_typeid . ' (SMW)'); |
97 | 109 | $this->m_errors = array(); // clear errors |
98 | 110 | $this->m_infolinks = array(); // clear links |
99 | 111 | $this->m_hasssearchlink = false; |
— | — | @@ -100,11 +112,6 @@ |
101 | 113 | $this->m_caption = false; |
102 | 114 | $this->m_stubvalues = $args; |
103 | 115 | $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)'); |
109 | 116 | } |
110 | 117 | |
111 | 118 | /** |
— | — | @@ -210,16 +217,6 @@ |
211 | 218 | /** |
212 | 219 | * Initialise the datavalue from the given value string and unit. |
213 | 220 | * 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 |
224 | 221 | * of this implementation for getDBkeys(). |
225 | 222 | */ |
226 | 223 | abstract protected function parseDBkeys($args); |
— | — | @@ -340,17 +337,6 @@ |
341 | 338 | } |
342 | 339 | |
343 | 340 | /** |
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 | | - /** |
355 | 341 | * Return an array of values that characterize the given datavalue completely, |
356 | 342 | * and that are sufficient to reproduce a value of identical content using the |
357 | 343 | * function setDBkeys(). The value array must use number keys that agree with |
— | — | @@ -374,29 +360,21 @@ |
375 | 361 | abstract public function getWikiValue(); |
376 | 362 | |
377 | 363 | /** |
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(). |
384 | 373 | */ |
385 | 374 | public function getNumericValue() { |
386 | 375 | return NULL; |
387 | 376 | } |
388 | 377 | |
389 | 378 | /** |
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 | | - /** |
401 | 379 | * Return a short string that unambiguously specify the type of this value. |
402 | 380 | * This value will globally be used to identify the type of a value (in spite |
403 | 381 | * of the class it actually belongs to, which can still implement various types). |
— | — | @@ -449,7 +427,8 @@ |
450 | 428 | } |
451 | 429 | |
452 | 430 | /** |
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. |
454 | 433 | * Possibly overwritten by subclasses. |
455 | 434 | */ |
456 | 435 | public function isNumeric() { |
— | — | @@ -529,6 +508,49 @@ |
530 | 509 | } |
531 | 510 | } |
532 | 511 | |
| 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 | + |
533 | 555 | } |
534 | 556 | |
535 | 557 | |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -216,63 +216,40 @@ |
217 | 217 | } |
218 | 218 | $res = $db->select( $from, $select, $where, 'SMW::getSemanticData' ); |
219 | 219 | while($row = $db->fetchObject($res)) { |
220 | | -// $dv = NULL; |
221 | 220 | $valuekeys = false; |
222 | 221 | if ($task & (SMW_SQL2_RELS2 | SMW_SQL2_ATTS2 | SMW_SQL2_TEXT2) ) { |
223 | | -// $property = SMWPropertyValue::makeProperty($row->prop); |
224 | 222 | $propertyname = $row->prop; |
225 | | -// $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
226 | 223 | } |
227 | 224 | // The following cases are very similar, yet different in certain details: |
228 | 225 | if ($task == SMW_SQL2_RELS2) { |
229 | 226 | if ( ($row->iw === '') || ($row->iw{0} != ':') ) { // filter "special" iws that mark internal objects |
230 | 227 | $valuekeys = array($row->title, $row->namespace,$row->iw,''); |
231 | 228 | } |
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 | | -// } |
237 | 229 | } elseif ($task == SMW_SQL2_ATTS2) { |
238 | | -// $dv->setXSDValue($row->value, $row->unit); |
239 | 230 | $valuekeys = array($row->value, $row->unit); |
240 | 231 | } elseif ($task == SMW_SQL2_TEXT2) { |
241 | | -// $dv->setXSDValue($row->value, ''); |
242 | 232 | $valuekeys = array($row->value); |
243 | 233 | } elseif ($task == SMW_SQL2_SPEC2) { |
244 | 234 | $pid = array_search($row->p_id, SMWSQLStore2::$special_ids); |
245 | 235 | if ($pid != false) { |
246 | | -// $property = SMWPropertyValue::makeProperty($pid); |
247 | 236 | $propertyname = $pid; |
248 | 237 | } else { // this should be rare (only if some extension uses properties of "special" types) |
249 | 238 | $proprow = $db->selectRow('smw_ids', array('smw_title'), array('smw_id' => $row->p_id), 'SMW::getSemanticData'); |
250 | 239 | /// TODO: $proprow may be false (inconsistent DB but anyway); maybe check and be gentle in some way |
251 | | -// $property = SMWPropertyValue::makeProperty($proprow->smw_title); |
252 | 240 | $propertyname = $proprow->smw_title; |
253 | 241 | } |
254 | | -// $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
255 | | -// $dv->setXSDValue($row->value, ''); |
256 | 242 | $valuekeys = array($row->value); |
257 | 243 | } elseif ( ($task == SMW_SQL2_SUBS2) || ($task == SMW_SQL2_INST2) ) { |
258 | | -// $property = SMWPropertyValue::makeProperty($specprop); |
259 | 244 | $propertyname = $specprop; |
260 | | -// $dv = SMWWikiPageValue::makePage($row->value, $namespace); |
261 | 245 | $valuekeys = array($row->value,$namespace,'',''); |
262 | 246 | } elseif ($task == SMW_SQL2_REDI2) { |
263 | | -// $property = SMWPropertyValue::makeProperty('_REDI'); |
264 | 247 | $propertyname = '_REDI'; |
265 | | -// $dv = SMWWikiPageValue::makePage($row->title, $row->namespace); |
266 | 248 | $valuekeys = array($row->title, $row->namespace,'',''); |
267 | 249 | } elseif ($task == SMW_SQL2_CONC2) { |
268 | | -// $property = SMWPropertyValue::makeProperty('_CONC'); |
269 | 250 | $propertyname = '_CONC'; |
270 | | -// $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
271 | | -// $dv->setValues($row->concept, $row->docu, $row->features, $row->size, $row->depth); |
272 | 251 | $valuekeys = array($row->concept, $row->docu, $row->features, $row->size, $row->depth); |
273 | 252 | } |
274 | | -// if ($dv !== NULL) { |
275 | 253 | if ($valuekeys !== false) { |
276 | | -// $this->m_semdata[$sid]->addPropertyObjectValue($property, $dv); |
277 | 254 | $this->m_semdata[$sid]->addPropertyStubValue($propertyname, $valuekeys); |
278 | 255 | } |
279 | 256 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php |
— | — | @@ -125,17 +125,6 @@ |
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | |
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 | | - |
140 | 129 | protected function parseDBkeys($args) { |
141 | 130 | $this->m_value = $args[0]; |
142 | 131 | $this->m_caption = $this->m_value; |
— | — | @@ -187,10 +176,6 @@ |
188 | 177 | } |
189 | 178 | } |
190 | 179 | |
191 | | -// public function getXSDValue() { |
192 | | -// return $this->m_value; |
193 | | -// } |
194 | | - |
195 | 180 | public function getDBkeys() { |
196 | 181 | $this->unstub(); |
197 | 182 | return array($this->m_value); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php |
— | — | @@ -14,8 +14,8 @@ |
15 | 15 | */ |
16 | 16 | class SMWStringValue extends SMWDataValue { |
17 | 17 | |
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 = ''; |
20 | 20 | |
21 | 21 | protected function parseUserValue($value) { |
22 | 22 | wfLoadExtensionMessages('SemanticMediaWiki'); |
— | — | @@ -33,11 +33,6 @@ |
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
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 | | - |
42 | 37 | protected function parseDBkeys($args) { |
43 | 38 | $this->parseUserValue($args[0]); |
44 | 39 | $this->m_caption = $this->m_value; // this is our output text |
— | — | @@ -75,10 +70,6 @@ |
76 | 71 | } |
77 | 72 | } |
78 | 73 | |
79 | | -// public function getXSDValue() { |
80 | | -// return $this->m_value; |
81 | | -// } |
82 | | - |
83 | 74 | public function getDBkeys() { |
84 | 75 | $this->unstub(); |
85 | 76 | return array($this->m_value); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Import.php |
— | — | @@ -110,22 +110,6 @@ |
111 | 111 | return true; |
112 | 112 | } |
113 | 113 | |
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 | | - |
130 | 114 | protected function parseDBkeys($args) { |
131 | 115 | $parts = explode(' ', $args[0], 3); |
132 | 116 | if (array_key_exists(0,$parts)) { |
— | — | @@ -166,10 +150,6 @@ |
167 | 151 | } |
168 | 152 | } |
169 | 153 | |
170 | | -// public function getXSDValue() { |
171 | | -// return $this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri; |
172 | | -// } |
173 | | - |
174 | 154 | public function getDBkeys() { |
175 | 155 | return array($this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri); |
176 | 156 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php |
— | — | @@ -74,11 +74,6 @@ |
75 | 75 | return true; |
76 | 76 | } |
77 | 77 | |
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 | | - |
83 | 78 | protected function parseDBkeys($args) { |
84 | 79 | $this->m_value = $args[0]; |
85 | 80 | $this->m_unit = array_key_exists(1,$args)?$args[1]:''; |
— | — | @@ -162,12 +157,6 @@ |
163 | 158 | return $this->getLongWikiText($linker); |
164 | 159 | } |
165 | 160 | |
166 | | -// public function getXSDValue() { |
167 | | -// $this->unstub(); |
168 | | -// $this->convertToMainUnit(); |
169 | | -// return $this->m_value; |
170 | | -// } |
171 | | - |
172 | 161 | public function getDBkeys() { |
173 | 162 | $this->unstub(); |
174 | 163 | $this->convertToMainUnit(); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Bool.php |
— | — | @@ -57,11 +57,6 @@ |
58 | 58 | return true; |
59 | 59 | } |
60 | 60 | |
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 | | - |
66 | 61 | protected function parseDBkeys($args) { |
67 | 62 | $this->parseUserValue($args[0]); |
68 | 63 | $this->m_caption = $this->m_stdcaption; // use default for this language |
— | — | @@ -112,10 +107,6 @@ |
113 | 108 | } |
114 | 109 | } |
115 | 110 | |
116 | | -// public function getXSDValue() { |
117 | | -// return $this->m_value?'1':'0'; |
118 | | -// } |
119 | | - |
120 | 111 | public function getDBkeys() { |
121 | 112 | $this->unstub(); |
122 | 113 | return $this->m_value?array('1'):array('0'); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php |
— | — | @@ -28,13 +28,6 @@ |
29 | 29 | return true; |
30 | 30 | } |
31 | 31 | |
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 | | - |
39 | 32 | protected function parseDBkeys($args) { |
40 | 33 | $this->m_concept = $args[0]; |
41 | 34 | $this->m_caption = $args[0]; // is this useful? |
— | — | @@ -77,10 +70,6 @@ |
78 | 71 | } |
79 | 72 | } |
80 | 73 | |
81 | | -// public function getXSDValue() { |
82 | | -// return $this->getWikiValue(); // no XML encoding in DB for concepts, simplifies direct access in store |
83 | | -// } |
84 | | - |
85 | 74 | public function getDBkeys() { |
86 | 75 | $this->unstub(); |
87 | 76 | return array($this->m_concept, $this->m_docu, $this->m_queryfeatures, $this->m_size, $this->m_depth); |
— | — | @@ -185,16 +174,6 @@ |
186 | 175 | return $result; |
187 | 176 | } |
188 | 177 | |
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 | | - |
199 | 178 | public function getDocu() { |
200 | 179 | $this->unstub(); |
201 | 180 | return $this->m_docu; |
— | — | @@ -215,4 +194,9 @@ |
216 | 195 | return $this->m_queryfeatures; |
217 | 196 | } |
218 | 197 | |
| 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 | + |
219 | 203 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php |
— | — | @@ -255,17 +255,6 @@ |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
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 | | - |
270 | 259 | protected function parseDBkeys($args) { |
271 | 260 | list($date,$this->m_time) = explode('T',$args[0],2); |
272 | 261 | $d = explode('/',$date,3); |
— | — | @@ -299,13 +288,6 @@ |
300 | 289 | return $this->getLongWikiText($linker); |
301 | 290 | } |
302 | 291 | |
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 | | - |
310 | 292 | public function getDBkeys() { |
311 | 293 | $this->unstub(); |
312 | 294 | if ($this->m_xsdvalue === false) { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -6,9 +6,13 @@ |
7 | 7 | |
8 | 8 | /** |
9 | 9 | * 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. |
13 | 17 | * |
14 | 18 | * @author Nikolas Iwan |
15 | 19 | * @author Markus Krötzsch |
— | — | @@ -97,13 +101,6 @@ |
98 | 102 | } |
99 | 103 | } |
100 | 104 | |
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 | | - |
108 | 105 | protected function parseDBkeys($args) { |
109 | 106 | global $wgContLang; |
110 | 107 | $this->m_dbkeyform = $args[0]; |
— | — | @@ -129,40 +126,6 @@ |
130 | 127 | } |
131 | 128 | } |
132 | 129 | |
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 | | - |
167 | 130 | public function getShortWikiText($linked = NULL) { |
168 | 131 | $this->unstub(); |
169 | 132 | if ( ($linked === NULL) || ($linked === false) || (!$this->isValid()) || ($this->m_caption == '') ) { |
— | — | @@ -221,11 +184,6 @@ |
222 | 185 | } |
223 | 186 | } |
224 | 187 | |
225 | | -// public function getXSDValue() { |
226 | | -// $this->unstub(); |
227 | | -// return $this->m_dbkeyform; |
228 | | -// } |
229 | | - |
230 | 188 | public function getDBkeys() { |
231 | 189 | $this->unstub(); |
232 | 190 | return array($this->m_dbkeyform, $this->m_namespace, $this->m_interwiki, $this->getSortkey()); |
— | — | @@ -395,24 +353,6 @@ |
396 | 354 | } |
397 | 355 | |
398 | 356 | /** |
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 | | - /** |
417 | 357 | * Init this data value object based on a given Title object. |
418 | 358 | */ |
419 | 359 | public function setTitle($title) { |
— | — | @@ -420,5 +360,12 @@ |
421 | 361 | $this->m_title = $title; |
422 | 362 | } |
423 | 363 | |
| 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 | + |
424 | 371 | } |
425 | 372 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php |
— | — | @@ -41,11 +41,6 @@ |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | | -// protected function parseXSDValue($value, $unit) { |
46 | | -// $this->m_xsdvalue = $value; // lazy parsing |
47 | | -// $this->m_isalias = false; |
48 | | -// } |
49 | | - |
50 | 45 | protected function parseDBkeys($args) { |
51 | 46 | $this->m_xsdvalue = $args[0]; // lazy parsing |
52 | 47 | $this->m_isalias = false; |
— | — | @@ -200,26 +195,6 @@ |
201 | 196 | } |
202 | 197 | } |
203 | 198 | |
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 | | - |
224 | 199 | public function getWikiValue() { |
225 | 200 | return implode('; ', $this->getTypeLabels()); |
226 | 201 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php |
— | — | @@ -17,19 +17,11 @@ |
18 | 18 | |
19 | 19 | private $m_count = 0; |
20 | 20 | |
21 | | - /** |
22 | | - * The array of the data values within this container value |
23 | | - */ |
| 21 | + ///The array of the data values within this container value |
24 | 22 | 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 |
29 | 24 | 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) |
34 | 26 | private $m_querysyntax = false; |
35 | 27 | |
36 | 28 | private $m_comparators; |
— | — | @@ -103,14 +95,10 @@ |
104 | 96 | } |
105 | 97 | |
106 | 98 | /// 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) {} |
111 | 100 | |
112 | 101 | /// No unstubbing required for this datatype. Contained data will be unstubbed if needed. |
113 | | - protected function unstub() { |
114 | | - } |
| 102 | + protected function unstub() {} |
115 | 103 | |
116 | 104 | public function getShortWikiText($linked = NULL) { |
117 | 105 | if ($this->m_caption !== false) { |
— | — | @@ -166,25 +154,9 @@ |
167 | 155 | } |
168 | 156 | } |
169 | 157 | |
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 | | - |
186 | 158 | /// @note This function does not return a useful result for n-ary values. Use getDVs() to access the individual values of this n-ary. |
187 | 159 | public function getDBkeys() { |
188 | | - return array(); |
| 160 | + return array(''); |
189 | 161 | } |
190 | 162 | |
191 | 163 | public function getWikiValue() { |
— | — | @@ -205,29 +177,6 @@ |
206 | 178 | return $result; |
207 | 179 | } |
208 | 180 | |
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 | | - |
232 | 181 | public function getHash() { |
233 | 182 | $first = true; |
234 | 183 | $result = ''; |
— | — | @@ -352,9 +301,8 @@ |
353 | 302 | return $result; |
354 | 303 | } |
355 | 304 | |
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() {} |
359 | 307 | |
360 | 308 | } |
361 | 309 | |