/**
  * Render the special page
  *
  * @param string $subPage Tag name with underscores instead of spaces
  */
 public function executeWhenAvailable($subPage)
 {
     $mfConfig = $this->getMFConfig();
     if (!$mfConfig->get('MFIsBrowseEnabled')) {
         $this->renderError(array('browseDisabled' => true));
         return;
     }
     if (!class_exists('Gather\\Hooks')) {
         $this->renderError(array('noGather' => true));
         return;
     }
     $tagName = str_replace('_', ' ', $subPage);
     $titles = $this->getTagService()->getTitlesForTag($tagName);
     if (!$titles) {
         $this->renderError(array('unknownTag' => true));
         return;
     }
     $this->tagName = $tagName;
     $out = $this->getOutput();
     $out->addModules(array('ext.gather.special', 'mobile.special.browse.topicTag.styles', 'mobile.special.browse.topicTag.scripts'));
     $out->addModuleStyles(array('mediawiki.ui.anchor', 'mediawiki.ui.icon', 'ext.gather.icons', 'ext.gather.styles'));
     $collectionItems = array();
     $pageIds = array_map(function (Title $title) {
         return $title->getArticleID();
     }, $titles);
     // get page images and extracts
     $pages = $this->getPages($pageIds);
     if ($pages) {
         foreach ($pages as $page) {
             if (!isset($page['title']) || !$page['title']) {
                 continue;
             }
             $title = Title::newFromText($page['title']);
             $image = false;
             if (isset($page['pageimage'])) {
                 $image = wfFindFile($page['pageimage']);
             }
             $extract = '';
             if (isset($page['extract']['*'])) {
                 $extract = $page['extract']['*'];
             }
             $item = new models\CollectionItem($title, $image, $extract);
             $collectionItems[$page['pageid']] = $item;
         }
     }
     $orderedCollectionItems = array();
     foreach ($pageIds as $id) {
         if (isset($collectionItems[$id])) {
             array_push($orderedCollectionItems, $collectionItems[$id]);
         }
     }
     $collection = new models\Collection(null, $this->getUser());
     $collection->batch($orderedCollectionItems);
     $this->render(new views\Collection($this->getUser(), $collection));
 }