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


PHP SMW\DIWikiPage类代码示例

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


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

示例1: testGetRedirectTargetFromInMemoryCache

 public function testGetRedirectTargetFromInMemoryCache()
 {
     $inMemoryPoolCache = InMemoryPoolCache::getInstance();
     $instance = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $wikipage = new DIWikiPage('Foo', NS_MAIN);
     $expected = new DIWikiPage('Bar', NS_MAIN);
     $inMemoryPoolCache->getPoolCacheFor('store.redirectTarget.lookup')->save($wikipage->getHash(), $expected);
     $this->assertEquals($expected, $instance->getRedirectTarget($wikipage));
     $inMemoryPoolCache->resetPoolCacheFor('store.redirectTarget.lookup');
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:10,代码来源:StoreTest.php

示例2: getContainerFor

 /**
  * @since 2.4
  *
  * @param DIProperty $property
  * @param array|string $errorMsg
  *
  * @return DIContainer
  */
 public function getContainerFor(DIProperty $property = null, $errorMsg = '')
 {
     if ($property !== null && $property->isInverse()) {
         $property = new DIProperty($property->getKey());
     }
     $errorMsg = is_array($errorMsg) ? implode(' ', $errorMsg) : $errorMsg;
     $subject = new DIWikiPage($this->subject->getDBkey(), $this->subject->getNamespace(), $this->subject->getInterwiki(), '_ERR' . md5(($property !== null ? $property->getKey() : 'UNKNOWN') . $errorMsg));
     // Encode brackets to avoid an annotion is created/included
     return $this->newDiContainer($subject, $property, InTextAnnotationParser::obscureAnnotation($errorMsg));
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:18,代码来源:Error.php

示例3: testReUploadDummyTextFileToEditFilePage

 /**
  * @depends testFileUploadForDummyTextFile
  */
 public function testReUploadDummyTextFileToEditFilePage()
 {
     $subject = new DIWikiPage('Foo.txt', NS_FILE);
     $dummyTextFile = $this->fixturesFileProvider->newUploadForDummyTextFile('Foo.txt');
     $dummyTextFile->doUpload();
     $this->pageEditor->editPage($subject->getTitle())->doEdit('[[Ichi::Maru|Kyū]]');
     // File page content is kept from the initial upload
     $expected = array('propertyCount' => 4, 'propertyKeys' => array('HasFile', '_MEDIA', '_MIME', '_SKEY', 'Ichi'), 'propertyValues' => array('File:Foo.txt', 'TEXT', 'text/plain', 'Foo.txt', 'Maru'));
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $this->getStore()->getSemanticData($subject));
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:13,代码来源:FileUploadIntegrationTest.php

示例4: newDIContainer

 /**
  * #1416 create container manually to avoid any issues that may arise from
  * a failed Title::makeTitleSafe.
  */
 private function newDIContainer(Query $query)
 {
     $subject = $query->getContextPage();
     if ($subject === null) {
         $containerSemanticData = ContainerSemanticData::makeAnonymousContainer();
     } else {
         $subject = new DIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $query->getQueryId());
         $containerSemanticData = new ContainerSemanticData($subject);
     }
     return new DIContainer($containerSemanticData);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:15,代码来源:ProfileAnnotatorFactory.php

示例5: testResetCache

 public function testResetCache()
 {
     $subject = new DIWikiPage('Foo', NS_MAIN);
     $poolCache = $this->inMemoryPoolCache->getPoolCacheFor('exporter.dataitem.resource.encoder');
     $poolCache->save($subject->getHash(), true);
     $poolCache->save($subject->getHash() . DataItemToExpResourceEncoder::AUX_MARKER, true);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $instance = new DataItemToExpResourceEncoder($store);
     $instance->resetCacheFor($subject);
     $this->assertFalse($poolCache->contains($subject->getHash()));
 }
开发者ID:jdforrester,项目名称:SemanticMediaWiki,代码行数:11,代码来源:DataItemToExpResourceEncoderTest.php

示例6: testExportRedirect

 public function testExportRedirect()
 {
     $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
     $redirectProperty = new DIProperty('_REDI');
     $redirectTarget = new DIWikiPage('FooRedirectTarget', NS_MAIN, '');
     $semanticData->addPropertyObjectValue($redirectProperty, DIWikiPage::newFromTitle($redirectTarget->getTitle(), '__red'));
     $exportData = Exporter::getInstance()->makeExportData($semanticData);
     $this->assertCount(1, $exportData->getValues(Exporter::getInstance()->getSpecialNsResource('swivt', 'redirectsTo')));
     $this->assertCount(1, $exportData->getValues(Exporter::getInstance()->getSpecialNsResource('owl', 'sameAs')));
     $expectedResourceElement = new ExpNsResource('FooRedirectTarget', Exporter::getInstance()->getNamespaceUri('wiki'), 'wiki', $redirectTarget);
     $this->exportDataValidator->assertThatExportDataContainsResource($expectedResourceElement, Exporter::getInstance()->getSpecialNsResource('owl', 'sameAs'), $exportData);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:12,代码来源:ExportSemanticDataTest.php

示例7: testFileUploadForDummyTextFile

 public function testFileUploadForDummyTextFile()
 {
     $subject = new DIWikiPage('RdfLinkedFile.txt', NS_FILE);
     $fileNS = Localizer::getInstance()->getNamespaceTextById(NS_FILE);
     $dummyTextFile = $this->fixturesFileProvider->newUploadForDummyTextFile('RdfLinkedFile.txt');
     $dummyTextFile->doUpload('[[HasFile::File:RdfLinkedFile.txt]]');
     $exportController = new ExportController(new RDFXMLSerializer());
     $exportController->enableBacklinks(false);
     ob_start();
     $exportController->printPages(array($subject->getTitle()->getPrefixedDBKey()));
     $output = ob_get_clean();
     $expected = array("<rdfs:label>{$fileNS}:RdfLinkedFile.txt</rdfs:label>", '<swivt:file rdf:resource="' . $dummyTextFile->getLocalFile()->getFullURL() . '"/>', '<property:Media_type-23aux rdf:datatype="http://www.w3.org/2001/XMLSchema#string">TEXT</property:Media_type-23aux>', '<property:MIME_type-23aux rdf:datatype="http://www.w3.org/2001/XMLSchema#string">text/plain</property:MIME_type-23aux>');
     $this->stringValidator->assertThatStringContains($expected, $output);
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:14,代码来源:RdfFileResourceTest.php

示例8: testErrorContainerForSamePropertyButDifferentMsg

 public function testErrorContainerForSamePropertyButDifferentMsg()
 {
     $instance = new Error(DIWikiPage::newFromText('Foo'));
     $property = new DIProperty('Foo');
     $container = $instance->getContainerFor($property, array('Some error'));
     $this->assertNotSame($container->getHash(), $instance->getContainerFor($property, array('Different error'))->getHash());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:7,代码来源:ErrorTest.php

示例9: testCreateProfile

 /**
  * @dataProvider durationDataProvider
  */
 public function testCreateProfile($duration, $expected)
 {
     $profiler = new NullProfileAnnotator(new Subobject(DIWikiPage::newFromText(__METHOD__)->getTitle()), 'foo');
     $instance = new DurationProfileAnnotator($profiler, $duration);
     $instance->addAnnotation();
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getContainer()->getSemanticData());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:10,代码来源:DurationProfileAnnotatorTest.php

示例10: subjectProvider

 public function subjectProvider()
 {
     $provider[] = array(DIWikiPage::newFromText('Foo'));
     $provider[] = array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY));
     $provider[] = array(DIWikiPage::newFromText('Modification date', SMW_NS_PROPERTY));
     return $provider;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:7,代码来源:EntitySubobjectListIteratorTest.php

示例11: testPageImportToCreateRedirect

 public function testPageImportToCreateRedirect()
 {
     $this->importedTitles = array('SimplePageRedirectRegressionTest', 'ToBeSimplePageRedirect');
     $this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
     $main = Title::newFromText('SimplePageRedirectRegressionTest');
     $expectedCategoryAsWikiValue = array('property' => new DIProperty(DIProperty::TYPE_CATEGORY), 'propertyValues' => array('Regression test', 'Redirect test', 'Simple redirect test'));
     $expectedSomeProperties = array('properties' => array(new DIProperty('Has regression test')));
     $expectedRedirectAsWikiValue = array('property' => new DIProperty('_REDI'), 'propertyValues' => array('ToBeSimplePageRedirect', 'NewPageRedirectRegressionTest', 'NewTargetPageRedirectRegressionTest'));
     $newRedirectPage = $this->createPageWithRedirectFor('NewPageRedirectRegressionTest', 'SimplePageRedirectRegressionTest');
     $this->testEnvironment->executePendingDeferredUpdates();
     $this->movePageToTargetRedirect($newRedirectPage, 'NewTargetPageRedirectRegressionTest');
     $this->testEnvironment->executePendingDeferredUpdates();
     $this->pageRefresher->doRefreshPoolOfPages(array($main, $newRedirectPage, 'NewTargetPageRedirectRegressionTest'));
     $this->testEnvironment->executePendingDeferredUpdates();
     $semanticDataBatches = array($this->getStore()->getSemanticData(DIWikiPage::newFromTitle($main)));
     $this->assertThatCategoriesAreSet($expectedCategoryAsWikiValue, $semanticDataBatches);
     $this->assertThatPropertiesAreSet($expectedSomeProperties, $semanticDataBatches);
     $inSemanticDataFetcher = new InSemanticDataFetcher($this->getStore());
     $inSemanticData = $inSemanticDataFetcher->getSemanticData(DIWikiPage::newFromTitle($main));
     // When running sqlite, the database select returns an empty result which
     // is probably due to some DB-prefix issues in MW's DatabaseBaseSqlite
     // implementation and for non-sqlite see #212 / bug 62856
     if ($inSemanticData->getProperties() === array()) {
         $this->markTestSkipped("Skipping test either because of sqlite or MW-{$GLOBALS['wgVersion']} / bug 62856");
     }
     $this->assertThatSemanticDataValuesForPropertyAreSet($expectedRedirectAsWikiValue, $inSemanticData);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:27,代码来源:RedirectPageTest.php

示例12: testGetHash

 public function testGetHash()
 {
     $diff = array();
     $instance = new CompositePropertyTableDiffIterator($diff);
     $instance->setSubject(DIWikiPage::newFromText(__METHOD__));
     $this->assertInternalType('string', $instance->getHash());
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:7,代码来源:CompositePropertyTableDiffIteratorTest.php

示例13: deleteSubject

 /**
  * @see SMWStore::deleteSubject
  *
  * @since 1.8
  * @param Title $title
  */
 public function deleteSubject(Title $title)
 {
     // @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
     wfRunHooks('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
     wfRunHooks('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
     $id = $this->store->getObjectIds()->getSMWPageID($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), '', false);
     $emptySemanticData = new SemanticData(DIWikiPage::newFromTitle($title));
     $subobjects = $this->getSubobjects($emptySemanticData->getSubject());
     $this->doDataUpdate($emptySemanticData);
     if ($title->getNamespace() === SMW_NS_CONCEPT) {
         // make sure to clear caches
         $db = $this->store->getConnection();
         $db->delete('smw_fpt_conc', array('s_id' => $id), 'SMW::deleteSubject::Conc');
         $db->delete(SMWSQLStore3::CONCEPT_CACHE_TABLE, array('o_id' => $id), 'SMW::deleteSubject::Conccache');
     }
     // Mark subject/subobjects with a special IW, the final removal is being
     // triggered by the `ByIdDataRebuildDispatcher`
     $this->store->getObjectIds()->updateInterwikiField($id, $emptySemanticData->getSubject(), SMW_SQL3_SMWDELETEIW);
     foreach ($subobjects as $smw_id => $subobject) {
         $this->store->getObjectIds()->updateInterwikiField($smw_id, $subobject, SMW_SQL3_SMWDELETEIW);
     }
     // 1.9.0.1
     // The update of possible associative entities is handled by DeleteSubjectJob which is invoked during
     // the ArticleDelete hook
     // @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
     wfRunHooks('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
     wfRunHooks('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
 }
开发者ID:ReachingOut,项目名称:SemanticMediaWiki,代码行数:34,代码来源:SMW_SQLStore3_Writers.php

示例14: createDataItemByPropertyId

 protected function createDataItemByPropertyId($propertyId)
 {
     $dataItem = null;
     switch ($propertyId) {
         case DIProperty::TYPE_MODIFICATION_DATE:
             $dataItem = DITime::newFromTimestamp($this->pageInfo->getModificationDate());
             break;
         case DIProperty::TYPE_CREATION_DATE:
             $dataItem = DITime::newFromTimestamp($this->pageInfo->getCreationDate());
             break;
         case DIProperty::TYPE_NEW_PAGE:
             $dataItem = new DIBoolean($this->pageInfo->isNewPage());
             break;
         case DIProperty::TYPE_LAST_EDITOR:
             $dataItem = $this->pageInfo->getLastEditor() ? DIWikiPage::newFromTitle($this->pageInfo->getLastEditor()) : null;
             break;
         case DIProperty::TYPE_MEDIA:
             $dataItem = $this->pageInfo->isFilePage() && $this->pageInfo->getMediaType() !== '' && $this->pageInfo->getMediaType() !== null ? new DIBlob($this->pageInfo->getMediaType()) : null;
             break;
         case DIProperty::TYPE_MIME:
             $dataItem = $this->pageInfo->isFilePage() && $this->pageInfo->getMimeType() !== '' && $this->pageInfo->getMimeType() !== null ? new DIBlob($this->pageInfo->getMimeType()) : null;
             break;
     }
     return $dataItem;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:25,代码来源:PredefinedPropertyAnnotator.php

示例15: testGetPropertyValues

 public function testGetPropertyValues()
 {
     $instance = StubSemanticData::newFromSemanticData(new SemanticData(DIWikiPage::newFromTitle(Title::newFromText(__METHOD__))), $this->store);
     $this->assertInstanceOf('SMW\\DIWikiPage', $instance->getSubject());
     $this->assertEmpty($instance->getPropertyValues(new DIProperty('unknownInverseProperty', true)));
     $this->assertEmpty($instance->getPropertyValues(new DIProperty('unknownProperty')));
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:7,代码来源:Sql3StubSemanticDataTest.php


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