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


PHP SMWExporter类代码示例

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


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

示例1: categoryProvider

 public function categoryProvider()
 {
     $stringBuilder = UtilityFactory::getInstance()->newStringBuilder();
     # 0
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\FalseCondition';
     $description = new ClassDescription(array());
     $orderByProperty = null;
     $expected = $stringBuilder->addString('<http://www.example.org> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#nothing> .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $conditionType, $expected);
     # 1
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $category = new DIWikiPage('Foo', NS_CATEGORY);
     $categoryName = \SMWTurtleSerializer::getTurtleNameForExpElement(\SMWExporter::getInstance()->getResourceElementForWikiPage($category));
     $description = new ClassDescription($category);
     $orderByProperty = null;
     $expected = $stringBuilder->addString("{ ?result rdf:type {$categoryName} . }")->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $conditionType, $expected);
     # 2
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $categoryFoo = new DIWikiPage('Foo', NS_CATEGORY);
     $categoryFooName = \SMWTurtleSerializer::getTurtleNameForExpElement(\SMWExporter::getInstance()->getResourceElementForWikiPage($categoryFoo));
     $categoryBar = new DIWikiPage('Bar', NS_CATEGORY);
     $categoryBarName = \SMWTurtleSerializer::getTurtleNameForExpElement(\SMWExporter::getInstance()->getResourceElementForWikiPage($categoryBar));
     $description = new ClassDescription(array($categoryFoo, $categoryBar));
     $orderByProperty = null;
     $expected = $stringBuilder->addString("{ ?result rdf:type {$categoryFooName} . }")->addNewLine()->addString('UNION')->addNewLine()->addString("{ ?result rdf:type {$categoryBarName} . }")->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $conditionType, $expected);
     # 3
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new ClassDescription(array($categoryFoo, $categoryBar));
     $orderByProperty = new DIProperty('Foo');
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("{ ?result rdf:type {$categoryFooName} . }")->addNewLine()->addString('UNION')->addNewLine()->addString("{ ?result rdf:type {$categoryBarName} . }")->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $conditionType, $expected);
     return $provider;
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:35,代码来源:ClassDescriptionInterpreterTest.php

示例2: execute

 function execute($query)
 {
     global $wgOut;
     wfProfileIn('SpecialURIResolver::execute (SMW)');
     if (is_null($query) || trim($query) === '') {
         if (stristr($_SERVER['HTTP_ACCEPT'], 'RDF')) {
             $wgOut->redirect(SpecialPage::getTitleFor('ExportRDF')->getFullURL(array('stats' => '1')), '303');
         } else {
             $this->setHeaders();
             $wgOut->addHTML('<p>' . wfMessage('smw_uri_doc', 'http://www.w3.org/2001/tag/issues.html#httpRange-14')->parse() . '</p>');
         }
     } else {
         $query = SMWExporter::decodeURI($query);
         $query = str_replace('_', '%20', $query);
         $query = urldecode($query);
         $title = Title::newFromText($query);
         // In case the title doesn't exists throw an error page
         if ($title === null) {
             $wgOut->showErrorPage('badtitle', 'badtitletext');
         } else {
             $wgOut->redirect(stristr($_SERVER['HTTP_ACCEPT'], 'RDF') ? SpecialPage::getTitleFor('ExportRDF', $title->getPrefixedText())->getFullURL(array('xmlmime' => 'rdf')) : $title->getFullURL(), '303');
         }
     }
     wfProfileOut('SpecialURIResolver::execute (SMW)');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:SMW_SpecialURIResolver.php

示例3: serializeHeader

 protected function serializeHeader()
 {
     $this->namespaces_are_global = true;
     $this->namespace_block_started = true;
     $this->pre_ns_buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE rdf:RDF[\n" . "\t<!ENTITY rdf " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&rdf;')) . ">\n" . "\t<!ENTITY rdfs " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&rdfs;')) . ">\n" . "\t<!ENTITY owl " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&owl;')) . ">\n" . "\t<!ENTITY swivt " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&swivt;')) . ">\n" . "\t<!ENTITY wiki " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&wiki;')) . ">\n" . "\t<!ENTITY property " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&property;')) . ">\n" . "\t<!ENTITY wikiurl " . $this->makeValueEntityString(SMWExporter::getInstance()->expandURI('&wikiurl;')) . ">\n" . "]>\n\n" . "<rdf:RDF\n" . "\txmlns:rdf=\"&rdf;\"\n" . "\txmlns:rdfs=\"&rdfs;\"\n" . "\txmlns:owl =\"&owl;\"\n" . "\txmlns:swivt=\"&swivt;\"\n" . "\txmlns:wiki=\"&wiki;\"\n" . "\txmlns:property=\"&property;\"";
     $this->global_namespaces = array('rdf' => true, 'rdfs' => true, 'owl' => true, 'swivt' => true, 'wiki' => true, 'property' => true);
     $this->post_ns_buffer .= ">\n\n";
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:8,代码来源:SMW_Serializer_RDFXML.php

示例4: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make RDF file
         $serializer = $this->syntax == 'turtle' ? new SMWTurtleSerializer() : new SMWRDFXMLSerializer();
         $serializer->startSerialization();
         $serializer->serializeExpData(SMWExporter::getOntologyExpData(''));
         while ($row = $res->getNext()) {
             $subjectDi = reset($row)->getResultSubject();
             $data = SMWExporter::makeExportDataForSubject($subjectDi);
             foreach ($row as $resultarray) {
                 $printreq = $resultarray->getPrintRequest();
                 $property = null;
                 switch ($printreq->getMode()) {
                     case SMWPrintRequest::PRINT_PROP:
                         $property = $printreq->getData()->getDataItem();
                         break;
                     case SMWPrintRequest::PRINT_CATS:
                         $property = new SMWDIProperty('_TYPE');
                         break;
                     case SMWPrintRequest::PRINT_CCAT:
                         // not serialised right now
                         break;
                     case SMWPrintRequest::PRINT_THIS:
                         // ignored here (object is always included in export)
                         break;
                 }
                 if (!is_null($property)) {
                     SMWExporter::addPropertyValues($property, $resultarray->getContent(), $data, $subjectDi);
                 }
             }
             $serializer->serializeExpData($data);
         }
         $serializer->finishSerialization();
         return $serializer->flushContent();
     } else {
         // just make link to feed
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('smw_rdf_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('rdf', 'format');
         $link->setParameter($this->syntax, 'syntax');
         if (array_key_exists('limit', $this->params)) {
             $link->setParameter($this->params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(100, 'limit');
         }
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
         return $link->getText($outputmode, $this->mLinker);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:SMW_QP_RDF.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $utilityFactory = $this->testEnvironment->getUtilityFactory();
     $this->fixturesFileProvider = $utilityFactory->newFixturesFactory()->newFixturesFileProvider();
     $this->stringValidator = $utilityFactory->newValidatorFactory()->newStringValidator();
     $this->testEnvironment->withConfiguration(array('smwgPageSpecialProperties' => array('_MEDIA', '_MIME'), 'smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true, NS_FILE => true), 'smwgCacheType' => 'hash', 'smwgExportBCAuxiliaryUse' => true));
     // Ensure that the DB creates the extra tables for MEDIA/MINE
     $this->getStore()->clear();
     $this->getStore()->setupStore(false);
     // MW GLOBALS to be restored after the test
     $this->testEnvironment->withConfiguration(array('wgEnableUploads' => true, 'wgFileExtensions' => array('txt'), 'wgVerifyMimeType' => true));
     \SMWExporter::clear();
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:14,代码来源:RdfFileResourceTest.php

示例6: buildCondition

 /**
  * Create an Condition from a NamespaceDescription
  *
  * @param NamespaceDescription $description
  * @param string $joinVariable
  * @param DIProperty|null $orderByProperty
  *
  * @return Condition
  */
 public function buildCondition(Description $description, $joinVariable, $orderByProperty = null)
 {
     $nspropExpElement = $this->exporter->getSpecialNsResource('swivt', 'wikiNamespace');
     $nsExpElement = new ExpLiteral(strval($description->getNamespace()), 'http://www.w3.org/2001/XMLSchema#integer');
     $nsName = TurtleSerializer::getTurtleNameForExpElement($nsExpElement);
     $condition = "{ ?{$joinVariable} " . $nspropExpElement->getQName() . " {$nsName} . }\n";
     $result = new WhereCondition($condition, true, array());
     $this->compoundConditionBuilder->addOrderByDataForProperty($result, $joinVariable, $orderByProperty, DataItem::TYPE_WIKIPAGE);
     return $result;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:19,代码来源:NamespaceConditionBuilder.php

示例7: makeQueryResultForInstance

 private function makeQueryResultForInstance(FederateResultSet $federateResultSet, Query $query)
 {
     $resultDataItems = array();
     foreach ($federateResultSet as $resultRow) {
         if (count($resultRow) > 0) {
             $dataItem = Exporter::findDataItemForExpElement($resultRow[0]);
             if (!is_null($dataItem)) {
                 $resultDataItems[] = $dataItem;
             }
         }
     }
     if ($federateResultSet->numRows() > $query->getLimit()) {
         array_pop($resultDataItems);
         $hasFurtherResults = true;
     } else {
         $hasFurtherResults = false;
     }
     $result = new QueryResult($query->getDescription()->getPrintrequests(), $query, $resultDataItems, $this->store, $hasFurtherResults);
     switch ($federateResultSet->getErrorCode()) {
         case FederateResultSet::ERROR_NOERROR:
             break;
         case FederateResultSet::ERROR_INCOMPLETE:
             $result->addErrors(array(wfMessage('smw_db_sparqlqueryincomplete')->inContentLanguage()->text()));
             break;
         default:
             $result->addErrors(array(wfMessage('smw_db_sparqlqueryproblem')->inContentLanguage()->text()));
             break;
     }
     return $result;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:30,代码来源:QueryResultFactory.php

示例8: testSortableDateQuery

 /**
  * #576
  */
 public function testSortableDateQuery()
 {
     $this->getStore()->updateData($this->fixturesProvider->getFactsheet('Berlin')->asEntity());
     // #576 introduced resource caching, therefore make sure that the
     // instance is cleared after data have been created before further
     // tests are carried out
     Exporter::clear();
     /**
      * @query {{#ask: [[Founded::SomeDistinctValue]] }}
      */
     $foundedValue = $this->fixturesProvider->getFactsheet('Berlin')->getFoundedValue();
     $description = new SomeProperty($foundedValue->getProperty(), new ValueDescription($foundedValue->getDataItem(), null, SMW_CMP_EQ));
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem($foundedValue->getProperty());
     $query = new Query($description, false, false);
     $query->querymode = Query::MODE_INSTANCES;
     $query->sortkeys = array($foundedValue->getProperty()->getLabel() => 'ASC');
     // Be aware of
     // Virtuoso 22023 Error SR353: Sorted TOP clause specifies more then
     // 10001 rows to sort. Only 10000 are allowed. Either decrease the
     // offset and/or row count or use a scrollable cursor
     $query->setLimit(100);
     $query->setExtraPrintouts(array(new PrintRequest(PrintRequest::PRINT_THIS, ''), new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)));
     $queryResult = $this->getStore()->getQueryResult($query);
     $this->queryResultValidator->assertThatQueryResultHasSubjects($this->fixturesProvider->getFactsheet('Berlin')->asSubject(), $queryResult);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:29,代码来源:DatePropertyValueQueryDBIntegrationTest.php

示例9: tearDown

 protected function tearDown()
 {
     ApplicationFactory::clear();
     NamespaceExaminer::clear();
     PropertyRegistry::clear();
     Settings::clear();
     Exporter::getInstance()->clear();
     parent::tearDown();
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:9,代码来源:MwDBaseUnitTestCase.php

示例10: mapCategoriesToConditionElements

 private function mapCategoriesToConditionElements(array $categories, $joinVariable)
 {
     $condition = '';
     $namespaces = array();
     $instExpElement = $this->exporter->getSpecialPropertyResource('_INST');
     foreach ($categories as $category) {
         $categoryExpElement = $this->exporter->getResourceElementForWikiPage($category);
         $categoryName = TurtleSerializer::getTurtleNameForExpElement($categoryExpElement);
         $namespaces[$categoryExpElement->getNamespaceId()] = $categoryExpElement->getNamespace();
         $newcondition = "{ ?{$joinVariable} " . $instExpElement->getQName() . " {$categoryName} . }\n";
         if ($condition === '') {
             $condition = $newcondition;
         } else {
             $condition .= "UNION\n{$newcondition}";
         }
     }
     return array($condition, $namespaces);
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:18,代码来源:ClassDescriptionInterpreter.php

示例11: getResourceElementHelperForProperty

 protected function getResourceElementHelperForProperty($property)
 {
     $key = 'resource:builder:aux:' . $property->getKey();
     if (($resourceElement = $this->inMemoryPoolCache->fetch($key)) !== false) {
         return $resourceElement;
     }
     $resourceElement = $this->exporter->getResourceElementForProperty($property, true);
     $this->inMemoryPoolCache->save($key, $resourceElement);
     return $resourceElement;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:10,代码来源:PropertyValueResourceBuilder.php

示例12: testChunkedTriples

 public function testChunkedTriples()
 {
     $expNsResource = new ExpNsResource('Redirect', Exporter::getInstance()->getNamespaceUri('wiki'), 'Redirect');
     $semanticData = new SemanticData(new DIWikiPage('Foo', NS_MAIN));
     $redirectLookup = $this->getMockBuilder('\\SMW\\SPARQLStore\\RedirectLookup')->disableOriginalConstructor()->getMock();
     $redirectLookup->expects($this->atLeastOnce())->method('findRedirectTargetResource')->will($this->returnValue($expNsResource));
     $instance = new TurtleTriplesBuilder($semanticData, $redirectLookup);
     $instance->setTriplesChunkSize(1);
     $this->assertInternalType('array', $instance->getChunkedTriples());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:10,代码来源:TurtleTriplesBuilderTest.php

示例13: tryToAddPropertyPathForSaturatedHierarchy

 /**
  * @note rdfs:subPropertyOf* where * means a property path of arbitrary length
  * can be found using the "zero or more" will resolve the complete path
  *
  * @see http://www.w3.org/TR/sparql11-query/#propertypath-arbitrary-length
  */
 private function tryToAddPropertyPathForSaturatedHierarchy(&$condition, DIProperty $property, &$propertyName)
 {
     if (!$this->compoundConditionBuilder->canUseQFeature(SMW_SPARQL_QF_SUBP) || !$property->isUserDefined()) {
         return null;
     }
     if ($this->compoundConditionBuilder->getPropertyHierarchyLookup() == null || !$this->compoundConditionBuilder->getPropertyHierarchyLookup()->hasSubpropertyFor($property)) {
         return null;
     }
     $subPropExpElement = $this->exporter->getSpecialPropertyResource('_SUBP', SMW_NS_PROPERTY);
     $propertyByVariable = '?' . $this->compoundConditionBuilder->getNextVariable('sp');
     $condition->weakConditions[$propertyName] = "\n" . "{$propertyByVariable} " . $subPropExpElement->getQName() . "*" . " {$propertyName} .\n" . "";
     $propertyName = $propertyByVariable;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:19,代码来源:SomePropertyInterpreter.php

示例14: getPropertyNameByUsingTurtleSerializer

 private function getPropertyNameByUsingTurtleSerializer(DIProperty $property, DIProperty $nonInverseProperty, &$namespaces)
 {
     // Use helper properties in encoding values, refer to this helper property:
     if ($this->exporter->hasHelperExpElement($property)) {
         $propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty, true);
     } else {
         $propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty);
     }
     if ($propertyExpElement instanceof ExpNsResource) {
         $namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
     }
     return TurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:13,代码来源:SomePropertyInterpreter.php

示例15: tearDown

 protected function tearDown()
 {
     // If setUp is skipped early this might not be initialized
     if ($this->testEnvironment !== null) {
         $this->testEnvironment->tearDown();
     }
     ApplicationFactory::clear();
     NamespaceExaminer::clear();
     PropertyRegistry::clear();
     Settings::clear();
     Exporter::getInstance()->clear();
     parent::tearDown();
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:13,代码来源:MwDBaseUnitTestCase.php


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