/** * Render default page header (with edit dropdown, history dropdown, ...) * * @param: array $params * key: showSearchBox (default: false) */ public function executeIndex($params) { global $wgTitle, $wgArticle, $wgOut, $wgUser, $wgContLang, $wgSupressPageTitle, $wgSupressPageSubtitle, $wgSuppressNamespacePrefix, $wgEnableWallExt; wfProfileIn(__METHOD__); $this->isUserLoggedIn = $wgUser->isLoggedIn(); // check for video add button permissions $this->showAddVideoBtn = $wgUser->isAllowed('videoupload'); // page namespace $ns = $wgTitle->getNamespace(); /** start of wikia changes @author nAndy */ $this->isWallEnabled = !empty($wgEnableWallExt) && $ns == NS_USER_WALL; /** end of wikia changes */ // currently used skin $skin = RequestContext::getMain()->getSkin(); // action button (edit / view soruce) and dropdown for it $this->prepareActionButton(); // dropdown actions $this->dropdown = $this->getDropdownActions(); /** start of wikia changes @author nAndy */ $response = $this->getResponse(); if ($response instanceof WikiaResponse) { wfRunHooks('PageHeaderIndexAfterActionButtonPrepared', array($response, $ns, $skin)); /** @author Jakub */ $this->extraButtons = array(); wfRunHooks('PageHeaderIndexExtraButtons', array($response)); } else { // it happened on TimQ's devbox that $response was probably null fb#28747 WikiaLogger::instance()->error('Response not an instance of WikiaResponse', ['ex' => new Exception()]); } /** end of wikia changes */ // for not existing pages page header is a bit different $this->pageExists = !empty($wgTitle) && $wgTitle->exists(); // default title "settings" (RT #145371), don't touch special pages if ($ns != NS_SPECIAL) { $this->displaytitle = true; $this->title = $wgOut->getPageTitle(); } else { // on special pages titles are already properly encoded (BugId:5983) $this->displaytitle = true; } // perform namespace and special page check // use service to get data $service = PageStatsService::newFromTitle($wgTitle); // comments - moved here to display comments even on deleted/non-existant pages $this->comments = $service->getCommentsCount(); if ($this->pageExists) { // mainpage? if (WikiaPageType::isMainPage()) { $this->isMainPage = true; } // number of pages on this wiki $this->tallyMsg = wfMessage('oasis-total-articles-mainpage', SiteStats::articles())->parse(); } // remove namespaces prefix from title $namespaces = array(NS_MEDIAWIKI, NS_TEMPLATE, NS_CATEGORY, NS_FILE); if (in_array($ns, array_merge($namespaces, $wgSuppressNamespacePrefix))) { $this->title = $wgTitle->getText(); $this->displaytitle = false; } // talk pages if ($wgTitle->isTalkPage()) { // remove comments & FB like button $this->comments = false; // Talk: <page name without namespace prefix> $this->displaytitle = true; $this->title = Xml::element('strong', array(), $wgContLang->getNsText(NS_TALK) . ':'); $this->title .= htmlspecialchars($wgTitle->getText()); // back to subject article link switch ($ns) { case NS_TEMPLATE_TALK: $msgKey = 'oasis-page-header-back-to-template'; break; case NS_MEDIAWIKI_TALK: $msgKey = 'oasis-page-header-back-to-mediawiki'; break; case NS_CATEGORY_TALK: $msgKey = 'oasis-page-header-back-to-category'; break; case NS_FILE_TALK: $msgKey = 'oasis-page-header-back-to-file'; break; default: $msgKey = 'oasis-page-header-back-to-article'; } $this->pageTalkSubject = Wikia::link($wgTitle->getSubjectPage(), wfMsg($msgKey), array('accesskey' => 'c')); } // forum namespace if ($ns == NS_FORUM) { // remove comments button $this->comments = false; // remove namespace prefix $this->title = $wgTitle->getText(); $this->displaytitle = false; } // mainpage if (WikiaPageType::isMainPage()) { // change page title to just "Home" $this->title = wfMsg('oasis-home'); } // render page type info switch ($ns) { case NS_MEDIAWIKI: $this->pageType = wfMsg('oasis-page-header-subtitle-mediawiki'); break; case NS_TEMPLATE: $this->pageType = wfMsg('oasis-page-header-subtitle-template'); break; case NS_SPECIAL: $this->pageType = wfMsg('oasis-page-header-subtitle-special'); // remove comments button (fix FB#3404 - Marooned) $this->comments = false; if ($wgTitle->isSpecial('Newimages')) { $this->isNewFiles = true; } if ($wgTitle->isSpecial('Videos')) { $this->isSpecialVideos = true; $mediaService = new MediaQueryService(); $this->tallyMsg = wfMessage('specialvideos-wiki-videos-tally', $mediaService->getTotalVideos())->parse(); } if ($wgTitle->isSpecial('LicensedVideoSwap')) { $this->pageType = ""; } break; case NS_CATEGORY: $this->pageType = wfMsg('oasis-page-header-subtitle-category'); break; case NS_FORUM: $this->pageType = wfMsg('oasis-page-header-subtitle-forum'); break; } // render subpage info $this->pageSubject = $skin->subPageSubtitle(); if (in_array($wgTitle->getNamespace(), BodyController::getUserPagesNamespaces())) { $title = explode(':', $this->title, 2); // User:Foo/World_Of_Warcraft:_Residers_in_Shadows (BAC-494) if (count($title) >= 2 && $wgTitle->getNsText() == str_replace(' ', '_', $title[0])) { // in case of error page (showErrorPage) $title is just a string (cannot explode it) $this->title = $title[1]; } } // render MW subtitle (contains old revision data) $this->subtitle = $wgOut->getSubtitle(); // render redirect info (redirected from) if (!empty($wgArticle->mRedirectedFrom)) { $this->pageRedirect = trim($this->subtitle, '()'); $this->subtitle = ''; } // render redirect page (redirect to) if ($wgTitle->isRedirect()) { $this->pageType = $this->subtitle; $this->subtitle = ''; } if (!empty($wgSupressPageTitle)) { $this->title = ''; $this->subtitle = ''; } if (!empty($wgSupressPageSubtitle)) { $this->subtitle = ''; $this->pageSubtitle = ''; } else { // render pageType, pageSubject and pageSubtitle as one message $subtitle = array_filter(array($this->pageType, $this->pageTalkSubject, $this->pageSubject, $this->pageRedirect)); /* * support for language variants * this adds links which automatically convert the content to that variant * * @author tor@wikia-inc.com * @author macbre@wikia-inc.com */ $variants = $this->skinTemplate->get('content_navigation')['variants']; if (!empty($variants)) { foreach ($variants as $variant) { $subtitle[] = Xml::element('a', array('href' => $variant['href'], 'rel' => 'nofollow', 'id' => $variant['id']), $variant['text']); } } $pipe = wfMsg('pipe-separator'); $this->pageSubtitle = implode(" {$pipe} ", $subtitle); } // force AjaxLogin popup for "Add a page" button (moved from the template) $this->loginClass = !empty($this->wg->DisableAnonymousEditing) ? ' require-login' : ''; // render monetization module if (!empty($params['monetizationModules'])) { $this->monetizationModules = $params['monetizationModules']; } wfProfileOut(__METHOD__); }
/** * Render default page header (with edit dropdown, history dropdown, ...) * * @param: array $params * key: showSearchBox (default: false) */ public function executeIndex($params) { global $wgTitle, $wgArticle, $wgOut, $wgUser, $wgContLang, $wgSupressPageTitle, $wgSupressPageSubtitle, $wgSuppressNamespacePrefix, $wgCityId, $wgEnableWallExt; wfProfileIn(__METHOD__); $this->isUserLoggedIn = $wgUser->isLoggedIn(); // page namespace $ns = $wgTitle->getNamespace(); /** start of wikia changes @author nAndy */ $this->isWallEnabled = (!empty($wgEnableWallExt) && $ns == NS_USER_WALL); /** end of wikia changes */ // currently used skin $skin = RequestContext::getMain()->getSkin(); // action button (edit / view soruce) and dropdown for it $this->prepareActionButton(); // dropdown actions $this->dropdown = $this->getDropdownActions(); /** start of wikia changes @author nAndy */ $response = $this->getResponse(); if( $response instanceof WikiaResponse ) { wfRunHooks( 'PageHeaderIndexAfterActionButtonPrepared', array($response, $ns, $skin) ); /** @author Jakub */ $this->extraButtons = array(); wfRunHooks( 'PageHeaderIndexExtraButtons', array( $response ) ); } else { //it happened on TimQ's devbox that $response was probably null fb#28747 Wikia::logBacktrace(__METHOD__); } /** end of wikia changes */ // for not existing pages page header is a bit different $this->pageExists = !empty($wgTitle) && $wgTitle->exists(); // default title "settings" (RT #145371), don't touch special pages if ($ns != NS_SPECIAL) { $this->displaytitle = true; $this->title = $wgOut->getPageTitle(); } else { // on special pages titles are already properly encoded (BugId:5983) $this->displaytitle = true; } // perform namespace and special page check // use service to get data $service = PageStatsService::newFromTitle( $wgTitle ); // comments - moved here to display comments even on deleted/non-existant pages $this->comments = $service->getCommentsCount(); if ($this->pageExists) { // show likes $this->likes = true; // get two popular categories this article is in $categories = array(); // FIXME: Might want to make a WikiFactory variable for controlling this feature if we aren't // comfortable with its performance. // NOTE: Skip getMostLinkedCategories() on Lyrics and Marvel because we're not sure yet that it's fast enough. $LYRICS_CITY_ID = "43339"; $MARVEL_CITY_ID = "2233"; if(($wgCityId != $LYRICS_CITY_ID) && ($wgCityId != $MARVEL_CITY_ID)){ $categories = $service->getMostLinkedCategories(); } // render links to most linked category page $categoriesVar = array(); foreach($categories as $category => $cnt) { $title = Title::newFromText($category, NS_CATEGORY); if($title) { $categoriesVar[] = Wikia::link($title, $title->getText()); } } $this->categories = $categoriesVar; // get info about current revision and list of authors of recent five edits $this->revisions = $this->getRecentRevisions(); // mainpage? if (WikiaPageType::isMainPage()) { $this->isMainPage = true; } // number of pages on this wiki $this->tallyMsg = wfMsgExt('oasis-total-articles-mainpage', array( 'parsemag' ), SiteStats::articles() ); } // remove namespaces prefix from title $namespaces = array(NS_MEDIAWIKI, NS_TEMPLATE, NS_CATEGORY, NS_FILE); if (defined('NS_VIDEO')) { $namespaces[] = NS_VIDEO; } if ( in_array($ns, array_merge( $namespaces, $wgSuppressNamespacePrefix ) ) ) { $this->title = $wgTitle->getText(); $this->displaytitle = false; } // talk pages if ($wgTitle->isTalkPage()) { // remove comments & FB like button $this->comments = false; // Talk: <page name without namespace prefix> $this->displaytitle = true; $this->title = Xml::element('strong', array(), $wgContLang->getNsText(NS_TALK) . ':'); $this->title .= htmlspecialchars($wgTitle->getText()); // back to subject article link switch($ns) { case NS_TEMPLATE_TALK: $msgKey = 'oasis-page-header-back-to-template'; break; case NS_MEDIAWIKI_TALK: $msgKey = 'oasis-page-header-back-to-mediawiki'; break; case NS_CATEGORY_TALK: $msgKey = 'oasis-page-header-back-to-category'; break; case NS_FILE_TALK: $msgKey = 'oasis-page-header-back-to-file'; break; default: $msgKey = 'oasis-page-header-back-to-article'; } $this->pageTalkSubject = Wikia::link($wgTitle->getSubjectPage(), wfMsg($msgKey), array('accesskey' => 'c')); } // category pages if ($ns == NS_CATEGORY) { // hide revisions / categories bar $this->categories = false; $this->revisions = false; } // forum namespace if ($ns == NS_FORUM) { // remove comments button $this->comments = false; // remove namespace prefix $this->title = $wgTitle->getText(); $this->displaytitle = false; } // mainpage if (WikiaPageType::isMainPage()) { // change page title to just "Home" $this->title = wfMsg('oasis-home'); // hide revisions / categories bar $this->categories = false; $this->revisions = false; } // render page type info switch($ns) { case NS_MEDIAWIKI: $this->pageType = wfMsg('oasis-page-header-subtitle-mediawiki'); break; case NS_TEMPLATE: $this->pageType = wfMsg('oasis-page-header-subtitle-template'); break; case NS_SPECIAL: $this->pageType = wfMsg('oasis-page-header-subtitle-special'); // remove comments button (fix FB#3404 - Marooned) $this->comments = false; // FIXME: use PageHeaderIndexAfterExecute hook or $wgSupressPageSubtitle instead if($wgTitle->isSpecial('PageLayoutBuilderForm') || $wgTitle->isSpecial('PageLayoutBuilder') ) { $this->displaytitle = true; $this->pageType = ""; } if($wgTitle->isSpecial('Newimages')) { $this->isNewFiles = true; } if($wgTitle->isSpecial('Videos')) { $this->isSpecialVideos = true; $mediaService = F::build( 'MediaQueryService' ); $this->tallyMsg = wfMsgExt('specialvideos-wiki-videos-tally', array( 'parsemag' ), $mediaService->getTotalVideos() ); } break; case NS_CATEGORY: $this->pageType = wfMsg('oasis-page-header-subtitle-category'); break; case NS_FORUM: $this->pageType = wfMsg('oasis-page-header-subtitle-forum'); break; } // render subpage info $this->pageSubject = $skin->subPageSubtitle(); if ( in_array($wgTitle->getNamespace(), BodyController::getUserPagesNamespaces() ) ) { $title = explode(':', $this->title); if(count($title) >= 2 && $wgTitle->getNsText() == str_replace(' ', '_', $title[0]) ) // in case of error page (showErrorPage) $title is just a string (cannot explode it) $this->title = $title[1]; } // render MW subtitle (contains old revision data) $this->subtitle = $wgOut->getSubtitle(); // render redirect info (redirected from) if (!empty($wgArticle->mRedirectedFrom)) { $this->pageRedirect = trim($this->subtitle, '()'); $this->subtitle = ''; } // render redirect page (redirect to) if ($wgTitle->isRedirect()) { $this->pageType = $this->subtitle; $this->subtitle = ''; } // if page is rendered using one column layout, show search box as a part of page header $this->showSearchBox = isset($params['showSearchBox']) ? $params['showSearchBox'] : false ; if (!empty($wgSupressPageTitle)) { $this->title = ''; $this->subtitle = ''; } if (!empty($wgSupressPageSubtitle)) { $this->subtitle = ''; $this->pageSubtitle = ''; } else { // render pageType, pageSubject and pageSubtitle as one message $subtitle = array_filter(array( $this->pageType, $this->pageTalkSubject, $this->pageSubject, $this->pageRedirect, )); /* * support for language variants * this adds links which automatically convert the content to that variant * * @author tor@wikia-inc.com */ if ( $wgContLang->hasVariants() ) { foreach ( $wgContLang->getVariants() as $variant ) { if ( $variant != $wgContLang->getCode() ) { $subtitle[] = Xml::element( 'a', array( 'href' => $wgTitle->getLocalUrl( array( 'variant' => $variant ) ), 'rel' => 'nofollow' ), $wgContLang->getVariantname( $variant ) ); } } } $pipe = wfMsg('pipe-separator'); $this->pageSubtitle = implode(" {$pipe} ", $subtitle); } // force AjaxLogin popup for "Add a page" button (moved from the template) $this->loginClass = !empty($this->wg->DisableAnonymousEditing) ? ' require-login' : ''; if ( $this->wg->OasisNavV2 && $response instanceof WikiaResponse ) { $response->getView()->setTemplatePath( dirname( __FILE__ ) .'/templates/PageHeader_IndexV2.php' ); } wfProfileOut(__METHOD__); }