1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use SMW\ApplicationFactory; |
4
|
|
|
use SMW\DataValueFactory; |
5
|
|
|
use SMW\DIProperty; |
6
|
|
|
use SMW\Highlighter; |
7
|
|
|
use SMW\Message; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Objects of this class represent properties in SMW. |
11
|
|
|
* |
12
|
|
|
* This class represents both normal (user-defined) properties and |
13
|
|
|
* predefined ("special") properties. Predefined properties may still |
14
|
|
|
* have a standard label (and associated wiki article) and they will |
15
|
|
|
* behave just like user-defined properties in most cases (e.g. when |
16
|
|
|
* asking for a printout text, a link to the according page is produced). |
17
|
|
|
* It is possible that predefined properties have no visible label at all, |
18
|
|
|
* if they are used only internally and never specified by or shown to |
19
|
|
|
* the user. Those will use their internal ID as DB key, and |
20
|
|
|
* empty texts for most printouts. All other proeprties use their |
21
|
|
|
* canonical DB key (even if they are predefined and have an id). |
22
|
|
|
* Functions are provided to check whether a property is visible or |
23
|
|
|
* user-defined, and to get the internal ID, if any. |
24
|
|
|
* |
25
|
|
|
* @note This datavalue is used only for representing properties and, |
26
|
|
|
* possibly objects/values, but never for subjects (pages as such). Hence |
27
|
|
|
* it does not provide a complete Title-like interface, or support for |
28
|
|
|
* things like sortkey. |
29
|
|
|
* |
30
|
|
|
* @author Markus Krötzsch |
31
|
|
|
* @ingroup SMWDataValues |
32
|
|
|
*/ |
33
|
|
|
class SMWPropertyValue extends SMWDataValue { |
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Avoid the display of a tooltip |
37
|
|
|
*/ |
38
|
|
|
const OPT_NO_HIGHLIGHT = 'no.highlight'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Cache for wiki page value object associated to this property, or |
42
|
|
|
* null if no such page exists. Use getWikiPageValue() to get the data. |
43
|
|
|
* @var SMWWikiPageValue |
44
|
|
|
*/ |
45
|
|
|
protected $m_wikipage = null; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var array |
49
|
|
|
*/ |
50
|
|
|
protected $linkAttributes = array(); |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Cache for type value of this property, or null if not calculated yet. |
54
|
|
|
* @var SMWTypesValue |
55
|
|
|
*/ |
56
|
|
|
private $mPropTypeValue; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var DIProperty |
60
|
|
|
*/ |
61
|
|
|
private $inceptiveProperty = null; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @since 2.4 |
65
|
|
|
* |
66
|
|
|
* @param string $typeid |
67
|
|
|
*/ |
68
|
218 |
|
public function __construct( $typeid ) { |
69
|
218 |
|
parent::__construct( $typeid ); |
70
|
218 |
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Static function for creating a new property object from a |
74
|
|
|
* propertyname (string) as a user might enter it. |
75
|
|
|
* @note The resulting property object might be invalid if |
76
|
|
|
* the provided name is not allowed. An object is returned |
77
|
|
|
* in any case. |
78
|
|
|
* |
79
|
|
|
* @param string $propertyName |
|
|
|
|
80
|
|
|
* |
81
|
|
|
* @return SMWPropertyValue |
82
|
|
|
*/ |
83
|
131 |
|
static public function makeUserProperty( $propertyLabel ) { |
|
|
|
|
84
|
131 |
|
return DataValueFactory::getInstance()->newPropertyValueByLabel( $propertyLabel ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Static function for creating a new property object from a property |
89
|
|
|
* identifier (string) as it might be used internally. This might be |
90
|
|
|
* the DB key version of some property title text or the id of a |
91
|
|
|
* predefined property (such as '_TYPE'). |
92
|
|
|
* @note This function strictly requires an internal identifier, i.e. |
93
|
|
|
* predefined properties must be referred to by their ID, and '-' is |
94
|
|
|
* not supported for indicating inverses. |
95
|
|
|
* @note The resulting property object might be invalid if |
96
|
|
|
* the provided name is not allowed. An object is returned |
97
|
|
|
* in any case. |
98
|
|
|
*/ |
99
|
|
|
static public function makeProperty( $propertyid ) { |
|
|
|
|
100
|
|
|
$diProperty = new DIProperty( $propertyid ); |
101
|
|
|
$dvProperty = new SMWPropertyValue( '__pro' ); |
102
|
|
|
$dvProperty->setDataItem( $diProperty ); |
103
|
|
|
return $dvProperty; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* We use the internal wikipage object to store some of this objects data. |
108
|
|
|
* Clone it to make sure that data can be modified independently from the |
109
|
|
|
* original object's content. |
110
|
|
|
*/ |
111
|
1 |
|
public function __clone() { |
112
|
1 |
|
if ( !is_null( $this->m_wikipage ) ) { |
113
|
1 |
|
$this->m_wikipage = clone $this->m_wikipage; |
114
|
|
|
} |
115
|
1 |
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @note If the inceptive property and the property referenced in dataItem |
119
|
|
|
* are not equal then the dataItem represents the end target to which the |
120
|
|
|
* inceptive property has been redirected. |
121
|
|
|
* |
122
|
|
|
* @since 2.4 |
123
|
|
|
* |
124
|
|
|
* @return DIProperty |
125
|
|
|
*/ |
126
|
1 |
|
public function getInceptiveProperty() { |
127
|
1 |
|
return $this->inceptiveProperty; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Extended parsing function to first check whether value refers to pre-defined |
132
|
|
|
* property, resolve aliases, and set internal property id accordingly. |
133
|
|
|
* @todo Accept/enforce property namespace. |
134
|
|
|
*/ |
135
|
199 |
|
protected function parseUserValue( $value ) { |
136
|
199 |
|
$this->mPropTypeValue = null; |
137
|
199 |
|
$this->m_wikipage = null; |
138
|
|
|
|
139
|
199 |
|
if ( $this->m_caption === false ) { // always use this as caption |
140
|
199 |
|
$this->m_caption = $value; |
141
|
|
|
} |
142
|
|
|
|
143
|
199 |
|
list( $propertyName, $inverse ) = $this->doNormalizeUserValue( |
144
|
|
|
$value |
145
|
|
|
); |
146
|
|
|
|
147
|
199 |
|
$contentLanguage = $this->getOptionBy( self::OPT_CONTENT_LANGUAGE ); |
148
|
|
|
|
149
|
|
|
try { |
150
|
199 |
|
$this->m_dataitem = DIProperty::newFromUserLabel( $propertyName, $inverse, $contentLanguage ); |
|
|
|
|
151
|
2 |
|
} catch ( SMWDataItemException $e ) { // happens, e.g., when trying to sort queries by property "-" |
152
|
2 |
|
$this->addErrorMsg( array( 'smw_noproperty', $value ) ); |
153
|
2 |
|
$this->m_dataitem = new DIProperty( 'ERROR', false ); // just to have something |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
// @see the SMW_DV_PROV_DTITLE explanation |
157
|
199 |
|
if ( $this->isEnabledFeature( SMW_DV_PROV_DTITLE ) ) { |
158
|
|
|
$dataItem = ApplicationFactory::getInstance()->getPropertySpecificationLookup()->getPropertyFromDisplayTitle( |
159
|
|
|
$value |
160
|
|
|
); |
161
|
|
|
|
162
|
|
|
$this->m_dataitem = $dataItem ? $dataItem : $this->m_dataitem; |
163
|
|
|
} |
164
|
|
|
|
165
|
199 |
|
$this->inceptiveProperty = $this->m_dataitem; |
166
|
|
|
|
167
|
199 |
|
if ( $this->isEnabledFeature( SMW_DV_PROV_REDI ) ) { |
168
|
191 |
|
$this->m_dataitem = $this->m_dataitem->getRedirectTarget(); |
169
|
|
|
} |
170
|
199 |
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @see SMWDataValue::loadDataItem() |
174
|
|
|
* @param $dataitem SMWDataItem |
175
|
|
|
* @return boolean |
176
|
|
|
*/ |
177
|
32 |
|
protected function loadDataItem( SMWDataItem $dataItem ) { |
178
|
|
|
|
179
|
32 |
|
if ( $dataItem->getDIType() !== SMWDataItem::TYPE_PROPERTY ) { |
180
|
|
|
return false; |
181
|
|
|
} |
182
|
|
|
|
183
|
32 |
|
$this->inceptiveProperty = $dataItem; |
|
|
|
|
184
|
32 |
|
$this->m_dataitem = $dataItem; |
185
|
|
|
|
186
|
32 |
|
$this->mPropTypeValue = null; |
187
|
32 |
|
unset( $this->m_wikipage ); |
188
|
32 |
|
$this->m_caption = false; |
|
|
|
|
189
|
32 |
|
$this->linkAttributes = array(); |
190
|
|
|
|
191
|
32 |
|
return true; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @since 2.4 |
196
|
|
|
* |
197
|
|
|
* @param array $linkAttributes |
198
|
|
|
*/ |
199
|
1 |
|
public function setLinkAttributes( array $linkAttributes ) { |
200
|
1 |
|
$this->linkAttributes = $linkAttributes; |
201
|
|
|
|
202
|
1 |
|
if ( $this->getWikiPageValue() instanceof SMWDataValue ) { |
203
|
1 |
|
$this->m_wikipage->setLinkAttributes( $linkAttributes ); |
204
|
|
|
} |
205
|
1 |
|
} |
206
|
|
|
|
207
|
105 |
|
public function setCaption( $caption ) { |
208
|
105 |
|
parent::setCaption( $caption ); |
209
|
105 |
|
if ( $this->getWikiPageValue() instanceof SMWDataValue ) { // pass caption to embedded datavalue (used for printout) |
210
|
105 |
|
$this->m_wikipage->setCaption( $caption ); |
211
|
|
|
} |
212
|
105 |
|
} |
213
|
|
|
|
214
|
|
|
public function setOutputFormat( $formatstring ) { |
215
|
|
|
$this->m_outformat = $formatstring; |
216
|
|
|
if ( $this->getWikiPageValue() instanceof SMWDataValue ) { |
217
|
|
|
$this->m_wikipage->setOutputFormat( $formatstring ); |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
public function setInverse( $isinverse ) { |
222
|
|
|
return $this->m_dataitem = new DIProperty( $this->m_dataitem->getKey(), ( $isinverse == true ) ); |
|
|
|
|
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Return a wiki page value that can be used for displaying this |
227
|
|
|
* property, or null if no such wiki page exists (for predefined |
228
|
|
|
* properties without any label). |
229
|
|
|
* @return SMWWikiPageValue or null |
230
|
|
|
*/ |
231
|
109 |
|
public function getWikiPageValue() { |
232
|
|
|
|
233
|
109 |
|
if ( isset( $this->m_wikipage ) ) { |
234
|
69 |
|
return $this->m_wikipage; |
235
|
|
|
} |
236
|
|
|
|
237
|
109 |
|
$diWikiPage = $this->m_dataitem->getCanonicalDiWikiPage(); |
|
|
|
|
238
|
|
|
|
239
|
109 |
|
if ( $diWikiPage !== null ) { |
240
|
109 |
|
$this->m_wikipage = \SMW\DataValueFactory::getInstance()->newDataValueByItem( $diWikiPage, null, $this->m_caption ); |
|
|
|
|
241
|
109 |
|
$this->m_wikipage->setOutputFormat( $this->m_outformat ); |
242
|
109 |
|
$this->m_wikipage->setLinkAttributes( $this->linkAttributes ); |
|
|
|
|
243
|
109 |
|
$this->m_wikipage->setOptions( $this->getOptions() ); |
244
|
109 |
|
$this->addError( $this->m_wikipage->getErrors() ); |
245
|
|
|
} else { // should rarely happen ($value is only changed if the input $value really was a label for a predefined prop) |
246
|
|
|
$this->m_wikipage = null; |
247
|
|
|
} |
248
|
|
|
|
249
|
109 |
|
return $this->m_wikipage; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Return TRUE if this is a property that can be displayed, and not a pre-defined |
254
|
|
|
* property that is used only internally and does not even have a user-readable name. |
255
|
|
|
* @note Every user defined property is necessarily visible. |
256
|
|
|
*/ |
257
|
94 |
|
public function isVisible() { |
258
|
94 |
|
return $this->isValid() && ( $this->m_dataitem->isUserDefined() || $this->m_dataitem->getLabel() !== '' ); |
|
|
|
|
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @since 2.2 |
263
|
|
|
* |
264
|
|
|
* @return boolean |
265
|
|
|
*/ |
266
|
177 |
|
public function canUse() { |
267
|
177 |
|
return $this->isValid() && $this->m_dataitem->isUnrestricted(); |
|
|
|
|
268
|
|
|
} |
269
|
|
|
|
270
|
40 |
|
public function getShortWikiText( $linked = null ) { |
271
|
|
|
|
272
|
40 |
|
if ( $this->isVisible() ) { |
273
|
39 |
|
$wikiPageValue = $this->getWikiPageValue(); |
274
|
39 |
|
return is_null( $wikiPageValue ) ? '' : $this->highlightText( $wikiPageValue->getShortWikiText( $linked ) ); |
275
|
|
|
} |
276
|
|
|
|
277
|
1 |
|
return ''; |
278
|
|
|
} |
279
|
|
|
|
280
|
8 |
|
public function getShortHTMLText( $linked = null ) { |
281
|
|
|
|
282
|
8 |
|
if ( $this->isVisible() ) { |
283
|
8 |
|
$wikiPageValue = $this->getWikiPageValue(); |
284
|
8 |
|
return is_null( $wikiPageValue ) ? '' : $this->highlightText( $wikiPageValue->getShortHTMLText( $linked ), $linked ); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
return ''; |
288
|
|
|
} |
289
|
|
|
|
290
|
12 |
|
public function getLongWikiText( $linked = null ) { |
291
|
|
|
|
292
|
12 |
|
if ( $this->isVisible() ) { |
293
|
12 |
|
$wikiPageValue = $this->getWikiPageValue(); |
294
|
12 |
|
return is_null( $wikiPageValue ) ? '' : $this->highlightText( $wikiPageValue->getLongWikiText( $linked ) ); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
return ''; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
public function getLongHTMLText( $linked = null ) { |
301
|
|
|
|
302
|
|
|
if ( $this->isVisible() ) { |
303
|
|
|
$wikiPageValue = $this->getWikiPageValue(); |
304
|
|
|
return is_null( $wikiPageValue ) ? '' : $this->highlightText( $wikiPageValue->getLongHTMLText( $linked ), $linked ); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return ''; |
308
|
|
|
} |
309
|
|
|
|
310
|
68 |
|
public function getWikiValue() { |
311
|
|
|
|
312
|
68 |
|
if ( !$this->isVisible() ) { |
313
|
|
|
return ''; |
314
|
|
|
} |
315
|
|
|
|
316
|
68 |
|
if ( $this->getWikiPageValue() !== null && $this->getWikiPageValue()->getDisplayTitle() !== '' ) { |
317
|
1 |
|
return $this->getWikiPageValue()->getDisplayTitle(); |
318
|
|
|
} |
319
|
|
|
|
320
|
68 |
|
return $this->m_dataitem->getLabel(); |
|
|
|
|
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* If this property was not user defined, return the internal ID string referring to |
325
|
|
|
* that property. Otherwise return FALSE; |
326
|
|
|
*/ |
327
|
|
|
public function getPropertyID() { |
328
|
|
|
return $this->m_dataitem->isUserDefined() ? false : $this->m_dataitem->getKey(); |
|
|
|
|
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* Return an SMWTypesValue object representing the datatype of this |
333
|
|
|
* property. |
334
|
|
|
* @deprecated Types values are not a good way to exchange SMW type information. They are for input only. Use getPropertyTypeID() if you want the type id. This method will vanish in SMW 1.7. |
335
|
|
|
*/ |
336
|
|
|
public function getTypesValue() { |
337
|
|
|
$result = SMWTypesValue::newFromTypeId( $this->getPropertyTypeID() ); |
338
|
|
|
if ( !$this->isValid() ) { |
339
|
|
|
$result->addError( $this->getErrors() ); |
340
|
|
|
} |
341
|
|
|
return $result; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* Convenience method to find the type id of this property. Most callers |
346
|
|
|
* should rather use DIProperty::findPropertyTypeId() directly. Note |
347
|
|
|
* that this is not the same as getTypeID(), which returns the id of |
348
|
|
|
* this property datavalue. |
349
|
|
|
* |
350
|
|
|
* @return string |
351
|
|
|
*/ |
352
|
4 |
|
public function getPropertyTypeID() { |
353
|
4 |
|
if ( $this->isValid() ) { |
354
|
4 |
|
return $this->m_dataitem->findPropertyTypeId(); |
|
|
|
|
355
|
|
|
} else { |
356
|
|
|
return '__err'; |
357
|
|
|
} |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Create special highlighting for hinting at special properties. |
362
|
|
|
*/ |
363
|
51 |
|
protected function highlightText( $text, $linker = null ) { |
364
|
|
|
|
365
|
51 |
|
if ( $this->getOptionBy( self::OPT_NO_HIGHLIGHT ) === true ) { |
366
|
2 |
|
return $text; |
367
|
|
|
} |
368
|
|
|
|
369
|
51 |
|
$propertySpecificationLookup = ApplicationFactory::getInstance()->getPropertySpecificationLookup(); |
370
|
|
|
|
371
|
51 |
|
if ( ( $content = $propertySpecificationLookup->getPropertyDescriptionBy( $this->m_dataitem, $linker ) ) !== '' || !$this->m_dataitem->isUserDefined() ) { |
|
|
|
|
372
|
|
|
|
373
|
14 |
|
$highlighter = Highlighter::factory( Highlighter::TYPE_PROPERTY ); |
374
|
14 |
|
$highlighter->setContent( array ( |
375
|
14 |
|
'userDefined' => $this->m_dataitem->isUserDefined(), |
|
|
|
|
376
|
14 |
|
'caption' => $text, |
377
|
14 |
|
'content' => $content !== '' ? $content : wfMessage( 'smw_isspecprop' )->text() |
378
|
|
|
) ); |
379
|
|
|
|
380
|
14 |
|
return $highlighter->getHtml(); |
381
|
|
|
} |
382
|
|
|
|
383
|
46 |
|
return $text; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* A function for registering/overwriting predefined properties for SMW. Should be called from |
388
|
|
|
* within the hook 'smwInitProperties'. Ids should start with three underscores "___" to avoid |
389
|
|
|
* current and future confusion with SMW built-ins. |
390
|
|
|
* |
391
|
|
|
* @deprecated Use DIProperty::registerProperty(). Will vanish before SMW 1.7. |
392
|
|
|
*/ |
393
|
|
|
static public function registerProperty( $id, $typeid, $label = false, $show = false ) { |
|
|
|
|
394
|
|
|
DIProperty::registerProperty( $id, $typeid, $label, $show ); |
|
|
|
|
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Add a new alias label to an existing datatype id. Note that every ID should have a primary |
399
|
|
|
* label, either provided by SMW or registered with registerDatatype. This function should be |
400
|
|
|
* called from within the hook 'smwInitDatatypes'. |
401
|
|
|
* |
402
|
|
|
* @deprecated Use DIProperty::registerPropertyAlias(). Will vanish before SMW 1.7. |
403
|
|
|
*/ |
404
|
|
|
static public function registerPropertyAlias( $id, $label ) { |
|
|
|
|
405
|
|
|
DIProperty::registerPropertyAlias( $id, $label ); |
|
|
|
|
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* @see DIProperty::isUserDefined() |
410
|
|
|
* |
411
|
|
|
* @deprecated since 1.6 |
412
|
|
|
*/ |
413
|
|
|
public function isUserDefined() { |
414
|
|
|
return $this->m_dataitem->isUserDefined(); |
|
|
|
|
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* @see DIProperty::isShown() |
419
|
|
|
* |
420
|
|
|
* @deprecated since 1.6 |
421
|
|
|
*/ |
422
|
|
|
public function isShown() { |
423
|
|
|
return $this->m_dataitem->isShown(); |
|
|
|
|
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* @see DIProperty::isInverse() |
428
|
|
|
* |
429
|
|
|
* @deprecated since 1.6 |
430
|
|
|
*/ |
431
|
|
|
public function isInverse() { |
432
|
|
|
return $this->m_dataitem->isInverse(); |
|
|
|
|
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Return a DB-key-like string: for visible properties, it is the actual DB key, |
437
|
|
|
* for internal (invisible) properties, it is the property ID. The value agrees |
438
|
|
|
* with the first component of getDBkeys() and it can be used in its place. |
439
|
|
|
* @see DIProperty::getKey() |
440
|
|
|
* |
441
|
|
|
* @deprecated since 1.6 |
442
|
|
|
*/ |
443
|
|
|
public function getDBkey() { |
444
|
|
|
return $this->m_dataitem->getKey(); |
|
|
|
|
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* @see DIProperty::getLabel() |
449
|
|
|
* |
450
|
|
|
* @deprecated since 1.6 |
451
|
|
|
*/ |
452
|
|
|
public function getText() { |
453
|
|
|
return $this->m_dataitem->getLabel(); |
|
|
|
|
454
|
|
|
} |
455
|
|
|
|
456
|
199 |
|
private function doNormalizeUserValue( $value ) { |
457
|
|
|
|
458
|
|
|
if ( |
459
|
199 |
|
( $pos = strpos( $value, '#' ) ) !== false && strlen( $value ) > 1 || /* #1567 */ |
460
|
199 |
|
( $pos = strpos( $value, '[' ) ) !== false ) /* #1638 */ { |
461
|
2 |
|
$this->addErrorMsg( array( 'smw-datavalue-property-invalid-name', $value, substr( $value, $pos, 1 ) ) ); |
462
|
2 |
|
$this->m_dataitem = new DIProperty( 'ERROR', false ); |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
// #1727 <Foo> or <Foo-<Bar> are not permitted but |
466
|
|
|
// Foo-<Bar will be converted to Foo- |
467
|
199 |
|
$value = strip_tags( htmlspecialchars_decode( $value ) ); |
468
|
199 |
|
$inverse = false; |
469
|
|
|
|
470
|
|
|
// Enforce upper case for the first character on annotations that are used |
471
|
|
|
// within the property namespace in order to avoid confusion when |
472
|
|
|
// $wgCapitalLinks setting is disabled |
473
|
199 |
|
if ( $this->getContextPage() !== null && $this->getContextPage()->getNamespace() === SMW_NS_PROPERTY ) { |
474
|
|
|
// ucfirst is not utf-8 safe hence the reliance on mb_strtoupper |
475
|
141 |
|
$value = mb_strtoupper( mb_substr( $value, 0, 1 ) ) . mb_substr( $value, 1 ); |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
// slightly normalise label |
479
|
199 |
|
$propertyName = smwfNormalTitleText( ltrim( rtrim( $value, ' ]' ), ' [' ) ); |
480
|
|
|
|
481
|
199 |
|
if ( ( $propertyName !== '' ) && ( $propertyName { 0 } == '-' ) ) { // property refers to an inverse |
482
|
11 |
|
$propertyName = smwfNormalTitleText( (string)substr( $value, 1 ) ); |
483
|
|
|
/// NOTE The cast is necessary at least in PHP 5.3.3 to get string '' instead of boolean false. |
484
|
|
|
/// NOTE It is necessary to normalize again here, since normalization may uppercase the first letter. |
485
|
11 |
|
$inverse = true; |
486
|
|
|
} |
487
|
|
|
|
488
|
199 |
|
return array( $propertyName, $inverse ); |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
} |
492
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.