r45792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45791‎ | r45792 | r45793 >
Date:12:14, 16 January 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Updated datavalue API to allow for a more effective stubbing mechanism and lazy loading. Some further improvements in SMWSQLStore2 cahce management.
Significantly reduced DB access and memory needs overall (varying depending on taks). See email to developer's list for details.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Bool.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_GeoCoords.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Import.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -20,15 +20,15 @@
2121 */
2222 abstract class SMWDataValue {
2323
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
2525 protected $m_caption; /// The text label to be used for output or false if none given
2626 protected $m_errors = array(); /// Array of error text messages
2727 protected $m_isset = false; /// True if a value was set.
2828 protected $m_typeid; /// The type id for this value object
2929 protected $m_infolinks = array(); /// Array of infolink objects
3030 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
3333
3434 private $m_hasssearchlink; /// used to control the addition of the standard search link
3535 private $m_hasservicelinks; /// used to control service link creation
@@ -52,6 +52,7 @@
5353 $this->m_isset = false;
5454 $this->m_hasssearchlink = false;
5555 $this->m_hasservicelinks = false;
 56+ $this->m_stubvalues = false;
5657 if ( is_string($caption) ) {
5758 $this->m_caption = trim($caption);
5859 } else {
@@ -79,20 +80,51 @@
8081 * Set the xsd value (and compute other representations if possible).
8182 * The given value is a string that was provided by getXSDValue() (all
8283 * implementations should support round-tripping).
 84+ * @deprecated Use setDBkeys().
8385 */
8486 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)');
8697 $this->m_errors = array(); // clear errors
8798 $this->m_infolinks = array(); // clear links
8899 $this->m_hasssearchlink = false;
89100 $this->m_hasservicelinks = false;
90101 $this->m_caption = false;
91 - $this->parseXSDValue($value, $unit);
 102+ $this->m_stubvalues = $args;
92103 $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)');
94109 }
95110
96111 /**
 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+ /**
97129 * Specify the property to which this value refers. Used to generate search links and
98130 * to find custom settings that relate to the property.
99131 */
@@ -119,7 +151,7 @@
120152 * depending on the datatype, and the service link message is usually crafted with a
121153 * particular datatype in mind.
122154 */
123 - function addServiceLinks() {
 155+ public function addServiceLinks() {
124156 if ($this->m_hasservicelinks) return;
125157 if ( ($this->m_property === NULL) || ($this->m_property->getWikiPageValue() === NULL) ) return; // no property known
126158 $args = $this->getServiceLinkParams();
@@ -155,7 +187,7 @@
156188
157189 /**
158190 * 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
160192 * will happen!
161193 */
162194 public function addError($error) {
@@ -179,18 +211,18 @@
180212 * Initialise the datavalue from the given value string and unit.
181213 * The format of both strings strictly corresponds to the output
182214 * of this implementation for getXSDValue() and getUnit().
 215+ * @deprecated Use parseDBkeys()
183216 */
184 - abstract protected function parseXSDValue($value, $unit);
 217+ protected function parseXSDValue($value, $unit) {
 218+ $this->parserDBkeys(array($value, $unit));
 219+ }
185220
186221 /**
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().
192225 */
193 - protected function unstub() {
194 - }
 226+ abstract protected function parseDBkeys($args);
195227
196228 ///// Get methods /////
197229
@@ -271,7 +303,7 @@
272304 }
273305
274306 /**
275 - * Return text serialisation of info links. Ensures more uniform layout
 307+ * Return text serialisation of info links. Ensures more uniform layout
276308 * throughout wiki (Factbox, Property pages, ...).
277309 */
278310 public function getInfolinkText($outputformat, $linker=NULL) {
@@ -308,13 +340,31 @@
309341 }
310342
311343 /**
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,
314346 * then this value is given in the unit provided by getUnit().
 347+ * @deprecated Use getDBkeys()
315348 */
316 - abstract public function getXSDValue();
 349+ public function getXSDValue() {
 350+ $keys = $this->getDBkeys();
 351+ return array_key_exists(0,$keys)?$keys[0]:'';
 352+ }
317353
318354 /**
 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+ /**
319369 * Return the plain wiki version of the value, or
320370 * FALSE if no such version is available. The returned
321371 * string suffices to reobtain the same DataValue
@@ -340,6 +390,7 @@
341391 * This string is a plain UTF-8 string without wiki or html markup.
342392 * Returns the empty string if no unit is given for the value.
343393 * Possibly overwritten by subclasses.
 394+ * @deprecated Use getDBkeys()
344395 */
345396 public function getUnit() {
346397 return ''; // empty unit
@@ -374,7 +425,7 @@
375426 }
376427
377428 /**
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
379430 * creating servicelinks. The number and content of values in the parameter array
380431 * may vary, depending on the concrete datatype.
381432 */
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_GeoCoords.php
@@ -139,7 +139,7 @@
140140 $this->setAngleValues('E',$angles);
141141 }
142142 if ( ($angles[0] !== false)||($curnum !== false)) { // unprocessed chunk, error
143 -
 143+
144144 }
145145
146146 if ($this->m_caption === false) {
@@ -148,19 +148,15 @@
149149 return true;
150150 }
151151
152 - protected function parseXSDValue($value, $unit) {
 152+ protected function parseDBkeys($args) {
153153 $this->m_lat = false;
154154 $this->m_long = false;
155155 $this->m_latparts = false;
156156 $this->m_longparts = false;
157157
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;
165161 }
166162
167163 public function getShortWikiText($linked = NULL) {
@@ -192,11 +188,13 @@
193189 return $this->getLongWikiText($linker);
194190 }
195191
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);
198195 }
199196
200197 public function getWikiValue(){
 198+ $this->unstub();
201199 return $this->m_wikivalue;
202200 }
203201
@@ -247,7 +245,7 @@
248246 case 'E': $this->m_long = $res; break;
249247 case 'W': $this->m_long = -1 * $res; break;
250248 }
251 - if ( (($direction == 'E') || ($direction == 'W')) &&
 249+ if ( (($direction == 'E') || ($direction == 'W')) &&
252250 (($this->m_long > 180) || ($this->m_long <= -180)) ) { // bring values back into [180, -180)
253251 $this->m_long += ($this->m_long<0)?(round(abs($this->m_long)/360)*360):(round($this->m_long/360)*-360);
254252 }
@@ -313,7 +311,7 @@
314312 }
315313
316314 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
318316 // available to the message are:
319317 // $1: latitude integer degrees, $2: longitude integer degrees
320318 // $3: latitude integer minutes, $4: longitude integer minutes
@@ -324,7 +322,7 @@
325323 $latvals = $this->getAngleValues(true);
326324 $longvals = $this->getAngleValues(false);
327325 return array($latvals[0], $longvals[0],
328 - $latvals[1], $longvals[1],
 326+ $latvals[1], $longvals[1],
329327 round($latvals[2]), round($longvals[2]),
330328 $latvals[3], $longvals[3],
331329 abs($this->m_lat), abs($this->m_long),
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php
@@ -13,7 +13,7 @@
1414 class SMWErrorValue extends SMWDataValue {
1515
1616 private $m_value;
17 -
 17+
1818 public function SMWErrorValue($errormsg = '', $uservalue = '', $caption = false) {
1919 $this->setUserValue($uservalue, $caption);
2020 if ($errormsg != '') $this->addError($errormsg);
@@ -27,8 +27,8 @@
2828 return true;
2929 }
3030
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
3333 }
3434
3535 public function setOutputFormat($formatstring){
@@ -36,6 +36,7 @@
3737 }
3838
3939 public function getShortWikiText($linked = NULL) {
 40+ $this->unstub();
4041 //TODO: support linking?
4142 return $this->m_caption;
4243 }
@@ -46,15 +47,17 @@
4748
4849 public function getLongWikiText($linked = NULL) {
4950 //TODO: support linking?
 51+ $this->unstub();
5052 return $this->getErrorText();
5153 }
5254
5355 public function getLongHTMLText($linker = NULL) {
 56+ $this->unstub();
5457 return $this->getErrorText();
5558 }
5659
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?)
5962 }
6063
6164 public function getWikiValue() {
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -33,7 +33,7 @@
3434 *
3535 * @note Regarding the use of interwiki links in the store, there is currently
3636 * 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
3838 * object positions. Most methods still use the given input interwiki text as a simple
3939 * way to filter out results that may be found if an interwiki object is given but a
4040 * local object of the same name exists. It is currently not planned to support things
@@ -49,9 +49,9 @@
5050 protected $m_semdata = array();
5151 /// Like SMWSQLStore2::m_semdata, but containing flags indicating completeness of the SMWSemanticData objs
5252 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;
5355
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 -
5656 /// Use pre-defined ids for Very Important Properties, avoiding frequent ID lookups for those
5757 private static $special_ids = array(
5858 '_TYPE' => 1,
@@ -156,8 +156,10 @@
157157 $this->m_sdstate[$sid] = $this->m_sdstate[$sid] | $tasks;
158158 $tasks = $newtasks;
159159 }
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.
162164 $this->m_semdata = array($sid => $this->m_semdata[$sid]);
163165 $this->m_sdstate = array($sid => $this->m_sdstate[$sid]);
164166 }
@@ -214,46 +216,64 @@
215217 }
216218 $res = $db->select( $from, $select, $where, 'SMW::getSemanticData' );
217219 while($row = $db->fetchObject($res)) {
218 - $dv = NULL;
 220+// $dv = NULL;
 221+ $valuekeys = false;
219222 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);
222226 }
223227 // The following cases are very similar, yet different in certain details:
224228 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,'');
229231 }
 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+// }
230237 } 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);
232240 } elseif ($task == SMW_SQL2_TEXT2) {
233 - $dv->setXSDValue($row->value, '');
 241+// $dv->setXSDValue($row->value, '');
 242+ $valuekeys = array($row->value);
234243 } elseif ($task == SMW_SQL2_SPEC2) {
235244 $pid = array_search($row->p_id, SMWSQLStore2::$special_ids);
236245 if ($pid != false) {
237 - $property = SMWPropertyValue::makeProperty($pid);
 246+// $property = SMWPropertyValue::makeProperty($pid);
 247+ $propertyname = $pid;
238248 } else { // this should be rare (only if some extension uses properties of "special" types)
239249 $proprow = $db->selectRow('smw_ids', array('smw_title'), array('smw_id' => $row->p_id), 'SMW::getSemanticData');
240250 /// 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;
242253 }
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);
245257 } 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,'','');
248262 } 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,'','');
251267 } 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);
255273 }
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);
258278 }
259279 }
260280 $db->freeResult($res);
@@ -312,7 +332,7 @@
313333 }
314334 $db->freeResult($res);
315335 }
316 -
 336+
317337 foreach ($properties as $name => $property) {
318338 $pdvs = $dvs[$name];
319339 foreach ($pdvs as $bnode => $values) {
@@ -871,7 +891,7 @@
872892 $db->insert( 'smw_redi2', array('s_title'=>$oldtitle->getDBkey(), 's_namespace'=>$oldtitle->getNamespace(), 'o_id'=>$sid), 'SMWSQLStore2::changeTitle');
873893 /// NOTE: this temporarily leaves existing redirects to oldtitle point to newtitle as well, which
874894 /// 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
876896 /// will hopefully be to fix the double redirect.
877897 } else {
878898 $this->deleteSemanticData(SMWWikiPageValue::makePageFromTitle($newtitle)); // should not have much effect, but let's be sure
@@ -885,17 +905,17 @@
886906 $db->update('smw_atts2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
887907 $db->update('smw_text2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
888908 $db->update('smw_inst2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
889 - if ( ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) &&
 909+ if ( ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) &&
890910 ( $newtitle->getNamespace() == SMW_NS_PROPERTY ) ) {
891911 $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
892912 } elseif ($oldtitle->getNamespace() == SMW_NS_PROPERTY) {
893913 $db->delete('smw_subs2', $cond_array, 'SMWSQLStore2::changeTitle');
894 - } elseif ( ( $oldtitle->getNamespace() == NS_CATEGORY ) &&
 914+ } elseif ( ( $oldtitle->getNamespace() == NS_CATEGORY ) &&
895915 ( $newtitle->getNamespace() == NS_CATEGORY ) ) {
896916 $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
897917 } elseif ($oldtitle->getNamespace() == NS_CATEGORY) {
898918 $db->delete('smw_subs2', $cond_array, 'SMWSQLStore2::changeTitle');
899 - } elseif ( ( $oldtitle->getNamespace() == SMW_NS_CONCEPT ) &&
 919+ } elseif ( ( $oldtitle->getNamespace() == SMW_NS_CONCEPT ) &&
900920 ( $newtitle->getNamespace() == SMW_NS_CONCEPT ) ) {
901921 $db->update('smw_conc2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
902922 $db->update('smw_conccache', array('o_id' => $tid), array('o_id' => $sid), 'SMWSQLStore2::changeTitle');
@@ -1016,7 +1036,7 @@
10171037 $options .= ' OFFSET ' . $requestoptions->offset;
10181038 }
10191039 $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') .
10211041 ' ON p_id=smw_id LEFT JOIN ' . $db->tableName('page') .
10221042 ' ON (page_namespace=' . SMW_NS_PROPERTY .
10231043 ' AND page_title=smw_title) WHERE smw_id > 50 AND page_id IS NULL GROUP BY smw_title' . $options,
@@ -1192,7 +1212,7 @@
11931213 function drop($verbose = true) {
11941214 $this->reportProgress("Deleting all database content and tables generated by SMW ...\n\n",$verbose);
11951215 $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',
11971217 'smw_subs2', 'smw_redi2', 'smw_ids', 'smw_inst2',
11981218 'smw_conc2');
11991219 foreach ($tables as $table) {
@@ -1700,7 +1720,7 @@
17011721 * If $canonical is set to true, redirects are taken into account to find the
17021722 * canonical alias ID for the given page.
17031723 * 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
17051725 * is empty.
17061726 * @note Using this with $canonical==false may make sense, especially when
17071727 * the title is a redirect target (we do not want chains of redirects).
@@ -1788,7 +1808,7 @@
17891809 * n-ary property. Bnodes are managed through the smw_ids table but will always
17901810 * have an empty smw_title, and smw_namespace being set to the parent object
17911811 * (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
17931813 * reuse an unused bnode before making a new one.
17941814 * @note Every call to this function, even if the same parameter id is used, returns
17951815 * a new bnode id!
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
@@ -51,7 +51,7 @@
5252 $value = 'http://' . $value;
5353 $parts[1] = $parts[0];
5454 $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]) )) {
5656 $this->addError(wfMsgForContent('smw_baduri', $value));
5757 return true;
5858 }
@@ -72,7 +72,7 @@
7373 // break;
7474 // }
7575 /// TODO: the remaining checks need improvement
76 -// // validate last part of URI (after #) if provided
 76+// // validate last part of URI (after #) if provided
7777 // $uri_ex = explode('#',$value);
7878 // $check2 = "@^[a-zA-Z0-9-_\%]+$@u"; ///FIXME: why only ascii symbols?
7979 // if(sizeof($uri_ex)>2 ){ // URI should only contain at most one '#'
@@ -125,18 +125,30 @@
126126 return true;
127127 }
128128
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;
132143 if ($this->m_mode == SMW_URI_MODE_EMAIL) {
133 - $this->m_url = 'mailto:' . $value;
 144+ $this->m_url = 'mailto:' . $this->m_value;
134145 } else {
135 - $this->m_url = $value;
 146+ $this->m_url = $this->m_value;
136147 }
137148 $this->m_uri = $this->m_url;
138149 }
139150
140151 public function getShortWikiText($linked = NULL) {
 152+ $this->unstub();
141153 if ( ($linked === NULL) || ($linked === false) || ($this->m_url == '') || ($this->m_caption == '') ) {
142154 return $this->m_caption;
143155 } else {
@@ -145,6 +157,7 @@
146158 }
147159
148160 public function getShortHTMLText($linker = NULL) {
 161+ $this->unstub();
149162 if (($linker === NULL) || (!$this->isValid()) || ($this->m_url == '') || ($this->m_caption == '')) {
150163 return $this->m_caption;
151164 } else {
@@ -174,16 +187,23 @@
175188 }
176189 }
177190
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);
180198 }
181199
182200 public function getWikiValue(){
 201+ $this->unstub();
183202 return $this->m_value;
184203 }
185204
186205 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
188208 // available to the message are:
189209 // $1: urlencoded version of URI/URL value (includes mailto: for emails)
190210 return array(rawurlencode($this->m_uri));
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php
@@ -9,7 +9,7 @@
1010 */
1111
1212 /**
13 - * Class for representing chunks of semantic data for one given
 13+ * Class for representing chunks of semantic data for one given
1414 * article (subject), similar what is typically displayed in the factbox.
1515 * This is a light-weight data container.
1616 * @ingroup SMW
@@ -19,6 +19,10 @@
2020 protected $propvals = array();
2121 /// Text keys and title objects.
2222 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();
2327 /// Boolean, stating whether the container holds any normal properties.
2428 protected $hasvisibleprops = false;
2529 /// Boolean, stating whether the container holds any displayable special properties (some are internal only without a display name).
@@ -45,7 +49,7 @@
4650
4751 /**
4852 * 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
5054 * subject is serialised, yielding a minimal stub data container after unserialisation. This is a little safer than serialising
5155 * nothing: if, for any reason, SMW should ever access an unserialised parser output, then the Semdata container will at least
5256 * look as if properly initialised (though empty).
@@ -67,6 +71,7 @@
6872 * Get the array of all properties that have stored values.
6973 */
7074 public function getProperties() {
 75+ $this->unstubProperties();
7176 ksort($this->properties,SORT_STRING);
7277 return $this->properties;
7378 }
@@ -75,6 +80,19 @@
7681 * Get the array of all stored values for some property.
7782 */
7883 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+ }
7997 if (array_key_exists($property->getXSDValue(), $this->propvals)) {
8098 return $this->propvals[$property->getXSDValue()];
8199 } else {
@@ -86,6 +104,7 @@
87105 * Return true if there are any visible properties.
88106 */
89107 public function hasVisibleProperties() {
 108+ $this->unstubProperties();
90109 return $this->hasvisibleprops;
91110 }
92111
@@ -94,12 +113,13 @@
95114 * be displayed.
96115 */
97116 public function hasVisibleSpecialProperties() {
 117+ $this->unstubProperties();
98118 return $this->hasvisiblespecs;
99119 }
100120
101121 /**
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.
104124 * @note Attention: there is no check whether the type of the given datavalue agrees
105125 * with what SMWDataValueFactory is producing (based on predefined property records and
106126 * the current DB content). Always use SMWDataValueFactory to produce fitting values!
@@ -127,7 +147,7 @@
128148
129149 /**
130150 * 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.
132152 */
133153 public function addPropertyValue($propertyname, SMWDataValue $value) {
134154 $propertykey = smwfNormalTitleDBKey($propertyname);
@@ -147,14 +167,61 @@
148168 }
149169
150170 /**
 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+ /**
151186 * Delete all data other than the subject.
152187 */
153188 public function clear() {
154189 $this->propvals = array();
155190 $this->properties = array();
 191+ $this->stubpropvals = array();
156192 $this->hasvisibleprops = false;
157193 $this->hasvisiblespecs = false;
158194 }
159195
 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+
160227 }
161228
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -33,12 +33,18 @@
3434 return true;
3535 }
3636
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]);
3944 $this->m_caption = $this->m_value; // this is our output text
4045 }
4146
4247 public function getShortWikiText($linked = NULL) {
 48+ $this->unstub();
4349 //TODO: Support linking?
4450 return $this->m_caption;
4551 }
@@ -69,15 +75,22 @@
7076 }
7177 }
7278
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);
7586 }
7687
7788 public function getWikiValue(){
 89+ $this->unstub();
7890 return $this->m_value;
7991 }
8092
8193 public function getInfolinks() {
 94+ $this->unstub();
8295 if ( ($this->m_typeid != '_txt') && ($this->m_typeid != '_cod') ) {
8396 return SMWDataValue::getInfolinks();
8497 }
@@ -85,6 +98,7 @@
8699 }
87100
88101 protected function getServiceLinkParams() {
 102+ $this->unstub();
89103 // Create links to mapping services based on a wiki-editable message. The parameters
90104 // available to the message are:
91105 // $1: urlencoded string
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Import.php
@@ -39,7 +39,7 @@
4040
4141 //browse list in smw_import_* for section
4242 list($onto_uri,$onto_name) = explode('|',array_shift($msglines),2);
43 -
 43+
4444 if ( ' ' == $onto_uri[0]) $onto_uri = mb_substr($onto_uri,1); // tolerate initial space
4545
4646 $this->m_uri = $onto_uri;
@@ -79,7 +79,7 @@
8080 // $this_ns = SMWParseData::getSMWData($parser)->getSubject()->getNamespace();
8181 // $error = NULL;
8282 // switch ($elemtype) {
83 -// case SMW_NS_PROPERTY: case NS_CATEGORY:
 83+// case SMW_NS_PROPERTY: case NS_CATEGORY:
8484 // if ($this_ns != $elemtype) {
8585 // $error = wfMsgForContent('smw_nonright_importtype',$value, $wgContLang->getNsText($elemtype));
8686 // }
@@ -92,14 +92,14 @@
9393 // case -1:
9494 // $error = wfMsgForContent('smw_no_importelement',$value);
9595 // }
96 -//
 96+//
9797 // if (NULL != $error) {
9898 // $this->addError($error);
9999 // return true;
100100 // }
101101 // }
102102
103 - //create String to be returned by getShort/LongWikiText
 103+ //create String to be returned by getShort/LongWikiText
104104 $this->m_wikilink = "[".$this->m_uri." ".$this->m_value."] (".$this->m_name.")";
105105
106106 //check whether caption is set, otherwise assign link statement to caption
@@ -110,8 +110,24 @@
111111 return true;
112112 }
113113
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);
116132 if (array_key_exists(0,$parts)) {
117133 $this->m_namespace = $parts[0];
118134 }
@@ -150,8 +166,12 @@
151167 }
152168 }
153169
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);
156176 }
157177
158178 public function getWikiValue(){
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php
@@ -16,13 +16,13 @@
1717 * if they are used only internally and never specified by or shown to
1818 * the user. Those will use their internal ID as "XSD value", and
1919 * 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
2121 * have an id). Functions are provided to check whether a property
2222 * is visible or user-defined, and to get the internal ID, if any.
2323 *
2424 * @note This datavalue is used only for representing properties and,
2525 * 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
2727 * things like sortkey.
2828 *
2929 * @author Markus Krötzsch
@@ -49,6 +49,8 @@
5050 /// If the property is associated with a wikipage, it is stored here. Otherwise NULL.
5151 protected $m_wikipage;
5252
 53+ private $m_typevalue; // once calculated, remember the type of this property
 54+
5355 /**
5456 * Static function for creating a new property object from a
5557 * propertyname (string) as a user might enter it.
@@ -73,7 +75,7 @@
7476 */
7577 static public function makeProperty($propertyid) {
7678 $property = new SMWPropertyValue('__pro');
77 - $property->setXSDValue($propertyid);
 79+ $property->setDBkeys(array($propertyid));
7880 return $property;
7981 }
8082
@@ -83,6 +85,7 @@
8486 * @todo Accept/enforce property namespace.
8587 */
8688 protected function parseUserValue($value) {
 89+ $this->m_typevalue = NULL;
8790 if ($this->m_caption === false) { // always use this as caption
8891 $this->m_caption = $value;
8992 }
@@ -100,35 +103,29 @@
101104 }
102105 }
103106
104 - protected function parseXSDValue($value, $unit) { // (ignore "unit")
105 - $this->m_stubdata = array($value);
106 - }
107 -
108107 /**
109108 * Extended parsing function to first check whether value is the id of a
110109 * pre-defined property, to resolve property names and aliases, and to set
111110 * internal property id accordingly.
112111 */
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]));
132119 }
 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+ }
133130 }
134131
135132 public function setCaption($caption) {
@@ -190,11 +187,11 @@
191188 }
192189
193190 /**
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.
195192 */
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);
199196 }
200197
201198 public function getWikiValue() {
@@ -224,6 +221,7 @@
225222 */
226223 public function getTypesValue() {
227224 global $smwgPDefaultType;
 225+ if ($this->m_typevalue !== NULL) return $this->m_typevalue;
228226 if (!$this->isValid()) { // errors in property, return invalid types value with same errors
229227 $result = SMWDataValueFactory::newTypeIDValue('__typ');
230228 $result->setXSDValue('__err');
@@ -249,6 +247,7 @@
250248 $result->setXSDValue('_str');
251249 }
252250 }
 251+ $this->m_typevalue = $result;
253252 return $result;
254253 }
255254
@@ -356,7 +355,7 @@
357356
358357 /**
359358 * 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
361360 * called from within the hook 'smwInitDatatypes'.
362361 */
363362 static public function registerPropertyAlias($id, $label) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php
@@ -14,7 +14,7 @@
1515 * Units work as follows: a unit is a string, but many such strings might
1616 * refer to the same unit of measurement. There is always one string, that
1717 * 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
1919 * avoidance. If no conversion information is given, any unit is its own ID.
2020 * In any case, units are /normalised/, i.e. given a more standardised meaning
2121 * before being processed. All units, IDs or otherwise, should be suitable for
@@ -74,20 +74,18 @@
7575 return true;
7676 }
7777
78 - protected function parseXSDValue($value, $unit) {
79 - // very lazy processing, lets store implementations prefetch more data, even if not needed
80 - $this->m_stubdata = array($value, $unit);
81 - }
 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+// }
8282
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;
9290 }
9391
9492 public function setOutputFormat($formatstring) {
@@ -164,10 +162,16 @@
165163 return $this->getLongWikiText($linker);
166164 }
167165
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() {
169173 $this->unstub();
170174 $this->convertToMainUnit();
171 - return $this->m_value;
 175+ return array($this->m_value, $this->m_unit);
172176 }
173177
174178 public function getWikiValue(){
@@ -182,9 +186,8 @@
183187 }
184188
185189 public function getUnit() {
186 - $this->unstub();
187 - $this->convertToMainUnit();
188 - return $this->m_unit;
 190+ $values = $this->getDBkeys();
 191+ return $values[1];
189192 }
190193
191194 public function getHash() {
@@ -199,7 +202,7 @@
200203
201204 protected function getServiceLinkParams() {
202205 $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
204207 // available to the message are:
205208 // $1: string of numerical value in English punctuation
206209 // $2: string of integer version of value, in English punctuation
@@ -237,7 +240,7 @@
238241 * Converts the current m_value and m_unit to the main unit, if possible.
239242 * This means, it changes the fileds m_value and m_unit accordingly, and
240243 * 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
242245 * first check if m_unitin is non-false. Also, it should be checked if the
243246 * value is valid before trying to calculate with its contents.
244247 *
@@ -253,8 +256,8 @@
254257 * The result is stored in $this->m_unitvalues. Again, any class that
255258 * requires effort for doing this should first check whether the array
256259 * 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
259262 * before trying to calculate with its contents.
260263 * This method also must call or implement convertToMainUnit().
261264 *
@@ -285,7 +288,7 @@
286289 }
287290
288291 /**
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
290293 * this datavalue.
291294 *
292295 * Overwritten by subclasses that support units.
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Bool.php
@@ -57,8 +57,13 @@
5858 return true;
5959 }
6060
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]);
6368 $this->m_caption = $this->m_stdcaption; // use default for this language
6469 }
6570
@@ -82,10 +87,12 @@
8388 }
8489
8590 public function getShortWikiText($linked = NULL) {
 91+ $this->unstub();
8692 return $this->m_caption;
8793 }
8894
8995 public function getShortHTMLText($linker = NULL) {
 96+ $this->unstub();
9097 return $this->m_caption;
9198 }
9299
@@ -105,15 +112,22 @@
106113 }
107114 }
108115
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');
111123 }
112124
113125 public function getWikiValue(){
 126+ $this->unstub();
114127 return $this->m_stdcaption;
115128 }
116129
117130 public function getNumericValue() {
 131+ $this->unstub();
118132 return $this->m_value?'1':'0';
119133 }
120134
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php
@@ -28,11 +28,20 @@
2929 return true;
3030 }
3131
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];
3746 }
3847
3948 protected function clear() {
@@ -44,6 +53,7 @@
4554 }
4655
4756 public function getShortWikiText($linked = NULL) {
 57+ $this->unstub();
4858 return $this->m_caption;
4959 }
5060
@@ -67,11 +77,17 @@
6878 }
6979 }
7080
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);
7388 }
7489
7590 public function getWikiValue(){
 91+ $this->unstub();
7692 return str_replace(array('&lt;','&gt;','&amp;'),array('<','>','&'), $this->m_concept);
7793 }
7894
@@ -97,7 +113,7 @@
98114 return NULL;
99115 }
100116 }
101 -
 117+
102118 public function descriptionToExpData($desc, &$exact) {
103119 if ( ($desc instanceof SMWConjunction) || ($desc instanceof SMWDisjunction) ) {
104120 $result = new SMWExpData(new SMWExpElement(''));
@@ -137,7 +153,7 @@
138154 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('owl', 'onProperty'),
139155 new SMWExpData(SMWExporter::getResourceElement($desc->getProperty())));
140156 $subdata = $this->descriptionToExpData($desc->getDescription(), $exact);
141 - if ( ($desc->getDescription() instanceof SMWValueDescription) &&
 157+ if ( ($desc->getDescription() instanceof SMWValueDescription) &&
142158 ($desc->getDescription()->getComparator() == SMW_CMP_EQ) ) {
143159 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('owl', 'hasValue'), $subdata);
144160 } else {
@@ -169,38 +185,33 @@
170186 return $result;
171187 }
172188
173 - /**
174 - * Special features for Type:Code formating.
175 - */
176 - protected function getCodeDisplay($value, $scroll = false) {
177 - $result = str_replace( array('<', '>', ' ', '://', '=', "'"), array('&lt;', '&gt;', '&nbsp;', '<!-- -->://<!-- -->', '&#x003D;', '&#x0027;'), $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().
184190 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;
190197 }
191198
192199 public function getDocu() {
 200+ $this->unstub();
193201 return $this->m_docu;
194202 }
195203
196204 public function getSize() {
 205+ $this->unstub();
197206 return $this->m_size;
198207 }
199208
200209 public function getDepth() {
 210+ $this->unstub();
201211 return $this->m_depth;
202212 }
203213
204214 public function getQueryFeatures() {
 215+ $this->unstub();
205216 return $this->m_queryfeatures;
206217 }
207218
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php
@@ -73,7 +73,7 @@
7474 protected $m_year = false; //Gregorian year, remains false if unspecified
7575 protected $m_time = false; //time, remains false if unspecified
7676 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)
7878 protected $m_timeannotation; //contains am or pm
7979 // The following are constant (array-valued constants are not supported, hence the decalration as variable):
8080 protected $m_months = array("January", "February", "March", "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December");
@@ -255,8 +255,19 @@
256256 }
257257 }
258258
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);
261272 $d = explode('/',$date,3);
262273 if (count($d)==3) list($this->m_year,$this->m_month,$this->m_day) = $d;
263274 elseif (count($d)==2) list($this->m_year,$this->m_month) = $d;
@@ -267,6 +278,7 @@
268279 }
269280
270281 public function getShortWikiText($linked = NULL) {
 282+ $this->unstub();
271283 return $this->m_caption;
272284 }
273285
@@ -287,19 +299,29 @@
288300 return $this->getLongWikiText($linker);
289301 }
290302
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();
292312 if ($this->m_xsdvalue === false) {
293313 $this->m_xsdvalue = $this->m_year."/".$this->m_month."/".$this->m_day."T".$this->m_time;
294314 }
295 - return $this->m_xsdvalue;
 315+ return array($this->m_xsdvalue);
296316 }
297317
298318 public function getNumericValue() {
 319+ $this->unstub();
299320 $this->createJD();
300321 return $this->m_jd;
301322 }
302323
303 - public function getWikiValue(){
 324+ public function getWikiValue() {
 325+ $this->unstub();
304326 return $this->m_wikivalue;
305327 }
306328
@@ -330,6 +352,7 @@
331353 * Gregorian calendar and using the astronomical year numbering (0 means 1 BC).
332354 */
333355 public function getYear() {
 356+ $this->unstub();
334357 return $this->m_year;
335358 }
336359
@@ -341,6 +364,7 @@
342365 * also be set to FALSE to detect this situation.
343366 */
344367 public function getMonth($default = 1) {
 368+ $this->unstub();
345369 return ($this->m_month != false)?$this->m_month:$default;
346370 }
347371
@@ -351,6 +375,7 @@
352376 * also be set to FALSE to detect this situation.
353377 */
354378 public function getDay($default = 1) {
 379+ $this->unstub();
355380 return ($this->m_day != false)?$this->m_day:$default;
356381 }
357382
@@ -363,6 +388,7 @@
364389 * also be set to FALSE to detect this situation.
365390 */
366391 public function getTimeString($default = '00:00:00') {
 392+ $this->unstub();
367393 return ($this->m_time != false)?$this->normalizeTimeValue($this->m_time):$default;
368394 }
369395
@@ -438,7 +464,7 @@
439465 * grater or equal to -4712 (4713 BC), then (something that is closely inspired by) the Julian Day
440466 * (JD) is computed. The JD has the form XXXX.YYYY where XXXX is the number of days having elapsed since
441467 * 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
443469 * the number of years BC and YYYY represents the elapsed days of the year as fraction of 1. This
444470 * enables even large negative dates using 32bit floats.
445471 *
@@ -492,7 +518,7 @@
493519 $minutes = intval($time / 60);
494520 $seconds = intval($time - $minutes * 60);
495521
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);
497523 }
498524
499525 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -14,7 +14,7 @@
1515 * @defgroup SMW Semantic MediaWiki
1616 */
1717
18 -define('SMW_VERSION','1.5b-SVN');
 18+define('SMW_VERSION','1.5c-SVN');
1919
2020 // constants for displaying the factbox
2121 define('SMW_FACTBOX_HIDDEN', 1);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -39,7 +39,7 @@
4040 */
4141 static public function makePage($title, $namespace, $sortkey = '', $interwiki = '') {
4242 $page = new SMWWikiPageValue('_wpg');
43 - $page->setValues($title,$namespace,false,$interwiki,$sortkey);
 43+ $page->setDBkeys(array($title,$namespace,$interwiki,$sortkey));
4444 return $page;
4545 }
4646
@@ -97,47 +97,72 @@
9898 }
9999 }
100100
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+// }
107107
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);
139123 }
 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+ }
140131 }
141132
 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+
142167 public function getShortWikiText($linked = NULL) {
143168 $this->unstub();
144169 if ( ($linked === NULL) || ($linked === false) || (!$this->isValid()) || ($this->m_caption == '') ) {
@@ -196,9 +221,14 @@
197222 }
198223 }
199224
200 - public function getXSDValue() {
 225+// public function getXSDValue() {
 226+// $this->unstub();
 227+// return $this->m_dbkeyform;
 228+// }
 229+
 230+ public function getDBkeys() {
201231 $this->unstub();
202 - return $this->m_dbkeyform;
 232+ return array($this->m_dbkeyform, $this->m_namespace, $this->m_interwiki, $this->getSortkey());
203233 }
204234
205235 public function getWikiValue() {
@@ -224,7 +254,7 @@
225255
226256 protected function getServiceLinkParams() {
227257 $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
229259 // available to the message are:
230260 // $1: urlencoded article name (no namespace)
231261 return array(rawurlencode(str_replace('_',' ',$this->m_dbkeyform)));
@@ -370,21 +400,23 @@
371401 *
372402 * @todo Rethink our standard set interfaces for datavalues to make wikipage
373403 * fit better with the rest.
 404+ * @deprecated Use setDBkeys()
374405 */
375406 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);
382414 }
383415
384416 /**
385417 * Init this data value object based on a given Title object.
386418 */
387419 public function setTitle($title) {
388 - $this->setValues($title->getDBkey(), $title->getNamespace(), false, $title->getInterwiki());
 420+ $this->setDBkeys(array($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), ''));
389421 $this->m_title = $title;
390422 }
391423
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php
@@ -9,7 +9,7 @@
1010 * types of properties (n-ary or binary).
1111 * Two main use-cases exist for this class:
1212 * - 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
1414 * wiki values, in order to support speedy creation of datavalues in
1515 * SMWDataValueFactory.
1616 *
@@ -41,12 +41,18 @@
4242 }
4343 }
4444
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
4752 $this->m_isalias = false;
4853 }
4954
5055 public function getShortWikiText($linked = NULL) {
 56+ $this->unstub();
5157 if ( ($linked === NULL) || ($linked === false) || ($this->m_caption === '') ) {
5258 if ($this->m_caption !== false) {
5359 return $this->m_caption;
@@ -82,6 +88,7 @@
8389 }
8490
8591 public function getShortHTMLText($linker = NULL) {
 92+ $this->unstub();
8693 if ( ($linker === NULL) || ($linker === false) || ($this->m_caption === '') ) {
8794 if ($this->m_caption !== false) {
8895 return htmlspecialchars($this->m_caption);
@@ -117,6 +124,7 @@
118125 }
119126
120127 public function getLongWikiText($linked = NULL) {
 128+ $this->unstub();
121129 if ( ($linked === NULL) || ($linked === false) ) {
122130 return str_replace('_',' ',implode(', ', $this->getTypeLabels()));
123131 } else {
@@ -144,6 +152,7 @@
145153 }
146154
147155 public function getLongHTMLText($linker = NULL) {
 156+ $this->unstub();
148157 if ( ($linker === NULL) || ($linker === false) ) {
149158 return str_replace('_',' ',implode(', ', $this->getTypeLabels()));
150159 } else {
@@ -160,7 +169,7 @@
161170 if ($id{0} == '_') { // builtin
162171 wfLoadExtensionMessages('SemanticMediaWiki');
163172 SMWOutputs::requireHeadItem(SMW_HEADER_TOOLTIP);
164 - $result .= '<span class="smwttinline"><span class="smwbuiltin">' .
 173+ $result .= '<span class="smwttinline"><span class="smwbuiltin">' .
165174 $linker->makeLinkObj( $title, $type) . '</span><span class="smwttcontent">' .
166175 wfMsgForContent('smw_isknowntype') . '</span></span>';
167176 } else {
@@ -171,7 +180,7 @@
172181 }
173182 }
174183
175 - public function getXSDValue() {
 184+ public function getDBkeys() {
176185 if ($this->isValid()) {
177186 if ($this->m_xsdvalue === false) {
178187 $first = true;
@@ -185,12 +194,32 @@
186195 $this->m_xsdvalue .= SMWDataValueFactory::findTypeID($label);
187196 }
188197 }
189 - return $this->m_xsdvalue;
 198+ return array($this->m_xsdvalue);
190199 } else {
191 - return false;
 200+ return array(false);
192201 }
193202 }
194203
 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+
195224 public function getWikiValue() {
196225 return implode('; ', $this->getTypeLabels());
197226 }
@@ -203,6 +232,7 @@
204233 * Is this a simple unary type or some composed n-ary type?
205234 */
206235 public function isUnary() {
 236+ $this->unstub();
207237 if ($this->m_typelabels !== false) {
208238 return (count($this->m_typelabels) == 1);
209239 } elseif ($this->m_xsdvalue !== false) {
@@ -226,6 +256,7 @@
227257 * explain entries in Special:Types that are found since they have pages.
228258 */
229259 public function isAlias() {
 260+ $this->unstub();
230261 return $this->m_isalias;
231262 }
232263
@@ -242,7 +273,7 @@
243274 }
244275
245276 /**
246 - * Retrieve type captions if needed. Can be done lazily. The captions
 277+ * Retrieve type captions if needed. Can be done lazily. The captions
247278 * are different from the labels if type aliases are used.
248279 */
249280 public function getTypeCaptions() {
@@ -258,6 +289,7 @@
259290 * Internal method to extract data from XSD-representation. Called lazily.
260291 */
261292 protected function initTypeData() {
 293+ $this->unstub();
262294 if ( ($this->m_typelabels === false) && ($this->m_xsdvalue !== false) ) {
263295 $this->m_typelabels = array();
264296 $ids = explode(';', $this->m_xsdvalue);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
@@ -94,26 +94,22 @@
9595 }
9696 }
9797
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+ }
104105
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+ }
109111
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() {
118114 }
119115
120116 public function getShortWikiText($linked = NULL) {
@@ -170,20 +166,25 @@
171167 }
172168 }
173169
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();
188189 }
189190
190191 public function getWikiValue() {
@@ -204,28 +205,28 @@
205206 return $result;
206207 }
207208
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+// }
230231
231232 public function getHash() {
232233 $first = true;

Status & tagging log