public function getTag() { $this->wf->profileIn(__METHOD__); $imageHTML = $this->request->getVal('imageHTML'); $align = $this->request->getVal('align'); $width = $this->request->getVal('width'); $showCaption = $this->request->getVal('showCaption', false); $caption = $this->request->getVal('caption', ''); $zoomIcon = $this->request->getVal('zoomIcon', ''); $showPictureAttribution = $this->request->getVal('showPictureAttribution', false); $attributeTo = $this->request->getVal('$attributeTo', null); $html = "<figure class=\"thumb" . (!empty($align) ? " t{$align}" : '') . " thumbinner\" style=\"width:{$width}px;\">{$imageHTML}{$zoomIcon}"; if (!empty($showCaption)) { $html .= "<figcaption class=\"thumbcaption\">{$caption}"; } //picture attribution if (!empty($showPictureAttribution) && !empty($attributeTo)) { $this->wf->profileIn(__METHOD__ . '::PictureAttribution'); // render avatar and link to user page $avatar = AvatarService::renderAvatar($attributeTo, 16); $link = AvatarService::renderLink($attributeTo); $html .= Xml::openElement('div', array('class' => 'picture-attribution')) . $avatar . $this->wf->MsgExt('oasis-content-picture-added-by', array('parsemag'), $link, $attributeTo) . Xml::closeElement('div'); $this->wf->profileOut(__METHOD__ . '::PictureAttribution'); } if (!empty($showCaption)) { $html .= '</figcaption>'; } $html .= '</figure>'; $this->setVal('tag', $html); $this->wf->profileOut(__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; }
/** * Execute function for generating view of PostInfo template * Sets params' values of template * @param $params array of params described below * @param $params['post_url'] string Full link to full article * @param $params['post_title'] string Title of post * @param $params['avatar_url'] string Full url to user avatar image * @param $params['username'] string Name of post author * @param $params['user_page_url'] string Full url to author page * @param $params['date'] string Date of post publish * @param $params['short_text'] string Shortened version of text */ public function executePostInfo($params) { wfProfileIn(__METHOD__); $this->post_url = array_key_exists('post_url', $params) ? $params['post_url'] : ''; $this->post_title = array_key_exists('post_title', $params) ? $params['post_title'] : ''; $this->avatar_url = array_key_exists('avatar_url', $params) ? $params['avatar_url'] : AvatarService::renderAvatar('', EmailTemplatesHooksHelper::EMAIL_AVATAR_DEFAULT_WIDTH); $this->username = array_key_exists('username', $params) ? $params['username'] : wfMessage('oasis-anon-user')->plain(); $this->user_page_url = array_key_exists('user_page_url', $params) ? $params['user_page_url'] : ''; $this->date = array_key_exists('date', $params) ? $params['date'] : ''; wfProfileOut(__METHOD__); }
/** * 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 index() { wfProfileIn(__METHOD__); global $wgUser; $this->isAnon = $wgUser->isAnon(); $this->username = $wgUser->getName(); $this->avatarContainerAdditionalClass = ''; $this->profileAvatar = ''; $this->setupPersonalUrls(); if ($this->isAnon) { $this->navItemLinkOpeningTag = $this->renderPersonalUrl('login', true); $this->avatarContainerAdditionalClass = ' anon-avatar-placeholder'; $this->loginDropdown = F::app()->renderView('UserLoginSpecial', 'dropdown', ['template' => 'globalNavigationDropdown', 'registerLink' => $this->renderPersonalUrl('register')]); } else { $this->navItemLinkOpeningTag = $this->renderPersonalUrl('userpage', true); if (AvatarService::isEmptyOrFirstDefault($this->username)) { $this->avatarContainerAdditionalClass = ' logged-avatar-placeholder'; } else { $this->avatarContainerAdditionalClass = ' logged-avatar'; $this->profileAvatar = AvatarService::renderAvatar($this->username, AvatarService::AVATAR_SIZE_SMALL_PLUS - 2); //2px css border } $possibleItems = ['mytalk', 'following', 'preferences']; $dropdownItems = []; // Allow hooks to modify the dropdown items. wfRunHooks('AccountNavigationModuleAfterDropdownItems', [&$possibleItems, &$this->personalUrls]); foreach ($possibleItems as $item) { if (isset($this->personalUrls[$item])) { $dropdownItems[] = $this->renderPersonalUrl($item); } } // link to Help:Content ('known' -> never render as redlink) $helpLang = array_key_exists($this->wg->LanguageCode, $this->wg->AvailableHelpLang) ? $this->wg->LanguageCode : 'en'; $dropdownItems[] = Wikia::link(Title::newFromText(wfMessage('helppage')->inLanguage($helpLang)->text()), wfMessage('help')->text(), ['data-id' => 'help'], '', ['known']); $dropdownItems[] = $this->renderPersonalUrl('logout', false); $this->userDropdown = $dropdownItems; } wfProfileOut(__METHOD__); }
/** * 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; }
<div class="speech-bubble-avatar"> <a href="<?php echo $user_author_url; ?> "> <?php if (!$isreply) { ?> <?php echo AvatarService::renderAvatar($username, 50); ?> <?php } else { ?> <?php echo AvatarService::renderAvatar($username, 30); ?> <?php } ?> </a> </div> <blockquote class="speech-bubble-message"> <?php if (!$isreply) { ?> <?php if ($isWatched) { ?> <a <?php
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; }
echo $url; ?> "> <div class="avatars"> <?php foreach ($authors as $key => $author) { ?> <div class="avatars_<?php echo count($authors); ?> _<?php echo $key + 1; ?> "> <?php echo AvatarService::renderAvatar($author['username'], 30 - (count($authors) - 1) * 2); ?> </div> <?php } ?> </div> <div class="notification"> <div class="msg-title"><?php echo $helper->shortenText($title, WallNotificationsController::NOTIFICATION_TITLE_LIMIT); ?> </div> <?php if ($unread) { ?> <div class="msg-body">
/** * @desc Returns an array with correct elements from given api results * * @param array $postData results from API call with request of posts (articles) list in a category * * @return array */ private function prepareCssUpdateData($postData) { $cssUpdatePost = []; $communityWikiId = WikiFactory::DBtoID($this->getCommunityDbName()); $blogTitle = GlobalTitle::newFromText($postData['title'], NS_MAIN, $communityWikiId); $blogTitleText = $blogTitle->getText(); $lastRevisionUser = isset($postData['revisions'][0]['user']) ? $postData['revisions'][0]['user'] : null; $timestamp = isset($postData['revisions'][0]['timestamp']) ? $postData['revisions'][0]['timestamp'] : null; $blogUser = $this->getUserFromTitleText($blogTitleText, $lastRevisionUser); $userPage = GlobalTitle::newFromText($blogUser, NS_USER, $communityWikiId); if (!is_null($lastRevisionUser) && !is_null($timestamp) && $blogTitle instanceof GlobalTitle && $userPage instanceof GlobalTitle) { // $postData['revisions'][0]['*'] is being checked in SpecialCssModel::filterRevisionsData() // which is called before this method $sectionText = $postData['revisions'][0]['*']; $cssUpdateText = $this->truncateAndParseLinks($this->getCssUpdateSection($sectionText)); $cssUpdatePost = ['title' => $this->getAfterLastSlashText($blogTitleText), 'url' => $this->appendHeadlineAnchor($blogTitle->getFullURL()), 'userAvatar' => AvatarService::renderAvatar($blogUser, 25), 'userUrl' => $userPage->getFullUrl(), 'userName' => $blogUser, 'timestamp' => $timestamp, 'text' => $cssUpdateText]; } return $cssUpdatePost; }
<?php if ($showModule) { ?> <section class="module WikiaActivityModule ForumActivityModule"> <h1><?php echo wfMsg('forum-related-module-heading'); ?> </h1> <ul> <?php foreach ($messages as $message) { ?> <li> <?php echo AvatarService::renderAvatar($message['message']->getUser()->getName(), 20); ?> <em> <a href="<?php echo $message['message']->getMessagePageUrl(); ?> "><?php echo $message['message']->getMetaTitle(); ?> </a> </em> <div class="edited-by"> <?php $messageLast = empty($message['reply']) ? $message['message'] : $message['reply']; ?>
?> <section class="WallHistoryRail module"> <h2><?php echo wfMessage('wall-history-who-involved-wall-title')->escaped(); ?> </h2> <ul> <?php foreach ($usersInvolved as $userInvolved) { ?> <li> <a href="<?php echo $userInvolved['userpage']; ?> " class="avatar"><?php echo AvatarService::renderAvatar($userInvolved['username'], 30); ?> </a> <span class="names"> <a href="<?php echo $userInvolved['userpage']; ?> "> <?php echo $userInvolved['name1']; ?> </a> <?php if (!empty($userInvolved['name2'])) { ?> <a class='realname' href="<?php
public function executePopularStaffPosts() { global $wgUser, $wgTitle, $wgStylePath, $wgEnableBlog, $wgContLanguageCode; $isManager = $wgUser->isAllowed('corporatepagemanager'); $datafeeds = new WikiaStatsAutoHubsConsumerDB(DB_SLAVE); // $lang = AutoHubsPagesHelper::getLangForHub($wgTitle); // $tag_id = AutoHubsPagesHelper::getHubIdFromTitle($wgTitle); // $tag_name = AutoHubsPagesHelper::getHubNameFromTitle($wgTitle); // TODO: use ApiService wfProfileIn(__METHOD__ . '::HTTP'); $wikiurl = "http://community.wikia.com"; $html_out = Http::get($wikiurl . "/api.php?action=query&list=categorymembers&cmtitle=Category:Staff_blogs&cmnamespace=500&cmsort=timestamp&cmdir=desc&format=json"); $data = json_decode($html_out, true); wfProfileOut(__METHOD__ . '::HTTP'); $page_ids = array(); if (isset($data['query']) && isset($data['query']['categorymembers'])) { foreach ($data['query']['categorymembers'] as $r) { $page_ids[] = $r['pageid']; } } if ($isManager) { $temp = $datafeeds->getTopBlogs("staff", $wgContLanguageCode, 8, 4, true, true, $page_ids); } else { $temp = $datafeeds->getTopBlogs("staff", $wgContLanguageCode, 4, 4, false, false, $page_ids); } $posts = array(); foreach ($temp['value'] as $value) { // get additional data for the blog $post = array(); $post['title'] = $value['title']; $post['namespace'] = $value['namespace']; $post['timestamp'] = $value['timestamp']; $post['date'] = $value['date']; $post['avatar'] = AvatarService::renderAvatar($value['author'], 48); $post['userpage'] = $value['real_pagename']; // FIXME $post['username'] = $value['author']; $post['readmore'] = null; $post['text'] = $value['description']; $post['comments'] = $value['all_count']; $post['likes'] = null; $posts[] = $post; } $this->posts = $posts; $this->title = 'Popular Staff Blogs'; }
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; }
" /> <?php } elseif ($curRanking > $prevRanking && $prevRanking !== null) { ?> <img src="<?php echo "{$wgExtensionsPath}/wikia/AchievementsII/images/downarrow.png"; ?> " /> <?php } ?> </span> </td> <td class="user"> <?php echo AvatarService::renderAvatar($rankedUser->getName(), 35); ?> <a href="<?php echo $rankedUser->getUserPageUrl(); ?> "><?php echo htmlspecialchars($rankedUser->getName()); ?> </a> </td> <td class="tally"> <em><?php echo $wgLang->formatNum($userScore); ?> </em> <span><?php
private function getTag($imageHTML, $align, $width, $showCaption = false, $caption = '', $zoomIcon = '', $showPictureAttribution = false, $attributeTo = null) { /** * Images SEO * @author: Marooned, Federico */ $this->wf->profileIn(__METHOD__); $html = "<figure class=\"thumb" . (!empty($align) ? " t{$align}" : '') . " thumbinner\" style=\"width:{$width}px;\">{$imageHTML}{$zoomIcon}"; if (!empty($showCaption)) { $html .= "<figcaption class=\"thumbcaption\">{$caption}"; } //picture attribution if (!empty($showPictureAttribution) && !empty($attributeTo)) { $this->wf->profileIn(__METHOD__ . '::PictureAttribution'); // render avatar and link to user page $avatar = AvatarService::renderAvatar($attributeTo, 16); $link = AvatarService::renderLink($attributeTo); $html .= Xml::openElement('div', array('class' => 'picture-attribution')) . $avatar . $this->wf->MsgExt('oasis-content-picture-added-by', array('parsemag'), $link, $attributeTo) . Xml::closeElement('div'); $this->wf->profileOut(__METHOD__ . '::PictureAttribution'); } if (!empty($showCaption)) { $html .= '</figcaption>'; } $html .= '</figure>'; $this->wf->profileOut(__METHOD__); return $html; }
public function Notification() { global $wgUser; $isUnread = 'unread'; $notify = $this->request->getVal('notify'); if (empty($notify['grouped'][0])) { // do not render this notification, it's bugged return false; } $firstNotify = $notify['grouped'][0]; $data = $firstNotify->data; if (isset($data->type) && ($data->type === 'ADMIN' || $data->type === 'OWNER')) { $this->forward(__CLASS__, 'NotificationAdmin'); return; } $authors = []; foreach ($notify['grouped'] as $notify_entity) { $authors[] = ['displayname' => $notify_entity->data->msg_author_displayname, 'username' => $notify_entity->data->msg_author_username, 'avatar' => AvatarService::renderAvatar($firstNotify->data->msg_author_username, AvatarService::AVATAR_SIZE_SMALL_PLUS)]; } // 1 = 1 user, // 2 = 2 users, // 3 = more than 2 users $userCount = count($notify['grouped']); if ($userCount > 3) { $userCount = 3; } $msg = ""; wfRunHooks('NotificationGetNotificationMessage', [&$this, &$msg, $firstNotify->isMain(), $data, $authors, $userCount, $wgUser->getName()]); if (empty($msg)) { $msg = $this->getNotificationMessage($firstNotify->isMain(), $data, $authors, $userCount, $wgUser->getName()); } $unread = $this->request->getVal('unread'); if (!$unread) { $isUnread = 'read'; $authors = array_slice($authors, 0, 1); } $this->response->setVal('isUnread', $isUnread); $this->response->setVal('unread', $unread); $this->response->setVal('msg', $msg); // The instances of `WallNotificationEntity` in the `$notify['grouped']` array are sorted in reverse // chronological order. We want the url to point to the oldest unread item (which is the last element in the // array) instead of the most recent so that they start reading where the left off. See bugid 64560. $oldestEntity = end($notify['grouped']); if (empty($oldestEntity->data->url)) { $oldestEntity->data->url = ''; } $title = $this->getWallHelper()->shortenText($data->thread_title, self::NOTIFICATION_TITLE_LIMIT); $this->response->setVal('url', $this->fixNotificationURL($oldestEntity->data->url)); $this->response->setVal('authors', array_reverse($authors)); $this->response->setVal('title', $title); $this->response->setVal('iso_timestamp', wfTimestamp(TS_ISO_8601, $data->timestamp)); if ($unread && $data->notifyeveryone) { $this->response->getView()->setTemplate('GlobalNavigationWallNotificationsController', 'NotifyEveryone'); } }
/** * Modify HTML body of email * This method is helper for onComposeCommonBodyMail hook function * * @param Title $title * @param array $keys * @param string $body * @param User $editor * @param string $bodyHTML * @param array $postTransformKeys * @param string $action * @return bool */ public function bodyBlogpost(Title $title, &$keys, &$body, User $editor, &$bodyHTML, &$postTransformKeys, $action = FollowHelper::LOG_ACTION_BLOG_POST) { /* @var $wgLang Language */ global $wgLang; wfProfileIn(__METHOD__); $msgContentHTML = wfMsgHTMLwithLanguageAndAlternative('enotif_body' . ($action == '' ? '' : '_' . $action), 'enotif_body', $this->app->wg->LanguageCode); $content = $msgContentHTML[1]; $username = $editor->getName(); /* * $title variable has wrong value. Use $keys['$PAGETITLE'] to get title of the post ($oPostTitle). * $keys['$PAGETITLE'] is being generated by MailNotifyBuildKeys hook */ $oPostTitle = Title::newFromText($keys['$PAGETITLE'], NS_BLOG_ARTICLE); $oRevision = Revision::newFromId($oPostTitle->getLatestRevID()); $timestamp = time(); if ($oRevision instanceof Revision) { $timestamp = $oRevision->getTimestamp(); } $date = $wgLang->date(wfTimestamp(TS_MW, $timestamp)); /* render blog post info (avatar, author, date, title and short text) */ $post_info_params = array('language' => $this->app->wg->LanguageCode, 'post_url' => $oPostTitle->getFullURL(), 'post_title' => $oPostTitle->getSubpageText(), 'username' => $username, 'user_page_url' => $editor->getUserPage()->getFullURL(), 'avatar_url' => AvatarService::renderAvatar($username, self::EMAIL_AVATAR_DEFAULT_WIDTH), 'date' => $date); $postInfoHTML = $this->app->renderView("EmailTemplates", "PostInfo", $post_info_params); $keys['$POST_INFO'] = $postInfoHTML; /* render button HTML to be replaced in body of mail */ $button_params = array('language' => $this->app->wg->LanguageCode, 'link_url' => $oPostTitle->getFullURL(), 'link_text' => wfMessage('read-the-whole-post')->plain()); $buttonHTML = $this->app->renderView("EmailTemplates", "Button", $button_params); $keys['$BUTTON'] = $buttonHTML; $keys['$TITLE_STYLE'] = ' style="color:#2c85d5;font-size:17px;font-weight:bold;"'; /* render body of mail */ $body_params = array('language' => $this->app->wg->LanguageCode, 'content' => $content); $bodyHTML = $this->app->renderView("EmailTemplates", "NewBlogPostMail", $body_params); wfProfileOut(__METHOD__); return true; }
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__); }
/** * 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__); }
/** * @brief Passes more data to the template to render avatar modal box * * @param int $userId * * @author Andrzej 'nAndy' Łukaszewski */ private function renderAvatarLightbox($userId) { wfProfileIn(__METHOD__); $user = User::newFromId($userId); $this->setVal('defaultAvatars', $this->getDefaultAvatars()); $this->setVal('isUploadsPossible', $this->wg->EnableUploads && $this->wg->User->isAllowed('upload') && empty($this->wg->AvatarsMaintenance)); $this->setVal('avatarName', $user->getGlobalAttribute('avatar')); $this->setVal('userId', $userId); $this->setVal('avatarMaxSize', self::AVATAR_MAX_SIZE); $this->setVal('avatar', AvatarService::renderAvatar($user->getName(), self::AVATAR_DEFAULT_SIZE)); wfProfileOut(__METHOD__); }
<section class="module WikiaActivityModule ForumActivityModule"> <h2><?php echo wfMessage('forum-activity-module-heading')->escaped(); ?> </h2> <ul> <?php foreach ($posts as $value) { ?> <li> <?php echo AvatarService::renderAvatar($value['user']->getName(), 20); ?> <em> <a href="<?php echo $value['wall_message']->getMessagePageUrl(true); ?> " title="<?php echo htmlspecialchars($value['metatitle']); ?> "><?php echo htmlspecialchars($value['metatitle']); ?> </a> </em> <div class="edited-by"> <?php $user = '******' . $value['user']->getUserPage()->getFullUrl() . '">' . htmlspecialchars($value['display_username']) . '</a>'; ?> <?php $time = '<span class="timeago abstimeago" title="' . $value['event_iso'] . '" alt="' . $value['event_mw'] . '"> </span>';
/** * 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__); }
/** * Given an array of user-data, returns the HTML for a badge representation. If largeFormat is true (default), * then the larger format including the avatar image will be used; otherwise, a compact version will be used. * * The userData is expected to be an associative array containing the keys 'user_id', 'user_name', and 'edits'. */ public static function getUserBadge($userData, $largeFormat = true) { $ret = ""; // get avatar $ret .= Xml::openElement('div', array('class' => 'userInfoBadge')); if ($largeFormat) { $ret .= Xml::openElement('div', array('class' => 'userInfoBadgeAvatarWrapper')); $avatarImg = AvatarService::renderAvatar($userData['user_id'], 50); $ret .= $avatarImg; $ret .= Xml::closeElement('div'); } // render user info $class = "userInfo"; $class .= $largeFormat ? "" : " userInfoNoAvatar"; $ret .= Xml::openElement('div', array('class' => $class)); if ($userData['user_name'] == 'helper') { // anonymous users $ret .= Xml::element('span', array('class' => 'userPageLink'), wfMsg('unregistered')); $ret .= Xml::element('span', array('class' => 'anonEditPoints'), wfMsgExt('anonymous_edit_points', array('parsemag'), array($userData['edits']))); } else { // link to user page $userPage = Title::newFromText($userData['user_name'], NS_USER); $userPageLink = !empty($userPage) ? $userPage->getLocalUrl() : ''; if ($largeFormat) { $ret .= Xml::element('a', array('href' => $userPageLink, 'class' => 'userPageLink'), $userData['user_name']); // user points $ret .= Xml::openElement('div', array('class' => 'userEditPoints')); $ret .= Xml::openElement('nobr'); $ret .= Xml::element('span', array('class' => "userPoints userDatas-user-points-{$userData['user_id']}", 'timestamp' => wfTimestampNow()), $userData['edits']); $ret .= ' '; // space for graceful degradation $ret .= wfMsgExt('edit_points', array('parsemag'), array($userData['edits'])); $ret .= Xml::closeElement('nobr'); $ret .= Xml::closeElement('div'); // END .userEditPoints } else { $ret .= Xml::openElement('div', array('style' => 'float:left;')); $ret .= Xml::element('a', array('href' => $userPageLink, 'class' => 'userPageLink'), $userData['user_name']); $ret .= Xml::closeElement('div'); // END .userEditPoints $ret .= ' '; // space for graceful degradation $ret .= Xml::element('div', array('class' => "userPoints userDatas-user-points-{$userData['user_id']}", 'style' => 'display:inline', 'timestamp' => wfTimestampNow()), $userData['edits']); } } $ret .= Xml::closeElement('div'); // END .userInfo $ret .= Xml::closeElement('div'); // END .userInfoBadge return $ret; }
} else { ?> <div id=wkWrdMrk><?php echo $wikiName; ?> </div> <?php } ?> </a> <a href=#wkNavSrh id=wkSrhTgl class=tgl></a> <a href=#wkNavMenu id=wkNavTgl class=tgl></a> <?php if ($loggedIn) { // This gives me image 50x50 but adds html attributes width and height with values 25 echo '<a id="wkPrfTgl" class="tgl lgdin" href="#">' . AvatarService::renderAvatar($userName, 25) . '</a>'; } else { echo '<a id="wkPrfTgl" class="tgl lgdout ' . $loginButtonClass . '" href="' . Sanitizer::encodeAttribute($loginUrl) . '"></a>'; } ?> </div> <div id=wkSrh> <form id=wkSrhFrm action="<?php echo Sanitizer::encodeAttribute(SpecialPage::getSafeTitleFor('Search')->getLocalURL()); ?> " method=get class='wkForm hide-clear'> <input type=hidden name=fulltext value=Search> <input id=wkSrhInp type=text name=search placeholder="<?php echo wfMessage('wikiamobile-search-this-wiki')->escaped(); ?> " value="<?php
"> <sup>#</sup> <?php echo $entry['msgid']; ?> </a> <?php } ?> </td> <td> <a href="<?php echo $entry['authorurl']; ?> "><?php echo AvatarService::renderAvatar($entry['username'], 20); ?> </a> </td> <td> <?php echo wfMessage($wallHistoryMsg[$entry['prefix'] . $entry['type']])->rawParams(['', $entry['displayname'], Xml::element('a', ['href' => $entry['msguserurl']], $entry['msgusername']), Xml::element('a', ['href' => $entry['msgurl'], 'class' => 'creation'], $entry['metatitle']), '<a href="' . $entry['msgurl'] . '">#' . $entry['msgid'] . '</a>'])->escaped(); ?> <?php if (!empty($entry['actions'])) { $actions = []; foreach ($entry['actions'] as $key => $action) { $htmldata = $action; unset($htmldata['msg']); $actions[] = wfMessage('parentheses')->rawParams(Xml::element('a', $htmldata, $action['msg']))->escaped();
<?php } ?> </td></tr></table> </div> <?php } ?> <?php if ($showArchiveInfo) { ?> <div class="deleteorremove-infobox"> <div class="deleteorremove-bubble"> <div class="avatar"><?php echo AvatarService::renderAvatar($statusInfo['user']->getName(), 20); ?> </div> <div class="message"> <?php echo wfMsgExt('wall-message-closed-by', array('parseinline'), array($statusInfo['user']->getName(), $statusInfo['user']->getUserPage())); ?> <br> <div class="timestamp"><span><?php echo $statusInfo['fmttime']; ?> </span></div> </div> </div> </div> <?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); }