/**
  * SkinPreloadExistence hook handler
  * Disables TOC in output before it grabs HTML
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinPreloadExistence
  *
  * @param Title[] $titles
  * @param Skin $skin
  * @return bool
  */
 public static function onSkinPreloadExistence(array &$titles, Skin $skin)
 {
     $context = MobileContext::singleton();
     if ($context->shouldDisplayMobileView() && !$context->isBlacklistedPage()) {
         $skin->getOutput()->setTarget('mobile');
     }
     return true;
 }
 /**
  * Adds the task-based tabs on Special:Translate and few other special pages.
  * Hook: SkinTemplateNavigation::SpecialPage
  * @since 2012-02-10
  */
 static function tabify(Skin $skin, array &$tabs)
 {
     $title = $skin->getTitle();
     list($alias, $sub) = SpecialPageFactory::resolveAlias($title->getText());
     $pagesInGroup = array('Translate', 'LanguageStats', 'MessageGroupStats');
     if (!in_array($alias, $pagesInGroup, true)) {
         return true;
     }
     $skin->getOutput()->addModuleStyles('ext.translate.tabgroup');
     // Extract subpage syntax, otherwise the values are not passed forward
     $params = array();
     if (trim($sub) !== '') {
         if ($alias === 'Translate' || $alias === 'MessageGroupStats') {
             $params['group'] = $sub;
         } elseif ($alias === 'LanguageStats') {
             // Breaks if additional parameters besides language are code provided
             $params['language'] = $sub;
         }
     }
     $request = $skin->getRequest();
     // However, query string params take precedence
     $params['language'] = $request->getVal('language');
     $params['group'] = $request->getVal('group');
     $taction = $request->getVal('taction', 'translate');
     $translate = SpecialPage::getTitleFor('Translate');
     $languagestats = SpecialPage::getTitleFor('LanguageStats');
     $messagegroupstats = SpecialPage::getTitleFor('MessageGroupStats');
     // Clear the special page tab that might be there already
     $tabs['namespaces'] = array();
     $tabs['namespaces']['translate'] = array('text' => wfMessage('translate-taction-translate')->text(), 'href' => $translate->getLocalUrl($params), 'class' => 'tux-tab');
     if ($alias === 'Translate' && $taction === 'translate') {
         $tabs['namespaces']['translate']['class'] .= ' selected';
     }
     if (!self::isBeta($request)) {
         $tabs['namespaces']['proofread'] = array('text' => wfMessage('translate-taction-proofread')->text(), 'href' => $translate->getLocalUrl(array('taction' => 'proofread') + $params), 'class' => 'tux-tab');
         if ($alias === 'Translate' && $taction === 'proofread') {
             $tabs['namespaces']['proofread']['class'] .= ' selected';
         }
     }
     $tabs['views']['lstats'] = array('text' => wfMessage('translate-taction-lstats')->text(), 'href' => $languagestats->getLocalUrl($params), 'class' => 'tux-tab');
     if ($alias === 'LanguageStats') {
         $tabs['views']['lstats']['class'] .= ' selected';
     }
     $tabs['views']['mstats'] = array('text' => wfMessage('translate-taction-mstats')->text(), 'href' => $messagegroupstats->getLocalUrl($params), 'class' => 'tux-tab');
     if ($alias === 'MessageGroupStats') {
         $tabs['views']['mstats']['class'] .= ' selected';
     }
     // Kind of hackish, but works for now
     global $wgTranslateTasks;
     foreach (array_keys($wgTranslateTasks) as $taskname) {
         if (!preg_match('/^export-/', $taskname)) {
             continue;
         }
         $tabs['views']['export'] = array('text' => wfMessage('translate-taction-export')->text(), 'href' => $translate->getLocalUrl(array('taction' => 'export') + $params), 'class' => 'tux-tab');
         if ($alias === 'Translate' && $taction === 'export') {
             $tabs['views']['export']['class'] .= ' selected';
         }
         // We only need the tab to apper once ;)
         break;
     }
     return true;
 }
    /**
     * Prepares links used in the mobile footer
     * @param Skin $sk
     * @param QuickTemplate $tpl
     * @param MobileContext $ctx
     * @param Title $title
     * @param WebRequest $req
     * @return QuickTemplate
     */
    protected static function mobileFooter($sk, $tpl, $ctx, $title, $req)
    {
        $url = $sk->getOutput()->getProperty('desktopUrl');
        if ($url) {
            $url = wfAppendQuery($url, 'mobileaction=toggle_view_desktop');
        } else {
            $url = $title->getLocalUrl($req->appendQueryValue('mobileaction', 'toggle_view_desktop', true));
        }
        $url = htmlspecialchars($ctx->getDesktopUrl(wfExpandUrl($url, PROTO_RELATIVE)));
        $desktop = wfMessage('mobile-frontend-view-desktop')->escaped();
        $mobile = wfMessage('mobile-frontend-view-mobile')->escaped();
        $sitename = self::getSitename(true);
        $switcherHtml = <<<HTML
<h2>{$sitename}</h2>
<ul>
\t<li>{$mobile}</li><li><a id="mw-mf-display-toggle" href="{$url}">{$desktop}</a></li>
</ul>
HTML;
        // Generate the licensing text displayed in the footer of each page.
        // See Skin::getCopyright for desktop equivalent.
        $license = self::getLicense('footer');
        if (isset($license['link']) && $license['link']) {
            $licenseText = $sk->msg($license['msg'])->rawParams($license['link'])->text();
        } else {
            $licenseText = '';
        }
        // Enable extensions to add links to footer in Mobile view, too - bug 66350
        Hooks::run('MobileSiteOutputPageBeforeExec', array(&$sk, &$tpl));
        // FIXME: Deprecate this hook.
        Hooks::run('SkinMinervaOutputPageBeforeExec', array(&$sk, &$tpl), '1.26');
        $tpl->set('mobile-switcher', $switcherHtml);
        $tpl->set('mobile-license', $licenseText);
        $tpl->set('privacy', $sk->footerLink('mobile-frontend-privacy-link-text', 'privacypage'));
        $tpl->set('terms-use', self::getTermsLink($sk));
        $tpl->set('footerlinks', array('info' => array('mobile-switcher', 'mobile-license'), 'places' => array('terms-use', 'privacy')));
        return $tpl;
    }
 /**
  * Adds the task-based tabs on Special:Translate and few other special pages.
  * Hook: SkinTemplateNavigation::SpecialPage
  * @since 2012-05-14
  */
 static function tabify(Skin $skin, array &$tabs)
 {
     $title = $skin->getTitle();
     list($alias, ) = SpecialPageFactory::resolveAlias($title->getText());
     $pagesInGroup = array('ManageMessageGroups' => 'namespaces', 'AggregateGroups' => 'namespaces', 'SupportedLanguages' => 'views', 'TranslationStats' => 'views');
     if (!isset($pagesInGroup[$alias])) {
         return true;
     }
     $skin->getOutput()->addModuleStyles('ext.translate.tabgroup');
     $tabs['namespaces'] = array();
     foreach ($pagesInGroup as $spName => $section) {
         $spClass = SpecialPageFactory::getPage($spName);
         if ($spClass === null) {
             continue;
             // Page explicitly disabled
         }
         $spTitle = $spClass->getPageTitle();
         $tabs[$section][strtolower($spName)] = array('text' => $spClass->getDescription(), 'href' => $spTitle->getLocalUrl(), 'class' => $alias === $spName ? 'selected' : '');
     }
     return true;
 }