コード例 #1
0
 public function executeIndex()
 {
     wfProfileIn(__METHOD__);
     global $wgLang, $wgOut;
     $themeSettings = new ThemeSettings();
     // current settings
     $this->themeSettings = $themeSettings->getSettings();
     // application theme settings (not user settable)
     $this->applicationThemeSettings = SassUtil::getApplicationThemeSettings();
     // recent versions
     $themeHistory = array_reverse($themeSettings->getHistory());
     // format time (for edits older than 30 days - show timestamp)
     foreach ($themeHistory as &$entry) {
         $diff = time() - strtotime($entry['timestamp']);
         if ($diff < 30 * 86400) {
             $entry['timeago'] = wfTimeFormatAgo($entry['timestamp']);
         } else {
             $entry['timeago'] = $wgLang->date($entry['timestamp']);
         }
     }
     $this->themeHistory = $themeHistory;
     // URL user should be redirected to when settings are saved
     if (isset($_SERVER['HTTP_REFERER'])) {
         $this->returnTo = $_SERVER['HTTP_REFERER'];
     } else {
         $this->returnTo = $this->wg->Script;
     }
     // load Google Analytics code
     $this->analytics = AnalyticsEngine::track('GA_Urchin', AnalyticsEngine::EVENT_PAGEVIEW);
     $wgOut->getResourceLoader()->getModule('mediawiki');
     $ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
     $this->globalVariablesScript = $ret;
     wfProfileOut(__METHOD__);
 }
コード例 #2
0
	public static function formatTimestamp($stamp) {

		$diff = time() - strtotime($stamp);

		// show time difference if it's 14 or less days
		if ($diff < 15 * 86400) {
			$ret = wfTimeFormatAgo($stamp);
		}
		else {
			$ret = '';
		}
		return $ret;
	}
コード例 #3
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;
 }
コード例 #4
0
ファイル: FeedRenderer.php プロジェクト: schwarer2006/wikia
 public static function formatTimestamp($stamp)
 {
     return wfTimeFormatAgo($stamp);
 }
コード例 #5
0
$count = 0;
foreach ($badges as $item) {
    //if ($count > $maxBadges) {	break;	}
    $badge_name = htmlspecialchars($item['badge']->getName(), ENT_NOQUOTES);
    $badge_url = $item['badge']->getPictureUrl(40);
    $badge_url_hover = $item['badge']->getPictureUrl(90);
    $badge_details = $item['badge']->getDetails();
    $is_sponsored = $item['badge']->isSponsored();
    $hover_url = $item['badge']->getHoverPictureUrl();
    $badge_tracking_url = $item['badge']->getTrackingUrl();
    $badge_click_url = $item['badge']->getClickCommandUrl();
    $hover_tracking_url = $item['badge']->getHoverTrackingUrl();
    $earned_by = $item['badge']->getEarnedBy();
    // Display mode can be 'LatestBadges' (special:leaderboard) or 'Achievements' (user page)
    if ($displayMode == 'LatestBadges') {
        $info = wfMsg('achievements-recent-info', $item['user']->getUserPage()->getLocalURL(), $item['user']->getName(), $badge_name, $item['badge']->getGiveFor(), wfTimeFormatAgo($item['date']));
    } else {
        $info = "<strong>{$badge_name}</strong><br /> {$item['to_get']}";
    }
    ?>
	<li>
		<div class="profile-hover<?php 
    echo $is_sponsored ? ' sponsored-hover' : null;
    ?>
"<?php 
    echo $is_sponsored && !empty($hover_tracking_url) ? " data-hovertrackurl=\"{$hover_tracking_url}\"" : null;
    ?>
>
			<?php 
    if ($is_sponsored) {
        ?>
コード例 #6
0
 /**
  * Return array consisting of videoThumb and videoTimestamp
  * for given video name
  *
  * @param string $fileName
  * @param int    $thumbSize
  *
  * @return array
  */
 public function getVideoData($fileName, $thumbSize)
 {
     $videoData = [];
     $title = Title::newFromText($fileName, NS_FILE);
     if (!empty($title)) {
         $file = wfFindFile($title);
     }
     if (!empty($file)) {
         $htmlParams = ['file-link' => true, 'duration' => true, 'img-class' => 'media', 'linkAttribs' => ['class' => 'video-thumbnail lightbox', 'data-video-name' => $fileName]];
         $thumb = $file->transform(['width' => $thumbSize]);
         $videoData['videoThumb'] = $thumb->toHtml($htmlParams);
         $videoData['videoTimestamp'] = $file->getTimestamp();
         $videoData['videoTime'] = wfTimeFormatAgo($videoData['videoTimestamp']);
         $meta = unserialize($file->getMetadata());
         $videoData['duration'] = isset($meta['duration']) ? $meta['duration'] : null;
         $videoData['title'] = $title->getText();
         $videoData['fileUrl'] = $this->getFileUrl($fileName, $file);
         $videoData['thumbUrl'] = $thumb->getUrl();
     }
     return $videoData;
 }
コード例 #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
/**
 * Returns the text from wfTimeFormatAgo only if the text is recent.
 * This can be used in places that we don't want to show glaringly stale timestamps.
 *
 * @author Maciej Brencz <*****@*****.**>, Sean Colombo
 */
function wfTimeFormatAgoOnlyRecent($stamp)
{
    wfProfileIn(__METHOD__);
    $ago = time() - strtotime($stamp) + 1;
    if ($ago < 7 * 86400) {
        $res = wfTimeFormatAgo($stamp);
    } else {
        $res = '';
    }
    wfProfileOut(__METHOD__);
    return $res;
}
コード例 #9
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;
 }
コード例 #10
0
    echo $thumbHeight;
    ?>
" data-video="<?php 
    echo $video['fileTitle'];
    ?>
" class="Wikia-video-thumb thumbimage">
				<?php 
    echo $video['videoOverlay'];
    ?>
			</a>
			<p><?php 
    echo $video['byUserMsg'];
    ?>
</p>
			<p itemprop="uploadDate"><?php 
    echo wfTimeFormatAgo($video['timestamp']);
    ?>
</p>
			<p><?php 
    echo $video['postedInMsg'];
    ?>
</p>
			<meta itemprop="embedUrl" content="<?php 
    echo $video['embedUrl'];
    ?>
" />			
		</div>

		<?php 
    $counter++;
    ?>
コード例 #11
0
ファイル: AchBadge.class.php プロジェクト: yusufchang/app
    /**
     * Outputs the HTML for the the badge. If 'compact' is set to true, displays a version with less info
     * that is used on the ActivityFeed (since the user's name, etc. are already on the associated RecentChange).
     *
     * @param badgeWrapper - not an AchBadge, but rather an associative array which contains an AchBadge and some other info.
     */
    public static function renderForActivityFeed($badgeWrapper, $compact = true)
    {
        wfProfileIn(__METHOD__);
        $badge_name = htmlspecialchars($badgeWrapper['badge']->getName());
        $badge_url = $badgeWrapper['badge']->getPictureUrl(82);
        $badge_url_hover = $badgeWrapper['badge']->getPictureUrl(90);
        $badge_details = $badgeWrapper['badge']->getDetails();
        $linkToLeaderboard = Skin::makeSpecialUrl('Leaderboard');
        if ($compact) {
            $info = wfMsg('achievements-activityfeed-info', $badge_name, $badgeWrapper['badge']->getGiveFor(), $linkToLeaderboard);
        } else {
            // This was for the sidebar on the leaderboard page.  Not sure if it makes sense to keep it in this function as an option.
            $info = wfMsg('achievements-recent-info', $badgeWrapper['user']->getUserPage()->getLocalURL(), $badgeWrapper['user']->getName(), $badge_name, $badgeWrapper['badge']->getGiveFor(), wfTimeFormatAgo($badgeWrapper['date']));
        }
        ?>
			<div class='achievement-in-activity-feed'>
				<div class="profile-hover">
					<img src="<?php 
        echo $badge_url_hover;
        ?>
" height="90" width="90" />
					<div class="profile-hover-text">
						<h3><?php 
        echo $badge_name;
        ?>
</h3>
						<p><?php 
        echo $badge_details;
        ?>
</p>
					</div>
				</div>
				<a href="<?php 
        echo $linkToLeaderboard;
        ?>
" class='achievement-image-link'>
					<img rel="leaderboard" src="<?php 
        echo $badge_url;
        ?>
" alt="<?php 
        echo $badge_name;
        ?>
" height="82" width="82" />
				</a>
				<div class="badge-text">
					<p><?php 
        echo $info;
        ?>
</p>
				</div>
			</div>
			<div class="feed-clear"></div>
		<?php 
        wfProfileOut(__METHOD__);
    }
コード例 #12
0
 /**
  * get list of videos
  * @param string $sort [recent/popular/trend]
  * @param integer $page
  * @param array $providers
  * @param string $category
  * @param array $options
  * @return array $videos
  */
 public function getVideos($sort, $page, $providers = [], $category = '', $options = [])
 {
     wfProfileIn(__METHOD__);
     if ($sort == 'premium') {
         $sort = 'recent';
         $filter = 'premium';
     } else {
         $filter = 'all';
     }
     if ($this->app->checkSkin('wikiamobile')) {
         $limit = self::VIDEOS_PER_PAGE_MOBILE;
         $providers = $this->wg->WikiaMobileSupportedVideos;
         $thumbOptions = ['useTemplate' => true, 'fluid' => true, 'forceSize' => 'small', 'img-class' => 'media', 'dataParams' => true];
     } else {
         $limit = self::VIDEOS_PER_PAGE;
         $providers = empty($providers) ? [] : explode(',', $providers);
         $thumbOptions = ['fluid' => true, 'showViews' => true, 'fixedHeight' => self::THUMBNAIL_HEIGHT, 'hidePlayButton' => true];
     }
     // get video list
     $mediaService = new MediaQueryService();
     $videoList = $mediaService->getVideoList($sort, $filter, $limit, $page, $providers, $category);
     $videoOptions = ['thumbWidth' => self::THUMBNAIL_WIDTH, 'thumbHeight' => self::THUMBNAIL_HEIGHT, 'postedInArticles' => self::POSTED_IN_ARTICLES, 'thumbOptions' => $thumbOptions, 'getThumbnail' => array_key_exists('getThumbnail', $options) ? $options['getThumbnail'] : true];
     // get video detail
     $videos = [];
     $helper = new VideoHandlerHelper();
     foreach ($videoList as $videoInfo) {
         $videoDetail = $helper->getVideoDetail($videoInfo, $videoOptions);
         if (!empty($videoDetail)) {
             $byUserMsg = WikiaFileHelper::getByUserMsg($videoDetail['userName'], $videoDetail['timestamp']);
             $viewTotal = wfMessage('videohandler-video-views', $this->wg->Lang->formatNum($videoDetail['viewsTotal']))->text();
             $videos[] = ['title' => $videoDetail['fileTitle'], 'fileKey' => $videoDetail['title'], 'fileUrl' => $videoDetail['fileUrl'], 'thumbnail' => $videoDetail['thumbnail'], 'timestamp' => wfTimeFormatAgo($videoDetail['timestamp'], false), 'updated' => $videoDetail['timestamp'], 'viewTotal' => $viewTotal, 'byUserMsg' => $byUserMsg, 'truncatedList' => $videoDetail['truncatedList'], 'duration' => $videoDetail['duration'], 'thumbUrl' => $videoDetail['thumbUrl'], 'embedUrl' => $videoDetail['embedUrl']];
         }
     }
     wfProfileOut(__METHOD__);
     return $videos;
 }
コード例 #13
0
function wfSpecialWikiaNewFiles($par, $specialPage)
{
    global $wgOut, $wgLang, $wgRequest, $wgMiserMode;
    global $wmu, $wgOasisHD;
    $wpIlMatch = $wgRequest->getText('wpIlMatch');
    $dbr = wfGetDB(DB_SLAVE);
    $sk = RequestContext::getMain()->getSkin();
    $shownav = !$specialPage->including();
    $hidebots = $wgRequest->getBool('hidebots', 1);
    $hidebotsql = '';
    if ($hidebots) {
        # Make a list of group names which have the 'bot' flag set.
        $botconds = array();
        foreach (User::getGroupsWithPermission('bot') as $groupname) {
            $botconds[] = 'ug_group = ' . $dbr->addQuotes($groupname);
        }
        # If not bot groups, do not set $hidebotsql
        if ($botconds) {
            $isbotmember = $dbr->makeList($botconds, LIST_OR);
            # This join, in conjunction with WHERE ug_group IS NULL, returns
            # only those rows from IMAGE where the uploading user is not a mem-
            # ber of a group which has the 'bot' permission set.
            $ug = $dbr->tableName('user_groups');
            $hidebotsql = " LEFT JOIN {$ug} ON img_user=ug_user AND ({$isbotmember})";
        }
    }
    $image = $dbr->tableName('image');
    $sql = "SELECT img_timestamp from {$image}";
    if ($hidebotsql) {
        $sql .= "{$hidebotsql} WHERE ug_group IS NULL";
    }
    $sql .= ' ORDER BY img_timestamp DESC LIMIT 1';
    $res = $dbr->query($sql, __FUNCTION__);
    $row = $dbr->fetchRow($res);
    if ($row !== false) {
        $ts = $row[0];
    } else {
        $ts = false;
    }
    $dbr->freeResult($res);
    $sql = '';
    # If we were clever, we'd use this to cache.
    $latestTimestamp = wfTimestamp(TS_MW, $ts);
    # Hardcode this for now.
    $limit = 48;
    if ($parval = intval($par)) {
        if ($parval <= $limit && $parval > 0) {
            $limit = $parval;
        }
    }
    $where = array();
    $searchpar = '';
    if ($wpIlMatch != '' && !$wgMiserMode) {
        $nt = Title::newFromUrl($wpIlMatch);
        if ($nt) {
            $m = $dbr->buildLike($dbr->anyString(), strtolower($nt->getDBkey()), $dbr->anyString());
            $where[] = 'LOWER(img_name)' . $m;
            $searchpar = '&wpIlMatch=' . urlencode($wpIlMatch);
        }
    }
    $invertSort = false;
    if ($until = $wgRequest->getVal('until')) {
        $where[] = "img_timestamp < '" . $dbr->timestamp($until) . "'";
    }
    if ($from = $wgRequest->getVal('from')) {
        $where[] = "img_timestamp >= '" . $dbr->timestamp($from) . "'";
        $invertSort = true;
    }
    $sql = 'SELECT img_size, img_name, img_user, img_user_text,' . "img_description,img_timestamp FROM {$image}";
    if ($hidebotsql) {
        $sql .= $hidebotsql;
        $where[] = 'ug_group IS NULL';
    }
    // hook by Wikia, Bartek Lapinski 26.03.2009, for videos and stuff
    wfRunHooks('SpecialNewImages::beforeQuery', array(&$where));
    if (count($where)) {
        $sql .= ' WHERE ' . $dbr->makeList($where, LIST_AND);
    }
    $sql .= ' ORDER BY img_timestamp ' . ($invertSort ? '' : ' DESC');
    $sql .= ' LIMIT ' . ($limit + 1);
    $res = $dbr->query($sql, __FUNCTION__);
    /**
     * We have to flip things around to get the last N after a certain date
     */
    $images = array();
    while ($s = $dbr->fetchObject($res)) {
        if ($invertSort) {
            array_unshift($images, $s);
        } else {
            array_push($images, $s);
        }
    }
    $dbr->freeResult($res);
    $gallery = new WikiaPhotoGallery();
    $gallery->parseParams(array("rowdivider" => true, "hideoverflow" => true));
    //FB#1150 - make the images fit the whole horizontal space in Oasis and Oasis HD
    if (get_class($sk) == 'SkinOasis') {
        if ($wgOasisHD) {
            $gallery->setWidths(202);
        } else {
            $gallery->setWidths(212);
        }
    }
    $firstTimestamp = null;
    $lastTimestamp = null;
    $shownImages = 0;
    foreach ($images as $s) {
        $shownImages++;
        if ($shownImages > $limit) {
            # One extra just to test for whether to show a page link;
            # don't actually show it.
            break;
        }
        $name = $s->img_name;
        $ut = $s->img_user_text;
        $nt = Title::newFromText($name, NS_FILE);
        $ul = $sk->link(Title::makeTitle(NS_USER, $ut), $ut, array('class' => 'wikia-gallery-item-user'));
        $timeago = wfTimeFormatAgo($s->img_timestamp);
        $links = getLinkedFiles($s);
        // If there are more than two files, remove the 2nd and link to the
        // image page
        if (count($links) == 2) {
            array_splice($links, 1);
            $moreFiles = true;
        } else {
            $moreFiles = false;
        }
        $caption = wfMsgHtml('wikianewfiles-uploadby', $ul) . "<br />\n" . "<i>{$timeago}</i><br />\n";
        if (count($links)) {
            $caption .= wfMsg('wikianewfiles-postedin') . "&nbsp;" . $links[0];
        }
        if ($moreFiles) {
            $caption .= ", " . '<a href="' . $nt->getLocalUrl() . '#filelinks" class="wikia-gallery-item-more">' . wfMsgHtml('wikianewfiles-more') . '</a>';
        }
        $gallery->add($nt, $caption);
        $timestamp = wfTimestamp(TS_MW, $s->img_timestamp);
        if (empty($firstTimestamp)) {
            $firstTimestamp = $timestamp;
        }
        $lastTimestamp = $timestamp;
    }
    wfRunHooks('SpecialNewImages::beforeDisplay', array(&$images, &$gallery, &$limit));
    $titleObj = SpecialPage::getTitleFor('Newimages');
    $action = $titleObj->getLocalURL($hidebots ? '' : 'hidebots=0');
    if ($shownav && !$wgMiserMode) {
        $wgOut->addHTML(Xml::openElement('form', array('action' => $action, 'method' => 'post', 'id' => 'imagesearch')) . Xml::fieldset(wfMsg('newimages-legend')) . Xml::inputLabel(wfMsg('newimages-label'), 'wpIlMatch', 'wpIlMatch', 20, $wpIlMatch) . ' ' . Xml::submitButton(wfMsg('ilsubmit'), array('name' => 'wpIlSubmit')) . Xml::closeElement('fieldset') . Xml::closeElement('form'));
    }
    /**
     * Paging controls...
     */
    # If we change bot visibility, this needs to be carried along.
    if (!$hidebots) {
        $botpar = '&hidebots=0';
    } else {
        $botpar = '';
    }
    $now = wfTimestampNow();
    $d = $wgLang->date($now, true);
    $t = $wgLang->time($now, true);
    $dateLink = $sk->link($titleObj, wfMsgHtml('sp-newimages-showfrom', $d, $t), array('class' => 'navigation-filesfrom'), 'from=' . $now . $botpar . $searchpar);
    $botLink = $sk->link($titleObj, wfMsgHtml('showhidebots', $hidebots ? wfMsgHtml('show') : wfMsgHtml('hide')), array('class' => 'navigation-' . ($hidebots ? 'showbots' : 'hidebots')), 'hidebots=' . ($hidebots ? '0' : '1') . $searchpar);
    $opts = array('parsemag', 'escapenoentities');
    $prevLink = wfMsgExt('pager-newer-n', $opts, $wgLang->formatNum($limit));
    if ($firstTimestamp && $firstTimestamp != $latestTimestamp) {
        $wmu['prev'] = $firstTimestamp;
        $prevLink = $sk->link($titleObj, $prevLink, array('class' => 'navigation-newer'), 'from=' . $firstTimestamp . $botpar . $searchpar);
    }
    $nextLink = wfMsgExt('pager-older-n', $opts, $wgLang->formatNum($limit));
    if ($shownImages > $limit && $lastTimestamp) {
        $wmu['next'] = $lastTimestamp;
        $nextLink = $sk->link($titleObj, $nextLink, array('class' => 'navigation-older'), 'until=' . $lastTimestamp . $botpar . $searchpar);
    }
    $prevnext = '<p id="newfiles-nav">' . $botLink . ' ' . wfMsgHtml('viewprevnext', $prevLink, $nextLink, $dateLink) . '</p>';
    if (count($images)) {
        $wmu['gallery'] = $gallery;
        $wgOut->addHTML($gallery->toHTML());
        if ($shownav) {
            $wgOut->addHTML($prevnext);
        }
    } else {
        $wgOut->addWikiMsg('noimages');
    }
}
コード例 #14
0
 public function widget()
 {
     global $wgBlankImgUrl;
     $this->response->addAsset('extensions/wikia/FounderProgressBar/css/FounderProgressBar.scss');
     $this->response->addAsset('extensions/wikia/FounderProgressBar/js/modernizr.custom.founder.js');
     $this->response->addAsset('extensions/wikia/FounderProgressBar/js/FounderProgressBar.js');
     $this->response->setVal("wgBlankImgUrl", $wgBlankImgUrl);
     $activityFull = F::app()->sendRequest('FounderProgressBar', 'getLongTaskList', array())->getData();
     $activityListPreview = F::app()->sendRequest('FounderProgressBar', 'getShortTaskList', array('list' => $activityFull))->getData();
     $showCompletionMessage = false;
     $activeTaskList = array();
     $skippedTaskList = array();
     $bonusTaskList = array();
     foreach ($activityFull['list'] as $activity) {
         if (!empty($activity['task_skipped'])) {
             $activity['task_skippable'] = 0;
             $skippedTaskList[] = $activity;
         } else {
             if (in_array($activity['task_id'], $this->bonus_tasks)) {
                 // bonus task list is built in the next step
             } else {
                 if ($activity['task_id'] == self::$tasks['FT_COMPLETION']) {
                     $showCompletionMessage = !$activity['task_skipped'];
                 } else {
                     $activity['task_skippable'] = 1;
                     $activeTaskList[] = $activity;
                 }
             }
         }
     }
     // Bonus tasks don't exist in the DB until they are opened up.  display them but default to "locked" status
     // If they exist in the task list from the DB, they are by definition unlocked (skipTask contains that biz logic)
     foreach ($this->bonus_tasks as $task_id) {
         $bonusTask = array("task_id" => $task_id, "task_label" => $this->getMsgForTask($task_id, "label"), "task_description" => $this->getMsgForTask($task_id, "description"), "task_action" => $this->getMsgForTask($task_id, "action"), "task_url" => $this->getURLForTask($task_id));
         // Task is opened up
         if (isset($activityFull['list'][$task_id])) {
             $bonusTask["task_count"] = $activityFull['list'][$task_id]["task_count"];
             $bonusTask["task_completed"] = $activityFull['list'][$task_id]["task_completed"];
             if (!is_int($activityFull['list'][$task_id]["task_timestamp"])) {
                 $activityFull['list'][$task_id]["task_timestamp"] = strtotime($activityFull['list'][$task_id]["task_timestamp"]);
             }
             $bonusTask["task_timestamp"] = wfTimeFormatAgo($activityFull['list'][$task_id]["task_timestamp"]);
             $bonusTask["task_locked"] = 0;
         } else {
             $bonusTask["task_completed"] = 0;
             $bonusTask["task_locked"] = 1;
         }
         $bonusTask["task_skippable"] = 0;
         $bonusTask["task_is_bonus"] = 1;
         $bonusTaskList[] = $bonusTask;
     }
     $this->response->setVal('progressData', $activityListPreview['data']);
     $this->response->setVal('activityListPreview', $activityListPreview['list']);
     $this->response->setVal('activeTaskList', $activeTaskList);
     $this->response->setVal('skippedTaskList', $skippedTaskList);
     $this->response->setVal('bonusTaskList', $bonusTaskList);
     $this->response->setVal('clickEvents', $this->click_events);
     $this->response->setVal('showCompletionMessage', $showCompletionMessage);
 }
コード例 #15
0
 /**
  * @author Jakub Kurcek
  * @param format string 'rss' or 'atom'
  */
 private function FeedRecentBadges($format)
 {
     global $wgUser, $wgOut, $wgExtensionsPath, $wgServer, $wgEnableAchievementsExt;
     if (empty($wgEnableAchievementsExt)) {
         $this->showMenu();
     } else {
         // local settings
         $howOld = 30;
         $maxBadgesToDisplay = 6;
         $badgeImageSize = 56;
         $userNameLength = 22;
         $badgeNameLength = 29;
         $rankingService = new AchRankingService();
         // ignore welcome badges
         $blackList = array(BADGE_WELCOME);
         $awardedBadges = $rankingService->getRecentAwardedBadges(null, $maxBadgesToDisplay, $howOld, $blackList);
         $recents = array();
         $count = 1;
         $feedArray = array();
         // getRecentAwardedBadges can sometimes return more than $max items
         foreach ($awardedBadges as $badgeData) {
             $recents[] = $badgeData;
             $descriptionText = $badgeData['badge']->getName() . $badgeData['badge']->getGiveFor();
             $descriptionText = preg_replace('/<br\\s*\\/*>/i', "\$1 \$2", $descriptionText);
             $descriptionText = strip_tags($descriptionText);
             $imgURL = $badgeData['badge']->getPictureUrl($badgeImageSize);
             if (strpos($imgURL, 'http') === false) {
                 $imgURL = sprintf("%s/%s", $wgServer, $imgURL);
             }
             $feedArray[] = array('title' => $badgeData['user']->getName(), 'description' => $descriptionText, 'url' => $badgeData['user']->getUserPage()->getFullURL(), 'date' => $badgeData['date'], 'author' => '', 'otherTags' => array('image' => $imgURL, 'earnedby' => $badgeData['user']->getName(), 'nicedate' => wfTimeFormatAgo($badgeData['date'])));
             if ($count++ >= $maxBadgesToDisplay) {
                 break;
             }
         }
         $this->showFeed($format, wfMsg('feed-title-recent-badges'), $feedArray);
     }
 }