Пример #1
0
 /**
  * @param string $summary summary for the change
  * @throws Exception
  * @todo push back changes for all data excepts claims
  */
 public function save($summary = '')
 {
     if ($this->changes === array()) {
         return;
         // Nothing to do
     }
     if ($this->id === null) {
         $result = $this->api->createEntity($this->getType(), $this->changes, $this->lastRevisionId, $summary);
     } else {
         $result = $this->api->editEntity($this->id->getPrefixedId(), $this->changes, $this->lastRevisionId, $summary);
     }
     if (isset($result['entity'])) {
         $this->fillData($result['entity']);
     }
     $this->changes = array();
 }
Пример #2
0
<?php

/**
 * Basic example for the use of the libary with some small edits
 */
include '../include.php';
//Instance the Api object with the base domain of the wiki and the user agent.
$api = new WikibaseApi('wikidata-test-repo.wikimedia.de', 'WikibasePhpLibExample/1.0');
//Instance the entity provider that allows to get entites from the wiki
$entityProvider = new EntityProvider($api);
//login with user:demo and test as password
$api->login('demo', 'test');
//Get an entity
$entity = $entityProvider->getEntityFromId(EntityId::newFromPrefixedId('Q257'));
//Output the description in French
echo $entity->getDescription('fr');
//Change the label in French
$entity->setLabel('fr', 'Or');
//Add an alias in English
$entity->addAlias('en', 'Test');
//Remove an alias
$entity->removeAlias('en', 'Test2');
//Delete the sitelink in French
$entity->setSitelink('frwiki', '');
//Save changes
$entity->save('Test of wikibase-php-lib');
//See the updated aliases in English
print_r($entity->getAlias('en'));
//Log out
$api->logout();
Пример #3
0
 /**
  * @param string[] $sites identifier for the site on which the corresponding page resides
  * @param string[] $titles the title of the corresponding page
  * @param string[] $languages Languages for labels/descriptions
  * @return Entity[]
  * @throws Exception
  */
 public function getEntitiesFromSitelinks(array $sites, array $titles, array $languages = array())
 {
     return $this->api->getEntitiesFromSitelinks($sites, $titles, $languages);
 }