public function __construct($ownerUser = null) { global $wgUser, $wgTitle; if (!isset($ownerUser)) { $ownerUser = User::newFromName(UserPagesHeaderController::getUserName($wgTitle, BodyController::getUserPagesNamespaces())); } $this->ownerUser = $ownerUser; $this->viewerUser = $wgUser; $this->owner = new AchUser($this->ownerUser); $this->viewer = new AchUser($this->viewerUser); }
public function getHTML() { wfProfileIn(__METHOD__); global $wgTitle, $wgUser; //fix #10881, get correct username from user namespace subpages $this->mUserOwner = F::build('User', array(UserPagesHeaderController::getUserName($wgTitle, BodyController::getUserPagesNamespaces())), 'newFromName'); if (in_array(strtolower(RequestContext::getMain()->getSkin()->getSkinName()), array('oasis')) && $this->mUserOwner && AchAwardingService::canEarnBadges($this->mUserOwner) && $this->mUserOwner->isLoggedIn() && !($wgUser->getId() == $this->mUserOwner->getId() && $wgUser->getOption('hidepersonalachievements'))) { $this->mUserViewer = $wgUser; if ($this->mUserViewer->isLoggedIn() && $this->mUserViewer->getId() != $this->mUserOwner->getId()) { $this->loadViewerBadges(); $this->loadViewerCounters(); } $this->loadOwnerBadges(); $this->loadOwnerCounters(); $this->prepareChallenges(); $tmplData = array(); $tmplData['ownerBadges'] = $this->mOwnerBadgesSimple; $tmplData['challengesBadges'] = $this->mChallengesBadges; $tmplData['title_no'] = wfMsg('achievements-profile-title-no', $this->mUserOwner->getName()); $tmplData['title'] = wfMsgExt('achievements-profile-title', array('parsemag'), $this->mUserOwner->getName(), count($this->mOwnerBadgesSimple)); $tmplData['title_challenges'] = wfMsg('achievements-profile-title-challenges', $this->mUserOwner->getName()); $tmplData['leaderboard_url'] = Skin::makeSpecialUrl("Leaderboard"); if (count($this->mOwnerBadgesExtended) > 0) { $rankingService = new AchRankingService(); $tmplData['user_rank'] = $rankingService->getUserRankingPosition($this->mUserOwner); } if ($this->mUserViewer->isAllowed('editinterface')) { $tmplData['customize_url'] = Skin::makeSpecialUrl("AchievementsCustomize"); } $template = new EasyTemplate(dirname(__FILE__) . '/../templates'); $template->set_vars($tmplData); $out = $template->render('ProfileBox'); } else { $out = ''; } wfProfileOut(__METHOD__); return $out; }
/** * Render header for blog post */ public function executeBlogPost() { wfProfileIn(__METHOD__); global $wgTitle, $wgLang, $wgOut; // remove User_blog:xxx from title $titleParts = explode('/', $wgTitle->getText()); array_shift($titleParts); $this->title = implode('/', $titleParts); // get user name to display in header $this->userName = self::getUserName($wgTitle, BodyController::getUserPagesNamespaces()); // render avatar (48x48) $this->avatar = AvatarService::renderAvatar($this->userName, 48); // link to user page $this->userPage = AvatarService::getUrl($this->userName); if ($this->wg->EnableBlogArticles) { // link to user blog page $this->userBlogPage = AvatarService::getUrl($this->userName, NS_BLOG_ARTICLE); // user blog page message $this->userBlogPageMessage = wfMessage('user-blog-url-link', $this->userName)->inContentLanguage()->parse(); } if (!empty($this->wg->EnableGoogleAuthorInfo) && !empty($this->wg->GoogleAuthorLinks) && array_key_exists($this->userName, $this->wg->GoogleAuthorLinks)) { $this->googleAuthorLink = $this->wg->GoogleAuthorLinks[$this->userName] . '?rel=author'; } if ($this->app->wg->Request->getVal('action') == 'history' || $this->app->wg->Request->getCheck('diff')) { $this->navLinks = Wikia::link($this->app->wg->title, wfMsg('oasis-page-header-back-to-article'), array(), array(), 'known'); } // user stats (edit points, account creation date) $this->stats = $this->getStats($this->userName); // commments / likes / date of first edit if (!empty($wgTitle) && $wgTitle->exists()) { $service = new PageStatsService($wgTitle->getArticleId()); $this->editTimestamp = $wgLang->date($service->getFirstRevisionTimestamp()); $this->comments = $service->getCommentsCount(); } $actionMenu = array(); $dropdownActions = array('move', 'protect', 'unprotect', 'delete', 'undelete', 'history'); // edit button / dropdown if (isset($this->content_actions['ve-edit'])) { // new visual editor is enabled $actionMenu['action'] = $this->content_actions['ve-edit']; // add classic editor link to the possible dropdown options array_unshift($dropdownActions, 'edit'); } else { if (isset($this->content_actions['edit'])) { $actionMenu['action'] = $this->content_actions['edit']; } } foreach ($dropdownActions as $action) { if (isset($this->content_actions[$action])) { $actionMenu['dropdown'][$action] = $this->content_actions[$action]; } } $this->actionMenu = $actionMenu; // load CSS for .WikiaUserPagesHeader (BugId:9212, 10246) $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL("skins/oasis/css/core/UserPagesHeader.scss")); 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, $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 header for blog post */ public function executeBlogPost() { wfProfileIn(__METHOD__); global $wgTitle, $wgLang, $wgOut; // remove User_blog:xxx from title $titleParts = explode('/', $wgTitle->getText()); array_shift($titleParts); $this->title = implode('/', $titleParts); // get user name to display in header $this->userName = self::getUserName($wgTitle, BodyController::getUserPagesNamespaces()); // render avatar (48x48) $this->avatar = AvatarService::renderAvatar($this->userName, 48); // link to user page $this->userPage = AvatarService::getUrl($this->userName); // user stats (edit points, account creation date) $this->stats = $this->getStats($this->userName); // commments / likes / date of first edit if (!empty($wgTitle) && $wgTitle->exists()) { $service = new PageStatsService($wgTitle->getArticleId()); $this->editTimestamp = $wgLang->date($service->getFirstRevisionTimestamp()); $this->comments = $service->getCommentsCount(); $this->likes = true; } $actionMenu = array(); // edit button / dropdown if (isset($this->content_actions['edit'])) { $actionMenu['action'] = $this->content_actions['edit']; } // dropdown actions $actions = array('move', 'protect', 'unprotect', 'delete', 'undelete', 'history'); foreach($actions as $action) { if (isset($this->content_actions[$action])) { $actionMenu['dropdown'][$action] = $this->content_actions[$action]; } } $this->actionMenu = $actionMenu; // load CSS for .WikiaUserPagesHeader (BugId:9212, 10246) $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL("skins/oasis/css/core/UserPagesHeader.scss")); 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__); }