/** * initialize various variables and generate the template * @return QuickTemplate */ protected function prepareQuickTemplate() { $appleTouchIcon = $this->getConfig()->get('AppleTouchIcon'); $out = $this->getOutput(); // add head items if ($appleTouchIcon !== false) { $out->addHeadItem('touchicon', Html::element('link', array('rel' => 'apple-touch-icon', 'href' => $appleTouchIcon))); } $out->addHeadItem('viewport', Html::element('meta', array('name' => 'viewport', 'content' => 'initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, ' . 'maximum-scale=5.0, width=device-width'))); if ($this->isMobileMode) { // Customize page content for mobile view, e.g. add togglable sections, filter // out various elements. // We do this before executing parent::prepareQuickTemplate() since the parent // overwrites $out->mBodytext, adding an mw-content-text div which is // redundant to our own content div. By defining the bodytext HTML before // $out->mBodytext is overwritten, we avoid including the mw-content-text div. // FIXME: Git rid of our content div and consolidate this line with the other // isMobileMode lines below. This will bring us more in line with core DOM. $html = ExtMobileFrontend::DOMParse($out); } // Generate skin template $tpl = parent::prepareQuickTemplate(); // Set whether or not the page content should be wrapped in div.content (for // example, on a special page) $tpl->set('unstyledContent', $out->getProperty('unstyledContent')); // Set the links for the main menu $tpl->set('menu_data', $this->getMenuData()); // Set the links for page secondary actions $tpl->set('secondary_actions', $this->getSecondaryActions($tpl)); // Construct various Minerva-specific interface elements $this->preparePageContent($tpl); $this->prepareHeaderAndFooter($tpl); $this->prepareMenuButton($tpl); $this->prepareBanners($tpl); $this->prepareWarnings($tpl); $this->preparePageActions($tpl); $this->prepareUserButton($tpl); $this->prepareLanguages($tpl); // Perform a few extra changes if we are in mobile mode if ($this->isMobileMode) { // Set our own bodytext that has been filtered by MobileFormatter $tpl->set('bodytext', $html); // Construct mobile-friendly footer $this->prepareMobileFooterLinks($tpl); } return $tpl; }
/** * OutputPageParserOutput hook handler * Disables TOC in output before it grabs HTML * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput * * @param OutputPage $outputPage * @param ParserOutput $po * @return bool */ public static function onOutputPageParserOutput($outputPage, ParserOutput $po) { global $wgMFWikibaseImageCategory; $context = MobileContext::singleton(); $isBeta = $context->isBetaGroupMember(); $mfUseWikibaseDescription = $context->getMFConfig()->get('MFUseWikibaseDescription'); if ($context->shouldDisplayMobileView()) { $outputPage->enableTOC(false); $outputPage->setProperty('MinervaTOC', $po->getTOCHTML() !== ''); if ($mfUseWikibaseDescription && $isBeta) { $item = $po->getProperty('wikibase_item'); if ($item) { $desc = ExtMobileFrontend::getWikibaseDescription($item); $category = ExtMobileFrontend::getWikibasePropertyValue($item, $wgMFWikibaseImageCategory); if ($desc) { $outputPage->setProperty('wgMFDescription', $desc); } if ($category) { $outputPage->setProperty('wgMFImagesCategory', $category); } } } // Enable wrapped sections $po->setText(ExtMobileFrontend::DOMParse($outputPage, $po->getText(), $isBeta)); } return true; }