Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | protected $m_data; // data entries specifyin gwhat was requested (mixed type) |
29 | 29 | protected $m_typeid = false; // id of the datatype of the printed objects, if applicable |
30 | 30 | protected $m_outputformat; // output format string for formatting results, if applicable |
| 31 | + protected $m_hash = false; // cache your hash (currently useful since SMWQueryResult accesses the hash many times, might be dropped at some point) |
31 | 32 | |
32 | 33 | /** |
33 | 34 | * Create a print request. |
— | — | @@ -140,14 +141,16 @@ |
141 | 142 | * labels. |
142 | 143 | */ |
143 | 144 | public function getHash() { |
144 | | - $hash = $this->m_mode . ':' . $this->m_label . ':'; |
145 | | - if ($this->m_data instanceof Title) { |
146 | | - $hash .= $this->m_data->getPrefixedText() . ':'; |
147 | | - } elseif ($this->m_data instanceof SMWDataValue) { |
148 | | - $hash .= $this->m_data->getHash() . ':'; |
| 145 | + if ($this->m_hash === false) { |
| 146 | + $this->m_hash = $this->m_mode . ':' . $this->m_label . ':'; |
| 147 | + if ($this->m_data instanceof Title) { |
| 148 | + $this->m_hash .= $this->m_data->getPrefixedText() . ':'; |
| 149 | + } elseif ($this->m_data instanceof SMWDataValue) { |
| 150 | + $this->m_hash .= $this->m_data->getHash() . ':'; |
| 151 | + } |
| 152 | + $this->m_hash .= $this->m_outputformat . ':'; |
149 | 153 | } |
150 | | - $hash .= $this->m_outputformat . ':'; |
151 | | - return $hash; |
| 154 | + return $this->m_hash; |
152 | 155 | } |
153 | 156 | |
154 | 157 | /** |
— | — | @@ -297,8 +300,8 @@ |
298 | 301 | /** |
299 | 302 | * A dummy description that describes any object. Corresponds to |
300 | 303 | * owl:thing, the class of all abstract objects. Note that it is |
301 | | - * not used for datavalues of attributes in order to support type |
302 | | - * hinting in the API: descriptions of data are always |
| 304 | + * not used for datavalues of attributes in order to support type |
| 305 | + * hinting in the API: descriptions of data are always |
303 | 306 | * SMWValueDescription objects. |
304 | 307 | * @ingroup SMWQuery |
305 | 308 | */ |
— | — | @@ -322,7 +325,7 @@ |
323 | 326 | |
324 | 327 | /** |
325 | 328 | * Description of a single class as given by a wiki category, or of a disjunction |
326 | | - * of such classes. Corresponds to (disjunctions of) atomic classes in OWL and |
| 329 | + * of such classes. Corresponds to (disjunctions of) atomic classes in OWL and |
327 | 330 | * to (unions of) classes in RDF. |
328 | 331 | * @ingroup SMWQuery |
329 | 332 | */ |
— | — | @@ -405,7 +408,7 @@ |
406 | 409 | |
407 | 410 | |
408 | 411 | /** |
409 | | - * Description of a single class as described by a concept page in the wiki. Corresponds to |
| 412 | + * Description of a single class as described by a concept page in the wiki. Corresponds to |
410 | 413 | * classes in (the EL fragment of) OWL DL, and to some extent to tree-shaped queries in SPARQL. |
411 | 414 | * @ingroup SMWQuery |
412 | 415 | */ |
— | — | @@ -486,10 +489,10 @@ |
487 | 490 | /** |
488 | 491 | * Description of one data value, or of a range of data values. |
489 | 492 | * |
490 | | - * Technically this usually corresponds to nominal predicates or to unary |
491 | | - * concrete domain predicates in OWL which are parametrised by one constant |
| 493 | + * Technically this usually corresponds to nominal predicates or to unary |
| 494 | + * concrete domain predicates in OWL which are parametrised by one constant |
492 | 495 | * from the concrete domain. |
493 | | - * In RDF, concrete domain predicates that define ranges (like "greater or |
| 496 | + * In RDF, concrete domain predicates that define ranges (like "greater or |
494 | 497 | * equal to") are not directly available. |
495 | 498 | * @ingroup SMWQuery |
496 | 499 | */ |
— | — | @@ -548,8 +551,8 @@ |
549 | 552 | |
550 | 553 | /** |
551 | 554 | * Description of an ordered list of SMWDescription objects, used as |
552 | | - * values for some n-ary property. NULL values are to be used for |
553 | | - * unspecifed values. Corresponds to the built-in support for n-ary |
| 555 | + * values for some n-ary property. NULL values are to be used for |
| 556 | + * unspecifed values. Corresponds to the built-in support for n-ary |
554 | 557 | * properties, i.e. can be viewed as a macro in OWL and RDF. |
555 | 558 | * @ingroup SMWQuery |
556 | 559 | */ |
— | — | @@ -916,7 +919,7 @@ |
917 | 920 | * fits another (sub)description. |
918 | 921 | * |
919 | 922 | * Corresponds to existential quatification ("some" restriction) on concrete properties |
920 | | - * in OWL. In conjunctive queries (OWL) and SPARQL (RDF), it is represented by using |
| 923 | + * in OWL. In conjunctive queries (OWL) and SPARQL (RDF), it is represented by using |
921 | 924 | * variables in the object part of such properties. |
922 | 925 | * @ingroup SMWQuery |
923 | 926 | */ |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -304,8 +304,9 @@ |
305 | 305 | $cats = $this->m_store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST')); |
306 | 306 | } |
307 | 307 | $found = '0'; |
| 308 | + $prkey = $pr->getData()->getDBkey(); |
308 | 309 | foreach ($cats as $cat) { |
309 | | - if ($cat->getDBkey() == $pr->getData()->getDBkey()) { |
| 310 | + if ($cat->getDBkey() == $prkey) { |
310 | 311 | $found = '1'; |
311 | 312 | break; |
312 | 313 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -114,7 +114,6 @@ |
115 | 115 | function getSemanticData($subject, $filter = false) { |
116 | 116 | wfProfileIn("SMWSQLStore2::getSemanticData (SMW)"); |
117 | 117 | SMWSQLStore2::$in_getSemanticData++; |
118 | | - $db =& wfGetDB( DB_SLAVE ); |
119 | 118 | |
120 | 119 | if ( $subject instanceof Title ) { |
121 | 120 | $sid = $this->getSMWPageID($subject->getDBkey(),$subject->getNamespace(),$subject->getInterwiki()); |
— | — | @@ -156,6 +155,10 @@ |
157 | 156 | $this->m_sdstate[$sid] = $this->m_sdstate[$sid] | $tasks; |
158 | 157 | $tasks = $newtasks; |
159 | 158 | } |
| 159 | + |
| 160 | + if ($tasks != 0) { // fetch DB handler only when really needed! |
| 161 | + $db =& wfGetDB( DB_SLAVE ); |
| 162 | + } |
160 | 163 | if ( (count($this->m_semdata) > 20) && (SMWSQLStore2::$in_getSemanticData == 1) ) { |
161 | 164 | // prevent memory leak; |
162 | 165 | // It is not so easy to find the sweet spot between cache size and performance gains (both memory and time), |
— | — | @@ -333,18 +336,7 @@ |
334 | 337 | */ |
335 | 338 | function getPropertyValues($subject, SMWPropertyValue $property, $requestoptions = NULL, $outputformat = '') { |
336 | 339 | wfProfileIn("SMWSQLStore2::getPropertyValues (SMW)"); |
337 | | - if ($subject !== NULL) { |
338 | | - $sid = $this->getSMWPageID($subject->getDBkey(), $subject->getNamespace(),$subject->getInterwiki()); |
339 | | - } else { |
340 | | - $sid = 0; |
341 | | - } |
342 | | - $pid = $this->getSMWPropertyID($property); |
343 | | - if ( ( ($sid == 0) && ($subject !== NULL) ) || ($pid == 0)) { |
344 | | - wfProfileOut("SMWSQLStore2::getPropertyValues (SMW)"); |
345 | | - return array(); |
346 | | - } |
347 | | - |
348 | | - if ($sid != 0) { // subject given, use semantic data cache: |
| 340 | + if ($subject !== NULL) { // subject given, use semantic data cache: |
349 | 341 | $sd = $this->getSemanticData($subject,array($property->getTypeID())); |
350 | 342 | $result = $this->applyRequestOptions($sd->getPropertyValues($property),$requestoptions); |
351 | 343 | if ($outputformat != '') { // reformat cached values |
— | — | @@ -357,6 +349,11 @@ |
358 | 350 | $result = $newres; |
359 | 351 | } |
360 | 352 | } else { // no subject given, get all values for the given property |
| 353 | + $pid = $this->getSMWPropertyID($property); |
| 354 | + if ( $pid == 0 ) { |
| 355 | + wfProfileOut("SMWSQLStore2::getPropertyValues (SMW)"); |
| 356 | + return array(); |
| 357 | + } |
361 | 358 | $db =& wfGetDB( DB_SLAVE ); |
362 | 359 | $result = array(); |
363 | 360 | $mode = SMWSQLStore2::getStorageMode($property->getTypeID()); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php |
— | — | @@ -49,7 +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 |
| 53 | + private $prop_typevalue; // once calculated, remember the type of this property |
| 54 | + private $prop_typeid; // once calculated, remember the type of this property |
54 | 55 | |
55 | 56 | /** |
56 | 57 | * Static function for creating a new property object from a |
— | — | @@ -85,7 +86,8 @@ |
86 | 87 | * @todo Accept/enforce property namespace. |
87 | 88 | */ |
88 | 89 | protected function parseUserValue($value) { |
89 | | - $this->m_typevalue = NULL; |
| 90 | + $this->prop_typevalue = NULL; |
| 91 | + $this->prop_typeid = NULL; |
90 | 92 | if ($this->m_caption === false) { // always use this as caption |
91 | 93 | $this->m_caption = $value; |
92 | 94 | } |
— | — | @@ -109,7 +111,8 @@ |
110 | 112 | * internal property id accordingly. |
111 | 113 | */ |
112 | 114 | protected function parseDBkeys($args) { |
113 | | - $this->m_typevalue = NULL; |
| 115 | + $this->prop_typevalue = NULL; |
| 116 | + $this->prop_typeid = NULL; |
114 | 117 | SMWPropertyValue::initProperties(); |
115 | 118 | if ($args[0]{0} == '_') { // internal id, use as is (and hope it is still known) |
116 | 119 | $this->m_propertyid = $args[0]; |
— | — | @@ -221,7 +224,7 @@ |
222 | 225 | */ |
223 | 226 | public function getTypesValue() { |
224 | 227 | global $smwgPDefaultType; |
225 | | - if ($this->m_typevalue !== NULL) return $this->m_typevalue; |
| 228 | + if ($this->prop_typevalue !== NULL) return $this->prop_typevalue; |
226 | 229 | if (!$this->isValid()) { // errors in property, return invalid types value with same errors |
227 | 230 | $result = SMWDataValueFactory::newTypeIDValue('__typ'); |
228 | 231 | $result->setXSDValue('__err'); |
— | — | @@ -247,7 +250,7 @@ |
248 | 251 | $result->setXSDValue('_str'); |
249 | 252 | } |
250 | 253 | } |
251 | | - $this->m_typevalue = $result; |
| 254 | + $this->prop_typevalue = $result; |
252 | 255 | return $result; |
253 | 256 | } |
254 | 257 | |
— | — | @@ -255,8 +258,11 @@ |
256 | 259 | * Quickly get the type id of some property without necessarily making another datavalue. |
257 | 260 | */ |
258 | 261 | public function getTypeID() { |
259 | | - $type = $this->getTypesValue(); |
260 | | - return $type->isUnary()?$type->getXSDValue():'__nry'; |
| 262 | + if ($this->prop_typeid === NULL) { |
| 263 | + $type = $this->getTypesValue(); |
| 264 | + $this->prop_typeid = $type->isUnary()?end($type->getDBkeys()):'__nry'; |
| 265 | + } |
| 266 | + return $this->prop_typeid; |
261 | 267 | } |
262 | 268 | |
263 | 269 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -20,7 +20,6 @@ |
21 | 21 | */ |
22 | 22 | class SMWWikiPageValue extends SMWDataValue { |
23 | 23 | |
24 | | - protected $m_value = ''; // the raw string passed to that datavalue, rough version of prefixedtext |
25 | 24 | protected $m_textform = ''; // the isolated title as text |
26 | 25 | protected $m_dbkeyform = ''; // the isolated title in DB form |
27 | 26 | protected $m_interwiki = ''; // interwiki prefix or '', actually stored in SMWSQLStore2 |
— | — | @@ -77,10 +76,17 @@ |
78 | 77 | protected function parseUserValue($value) { |
79 | 78 | $value = ltrim(rtrim($value,' ]'),' ['); // support inputs like " [[Test]] " |
80 | 79 | if ($value != '') { |
81 | | - $this->m_value = $value; |
82 | | - $this->m_title = NULL; |
83 | | - $this->m_dbkeyform = NULL; |
84 | | - if ($this->getTitle() !== NULL) { |
| 80 | + $this->m_title = Title::newFromText($value, $this->m_fixNamespace); |
| 81 | + ///TODO: Escape the text so users can see any punctuation problems (bug 11666). |
| 82 | + if ($this->m_title === NULL) { |
| 83 | + wfLoadExtensionMessages('SemanticMediaWiki'); |
| 84 | + $this->addError(wfMsgForContent('smw_notitle', $value)); |
| 85 | + } elseif ( ($this->m_fixNamespace != NS_MAIN) && |
| 86 | + ($this->m_fixNamespace != $this->m_title->getNamespace()) ) { |
| 87 | + wfLoadExtensionMessages('SemanticMediaWiki'); |
| 88 | + $this->addError(wfMsgForContent('smw_wrong_namespace', $wgContLang->getNsText($this->m_fixNamespace))); |
| 89 | + } |
| 90 | + if ($this->m_title !== NULL) { |
85 | 91 | $this->m_textform = $this->m_title->getText(); |
86 | 92 | $this->m_dbkeyform = $this->m_title->getDBkey(); |
87 | 93 | $this->m_interwiki = $this->m_title->getInterwiki(); |
— | — | @@ -91,7 +97,7 @@ |
92 | 98 | if ($this->m_caption === false) { |
93 | 99 | $this->m_caption = $value; |
94 | 100 | } |
95 | | - } // else: no action, errors are reported by getTitle() |
| 101 | + } |
96 | 102 | } else { |
97 | 103 | wfLoadExtensionMessages('SemanticMediaWiki'); |
98 | 104 | $this->addError(wfMsgForContent('smw_notitle', $value)); |
— | — | @@ -102,49 +108,40 @@ |
103 | 109 | } |
104 | 110 | |
105 | 111 | protected function parseDBkeys($args) { |
106 | | - global $wgContLang; |
107 | 112 | $this->m_dbkeyform = $args[0]; |
108 | 113 | $this->m_namespace = array_key_exists(1,$args)?$args[1]:$this->m_fixNamespace; |
109 | 114 | $this->m_interwiki = array_key_exists(2,$args)?$args[2]:''; |
110 | 115 | $this->m_sortkey = array_key_exists(3,$args)?$args[3]:''; |
111 | 116 | $this->m_textform = str_replace('_', ' ', $this->m_dbkeyform); |
112 | | - if ($this->m_interwiki == '') { |
113 | | - $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform); |
114 | | - $this->m_prefixedtext = $this->m_title->getPrefixedText(); |
115 | | - } else { // interwiki title objects must be built from full input texts |
116 | | - $nstext = $wgContLang->getNSText($this->m_namespace); |
117 | | - $this->m_prefixedtext = $this->m_interwiki . ($this->m_interwiki != ''?':':'') . |
118 | | - $nstext . ($nstext != ''?':':'') . $this->m_textform; |
119 | | - $this->m_title = Title::newFromText($this->m_prefixedtext); |
120 | | - } |
121 | | - $this->m_caption = $this->m_prefixedtext; |
122 | | - $this->m_value = $this->m_prefixedtext; |
123 | 117 | $this->m_id = false; |
| 118 | + $this->m_title = NULL; |
| 119 | + $this->m_prefixedtext = false; |
| 120 | + $this->m_caption = false; |
124 | 121 | if ( ($this->m_fixNamespace != NS_MAIN) && ( $this->m_fixNamespace != $this->m_namespace) ) { |
125 | 122 | wfLoadExtensionMessages('SemanticMediaWiki'); |
126 | | - $this->addError(wfMsgForContent('smw_notitle', $this->m_caption)); |
| 123 | + $this->addError(wfMsgForContent('smw_notitle', $this->getPrefixedText())); |
127 | 124 | } |
128 | 125 | } |
129 | 126 | |
130 | 127 | public function getShortWikiText($linked = NULL) { |
131 | 128 | $this->unstub(); |
132 | | - if ( ($linked === NULL) || ($linked === false) || (!$this->isValid()) || ($this->m_caption == '') ) { |
133 | | - return $this->m_caption; |
| 129 | + if ( ($linked === NULL) || ($linked === false) || (!$this->isValid()) || ($this->m_caption === '') ) { |
| 130 | + return $this->getCaption(); |
134 | 131 | } else { |
135 | | - return '[[:' . str_replace("'", ''', $this->m_prefixedtext) . |
136 | | - ($this->m_fragment?"#$this->m_fragment":'') . '|' . $this->m_caption . ']]'; |
| 132 | + return '[[:' . str_replace("'", ''', $this->getPrefixedText()) . |
| 133 | + ($this->m_fragment?"#$this->m_fragment":'') . '|' . $this->getCaption() . ']]'; |
137 | 134 | } |
138 | 135 | } |
139 | 136 | |
140 | 137 | public function getShortHTMLText($linker = NULL) { |
141 | 138 | $this->unstub(); |
142 | | - if ( ($linker === NULL) || (!$this->isValid()) || ($this->m_caption == '') ) { |
143 | | - return htmlspecialchars($this->m_caption); |
| 139 | + if ( ($linker === NULL) || (!$this->isValid()) || ($this->m_caption === '') ) { |
| 140 | + return htmlspecialchars($this->getCaption()); |
144 | 141 | } else { |
145 | 142 | if ($this->getNamespace() == NS_MEDIA) { /// NOTE: this extra case is indeed needed |
146 | | - return $linker->makeMediaLinkObj($this->getTitle(), $this->m_caption); |
| 143 | + return $linker->makeMediaLinkObj($this->getTitle(), $this->getCaption()); |
147 | 144 | } else { |
148 | | - return $linker->makeLinkObj($this->getTitle(), $this->m_caption); |
| 145 | + return $linker->makeLinkObj($this->getTitle(), $this->getCaption()); |
149 | 146 | } |
150 | 147 | } |
151 | 148 | } |
— | — | @@ -160,11 +157,11 @@ |
161 | 158 | return $this->getErrorText(); |
162 | 159 | } |
163 | 160 | if ( ($linked === NULL) || ($linked === false) ) { |
164 | | - return $this->m_prefixedtext; |
| 161 | + return $this->getPrefixedText(); |
165 | 162 | } elseif ($this->m_namespace == NS_IMAGE) { // embed images instead of linking to their page |
166 | | - return '[[' . str_replace("'", ''', $this->m_prefixedtext) . '|' . $this->m_textform . '|frameless|border|text-top]]'; |
| 163 | + return '[[' . str_replace("'", ''', $this->getPrefixedText()) . '|' . $this->m_textform . '|frameless|border|text-top]]'; |
167 | 164 | } else { // this takes care of all other cases, esp. it is right for Media: |
168 | | - return '[[:' . str_replace("'", ''', $this->m_prefixedtext) . '|' . $this->m_textform . ']]'; |
| 165 | + return '[[:' . str_replace("'", ''', $this->getPrefixedText()) . '|' . $this->m_textform . ']]'; |
169 | 166 | } |
170 | 167 | } |
171 | 168 | |
— | — | @@ -174,7 +171,7 @@ |
175 | 172 | return $this->getErrorText(); |
176 | 173 | } |
177 | 174 | if ($linker === NULL) { |
178 | | - return htmlspecialchars($this->m_prefixedtext); |
| 175 | + return htmlspecialchars($this->getPrefixedText()); |
179 | 176 | } else { |
180 | 177 | if ($this->getNamespace() == NS_MEDIA) { // this extra case is really needed |
181 | 178 | return $linker->makeMediaLinkObj($this->getTitle(), $this->m_textform); |
— | — | @@ -195,16 +192,16 @@ |
196 | 193 | return $this->getText(); |
197 | 194 | } elseif ($this->m_namespace == NS_CATEGORY) { |
198 | 195 | // escape to enable use in links; todo: not generally required/suitable :-/ |
199 | | - return ':' . $this->m_prefixedtext; |
| 196 | + return ':' . $this->getPrefixedText(); |
200 | 197 | } else { |
201 | | - return $this->m_prefixedtext; |
| 198 | + return $this->getPrefixedText(); |
202 | 199 | } |
203 | 200 | } |
204 | 201 | |
205 | 202 | public function getHash() { |
206 | 203 | $this->unstub(); |
207 | 204 | if ($this->isValid()) { // assume that XSD value + unit say all |
208 | | - return $this->m_prefixedtext; |
| 205 | + return $this->getPrefixedText(); |
209 | 206 | } else { |
210 | 207 | return implode("\t", $this->m_errors); |
211 | 208 | } |
— | — | @@ -247,39 +244,21 @@ |
248 | 245 | |
249 | 246 | /** |
250 | 247 | * Return according Title object or NULL if no valid value was set. |
251 | | - * If using a base value, this method also checks whether the given namespace |
252 | | - * is appropriate. Whenever this method sets the title page, it also implements |
253 | | - * error reporting, i.e. the object might become invalid when calling this |
254 | | - * function. |
255 | 248 | */ |
256 | 249 | public function getTitle() { |
257 | | - global $wgContLang; |
258 | 250 | $this->unstub(); |
259 | | - if ($this->m_title === NULL){ |
260 | | - if ($this->m_dbkeyform != '') { |
| 251 | + if ($this->m_title === NULL) { |
| 252 | + if ($this->m_interwiki == '') { |
261 | 253 | $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform); |
262 | | - if ($this->m_title === NULL) { // should not normally happen, but anyway ... |
263 | | - wfLoadExtensionMessages('SemanticMediaWiki'); |
264 | | - $this->addError(wfMsgForContent('smw_notitle', $wgContLang->getNsText($this->m_namespace) . ':' . $this->m_dbkeyform)); |
265 | | - $this->m_dbkeyform = ''; |
266 | | - } |
267 | | - } elseif ($this->m_value != ''){ |
268 | | - $this->m_title = Title::newFromText($this->m_value, $this->m_fixNamespace); |
269 | | - ///TODO: Escape the text so users can see any punctuation problems (bug 11666). |
270 | | - if ($this->m_title === NULL) { |
271 | | - wfLoadExtensionMessages('SemanticMediaWiki'); |
272 | | - $this->addError(wfMsgForContent('smw_notitle', $this->m_value)); |
273 | | - } elseif ( ($this->m_fixNamespace != NS_MAIN) && |
274 | | - ($this->m_fixNamespace != $this->m_title->getNamespace()) ) { |
275 | | - wfLoadExtensionMessages('SemanticMediaWiki'); |
276 | | - $this->addError(wfMsgForContent('smw_wrong_namespace', $wgContLang->getNsText($this->m_fixNamespace))); |
277 | | - } |
278 | | - } else { |
279 | | - wfLoadExtensionMessages('SemanticMediaWiki'); |
280 | | - $this->addError(wfMsgForContent('smw_notitle', '')); |
281 | | - return NULL; //not possible to create title from empty string |
| 254 | + } else { // interwiki title objects must be built from full input texts |
| 255 | + $this->m_title = Title::newFromText($this->getPrefixedText()); |
282 | 256 | } |
283 | 257 | } |
| 258 | + if ($this->m_title === NULL) { // should not normally happen, but anyway ... |
| 259 | + wfLoadExtensionMessages('SemanticMediaWiki'); |
| 260 | + $this->addError(wfMsgForContent('smw_notitle', $wgContLang->getNsText($this->m_namespace) . ':' . $this->m_dbkeyform)); |
| 261 | + $this->m_dbkeyform = ''; |
| 262 | + } |
284 | 263 | return $this->m_title; |
285 | 264 | } |
286 | 265 | |
— | — | @@ -317,17 +296,28 @@ |
318 | 297 | * to use this method in places where only MediaWiki Title keys are allowed. |
319 | 298 | */ |
320 | 299 | public function getDBkey() { |
321 | | - return $this->getXSDValue(); |
| 300 | + $this->unstub(); |
| 301 | + return $this->m_dbkeyform; |
322 | 302 | } |
323 | 303 | |
324 | | - /** |
325 | | - * Get text label for this value. |
326 | | - */ |
| 304 | + /// Get text label for this value. |
327 | 305 | public function getText() { |
328 | 306 | $this->unstub(); |
329 | 307 | return str_replace('_',' ',$this->m_dbkeyform); |
330 | 308 | } |
331 | 309 | |
| 310 | + /// Get the prefixed text for this value, including a localised namespace prefix. |
| 311 | + public function getPrefixedText() { |
| 312 | + global $wgContLang; |
| 313 | + $this->unstub(); |
| 314 | + if ($this->m_prefixedtext === false) { |
| 315 | + $nstext = $wgContLang->getNSText($this->m_namespace); |
| 316 | + $this->m_prefixedtext = $this->m_interwiki . ($this->m_interwiki != ''?':':'') . |
| 317 | + $nstext . ($nstext != ''?':':'') . $this->m_textform; |
| 318 | + } |
| 319 | + return $this->m_prefixedtext; |
| 320 | + } |
| 321 | + |
332 | 322 | /** |
333 | 323 | * Get interwiki prefix or empty string. |
334 | 324 | */ |
— | — | @@ -360,6 +350,11 @@ |
361 | 351 | $this->m_title = $title; |
362 | 352 | } |
363 | 353 | |
| 354 | + /// Get the (default) caption for this value. |
| 355 | + protected function getCaption() { |
| 356 | + return $this->m_caption !== false?$this->m_caption:$this->getPrefixedText(); |
| 357 | + } |
| 358 | + |
364 | 359 | /** |
365 | 360 | * @deprecated Use setDBkeys() |
366 | 361 | */ |