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


PHP SMWDataValueFactory::newTypeIdValue方法代码示例

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


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

示例1: storeData


//.........这里部分代码省略.........
         $ptype = new SMWDIProperty('_TYPE');
         $oldtype = smwfGetStore()->getPropertyValues($semdata->getSubject(), $ptype);
         $newtype = $semdata->getPropertyValues($ptype);
         if (!self::equalDatavalues($oldtype, $newtype)) {
             $updatejobflag = true;
         } else {
             foreach ($smwgDeclarationProperties as $prop) {
                 $pv = new SMWDIProperty($prop);
                 $oldvalues = smwfGetStore()->getPropertyValues($semdata->getSubject(), $pv);
                 $newvalues = $semdata->getPropertyValues($pv);
                 $updatejobflag = !self::equalDatavalues($oldvalues, $newvalues);
             }
         }
         if ($updatejobflag) {
             $prop = new SMWDIProperty($title->getDBkey());
             $subjects = smwfGetStore()->getAllPropertySubjects($prop);
             foreach ($subjects as $subject) {
                 $subjectTitle = $subject->getTitle();
                 if (!is_null($subjectTitle)) {
                     // wikia change start - jobqueue migration
                     $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
                     $task->call('SMWUpdateJob', $subjectTitle);
                     $jobs[] = $task;
                     // wikia change end
                 }
             }
             wfRunHooks('smwUpdatePropertySubjects', array(&$jobs));
             $subjects = smwfGetStore()->getPropertySubjects(new SMWDIProperty('_ERRP'), $semdata->getSubject());
             foreach ($subjects as $subject) {
                 $subjectTitle = $subject->getTitle();
                 if (!is_null($subjectTitle)) {
                     // wikia change start - jobqueue migration
                     $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
                     $task->call('SMWUpdateJob', $subjectTitle);
                     $jobs[] = $task;
                     // wikia change end
                 }
             }
         }
     } elseif ($makejobs && $smwgEnableUpdateJobs && $namespace == SMW_NS_TYPE) {
         // if it is a type we need to check if the conversion factors have been changed
         $pconv = new SMWDIProperty('_CONV');
         $ptype = new SMWDIProperty('_TYPE');
         $oldfactors = smwfGetStore()->getPropertyValues($semdata->getSubject(), $pconv);
         $newfactors = $semdata->getPropertyValues($pconv);
         $updatejobflag = !self::equalDatavalues($oldfactors, $newfactors);
         if ($updatejobflag) {
             $store = smwfGetStore();
             /// FIXME: this will kill large wikis! Use incremental updates!
             $dv = SMWDataValueFactory::newTypeIdValue('__typ', $title->getDBkey());
             $proppages = $store->getPropertySubjects($ptype, $dv);
             foreach ($proppages as $proppage) {
                 $propertyTitle = $proppage->getTitle();
                 if (!is_null($propertyTitle)) {
                     // wikia change start - jobqueue migration
                     $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
                     $task->call('SMWUpdateJob', $propertyTitle);
                     $jobs[] = $task;
                     // wikia change end
                 }
                 $prop = new SMWDIProperty($proppage->getDBkey());
                 $subjects = $store->getAllPropertySubjects($prop);
                 foreach ($subjects as $subject) {
                     $subjectTitle = $subject->getTitle();
                     if (!is_null($subjectTitle)) {
                         // wikia change start - jobqueue migration
                         $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
                         $task->call('SMWUpdateJob', $subjectTitle);
                         $jobs[] = $task;
                         // wikia change end
                     }
                 }
                 $subjects = smwfGetStore()->getPropertySubjects(new SMWDIProperty('_ERRP'), $prop->getWikiPageValue());
                 foreach ($subjects as $subject) {
                     $subjectTitle = $subject->getTitle();
                     if (!is_null($subjectTitle)) {
                         // wikia change start - jobqueue migration
                         $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
                         $task->call('SMWUpdateJob', $subjectTitle);
                         $jobs[] = $task;
                         // wikia change end
                     }
                 }
             }
         }
     }
     // Actually store semantic data, or at least clear it if needed
     if ($processSemantics) {
         smwfGetStore()->updateData($semdata);
     } else {
         smwfGetStore()->clearData($semdata->getSubject());
     }
     // Finally trigger relevant Updatejobs if necessary
     if ($updatejobflag) {
         // wikia change start - jobqueue migration
         \Wikia\Tasks\Tasks\BaseTask::batch($jobs);
         // wikia change end
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:SMW_ParseData.php

示例2: import


//.........这里部分代码省略.........
             $categoryTitle = Title::newFromText($category, $defaultNamespace = NS_CATEGORY);
             $categoryTitleWikified = $categoryTitle->getText();
             if (!array_key_exists($categoryTitleWikified, $mwCategories)) {
                 $newCategoriesAsWikiText .= '[[Category:' . $categoryTitleWikified . "]]\n";
                 // Is there an inbuilt class method to do this?  Can't find one in Category.
             }
         }
         // Add facts (properties) to the wiki text
         $newPropertiesAsWikiText = "\n";
         foreach ($wikiPage->getFacts() as $fact) {
             $pred = $fact['p'];
             $obj = $fact['o'];
             $predTitle = Title::newFromText($pred);
             $predTitleWikified = $predTitle->getText();
             $isEquivURI = strpos($pred, "Equivalent URI") !== false;
             $hasLocalUrl = strpos($obj, "Special:URIResolver") !== false;
             $templatesWithProperty = array();
             $isInTemplate = null;
             // Find whether the property is in any template(s) on the page
             if (!empty($mwTemplates)) {
                 foreach ($mwTemplates as $templateName => $array) {
                     $isInTemplate = array_key_exists($predTitleWikified, $mwTemplates[$templateName]['properties']);
                     if ($isInTemplate && !in_array($templateName, $templatesWithProperty)) {
                         $templatesWithProperty[] = $templateName;
                     }
                 }
             }
             $isInPage = array_key_exists($predTitleWikified, $mwProperties);
             // Set new value - this will be used in different ways depending on whether property is inside or outside template
             if ($isEquivURI) {
                 // FIXME: Should be done for all "URL type" facts, not just
                 //        Equivalent URI:s
                 // Since this is a URL, it should not be made into a WikiTitle
                 $newSMWValue = SMWDataValueFactory::newTypeIdValue('_uri', $obj);
             } else {
                 // Create an updated property
                 $objTitle = Title::newFromText($obj);
                 $newSMWValue = SMWWikiPageValue::makePageFromTitle($objTitle);
             }
             $newValueText = $newSMWValue->getWikiValue();
             // Handle updating differently depending on whether property exists in/outside template
             if ($hasLocalUrl && $isEquivURI) {
                 // Don't update Equivalent URI if the URL is a local URL (thus containing
                 // "Special:URIResolver").
             } else {
                 if ($isInTemplate) {
                     // Code to update/add property to template call(s)
                     foreach ($templatesWithProperty as $index => $templateName) {
                         $oldTemplateCall = $updatedTemplateCalls[$templateName];
                         // use temp value as may be updated more than once
                         $parameter = $mwTemplates[$templateName]['properties'][$predTitleWikified];
                         $oldValue = null;
                         $hasOldValue = array_key_exists('value', $mwTemplates[$templateName]['parameters'][$parameter]);
                         if ($hasOldValue) {
                             $oldValue = $mwTemplates[$templateName]['parameters'][$parameter]['value'];
                         }
                         $newParamValueText = $parameter . '=' . $newValueText;
                         $newTemplateCall = $oldTemplateCall;
                         if ($hasOldValue) {
                             // if the parameter already had a value and there's a new value, replace this value in the template call
                             if ($newValueText != $oldValue) {
                                 $oldParamValueText = $parameter . '=' . $oldValue;
                                 $newTemplateCall = str_replace($oldParamValueText, $newParamValueText, $oldTemplateCall);
                             }
                         } else {
                             // if the parameter wasn't previously populated, add it to the parameter list in the template call
开发者ID:rdfio,项目名称:RDFIO,代码行数:67,代码来源:RDFIO_SMWPageWriter.php


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