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


PHP SMWDIProperty::findPropertyLabel方法代码示例

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


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

示例1: 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;
 }
开发者ID:yusufchang,项目名称:app,代码行数:45,代码来源:SMW_Sql3SmwIds.php

示例2: refreshData

 /**
  * @see SMWStore::refreshData
  *
  * @todo This method will be overhauled in SMW 1.9 to become cleaner
  * and more robust.
  *
  * @param integer $index
  * @param integer $count
  * @param mixed $namespaces Array or false
  * @param boolean $usejobs
  *
  * @return decimal between 0 and 1 to indicate the overall progress of the refreshing
  */
 public function refreshData(&$index, $count, $namespaces = false, $usejobs = true)
 {
     $updatejobs = array();
     $emptyrange = true;
     // was nothing done in this run?
     // Update by MediaWiki page id --> make sure we get all pages.
     $tids = array();
     // Array of ids
     for ($i = $index; $i < $index + $count; $i++) {
         $tids[] = $i;
     }
     $titles = Title::newFromIDs($tids);
     foreach ($titles as $title) {
         if ($namespaces == false || in_array($title->getNamespace(), $namespaces)) {
             // wikia change start - jobqueue migration
             $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
             $task->call('SMWUpdateJob', $title);
             $updatejobs[] = $task;
             // wikia change end
             $emptyrange = false;
         }
     }
     // update by internal SMW id --> make sure we get all objects in SMW
     $dbr = wfGetDB(DB_SLAVE, 'smw');
     $res = $dbr->select(SMWSql3SmwIds::tableName, array('smw_id', 'smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject'), array("smw_id >= {$index} ", " smw_id < " . $dbr->addQuotes($index + $count)), __METHOD__);
     foreach ($res as $row) {
         $emptyrange = false;
         // note this even if no jobs were created
         if ($namespaces && !in_array($row->smw_namespace, $namespaces)) {
             continue;
         }
         // Find page to refresh, even for special properties:
         if ($row->smw_title != '' && $row->smw_title[0] != '_') {
             $titleKey = $row->smw_title;
         } elseif ($row->smw_namespace == SMW_NS_PROPERTY && $row->smw_iw == '' && $row->smw_subobject == '') {
             $titleKey = str_replace(' ', '_', SMWDIProperty::findPropertyLabel($row->smw_title));
         } else {
             $titleKey = '';
         }
         if ($row->smw_subobject !== '') {
             // leave subobjects alone; they ought to be changed with their pages
         } elseif (($row->smw_iw === '' || $row->smw_iw == SMW_SQL3_SMWREDIIW) && $titleKey != '') {
             // objects representing pages
             // TODO: special treament of redirects needed, since the store will
             // not act on redirects that did not change according to its records
             $title = Title::makeTitleSafe($row->smw_namespace, $titleKey);
             if ($title !== null && !$title->exists()) {
                 // wikia change start - jobqueue migration
                 $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
                 $task->call('SMWUpdateJob', $title);
                 $updatejobs[] = $task;
                 // wikia change end
             }
         } elseif ($row->smw_iw == SMW_SQL3_SMWIW_OUTDATED) {
             // remove outdated internal object references
             $dbw = wfGetDB(DB_MASTER, 'smw');
             foreach (SMWSQLStore3::getPropertyTables() as $proptable) {
                 if ($proptable->usesIdSubject()) {
                     $dbw->delete($proptable->getName(), array('s_id' => $row->smw_id), __METHOD__);
                 }
             }
             $dbw->delete(SMWSql3SmwIds::tableName, array('smw_id' => $row->smw_id), __METHOD__);
         } elseif ($titleKey != '') {
             // "normal" interwiki pages or outdated internal objects -- delete
             $diWikiPage = new SMWDIWikiPage($titleKey, $row->smw_namespace, $row->smw_iw);
             $emptySemanticData = new SMWSemanticData($diWikiPage);
             $this->store->doDataUpdate($emptySemanticData);
         }
     }
     $dbr->freeResult($res);
     wfRunHooks('smwRefreshDataJobs', array(&$updatejobs));
     if ($usejobs) {
         // wikia change start - jobqueue migration
         \Wikia\Tasks\Tasks\BaseTask::batch($updatejobs);
         // wikia change end
     } else {
         foreach ($updatejobs as $job) {
             // wikia change start - jobqueue migration
             /** @var \Wikia\Tasks\Tasks\JobWrapperTask $job */
             try {
                 $job->init();
             } catch (Exception $e) {
                 continue;
             }
             $job->wrap('SMWUpdateJob');
             // wikia change end
         }
//.........这里部分代码省略.........
开发者ID:yusufchang,项目名称:app,代码行数:101,代码来源:SMW_SQLStore3_SetupHandlers.php


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