public static function onOutputPageParserOutput(OutputPage &$out, ParserOutput $parseroutput)
 {
     global $wgEnableMWSuggest;
     $skin = $out->getSkin()->getSkinName();
     if ($skin == 'monobook' || $skin == 'uncyclopedia') {
         $wgEnableMWSuggest = true;
     }
     return true;
 }
Exemple #2
0
/**
 * MW1.19 - ResourceLoaderStartUpModule class adds more variables
 * @param array $vars JS variables to be added at the bottom of the page
 * @param OutputPage $out
 * @return bool return true - it's a hook
 */
function wfMakeGlobalVariablesScript(array &$vars, OutputPage $out)
{
    wfProfileIn(__METHOD__);
    global $wgMemc, $wgPrivateTracker, $wgExtensionsPath, $wgArticle, $wgSitename, $wgDisableAnonymousEditing, $wgCityId, $wgGroupPermissions, $wgBlankImgUrl, $wgCookieDomain, $wgCookiePath, $wgResourceBasePath;
    $skin = $out->getSkin();
    $title = $out->getTitle();
    // FIXME: This needs to be converted to getVerticalId when the data is available (PLATFORM-267)
    $hubService = WikiFactoryHub::getInstance();
    $catId = $hubService->getCategoryId($wgCityId);
    if (isset($catId)) {
        $vars['wgCatId'] = $catId;
    } else {
        $vars['wgCatId'] = 0;
    }
    $vars['wgBlankImgUrl'] = $wgBlankImgUrl;
    if (!empty($wgPrivateTracker)) {
        $vars['wgPrivateTracker'] = true;
    }
    // TODO: use wgMainPageTitle instead?
    $vars['wgMainpage'] = wfMsgForContent('mainpage');
    if (Wikia::isMainPage()) {
        $vars['wgIsMainpage'] = true;
    }
    if (Wikia::isContentNamespace()) {
        $vars['wgIsContentNamespace'] = true;
    }
    // TODO: is this one really needed?
    if (isset($skin->themename)) {
        $vars['themename'] = $skin->themename;
    }
    $vars['wgExtensionsPath'] = $wgExtensionsPath;
    $vars['wgResourceBasePath'] = $wgResourceBasePath;
    $vars['wgSitename'] = $wgSitename;
    // Set the JavaScript variable which is used by AJAX request to make data caching possible - Inez
    $vars['wgMWrevId'] = $wgMemc->get(wfMemcKey('wgMWrevId'));
    // macbre: get revision ID of current article
    if (($title->isContentPage() || $title->isTalkPage()) && !is_null($wgArticle)) {
        $vars['wgRevisionId'] = !empty($wgArticle->mRevision) ? $wgArticle->mRevision->getId() : intval($wgArticle->mLatest);
    }
    // is anon editing disabled?
    if ($wgDisableAnonymousEditing || $wgGroupPermissions['user']['edit'] === false) {
        $vars['wgDisableAnonymousEditing'] = true;
    }
    // moved from Interstitial.php
    $vars['wgCookieDomain'] = $wgCookieDomain;
    $vars['wgCookiePath'] = $wgCookiePath;
    wfProfileOut(__METHOD__);
    return true;
}
Exemple #3
0
 /**
  * Build a load.php URL using OutputPage instance to get  most of the required information
  *
  * @param OutputPage $out
  * @param string|array $modules Module names
  * @param string $only
  * @param bool|string $user User name (true to get it from OutputPage)
  * @param string $version
  * @param array $extraQuery
  * @return string
  */
 public static function makeCustomURL(OutputPage $out, $modules, $only = ResourceLoaderModule::TYPE_COMBINED, $user = null, $version = null, $extraQuery = array())
 {
     if ($user === true) {
         $user = $out->getUser()->getName();
     } else {
         if ($user === false || $user === null) {
             $user = null;
         } else {
             $user = (string) $user;
         }
     }
     $url = ResourceLoader::makeLoaderURL($modules, $out->getLanguage()->getCode(), $out->getSkin()->getSkinName(), $user, $version, ResourceLoader::inDebugMode(), $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only, $out->isPrintable(), $out->getRequest()->getBool('handheld'), $extraQuery);
     return $url;
 }
 /**
  * Display Related Discussion (Forum posts) in bottom of article
  * @param OutputPage $out
  * @param string $text article HTML
  * @return bool: true because it is a hook
  */
 public static function onOutputPageBeforeHTML(OutputPage $out, &$text)
 {
     $app = F::app();
     $title = $out->getTitle();
     if ($out->isArticle() && $title->exists() && $title->getNamespace() == NS_MAIN && !Wikia::isMainPage() && $out->getRequest()->getVal('diff') === null && $out->getRequest()->getVal('action') !== 'render' && !$app->checkSkin('wikiamobile', $out->getSkin())) {
         // VOLDEV-46: Omit zero-state, only render if there are related forum threads
         $messages = RelatedForumDiscussionController::getData($title->getArticleId());
         unset($messages['lastupdate']);
         if (!empty($messages)) {
             $text .= $app->renderView('RelatedForumDiscussionController', 'index', array('messages' => $messages));
         }
     }
     return true;
 }
 /**
  * @param OutputPage $out
  * @param            $text
  *
  * Add needed messages to page and add JS assets
  *
  * @return bool
  */
 public static function onOutputPageBeforeHTML(OutputPage $out, &$text)
 {
     $app = F::app();
     $wg = $app->wg;
     $request = $app->wg->Request;
     $title = $wg->Title;
     $am = AssetsManager::getInstance();
     $relatedPagesGroupName = 'relatedpages_js';
     if ($out->isArticle() && $request->getVal('action', 'view') == 'view') {
         JSMessages::enqueuePackage('RelatedPages', JSMessages::INLINE);
         if (!(Wikia::isMainPage() || !empty($title) && !in_array($title->getNamespace(), $wg->ContentNamespaces)) && !$app->checkSkin('wikiamobile') && $am->checkIfGroupForSkin($relatedPagesGroupName, $out->getSkin())) {
             if ($app->checkSkin('oasis')) {
                 OasisController::addSkinAssetGroup($relatedPagesGroupName);
             } else {
                 $scripts = $am->getURL($relatedPagesGroupName);
                 foreach ($scripts as $script) {
                     $wg->Out->addScript("<script src='{$script}'></script>");
                 }
             }
         }
     }
     return true;
 }
Exemple #6
0
/**
 * @param array $vars JS variables to be added at the bottom of the page
 * @param OutputPage $out
 * @return bool return true - it's a hook
 */
function wfMakeGlobalVariablesScript(array &$vars, OutputPage $out)
{
    wfProfileIn(__METHOD__);
    global $wgMemc, $wgEnableAjaxLogin, $wgPrivateTracker, $wgExtensionsPath, $wgArticle, $wgStyleVersion, $wgSitename, $wgDisableAnonymousEditing, $wgGroupPermissions, $wgBlankImgUrl, $wgCookieDomain, $wgCookiePath, $wgResourceBasePath;
    $skin = $out->getSkin();
    $title = $out->getTitle();
    // MW1.19 - ResourceLoaderStartUpModule class adds more variables
    $cats = wfGetBreadCrumb();
    $idx = count($cats) - 2;
    if (isset($cats[$idx])) {
        $vars['wgCatId'] = $cats[$idx]['id'];
        $vars['wgParentCatId'] = $cats[$idx]['parentId'];
    } else {
        $vars['wgCatId'] = 0;
        $vars['wgParentCatId'] = 0;
    }
    $skinName = get_class($skin);
    if (is_array($wgEnableAjaxLogin) && in_array($skinName, $wgEnableAjaxLogin)) {
        $vars['wgEnableAjaxLogin'] = true;
    }
    $vars['wgBlankImgUrl'] = $wgBlankImgUrl;
    if (!empty($wgPrivateTracker)) {
        $vars['wgPrivateTracker'] = true;
    }
    // TODO: load it on-demand using JSMessages
    if ($vars['wgIsArticle'] == false && !empty($vars['wgEnableAjaxLogin'])) {
        $vars['ajaxLogin1'] = wfMsg('ajaxLogin1');
        $vars['ajaxLogin2'] = wfMsg('ajaxLogin2');
    }
    // TODO: use wgMainPageTitle instead?
    $vars['wgMainpage'] = wfMsgForContent('mainpage');
    if (Wikia::isMainPage()) {
        $vars['wgIsMainpage'] = true;
    }
    if (Wikia::isContentNamespace()) {
        $vars['wgIsContentNamespace'] = true;
    }
    $vars['wgStyleVersion'] = isset($wgStyleVersion) ? $wgStyleVersion : '';
    // TODO: is this one really needed?
    if (isset($skin->themename)) {
        $vars['themename'] = $skin->themename;
    }
    $vars['wgExtensionsPath'] = $wgExtensionsPath;
    $vars['wgResourceBasePath'] = $wgResourceBasePath;
    $vars['wgSitename'] = $wgSitename;
    // Set the JavaScript variable which is used by AJAX request to make data caching possible - Inez
    $vars['wgMWrevId'] = $wgMemc->get(wfMemcKey('wgMWrevId'));
    // macbre: get revision ID of current article
    if (($title->isContentPage() || $title->isTalkPage()) && !is_null($wgArticle)) {
        $vars['wgRevisionId'] = !empty($wgArticle->mRevision) ? $wgArticle->mRevision->getId() : intval($wgArticle->mLatest);
    }
    // is anon editing disabled?
    if ($wgDisableAnonymousEditing || $wgGroupPermissions['user']['edit'] === false) {
        $vars['wgDisableAnonymousEditing'] = true;
    }
    // moved from Interstitial.php
    $vars['wgCookieDomain'] = $wgCookieDomain;
    $vars['wgCookiePath'] = $wgCookiePath;
    wfProfileOut(__METHOD__);
    return true;
}