本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::setLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::setLabel方法的具体用法?PHP Item::setLabel怎么用?PHP Item::setLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikibase\DataModel\Entity\Item
的用法示例。
在下文中一共展示了Item::setLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBadgeItem
private function getBadgeItem()
{
$item = new Item(new ItemId('Q17'));
$item->setLabel('de', 'exzellent');
$item->setLabel('en', 'featured');
return $item;
}
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:ParserOutputUpdateHookHandlersTest.php
示例2: itemProvider
public function itemProvider()
{
$emptyItem = new Item(new ItemId('Q1'));
$item = new Item(new ItemId('Q11'));
$item->setDescription('en', 'ohi there');
$item->setLabel('de', 'o_O');
$item->setAliases('nl', array('foo', 'bar'));
$item2 = new Item(new ItemId('Q12'));
$item2->setLabel('de', 'o_O');
$item2->setLabel('en', 'O_o');
$item2->setAliases('nl', array('daaaah'));
$redirect = new EntityRedirect(new ItemId('Q11'), new ItemId('Q21'));
$redirect2 = new EntityRedirect(new ItemId('Q11'), new ItemId('Q22'));
$insTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <ins>foo</ins>' => array('tag' => 'ins', 'content' => 'foo'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <ins>bar</ins>' => array('tag' => 'ins', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <ins>ohi there</ins>' => array('tag' => 'ins', 'content' => 'ohi there'));
$delTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <del>bar</del>' => array('tag' => 'del', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <del>ohi there</del>' => array('tag' => 'del', 'content' => 'ohi there'));
$changeTags = array('has <td>label / en</td>' => array('tag' => 'td', 'content' => 'label / en'), 'has <ins>O_o</ins>' => array('tag' => 'ins', 'content' => 'O_o'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <ins>daaaah</ins>' => array('tag' => 'ins', 'content' => 'daaaah'), 'has <td>aliases / nl / 1</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 1'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>aliases / nl / 2</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 2'), 'has <del>bar</del>' => array('tag' => 'del', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <del>ohi there</del>' => array('tag' => 'del', 'content' => 'ohi there'));
$fromRedirTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <ins>foo</ins>' => array('tag' => 'ins', 'content' => 'foo'), 'has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <del>Q21</del>' => array('tag' => 'del', 'content' => 'Q21'));
$toRedirTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <ins>Q21</ins>' => array('tag' => 'ins', 'content' => 'Q21'));
$changeRedirTags = array('has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <del>Q21</del>' => array('tag' => 'del', 'content' => 'Q21'), 'has <ins>Q22</del>' => array('tag' => 'ins', 'content' => 'Q22'));
$empty = ItemContent::newFromItem($emptyItem);
$itemContent = ItemContent::newFromItem($item);
$itemContent2 = ItemContent::newFromItem($item2);
$redirectContent = ItemContent::newFromRedirect($redirect, Title::newFromText($redirect->getEntityId()->getSerialization()));
$redirectContent2 = ItemContent::newFromRedirect($redirect2, Title::newFromText($redirect2->getEntityId()->getSerialization()));
return array('empty' => array($empty, $empty, array('empty' => '/^$/')), 'same' => array($itemContent, $itemContent, array('empty' => '/^$/')), 'from emtpy' => array($empty, $itemContent, $insTags), 'to empty' => array($itemContent, $empty, $delTags), 'changed' => array($itemContent, $itemContent2, $changeTags), 'to redirect' => array($itemContent, $redirectContent, $toRedirTags), 'from redirect' => array($redirectContent, $itemContent, $fromRedirTags), 'redirect changed' => array($redirectContent, $redirectContent2, $changeRedirTags));
}
示例3: getKnownEntities
/**
* @return EntityDocument[]
*/
protected function getKnownEntities()
{
$q1 = new Item(new ItemId('Q1'));
$q1->setLabel('en', 'label:Q1/en');
$q1->setLabel('de', 'label:Q1/de');
$q1->setDescription('en', 'description:Q1/en');
$q1->setDescription('de', 'description:Q1/de');
$q1->setAliases('en', array('alias:Q1/en#1'));
$q1->setAliases('de', array('alias:Q1/de#1', 'alias:Q1/de#2'));
$q2 = new Item(new ItemId('Q2'));
$q2->setLabel('en', 'label:Q2/en');
$q2->setLabel('de', 'label:Q2/de');
$q2->setAliases('en', array('alias:Q2/en#1'));
$q2->setAliases('de', array('alias:Q2/de#1', 'alias:Q2/de#2'));
$p2 = Property::newFromType('string');
$p2->setId(new PropertyId('P2'));
$p2->setLabel('en', 'label:P2/en');
$p2->setLabel('de', 'label:P2/de');
$p2->setDescription('en', 'description:P2/en');
$p2->setDescription('de', 'description:P2/de');
$p2->setAliases('en', array('alias:P2/en#1'));
$p2->setAliases('de', array('alias:P2/de#1', 'alias:P2/de#2'));
$p3 = Property::newFromType('string');
$p3->setId(new PropertyId('P3'));
$p3->setLabel('en', 'label:P3/en');
$p3->setLabel('de', 'label:P3/de');
$p3->setDescription('en', 'description:P3/en');
$p3->setDescription('de', 'description:P3/de');
return array($q1, $q2, $p2, $p3);
}
示例4: generateProvider
public function generateProvider()
{
$item = new Item();
$item->setLabel('en', 'Test');
$item->setLabel('de', 'Testen');
$item->setDescription('en', 'city in Spain');
$item->setAliases('en', array('abc', 'cde'));
$item->setAliases('de', array('xyz', 'uvw'));
$item->getSiteLinkList()->addNewSiteLink('dewiki', 'Berlin');
$item->getSiteLinkList()->addNewSiteLink('enwiki', 'Rome');
$patterns = array('/^Test$/', '/^Testen$/', '/^city in Spain$/', '/^abc$/', '/^cde$/', '/^uvw$/', '/^xyz$/', '/^(?!abcde).*$/', '/^Berlin$/', '/^Rome$/');
return array(array($item, $patterns));
}
示例5: getEntityRevisionLookup
/**
* @return EntityRevisionLookup
*/
private function getEntityRevisionLookup()
{
$repo = new MockRepository();
$offsets = array('Q1' => 1100, 'Q2' => 1200);
foreach ($offsets as $qid => $offset) {
// entity 1, revision 1111
$entity1 = new Item(new ItemId($qid));
$entity1->setLabel('en', 'ORIGINAL');
$entity1->getSiteLinkList()->addNewSiteLink('enwiki', 'Original');
$repo->putEntity($entity1, $offset + 11);
// entity 1, revision 1112
$entity1->setLabel('de', 'HINZUGEFÜGT');
$repo->putEntity($entity1, $offset + 12);
// entity 1, revision 1113
$entity1->setLabel('nl', 'Addiert');
$repo->putEntity($entity1, $offset + 13);
// entity 1, revision 1114
$entity1->getSiteLinkList()->addNewSiteLink('dewiki', 'Testen');
$repo->putEntity($entity1, $offset + 14);
// entity 1, revision 1117
$entity1->getSiteLinkList()->setSiteLink(new SiteLink('enwiki', 'Spam', array(new ItemId('Q12345'))));
$repo->putEntity($entity1, $offset + 17);
// entity 1, revision 1118
$entity1->getSiteLinkList()->setSiteLink(new SiteLink('enwiki', 'Spam', array(new ItemId('Q54321'))));
$repo->putEntity($entity1, $offset + 18);
}
return $repo;
}
示例6: getEntityRevisions
/**
* @return EntityRevision[]
*/
public static function getEntityRevisions()
{
$item = new Item(new ItemId('Q42'));
$item->setLabel('en', 'Raarrr!');
$itemRev = new EntityRevision($item, 4242, '20131211100908');
return array($itemRev);
}
示例7: 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());
}
}
示例8: entityProvider
public function entityProvider()
{
$empty = new Item(new ItemId('Q1'));
$simple = new Item(new ItemId('Q1'));
$simple->setLabel('en', 'Test');
return array('Property' => array(Property::newFromType('string'), null), 'empty' => array($empty, null), 'empty json' => array($empty, CONTENT_FORMAT_JSON), 'simple' => array($simple, null), 'simple json' => array($simple, CONTENT_FORMAT_JSON), 'simple php' => array($simple, CONTENT_FORMAT_SERIALIZED));
}
示例9: getSiteLinkLookup
/**
* @param array $pageNamesPerItemId
*
* @return SiteLinkLookup
*/
private function getSiteLinkLookup(array $pageNamesPerItemId)
{
$repo = new MockRepository();
// entity 1, revision 11
$entity1 = new Item(new ItemId('Q1'));
$entity1->setLabel('en', 'one');
$repo->putEntity($entity1, 11);
// entity 1, revision 12
$entity1->setLabel('de', 'eins');
$repo->putEntity($entity1, 12);
// entity 1, revision 13
$entity1->setLabel('it', 'uno');
$repo->putEntity($entity1, 13);
// entity 1, revision 1111
$entity1->setDescription('en', 'the first');
$repo->putEntity($entity1, 1111);
// entity 2, revision 21
$entity1 = new Item(new ItemId('Q2'));
$entity1->setLabel('en', 'two');
$repo->putEntity($entity1, 21);
// entity 2, revision 22
$entity1->setLabel('de', 'zwei');
$repo->putEntity($entity1, 22);
// entity 2, revision 23
$entity1->setLabel('it', 'due');
$repo->putEntity($entity1, 23);
// entity 2, revision 1211
$entity1->setDescription('en', 'the second');
$repo->putEntity($entity1, 1211);
$this->updateMockRepository($repo, $pageNamesPerItemId);
return $repo;
}
示例10: makeEntity
protected function makeEntity(EntityId $id, array $statements = array())
{
$item = new Item($id);
$item->setLabel('en', "label:{$id}");
$item->setDescription('en', "description:{$id}");
$item->setStatements(new StatementList($statements));
return $item;
}
示例11: createEntity
private function createEntity($label)
{
$entity = new Item();
$entity->setLabel('en', $label);
$store = WikibaseRepo::getDefaultInstance()->getEntityStore();
$rev = $store->saveEntity($entity, 'GetEntitiesRedirectTest', $GLOBALS['wgUser'], EDIT_NEW);
$id = $rev->getEntity()->getId();
return $id;
}
示例12: getEntityProvider
public function getEntityProvider()
{
$q10 = new ItemId('Q10');
$q11 = new ItemId('Q11');
$item10 = new Item($q10);
$item10->setLabel('en', 'ten');
$repo = new MockRepository();
$repo->putEntity($item10);
return array('found' => array($repo, $q10, $q10), 'not found' => array($repo, $q11, null));
}
示例13: itemProvider
public function itemProvider()
{
$items = array();
$item = new Item(new ItemId('Q1'));
$item->setLabel('en', 'Beer');
$siteLinks = array('cswiki' => 'Pivo', 'enwiki' => 'Beer', 'jawiki' => 'ビール');
foreach ($siteLinks as $siteId => $pageName) {
$item->getSiteLinkList()->addNewSiteLink($siteId, $pageName);
}
$items[] = $item;
return array($items);
}
示例14: testNewFromUpdate_add
public function testNewFromUpdate_add()
{
$itemId = new ItemId('Q1');
$item = new Item($itemId);
$item->setLabel('en', 'kitten');
$factory = $this->getEntityChangeFactory();
$change = $factory->newFromUpdate(EntityChange::ADD, null, $item);
$this->assertEquals($itemId, $change->getEntityId(), 'entity id');
$this->assertEquals('q1', $change->getObjectId(), 'object id');
$this->assertEquals('wikibase-item~add', $change->getType(), 'type');
$this->assertEquals(new Diff(array('en' => new DiffOpAdd('kitten'))), $change->getDiff()->getLabelsDiff(), 'diff');
}
示例15: createNewItem
/**
* Creates a new item and returns its id.
*
* @return string
*/
private function createNewItem()
{
$item = new Item();
// add data and check if it is shown in the form
$item->setLabel('de', 'foo');
$item->setDescription('de', 'foo');
$item->setAliases('de', array('foo'));
// save the item
$store = WikibaseRepo::getDefaultInstance()->getEntityStore();
$store->saveEntity($item, "testing", $GLOBALS['wgUser'], EDIT_NEW | EntityContent::EDIT_IGNORE_CONSTRAINTS);
// return the id
return $item->getId()->getSerialization();
}