예제 #1
0
 function findFiles($inputItems)
 {
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $items = array();
     foreach ($inputItems as $item) {
         if (!is_array($item)) {
             $item = array('title' => $item);
         }
         if (!$item['title'] instanceof Title) {
             $item['title'] = Title::makeTitleSafe(NS_FILE, $item['title']);
         }
         if ($item['title']) {
             $items[$item['title']->getDBkey()] = $item;
         }
     }
     $images = $this->localRepo->findFiles($items);
     foreach ($this->foreignRepos as $repo) {
         // Remove found files from $items
         foreach ($images as $name => $image) {
             unset($items[$name]);
         }
         $images = array_merge($images, $repo->findFiles($items));
     }
     return $images;
 }
예제 #2
0
 /**
  * Search repositories for many files at once.
  *
  * @param array $items An array of titles, or an array of findFile() options with
  *    the "title" option giving the title. Example:
  *
  *     $findItem = array( 'title' => $title, 'private' => true );
  *     $findBatch = array( $findItem );
  *     $repo->findFiles( $findBatch );
  *
  *    No title should appear in $items twice, as the result use titles as keys
  * @param int $flags Supports:
  *     - FileRepo::NAME_AND_TIME_ONLY : return a (search title => (title,timestamp)) map.
  *       The search title uses the input titles; the other is the final post-redirect title.
  *       All titles are returned as string DB keys and the inner array is associative.
  * @return array Map of (file name => File objects) for matches
  *
  * @param array $inputItems
  * @param integer $flags
  * @return array
  */
 function findFiles(array $inputItems, $flags = 0)
 {
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $items = array();
     foreach ($inputItems as $item) {
         if (!is_array($item)) {
             $item = array('title' => $item);
         }
         $item['title'] = File::normalizeTitle($item['title']);
         if ($item['title']) {
             $items[$item['title']->getDBkey()] = $item;
         }
     }
     $images = $this->localRepo->findFiles($items, $flags);
     foreach ($this->foreignRepos as $repo) {
         // Remove found files from $items
         foreach ($images as $name => $image) {
             unset($items[$name]);
         }
         $images = array_merge($images, $repo->findFiles($items, $flags));
     }
     return $images;
 }