当前位置: 首页>>代码示例>>PHP>>正文


PHP SFUtils::getSMWStore方法代码示例

本文整理汇总了PHP中SFUtils::getSMWStore方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::getSMWStore方法的具体用法?PHP SFUtils::getSMWStore怎么用?PHP SFUtils::getSMWStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SFUtils的用法示例。


在下文中一共展示了SFUtils::getSMWStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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';
     }
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:35,代码来源:SF_TemplateField.php

示例2: getAllPropertyNames

 public static function getAllPropertyNames()
 {
     $all_properties = array();
     // Set limit on results - we don't want a massive dropdown
     // of properties, if there are a lot of properties in this wiki.
     // getProperties() functions stop requiring a limit
     $options = new SMWRequestOptions();
     $options->limit = 500;
     $used_properties = SFUtils::getSMWStore()->getPropertiesSpecial($options);
     if ($used_properties instanceof SMW\SQLStore\PropertiesCollector) {
         // SMW 1.9+
         $used_properties = $used_properties->runCollector();
     }
     foreach ($used_properties as $property) {
         // Skip over properties that are errors. (This
         // shouldn't happen, but it sometimes does.)
         if (!method_exists($property[0], 'getKey')) {
             continue;
         }
         $propName = $property[0]->getKey();
         if ($propName[0] != '_') {
             $all_properties[] = str_replace('_', ' ', $propName);
         }
     }
     $unused_properties = SFUtils::getSMWStore()->getUnusedPropertiesSpecial($options);
     if ($unused_properties instanceof SMW\SQLStore\UnusedPropertiesCollector) {
         // SMW 1.9+
         $unused_properties = $unused_properties->runCollector();
     }
     foreach ($unused_properties as $property) {
         // Skip over properties that are errors. (This
         // shouldn't happen, but it sometimes does.)
         if (!method_exists($property, 'getKey')) {
             continue;
         }
         $all_properties[] = str_replace('_', ' ', $property->getKey());
     }
     // Sort properties list alphabetically, and get unique values
     // (for SQLStore3, getPropertiesSpecial() seems to get unused
     // properties as well).
     sort($all_properties);
     $all_properties = array_unique($all_properties);
     return $all_properties;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:44,代码来源:SF_CreateTemplate.php

示例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;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:60,代码来源:SF_FormLinker.php

示例4: getAllPagesForQuery

 /**
  * returns an array of pages that are result of the semantic query
  * @param $rawQueryString string - the query string like [[Category:Trees]][[age::>1000]]
  * @return array of SMWDIWikiPage objects representing the result
  */
 public static function getAllPagesForQuery($rawQuery)
 {
     $rawQueryArray = array($rawQuery);
     SMWQueryProcessor::processFunctionParams($rawQueryArray, $queryString, $processedParams, $printouts);
     SMWQueryProcessor::addThisPrintout($printouts, $processedParams);
     $processedParams = SMWQueryProcessor::getProcessedParams($processedParams, $printouts);
     $queryObj = SMWQueryProcessor::createQuery($queryString, $processedParams, SMWQueryProcessor::SPECIAL_PAGE, '', $printouts);
     $res = SFUtils::getSMWStore()->getQueryResult($queryObj);
     $pages = $res->getResults();
     return $pages;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:16,代码来源:SF_Utils.php


注:本文中的SFUtils::getSMWStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。