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