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__);
 }
예제 #2
0
	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));
	}
예제 #3
0
 /**
  * @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));
 }
예제 #4
0
function wfCOPageHeaderIndexAfterExecute(&$controller, &$params)
{
    if (wfCOCheck()) {
        if (isset($controller->content_actions['delete'])) {
            $action = $controller->content_actions['delete'];
            $action['text'] = wfMsgHtml('comments-only-delete-thread');
            $controller->actionName = 'delete';
            $controller->action = $action;
        } else {
            $controller->action = null;
            $controller->actionName = '';
        }
        $controller->dropdown = array();
        if ($controller->revisions) {
            global $wgTitle;
            $rev = $wgTitle->getFirstRevision();
            if ($rev) {
                $user = User::newFromId($rev->getUser());
                if ($user) {
                    $controller->revisions = array('current' => array('user' => $user->getName(), 'link' => AvatarService::renderLink($user->getName()), 'avatarUrl' => AvatarService::getAvatarUrl($user->getName()), 'timestamp' => wfTimestamp(TS_ISO_8601, $rev->getTimestamp())));
                }
            }
        }
    }
    return true;
}
예제 #5
0
 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;
 }
 public function executeIndex()
 {
     wfProfileIn(__METHOD__);
     $maxElements = 4;
     global $wgLang, $wgContentNamespaces, $wgMemc, $wgUser;
     $this->moduleHeader = wfMsg('oasis-activity-header');
     if (empty($this->userName)) {
         $mKey = wfMemcKey('mOasisLatestActivity');
         $feedData = $wgMemc->get($mKey);
     }
     if (empty($feedData)) {
         // data provider
         $includeNamespaces = implode('|', $wgContentNamespaces);
         $parameters = array('type' => 'widget', 'maxElements' => $maxElements, 'flags' => array('shortlist'), 'uselang' => $wgLang->getCode(), 'includeNamespaces' => $includeNamespaces);
         $feedProxy = new ActivityFeedAPIProxy($includeNamespaces, $this->userName);
         $feedProvider = new DataFeedProvider($feedProxy, 1, $parameters);
         $feedData = $feedProvider->get($maxElements);
         if (empty($this->userName)) {
             $wgMemc->set($mKey, $feedData);
         }
     }
     // Time strings are slow to calculate, but we still want them to update frequently (60 seconds)
     if (empty($this->userName)) {
         $mKeyTimes = wfMemcKey('mOasisLatestActivity_times', $wgLang->getCode());
         $this->changeList = $wgMemc->get($mKeyTimes, array());
     }
     if (empty($this->changeList) && !empty($feedData) && is_array($feedData['results'])) {
         $changeList = array();
         foreach ($feedData['results'] as $change) {
             $item = array();
             $item['time_ago'] = wfTimeFormatAgoOnlyRecent($change['timestamp']);
             // TODO: format the timestamp on front-end to allow longer caching in memcache?
             $item['user_name'] = $change['username'];
             $item['avatar_url'] = AvatarService::getAvatarUrl($item['user_name'], 20);
             $item['user_href'] = AvatarService::renderLink($item['user_name']);
             $item['page_title'] = $change['title'];
             $item['changetype'] = $change['type'];
             $title = Title::newFromText($change['title'], $change['ns']);
             if (!empty($change['articleComment']) && !empty($change['url'])) {
                 $item['page_href'] = Xml::element('a', array('href' => $change['url']), $item['page_title']);
             } else {
                 if (is_object($title)) {
                     $item['page_href'] = Xml::element('a', array('href' => $title->getLocalUrl()), $item['page_title']);
                 }
             }
             switch ($change['type']) {
                 case 'new':
                 case 'edit':
                 case 'delete':
                     // different formatting for User Profile Pages
                     if (!empty($this->userName)) {
                         $item['page_href'] = wfMsg("userprofilepage-activity-{$change['type']}", $item['page_href']);
                         $item['changemessage'] = $item['time_ago'];
                     } else {
                         // format message (RT #144814)
                         $item['changemessage'] = wfMsg("oasis-latest-activity-{$change['type']}-details", $item['user_href'], $item['time_ago']);
                     }
                     $item['changeicon'] = $change['type'];
                     break;
                 default:
                     // show just a timestamp
                     $item['changemessage'] = $item['time_ago'];
                     break;
             }
             $changeList[] = $item;
         }
         $this->changeList = $changeList;
         if (empty($this->userName)) {
             $wgMemc->set($mKeyTimes, $this->changeList, 60);
         }
     }
     // Cache the response in CDN and browser
     $this->response->setCacheValidity(600);
     wfProfileOut(__METHOD__);
 }
예제 #7
0
 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;
 }
예제 #8
0
 /**
  * Get message for by user section
  * @param string $userName
  * @param string $addedAt
  * @return string $addedBy
  */
 public static function getByUserMsg($userName, $addedAt)
 {
     // get link to user page
     $link = AvatarService::renderLink($userName);
     $addedBy = wfMessage('thumbnails-added-by', $link, wfTimeFormatAgo($addedAt, false))->text();
     return $addedBy;
 }
예제 #9
0
 /**
  * @param array $options
  * @return mixed|string
  * @throws MWException
  */
 function toHtml($options = array())
 {
     if (count(func_get_args()) == 2) {
         throw new MWException(__METHOD__ . ' called in the old style');
     }
     if (!empty(F::app()->wg->RTEParserEnabled)) {
         return $this->renderAsThumbnailImage($options);
     }
     wfProfileIn(__METHOD__);
     $alt = empty($options['alt']) ? '' : $options['alt'];
     $useThmbnailInfoBar = false;
     /*
      * in order to disable RDF metadata in video thumbnails
      * pass disableRDF parameter to toHtml method
      */
     $useRDFData = !empty($options['disableRDF']) && $options['disableRDF'] == true ? false : true;
     /**
      * Note: if title is empty and alt is not, make the title empty, don't
      * use alt; only use alt if title is not set
      * wikia change, Inez
      */
     $title = !isset($options['title']) ? $alt : $options['title'];
     $query = empty($options['desc-query']) ? '' : $options['desc-query'];
     if (!empty($options['custom-url-link'])) {
         $linkAttribs = array('href' => $options['custom-url-link']);
         if (!empty($options['title'])) {
             $linkAttribs['title'] = $options['title'];
         }
     } elseif (!empty($options['custom-title-link'])) {
         $title = $options['custom-title-link'];
         $linkAttribs = array('href' => $title->getLinkUrl(), 'title' => empty($options['title']) ? $title->getFullText() : $options['title']);
     } elseif (!empty($options['desc-link'])) {
         $linkAttribs = $this->getDescLinkAttribs(empty($options['title']) ? null : $options['title'], $query);
         if (F::app()->checkSkin(array('oasis', 'wikiamobile'))) {
             $linkAttribs['data-video-name'] = $this->file->getTitle()->getText();
             $linkAttribs['href'] = $this->file->getTitle()->getLocalURL();
             if (!empty($options['id'])) {
                 $linkAttribs['id'] = $options['id'];
             }
         }
     } elseif (!empty($options['file-link'])) {
         $linkAttribs = array('href' => $this->file->getTitle()->getLocalURL());
     } else {
         $linkAttribs = array();
     }
     if (isset($options['linkAttribs']) && is_array($options['linkAttribs'])) {
         $linkAttribs = array_merge($linkAttribs, $options['linkAttribs']);
     }
     $linkAttribs['class'] = empty($linkAttribs['class']) ? 'video' : $linkAttribs['class'] . ' video';
     if ($useRDFData) {
         // bugId: #46621
         $linkAttribs['itemprop'] = 'video';
         $linkAttribs['itemscope'] = '';
         $linkAttribs['itemtype'] = 'http://schema.org/VideoObject';
     }
     $attribs = array('alt' => $alt, 'src' => !empty($options['src']) ? $options['src'] : $this->url, 'width' => $this->width, 'height' => $this->height, 'data-video' => $this->file->getTitle()->getText());
     if ($useRDFData) {
         $attribs['itemprop'] = 'thumbnail';
     }
     if (!empty($options['usePreloading'])) {
         $attribs['data-src'] = $this->url;
     }
     if ($this->file instanceof OldLocalFile) {
         $archive_name = $this->file->getArchiveName();
         if (!empty($archive_name)) {
             $linkAttribs['href'] .= '?t=' . $this->file->getTimestamp();
             $linkAttribs['data-timestamp'] = $this->file->getTimestamp();
         }
     }
     if (!empty($options['valign'])) {
         $attribs['style'] = "vertical-align: {$options['valign']}";
     }
     $attribs['class'] = 'Wikia-video-thumb';
     if (!empty($options['img-class'])) {
         $attribs['class'] .= ' ' . $options['img-class'];
     }
     if ($this->file instanceof WikiaLocalFile || $this->file instanceof WikiaForeignDBFile) {
         $extraBorder = $this->file->addExtraBorder($this->width);
     }
     if (!empty($extraBorder)) {
         if (!isset($attribs['style'])) {
             $attribs['style'] = '';
         }
         $attribs['style'] .= 'border-top: 15px solid black; border-bottom: ' . $extraBorder . 'px solid black;';
     }
     if (isset($options['imgExtraStyle'])) {
         if (!isset($attribs['style'])) {
             $attribs['style'] = '';
         }
         $attribs['style'] .= $options['imgExtraStyle'];
     }
     if ($useThmbnailInfoBar || isset($options['duration']) && $options['duration'] == true) {
         $duration = $this->file->getHandler()->getFormattedDuration();
     }
     if (isset($options['constHeight'])) {
         $this->appendHtmlCrop($linkAttribs, $options);
     }
     $html = $linkAttribs && isset($linkAttribs['href']) ? Xml::openElement('a', $linkAttribs) : '';
     if (isset($duration) && !empty($duration)) {
         $timerProp = array('class' => 'timer');
         if ($useRDFData) {
             $timerProp['itemprop'] = 'duration';
         }
         $html .= Xml::element('div', $timerProp, $duration);
     }
     $playButtonHeight = isset($options['constHeight']) && $this->height > $options['constHeight'] ? $options['constHeight'] : $this->height;
     if (!empty($extraBorder)) {
         $playButtonHeight += $extraBorder * 2;
     }
     $html .= WikiaFileHelper::videoPlayButtonOverlay($this->width, $playButtonHeight);
     $html .= Xml::element('img', $attribs, '', true);
     $html .= WikiaFileHelper::videoInfoOverlay($this->width, $this->file->getTitle());
     $html .= $linkAttribs && isset($linkAttribs['href']) ? Xml::closeElement('a') : '';
     if ($useThmbnailInfoBar) {
         $titleBar = array("class" => "Wikia-video-title-bar", "style" => "width: {$this->width}px; margin-left: -{$this->width}px;");
         $videoTitle = $attribs['data-video'];
         $infoVars = array();
         $userName = $this->file->getUser();
         if (!is_null($userName)) {
             $link = AvatarService::renderLink($userName);
             $infoVars["author"] = wfMsgExt('oasis-content-picture-added-by', array('parsemag'), $link, $userName);
         } else {
             $infoVars["author"] = "";
         }
         if (!empty($duration)) {
             $infoVars["duration"] = '(' . $duration . ')';
         } else {
             $infoVars["duration"] = '';
         }
         if (!isset($options['img-class'])) {
             $options['img-class'] = "";
         }
         if ($options['img-class'] != "thumbimage") {
             $html .= Xml::openElement('span', $titleBar);
             $html .= Xml::element('span', array('class' => 'title'), $videoTitle);
             $html .= Xml::element('span', array('class' => 'info'), '{author} {duration}');
             $html .= Xml::closeElement('span');
         }
         foreach ($infoVars as $key => $value) {
             $html = str_replace('{' . $key . '}', $value, $html);
         }
     }
     //give extensions a chance to modify the markup
     wfRunHooks('ThumbnailVideoHTML', array($options, $linkAttribs, $attribs, $this->file, &$html));
     wfProfileOut(__METHOD__);
     return $html;
 }
예제 #10
0
 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;
 }
예제 #11
0
<aside id="recentWikiActivity" class="recent-wiki-activity">
	<header><?php 
echo wfMessage('recent-wiki-activity-header');
?>
</header>
	<ul>
		<?php 
foreach ($changeList as $change) {
    ?>
			<?php 
    if (in_array($change['type'], ['new', 'edit', 'delete'])) {
        $message = wfMessage("recent-wiki-activity-{$change['type']}-details")->params(AvatarService::renderLink($change['username']), wfTimeFormatAgoOnlyRecent($change['timestamp']))->text();
    } else {
        $message = wfTimeFormatAgoOnlyRecent($change['timestamp']);
    }
    ?>
			<li>
				<a class="recent-wiki-activity-link" href="<?php 
    echo $change['url'];
    ?>
"><?php 
    echo $change['title'];
    ?>
</a>
				<span><?php 
    echo $message;
    ?>
</span>
			</li>
		<?php 
}
	/**
	 * Get recent revisions of current article and format them
	 */
	protected function getRecentRevisions() {
		global $wgTitle, $wgMemc;

		// use service to get data
		$service = new PageStatsService($wgTitle->getArticleId());

		// get info about current revision and list of authors of recent five edits
		// This key is refreshed by the onArticleSaveComplete() hook
		$mKey = wfMemcKey('mOasisRecentRevisions2', $wgTitle->getArticleId());
		$revisions = $wgMemc->get($mKey);

		if (empty($revisions)) {
			$revisions = $service->getCurrentRevision();

			// format timestamps, render avatars and user links
			if (is_array($revisions)) {
				foreach($revisions as &$revision) {
					if (isset($revision['user'])) {
						$revision['avatarUrl'] = AvatarService::getAvatarUrl($revision['user']);
						$revision['link'] = AvatarService::renderLink($revision['user']);
					}
				}
			}
			$wgMemc->set($mKey, $revisions);
		}

		return $revisions;
	}