本文整理汇总了PHP中SFUtils::getSMWPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::getSMWPropertyValues方法的具体用法?PHP SFUtils::getSMWPropertyValues怎么用?PHP SFUtils::getSMWPropertyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFUtils
的用法示例。
在下文中一共展示了SFUtils::getSMWPropertyValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTypeAndPossibleValues
function setTypeAndPossibleValues()
{
$proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
if ($proptitle === null) {
return;
}
$store = smwfGetStore();
// this returns an array of objects
$allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
$label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
$propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
$this->mPropertyType = $propValue->findPropertyTypeID();
foreach ($allowed_values as $allowed_value) {
// HTML-unencode each value
$this->mPossibleValues[] = html_entity_decode($allowed_value);
if (count($label_formats) > 0) {
$label_format = $label_formats[0];
$prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
$label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
$label_value->setOutputFormat($label_format);
$this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
}
}
// HACK - if there were any possible values, set the property
// type to be 'enumeration', regardless of what the actual type is
if (count($this->mPossibleValues) > 0) {
$this->mPropertyType = 'enumeration';
}
}
示例2: setTypeAndPossibleValues
function setTypeAndPossibleValues()
{
// The presence of "-" at the beginning of a property name
// (which happens if SF tries to parse an inverse query)
// leads to an error in SMW - just exit if that's the case.
if (strpos($this->mSemanticProperty, '-') === 0) {
return;
}
$proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
if ($proptitle === null) {
return;
}
$store = SFUtils::getSMWStore();
// this returns an array of objects
$allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
$label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
$propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
$this->mPropertyType = $propValue->findPropertyTypeID();
foreach ($allowed_values as $allowed_value) {
// HTML-unencode each value
$this->mPossibleValues[] = html_entity_decode($allowed_value);
if (count($label_formats) > 0) {
$label_format = $label_formats[0];
$prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
$label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
$label_value->setOutputFormat($label_format);
$this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
}
}
// HACK - if there were any possible values, set the property
// type to be 'enumeration', regardless of what the actual type is
if (count($this->mPossibleValues) > 0) {
$this->mPropertyType = 'enumeration';
}
}
示例3: getFormsThatPagePointsTo
/**
* Gets the forms specified, if any, of either type "default form",
* "alternate form", or "default form for page", for a specific page
* (which should be a category, property, or namespace page)
*/
static function getFormsThatPagePointsTo($page_name, $page_namespace, $form_connection_type)
{
if ($page_name == NULL) {
return array();
}
// Check if we've already gotten the set of forms for this
// combination of page and "form connection type" (default,
// alternate or "creates pages with"). If so, use that -
// otherwise, prepare the array so that we can add this
// data to it.
$page_key = "{$page_namespace}:{$page_name}";
if (array_key_exists($page_key, self::$mLinkedForms)) {
if (array_key_exists($form_connection_type, self::$mLinkedForms[$page_key])) {
return self::$mLinkedForms[$page_key][$form_connection_type];
} else {
// Do nothing - an entry with this key will
// be added at the end of this method.
}
} else {
self::$mLinkedForms[$page_key] = array();
}
if ($form_connection_type == self::DEFAULT_FORM) {
$prop_smw_id = '_SF_DF';
$backup_prop_smw_id = '_SF_DF_BACKUP';
} elseif ($form_connection_type == self::ALTERNATE_FORM) {
$prop_smw_id = '_SF_AF';
$backup_prop_smw_id = '_SF_AF_BACKUP';
} elseif ($form_connection_type == self::PAGE_DEFAULT_FORM) {
$prop_smw_id = '_SF_PDF';
$backup_prop_smw_id = '_SF_PDF_BACKUP';
} elseif ($form_connection_type == self::AUTO_CREATE_FORM) {
$prop_smw_id = '_SF_CP';
$backup_prop_smw_id = '_SF_CP_BACKUP';
} else {
return array();
}
global $sfgContLang;
$store = SFUtils::getSMWStore();
$subject = Title::makeTitleSafe($page_namespace, $page_name);
$form_names = SFUtils::getSMWPropertyValues($store, $subject, $prop_smw_id);
// If we're using a non-English language, check for the English
// string as well.
if (!class_exists('SF_LanguageEn') || !$sfgContLang instanceof SF_LanguageEn) {
$backup_form_names = SFUtils::getSMWPropertyValues($store, $subject, $backup_prop_smw_id);
$form_names = array_merge($form_names, $backup_form_names);
}
// These form names will all start with "Form:" - remove the
// namespace prefix.
foreach ($form_names as $i => $form_name) {
$form_names[$i] = preg_replace('/^Form:/', '', $form_name);
}
// Add this data to the "cache".
self::$mLinkedForms[$page_key][$form_connection_type] = $form_names;
return $form_names;
}