/** * Handler for BeforePageDisplay hook * Add JavaScript to the page when an image is on it * and the user has enabled the feature if BetaFeatures is installed * @param OutputPage $out * @param Skin $skin * @return bool */ public static function getModulesForArticle(&$out, &$skin) { if (count($out->getFileSearchOptions()) > 0 || $out->getTitle()->inNamespace(NS_FILE)) { return self::getModules($out); } return true; }
/** * Hook: BeforePageDisplay */ public static function addModules(OutputPage $out, Skin $skin) { global $wgContentTranslationEventLogging, $wgContentTranslationCampaigns; $title = $out->getTitle(); $user = $out->getUser(); // Check if CX is available for current user. if (!self::isEnabledForUser($user)) { if (!$title->exists() && $wgContentTranslationCampaigns['newarticle'] && !$out->getRequest()->getCookie('cx_campaign_newarticle_hide', '') && !$user->isAnon()) { $out->addModules('ext.cx.campaigns.newarticle.veloader'); if ($wgContentTranslationEventLogging) { $out->addModules('ext.cx.eventlogging'); } } return; } // If EventLogging integration is enabled, load the event logging functions module if ($wgContentTranslationEventLogging) { $out->addModules('ext.cx.eventlogging'); } if ($title->inNamespace(NS_MAIN) && Action::getActionName($out->getContext()) === 'view' && $title->exists()) { $out->addModules('ext.cx.interlanguagelink'); } // Add a hover menu for the contributions link in personal toolbar $out->addModules('ext.cx.campaigns.contributionsmenu'); // The current guided tours are only for the user namespace, // so load the module only there. // In the future there may be guided tours in other namespaces, // and then this condition should be changed. if (class_exists('GuidedTourHooks') && $title->inNamespace(NS_USER)) { $out->addModules('ext.guidedTour'); } }
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; }
/** * Transforms content to be mobile friendly version. * Filters out various elements and runs the MobileFormatter. * @param OutputPage $out * @param string $mode mobile mode, i.e. stable or beta * * @return string */ public static function DOMParse(OutputPage $out, $text = null, $isBeta = false) { $html = $text ? $text : $out->getHTML(); $context = MobileContext::singleton(); $formatter = MobileFormatter::newFromContext($context, $html); Hooks::run('MobileFrontendBeforeDOM', array($context, $formatter)); $title = $out->getTitle(); $isSpecialPage = $title->isSpecialPage(); $formatter->enableExpandableSections($out->canUseWikiPage() && $out->getWikiPage()->getContentModel() == CONTENT_MODEL_WIKITEXT && array_search($title->getNamespace(), $context->getMFConfig()->get('MFNamespacesWithoutCollapsibleSections')) === false && $context->getRequest()->getText('action', 'view') == 'view'); if ($context->getContentTransformations()) { // Remove images if they're disabled from special pages, but don't transform otherwise $formatter->filterContent(!$isSpecialPage); } $contentHtml = $formatter->getText(); // If the page is a user page which has not been created, then let the // user know about it with pretty graphics and different texts depending // on whether the user is the owner of the page or not. if ($isBeta && $title->inNamespace(NS_USER) && !$title->isSubpage()) { $pageUserId = User::idFromName($title->getText()); if ($pageUserId && !$title->exists()) { $pageUser = User::newFromId($pageUserId); $contentHtml = ExtMobileFrontend::getUserPageContent($out, $pageUser); } } return $contentHtml; }
function efOpenGraphMetaPageHook(OutputPage &$out, &$sk) { global $wgLogo, $wgSitename, $wgXhtmlNamespaces, $egFacebookAppId, $egFacebookAdmins; $wgXhtmlNamespaces["og"] = "http://opengraphprotocol.org/schema/"; $title = $out->getTitle(); $isMainpage = $title->isMainPage(); $meta = array(); if ($isMainpage) { $meta["og:type"] = "website"; $meta["og:title"] = $wgSitename; } else { $meta["og:type"] = "article"; $meta["og:site_name"] = $wgSitename; // Try to chose the most appropriate title for showing in news feeds. if (defined('NS_BLOG_ARTICLE') && $title->getNamespace() == NS_BLOG_ARTICLE || defined('NS_BLOG_ARTICLE_TALK') && $title->getNamespace() == NS_BLOG_ARTICLE_TALK) { $meta["og:title"] = $title->getSubpageText(); } else { $meta["og:title"] = $title->getText(); } } if (isset($out->mMainImage) && $out->mMainImage !== false) { if (is_object($out->mMainImage)) { $meta["og:image"] = wfExpandUrl($out->mMainImage->createThumb(100 * 3, 100)); } else { // In some edge-cases we won't have defined an object but rather a full URL. $meta["og:image"] = $out->mMainImage; } } elseif ($isMainpage) { $meta["og:image"] = wfExpandUrl($wgLogo); } if (isset($out->mDescription)) { // set by Description2 extension, install it if you want proper og:description support $meta["og:description"] = $out->mDescription; } $meta["og:url"] = $title->getFullURL(); if ($egFacebookAppId) { /* begin wikia change */ // $meta["fb:app_id"] = $egFacebookAppId; // fb:app_id needs a prefix property declaring the namespace, so just add it directly $out->addHeadItem("meta:property:fb:app_id", "\t" . Html::element('meta', array('property' => 'fb:app_id', 'content' => $egFacebookAppId, 'prefix' => "fb: http://www.facebook.com/2008/fbml")) . "\n"); /* end wikia change */ } if ($egFacebookAdmins) { $meta["fb:admins"] = $egFacebookAdmins; } /* begin wikia change */ wfRunHooks('OpenGraphMetaHeaders', array("meta" => &$meta, "title" => $title)); /* end wikia change */ foreach ($meta as $property => $value) { if ($value) { if (isset(OutputPage::$metaAttrPrefixes) && isset(OutputPage::$metaAttrPrefixes['property'])) { $out->addMeta("property:{$property}", $value); } else { $out->addHeadItem("meta:property:{$property}", "\t" . Html::element('meta', array('property' => $property, 'content' => $value)) . "\n"); } } } return true; }
/** * Hook-Handler for MediaWiki 'BeforePageDisplay' hook. Sets context if needed. * @param OutputPage $oOutputPage * @param Skin $oSkin * @return bool */ public function onBeforePageDisplay(&$oOutputPage, &$oSkin) { if (!SpecialPage::getTitleFor('Preferences')->equals($oOutputPage->getTitle())) { return true; } $oOutputPage->addModules('ext.bluespice.userpreferences'); return true; }
/** * Adds module * @param OutputPage $out * @param SkinTemplate $skin * @return boolean */ public static function onBeforePageDisplay(&$out, &$skin) { if (!$out->getTitle()->equals($out->getUser()->getUserPage())) { return true; } $out->addModules("ext.bluespice.avatars.js"); return true; }
function hookOutputPageBeforeHTML(OutputPage &$out, &$text) { if ($out->getTitle()->getNamespace() == 6) { //6 is the File Namespace $out->includeJQuery(); $out->addModules('ext.SemanticImageAnnotator'); } return true; }
public static function onBeforePageDisplay(OutputPage $out, Skin $sk) { wfProfileIn(__METHOD__); $title = $out->getTitle(); if ($title instanceof Title && $title->isContentPage()) { $storage = PlaceStorage::newFromTitle($out->getTitle()); $model = $storage->getModel(); /* @var $model PlaceModel */ if ($model instanceof PlaceModel && !$model->isEmpty()) { $out->addMeta('geo.position', implode(',', $model->getLatLon())); } } if ($title instanceof Title && $title->getNamespace() == NS_CATEGORY) { $out->addScript('<script src="' . F::app()->wg->extensionsPath . '/wikia/Places/js/GeoEnableButton.js"></script>'); $out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/Places/css/GeoEnableButton.scss')); } wfProfileOut(__METHOD__); return true; }
/** * Parser hook registering the GUI module only in edit pages. * * @param EditPage $editPage * @param OutputPage $output * @return bool */ public static function onEditPage($editPage, $output) { global $wgTemplateDataUseGUI; if ($wgTemplateDataUseGUI) { if ($output->getTitle()->getNamespace() === NS_TEMPLATE) { $output->addModules('ext.templateDataGenerator.editPage'); } } return true; }
/** * This function adds additional modules containing CSS before the page is displayed */ public function onBeforePageDisplay(OutputPage &$out, Skin &$ski) { $title_object = $out->getTitle(); $page_title = $title_object->getPrefixedURL(); if ($page_title === 'Special:UserPage' || $page_title === 'Special:AllCollections' || $page_title === 'Special:SingleManuscriptPages' || $page_title === 'Special:AllCollations' || $page_title === 'Special:RecentManuscriptPages' || $page_title === 'Special:AllStylometricAnalysis') { $out->addModuleStyles(array('ext.userpagecss', 'ext.manuscriptdeskbasecss')); $out->addModules("ext.javascriptloaderdots"); } return true; }
/** * * @param OutputPage $oOutputPage * @param SkinTemplate $oSkinTemplate * @return boolean */ public function onBeforePageDisplay($oOutputPage, $oSkinTemplate) { $oTitle = $oOutputPage->getTitle(); $sHideTitlePageProp = BsArticleHelper::getInstance($oTitle)->getPageProp('bs_hidetitle'); if ($sHideTitlePageProp === '') { $oOutputPage->mPagetitle = ''; $oOutputPage->addInlineScript("\$('.firstHeading').remove()"); } return true; }
public static function onBeforePageDisplay(OutputPage $out, SkinTemplate $sk) { $config = $out->getConfig(); if (self::canOutputHreflang($config)) { # Generate hreflang tags $languageLinks = $out->getLanguageLinks(); if (empty($languageLinks)) { // shortcut - if we don't have any language links, don't bother return; } $addedLink = false; $pages = $config->get("HreflangPages"); if (!$pages) { $pages = array(); $foundPage = true; } else { $pages = array_flip($pages); $pageName = $out->getLanguage()->getHtmlCode() . ":" . $out->getTitle()->getBaseText(); $foundPage = isset($pages[$pageName]); } foreach ($languageLinks as $languageLinkText) { $languageLinkTitle = Title::newFromText($languageLinkText); if (!$languageLinkTitle) { continue; } $ilInterwikiCode = $languageLinkTitle->getInterwiki(); if (!Language::isKnownLanguageTag($ilInterwikiCode)) { continue; } $foundPage = $foundPage || isset($pages[$languageLinkText]); $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => wfBCP47($ilInterwikiCode), 'href' => $languageLinkTitle->getFullURL())); $addedLink = true; } // Only add current language link if we had any other links if ($addedLink) { $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $out->getLanguage()->getHtmlCode(), 'href' => $out->getTitle()->getFullURL())); } } if ($foundPage && $tags) { $out->addHeadItem("hreflang:tags", join("\n", $tags)); } }
/** * BeofrePageDislpay hook. Load additional modules containing CSS before the page is displayed */ public function onBeforePageDisplay(OutputPage &$out, Skin &$ski) { $page_title_with_namespace = $out->getTitle()->getPrefixedURL(); if ($page_title_with_namespace === 'Special:HelperScripts') { $css_modules = array('ext.manuscriptdeskbasecss'); $javascript_modules = array('ext.javascriptloader'); $out->addModuleStyles($css_modules); $out->addModules($javascript_modules); } return true; }
/** * Adds feeds to the page header * * @param OutputPage $out * @return bool */ public static function beforePageDisplay(OutputPage &$out) { global $wgAdvertisedFeedTypes; if ($out->getTitle()->isMainPage()) { foreach (self::getFeeds($out->getLanguage()->getCode()) as $feed) { foreach ($wgAdvertisedFeedTypes as $type) { $out->addLink(array('rel' => 'alternate', 'type' => "application/{$type}+xml", 'title' => $feed->title, 'href' => $feed->getURL($type))); } } } return true; }
/** * Handler for the BeforePageDisplay hook, injects special behaviour * for PropertySuggestions in the EntitySuggester (if page is in EntityNamespace) * * * @param OutputPage $out * @param Skin $skin * @return bool */ public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) { if ($out->getRequest()->getCheck('nosuggestions')) { return true; } $entityNamespaceLookup = WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup(); $itemNamespace = $entityNamespaceLookup->getEntityNamespace(CONTENT_MODEL_WIKIBASE_ITEM); if ($out->getTitle()->getNamespace() !== $itemNamespace) { return true; } $out->addModules('ext.PropertySuggester.EntitySelector'); return true; }
public static function onBeforePageDisplay(\OutputPage $out, \Skin $skin) { $helper = new FlagsHelper(); /* Assets for flags view */ if ($helper->shouldDisplayFlags() || $out->getTitle()->isSpecial('Flags')) { \Wikia::addAssetsToOutput('flags_view_scss'); } /* Assets for flags edit form */ if ($helper->areFlagsEditable()) { \Wikia::addAssetsToOutput('flags_editform_js'); $out->addModules('ext.wikia.Flags.EditFormMessages'); } return true; }
/** * 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; }
/** * Adds required JavaScript & CSS files to the HTML output of a page if AjaxLogin is enabled * * @param $out OutputPage object * @return true */ function AjaxLoginJS(OutputPage $out) { global $wgEnableAjaxLogin, $wgScriptPath; # Don't load anything if AjaxLogin isn't enabled or if we're on login page if (!isset($wgEnableAjaxLogin) || $out->getTitle()->isSpecial('Userlogin')) { return true; } // Our custom CSS $out->addExtensionStyle($wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.css'); // jQuery and JQModal scripts $out->includeJQuery(); $out->addScriptFile($wgScriptPath . '/extensions/AjaxLogin/jqModal.js'); $out->addScriptFile($wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.js'); return true; }
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; }
/** * Transforms content to be mobile friendly version. * Filters out various elements and runs the MobileFormatter. * @param OutputPage $out * * @return string */ public static function DOMParse(OutputPage $out) { $html = $out->getHTML(); $context = MobileContext::singleton(); $formatter = MobileFormatter::newFromContext($context, $html); Hooks::run('MobileFrontendBeforeDOM', array($context, $formatter)); $title = $out->getTitle(); $isSpecialPage = $title->isSpecialPage(); $formatter->enableExpandableSections($out->canUseWikiPage() && $out->getWikiPage()->getContentModel() == CONTENT_MODEL_WIKITEXT && array_search($title->getNamespace(), $context->getMFConfig()->get('MFNamespacesWithoutCollapsibleSections')) === false && $context->getRequest()->getText('action', 'view') == 'view'); if ($context->getContentTransformations()) { // Remove images if they're disabled from special pages, but don't transform otherwise $formatter->filterContent(!$isSpecialPage); } $contentHtml = $formatter->getText(); return $contentHtml; }
static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) { $languageLinks = $out->getLanguageLinks(); if (empty($languageLinks)) { return true; } // this is partly a ripoff from SkinTemplate::getLanguages() foreach ($languageLinks as $langLink) { $languageLinkTitle = Title::newFromText($langLink); $interwikiCode = $languageLinkTitle->getInterwiki(); $out->addLink(array('rel' => 'alternate', 'hreflang' => wfBCP47($interwikiCode), 'href' => wfExpandIRI($languageLinkTitle->getFullURL()))); } // We also must add the current language $currentPageLangCode = $out->getLanguage()->getCode(); $currentPageTitle = $out->getTitle(); $out->addLink(array('rel' => 'alternate', 'hreflang' => wfBCP47($currentPageLangCode), 'href' => wfExpandIRI($currentPageTitle->getFullURL()))); return true; }
/** * Hook function for BeforePageDisplay */ function efSkinPerPageBeforePageDisplayHook(OutputPage &$out, Skin &$skin) { global $wgSkinPerNamespace, $wgSkinPerSpecialPage, $wgSkinPerNamespaceOverrideLoggedIn, $wgUser; if (!$wgSkinPerNamespaceOverrideLoggedIn && $wgUser->isLoggedIn()) { return true; } $title = $out->getTitle(); $ns = $title->getNamespace(); $skinName = null; if ($ns == NS_SPECIAL) { list($canonical, ) = SpecialPageFactory::resolveAlias($title->getDBkey()); if (isset($wgSkinPerSpecialPage[$canonical])) { $skinName = $wgSkinPerSpecialPage[$canonical]; } } if ($skinName === null && isset($wgSkinPerNamespace[$ns])) { $skinName = $wgSkinPerNamespace[$ns]; } if ($skinName !== null) { $skin = Skin::newFromKey($skinName); $skin->setRelevantTitle($title); } return true; }
/** * Adds extra variables to the page config. */ public static function onMakeGlobalVariablesScript(array &$vars, OutputPage $out) { $pageLanguage = $out->getTitle()->getPageLanguage(); $vars['wgVisualEditor'] = array('pageLanguageCode' => $pageLanguage->getHtmlCode(), 'pageLanguageDir' => $pageLanguage->getDir()); return true; }
/** * @param $helppage Article * @return bool */ function fnHelpCommonsLoad(OutputPage &$helppage, Skin &$skin) { global $wgRequest, $wgHelpCommonsFetchingWikis, $wgDBname, $wgLanguageCode, $wgOut, $wgHelpCommonsShowCategories, $wgContLang; $title = $helppage->getTitle(); $action = $wgRequest->getVal('action', 'view'); if ($title->getNamespace() != NS_HELP || $action != 'view' && $action != 'purge') { return true; } foreach ($wgHelpCommonsFetchingWikis as $language => $dbs) { foreach ($dbs as $db => $urls) { foreach ($urls as $url => $helpWikiPrefixes) { foreach ($helpWikiPrefixes as $helpWikiPrefix => $name) { if ($wgLanguageCode == $language) { if ($db != 'no-database') { if ($wgDBname == $db) { return true; } } $dbkey = $title->getDBkey(); if ($helpWikiPrefix != 'no-prefix') { $prefix = '/' . $helpWikiPrefix; } else { $prefix = ''; } // check if requested page does exist $apiResponse = file_get_contents($url . $prefix . '/api.php?format=php&action=query&titles=Help:' . $dbkey); $apiData = unserialize($apiResponse); if (!$apiResponse) { return true; } if (!$apiData) { return true; } if (!$apiData['query']) { return true; } foreach ($apiData['query']['pages'] as $pageId => $pageData) { if (!isset($pageData['missing'])) { // remove noarticletext message and its <div> if not existent (does remove all content) if (!$title->exists()) { $wgOut->clearHTML(); } $response = file_get_contents($url . $prefix . '/api.php?format=json&action=parse&prop=text|categorieshtml&redirects&disablepp&pst&text={{:Help:' . $dbkey . '}}'); $data = json_decode($response, true); $text = $data['parse']['text']['*']; $text_html = str_replace('<span class="editsection">[<a href="' . $prefix . '/', '<span class="editsection">[<a href="' . $url . $prefix . '/', $text); // re-locate [edit] links to help wiki if ($wgHelpCommonsShowCategories) { $categories = $data['parse']['categorieshtml']['*']; $categories_html = str_replace('<a href="', '<a href="' . $url, $categories); $content = $text_html . $categories_html; } else { $content = $text_html; } $wgOut->addHTML('<div id="helpCommons" style="border: solid 1px; padding: 10px; margin: 5px;">' . '<div class="helpCommonsInfo" style="text-align: right; font-size: smaller;padding: 5px;">' . wfMsgForContent('helpcommons-info', $name, '<a href="' . $url . $prefix . '/index.php?title=Help:' . $dbkey . '" title="' . $wgContLang->namespaceNames[NS_HELP] . ':' . str_replace('_', ' ', $dbkey) . '">' . $wgContLang->namespaceNames[NS_HELP] . ':' . str_replace('_', ' ', $dbkey) . '</a>') . '</div>' . $content . '</div>'); return false; } else { return true; } } } } } } } return true; }
/** * Get the Title object of the page the links should point to. * This is NOT the Title of the page the entries should be restricted to. * * @return Title object */ public function getDisplayTitle() { return $this->out->getTitle(); }
/** * This hook copies SMW's custom data from the given ParserOutput object to * the given OutputPage object, since otherwise it is not possible to access * it later on to build a Factbox. * * @param OutputPage $outputpage * @param ParserOutput $parseroutput * * @return true */ public static function onOutputPageParserOutput(OutputPage $outputpage, ParserOutput $parseroutput) { global $wgParser; $factbox = SMWFactbox::getFactboxTextFromOutput($parseroutput, $outputpage->getTitle()); if ($factbox !== '') { $popts = new ParserOptions(); $po = $wgParser->parse($factbox, $outputpage->getTitle(), $popts); $outputpage->mSMWFactboxText = $po->getText(); // do not forget to grab the outputs header items SMWOutputs::requireFromParserOutput($po); SMWOutputs::commitToOutputPage($outputpage); } // else: nothing shown, don't even set any text return true; }
/** * MediaWiki BeforePageDisplay hook. Adds additional modules containing CSS before the page is displayed */ public function onBeforePageDisplay(OutputPage &$out, Skin &$ski) { try { $partial_url = $out->getTitle()->mPrefixedText; if ($this->isInManuscriptsNamespace($out) && $this->manuscriptIsInViewMode($out) && $this->user_has_view_permission) { //doing this here ensures the table will be displayed at the bottom of the $this->addMetatableToManuscriptsPage($out); $out->addModuleStyles('ext.manuscriptpagecss'); } elseif ($partial_url === 'Special:NewManuscript') { $out->addModules('ext.javascriptloader'); $out->addModules('ext.newmanuscriptbuttoncontroller'); $out->addModuleStyles('ext.manuscriptdeskbasecss'); } return true; } catch (Exception $e) { return true; } }
public static function replaceSubtitle(&$subpages, $skin = null, OutputPage $out) { if (!TranslatablePage::isTranslationPage($out->getTitle()) && !TranslatablePage::isSourcePage($out->getTitle())) { return true; } // Copied from Skin::subPageSubtitle() if ($out->isArticle() && MWNamespace::hasSubpages($out->getTitle()->getNamespace())) { $ptext = $out->getTitle()->getPrefixedText(); if (preg_match('/\\//', $ptext)) { $links = explode('/', $ptext); array_pop($links); // Also pop of one extra for language code is needed if (TranslatablePage::isTranslationPage($out->getTitle())) { array_pop($links); } $c = 0; $growinglink = ''; $display = ''; foreach ($links as $link) { $growinglink .= $link; $display .= $link; $linkObj = Title::newFromText($growinglink); if (is_object($linkObj) && $linkObj->exists()) { $getlink = Linker::linkKnown(SpecialPage::getTitleFor('MyLanguage', $growinglink), htmlspecialchars($display)); $c++; if ($c > 1) { $subpages .= wfMessage('pipe-separator')->plain(); } else { // This one is stupid imho, doesn't work with chihuahua // $subpages .= '< '; } $subpages .= $getlink; $display = ''; } else { $display .= '/'; } $growinglink .= '/'; } } return false; } return true; }
/** * 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; }