本文整理汇总了PHP中SMWDIProperty::findPropertyID方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDIProperty::findPropertyID方法的具体用法?PHP SMWDIProperty::findPropertyID怎么用?PHP SMWDIProperty::findPropertyID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWDIProperty
的用法示例。
在下文中一共展示了SMWDIProperty::findPropertyID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newFromUserLabel
/**
* Construct a property from a user-supplied label. The main difference
* to the normal constructor of SMWDIProperty is that it is checked
* whether the label refers to a known predefined property.
* Note that this function only gives access to the registry data that
* SMWDIProperty stores, but does not do further parsing of user input.
* For example, '-' as first character is not interpreted for inverting
* a property. Likewise, no normalization of title strings is done. To
* process wiki input, SMWPropertyValue should be used.
*
* @param $label string label for the property
* @param $inverse boolean states if the inverse of the property is constructed
*
* @return SMWDIProperty object
*/
public static function newFromUserLabel($label, $inverse = false)
{
$id = SMWDIProperty::findPropertyID($label);
if ($id === false) {
return new SMWDIProperty(str_replace(' ', '_', $label), $inverse);
} else {
return new SMWDIProperty($id, $inverse);
}
}
示例2: getPredefinedData
/**
* Normalize the information for an SMW object (page etc.) and return
* the predefined ID if any. All parameters are call-by-reference and
* will be changed to perform any kind of built-in normalization that
* SMW requires. This mainly applies to predefined properties that
* should always use their property key as a title, have fixed
* sortkeys, etc. Some very special properties also have fixed IDs that
* do not require any DB lookups. In such cases, the method returns
* this ID; otherwise it returns 0.
*
* @note This function could be extended to account for further kinds
* of normalization and predefined ID. However, both getSMWPropertyID
* and makeSMWPropertyID must then also be adjusted to do the same.
*
* @since 1.8
* @param string $title DB key
* @param integer $namespace namespace
* @param string $iw interwiki prefix
* @param string $subobjectName
* @param string $sortkey
* @return integer predefined id or 0 if none
*/
protected function getPredefinedData(&$title, &$namespace, &$iw, &$subobjectName, &$sortkey)
{
if ($namespace == SMW_NS_PROPERTY && ($iw === '' || $iw == SMW_SQL3_SMWINTDEFIW) && $title != '') {
// Check if this is a predefined property:
if ($title[0] != '_') {
// This normalization also applies to
// subobjects of predefined properties.
$newTitle = SMWDIProperty::findPropertyID(str_replace('_', ' ', $title));
if ($newTitle) {
$title = $newTitle;
$sortkey = SMWDIProperty::findPropertyLabel($title);
if ($sortkey === '') {
$iw = SMW_SQL3_SMWINTDEFIW;
}
}
}
// Check if this is a property with a fixed SMW ID:
if ($subobjectName === '' && array_key_exists($title, self::$special_ids)) {
return self::$special_ids[$title];
}
}
return 0;
}