public function execute()
 {
     $params = $this->extractRequestParams();
     $prop = array_flip($params['prop']);
     $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
     if (!empty($pageIds[NS_FILE])) {
         # Create a query and set parameters
         $pageIds = $pageIds[NS_FILE];
         $query = new GlobalUsageQuery(array_keys($pageIds));
         if (!is_null($params['continue'])) {
             if (!$query->setOffset($params['continue'])) {
                 $this->dieUsage('Invalid continue parameter', 'badcontinue');
             }
         }
         $query->setLimit($params['limit']);
         $query->filterLocal($params['filterlocal']);
         # Execute the query
         $query->execute();
         # Create the result
         $apiResult = $this->getResult();
         foreach ($query->getResult() as $image => $wikis) {
             $pageId = intval($pageIds[$image]);
             foreach ($wikis as $wiki => $result) {
                 foreach ($result as $item) {
                     if ($item['namespace']) {
                         $title = "{$item['namespace']}:{$item['title']}";
                     } else {
                         $title = $item['title'];
                     }
                     $result = array('title' => $title, 'wiki' => WikiMap::getWikiName($wiki));
                     if (isset($prop['url'])) {
                         $result['url'] = WikiMap::getForeignUrl($item['wiki'], $title);
                     }
                     if (isset($prop['pageid'])) {
                         $result['pageid'] = $item['id'];
                     }
                     if (isset($prop['namespace'])) {
                         $result['ns'] = $item['namespace_id'];
                     }
                     $fit = $apiResult->addValue(array('query', 'pages', $pageId, 'globalusage'), null, $result);
                     if (!$fit) {
                         $continue = "{$item['image']}|{$item['wiki']}|{$item['id']}";
                         $this->setIndexedTagName();
                         $this->setContinueEnumParameter('continue', $continue);
                         return;
                     }
                 }
             }
         }
         $this->setIndexedTagName();
         if ($query->hasMore()) {
             $this->setContinueEnumParameter('continue', $query->getContinueString());
         }
     }
 }
 /**
  * Get an executed query for use on image pages
  *
  * @param Title $title File to query for
  * @return GlobalUsageQuery Query object, already executed
  */
 private static function getImagePageQuery($title)
 {
     $name = $title->getDBkey();
     if (!isset(self::$queryCache[$name])) {
         $query = new GlobalUsageQuery($title);
         $query->filterLocal();
         $query->execute();
         self::$queryCache[$name] = $query;
         // Limit cache size to 100
         if (count(self::$queryCache) > 100) {
             array_shift(self::$queryCache);
         }
     }
     return self::$queryCache[$name];
 }
 /**
  * Creates as queryer and executes it based on $wgRequest
  */
 private function showResult()
 {
     global $wgRequest;
     $query = new GlobalUsageQuery($this->target);
     // Extract params from $wgRequest
     if ($wgRequest->getText('from')) {
         $query->setOffset($wgRequest->getText('from'));
     } elseif ($wgRequest->getText('to')) {
         $query->setOffset($wgRequest->getText('to'), true);
     }
     $query->setLimit($wgRequest->getInt('limit', 50));
     $query->filterLocal($this->filterLocal);
     // Perform query
     $query->execute();
     // Show result
     global $wgOut;
     // Don't show form element if there is no data
     if ($query->count() == 0) {
         $wgOut->addWikiMsg('globalusage-no-results', $this->target->getPrefixedText());
         return;
     }
     $navbar = $this->getNavBar($query);
     $targetName = $this->target->getText();
     // Top navbar
     $wgOut->addHtml($navbar);
     $wgOut->addHtml('<div id="mw-globalusage-result">');
     foreach ($query->getSingleImageResult() as $wiki => $result) {
         $wgOut->addHtml('<h2>' . wfMsgExt('globalusage-on-wiki', 'parseinline', $targetName, WikiMap::getWikiName($wiki)) . "</h2><ul>\n");
         foreach ($result as $item) {
             $wgOut->addHtml("\t<li>" . self::formatItem($item) . "</li>\n");
         }
         $wgOut->addHtml("</ul>\n");
     }
     $wgOut->addHtml('</div>');
     // Bottom navbar
     $wgOut->addHtml($navbar);
 }