Exemplo n.º 1
0
 /**
  * @param  $title Title
  * @param  $repo ForeignApiRepo
  * @return ForeignAPIFile|null
  */
 static function newFromTitle($title, $repo)
 {
     $data = $repo->fetchImageQuery(array('titles' => 'File:' . $title->getDBKey(), 'iiprop' => self::getProps(), 'prop' => 'imageinfo', 'iimetadataversion' => MediaHandler::getMetadataVersion()));
     $info = $repo->getImageInfo($data);
     if ($info) {
         $lastRedirect = isset($data['query']['redirects']) ? count($data['query']['redirects']) - 1 : -1;
         if ($lastRedirect >= 0) {
             $newtitle = Title::newFromText($data['query']['redirects'][$lastRedirect]['to']);
             $img = new ForeignAPIFile($newtitle, $repo, $info, true);
             if ($img) {
                 $img->redirectedFrom($title->getDBkey());
             }
         } else {
             $img = new ForeignAPIFile($title, $repo, $info, true);
         }
         return $img;
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 function findBySha1($hash)
 {
     $results = $this->fetchImageQuery(array('aisha1base36' => $hash, 'aiprop' => ForeignAPIFile::getProps(), 'list' => 'allimages'));
     $ret = array();
     if (isset($results['query']['allimages'])) {
         foreach ($results['query']['allimages'] as $img) {
             // 1.14 was broken, doesn't return name attribute
             if (!isset($img['name'])) {
                 continue;
             }
             $ret[] = new ForeignAPIFile(Title::makeTitle(NS_FILE, $img['name']), $this, $img);
         }
     }
     return $ret;
 }