Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php |
— | — | @@ -20,15 +20,15 @@ |
21 | 21 | */ |
22 | 22 | abstract class SMWDataValue { |
23 | 23 | |
24 | | - protected $m_property = NULL; /// The text label of the respective property or false if none given |
| 24 | + protected $m_property = NULL; /// The text label of the respective property or false if none given |
25 | 25 | protected $m_caption; /// The text label to be used for output or false if none given |
26 | 26 | protected $m_errors = array(); /// Array of error text messages |
27 | 27 | protected $m_isset = false; /// True if a value was set. |
28 | 28 | protected $m_typeid; /// The type id for this value object |
29 | 29 | protected $m_infolinks = array(); /// Array of infolink objects |
30 | 30 | protected $m_outformat = false; /// output formatting string, see setOutputFormat() |
31 | | - protected $m_stubdata = false; /// usually unstub() checks if this contains useful content, |
32 | | - /// and inits the value if this is the case; false while unused |
| 31 | + protected $m_stubvalues = false; /// usually unstub() checks if this contains useful content, |
| 32 | + /// and inits the value with setDBkeys() in this case; false while unused |
33 | 33 | |
34 | 34 | private $m_hasssearchlink; /// used to control the addition of the standard search link |
35 | 35 | private $m_hasservicelinks; /// used to control service link creation |
— | — | @@ -52,6 +52,7 @@ |
53 | 53 | $this->m_isset = false; |
54 | 54 | $this->m_hasssearchlink = false; |
55 | 55 | $this->m_hasservicelinks = false; |
| 56 | + $this->m_stubvalues = false; |
56 | 57 | if ( is_string($caption) ) { |
57 | 58 | $this->m_caption = trim($caption); |
58 | 59 | } else { |
— | — | @@ -79,20 +80,51 @@ |
80 | 81 | * Set the xsd value (and compute other representations if possible). |
81 | 82 | * The given value is a string that was provided by getXSDValue() (all |
82 | 83 | * implementations should support round-tripping). |
| 84 | + * @deprecated Use setDBkeys(). |
83 | 85 | */ |
84 | 86 | public function setXSDValue($value, $unit = '') { |
85 | | - wfProfileIn('SMWDataValue::setXSDValue (SMW)'); |
| 87 | + $this->setDBkeys(array($value, $unit)); |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Initialise this object based on an array of values. The contents |
| 92 | + * of the array depends on the given datatype. All implementations |
| 93 | + * should support round-tripping between this function and getDBkeys(). |
| 94 | + */ |
| 95 | + public function setDBkeys($args) { |
| 96 | +// wfProfileIn('SMWDataValue::setXSDValue-' . $this->m_typeid . ' (SMW)'); |
86 | 97 | $this->m_errors = array(); // clear errors |
87 | 98 | $this->m_infolinks = array(); // clear links |
88 | 99 | $this->m_hasssearchlink = false; |
89 | 100 | $this->m_hasservicelinks = false; |
90 | 101 | $this->m_caption = false; |
91 | | - $this->parseXSDValue($value, $unit); |
| 102 | + $this->m_stubvalues = $args; |
92 | 103 | $this->m_isset = true; |
93 | | - wfProfileOut('SMWDataValue::setXSDValue (SMW)'); |
| 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)'); |
94 | 109 | } |
95 | 110 | |
96 | 111 | /** |
| 112 | + * This function does the acutal processing for loading a datavalue's |
| 113 | + * contents from a value array. setDBkeys() merely stores the given |
| 114 | + * values, whereas unstub() actually parses and processes them. This |
| 115 | + * function usually needs to be called before any outputs can be returned. |
| 116 | + * It takes only very little effort if unstubbing is not needed. |
| 117 | + */ |
| 118 | + protected function unstub() { |
| 119 | + if ($this->m_stubvalues !== false) { |
| 120 | + wfProfileIn('SMWDataValue::unstub-' . $this->m_typeid . ' (SMW)'); |
| 121 | + $args = $this->m_stubvalues; |
| 122 | + $this->m_stubvalues = false; // careful to avoid recursive unstubbing |
| 123 | + $this->parseDBkeys($args); |
| 124 | + wfProfileOut('SMWDataValue::unstub-' . $this->m_typeid . ' (SMW)'); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + /** |
97 | 129 | * Specify the property to which this value refers. Used to generate search links and |
98 | 130 | * to find custom settings that relate to the property. |
99 | 131 | */ |
— | — | @@ -119,7 +151,7 @@ |
120 | 152 | * depending on the datatype, and the service link message is usually crafted with a |
121 | 153 | * particular datatype in mind. |
122 | 154 | */ |
123 | | - function addServiceLinks() { |
| 155 | + public function addServiceLinks() { |
124 | 156 | if ($this->m_hasservicelinks) return; |
125 | 157 | if ( ($this->m_property === NULL) || ($this->m_property->getWikiPageValue() === NULL) ) return; // no property known |
126 | 158 | $args = $this->getServiceLinkParams(); |
— | — | @@ -155,7 +187,7 @@ |
156 | 188 | |
157 | 189 | /** |
158 | 190 | * Add a new error string or array of such strings to the error list. |
159 | | - * @note All error string must be wiki and html-safe! No further escaping |
| 191 | + * @note All error strings must be wiki and html-safe! No further escaping |
160 | 192 | * will happen! |
161 | 193 | */ |
162 | 194 | public function addError($error) { |
— | — | @@ -179,18 +211,18 @@ |
180 | 212 | * Initialise the datavalue from the given value string and unit. |
181 | 213 | * The format of both strings strictly corresponds to the output |
182 | 214 | * of this implementation for getXSDValue() and getUnit(). |
| 215 | + * @deprecated Use parseDBkeys() |
183 | 216 | */ |
184 | | - abstract protected function parseXSDValue($value, $unit); |
| 217 | + protected function parseXSDValue($value, $unit) { |
| 218 | + $this->parserDBkeys(array($value, $unit)); |
| 219 | + } |
185 | 220 | |
186 | 221 | /** |
187 | | - * It makes sense for datavalues to have a stubbing mechanism, especially when |
188 | | - * initialised by parseXSDValue. Such a mechanism quickly stores the initialisation |
189 | | - * parameters and prevents to do any work on them. Each function that requires |
190 | | - * values to be set then first calls unstub() to trigger the required processing. |
191 | | - * This is especially useful for datatypes where this processing may take some time. |
| 222 | + * Initialise the datavalue from the given value string and unit. |
| 223 | + * The format of both strings strictly corresponds to the output |
| 224 | + * of this implementation for getDBkeys(). |
192 | 225 | */ |
193 | | - protected function unstub() { |
194 | | - } |
| 226 | + abstract protected function parseDBkeys($args); |
195 | 227 | |
196 | 228 | ///// Get methods ///// |
197 | 229 | |
— | — | @@ -271,7 +303,7 @@ |
272 | 304 | } |
273 | 305 | |
274 | 306 | /** |
275 | | - * Return text serialisation of info links. Ensures more uniform layout |
| 307 | + * Return text serialisation of info links. Ensures more uniform layout |
276 | 308 | * throughout wiki (Factbox, Property pages, ...). |
277 | 309 | */ |
278 | 310 | public function getInfolinkText($outputformat, $linker=NULL) { |
— | — | @@ -308,13 +340,31 @@ |
309 | 341 | } |
310 | 342 | |
311 | 343 | /** |
312 | | - * Return the XSD compliant version of the value, or FALSE if parsing the |
313 | | - * value failed and no XSD version is available. If the datatype has units, |
| 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, |
314 | 346 | * then this value is given in the unit provided by getUnit(). |
| 347 | + * @deprecated Use getDBkeys() |
315 | 348 | */ |
316 | | - abstract public function getXSDValue(); |
| 349 | + public function getXSDValue() { |
| 350 | + $keys = $this->getDBkeys(); |
| 351 | + return array_key_exists(0,$keys)?$keys[0]:''; |
| 352 | + } |
317 | 353 | |
318 | 354 | /** |
| 355 | + * Return an array of values that characterize the given datavalue completely, |
| 356 | + * and that are sufficient to reproduce a value of identical content using the |
| 357 | + * function setDBkeys(). The value array must use number keys that agree with |
| 358 | + * the array's natural order (in which the data was added). |
| 359 | + * Moreover, each entry of the array must be of a basic type, typically string |
| 360 | + * or int. Do not use arrays or objects! |
| 361 | + * The array should only contain components required for storing, but no derived |
| 362 | + * versions of the value. It should provide a compact form for the data that is |
| 363 | + * still easy to unserialize into a new object. Many datatypes will use arrays |
| 364 | + * with only one entry here. |
| 365 | + */ |
| 366 | + abstract public function getDBkeys(); |
| 367 | + |
| 368 | + /** |
319 | 369 | * Return the plain wiki version of the value, or |
320 | 370 | * FALSE if no such version is available. The returned |
321 | 371 | * string suffices to reobtain the same DataValue |
— | — | @@ -340,6 +390,7 @@ |
341 | 391 | * This string is a plain UTF-8 string without wiki or html markup. |
342 | 392 | * Returns the empty string if no unit is given for the value. |
343 | 393 | * Possibly overwritten by subclasses. |
| 394 | + * @deprecated Use getDBkeys() |
344 | 395 | */ |
345 | 396 | public function getUnit() { |
346 | 397 | return ''; // empty unit |
— | — | @@ -374,7 +425,7 @@ |
375 | 426 | } |
376 | 427 | |
377 | 428 | /** |
378 | | - * Overwritten by callers to supply an array of parameters that can be used for |
| 429 | + * Overwritten by callers to supply an array of parameters that can be used for |
379 | 430 | * creating servicelinks. The number and content of values in the parameter array |
380 | 431 | * may vary, depending on the concrete datatype. |
381 | 432 | */ |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_GeoCoords.php |
— | — | @@ -139,7 +139,7 @@ |
140 | 140 | $this->setAngleValues('E',$angles); |
141 | 141 | } |
142 | 142 | if ( ($angles[0] !== false)||($curnum !== false)) { // unprocessed chunk, error |
143 | | - |
| 143 | + |
144 | 144 | } |
145 | 145 | |
146 | 146 | if ($this->m_caption === false) { |
— | — | @@ -148,19 +148,15 @@ |
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | |
152 | | - protected function parseXSDValue($value, $unit) { |
| 152 | + protected function parseDBkeys($args) { |
153 | 153 | $this->m_lat = false; |
154 | 154 | $this->m_long = false; |
155 | 155 | $this->m_latparts = false; |
156 | 156 | $this->m_longparts = false; |
157 | 157 | |
158 | | - list($this->m_lat, $this->m_long) = split(',', $value); |
159 | | - if ( !is_numeric($this->m_lat) || !is_numeric($this->m_long) ) { // maybe legacy value, try user parsing |
160 | | - $this->setUserValue($value); |
161 | | - } else { |
162 | | - $this->m_caption = $this->formatAngleValues(true) . ', ' . $this->formatAngleValues(false); // this is our output text |
163 | | - $this->m_wikivalue = $this->m_caption; |
164 | | - } |
| 158 | + list($this->m_lat, $this->m_long) = split(',', $args[0]); |
| 159 | + $this->m_caption = $this->formatAngleValues(true) . ', ' . $this->formatAngleValues(false); // this is our output text |
| 160 | + $this->m_wikivalue = $this->m_caption; |
165 | 161 | } |
166 | 162 | |
167 | 163 | public function getShortWikiText($linked = NULL) { |
— | — | @@ -192,11 +188,13 @@ |
193 | 189 | return $this->getLongWikiText($linker); |
194 | 190 | } |
195 | 191 | |
196 | | - public function getXSDValue() { |
197 | | - return $this->m_lat . ',' . $this->m_long; |
| 192 | + public function getDBkeys() { |
| 193 | + $this->unstub(); |
| 194 | + return array($this->m_lat . ',' . $this->m_long); |
198 | 195 | } |
199 | 196 | |
200 | 197 | public function getWikiValue(){ |
| 198 | + $this->unstub(); |
201 | 199 | return $this->m_wikivalue; |
202 | 200 | } |
203 | 201 | |
— | — | @@ -247,7 +245,7 @@ |
248 | 246 | case 'E': $this->m_long = $res; break; |
249 | 247 | case 'W': $this->m_long = -1 * $res; break; |
250 | 248 | } |
251 | | - if ( (($direction == 'E') || ($direction == 'W')) && |
| 249 | + if ( (($direction == 'E') || ($direction == 'W')) && |
252 | 250 | (($this->m_long > 180) || ($this->m_long <= -180)) ) { // bring values back into [180, -180) |
253 | 251 | $this->m_long += ($this->m_long<0)?(round(abs($this->m_long)/360)*360):(round($this->m_long/360)*-360); |
254 | 252 | } |
— | — | @@ -313,7 +311,7 @@ |
314 | 312 | } |
315 | 313 | |
316 | 314 | protected function getServiceLinkParams() { |
317 | | - // Create links to mapping services based on a wiki-editable message. The parameters |
| 315 | + // Create links to mapping services based on a wiki-editable message. The parameters |
318 | 316 | // available to the message are: |
319 | 317 | // $1: latitude integer degrees, $2: longitude integer degrees |
320 | 318 | // $3: latitude integer minutes, $4: longitude integer minutes |
— | — | @@ -324,7 +322,7 @@ |
325 | 323 | $latvals = $this->getAngleValues(true); |
326 | 324 | $longvals = $this->getAngleValues(false); |
327 | 325 | return array($latvals[0], $longvals[0], |
328 | | - $latvals[1], $longvals[1], |
| 326 | + $latvals[1], $longvals[1], |
329 | 327 | round($latvals[2]), round($longvals[2]), |
330 | 328 | $latvals[3], $longvals[3], |
331 | 329 | abs($this->m_lat), abs($this->m_long), |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | class SMWErrorValue extends SMWDataValue { |
15 | 15 | |
16 | 16 | private $m_value; |
17 | | - |
| 17 | + |
18 | 18 | public function SMWErrorValue($errormsg = '', $uservalue = '', $caption = false) { |
19 | 19 | $this->setUserValue($uservalue, $caption); |
20 | 20 | if ($errormsg != '') $this->addError($errormsg); |
— | — | @@ -27,8 +27,8 @@ |
28 | 28 | return true; |
29 | 29 | } |
30 | 30 | |
31 | | - protected function parseXSDValue($value, $unit) { |
32 | | - $this->setUserValue($value); // no units, compatible syntax |
| 31 | + protected function parseDBkeys($args) { |
| 32 | + $this->setUserValue($args[0]); // compatible syntax |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setOutputFormat($formatstring){ |
— | — | @@ -36,6 +36,7 @@ |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function getShortWikiText($linked = NULL) { |
| 40 | + $this->unstub(); |
40 | 41 | //TODO: support linking? |
41 | 42 | return $this->m_caption; |
42 | 43 | } |
— | — | @@ -46,15 +47,17 @@ |
47 | 48 | |
48 | 49 | public function getLongWikiText($linked = NULL) { |
49 | 50 | //TODO: support linking? |
| 51 | + $this->unstub(); |
50 | 52 | return $this->getErrorText(); |
51 | 53 | } |
52 | 54 | |
53 | 55 | public function getLongHTMLText($linker = NULL) { |
| 56 | + $this->unstub(); |
54 | 57 | return $this->getErrorText(); |
55 | 58 | } |
56 | 59 | |
57 | | - public function getXSDValue() { |
58 | | - return $this->getShortWikiText(); ///TODO: really? (errors are not meant to be saved, or are they?) |
| 60 | + public function getDBkeys() { |
| 61 | + return array($this->getShortWikiText()); ///TODO: really? (errors are not meant to be saved, or are they?) |
59 | 62 | } |
60 | 63 | |
61 | 64 | public function getWikiValue() { |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | * |
35 | 35 | * @note Regarding the use of interwiki links in the store, there is currently |
36 | 36 | * no support for storing semantic data about interwiki objects, and hence queries |
37 | | - * that involve interwiki objects really make sense only for them occurring in |
| 37 | + * that involve interwiki objects really make sense only for them occurring in |
38 | 38 | * object positions. Most methods still use the given input interwiki text as a simple |
39 | 39 | * way to filter out results that may be found if an interwiki object is given but a |
40 | 40 | * local object of the same name exists. It is currently not planned to support things |
— | — | @@ -49,9 +49,9 @@ |
50 | 50 | protected $m_semdata = array(); |
51 | 51 | /// Like SMWSQLStore2::m_semdata, but containing flags indicating completeness of the SMWSemanticData objs |
52 | 52 | protected $m_sdstate = array(); |
| 53 | + /// >0 while getSemanticData runs, used to prevent nested calls from clearing the cache while another call runs and is about to fill it with data |
| 54 | + protected static $in_getSemanticData = 0; |
53 | 55 | |
54 | | - protected static $in_getSemanticData = 0; /// >0 while getSemanticData runs, used to prevent nested calls from clearing the cache while another call runs and is about to fill it with data |
55 | | - |
56 | 56 | /// Use pre-defined ids for Very Important Properties, avoiding frequent ID lookups for those |
57 | 57 | private static $special_ids = array( |
58 | 58 | '_TYPE' => 1, |
— | — | @@ -156,8 +156,10 @@ |
157 | 157 | $this->m_sdstate[$sid] = $this->m_sdstate[$sid] | $tasks; |
158 | 158 | $tasks = $newtasks; |
159 | 159 | } |
160 | | - if ( (count($this->m_semdata) > 1000) && (SMWSQLStore2::$in_getSemanticData == 0) ) { |
161 | | - // prevent memory leak on very long PHP runs |
| 160 | + if ( (count($this->m_semdata) > 20) && (SMWSQLStore2::$in_getSemanticData == 1) ) { |
| 161 | + // prevent memory leak; |
| 162 | + // It is not so easy to find the sweet spot between cache size and performance gains (both memory and time), |
| 163 | + // The value of 20 was chosen by profiling runtimes for large inline queries and heavily annotated pages. |
162 | 164 | $this->m_semdata = array($sid => $this->m_semdata[$sid]); |
163 | 165 | $this->m_sdstate = array($sid => $this->m_sdstate[$sid]); |
164 | 166 | } |
— | — | @@ -214,46 +216,64 @@ |
215 | 217 | } |
216 | 218 | $res = $db->select( $from, $select, $where, 'SMW::getSemanticData' ); |
217 | 219 | while($row = $db->fetchObject($res)) { |
218 | | - $dv = NULL; |
| 220 | +// $dv = NULL; |
| 221 | + $valuekeys = false; |
219 | 222 | if ($task & (SMW_SQL2_RELS2 | SMW_SQL2_ATTS2 | SMW_SQL2_TEXT2) ) { |
220 | | - $property = SMWPropertyValue::makeProperty($row->prop); |
221 | | - $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
| 223 | +// $property = SMWPropertyValue::makeProperty($row->prop); |
| 224 | + $propertyname = $row->prop; |
| 225 | +// $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
222 | 226 | } |
223 | 227 | // The following cases are very similar, yet different in certain details: |
224 | 228 | if ($task == SMW_SQL2_RELS2) { |
225 | | - if ($dv instanceof SMWWikiPagevalue) { // may fail if type was changed! |
226 | | - $dv->setValues($row->title, $row->namespace, false, $row->iw); |
227 | | - } else { |
228 | | - $dv = NULL; |
| 229 | + if ( ($row->iw === '') || ($row->iw{0} != ':') ) { // filter "special" iws that mark internal objects |
| 230 | + $valuekeys = array($row->title, $row->namespace,$row->iw,''); |
229 | 231 | } |
| 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 | +// } |
230 | 237 | } elseif ($task == SMW_SQL2_ATTS2) { |
231 | | - $dv->setXSDValue($row->value, $row->unit); |
| 238 | +// $dv->setXSDValue($row->value, $row->unit); |
| 239 | + $valuekeys = array($row->value, $row->unit); |
232 | 240 | } elseif ($task == SMW_SQL2_TEXT2) { |
233 | | - $dv->setXSDValue($row->value, ''); |
| 241 | +// $dv->setXSDValue($row->value, ''); |
| 242 | + $valuekeys = array($row->value); |
234 | 243 | } elseif ($task == SMW_SQL2_SPEC2) { |
235 | 244 | $pid = array_search($row->p_id, SMWSQLStore2::$special_ids); |
236 | 245 | if ($pid != false) { |
237 | | - $property = SMWPropertyValue::makeProperty($pid); |
| 246 | +// $property = SMWPropertyValue::makeProperty($pid); |
| 247 | + $propertyname = $pid; |
238 | 248 | } else { // this should be rare (only if some extension uses properties of "special" types) |
239 | 249 | $proprow = $db->selectRow('smw_ids', array('smw_title'), array('smw_id' => $row->p_id), 'SMW::getSemanticData'); |
240 | 250 | /// TODO: $proprow may be false (inconsistent DB but anyway); maybe check and be gentle in some way |
241 | | - $property = SMWPropertyValue::makeProperty($proprow->smw_title); |
| 251 | +// $property = SMWPropertyValue::makeProperty($proprow->smw_title); |
| 252 | + $propertyname = $proprow->smw_title; |
242 | 253 | } |
243 | | - $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
244 | | - $dv->setXSDValue($row->value, ''); |
| 254 | +// $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
| 255 | +// $dv->setXSDValue($row->value, ''); |
| 256 | + $valuekeys = array($row->value); |
245 | 257 | } elseif ( ($task == SMW_SQL2_SUBS2) || ($task == SMW_SQL2_INST2) ) { |
246 | | - $property = SMWPropertyValue::makeProperty($specprop); |
247 | | - $dv = SMWWikiPageValue::makePage($row->value, $namespace); |
| 258 | +// $property = SMWPropertyValue::makeProperty($specprop); |
| 259 | + $propertyname = $specprop; |
| 260 | +// $dv = SMWWikiPageValue::makePage($row->value, $namespace); |
| 261 | + $valuekeys = array($row->value,$namespace,'',''); |
248 | 262 | } elseif ($task == SMW_SQL2_REDI2) { |
249 | | - $property = SMWPropertyValue::makeProperty('_REDI'); |
250 | | - $dv = SMWWikiPageValue::makePage($row->title, $row->namespace); |
| 263 | +// $property = SMWPropertyValue::makeProperty('_REDI'); |
| 264 | + $propertyname = '_REDI'; |
| 265 | +// $dv = SMWWikiPageValue::makePage($row->title, $row->namespace); |
| 266 | + $valuekeys = array($row->title, $row->namespace,'',''); |
251 | 267 | } elseif ($task == SMW_SQL2_CONC2) { |
252 | | - $property = SMWPropertyValue::makeProperty('_CONC'); |
253 | | - $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
254 | | - $dv->setValues($row->concept, $row->docu, $row->features, $row->size, $row->depth); |
| 268 | +// $property = SMWPropertyValue::makeProperty('_CONC'); |
| 269 | + $propertyname = '_CONC'; |
| 270 | +// $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
| 271 | +// $dv->setValues($row->concept, $row->docu, $row->features, $row->size, $row->depth); |
| 272 | + $valuekeys = array($row->concept, $row->docu, $row->features, $row->size, $row->depth); |
255 | 273 | } |
256 | | - if ($dv !== NULL) { |
257 | | - $this->m_semdata[$sid]->addPropertyObjectValue($property, $dv); |
| 274 | +// if ($dv !== NULL) { |
| 275 | + if ($valuekeys !== false) { |
| 276 | +// $this->m_semdata[$sid]->addPropertyObjectValue($property, $dv); |
| 277 | + $this->m_semdata[$sid]->addPropertyStubValue($propertyname, $valuekeys); |
258 | 278 | } |
259 | 279 | } |
260 | 280 | $db->freeResult($res); |
— | — | @@ -312,7 +332,7 @@ |
313 | 333 | } |
314 | 334 | $db->freeResult($res); |
315 | 335 | } |
316 | | - |
| 336 | + |
317 | 337 | foreach ($properties as $name => $property) { |
318 | 338 | $pdvs = $dvs[$name]; |
319 | 339 | foreach ($pdvs as $bnode => $values) { |
— | — | @@ -871,7 +891,7 @@ |
872 | 892 | $db->insert( 'smw_redi2', array('s_title'=>$oldtitle->getDBkey(), 's_namespace'=>$oldtitle->getNamespace(), 'o_id'=>$sid), 'SMWSQLStore2::changeTitle'); |
873 | 893 | /// NOTE: this temporarily leaves existing redirects to oldtitle point to newtitle as well, which |
874 | 894 | /// will be lost after the next update. Since double redirects are an error anyway, this is not |
875 | | - /// a bad behaviour: everything will continue to work until the old redirect is updated, which |
| 895 | + /// a bad behaviour: everything will continue to work until the old redirect is updated, which |
876 | 896 | /// will hopefully be to fix the double redirect. |
877 | 897 | } else { |
878 | 898 | $this->deleteSemanticData(SMWWikiPageValue::makePageFromTitle($newtitle)); // should not have much effect, but let's be sure |
— | — | @@ -885,17 +905,17 @@ |
886 | 906 | $db->update('smw_atts2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
887 | 907 | $db->update('smw_text2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
888 | 908 | $db->update('smw_inst2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
889 | | - if ( ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) && |
| 909 | + if ( ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) && |
890 | 910 | ( $newtitle->getNamespace() == SMW_NS_PROPERTY ) ) { |
891 | 911 | $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
892 | 912 | } elseif ($oldtitle->getNamespace() == SMW_NS_PROPERTY) { |
893 | 913 | $db->delete('smw_subs2', $cond_array, 'SMWSQLStore2::changeTitle'); |
894 | | - } elseif ( ( $oldtitle->getNamespace() == NS_CATEGORY ) && |
| 914 | + } elseif ( ( $oldtitle->getNamespace() == NS_CATEGORY ) && |
895 | 915 | ( $newtitle->getNamespace() == NS_CATEGORY ) ) { |
896 | 916 | $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
897 | 917 | } elseif ($oldtitle->getNamespace() == NS_CATEGORY) { |
898 | 918 | $db->delete('smw_subs2', $cond_array, 'SMWSQLStore2::changeTitle'); |
899 | | - } elseif ( ( $oldtitle->getNamespace() == SMW_NS_CONCEPT ) && |
| 919 | + } elseif ( ( $oldtitle->getNamespace() == SMW_NS_CONCEPT ) && |
900 | 920 | ( $newtitle->getNamespace() == SMW_NS_CONCEPT ) ) { |
901 | 921 | $db->update('smw_conc2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
902 | 922 | $db->update('smw_conccache', array('o_id' => $tid), array('o_id' => $sid), 'SMWSQLStore2::changeTitle'); |
— | — | @@ -1016,7 +1036,7 @@ |
1017 | 1037 | $options .= ' OFFSET ' . $requestoptions->offset; |
1018 | 1038 | } |
1019 | 1039 | $res = $db->query('SELECT smw_title, COUNT(*) as count FROM ' . |
1020 | | - $db->tableName($table) . ' INNER JOIN ' . $db->tableName('smw_ids') . |
| 1040 | + $db->tableName($table) . ' INNER JOIN ' . $db->tableName('smw_ids') . |
1021 | 1041 | ' ON p_id=smw_id LEFT JOIN ' . $db->tableName('page') . |
1022 | 1042 | ' ON (page_namespace=' . SMW_NS_PROPERTY . |
1023 | 1043 | ' AND page_title=smw_title) WHERE smw_id > 50 AND page_id IS NULL GROUP BY smw_title' . $options, |
— | — | @@ -1192,7 +1212,7 @@ |
1193 | 1213 | function drop($verbose = true) { |
1194 | 1214 | $this->reportProgress("Deleting all database content and tables generated by SMW ...\n\n",$verbose); |
1195 | 1215 | $db =& wfGetDB( DB_MASTER ); |
1196 | | - $tables = array('smw_rels2', 'smw_atts2', 'smw_text2', 'smw_spec2', |
| 1216 | + $tables = array('smw_rels2', 'smw_atts2', 'smw_text2', 'smw_spec2', |
1197 | 1217 | 'smw_subs2', 'smw_redi2', 'smw_ids', 'smw_inst2', |
1198 | 1218 | 'smw_conc2'); |
1199 | 1219 | foreach ($tables as $table) { |
— | — | @@ -1700,7 +1720,7 @@ |
1701 | 1721 | * If $canonical is set to true, redirects are taken into account to find the |
1702 | 1722 | * canonical alias ID for the given page. |
1703 | 1723 | * If no such ID exists, a new ID is created and returned. |
1704 | | - * In any case, the current sortkey is set to the given one unless $sortkey |
| 1724 | + * In any case, the current sortkey is set to the given one unless $sortkey |
1705 | 1725 | * is empty. |
1706 | 1726 | * @note Using this with $canonical==false may make sense, especially when |
1707 | 1727 | * the title is a redirect target (we do not want chains of redirects). |
— | — | @@ -1788,7 +1808,7 @@ |
1789 | 1809 | * n-ary property. Bnodes are managed through the smw_ids table but will always |
1790 | 1810 | * have an empty smw_title, and smw_namespace being set to the parent object |
1791 | 1811 | * (the id of the page that uses the Bnode). Unused Bnodes are not deleted but |
1792 | | - * marked as available by setting smw_namespace to 0. This method then tries to |
| 1812 | + * marked as available by setting smw_namespace to 0. This method then tries to |
1793 | 1813 | * reuse an unused bnode before making a new one. |
1794 | 1814 | * @note Every call to this function, even if the same parameter id is used, returns |
1795 | 1815 | * a new bnode id! |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | $value = 'http://' . $value; |
53 | 53 | $parts[1] = $parts[0]; |
54 | 54 | $parts[0] = 'http'; |
55 | | - } elseif ( (count($parts) < 1) || ($parts[0] == '') || ($parts[1] == '') || (preg_match('/[^a-zA-Z]/u',$parts[0]) )) { |
| 55 | + } elseif ( (count($parts) < 1) || ($parts[0] == '') || ($parts[1] == '') || (preg_match('/[^a-zA-Z]/u',$parts[0]) )) { |
56 | 56 | $this->addError(wfMsgForContent('smw_baduri', $value)); |
57 | 57 | return true; |
58 | 58 | } |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | // break; |
74 | 74 | // } |
75 | 75 | /// TODO: the remaining checks need improvement |
76 | | -// // validate last part of URI (after #) if provided |
| 76 | +// // validate last part of URI (after #) if provided |
77 | 77 | // $uri_ex = explode('#',$value); |
78 | 78 | // $check2 = "@^[a-zA-Z0-9-_\%]+$@u"; ///FIXME: why only ascii symbols? |
79 | 79 | // if(sizeof($uri_ex)>2 ){ // URI should only contain at most one '#' |
— | — | @@ -125,18 +125,30 @@ |
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | |
129 | | - protected function parseXSDValue($value, $unit) { |
130 | | - $this->m_value = $value; |
131 | | - $this->m_caption = $value; |
| 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 | + protected function parseDBkeys($args) { |
| 141 | + $this->m_value = $args[0]; |
| 142 | + $this->m_caption = $this->m_value; |
132 | 143 | if ($this->m_mode == SMW_URI_MODE_EMAIL) { |
133 | | - $this->m_url = 'mailto:' . $value; |
| 144 | + $this->m_url = 'mailto:' . $this->m_value; |
134 | 145 | } else { |
135 | | - $this->m_url = $value; |
| 146 | + $this->m_url = $this->m_value; |
136 | 147 | } |
137 | 148 | $this->m_uri = $this->m_url; |
138 | 149 | } |
139 | 150 | |
140 | 151 | public function getShortWikiText($linked = NULL) { |
| 152 | + $this->unstub(); |
141 | 153 | if ( ($linked === NULL) || ($linked === false) || ($this->m_url == '') || ($this->m_caption == '') ) { |
142 | 154 | return $this->m_caption; |
143 | 155 | } else { |
— | — | @@ -145,6 +157,7 @@ |
146 | 158 | } |
147 | 159 | |
148 | 160 | public function getShortHTMLText($linker = NULL) { |
| 161 | + $this->unstub(); |
149 | 162 | if (($linker === NULL) || (!$this->isValid()) || ($this->m_url == '') || ($this->m_caption == '')) { |
150 | 163 | return $this->m_caption; |
151 | 164 | } else { |
— | — | @@ -174,16 +187,23 @@ |
175 | 188 | } |
176 | 189 | } |
177 | 190 | |
178 | | - public function getXSDValue() { |
179 | | - return $this->m_value; |
| 191 | +// public function getXSDValue() { |
| 192 | +// return $this->m_value; |
| 193 | +// } |
| 194 | + |
| 195 | + public function getDBkeys() { |
| 196 | + $this->unstub(); |
| 197 | + return array($this->m_value); |
180 | 198 | } |
181 | 199 | |
182 | 200 | public function getWikiValue(){ |
| 201 | + $this->unstub(); |
183 | 202 | return $this->m_value; |
184 | 203 | } |
185 | 204 | |
186 | 205 | protected function getServiceLinkParams() { |
187 | | - // Create links to mapping services based on a wiki-editable message. The parameters |
| 206 | + $this->unstub(); |
| 207 | + // Create links to mapping services based on a wiki-editable message. The parameters |
188 | 208 | // available to the message are: |
189 | 209 | // $1: urlencoded version of URI/URL value (includes mailto: for emails) |
190 | 210 | return array(rawurlencode($this->m_uri)); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | */ |
11 | 11 | |
12 | 12 | /** |
13 | | - * Class for representing chunks of semantic data for one given |
| 13 | + * Class for representing chunks of semantic data for one given |
14 | 14 | * article (subject), similar what is typically displayed in the factbox. |
15 | 15 | * This is a light-weight data container. |
16 | 16 | * @ingroup SMW |
— | — | @@ -19,6 +19,10 @@ |
20 | 20 | protected $propvals = array(); |
21 | 21 | /// Text keys and title objects. |
22 | 22 | protected $properties = array(); |
| 23 | + /// Stub property data that is not part of $propvals and $properties yet. Entries use |
| 24 | + /// property DB keys as keys. The value is an array of DBkey-arrays that define individual |
| 25 | + /// datavalues. The stubs will be set up when first accessed. |
| 26 | + protected $stubpropvals = array(); |
23 | 27 | /// Boolean, stating whether the container holds any normal properties. |
24 | 28 | protected $hasvisibleprops = false; |
25 | 29 | /// Boolean, stating whether the container holds any displayable special properties (some are internal only without a display name). |
— | — | @@ -45,7 +49,7 @@ |
46 | 50 | |
47 | 51 | /** |
48 | 52 | * This object is added to the parser output of MediaWiki, but it is not useful to have all its data as part of the parser cache |
49 | | - * since the data is already stored in more accessible format in SMW. Hence this implementation of __sleep() makes sure only the |
| 53 | + * since the data is already stored in more accessible format in SMW. Hence this implementation of __sleep() makes sure only the |
50 | 54 | * subject is serialised, yielding a minimal stub data container after unserialisation. This is a little safer than serialising |
51 | 55 | * nothing: if, for any reason, SMW should ever access an unserialised parser output, then the Semdata container will at least |
52 | 56 | * look as if properly initialised (though empty). |
— | — | @@ -67,6 +71,7 @@ |
68 | 72 | * Get the array of all properties that have stored values. |
69 | 73 | */ |
70 | 74 | public function getProperties() { |
| 75 | + $this->unstubProperties(); |
71 | 76 | ksort($this->properties,SORT_STRING); |
72 | 77 | return $this->properties; |
73 | 78 | } |
— | — | @@ -75,6 +80,19 @@ |
76 | 81 | * Get the array of all stored values for some property. |
77 | 82 | */ |
78 | 83 | public function getPropertyValues(SMWPropertyValue $property) { |
| 84 | + if (array_key_exists($property->getXSDValue(), $this->stubpropvals)) { // unstub those entries completely |
| 85 | + $this->unstubProperty($property->getXSDValue(), $property); |
| 86 | + foreach ( $this->stubpropvals[$property->getXSDValue()] as $dbkeys ) { |
| 87 | + $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
| 88 | + $dv->setDBkeys($dbkeys); |
| 89 | + if ($this->m_noduplicates) { |
| 90 | + $this->propvals[$property->getXSDValue()][$dv->getHash()] = $dv; |
| 91 | + } else { |
| 92 | + $this->propvals[$property->getXSDValue()][] = $dv; |
| 93 | + } |
| 94 | + } |
| 95 | + unset($this->stubpropvals[$property->getXSDValue()]); |
| 96 | + } |
79 | 97 | if (array_key_exists($property->getXSDValue(), $this->propvals)) { |
80 | 98 | return $this->propvals[$property->getXSDValue()]; |
81 | 99 | } else { |
— | — | @@ -86,6 +104,7 @@ |
87 | 105 | * Return true if there are any visible properties. |
88 | 106 | */ |
89 | 107 | public function hasVisibleProperties() { |
| 108 | + $this->unstubProperties(); |
90 | 109 | return $this->hasvisibleprops; |
91 | 110 | } |
92 | 111 | |
— | — | @@ -94,12 +113,13 @@ |
95 | 114 | * be displayed. |
96 | 115 | */ |
97 | 116 | public function hasVisibleSpecialProperties() { |
| 117 | + $this->unstubProperties(); |
98 | 118 | return $this->hasvisiblespecs; |
99 | 119 | } |
100 | 120 | |
101 | 121 | /** |
102 | | - * Store a value for an property identified by its title object. Duplicate |
103 | | - * value entries are ignored. |
| 122 | + * Store a value for a property identified by its title object. Duplicate |
| 123 | + * value entries are usually ignored. |
104 | 124 | * @note Attention: there is no check whether the type of the given datavalue agrees |
105 | 125 | * with what SMWDataValueFactory is producing (based on predefined property records and |
106 | 126 | * the current DB content). Always use SMWDataValueFactory to produce fitting values! |
— | — | @@ -127,7 +147,7 @@ |
128 | 148 | |
129 | 149 | /** |
130 | 150 | * Store a value for a given property identified by its text label (without |
131 | | - * namespace prefix). Duplicate value entries are ignored. |
| 151 | + * namespace prefix). Duplicate value entries are usually ignored. |
132 | 152 | */ |
133 | 153 | public function addPropertyValue($propertyname, SMWDataValue $value) { |
134 | 154 | $propertykey = smwfNormalTitleDBKey($propertyname); |
— | — | @@ -147,14 +167,61 @@ |
148 | 168 | } |
149 | 169 | |
150 | 170 | /** |
| 171 | + * Add data in abbreviated form so that it is only expanded if needed. The property key |
| 172 | + * is the DB key (string) of a property value, whereas valuekeys is an array of DBkeys for |
| 173 | + * the added value that will be used to initialize the value if needed at some point. |
| 174 | + */ |
| 175 | + public function addPropertyStubValue($propertykey, $valuekeys) { |
| 176 | + // catch built-in properties, since their internal key is not what is used as a key elsewhere in SMWSemanticData |
| 177 | + if ($propertykey{0} == '_') { |
| 178 | + $property = SMWPropertyValue::makeProperty($propertykey); |
| 179 | + $propertykey = $property->getXSDValue(); |
| 180 | + $this->unstubProperty($propertykey, $property); |
| 181 | + } |
| 182 | + $this->stubpropvals[$propertykey][] = $valuekeys; |
| 183 | + } |
| 184 | + |
| 185 | + /** |
151 | 186 | * Delete all data other than the subject. |
152 | 187 | */ |
153 | 188 | public function clear() { |
154 | 189 | $this->propvals = array(); |
155 | 190 | $this->properties = array(); |
| 191 | + $this->stubpropvals = array(); |
156 | 192 | $this->hasvisibleprops = false; |
157 | 193 | $this->hasvisiblespecs = false; |
158 | 194 | } |
159 | 195 | |
| 196 | + /** |
| 197 | + * Process all properties that have been added as stubs. Associated data may remain in stub form. |
| 198 | + */ |
| 199 | + protected function unstubProperties() { |
| 200 | + foreach ($this->stubpropvals as $pname => $values) { // unstub property values only, the value lists are still kept as stubs |
| 201 | + $this->unstubProperty($pname); |
| 202 | + } |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * Unstub a single property from the stub data array. If available, an existing object |
| 207 | + * for that property might be provided, so we do not need to make a new one. It is not |
| 208 | + * checked if the object matches the property name. |
| 209 | + */ |
| 210 | + protected function unstubProperty($pname, $propertyobj = NULL) { |
| 211 | + if (!array_key_exists($pname, $this->properties)) { |
| 212 | + if ($propertyobj === NULL) { |
| 213 | + $propertyobj = SMWPropertyValue::makeProperty($pname); |
| 214 | + } |
| 215 | + $this->properties[$pname] = $propertyobj; |
| 216 | + if (!$propertyobj->isUserDefined()) { |
| 217 | + if ($propertyobj->isVisible()) { |
| 218 | + $this->hasvisiblespecs = true; |
| 219 | + $this->hasvisibleprops = true; |
| 220 | + } |
| 221 | + } else { |
| 222 | + $this->hasvisibleprops = true; |
| 223 | + } |
| 224 | + } |
| 225 | + } |
| 226 | + |
160 | 227 | } |
161 | 228 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php |
— | — | @@ -33,12 +33,18 @@ |
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | | - protected function parseXSDValue($value, $unit) { |
38 | | - $this->parseUserValue($value); // no units, XML compatible syntax |
| 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 | + protected function parseDBkeys($args) { |
| 43 | + $this->parseUserValue($args[0]); |
39 | 44 | $this->m_caption = $this->m_value; // this is our output text |
40 | 45 | } |
41 | 46 | |
42 | 47 | public function getShortWikiText($linked = NULL) { |
| 48 | + $this->unstub(); |
43 | 49 | //TODO: Support linking? |
44 | 50 | return $this->m_caption; |
45 | 51 | } |
— | — | @@ -69,15 +75,22 @@ |
70 | 76 | } |
71 | 77 | } |
72 | 78 | |
73 | | - public function getXSDValue() { |
74 | | - return $this->m_value; |
| 79 | +// public function getXSDValue() { |
| 80 | +// return $this->m_value; |
| 81 | +// } |
| 82 | + |
| 83 | + public function getDBkeys() { |
| 84 | + $this->unstub(); |
| 85 | + return array($this->m_value); |
75 | 86 | } |
76 | 87 | |
77 | 88 | public function getWikiValue(){ |
| 89 | + $this->unstub(); |
78 | 90 | return $this->m_value; |
79 | 91 | } |
80 | 92 | |
81 | 93 | public function getInfolinks() { |
| 94 | + $this->unstub(); |
82 | 95 | if ( ($this->m_typeid != '_txt') && ($this->m_typeid != '_cod') ) { |
83 | 96 | return SMWDataValue::getInfolinks(); |
84 | 97 | } |
— | — | @@ -85,6 +98,7 @@ |
86 | 99 | } |
87 | 100 | |
88 | 101 | protected function getServiceLinkParams() { |
| 102 | + $this->unstub(); |
89 | 103 | // Create links to mapping services based on a wiki-editable message. The parameters |
90 | 104 | // available to the message are: |
91 | 105 | // $1: urlencoded string |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Import.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | |
41 | 41 | //browse list in smw_import_* for section |
42 | 42 | list($onto_uri,$onto_name) = explode('|',array_shift($msglines),2); |
43 | | - |
| 43 | + |
44 | 44 | if ( ' ' == $onto_uri[0]) $onto_uri = mb_substr($onto_uri,1); // tolerate initial space |
45 | 45 | |
46 | 46 | $this->m_uri = $onto_uri; |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | // $this_ns = SMWParseData::getSMWData($parser)->getSubject()->getNamespace(); |
81 | 81 | // $error = NULL; |
82 | 82 | // switch ($elemtype) { |
83 | | -// case SMW_NS_PROPERTY: case NS_CATEGORY: |
| 83 | +// case SMW_NS_PROPERTY: case NS_CATEGORY: |
84 | 84 | // if ($this_ns != $elemtype) { |
85 | 85 | // $error = wfMsgForContent('smw_nonright_importtype',$value, $wgContLang->getNsText($elemtype)); |
86 | 86 | // } |
— | — | @@ -92,14 +92,14 @@ |
93 | 93 | // case -1: |
94 | 94 | // $error = wfMsgForContent('smw_no_importelement',$value); |
95 | 95 | // } |
96 | | -// |
| 96 | +// |
97 | 97 | // if (NULL != $error) { |
98 | 98 | // $this->addError($error); |
99 | 99 | // return true; |
100 | 100 | // } |
101 | 101 | // } |
102 | 102 | |
103 | | - //create String to be returned by getShort/LongWikiText |
| 103 | + //create String to be returned by getShort/LongWikiText |
104 | 104 | $this->m_wikilink = "[".$this->m_uri." ".$this->m_value."] (".$this->m_name.")"; |
105 | 105 | |
106 | 106 | //check whether caption is set, otherwise assign link statement to caption |
— | — | @@ -110,8 +110,24 @@ |
111 | 111 | return true; |
112 | 112 | } |
113 | 113 | |
114 | | - protected function parseXSDValue($value, $unit) { |
115 | | - $parts = explode(' ', $value, 3); |
| 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 | + protected function parseDBkeys($args) { |
| 131 | + $parts = explode(' ', $args[0], 3); |
116 | 132 | if (array_key_exists(0,$parts)) { |
117 | 133 | $this->m_namespace = $parts[0]; |
118 | 134 | } |
— | — | @@ -150,8 +166,12 @@ |
151 | 167 | } |
152 | 168 | } |
153 | 169 | |
154 | | - public function getXSDValue() { |
155 | | - return $this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri; |
| 170 | +// public function getXSDValue() { |
| 171 | +// return $this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri; |
| 172 | +// } |
| 173 | + |
| 174 | + public function getDBkeys() { |
| 175 | + return array($this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri); |
156 | 176 | } |
157 | 177 | |
158 | 178 | public function getWikiValue(){ |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php |
— | — | @@ -16,13 +16,13 @@ |
17 | 17 | * if they are used only internally and never specified by or shown to |
18 | 18 | * the user. Those will use their internal ID as "XSD value", and |
19 | 19 | * empty texts for most printouts. All other proeprties use their |
20 | | - * canonical DB key as "XSD value" (even if they are predefined and |
| 20 | + * canonical DB key as "XSD value" (even if they are predefined and |
21 | 21 | * have an id). Functions are provided to check whether a property |
22 | 22 | * is visible or user-defined, and to get the internal ID, if any. |
23 | 23 | * |
24 | 24 | * @note This datavalue is used only for representing properties and, |
25 | 25 | * possibly objects/values, but never for subjects (pages as such). Hence |
26 | | - * it does not rpvide a complete Title-like interface, or support for |
| 26 | + * it does not provide a complete Title-like interface, or support for |
27 | 27 | * things like sortkey. |
28 | 28 | * |
29 | 29 | * @author Markus Krötzsch |
— | — | @@ -49,6 +49,8 @@ |
50 | 50 | /// If the property is associated with a wikipage, it is stored here. Otherwise NULL. |
51 | 51 | protected $m_wikipage; |
52 | 52 | |
| 53 | + private $m_typevalue; // once calculated, remember the type of this property |
| 54 | + |
53 | 55 | /** |
54 | 56 | * Static function for creating a new property object from a |
55 | 57 | * propertyname (string) as a user might enter it. |
— | — | @@ -73,7 +75,7 @@ |
74 | 76 | */ |
75 | 77 | static public function makeProperty($propertyid) { |
76 | 78 | $property = new SMWPropertyValue('__pro'); |
77 | | - $property->setXSDValue($propertyid); |
| 79 | + $property->setDBkeys(array($propertyid)); |
78 | 80 | return $property; |
79 | 81 | } |
80 | 82 | |
— | — | @@ -83,6 +85,7 @@ |
84 | 86 | * @todo Accept/enforce property namespace. |
85 | 87 | */ |
86 | 88 | protected function parseUserValue($value) { |
| 89 | + $this->m_typevalue = NULL; |
87 | 90 | if ($this->m_caption === false) { // always use this as caption |
88 | 91 | $this->m_caption = $value; |
89 | 92 | } |
— | — | @@ -100,35 +103,29 @@ |
101 | 104 | } |
102 | 105 | } |
103 | 106 | |
104 | | - protected function parseXSDValue($value, $unit) { // (ignore "unit") |
105 | | - $this->m_stubdata = array($value); |
106 | | - } |
107 | | - |
108 | 107 | /** |
109 | 108 | * Extended parsing function to first check whether value is the id of a |
110 | 109 | * pre-defined property, to resolve property names and aliases, and to set |
111 | 110 | * internal property id accordingly. |
112 | 111 | */ |
113 | | - protected function unstub() { |
114 | | - if (is_array($this->m_stubdata)) { |
115 | | - SMWPropertyValue::initProperties(); |
116 | | - if ($this->m_stubdata[0]{0} == '_') { // internal id, use as is (and hope it is still known) |
117 | | - $this->m_propertyid = $this->m_stubdata[0]; |
118 | | - } else { // possibly name of special property |
119 | | - $this->m_propertyid = SMWPropertyValue::findPropertyID(str_replace('_',' ',$this->m_stubdata[0])); |
120 | | - } |
121 | | - $label = ($this->m_propertyid !== false)?SMWPropertyValue::findPropertyLabel($this->m_propertyid):$this->m_stubdata[0]; |
122 | | - if ($label != '') { |
123 | | - $this->m_wikipage = SMWDataValueFactory::newTypeIDValue('_wpp'); |
124 | | - $this->m_wikipage->setValues(str_replace(' ', '_',$label),SMW_NS_PROPERTY); |
125 | | - $this->m_caption = $label; |
126 | | - $this->addError($this->m_wikipage->getErrors()); // NOTE: this unstubs the wikipage, should we rather ignore errors here to prevent this? |
127 | | - } else { // predefined property without label |
128 | | - $this->m_wikipage = NULL; |
129 | | - $this->m_caption = $this->m_propertyid; |
130 | | - } |
131 | | - $this->m_stubdata = false; |
| 112 | + protected function parseDBkeys($args) { |
| 113 | + $this->m_typevalue = NULL; |
| 114 | + SMWPropertyValue::initProperties(); |
| 115 | + if ($args[0]{0} == '_') { // internal id, use as is (and hope it is still known) |
| 116 | + $this->m_propertyid = $args[0]; |
| 117 | + } else { // possibly name of special property |
| 118 | + $this->m_propertyid = SMWPropertyValue::findPropertyID(str_replace('_',' ',$args[0])); |
132 | 119 | } |
| 120 | + $label = ($this->m_propertyid !== false)?SMWPropertyValue::findPropertyLabel($this->m_propertyid):$args[0]; |
| 121 | + if ($label != '') { |
| 122 | + $this->m_wikipage = SMWDataValueFactory::newTypeIDValue('_wpp'); |
| 123 | + $this->m_wikipage->setDBkeys(array(str_replace(' ', '_',$label),SMW_NS_PROPERTY,'','')); |
| 124 | + $this->m_caption = $label; |
| 125 | + $this->addError($this->m_wikipage->getErrors()); // NOTE: this unstubs the wikipage, should we rather ignore errors here to prevent this? |
| 126 | + } else { // predefined property without label |
| 127 | + $this->m_wikipage = NULL; |
| 128 | + $this->m_caption = $this->m_propertyid; |
| 129 | + } |
133 | 130 | } |
134 | 131 | |
135 | 132 | public function setCaption($caption) { |
— | — | @@ -190,11 +187,11 @@ |
191 | 188 | } |
192 | 189 | |
193 | 190 | /** |
194 | | - * Return internal property id as the main way of storing property references. |
| 191 | + * Return internal property id or page DBkey, either of which is sufficient for storing property references. |
195 | 192 | */ |
196 | | - public function getXSDValue() { |
197 | | - $this->unstub(); |
198 | | - return $this->isVisible()?$this->m_wikipage->getXSDValue():$this->m_propertyid; |
| 193 | + public function getDBkeys() { |
| 194 | + $this->unstub(); |
| 195 | + return $this->isVisible()?array($this->m_wikipage->getDBkey()):array($this->m_propertyid); |
199 | 196 | } |
200 | 197 | |
201 | 198 | public function getWikiValue() { |
— | — | @@ -224,6 +221,7 @@ |
225 | 222 | */ |
226 | 223 | public function getTypesValue() { |
227 | 224 | global $smwgPDefaultType; |
| 225 | + if ($this->m_typevalue !== NULL) return $this->m_typevalue; |
228 | 226 | if (!$this->isValid()) { // errors in property, return invalid types value with same errors |
229 | 227 | $result = SMWDataValueFactory::newTypeIDValue('__typ'); |
230 | 228 | $result->setXSDValue('__err'); |
— | — | @@ -249,6 +247,7 @@ |
250 | 248 | $result->setXSDValue('_str'); |
251 | 249 | } |
252 | 250 | } |
| 251 | + $this->m_typevalue = $result; |
253 | 252 | return $result; |
254 | 253 | } |
255 | 254 | |
— | — | @@ -356,7 +355,7 @@ |
357 | 356 | |
358 | 357 | /** |
359 | 358 | * Add a new alias label to an existing datatype id. Note that every ID should have a primary |
360 | | - * label, either provided by SMW or registered with registerDatatype. This function should be |
| 359 | + * label, either provided by SMW or registered with registerDatatype. This function should be |
361 | 360 | * called from within the hook 'smwInitDatatypes'. |
362 | 361 | */ |
363 | 362 | static public function registerPropertyAlias($id, $label) { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * Units work as follows: a unit is a string, but many such strings might |
16 | 16 | * refer to the same unit of measurement. There is always one string, that |
17 | 17 | * canonically represents the unit, and we will call this version of writing |
18 | | - * the unit the /unit id/. IDs for units are needed for tasks like duplicate |
| 18 | + * the unit the /unit id/. IDs for units are needed for tasks like duplicate |
19 | 19 | * avoidance. If no conversion information is given, any unit is its own ID. |
20 | 20 | * In any case, units are /normalised/, i.e. given a more standardised meaning |
21 | 21 | * before being processed. All units, IDs or otherwise, should be suitable for |
— | — | @@ -74,20 +74,18 @@ |
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 | | - } |
| 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 | 82 | |
83 | | - protected function unstub() { |
84 | | - if (is_array($this->m_stubdata)) { |
85 | | - $this->m_value = $this->m_stubdata[0]; |
86 | | - $this->m_unit = $this->m_stubdata[1]; |
87 | | - $this->m_unitin = false; |
88 | | - $this->m_stubdata = false; |
89 | | - $this->makeUserValue(); |
90 | | - $this->m_unitvalues = false; |
91 | | - } |
| 83 | + protected function parseDBkeys($args) { |
| 84 | + $this->m_value = $args[0]; |
| 85 | + $this->m_unit = array_key_exists(1,$args)?$args[1]:''; |
| 86 | + $this->m_unitin = false; |
| 87 | + $this->m_stubdata = false; |
| 88 | + $this->makeUserValue(); |
| 89 | + $this->m_unitvalues = false; |
92 | 90 | } |
93 | 91 | |
94 | 92 | public function setOutputFormat($formatstring) { |
— | — | @@ -164,10 +162,16 @@ |
165 | 163 | return $this->getLongWikiText($linker); |
166 | 164 | } |
167 | 165 | |
168 | | - public function getXSDValue() { |
| 166 | +// public function getXSDValue() { |
| 167 | +// $this->unstub(); |
| 168 | +// $this->convertToMainUnit(); |
| 169 | +// return $this->m_value; |
| 170 | +// } |
| 171 | + |
| 172 | + public function getDBkeys() { |
169 | 173 | $this->unstub(); |
170 | 174 | $this->convertToMainUnit(); |
171 | | - return $this->m_value; |
| 175 | + return array($this->m_value, $this->m_unit); |
172 | 176 | } |
173 | 177 | |
174 | 178 | public function getWikiValue(){ |
— | — | @@ -182,9 +186,8 @@ |
183 | 187 | } |
184 | 188 | |
185 | 189 | public function getUnit() { |
186 | | - $this->unstub(); |
187 | | - $this->convertToMainUnit(); |
188 | | - return $this->m_unit; |
| 190 | + $values = $this->getDBkeys(); |
| 191 | + return $values[1]; |
189 | 192 | } |
190 | 193 | |
191 | 194 | public function getHash() { |
— | — | @@ -199,7 +202,7 @@ |
200 | 203 | |
201 | 204 | protected function getServiceLinkParams() { |
202 | 205 | $this->unstub(); |
203 | | - // Create links to mapping services based on a wiki-editable message. The parameters |
| 206 | + // Create links to mapping services based on a wiki-editable message. The parameters |
204 | 207 | // available to the message are: |
205 | 208 | // $1: string of numerical value in English punctuation |
206 | 209 | // $2: string of integer version of value, in English punctuation |
— | — | @@ -237,7 +240,7 @@ |
238 | 241 | * Converts the current m_value and m_unit to the main unit, if possible. |
239 | 242 | * This means, it changes the fileds m_value and m_unit accordingly, and |
240 | 243 | * that it stores the ID of the originally given unit in $this->m_unitin. |
241 | | - * This should obviously not be done more than once, so it is advisable to |
| 244 | + * This should obviously not be done more than once, so it is advisable to |
242 | 245 | * first check if m_unitin is non-false. Also, it should be checked if the |
243 | 246 | * value is valid before trying to calculate with its contents. |
244 | 247 | * |
— | — | @@ -253,8 +256,8 @@ |
254 | 257 | * The result is stored in $this->m_unitvalues. Again, any class that |
255 | 258 | * requires effort for doing this should first check whether the array |
256 | 259 | * is already set (i.e. not false) before doing any work. |
257 | | - * Note that the values should be plain numbers. Output formatting is done |
258 | | - * later when needed. Also, it should be checked if the value is valid |
| 260 | + * Note that the values should be plain numbers. Output formatting is done |
| 261 | + * later when needed. Also, it should be checked if the value is valid |
259 | 262 | * before trying to calculate with its contents. |
260 | 263 | * This method also must call or implement convertToMainUnit(). |
261 | 264 | * |
— | — | @@ -285,7 +288,7 @@ |
286 | 289 | } |
287 | 290 | |
288 | 291 | /** |
289 | | - * Return an array of major unit strings (ids only recommended) supported by |
| 292 | + * Return an array of major unit strings (ids only recommended) supported by |
290 | 293 | * this datavalue. |
291 | 294 | * |
292 | 295 | * Overwritten by subclasses that support units. |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Bool.php |
— | — | @@ -57,8 +57,13 @@ |
58 | 58 | return true; |
59 | 59 | } |
60 | 60 | |
61 | | - protected function parseXSDValue($value, $unit) { |
62 | | - $this->parseUserValue($value); // no units, XML compatible syntax |
| 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 | + protected function parseDBkeys($args) { |
| 67 | + $this->parseUserValue($args[0]); |
63 | 68 | $this->m_caption = $this->m_stdcaption; // use default for this language |
64 | 69 | } |
65 | 70 | |
— | — | @@ -82,10 +87,12 @@ |
83 | 88 | } |
84 | 89 | |
85 | 90 | public function getShortWikiText($linked = NULL) { |
| 91 | + $this->unstub(); |
86 | 92 | return $this->m_caption; |
87 | 93 | } |
88 | 94 | |
89 | 95 | public function getShortHTMLText($linker = NULL) { |
| 96 | + $this->unstub(); |
90 | 97 | return $this->m_caption; |
91 | 98 | } |
92 | 99 | |
— | — | @@ -105,15 +112,22 @@ |
106 | 113 | } |
107 | 114 | } |
108 | 115 | |
109 | | - public function getXSDValue() { |
110 | | - return $this->m_value?'1':'0'; |
| 116 | +// public function getXSDValue() { |
| 117 | +// return $this->m_value?'1':'0'; |
| 118 | +// } |
| 119 | + |
| 120 | + public function getDBkeys() { |
| 121 | + $this->unstub(); |
| 122 | + return $this->m_value?array('1'):array('0'); |
111 | 123 | } |
112 | 124 | |
113 | 125 | public function getWikiValue(){ |
| 126 | + $this->unstub(); |
114 | 127 | return $this->m_stdcaption; |
115 | 128 | } |
116 | 129 | |
117 | 130 | public function getNumericValue() { |
| 131 | + $this->unstub(); |
118 | 132 | return $this->m_value?'1':'0'; |
119 | 133 | } |
120 | 134 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php |
— | — | @@ -28,11 +28,20 @@ |
29 | 29 | return true; |
30 | 30 | } |
31 | 31 | |
32 | | - protected function parseXSDValue($value, $unit) { |
33 | | - // normally not used, store should use setValues |
34 | | - $this->clear(); |
35 | | - $this->m_concept = $value; |
36 | | - $this->m_caption = $this->m_concept; // this is our output text |
| 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 | + protected function parseDBkeys($args) { |
| 40 | + $this->m_concept = $args[0]; |
| 41 | + $this->m_caption = $args[0]; // is this useful? |
| 42 | + $this->m_docu = $args[1]?smwfXMLContentEncode($args[1]):''; |
| 43 | + $this->m_queryfeatures = $args[2]; |
| 44 | + $this->m_size = $args[3]; |
| 45 | + $this->m_depth = $args[4]; |
37 | 46 | } |
38 | 47 | |
39 | 48 | protected function clear() { |
— | — | @@ -44,6 +53,7 @@ |
45 | 54 | } |
46 | 55 | |
47 | 56 | public function getShortWikiText($linked = NULL) { |
| 57 | + $this->unstub(); |
48 | 58 | return $this->m_caption; |
49 | 59 | } |
50 | 60 | |
— | — | @@ -67,11 +77,17 @@ |
68 | 78 | } |
69 | 79 | } |
70 | 80 | |
71 | | - public function getXSDValue() { |
72 | | - return $this->getWikiValue(); // no XML encoding in DB for concepts, simplifies direct access in store |
| 81 | +// public function getXSDValue() { |
| 82 | +// return $this->getWikiValue(); // no XML encoding in DB for concepts, simplifies direct access in store |
| 83 | +// } |
| 84 | + |
| 85 | + public function getDBkeys() { |
| 86 | + $this->unstub(); |
| 87 | + return array($this->m_concept, $this->m_docu, $this->m_queryfeatures, $this->m_size, $this->m_depth); |
73 | 88 | } |
74 | 89 | |
75 | 90 | public function getWikiValue(){ |
| 91 | + $this->unstub(); |
76 | 92 | return str_replace(array('<','>','&'),array('<','>','&'), $this->m_concept); |
77 | 93 | } |
78 | 94 | |
— | — | @@ -97,7 +113,7 @@ |
98 | 114 | return NULL; |
99 | 115 | } |
100 | 116 | } |
101 | | - |
| 117 | + |
102 | 118 | public function descriptionToExpData($desc, &$exact) { |
103 | 119 | if ( ($desc instanceof SMWConjunction) || ($desc instanceof SMWDisjunction) ) { |
104 | 120 | $result = new SMWExpData(new SMWExpElement('')); |
— | — | @@ -137,7 +153,7 @@ |
138 | 154 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('owl', 'onProperty'), |
139 | 155 | new SMWExpData(SMWExporter::getResourceElement($desc->getProperty()))); |
140 | 156 | $subdata = $this->descriptionToExpData($desc->getDescription(), $exact); |
141 | | - if ( ($desc->getDescription() instanceof SMWValueDescription) && |
| 157 | + if ( ($desc->getDescription() instanceof SMWValueDescription) && |
142 | 158 | ($desc->getDescription()->getComparator() == SMW_CMP_EQ) ) { |
143 | 159 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('owl', 'hasValue'), $subdata); |
144 | 160 | } else { |
— | — | @@ -169,38 +185,33 @@ |
170 | 186 | return $result; |
171 | 187 | } |
172 | 188 | |
173 | | - /** |
174 | | - * Special features for Type:Code formating. |
175 | | - */ |
176 | | - protected function getCodeDisplay($value, $scroll = false) { |
177 | | - $result = str_replace( array('<', '>', ' ', '://', '=', "'"), array('<', '>', ' ', '<!-- -->://<!-- -->', '=', '''), $value); |
178 | | - if ($scroll) { |
179 | | - $result = "<div style=\"height:5em; overflow:auto;\">$result</div>"; |
180 | | - } |
181 | | - return "<pre>$result</pre>"; |
182 | | - } |
183 | | - |
| 189 | + /// @deprecated Use setDBkeys(). |
184 | 190 | public function setValues($concept, $docu, $queryfeatures, $size, $depth) { |
185 | | - $this->setUserValue($concept); // must be called to make object valid (parent implementation) |
186 | | - $this->m_docu = $docu?smwfXMLContentEncode($docu):''; |
187 | | - $this->m_queryfeatures = $queryfeatures; |
188 | | - $this->m_size = $size; |
189 | | - $this->m_depth = $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; |
190 | 197 | } |
191 | 198 | |
192 | 199 | public function getDocu() { |
| 200 | + $this->unstub(); |
193 | 201 | return $this->m_docu; |
194 | 202 | } |
195 | 203 | |
196 | 204 | public function getSize() { |
| 205 | + $this->unstub(); |
197 | 206 | return $this->m_size; |
198 | 207 | } |
199 | 208 | |
200 | 209 | public function getDepth() { |
| 210 | + $this->unstub(); |
201 | 211 | return $this->m_depth; |
202 | 212 | } |
203 | 213 | |
204 | 214 | public function getQueryFeatures() { |
| 215 | + $this->unstub(); |
205 | 216 | return $this->m_queryfeatures; |
206 | 217 | } |
207 | 218 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | protected $m_year = false; //Gregorian year, remains false if unspecified |
75 | 75 | protected $m_time = false; //time, remains false if unspecified |
76 | 76 | protected $m_jd = ''; //numerical time representation similiar to Julian Day; for ancient times, a more compressed number is used (preserving ordering of time points) |
77 | | - protected $m_timeoffset; //contains offset (e.g. timezone) |
| 77 | + protected $m_timeoffset; //contains offset (e.g. timezone) |
78 | 78 | protected $m_timeannotation; //contains am or pm |
79 | 79 | // The following are constant (array-valued constants are not supported, hence the decalration as variable): |
80 | 80 | protected $m_months = array("January", "February", "March", "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December"); |
— | — | @@ -255,8 +255,19 @@ |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | | - protected function parseXSDValue($value, $unit) { |
260 | | - list($date,$this->m_time) = explode('T',$value,2); |
| 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 | + protected function parseDBkeys($args) { |
| 271 | + list($date,$this->m_time) = explode('T',$args[0],2); |
261 | 272 | $d = explode('/',$date,3); |
262 | 273 | if (count($d)==3) list($this->m_year,$this->m_month,$this->m_day) = $d; |
263 | 274 | elseif (count($d)==2) list($this->m_year,$this->m_month) = $d; |
— | — | @@ -267,6 +278,7 @@ |
268 | 279 | } |
269 | 280 | |
270 | 281 | public function getShortWikiText($linked = NULL) { |
| 282 | + $this->unstub(); |
271 | 283 | return $this->m_caption; |
272 | 284 | } |
273 | 285 | |
— | — | @@ -287,19 +299,29 @@ |
288 | 300 | return $this->getLongWikiText($linker); |
289 | 301 | } |
290 | 302 | |
291 | | - public function getXSDValue() { |
| 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 | + public function getDBkeys() { |
| 311 | + $this->unstub(); |
292 | 312 | if ($this->m_xsdvalue === false) { |
293 | 313 | $this->m_xsdvalue = $this->m_year."/".$this->m_month."/".$this->m_day."T".$this->m_time; |
294 | 314 | } |
295 | | - return $this->m_xsdvalue; |
| 315 | + return array($this->m_xsdvalue); |
296 | 316 | } |
297 | 317 | |
298 | 318 | public function getNumericValue() { |
| 319 | + $this->unstub(); |
299 | 320 | $this->createJD(); |
300 | 321 | return $this->m_jd; |
301 | 322 | } |
302 | 323 | |
303 | | - public function getWikiValue(){ |
| 324 | + public function getWikiValue() { |
| 325 | + $this->unstub(); |
304 | 326 | return $this->m_wikivalue; |
305 | 327 | } |
306 | 328 | |
— | — | @@ -330,6 +352,7 @@ |
331 | 353 | * Gregorian calendar and using the astronomical year numbering (0 means 1 BC). |
332 | 354 | */ |
333 | 355 | public function getYear() { |
| 356 | + $this->unstub(); |
334 | 357 | return $this->m_year; |
335 | 358 | } |
336 | 359 | |
— | — | @@ -341,6 +364,7 @@ |
342 | 365 | * also be set to FALSE to detect this situation. |
343 | 366 | */ |
344 | 367 | public function getMonth($default = 1) { |
| 368 | + $this->unstub(); |
345 | 369 | return ($this->m_month != false)?$this->m_month:$default; |
346 | 370 | } |
347 | 371 | |
— | — | @@ -351,6 +375,7 @@ |
352 | 376 | * also be set to FALSE to detect this situation. |
353 | 377 | */ |
354 | 378 | public function getDay($default = 1) { |
| 379 | + $this->unstub(); |
355 | 380 | return ($this->m_day != false)?$this->m_day:$default; |
356 | 381 | } |
357 | 382 | |
— | — | @@ -363,6 +388,7 @@ |
364 | 389 | * also be set to FALSE to detect this situation. |
365 | 390 | */ |
366 | 391 | public function getTimeString($default = '00:00:00') { |
| 392 | + $this->unstub(); |
367 | 393 | return ($this->m_time != false)?$this->normalizeTimeValue($this->m_time):$default; |
368 | 394 | } |
369 | 395 | |
— | — | @@ -438,7 +464,7 @@ |
439 | 465 | * grater or equal to -4712 (4713 BC), then (something that is closely inspired by) the Julian Day |
440 | 466 | * (JD) is computed. The JD has the form XXXX.YYYY where XXXX is the number of days having elapsed since |
441 | 467 | * 4713 BC and YYYY is the elapsed time of the day as fraction of 1. See http://en.wikipedia.org/wiki/Julian_day |
442 | | - * If the year is before -4713, then the computed number XXXX.YYYY has the following form: XXXX is |
| 468 | + * If the year is before -4713, then the computed number XXXX.YYYY has the following form: XXXX is |
443 | 469 | * the number of years BC and YYYY represents the elapsed days of the year as fraction of 1. This |
444 | 470 | * enables even large negative dates using 32bit floats. |
445 | 471 | * |
— | — | @@ -492,7 +518,7 @@ |
493 | 519 | $minutes = intval($time / 60); |
494 | 520 | $seconds = intval($time - $minutes * 60); |
495 | 521 | |
496 | | - $this->m_time = $this->normalizeValue($hours).":".$this->normalizeValue($minutes).":".$this->normalizeValue($seconds); |
| 522 | + $this->m_time = $this->normalizeValue($hours).":".$this->normalizeValue($minutes).":".$this->normalizeValue($seconds); |
497 | 523 | } |
498 | 524 | |
499 | 525 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * @defgroup SMW Semantic MediaWiki |
16 | 16 | */ |
17 | 17 | |
18 | | -define('SMW_VERSION','1.5b-SVN'); |
| 18 | +define('SMW_VERSION','1.5c-SVN'); |
19 | 19 | |
20 | 20 | // constants for displaying the factbox |
21 | 21 | define('SMW_FACTBOX_HIDDEN', 1); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | */ |
41 | 41 | static public function makePage($title, $namespace, $sortkey = '', $interwiki = '') { |
42 | 42 | $page = new SMWWikiPageValue('_wpg'); |
43 | | - $page->setValues($title,$namespace,false,$interwiki,$sortkey); |
| 43 | + $page->setDBkeys(array($title,$namespace,$interwiki,$sortkey)); |
44 | 44 | return $page; |
45 | 45 | } |
46 | 46 | |
— | — | @@ -97,47 +97,72 @@ |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
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 | | - } |
| 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 | 107 | |
108 | | - protected function unstub() { |
109 | | - if (is_array($this->m_stubdata)) { |
110 | | - global $wgContLang; |
111 | | - $this->m_dbkeyform = $this->m_stubdata[0]; |
112 | | - $this->m_namespace = $this->m_stubdata[1]; |
113 | | - $this->m_interwiki = $this->m_stubdata[3]; |
114 | | - $this->m_sortkey = $this->m_stubdata[4]; |
115 | | - $this->m_textform = str_replace('_', ' ', $this->m_dbkeyform); |
116 | | - if ($this->m_interwiki == '') { |
117 | | - $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform); |
118 | | - $this->m_prefixedtext = $this->m_title->getPrefixedText(); |
119 | | - } else { // interwiki title objects must be built from full input texts |
120 | | - $nstext = $wgContLang->getNSText($this->m_namespace); |
121 | | - $this->m_prefixedtext = $this->m_interwiki . ($this->m_interwiki != ''?':':'') . |
122 | | - $nstext . ($nstext != ''?':':'') . $this->m_textform; |
123 | | - $this->m_title = Title::newFromText($this->m_prefixedtext); |
124 | | - } |
125 | | - $this->m_caption = $this->m_prefixedtext; |
126 | | - $this->m_value = $this->m_prefixedtext; |
127 | | - if ($this->m_stubdata[2] === NULL) { |
128 | | - $this->m_id = 0; |
129 | | - $linkCache =& LinkCache::singleton(); |
130 | | - $linkCache->addBadLinkObj($this->m_title); // prefill link cache, save lookups |
131 | | - } elseif ($this->m_stubdata[2] === false) { |
132 | | - $this->m_id = false; |
133 | | - } else { |
134 | | - $this->m_id = $this->m_stubdata[2]; |
135 | | - $linkCache =& LinkCache::singleton(); |
136 | | - $linkCache->addGoodLinkObj($this->m_id, $this->m_title); // prefill link cache, save lookups |
137 | | - } |
138 | | - $this->m_stubdata = false; |
| 108 | + protected function parseDBkeys($args) { |
| 109 | + global $wgContLang; |
| 110 | + $this->m_dbkeyform = $args[0]; |
| 111 | + $this->m_namespace = array_key_exists(1,$args)?$args[1]:$this->m_fixNamespace; |
| 112 | + $this->m_interwiki = array_key_exists(2,$args)?$args[2]:''; |
| 113 | + $this->m_sortkey = array_key_exists(3,$args)?$args[3]:''; |
| 114 | + $this->m_textform = str_replace('_', ' ', $this->m_dbkeyform); |
| 115 | + if ($this->m_interwiki == '') { |
| 116 | + $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform); |
| 117 | + $this->m_prefixedtext = $this->m_title->getPrefixedText(); |
| 118 | + } else { // interwiki title objects must be built from full input texts |
| 119 | + $nstext = $wgContLang->getNSText($this->m_namespace); |
| 120 | + $this->m_prefixedtext = $this->m_interwiki . ($this->m_interwiki != ''?':':'') . |
| 121 | + $nstext . ($nstext != ''?':':'') . $this->m_textform; |
| 122 | + $this->m_title = Title::newFromText($this->m_prefixedtext); |
139 | 123 | } |
| 124 | + $this->m_caption = $this->m_prefixedtext; |
| 125 | + $this->m_value = $this->m_prefixedtext; |
| 126 | + $this->m_id = false; |
| 127 | + if ( ($this->m_fixNamespace != NS_MAIN) && ( $this->m_fixNamespace != $this->m_namespace) ) { |
| 128 | + wfLoadExtensionMessages('SemanticMediaWiki'); |
| 129 | + $this->addError(wfMsgForContent('smw_notitle', $this->m_caption)); |
| 130 | + } |
140 | 131 | } |
141 | 132 | |
| 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 | + |
142 | 167 | public function getShortWikiText($linked = NULL) { |
143 | 168 | $this->unstub(); |
144 | 169 | if ( ($linked === NULL) || ($linked === false) || (!$this->isValid()) || ($this->m_caption == '') ) { |
— | — | @@ -196,9 +221,14 @@ |
197 | 222 | } |
198 | 223 | } |
199 | 224 | |
200 | | - public function getXSDValue() { |
| 225 | +// public function getXSDValue() { |
| 226 | +// $this->unstub(); |
| 227 | +// return $this->m_dbkeyform; |
| 228 | +// } |
| 229 | + |
| 230 | + public function getDBkeys() { |
201 | 231 | $this->unstub(); |
202 | | - return $this->m_dbkeyform; |
| 232 | + return array($this->m_dbkeyform, $this->m_namespace, $this->m_interwiki, $this->getSortkey()); |
203 | 233 | } |
204 | 234 | |
205 | 235 | public function getWikiValue() { |
— | — | @@ -224,7 +254,7 @@ |
225 | 255 | |
226 | 256 | protected function getServiceLinkParams() { |
227 | 257 | $this->unstub(); |
228 | | - // Create links to mapping services based on a wiki-editable message. The parameters |
| 258 | + // Create links to mapping services based on a wiki-editable message. The parameters |
229 | 259 | // available to the message are: |
230 | 260 | // $1: urlencoded article name (no namespace) |
231 | 261 | return array(rawurlencode(str_replace('_',' ',$this->m_dbkeyform))); |
— | — | @@ -370,21 +400,23 @@ |
371 | 401 | * |
372 | 402 | * @todo Rethink our standard set interfaces for datavalues to make wikipage |
373 | 403 | * fit better with the rest. |
| 404 | + * @deprecated Use setDBkeys() |
374 | 405 | */ |
375 | 406 | public function setValues($dbkey, $namespace, $id = false, $interwiki = '', $sortkey = '') { |
376 | | - $this->setXSDValue($dbkey,''); // just used to trigger standard parent class methods! |
377 | | - if ( ($this->m_fixNamespace != NS_MAIN) && ( $this->m_fixNamespace != $namespace) ) { |
378 | | - wfLoadExtensionMessages('SemanticMediaWiki'); |
379 | | - $this->addError(wfMsgForContent('smw_notitle', str_replace('_',' ',$dbkey))); |
380 | | - } |
381 | | - $this->m_stubdata = array($dbkey, $namespace, $id, $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); |
382 | 414 | } |
383 | 415 | |
384 | 416 | /** |
385 | 417 | * Init this data value object based on a given Title object. |
386 | 418 | */ |
387 | 419 | public function setTitle($title) { |
388 | | - $this->setValues($title->getDBkey(), $title->getNamespace(), false, $title->getInterwiki()); |
| 420 | + $this->setDBkeys(array($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), '')); |
389 | 421 | $this->m_title = $title; |
390 | 422 | } |
391 | 423 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * types of properties (n-ary or binary). |
11 | 11 | * Two main use-cases exist for this class: |
12 | 12 | * - to parse and format a use-provided string in a rather tolerant way |
13 | | - * - to efficiently be generated from XSD values and to provide according |
| 13 | + * - to efficiently be generated from XSD values and to provide according |
14 | 14 | * wiki values, in order to support speedy creation of datavalues in |
15 | 15 | * SMWDataValueFactory. |
16 | 16 | * |
— | — | @@ -41,12 +41,18 @@ |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | | - protected function parseXSDValue($value, $unit) { |
46 | | - $this->m_xsdvalue = $value; // lazy parsing |
| 45 | +// protected function parseXSDValue($value, $unit) { |
| 46 | +// $this->m_xsdvalue = $value; // lazy parsing |
| 47 | +// $this->m_isalias = false; |
| 48 | +// } |
| 49 | + |
| 50 | + protected function parseDBkeys($args) { |
| 51 | + $this->m_xsdvalue = $args[0]; // lazy parsing |
47 | 52 | $this->m_isalias = false; |
48 | 53 | } |
49 | 54 | |
50 | 55 | public function getShortWikiText($linked = NULL) { |
| 56 | + $this->unstub(); |
51 | 57 | if ( ($linked === NULL) || ($linked === false) || ($this->m_caption === '') ) { |
52 | 58 | if ($this->m_caption !== false) { |
53 | 59 | return $this->m_caption; |
— | — | @@ -82,6 +88,7 @@ |
83 | 89 | } |
84 | 90 | |
85 | 91 | public function getShortHTMLText($linker = NULL) { |
| 92 | + $this->unstub(); |
86 | 93 | if ( ($linker === NULL) || ($linker === false) || ($this->m_caption === '') ) { |
87 | 94 | if ($this->m_caption !== false) { |
88 | 95 | return htmlspecialchars($this->m_caption); |
— | — | @@ -117,6 +124,7 @@ |
118 | 125 | } |
119 | 126 | |
120 | 127 | public function getLongWikiText($linked = NULL) { |
| 128 | + $this->unstub(); |
121 | 129 | if ( ($linked === NULL) || ($linked === false) ) { |
122 | 130 | return str_replace('_',' ',implode(', ', $this->getTypeLabels())); |
123 | 131 | } else { |
— | — | @@ -144,6 +152,7 @@ |
145 | 153 | } |
146 | 154 | |
147 | 155 | public function getLongHTMLText($linker = NULL) { |
| 156 | + $this->unstub(); |
148 | 157 | if ( ($linker === NULL) || ($linker === false) ) { |
149 | 158 | return str_replace('_',' ',implode(', ', $this->getTypeLabels())); |
150 | 159 | } else { |
— | — | @@ -160,7 +169,7 @@ |
161 | 170 | if ($id{0} == '_') { // builtin |
162 | 171 | wfLoadExtensionMessages('SemanticMediaWiki'); |
163 | 172 | SMWOutputs::requireHeadItem(SMW_HEADER_TOOLTIP); |
164 | | - $result .= '<span class="smwttinline"><span class="smwbuiltin">' . |
| 173 | + $result .= '<span class="smwttinline"><span class="smwbuiltin">' . |
165 | 174 | $linker->makeLinkObj( $title, $type) . '</span><span class="smwttcontent">' . |
166 | 175 | wfMsgForContent('smw_isknowntype') . '</span></span>'; |
167 | 176 | } else { |
— | — | @@ -171,7 +180,7 @@ |
172 | 181 | } |
173 | 182 | } |
174 | 183 | |
175 | | - public function getXSDValue() { |
| 184 | + public function getDBkeys() { |
176 | 185 | if ($this->isValid()) { |
177 | 186 | if ($this->m_xsdvalue === false) { |
178 | 187 | $first = true; |
— | — | @@ -185,12 +194,32 @@ |
186 | 195 | $this->m_xsdvalue .= SMWDataValueFactory::findTypeID($label); |
187 | 196 | } |
188 | 197 | } |
189 | | - return $this->m_xsdvalue; |
| 198 | + return array($this->m_xsdvalue); |
190 | 199 | } else { |
191 | | - return false; |
| 200 | + return array(false); |
192 | 201 | } |
193 | 202 | } |
194 | 203 | |
| 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 | + |
195 | 224 | public function getWikiValue() { |
196 | 225 | return implode('; ', $this->getTypeLabels()); |
197 | 226 | } |
— | — | @@ -203,6 +232,7 @@ |
204 | 233 | * Is this a simple unary type or some composed n-ary type? |
205 | 234 | */ |
206 | 235 | public function isUnary() { |
| 236 | + $this->unstub(); |
207 | 237 | if ($this->m_typelabels !== false) { |
208 | 238 | return (count($this->m_typelabels) == 1); |
209 | 239 | } elseif ($this->m_xsdvalue !== false) { |
— | — | @@ -226,6 +256,7 @@ |
227 | 257 | * explain entries in Special:Types that are found since they have pages. |
228 | 258 | */ |
229 | 259 | public function isAlias() { |
| 260 | + $this->unstub(); |
230 | 261 | return $this->m_isalias; |
231 | 262 | } |
232 | 263 | |
— | — | @@ -242,7 +273,7 @@ |
243 | 274 | } |
244 | 275 | |
245 | 276 | /** |
246 | | - * Retrieve type captions if needed. Can be done lazily. The captions |
| 277 | + * Retrieve type captions if needed. Can be done lazily. The captions |
247 | 278 | * are different from the labels if type aliases are used. |
248 | 279 | */ |
249 | 280 | public function getTypeCaptions() { |
— | — | @@ -258,6 +289,7 @@ |
259 | 290 | * Internal method to extract data from XSD-representation. Called lazily. |
260 | 291 | */ |
261 | 292 | protected function initTypeData() { |
| 293 | + $this->unstub(); |
262 | 294 | if ( ($this->m_typelabels === false) && ($this->m_xsdvalue !== false) ) { |
263 | 295 | $this->m_typelabels = array(); |
264 | 296 | $ids = explode(';', $this->m_xsdvalue); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php |
— | — | @@ -94,26 +94,22 @@ |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | | - protected function parseXSDValue($value, $unit) { |
99 | | - $types = $this->m_type->getTypeValues(); |
100 | | - // Note: we can always assume this to be the form that getXSDValue returns, |
101 | | - // unless it is complete junk. So be strict in parsing. |
102 | | - $values = explode(';', $value, $this->m_count); |
103 | | - $units = explode(';', $unit, $this->m_count); |
| 98 | + public function setDBkeys($args) { |
| 99 | + wfLoadExtensionMessages('SemanticMediaWiki'); |
| 100 | + $this->addError(wfMsgForContent('smw_parseerror')); |
| 101 | +// trigger_error("setDBkeys() cannot be used for initializing n-ary datavalues (SMWNAryValue). Use SMWNAryValue->setDVs() instead.", E_USER_WARNING); |
| 102 | +// debug_print_backtrace(); |
| 103 | +// die; |
| 104 | + } |
104 | 105 | |
105 | | - if (count($values) != $this->m_count) { |
106 | | - $this->addError('This is not an nary value.'); |
107 | | - return; |
108 | | - } |
| 106 | + /// 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 | + } |
109 | 111 | |
110 | | - $this->m_values = array(); |
111 | | - for ($i = 0; $i < $this->m_count; $i++) { |
112 | | - if ($values[$i] == '') { |
113 | | - $this->m_values[$i] = NULL; |
114 | | - } else { |
115 | | - $this->m_values[$i] = SMWDataValueFactory::newTypeObjectValue($types[$i], $values[$i]); |
116 | | - } |
117 | | - } |
| 112 | + /// No unstubbing required for this datatype. Contained data will be unstubbed if needed. |
| 113 | + protected function unstub() { |
118 | 114 | } |
119 | 115 | |
120 | 116 | public function getShortWikiText($linked = NULL) { |
— | — | @@ -170,20 +166,25 @@ |
171 | 167 | } |
172 | 168 | } |
173 | 169 | |
174 | | - public function getXSDValue() { |
175 | | - $first = true; |
176 | | - $result = ''; |
177 | | - foreach ($this->m_values as $value) { |
178 | | - if ($first) { |
179 | | - $first = false; |
180 | | - } else { |
181 | | - $result .= ';'; |
182 | | - } |
183 | | - if ($value !== NULL) { |
184 | | - $result .= $value->getXSDValue(); |
185 | | - } |
186 | | - } |
187 | | - return $result; |
| 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 | + /// @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 | + public function getDBkeys() { |
| 188 | + return array(); |
188 | 189 | } |
189 | 190 | |
190 | 191 | public function getWikiValue() { |
— | — | @@ -204,28 +205,28 @@ |
205 | 206 | return $result; |
206 | 207 | } |
207 | 208 | |
208 | | - public function getUnit() { |
209 | | - $first = true; |
210 | | - $result = ''; |
211 | | - $hasunit = false; |
212 | | - foreach ($this->m_values as $value) { |
213 | | - if ($first) { |
214 | | - $first = false; |
215 | | - } else { |
216 | | - $result .= ';'; |
217 | | - } |
218 | | - if ($value !== NULL) { |
219 | | - $result .= $value->getUnit(); |
220 | | - if ( (!$hasunit) && ($value->getUnit() != '') ) { |
221 | | - $hasunit = true; |
222 | | - } |
223 | | - } |
224 | | - } |
225 | | - if (!$hasunit) { |
226 | | - $result = ''; |
227 | | - } |
228 | | - return $result; |
229 | | - } |
| 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 | +// } |
230 | 231 | |
231 | 232 | public function getHash() { |
232 | 233 | $first = true; |