Ejemplo n.º 1
0
 public static function onBeforePageDisplay(\OutputPage &$output, \Skin &$skin)
 {
     $title = $output->getTitle();
     // Disallow commenting on pages without article id
     if ($title->getArticleID() == 0) {
         return true;
     }
     if ($title->isSpecialPage()) {
         return true;
     }
     // These could be explicitly allowed in later version
     if (!$title->canTalk()) {
         return true;
     }
     if ($title->isTalkPage()) {
         return true;
     }
     if ($title->isMainPage()) {
         return true;
     }
     // Do not display when printing
     if ($output->isPrintable()) {
         return true;
     }
     // Disable if not viewing
     if ($skin->getRequest()->getVal('action', 'view') != 'view') {
         return true;
     }
     // Blacklist several namespace
     if (in_array($title->getNamespace(), array(NS_MEDIAWIKI, NS_TEMPLATE, NS_CATEGORY, NS_FILE, NS_USER))) {
         return true;
     }
     $output->addModules('ext.pagerating');
     return true;
 }
Ejemplo n.º 2
0
 public static function onBeforePageDisplay(OutputPage &$output, Skin &$skin)
 {
     $title = $output->getTitle();
     // Disallow commenting on pages without article id
     if ($title->getArticleID() == 0) {
         return true;
     }
     if ($title->isSpecialPage()) {
         return true;
     }
     // These could be explicitly allowed in later version
     if (!$title->canTalk()) {
         return true;
     }
     if ($title->isTalkPage()) {
         return true;
     }
     // No commenting on main page
     if ($title->isMainPage()) {
         return true;
     }
     // Do not display when printing
     if ($output->isPrintable()) {
         return true;
     }
     // Disable if not viewing
     if ($skin->getRequest()->getVal('action', 'view') != 'view') {
         return true;
     }
     // Blacklist several namespace
     if (in_array($title->getNamespace(), self::getFilteredNamespace())) {
         return true;
     }
     if ($output->getUser()->isAllowed('commentadmin-restricted')) {
         $output->addJsConfigVars(array('commentadmin' => ''));
     }
     global $wgFlowThreadConfig;
     $config = array('Avatar' => $wgFlowThreadConfig['Avatar'], 'AnonymousAvatar' => $wgFlowThreadConfig['AnonymousAvatar']);
     if (\FlowThread\Post::canPost($output->getUser())) {
         $output->addJsConfigVars(array('canpost' => ''));
     } else {
         $config['CantPostNotice'] = wfMessage('flowthread-ui-cantpost')->toString();
     }
     global $wgFlowThreadConfig;
     $output->addJsConfigVars(array('wgFlowThreadConfig' => $config));
     $output->addModules('ext.flowthread');
     return true;
 }
 /**
  * Prepares the footer for the skins serving the desktop and mobile sites.
  * @param Skin $skin
  * @param QuickTemplate $tpl
  */
 public static function prepareFooter($skin, $tpl)
 {
     $title = $skin->getTitle();
     $req = $skin->getRequest();
     $ctx = MobileContext::singleton();
     // Certain pages might be blacklisted and not have a mobile equivalent.
     if (!$ctx->isBlacklistedPage()) {
         if ($ctx->shouldDisplayMobileView()) {
             MobileFrontendSkinHooks::mobileFooter($skin, $tpl, $ctx, $title, $req);
         } else {
             MobileFrontendSkinHooks::desktopFooter($skin, $tpl, $ctx, $title, $req);
         }
     }
 }
 /**
  * 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;
 }