/** * The template used for article pages and edit previews. */ public function articlePage() { wfProfileIn(__METHOD__); // Template rendering cancelled by hook if (!wfRunHooks('CategorySelectArticlePage')) { wfProfileOut(__METHOD__); return false; } $categories = $this->wg->out->getCategories(); $showHidden = (bool) $this->wg->User->getGlobalPreference('showhiddencats'); $userCanEdit = $this->request->getVal('userCanEdit', CategorySelectHelper::isEditable()); // There are no categories present and user can't edit, skip rendering if (!$userCanEdit && !count($categories)) { wfProfileOut(__METHOD__); return false; } // Categories link $categoriesLinkAttributes = array('class' => 'categoriesLink'); $categoriesLinkPage = wfMessage('pagecategorieslink')->inContentLanguage()->text(); $categoriesLinkText = wfMessage('pagecategories')->escaped(); if (!empty($this->wg->WikiaUseNoFollow)) { $categoriesLinkAttributes['rel'] = 'nofollow'; } $categoriesLink = Linker::link(Title::newFromText($categoriesLinkPage), $categoriesLinkText, $categoriesLinkAttributes); Wikia::addAssetsToOutput('category_select_css'); Wikia::addAssetsToOutput('category_select_js'); $this->response->setVal('categories', $categories); $this->response->setVal('categoriesLink', $categoriesLink); $this->response->setVal('showHidden', $showHidden); $this->response->setVal('userCanEdit', $userCanEdit); if ($this->app->checkSkin('venus')) { $this->overrideTemplate('articlePageVenus'); } wfProfileOut(__METHOD__); }
public function index() { wfProfileIn(__METHOD__); Wikia::addAssetsToOutput('recent_wiki_activity_scss'); Wikia::addAssetsToOutput('recent_wiki_activity_js'); $this->changeList = WikiaDataAccess::cache(wfMemcKey(self::$memcKey), 0, function () { global $wgContentNamespaces, $wgLang; $maxElements = 4; $includeNamespaces = implode('|', $wgContentNamespaces); $parameters = array('type' => 'widget', 'maxElements' => $maxElements, 'flags' => array('shortlist'), 'uselang' => $wgLang->getCode(), 'includeNamespaces' => $includeNamespaces); $feedProxy = new ActivityFeedAPIProxy($includeNamespaces, $this->userName); $feedProvider = new DataFeedProvider($feedProxy, 1, $parameters); $feedData = $feedProvider->get($maxElements); foreach ($feedData['results'] as &$result) { if (!empty($result['articleComment'])) { $title = Title::newFromText($result['title'], $result['ns']); if ($title instanceof Title) { $result['url'] = $title->getLocalURL(); } } } return $feedData['results']; }); wfProfileOut(__METHOD__); }
public function index() { $this->messages = $this->getVal('messages'); // loading assets in Monobook that would normally load in oasis if ($this->app->checkSkin('monobook')) { $this->response->addAsset('skins/shared/styles/sprite.scss'); $this->response->addAsset('extensions/wikia/Forum/css/monobook/RelatedForumMonobook.scss'); } $title = $this->getContext()->getTitle(); $topicTitle = Title::newFromText($title->getPrefixedText(), NS_WIKIA_FORUM_TOPIC_BOARD); // common data $this->sectionHeading = wfMessage('forum-related-discussion-heading', $title->getText())->escaped(); $this->newPostButton = wfMessage('forum-related-discussion-new-post-button')->escaped(); $this->newPostUrl = $topicTitle->getFullUrl('openEditor=1'); $this->newPostTooltip = wfMessage('forum-related-discussion-new-post-tooltip', $title->getText())->escaped(); $this->blankImgUrl = wfBlankImgUrl(); $this->seeMoreUrl = $topicTitle->getFullUrl(); $this->seeMoreText = wfMessage('forum-related-discussion-see-more')->escaped(); // TODO: move classes to template when Venus will be live on all wikis $this->venusBtnClasses = ''; if ($this->app->checkSkin('venus')) { $this->venusBtnClasses = 'wikia-button secondary'; Wikia::addAssetsToOutput('related_forum_discussion_css'); } }
/** * Load JS needed to display the VideosModule at the bottom of the article content * @param OutputPage $out * @param string $text * @return bool */ public static function onOutputPageBeforeHTML(OutputPage $out, &$text) { wfProfileIn(__METHOD__); // Check if we're on a page where we want to show the Videos Module. // If we're not, stop right here. if (!self::canShowVideosModule()) { wfProfileOut(__METHOD__); return true; } // On file pages, this hook can be called multiple times, so we're going to check if the // assets are loaded already before we load them again. $app = F::app(); // Don't do anything if we've already loaded the assets if ($app->wg->VideosModuleAssetsLoaded) { wfProfileOut(__METHOD__); return true; } // Don't do anything if this is the main page of a site with the VPT enabled if ($app->wg->Title->isMainPage() && $app->wg->EnableVideoPageToolExt) { wfProfileOut(__METHOD__); return true; } JSMessages::enqueuePackage('VideosModule', JSMessages::EXTERNAL); if ($app->checkSkin('venus')) { Wikia::addAssetsToOutput('videos_module_venus_js'); Wikia::addAssetsToOutput('videos_module_venus_scss'); } else { Wikia::addAssetsToOutput('videos_module_js'); } $app->wg->VideosModuleAssetsLoaded = true; wfProfileOut(__METHOD__); return true; }
/** * Load Captcha.js on demand when we're getting an instance of a Captcha. */ public static function addCaptchaJS() { // Make sure we only load FancyCaptcha library once if (!\F::app()->wg->CaptchaLibraryLoaded) { \Wikia::addAssetsToOutput('captcha_js'); \F::app()->wg->CaptchaLibraryLoaded = true; } }
function execute($par) { $this->mName = 'WikiaNewFiles'; $this->setHeaders(); Wikia::addAssetsToOutput('upload_photos_dialog_js'); Wikia::addAssetsToOutput('upload_photos_dialog_scss'); wfSpecialWikiaNewFiles($par, $this); }
/** * Add JS module to the output * @param \OutputPage $out An output object passed from a hook * @return bool */ public static function onBeforePageDisplay(\OutputPage $out) { // use resource loader for i18n messages in JS $out->addModules('ext.cookiePolicyMessages'); // use AssetsManager for script loading to avoid race conditions (SOC-528) \Wikia::addAssetsToOutput('cookie_policy_js'); return true; }
public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { if (F::app()->checkSkin('monobook', $skin)) { Wikia::addAssetsToOutput('portable_infobox_monobook_scss'); } else { Wikia::addAssetsToOutput('portable_infobox_scss'); } return true; }
public static function onBlogArticleInitialized(CreateBlogPage $blogPage, $mode) { if ($mode == SpecialCustomEditPage::MODE_EDIT || !$blogPage->user->isAllowed(self::PERM_NAME)) { return true; } Wikia::addAssetsToOutput('extensions/wikia/BlogEditCategoryPrompter/becp.js'); JSMessages::enqueuePackage('BECP', JSMessages::INLINE); return true; }
public function index() { Wikia::addAssetsToOutput('global_footer_scss'); Wikia::addAssetsToOutput('global_footer_js'); $this->response->setVal('footerLinks', $this->getGlobalFooterLinks()); $this->response->setVal('copyright', RequestContext::getMain()->getSkin()->getCopyright()); $this->response->setVal('isCorporate', WikiaPageType::isWikiaHomePage()); $this->response->setVal('verticalShort', $this->getVerticalShortName()); $this->response->setVal('verticalNameMessage', $this->verticalNameMessage()); $this->response->setVal('logoLink', $this->getLogoLink()); }
/** * @brief Displays the main menu for the admin dashboard * */ public function index() { $this->wg->Out->setPageTitle(wfMsg('admindashboard-title')); if (!$this->wg->User->isAllowed('admindashboard')) { $this->displayRestrictionError(); return false; // skip rendering } $this->tab = $this->getVal('tab', 'general'); // links $this->urlThemeDesigner = Title::newFromText('ThemeDesigner', NS_SPECIAL)->getFullURL(); $this->urlRecentChanges = Title::newFromText('RecentChanges', NS_SPECIAL)->getFullURL(); $this->urlTopNavigation = Title::newFromText('Wiki-navigation', NS_MEDIAWIKI)->getFullURL('action=edit'); $this->urlWikiFeatures = Title::newFromText('WikiFeatures', NS_SPECIAL)->getFullURL(); $this->urlListUsers = Title::newFromText('ListUsers', NS_SPECIAL)->getFullURL(); $this->urlUserRights = Title::newFromText('UserRights', NS_SPECIAL)->getFullURL(); $this->urlCommunityCorner = Title::newFromText('Community-corner', NS_MEDIAWIKI)->getFullURL('action=edit'); $this->urlAllCategories = Title::newFromText('Categories', NS_SPECIAL)->getFullURL(); $this->urlAddPage = Title::newFromText('CreatePage', NS_SPECIAL)->getFullURL(); $this->urlAddPhoto = Title::newFromText('Upload', NS_SPECIAL)->getFullURL(); if (!empty($this->wg->EnableSpecialVideosExt)) { $this->showVideoLink = true; $this->urlAddVideo = Title::newFromText('WikiaVideoAdd', NS_SPECIAL)->getFullURL(); $this->urlAddVideoReturnUrl = SpecialPage::getTitleFor("Videos")->escapeLocalUrl("sort=recent"); } else { $this->showVideoLink = false; } $this->urlCreateBlogPage = Title::newFromText('CreateBlogPage', NS_SPECIAL)->getFullURL(); $this->urlMultipleUpload = Title::newFromText('MultipleUpload', NS_SPECIAL)->getFullURL(); $this->urlLVS = Title::newFromText('LicensedVideoSwap', NS_SPECIAL)->getFullURL(); $this->urlSpecialCss = SpecialPage::getTitleFor('CSS')->getFullURL(); // special:specialpages $this->advancedSection = (string) $this->app->sendRequest('AdminDashboardSpecialPage', 'getAdvancedSection', array()); // icon display logic $this->displayWikiFeatures = !empty($this->wg->EnableWikiFeatures); $this->displaySpecialCss = !empty($this->wg->EnableSpecialCssExt); // LicensedVideoSwap if (empty($this->wg->EnableLicensedVideoSwapExt)) { $this->displayLicensedVideoSwap = false; $this->badgeLicensedVideoSwap = ''; } else { $this->displayLicensedVideoSwap = true; // alert badge $lvsHelper = new LicensedVideoSwapHelper(); $this->badgeLicensedVideoSwap = $lvsHelper->getAlertBadge(); } // add messages package JSMessages::enqueuePackage('AdminDashboard', JSMessages::INLINE); // Add Upload Photos Dialog Wikia::addAssetsToOutput('upload_photos_dialog_js'); Wikia::addAssetsToOutput('upload_photos_dialog_scss'); }
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; }
private function setBodyModules() { $this->globalNavigation = $this->getGlobalNavigation(); $this->localNavigation = $this->getLocalNavigation(); $this->categorySelect = $this->getCategorySelect(); $this->notifications = $this->app->renderView('BannerNotifications', 'Confirmation'); if ($this->isUserLoggedIn) { $this->recentWikiActivity = $this->getRecentWikiActivity(); } if (WikiaPageType::isArticlePage()) { $this->articleNav = $this->getArticleNavigation(); $this->setVal('header', $this->app->renderView('Venus', 'header')); Wikia::addAssetsToOutput('article_scss'); } }
/** * render index */ public function index() { $app = F::app(); Wikia::addAssetsToOutput('article_navigation_scss'); Wikia::addAssetsToOutput('article_navigation_js'); Wikia::addAssetsToOutput('article_js'); $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE); $this->setVal('editActionsDropdown', $this->renderEditActions()); $this->setVal('share', $app->renderView('ArticleNavigationController', 'share')); $this->setVal('userTools', json_encode($this->helper->extractDropdownData($this->generateUserTools()))); // messages $this->setVal('tocTitle', wfMessage('article-navigation-icon-title-toc')->text()); $this->setVal('editTitle', wfMessage('article-navigation-icon-title-edit')->text()); $this->setVal('toolsTitle', wfMessage('article-navigation-icon-title-tools')->text()); }
public function index() { global $wgLang, $wgUser; Wikia::addAssetsToOutput('global_navigation_scss'); Wikia::addAssetsToOutput('global_navigation_js'); //Lang for centralUrl and CNW should be the same as user language not content language //That's why $wgLang global is used $lang = $wgLang->getCode(); $centralUrl = $this->wikiaLogoHelper->getCentralUrlForLang($lang); $createWikiUrl = $this->helper->getCreateNewWikiUrl($lang); $userCanRead = $wgUser->isAllowed('read'); $this->response->setVal('centralUrl', $centralUrl); $this->response->setVal('createWikiUrl', $createWikiUrl); $this->response->setVal('notificationsEnabled', !empty($userCanRead)); $this->response->setVal('isAnon', $wgUser->isAnon()); $isGameStarLogoEnabled = $this->isGameStarLogoEnabled(); $this->response->setVal('isGameStarLogoEnabled', $isGameStarLogoEnabled); if ($isGameStarLogoEnabled) { $this->response->addAsset('extensions/wikia/GlobalNavigation/styles/GlobalNavigationGameStar.scss'); } }
/** * Test for WikiaSkin::getScriptsWithCombinedGroups */ public function testGetScriptsWithCombinedGroups() { global $wgStyleVersion, $wgCdnRootUrl; $cb = $wgStyleVersion; $inlineScripts = ['var inlineScript = true;']; $groups = ['tracker_js', 'oasis_jquery']; $singleAssets = ['/extensions/wikia/Foo/js/bar.js']; $skin = new DummySkin(); $out = $skin->getOutput(); // add the stuff the output foreach ($inlineScripts as $item) { $out->addScript(\Html::inlineScript($item)); } foreach ($groups as $item) { \Wikia::addAssetsToOutput($item); } foreach ($singleAssets as $item) { \Wikia::addAssetsToOutput($item); } $jsGroups = ['jquery']; $combinedScripts = $skin->getScriptsWithCombinedGroups($jsGroups); // assert that single AM groups are not requested foreach ($groups as $item) { $this->assertNotContains("/__am/{$cb}/group/-/{$item}", $combinedScripts, "'{$item}' group should not be loaded separately"); } // assert that single static files are still requested foreach ($singleAssets as $item) { $this->assertContains("/{$item}", $combinedScripts, "'{$item}' asset should still be loaded separately"); } // assert that inline scripts are still there foreach ($inlineScripts as $item) { $this->assertContains(\Html::inlineScript($item), $combinedScripts, "Inline scripts should be kept"); } // assert that combined AM groups <script> tag is the first one $items = join(',', array_merge(['jquery'], $groups)); $this->assertStringStartsWith("<script src='{$wgCdnRootUrl}/__am/{$cb}/groups/-/{$items}", $combinedScripts, "'{$items}' groups should be loaded in a single request"); // $jsGroups should be updated with the full list of combined groups $this->assertEquals($jsGroups, array_merge(['jquery'], $groups), '$jsGroups should contain the list of combined groups'); }
/** * Register global JS variables bottom * * @param array $vars * * @return bool */ public static function onMakeGlobalVariablesScript(&$vars) { Wikia::addAssetsToOutput('extensions/wikia/Staging/js/Staging.js'); $vars['wgStagingEnvironment'] = true; return true; }
/** * @param $components */ private function includeComponentsAssets($components) { foreach ($components as $component) { if (!empty($component['examples'])) { foreach ($component['examples'] as $example) { if (!empty($example->assets)) { foreach ($example->assets as $assetUrl) { \Wikia::addAssetsToOutput($assetUrl); } } } } } }
/** * @desc Adds asset to load * * @param $assetName */ private function addAsset($assetName) { wfProfileIn(__METHOD__); \Wikia::addAssetsToOutput($assetName); wfProfileOut(__METHOD__); }
/** * @desc Adds an asset to the current response * * @see Wikia::addAssetsToOutput */ public function addAsset($assetName, $local = false) { wfProfileIn(__METHOD__); if ($this->format == 'html') { Wikia::addAssetsToOutput($assetName, $local); } wfProfileOut(__METHOD__); }
public function index() { Wikia::addAssetsToOutput('page_share_scss'); Wikia::addAssetsToOutput('page_share_js'); $this->skipRendering(); }
public function Index() { Wikia::addAssetsToOutput('local_navigation_scss'); Wikia::addAssetsToOutput('local_navigation_oasis_scss'); Wikia::addAssetsToOutput('local_navigation_js'); }
/** * Add JS assets package to the output * @param \OutputPage $out An output object passed from a hook * @return bool */ public static function onBeforePageDisplay(\OutputPage $out) { \Wikia::addAssetsToOutput('wikia_in_your_lang_js'); return true; }