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


PHP Repo\WikibaseRepo类代码示例

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


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

示例1: __construct

 /**
  * @see SpecialWikibasePage::__construct
  */
 public function __construct()
 {
     parent::__construct('GoToLinkedPage', '', true);
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $this->initServices($wikibaseRepo->getSiteStore(), $wikibaseRepo->getStore()->newSiteLinkStore(), $wikibaseRepo->getStore()->getEntityRedirectLookup(), $wikibaseRepo->getEntityIdParser(), $wikibaseRepo->getStore()->getEntityLookup());
     $this->errorMessageKey = null;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:10,代码来源:SpecialGoToLinkedPage.php

示例2: __construct

 /**
  * @param ApiMain $mainModule
  * @param string $moduleName
  * @param string $modulePrefix
  *
  * @see ApiBase::__construct
  */
 public function __construct(ApiMain $mainModule, $moduleName, $modulePrefix = '')
 {
     parent::__construct($mainModule, $moduleName, $modulePrefix);
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $apiHelperFactory = $wikibaseRepo->getApiHelperFactory($this->getContext());
     $this->setServices($wikibaseRepo->getEntityIdParser(), $apiHelperFactory->getErrorReporter($this), $apiHelperFactory->getResultBuilder($this), new ItemMergeInteractor($wikibaseRepo->getChangeOpFactoryProvider()->getMergeChangeOpFactory(), $wikibaseRepo->getEntityRevisionLookup('uncached'), $wikibaseRepo->getEntityStore(), $wikibaseRepo->getEntityPermissionChecker(), $wikibaseRepo->getSummaryFormatter(), $this->getUser(), $wikibaseRepo->newRedirectCreationInteractor($this->getUser(), $this->getContext())));
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:14,代码来源:MergeItems.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     $sitesTable = WikibaseRepo::getDefaultInstance()->getSiteStore();
     $sitesTable->clear();
     $sitesTable->saveSites(TestSites::getSites());
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:IntegrationApiTest.php

示例4: testMovePrevention

 /**
  * Tests @see WikibaseItem::getIdForSiteLink
  */
 public function testMovePrevention()
 {
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $titleLookup = $wikibaseRepo->getEntityTitleLookup();
     // Moving a regular page into data NS onto an existing item
     $title = $this->itemTitle;
     $this->assertInstanceOf('Title', $title);
     // sanity check
     $this->assertFalse($this->page->getTitle()->moveTo($title) === true);
     $entityNamespaceLookup = $wikibaseRepo->getEntityNamespaceLookup();
     $itemNamespace = $entityNamespaceLookup->getEntityNamespace(CONTENT_MODEL_WIKIBASE_ITEM);
     // Moving a regular page into data NS to an invalid location
     // @todo: test other types of entities too!
     $title = Title::newFromText($this->page->getTitle()->getText(), $itemNamespace);
     $this->assertFalse($this->page->getTitle()->moveTo($title) === true);
     // Moving a regular page into data NS to an empty (but valid) location
     $title = $titleLookup->getTitleForId(new ItemId('Q42'));
     $this->assertFalse($this->page->getTitle()->moveTo($title) === true);
     // Moving item page out of data NS onto an existing page
     $title = $this->page->getTitle();
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
     // Moving item page out of data NS onto a non-existing page
     $title = Title::newFromText('wbmovetestitem');
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
     // Moving item to an invalid location in the data NS
     $title = Title::newFromText($this->page->getTitle()->getText(), $itemNamespace);
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
     // Moving item to an valid location in the data NS
     $title = $titleLookup->getTitleForId(new ItemId('Q42'));
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:34,代码来源:ItemMoveTest.php

示例5: getLanguageFallbackChain

 /**
  * Get the language fallback chain for current context.
  *
  * @since 0.4
  *
  * @return LanguageFallbackChain
  */
 public function getLanguageFallbackChain()
 {
     if ($this->languageFallbackChain === null) {
         $this->languageFallbackChain = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory()->newFromContext($this->getContext());
     }
     return $this->languageFallbackChain;
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:14,代码来源:HistoryEntityAction.php

示例6: __construct

 /**
  * @since 0.4
  *
  * @param string $title The title of the special page
  * @param string $restriction The required user right, 'edit' per default.
  */
 public function __construct($title, $restriction = 'edit')
 {
     parent::__construct($title, $restriction);
     $settings = WikibaseRepo::getDefaultInstance()->getSettings();
     $this->rightsUrl = $settings->getSetting('dataRightsUrl');
     $this->rightsText = $settings->getSetting('dataRightsText');
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:13,代码来源:SpecialModifyEntity.php

示例7: __construct

 /**
  * @param ApiMain $mainModule
  * @param string $moduleName
  * @param string $modulePrefix
  *
  * @see ApiBase::__construct
  */
 public function __construct(ApiMain $mainModule, $moduleName, $modulePrefix = '')
 {
     parent::__construct($mainModule, $moduleName, $modulePrefix);
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $apiHelperFactory = $wikibaseRepo->getApiHelperFactory($this->getContext());
     $this->setServices($wikibaseRepo->getDataTypeFactory(), $wikibaseRepo->getValueParserFactory(), $wikibaseRepo->getDataTypeValidatorFactory(), $wikibaseRepo->getExceptionLocalizer(), $wikibaseRepo->getValidatorErrorLocalizer(), $apiHelperFactory->getErrorReporter($this));
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:14,代码来源:ParseValue.php

示例8: testScript

 public function testScript()
 {
     $dumpScript = new DumpRdf();
     $mockRepo = new MockRepository();
     $mockEntityPerPage = new MockEntityPerPage();
     $snakList = new SnakList();
     $snakList->addSnak(new PropertySomeValueSnak(new PropertyId('P12')));
     $snakList->addSnak(new PropertyValueSnak(new PropertyId('P12'), new StringValue('stringVal')));
     /** @var Entity[] $testEntities */
     $testEntities = array(new Item(new ItemId('Q1')), new Property(new PropertyId('P1'), null, 'string'), new Property(new PropertyId('P12'), null, 'string', new StatementList(array(new Statement(new PropertySomeValueSnak(new PropertyId('P999')), null, null, 'GUID1')))), new Item(new ItemId('Q2'), new Fingerprint(new TermList(array(new Term('en', 'en-label'), new Term('de', 'de-label'))), new TermList(array(new Term('fr', 'en-desc'), new Term('de', 'de-desc'))), new AliasGroupList(array(new AliasGroup('en', array('ali1', 'ali2')), new AliasGroup('dv', array('ali11', 'ali22'))))), new SiteLinkList(array(new SiteLink('enwiki', 'Berlin'), new SiteLink('dewiki', 'England', array(new ItemId('Q1'))))), new StatementList(array(new Statement(new PropertySomeValueSnak(new PropertyId('P12')), null, null, 'GUID1'), new Statement(new PropertySomeValueSnak(new PropertyId('P12')), $snakList, new ReferenceList(array(new Reference(array(new PropertyValueSnak(new PropertyId('P12'), new StringValue('refSnakVal')), new PropertyNoValueSnak(new PropertyId('P12')))))), 'GUID2')))));
     foreach ($testEntities as $key => $testEntity) {
         $mockRepo->putEntity($testEntity, $key, '20000101000000');
         $mockEntityPerPage->addEntityPage($testEntity->getId(), $key);
     }
     // Note: We are testing with the actual RDF bindings, so we can check for actual RDF output.
     $rdfBuilder = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory();
     $dumpScript->setServices($mockEntityPerPage, new NullEntityPrefetcher(), MockSiteStore::newFromTestSites(), $this->getMockPropertyDataTypeLookup(), $rdfBuilder, $mockRepo, 'fooUri');
     $logFileName = tempnam(sys_get_temp_dir(), "Wikibase-DumpRdfTest");
     $outFileName = tempnam(sys_get_temp_dir(), "Wikibase-DumpRdfTest");
     $dumpScript->loadParamsAndArgs(null, array('log' => $logFileName, 'output' => $outFileName, 'format' => 'n-triples'));
     $dumpScript->execute();
     $expectedLog = file_get_contents(__DIR__ . '/../data/maintenance/dumpRdf-log.txt');
     $expectedOut = file_get_contents(__DIR__ . '/../data/maintenance/dumpRdf-out.txt');
     $actualOut = file_get_contents($outFileName);
     $actualOut = preg_replace('/<http:\\/\\/wikiba.se\\/ontology-beta#Dump> <http:\\/\\/schema.org\\/dateModified> "[^"]+"/', "<http://wikiba.se/ontology-beta#Dump> <http://schema.org/dateModified> \"2015-01-01T00:00:00Z\"", $actualOut);
     $this->assertEquals($this->fixLineEndings($expectedLog), $this->fixLineEndings(file_get_contents($logFileName)));
     $this->assertEquals($this->fixLineEndings($expectedOut), $this->fixLineEndings($actualOut));
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:28,代码来源:dumpRdfTest.php

示例9: getChangeNotifier

 private function getChangeNotifier($expectNotifications = 1)
 {
     $changeTransmitter = $this->getMock('Wikibase\\Repo\\Notifications\\ChangeTransmitter');
     $changeTransmitter->expects($this->exactly($expectNotifications))->method('transmitChange');
     $notifier = new ChangeNotifier(WikibaseRepo::getDefaultInstance()->getEntityChangeFactory(), array($changeTransmitter));
     return $notifier;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:ChangeNotifierTest.php

示例10: newRedirect

 /**
  * @param ItemId $itemId
  * @param ItemId $targetId
  *
  * @return ItemContent
  */
 private function newRedirect(ItemId $itemId, ItemId $targetId)
 {
     // FIXME: Use the respective EntityHandler instead of going via the global title lookup!
     $titleLookup = WikibaseRepo::getDefaultInstance()->getEntityTitleLookup();
     $title = $titleLookup->getTitleForId($targetId);
     return ItemContent::newFromRedirect(new EntityRedirect($itemId, $targetId), $title);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:13,代码来源:ItemContentTest.php

示例11: testRebuildSearchKey

 /**
  * @dataProvider termProvider
  */
 public function testRebuildSearchKey($languageCode, $termText, $searchText, $matches)
 {
     /* @var TermSqlIndex $termCache */
     $termCache = WikibaseRepo::getDefaultInstance()->getStore()->getTermIndex();
     // make term in item
     $item = new Item(new ItemId('Q42'));
     $item->setLabel($languageCode, $termText);
     // save term
     $termCache->clear();
     $termCache->saveTermsOfEntity($item);
     // remove search key
     $dbw = wfGetDB(DB_MASTER);
     $dbw->update($termCache->getTableName(), array('term_search_key' => ''), array(), __METHOD__);
     // rebuild search key
     $builder = new TermSearchKeyBuilder($termCache);
     $builder->setRebuildAll(true);
     $builder->rebuildSearchKey();
     // remove search key
     $term = new TermIndexEntry();
     $term->setLanguage($languageCode);
     $term->setText($searchText);
     $options = array('caseSensitive' => false);
     $obtainedTerms = $termCache->getMatchingTerms(array($term), TermIndexEntry::TYPE_LABEL, Item::ENTITY_TYPE, $options);
     $this->assertEquals($matches ? 1 : 0, count($obtainedTerms));
     if ($matches) {
         $obtainedTerm = array_shift($obtainedTerms);
         $this->assertEquals($termText, $obtainedTerm->getText());
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:32,代码来源:TermSearchKeyBuilderTest.php

示例12: execute

 /**
  * @see ApiBase::execute
  *
  * @since 0.5
  */
 public function execute()
 {
     $badgeItems = WikibaseRepo::getDefaultInstance()->getSettings()->getSetting('badgeItems');
     $idStrings = array_keys($badgeItems);
     ApiResult::setIndexedTagName($idStrings, 'badge');
     $this->getResult()->addValue(null, 'badges', $idStrings);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:12,代码来源:AvailableBadges.php

示例13: save

 /**
  * @param EntityDocument $entity
  */
 private function save(EntityDocument $entity)
 {
     $flags = $entity->getId() ? EDIT_UPDATE : EDIT_NEW;
     $store = WikibaseRepo::getDefaultInstance()->getEntityStore();
     $rev = $store->saveEntity($entity, '', $GLOBALS['wgUser'], $flags);
     $entity->setId($rev->getEntity()->getId());
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:10,代码来源:GetClaimsTest.php

示例14: __construct

 public function __construct()
 {
     parent::__construct('SetLabelDescriptionAliases', 'edit');
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $this->changeOpFactory = $wikibaseRepo->getChangeOpFactoryProvider()->getFingerprintChangeOpFactory();
     $this->termsLanguages = $wikibaseRepo->getTermsLanguages();
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:7,代码来源:SpecialSetLabelDescriptionAliases.php

示例15: setup

 public function setup()
 {
     parent::setup();
     if (!isset(self::$hasSetup)) {
         $wikibaseRepo = WikibaseRepo::getDefaultInstance();
         $store = $wikibaseRepo->getEntityStore();
         $prop = Property::newFromType('string');
         $store->saveEntity($prop, 'EditEntityTestP56', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%P56%'] = $prop->getId()->getSerialization();
         self::$idMap['%StringProp%'] = $prop->getId()->getSerialization();
         $prop = Property::newFromType('string');
         $store->saveEntity($prop, 'EditEntityTestP72', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%P72%'] = $prop->getId()->getSerialization();
         $this->initTestEntities(array('Berlin'), self::$idMap);
         self::$idMap['%Berlin%'] = EntityTestHelper::getId('Berlin');
         $p56 = self::$idMap['%P56%'];
         $berlinData = EntityTestHelper::getEntityOutput('Berlin');
         self::$idMap['%BerlinP56%'] = $berlinData['claims'][$p56][0]['id'];
         $badge = new Item();
         $store->saveEntity($badge, 'EditEntityTestQ42', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%Q42%'] = $badge->getId()->getSerialization();
         $badge = new Item();
         $store->saveEntity($badge, 'EditEntityTestQ149', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%Q149%'] = $badge->getId()->getSerialization();
         $badge = new Item();
         $store->saveEntity($badge, 'EditEntityTestQ32', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%Q32%'] = $badge->getId()->getSerialization();
         $wikibaseRepo->getSettings()->setSetting('badgeItems', array(self::$idMap['%Q42%'] => '', self::$idMap['%Q149%'] => '', 'Q99999' => ''));
     }
     self::$hasSetup = true;
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:31,代码来源:EditEntityTest.php


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