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


PHP SMW\DataValueFactory类代码示例

本文整理汇总了PHP中SMW\DataValueFactory的典型用法代码示例。如果您正苦于以下问题:PHP DataValueFactory类的具体用法?PHP DataValueFactory怎么用?PHP DataValueFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getSerialization

 /**
  * Get the serialization for the provided data item.
  *
  * @since 1.7
  *
  * @param SMWDataItem $dataItem
  *
  * @return mixed
  */
 public static function getSerialization(DataItem $dataItem, $printRequest = null)
 {
     $result = array();
     switch ($dataItem->getDIType()) {
         case DataItem::TYPE_WIKIPAGE:
             $title = $dataItem->getTitle();
             $result = array('fulltext' => $title->getFullText(), 'fullurl' => $title->getFullUrl(), 'namespace' => $title->getNamespace(), 'exists' => $title->isKnown());
             break;
         case DataItem::TYPE_NUMBER:
             // dataitems and datavalues
             // Quantity is a datavalue type that belongs to dataitem
             // type number which means in order to identify the correct
             // unit, we have re-factor the corresponding datavalue otherwise
             // we will not be able to determine the unit
             // (unit is part of the datavalue object)
             if ($printRequest !== null && $printRequest->getTypeID() === '_qty') {
                 $diProperty = $printRequest->getData()->getDataItem();
                 $dataValue = DataValueFactory::getInstance()->newDataItemValue($dataItem, $diProperty);
                 $result = array('value' => $dataValue->getNumber(), 'unit' => $dataValue->getUnit());
             } else {
                 $result = $dataItem->getNumber();
             }
             break;
         case DataItem::TYPE_GEO:
             $result = $dataItem->getCoordinateSet();
             break;
         case DataItem::TYPE_TIME:
             $result = $dataItem->getMwTimestamp();
             break;
         default:
             $result = $dataItem->getSerialization();
             break;
     }
     return $result;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:44,代码来源:QueryResultSerializer.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $this->queryResultValidator = UtilityFactory::getInstance()->newValidatorFactory()->newQueryResultValidator();
     $this->semanticDataFactory = UtilityFactory::getInstance()->newSemanticDataFactory();
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:7,代码来源:CategoryClassQueryDBIntegrationTest.php

示例3: parse

 /**
  * @since  1.9
  *
  * @param ParserParameterProcessor $parameters
  *
  * @return string|null
  */
 public function parse(ParserParameterProcessor $parameters)
 {
     $count = 0;
     $template = '';
     $subject = $this->parserData->getSemanticData()->getSubject();
     $parametersToArray = $parameters->toArray();
     if (isset($parametersToArray['template'])) {
         $template = $parametersToArray['template'][0];
         unset($parametersToArray['template']);
     }
     foreach ($parametersToArray as $property => $values) {
         $last = count($values) - 1;
         // -1 because the key starts with 0
         foreach ($values as $key => $value) {
             $dataValue = DataValueFactory::getInstance()->newDataValueByText($property, $value, false, $subject);
             if ($this->parserData->canModifySemanticData()) {
                 $this->parserData->addDataValue($dataValue);
             }
             $this->messageFormatter->addFromArray($dataValue->getErrors());
             $this->addFieldsToTemplate($template, $dataValue, $property, $value, $last == $key, $count);
         }
     }
     $this->parserData->pushSemanticDataToParserOutput();
     $html = $this->templateRenderer->render() . $this->messageFormatter->addFromArray($parameters->getErrors())->getHtml();
     return array($html, 'noparse' => $template === '', 'isHTML' => false);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:33,代码来源:SetParserFunction.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     $validatorFactory = $this->testEnvironment->getUtilityFactory()->newValidatorFactory();
     $stringValidator = $validatorFactory->newStringValidator();
     $semanticDataValidator = $validatorFactory->newSemanticDataValidator();
     $queryResultValidator = $validatorFactory->newQueryResultValidator();
     $this->queryTestCaseProcessor = new QueryTestCaseProcessor($this->getStore(), $queryResultValidator, $stringValidator);
     $this->rdfTestCaseProcessor = new RdfTestCaseProcessor($this->getStore(), $stringValidator);
     $this->parserTestCaseProcessor = new ParserTestCaseProcessor($this->getStore(), $semanticDataValidator, $stringValidator);
     $this->specialPageTestCaseProcessor = new SpecialPageTestCaseProcessor($this->getStore(), $stringValidator);
     $this->eventDispatcher = EventHandler::getInstance()->getEventDispatcher();
     // This ensures that if content is created in the NS_MEDIAWIKI namespace
     // and an object relies on the MediaWikiNsContentReader then it uses the DB
     ApplicationFactory::getInstance()->getMediaWikiNsContentReader()->skipMessageCache();
     DataValueFactory::getInstance()->clear();
     // Reset the Title/TitleParser otherwise a singleton instance holds an outdated
     // content language reference
     $this->testEnvironment->resetMediaWikiService('_MediaWikiTitleCodec');
     $this->testEnvironment->resetMediaWikiService('TitleParser');
     $this->testEnvironment->resetPoolCacheFor(PropertySpecificationLookup::POOLCACHE_ID);
     // Make sure LocalSettings don't interfere with the default settings
     $GLOBALS['smwgDVFeatures'] = $GLOBALS['smwgDVFeatures'] & ~SMW_DV_NUMV_USPACE;
     $this->testEnvironment->addConfiguration('smwgQueryResultCacheType', false);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:25,代码来源:ByJsonScriptFixtureTestCaseRunnerTest.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->testEnvironment = new TestEnvironment();
     $this->semanticDataValidator = $this->testEnvironment->getUtilityFactory()->newValidatorFactory()->newSemanticDataValidator();
     $this->dataValueFactory = DataValueFactory::getInstance();
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:7,代码来源:ParserDataTest.php

示例6: getTypeProperties

 protected function getTypeProperties($typeLabel)
 {
     global $wgRequest, $smwgTypePagingLimit;
     if ($smwgTypePagingLimit <= 0) {
         return '';
         // not too useful, but we comply to this request
     }
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $typeValue = DataValueFactory::getInstance()->newTypeIDValue('__typ', $typeLabel);
     if (!$typeValue->isValid()) {
         return $this->msg('smw-special-types-no-such-type')->escaped();
     }
     $store = \SMW\StoreFactory::getStore();
     $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until);
     $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options);
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until);
         $title = $this->getTitleFor('Types', $typeLabel);
         $title->setFragment('#SMWResults');
         // Make navigation point to the result list.
         $navigation = $pageLister->getNavigationLinks($title);
         $resultNumber = min($smwgTypePagingLimit, count($diWikiPages));
         $typeName = $typeValue->getLongWikiText();
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMessage('smw_type_header', $typeName)->text() . "</h2>\n<p>" . wfMessage('smw_typearticlecount')->numParams($resultNumber)->text() . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>";
     }
     return $result;
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:32,代码来源:SMW_SpecialTypes.php

示例7: deserialize

 /**
  * @since 2.4
  *
  * @param string $value
  *
  * @return Description
  * @throws InvalidArgumentException
  */
 public function deserialize($value)
 {
     if (!is_string($value)) {
         throw new InvalidArgumentException('Value needs to be a string');
     }
     if ($value === '') {
         $this->addError(wfMessage('smw_novalues')->text());
         return new ThingDescription();
     }
     $subdescriptions = array();
     list($text, $languageCode) = $this->dataValue->getValuesFromString($value);
     foreach ($this->dataValue->getPropertyDataItems() as $property) {
         // If the DVFeature doesn't require a language code to be present then
         // allow to skip it as conjunctive condition when it is empty
         if ($languageCode === '' && $property->getKey() === '_LCODE' && !$this->dataValue->isEnabledFeature(SMW_DV_MLTV_LCODE)) {
             continue;
         }
         $value = $property->getKey() === '_LCODE' ? $languageCode : $text;
         $comparator = SMW_CMP_EQ;
         $this->prepareValue($value, $comparator);
         // Directly use the DI instead of going through the DVFactory to
         // avoid having ~zh-* being validated when building a DV
         // If one of the values is empty use, ? so queries can be arbitrary
         // in respect of the query condition
         $dataValue = DataValueFactory::getInstance()->newDataValueByItem(new DIBlob($value === '' ? '?' : $value), $property, false, $this->dataValue->getContextPage());
         if (!$dataValue->isValid()) {
             $this->addError($dataValue->getErrors());
             continue;
         }
         $subdescriptions[] = $this->newSubdescription($dataValue, $comparator);
     }
     return $this->getFinalDescriptionFor($subdescriptions);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:41,代码来源:MonolingualTextValueDescriptionDeserializer.php

示例8: semanticDataProvider

 public function semanticDataProvider()
 {
     // Is a dataprovider therefore can't use the setUp
     $this->semanticDataFactory = UtilityFactory::getInstance()->newSemanticDataFactory();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $title = Title::newFromText('Foo');
     #0 Empty container
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $provider[] = array($foo);
     #1 Single entry
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Bar'));
     $provider[] = array($foo);
     // #2 Single + single subobject entry
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Bar'));
     $subobject = new Subobject($title);
     $subobject->setSemanticData('Foo');
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has subobjects', 'Bam'));
     $foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
     $provider[] = array($foo);
     #3 Multiple entries
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Bar'));
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has queez', 'Xeey'));
     $subobject = new Subobject($title);
     $subobject->setSemanticData('Foo');
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has subobjects', 'Bam'));
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Fuz'));
     $subobject->setSemanticData('Bar');
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Fuz'));
     $foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
     $provider[] = array($foo);
     return $provider;
 }
开发者ID:ReachingOut,项目名称:SemanticMediaWiki,代码行数:35,代码来源:SemanticDataSerializerTest.php

示例9: doFormatFinalOutputFor

 private function doFormatFinalOutputFor($type, $linker)
 {
     $text = '';
     $languagecode = '';
     foreach ($this->dataValue->getPropertyDataItems() as $property) {
         // If we wanted to omit the language code display for some outputs then
         // this is the point to make it happen
         if (($type == self::HTML_LONG || $type == self::WIKI_SHORT) && $property->getKey() === '_LCODE') {
             //continue;
         }
         $dataItems = $this->dataValue->getDataItem()->getSemanticData()->getPropertyValues($property);
         // Should not happen but just in case
         if (!$dataItems === array()) {
             $this->dataValue->addErrorMsg('smw-datavalue-monolingual-dataitem-missing');
             continue;
         }
         $dataItem = reset($dataItems);
         if ($dataItem === false) {
             continue;
         }
         $dataValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $property);
         $result = $this->findValueOutputFor($type, $dataValue, $linker);
         if ($property->getKey() === '_LCODE' && $type !== self::VALUE) {
             $languagecode = ' ' . Message::get(array('smw-datavalue-monolingual-lcode-parenthesis', $result));
         } elseif ($property->getKey() === '_LCODE' && $type === self::VALUE) {
             $languagecode = '@' . $result;
         } else {
             $text = $result;
         }
     }
     return $text . $languagecode;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:32,代码来源:MonolingualTextValueFormatter.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->dataItemFactory = new DataItemFactory();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $this->testEnvironment = new TestEnvironment();
     $this->testEnvironment->resetPoolCacheFor(\SMWExporter::POOLCACHE_ID);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:8,代码来源:PropertyDescriptionValueResourceBuilderTest.php

示例11: setUp

 protected function setUp()
 {
     $this->testEnvironment = new TestEnvironment();
     $this->dataItemFactory = new DataItemFactory();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $this->cachedPropertyValuesPrefetcher = $this->getMockBuilder('\\SMW\\CachedPropertyValuesPrefetcher')->disableOriginalConstructor()->getMock();
     $this->testEnvironment->registerObject('CachedPropertyValuesPrefetcher', $this->cachedPropertyValuesPrefetcher);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:8,代码来源:InfoLinksProviderTest.php

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $this->queryResultValidator = UtilityFactory::getInstance()->newValidatorFactory()->newQueryResultValidator();
     $this->semanticDataFactory = UtilityFactory::getInstance()->newSemanticDataFactory();
     $this->testEnvironment->addConfiguration('smwgQueryResultCacheType', false);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:8,代码来源:GeneralQueryDBIntegrationTest.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $this->semanticDataFactory = new SemanticDataFactory();
     $this->exportDataValidator = new ExportDataValidator();
     $this->fixturesProvider = new FixturesProvider();
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:8,代码来源:ExportSemanticDataTest.php

示例14: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->apiFactory = new MwApiFactory();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $this->serializerFactory = new SerializerFactory();
     $this->semanticDataFactory = new SemanticDataFactory();
 }
开发者ID:hangya,项目名称:SemanticMediaWiki,代码行数:8,代码来源:ApiBrowseBySubjectDBIntegrationTest.php

示例15: getQueryString

 /**
  * @see SMWDescription::getQueryString
  * 
  * @since 0.6
  * 
  * @param boolean $asValue
  * @return string
  */
 public function getQueryString($asValue = false)
 {
     if ($this->getDataItem() !== null) {
         $queryString = DataValueFactory::newDataItemValue($this->getDataItem(), $this->getPropertyCompat())->getWikiValue();
         return $asValue ? $queryString : "[[{$queryString}]]";
     } else {
         return $asValue ? '+' : '';
     }
 }
开发者ID:hangya,项目名称:SemanticMaps,代码行数:17,代码来源:SM_GeoCoordsValueDescription.php


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