Пример #1
0
 /**
  * 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__);
 }
 /**
  * Get a count of videos that would be returned by $videoParams when passed to getVideos()
  * @param array $videoParams
  *   [ array( 'sort' => string, 'page' => int, 'category' => string, 'provider' => string ) ]
  * @return integer $totalVideos
  */
 protected function getTotalVideos($videoParams)
 {
     wfProfileIn(__METHOD__);
     $mediaService = new MediaQueryService();
     if ($videoParams['sort'] == 'premium') {
         $totalVideos = $mediaService->getTotalPremiumVideos();
     } else {
         if (!empty($videoParams['category'])) {
             $totalVideos = $mediaService->getTotalVideosByCategory($videoParams['category']);
         } else {
             $totalVideos = $mediaService->getTotalVideos();
         }
     }
     $totalVideos = $totalVideos + 1;
     // adding 'add video' placeholder to video array count
     wfProfileOut(__METHOD__);
     return $totalVideos;
 }