/** * Get details about one or more user * * @requestParam string $ids A string with a comma-separated list of user ID's, limit for query equals 100 * @requestParam integer $size [OPTIONAL] The desired width and height for the thumbnail, defaults to 100, 0 for no thumbnail * * @responseParam array $items A list of results with the user ID as the index, each item has a title, name, url, avatar, numberofedits * @responseParam string $basepath domain of a wiki to create a url for an user * * @example &ids=123&size=150 */ public function getDetails() { wfProfileIn(__METHOD__); $ids = $this->request->getVal('ids'); if (empty($ids)) { throw new InvalidParameterApiException('ids'); } $ids = explode(',', trim($ids)); $size = $this->request->getInt('size', static::AVATAR_DEFAULT_SIZE); //limit number of users $ids = array_slice($ids, 0, static::USER_LIMIT); //users are cached inside the service $users = (new UserService())->getUsers($ids); $items = array(); foreach ($users as $user) { $userName = $user->getName(); $item = array('user_id' => $user->getId(), 'title' => $user->getTitleKey(), 'name' => $userName, 'url' => AvatarService::getUrl($userName), 'numberofedits' => (int) $user->getEditCountLocal()); //add avatar url if size !== 0 if ($size > 0) { $item['avatar'] = AvatarService::getAvatarUrl($user, $size); } $items[] = $item; } if (!empty($items)) { $this->setResponseData(['basepath' => $this->wg->Server, 'items' => $items], ['imgFields' => 'avatar', 'urlFields' => ['avatar', 'url']], WikiaResponse::CACHE_STANDARD); } else { throw new NotFoundApiException(); } wfProfileOut(__METHOD__); }
/** * Modify results from Blogs * * Add likes count and render avatar */ static function getResults(&$results) { wfProfileIn(__METHOD__); /* @var $wgLang Language */ global $wgLang; // get message for "read more" link $cutSign = wfMsg('blug-cut-sign'); foreach($results as &$result) { $result['likes'] = false; $result['avatar'] = AvatarService::renderAvatar($result['username'], 48); $result['userpage'] = AvatarService::getUrl($result['username']); $result['date'] = $wgLang->date(wfTimestamp(TS_MW, $result['timestamp'])); // "read more" handling if (strpos($result['text'], $cutSign) !== false) { $result['readmore'] = true; } } //print_pre($results); wfProfileOut(__METHOD__); return true; }
/** * Modify results from Blogs * * Add likes count and render avatar */ static function getResults(&$results) { wfProfileIn(__METHOD__); /* @var $wgLang Language */ global $wgLang; foreach ($results as &$result) { $result['likes'] = false; $result['avatar'] = AvatarService::renderAvatar($result['username'], 48); $result['userpage'] = AvatarService::getUrl($result['username']); $result['date'] = $wgLang->date(wfTimestamp(TS_MW, $result['timestamp'])); } wfProfileOut(__METHOD__); return true; }
function testAvatarService() { $anonName = '10.10.10.10'; $userName = '******'; // users $this->assertRegExp('/width="32"/', AvatarService::render($userName, 32)); $this->assertRegExp('/\/20px-/', AvatarService::render($userName, 16)); $this->assertRegExp('/User:WikiaBot/', AvatarService::renderLink($userName)); $this->assertRegExp('/^<img src="http:\/\/images/', AvatarService::renderAvatar($userName)); $this->assertRegExp('/^http:\/\/images/', AvatarService::getAvatarUrl($userName)); // anons $this->assertRegExp('/Special:Contributions\//', AvatarService::getUrl($anonName)); $this->assertRegExp('/^<img src="/', AvatarService::renderAvatar($anonName)); $this->assertRegExp('/\/20px-/', AvatarService::renderAvatar($anonName, 20)); $this->assertRegExp('/Special:Contributions/', AvatarService::renderLink($anonName)); }
/** * @group Slow * @slowExecutionTime 0.04016 ms * @group UsingDB */ function testAvatarService() { $anonName = '10.10.10.10'; $userName = '******'; $this->mockGlobalVariable('wgVignetteUrl', 'http://images.foo.wikia-dev.com'); $this->mockGlobalVariable('wgEnableVignette', true); // users $this->assertContains('width="32"', AvatarService::render($userName, 32)); $this->assertContains('/scale-to-width-down/20', AvatarService::render($userName, 16)); $this->assertContains('User:WikiaBot', AvatarService::renderLink($userName)); $this->assertRegExp('/^<img src="http:\\/\\/images/', AvatarService::renderAvatar($userName)); // anons $this->assertContains('Special:Contributions/', AvatarService::getUrl($anonName)); $this->assertRegExp('/^<img src="/', AvatarService::renderAvatar($anonName)); $this->assertContains('/20px-', AvatarService::renderAvatar($anonName, 20)); $this->assertContains('Special:Contributions', AvatarService::renderLink($anonName)); }
public function getData($master = false, $title = null) { global $wgUser, $wgTitle, $wgBlankImgUrl, $wgMemc, $wgArticleCommentsEnableVoting; wfProfileIn(__METHOD__); $title = empty($title) ? $wgTitle : $title; $title = empty($title) ? $this->mTitle : $title; $comment = false; if ($this->load($master)) { $articleDataKey = wfMemcKey('articlecomment', 'comm_data_v2', $this->mLastRevId, $wgUser->getId()); $data = $wgMemc->get($articleDataKey); if (!empty($data)) { wfProfileOut(__METHOD__); $data['timestamp'] = "<a href='" . $this->getTitle()->getFullUrl(array('permalink' => $data['articleId'])) . '#comm-' . $data['articleId'] . "' class='permalink'>" . wfTimeFormatAgo($data['rawmwtimestamp']) . "</a>"; return $data; } $canDelete = $wgUser->isAllowed('delete'); $sig = $this->mUser->isAnon() ? AvatarService::renderLink($this->mUser->getName()) : Xml::element('a', array('href' => $this->mUser->getUserPage()->getFullUrl()), $this->mUser->getName()); $articleId = $this->mTitle->getArticleId(); $isStaff = (int) in_array('staff', $this->mUser->getEffectiveGroups()); $parts = self::explode($this->getTitle()); $buttons = array(); $replyButton = ''; $commentingAllowed = true; if (defined('NS_BLOG_ARTICLE') && $title->getNamespace() == NS_BLOG_ARTICLE) { $props = BlogArticle::getProps($title->getArticleID()); $commentingAllowed = isset($props['commenting']) ? (bool) $props['commenting'] : true; } if (count($parts['partsStripped']) == 1 && $commentingAllowed && !ArticleCommentInit::isFbConnectionNeeded()) { $replyButton = '<button type="button" class="article-comm-reply wikia-button secondary actionButton">' . wfMsg('article-comments-reply') . '</button>'; } if (defined('NS_QUESTION_TALK') && $this->mTitle->getNamespace() == NS_QUESTION_TALK) { $replyButton = ''; } if ($canDelete && !ArticleCommentInit::isFbConnectionNeeded()) { $img = '<img class="remove sprite" alt="" src="' . $wgBlankImgUrl . '" width="16" height="16" />'; $buttons[] = $img . '<a href="' . $this->mTitle->getLocalUrl('redirect=no&action=delete') . '" class="article-comm-delete">' . wfMsg('article-comments-delete') . '</a>'; } //due to slave lag canEdit() can return false negative - we are hiding it by CSS and force showing by JS if ($wgUser->isLoggedIn() && $commentingAllowed && !ArticleCommentInit::isFbConnectionNeeded()) { $display = $this->canEdit() ? 'test=' : ' style="display:none"'; $img = '<img class="edit-pencil sprite" alt="" src="' . $wgBlankImgUrl . '" width="16" height="16" />'; $buttons[] = "<span class='edit-link'{$display}>" . $img . '<a href="#comment' . $articleId . '" class="article-comm-edit actionButton" id="comment' . $articleId . '">' . wfMsg('article-comments-edit') . '</a></span>'; } if (!$this->mTitle->isNewPage(Title::GAID_FOR_UPDATE)) { $buttons[] = RequestContext::getMain()->getSkin()->makeKnownLinkObj($this->mTitle, wfMsgHtml('article-comments-history'), 'action=history', '', '', 'class="article-comm-history"'); } $commentId = $this->getTitle()->getArticleId(); $rawmwtimestamp = $this->mFirstRevision->getTimestamp(); $rawtimestamp = wfTimeFormatAgo($rawmwtimestamp); $timestamp = "<a rel='nofollow' href='" . $this->getTitle()->getFullUrl(array('permalink' => $commentId)) . '#comm-' . $commentId . "' class='permalink'>" . wfTimeFormatAgo($rawmwtimestamp) . "</a>"; $comment = array('id' => $commentId, 'articleId' => $articleId, 'author' => $this->mUser, 'username' => $this->mUser->getName(), 'avatar' => AvatarService::renderAvatar($this->mUser->getName(), self::AVATAR_BIG_SIZE), 'avatarSmall' => AvatarService::renderAvatar($this->mUser->getName(), self::AVATAR_SMALL_SIZE), 'userurl' => AvatarService::getUrl($this->mUser->getName()), 'isLoggedIn' => $this->mUser->isLoggedIn(), 'buttons' => $buttons, 'replyButton' => $replyButton, 'sig' => $sig, 'text' => $this->mText, 'metadata' => $this->mMetadata, 'rawtext' => $this->mRawtext, 'timestamp' => $timestamp, 'rawtimestamp' => $rawtimestamp, 'rawmwtimestamp' => $rawmwtimestamp, 'title' => $this->mTitle->getText(), 'isStaff' => $isStaff); if (!empty($wgArticleCommentsEnableVoting)) { $comment['votes'] = $this->getVotesCount(); } $wgMemc->set($articleDataKey, $comment, 60 * 60); if (!$comment['title'] instanceof Title) { $comment['title'] = F::build('Title', array($comment['title'], NS_TALK), 'newFromText'); } } wfProfileOut(__METHOD__); return $comment; }
/** * getData -- return raw data for displaying commentList * * @access public * * @return array data for comments list */ public function getData($page = 1) { global $wgUser, $wgTitle, $wgStylePath; $groups = $wgUser->getEffectiveGroups(); //$isSysop = in_array('sysop', $groups) || in_array('staff', $groups); $canEdit = $wgUser->isAllowed('edit'); $isBlocked = $wgUser->isBlocked(); $isReadOnly = wfReadOnly(); //$showall = $wgRequest->getText( 'showall', false ); //default to using slave. comments are posted with ajax which hits master db //$commentList = $this->getCommentList(false); $countComments = $this->getCountAll(); $countCommentsNested = $this->getCountAllNested(); $countPages = ceil($countComments / $this->mMaxPerPage); $pageRequest = (int) $page; $page = 1; if ($pageRequest <= $countPages && $pageRequest > 0) { $page = $pageRequest; } $comments = $this->getCommentPages(false, $page); $pagination = $this->doPagination($countComments, count($comments), $page); $commentListHTML = ''; if (!empty($wgTitle)) { $commentListHTML = F::app()->getView('ArticleComments', 'CommentList', array('commentListRaw' => $comments, 'page' => $page, 'useMaster' => false))->render(); } $commentingAllowed = true; if (defined('NS_BLOG_ARTICLE') && $wgTitle && $wgTitle->getNamespace() == NS_BLOG_ARTICLE) { $props = BlogArticle::getProps($wgTitle->getArticleID()); $commentingAllowed = isset($props['commenting']) ? (bool) $props['commenting'] : true; } $retVal = array('avatar' => AvatarService::renderAvatar($wgUser->getName(), 50), 'userurl' => AvatarService::getUrl($wgUser->getName()), 'canEdit' => $canEdit, 'commentListRaw' => $comments, 'commentListHTML' => $commentListHTML, 'commentingAllowed' => $commentingAllowed, 'commentsPerPage' => $this->mMaxPerPage, 'countComments' => $countComments, 'countCommentsNested' => $countCommentsNested, 'isAnon' => $wgUser->isAnon(), 'isBlocked' => $isBlocked, 'isFBConnectionProblem' => ArticleCommentInit::isFbConnectionNeeded(), 'isReadOnly' => $isReadOnly, 'page' => $page, 'pagination' => $pagination, 'reason' => $isBlocked ? $this->blockedPage() : '', 'stylePath' => $wgStylePath, 'title' => $wgTitle); return $retVal; }
public function getData($master = false) { global $wgUser, $wgBlankImgUrl, $wgMemc, $wgArticleCommentsEnableVoting; wfProfileIn(__METHOD__); $comment = false; $canDelete = $wgUser->isAllowed('commentdelete'); if (self::isBlog()) { $canDelete = $canDelete || $wgUser->isAllowed('blog-comments-delete'); } $title = $this->getTitle(); $commentId = $title->getArticleId(); // vary cache on permission as well so it changes we can show it to a user $articleDataKey = wfMemcKey('articlecomment_data', $commentId, $title->getLatestRevID(), $wgUser->getId(), $canDelete, RequestContext::getMain()->getSkin()->getSkinName(), self::CACHE_VERSION); $data = $wgMemc->get($articleDataKey); if (!empty($data)) { $data['timestamp'] = "<a href='" . $title->getFullUrl(['permalink' => $data['id']]) . '#comm-' . $data['id'] . "' class='permalink'>" . wfTimeFormatAgo($data['rawmwtimestamp']) . "</a>"; wfProfileOut(__METHOD__); return $data; } if ($this->load($master)) { $sig = $this->mUser->isAnon() ? AvatarService::renderLink($this->mUser->getName()) : Xml::element('a', array('href' => $this->mUser->getUserPage()->getFullUrl()), $this->mUser->getName()); $isStaff = (int) in_array('staff', $this->mUser->getEffectiveGroups()); $parts = self::explode($title->getDBkey()); $buttons = []; // action links with full markup (used in Oasis) $links = []; // action links with only a URL $replyButton = ''; // this is for blogs we want to know if commenting on it is enabled // we cannot check it using $title->getBaseText, as this returns main namespace title // the subjectpage for $parts title is something like 'User blog comment:SomeUser/BlogTitle' which is fine $articleTitle = Title::makeTitle(MWNamespace::getSubject($this->mNamespace), $parts['title']); $commentingAllowed = ArticleComment::canComment($articleTitle); if (count($parts['partsStripped']) == 1 && $commentingAllowed) { $replyButton = '<button type="button" class="article-comm-reply wikia-button secondary actionButton">' . wfMsg('article-comments-reply') . '</button>'; } if (defined('NS_QUESTION_TALK') && $title->getNamespace() == NS_QUESTION_TALK) { $replyButton = ''; } if ($canDelete) { $img = '<img class="remove sprite" alt="" src="' . $wgBlankImgUrl . '" width="16" height="16" />'; $buttons[] = $img . '<a href="' . $title->getLocalUrl('redirect=no&action=delete') . '" class="article-comm-delete">' . wfMsg('article-comments-delete') . '</a>'; $links['delete'] = $title->getLocalUrl('redirect=no&action=delete'); } // due to slave lag canEdit() can return false negative - we are hiding it by CSS and force showing by JS if ($wgUser->isLoggedIn() && $commentingAllowed) { $display = $this->canEdit() ? 'test=' : ' style="display:none"'; $img = '<img class="edit-pencil sprite" alt="" src="' . $wgBlankImgUrl . '" width="16" height="16" />'; $buttons[] = "<span class='edit-link'{$display}>" . $img . '<a href="#comment' . $commentId . '" class="article-comm-edit actionButton" id="comment' . $commentId . '">' . wfMsg('article-comments-edit') . '</a></span>'; $links['edit'] = '#comment' . $commentId; } if (!$this->mTitle->isNewPage(Title::GAID_FOR_UPDATE)) { $buttons[] = RequestContext::getMain()->getSkin()->makeKnownLinkObj($title, wfMsgHtml('article-comments-history'), 'action=history', '', '', 'class="article-comm-history"'); $links['history'] = $title->getLocalUrl('action=history'); } $rawmwtimestamp = $this->mFirstRevision->getTimestamp(); $rawtimestamp = wfTimeFormatAgo($rawmwtimestamp); $timestamp = "<a rel='nofollow' href='" . $title->getFullUrl(['permalink' => $commentId]) . '#comm-' . $commentId . "' class='permalink'>" . wfTimeFormatAgo($rawmwtimestamp) . "</a>"; $comment = ['id' => $commentId, 'author' => $this->mUser, 'username' => $this->mUser->getName(), 'avatar' => AvatarService::renderAvatar($this->mUser->getName(), self::AVATAR_BIG_SIZE), 'avatarSmall' => AvatarService::renderAvatar($this->mUser->getName(), self::AVATAR_SMALL_SIZE), 'userurl' => AvatarService::getUrl($this->mUser->getName()), 'isLoggedIn' => $this->mUser->isLoggedIn(), 'buttons' => $buttons, 'links' => $links, 'replyButton' => $replyButton, 'sig' => $sig, 'text' => $this->mText, 'metadata' => $this->mMetadata, 'rawtext' => $this->mRawtext, 'timestamp' => $timestamp, 'rawtimestamp' => $rawtimestamp, 'rawmwtimestamp' => $rawmwtimestamp, 'title' => $title->getText(), 'isStaff' => $isStaff]; if (!empty($wgArticleCommentsEnableVoting)) { $comment['votes'] = $this->getVotesCount(); } $wgMemc->set($articleDataKey, $comment, self::AN_HOUR); if (!$comment['title'] instanceof Title) { $comment['title'] = Title::newFromText($comment['title'], NS_TALK); } } wfProfileOut(__METHOD__); return $comment; }
?> "> <?php if ($loggedIn) { echo $userName; } else { echo $wf->Msg('userlogin-login-heading'); } ?> </header> <?php if ($loggedIn) { ?> <ul class=wkLst> <li><a class=chg href="<?php echo AvatarService::getUrl($userName); ?> "><?php echo $wf->Msg('wikiamobile-profile'); ?> </a></li> <li><a class=logout href="<?php echo str_replace("\$1", SpecialPage::getSafeTitleFor('UserLogout')->getPrefixedText() . '?returnto=' . $wg->Title->getPrefixedURL(), $wg->ArticlePath); ?> "><?php echo $wf->Msg('logout'); ?> </a></li> </ul> <?php }
/** * Modify personal URLs list. */ private function setupPersonalUrls() { $this->personalUrls = F::app()->getSkinTemplateObj()->data['personal_urls']; if ($this->isAnon) { $query = F::app()->wg->Request->getValues(); if (isset($query['title']) && !self::isBlacklisted($query['title'])) { $returnto = wfUrlencode($query['title']); } else { $returnto = Title::newMainPage()->getPartialURL(); } $returnto = wfGetReturntoParam($returnto); $this->personalUrls['login'] = ['title' => wfMessage('login')->text(), 'href' => Skin::makeSpecialUrl('UserLogin', $returnto), 'class' => 'ajaxLogin table-cell']; $this->personalUrls['register'] = ['text' => wfMessage('oasis-signup')->text(), 'href' => Skin::makeSpecialUrl('UserSignup'), 'class' => 'ajaxRegister']; } else { $this->personalUrls['userpage'] = ['title' => $this->username . ' - ' . wfMessage('mypage')->text(), 'href' => AvatarService::getUrl($this->username), 'class' => 'ajaxLogin table-cell']; } }
/** * 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__); }
public function executeIndex() { wfProfileIn(__METHOD__); global $wgUser; $this->setupPersonalUrls(); $this->itemsBefore = array(); $this->isAnon = $wgUser->isAnon(); $this->username = $wgUser->getName(); if ($this->isAnon) { // facebook connect if (!empty($this->personal_urls['fbconnect']['html'])) { $this->itemsBefore = array($this->personal_urls['fbconnect']['html']); } // render Login and Register links $this->loginLink = $this->renderPersonalUrl('login'); $this->registerLink = $this->renderPersonalUrl('register'); $this->loginDropdown = ''; $this->loginDropdown = (string) F::app()->sendRequest('UserLoginSpecial', 'dropdown', array('param' => 'paramvalue')); } else { // render user avatar and link to his user page $this->profileLink = AvatarService::getUrl($this->username); $this->profileAvatar = AvatarService::renderAvatar($this->username, 20); // dropdown items $possibleItems = array('mytalk', 'following', 'preferences'); $dropdownItems = array(); // Allow hooks to modify the dropdown items. wfRunHooks('AccountNavigationModuleAfterDropdownItems', array(&$possibleItems, &$this->personal_urls)); foreach ($possibleItems as $item) { if (isset($this->personal_urls[$item])) { $dropdownItems[] = $this->renderPersonalUrl($item); } } // link to Help:Content (never render as redlink) $helpLang = array_key_exists($this->wg->LanguageCode, $this->wg->AvailableHelpLang) ? $this->wg->LanguageCode : 'en'; $dropdownItems[] = Wikia::link(Title::newFromText(wfMsgExt('helppage', array('parsemag', 'language' => $helpLang))), wfMsg('help'), array('title' => '', 'data-id' => 'help'), '', array('known')); // logout link $dropdownItems[] = $this->renderPersonalUrl('logout'); $this->dropdown = $dropdownItems; } wfProfileOut(__METHOD__); }
/** * @dataProvider getUrlDataProvider * @group UsingDB */ public function testGetUrl($url, $userName) { $this->assertStringEndsWith($url, AvatarService::getUrl($userName)); }
/** * 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__); }
/** * Handle confirmations from Facebook Connect */ public static function addFacebookConnectConfirmation(&$html) { wfProfileIn(__METHOD__); global $wgRequest, $wgUser; // FBConnect messages if ( F::app()->checkSkin( 'oasis' ) && class_exists('FBConnectHooks')) { $preferencesUrl = SpecialPage::getTitleFor('Preferences')->getFullUrl(); $fbStatus = $wgRequest->getVal('fbconnected'); switch($fbStatus) { // success case 1: $id = FBConnectDB::getFacebookIDs($wgUser, DB_MASTER); if (count($id) > 0) { global $wgEnableFacebookSync; if ($wgEnableFacebookSync == true) { $userURL = AvatarService::getUrl($wgUser->mName); self::addConfirmation(wfMsg('fbconnect-connect-msg-sync-profile', $preferencesUrl, $userURL)); } else { self::addConfirmation(wfMsg('fbconnect-connect-msg', $preferencesUrl)); } } break; // error case 2: $fb = new FBConnectAPI(); if (strlen($fb->user()) < 1) { self::addConfirmation(wfMsgExt('fbconnect-connect-error-msg', array('parseinline'), $preferencesUrl), self::CONFIRMATION_ERROR); } break; } } wfProfileOut(__METHOD__); return true; }
?> "> <?php if ($loggedIn) { echo $userName; } else { echo wfMessage('userlogin-login-heading')->text(); } ?> </header> <?php if ($loggedIn) { ?> <ul class=wkLst> <li><a class=chg href="<?php echo Sanitizer::encodeAttribute(AvatarService::getUrl($userName)); ?> "><?php echo wfMessage('wikiamobile-profile')->escaped(); ?> </a></li> <li><a class=logout href="<?php echo Sanitizer::encodeAttribute(str_replace("\$1", SpecialPage::getSafeTitleFor('UserLogout')->getPrefixedText() . '?returnto=' . $wg->Title->getPrefixedURL(), $wg->ArticlePath)); ?> "><?php echo wfMessage('logout')->escaped(); ?> </a></li> </ul> <?php }
/** * getData -- return raw data for displaying commentList * * @access public * * @return array data for comments list */ public function getData($page = 1) { global $wgUser, $wgStylePath; //$isSysop = in_array('sysop', $groups) || in_array('staff', $groups); $canEdit = $wgUser->isAllowed('edit'); $isBlocked = $wgUser->isBlocked(); $isReadOnly = wfReadOnly(); //$showall = $wgRequest->getText( 'showall', false ); //default to using slave. comments are posted with ajax which hits master db //$commentList = $this->getCommentList(false); $countComments = $this->getCountAll(); $countCommentsNested = $this->getCountAllNested(); $countPages = ceil($countComments / $this->mMaxPerPage); $pageRequest = (int) $page; $page = 1; if ($pageRequest <= $countPages && $pageRequest > 0) { $page = $pageRequest; } $comments = $this->getCommentPages(false, $page); $this->preloadFirstRevId($comments); $pagination = $this->doPagination($countComments, count($comments), $page); return array('avatar' => AvatarService::renderAvatar($wgUser->getName(), 50), 'userurl' => AvatarService::getUrl($wgUser->getName()), 'canEdit' => $canEdit, 'commentListRaw' => $comments, 'commentingAllowed' => ArticleComment::canComment($this->mTitle), 'commentsPerPage' => $this->mMaxPerPage, 'countComments' => $countComments, 'countCommentsNested' => $countCommentsNested, 'isAnon' => $wgUser->isAnon(), 'isBlocked' => $isBlocked, 'isReadOnly' => $isReadOnly, 'page' => $page, 'pagination' => $pagination, 'reason' => $isBlocked ? $this->blockedPage() : '', 'stylePath' => $wgStylePath, 'title' => $this->mTitle); }