Example #1
0
 /**
  * @param Array $extraParams: array of extra parameters to give to the image
  * @return String: <img> HTML tag with full path to the avatar image
  * */
 function getAvatarHtml($extraParams = array())
 {
     global $wgUploadPath;
     $site_prefix = $this->user_id;
     $name = HuijiPrefix::prefixToSiteName($site_prefix);
     $defaultParams = array('src' => "{$wgUploadPath}/avatars/{$this->getAvatarImage()}", 'alt' => 'avatar', 'border' => '0', 'class' => 'siteimg', 'data-name' => $name);
     $params = array_merge($extraParams, $defaultParams);
     return Html::element('img', $params, '');
 }
 public function execute($par)
 {
     global $wgCookieDomain;
     $prefix = HuijiPrefix::getRandomPrefix();
     if (is_null($prefix)) {
         $this->setHeader();
         $this->getOutput()->addWikiMsg(strtolower($this->getName()) . '-nopages');
         return;
     }
     $this->getOutput()->redirect('http://' . $prefix . '.huiji.wiki');
 }
Example #3
0
 /**
  * get all site prefix 
  * @param  boolean $showHidden if false, just show the usual prefix,otherwise show all prefix(include the site be hidden)
  * @return array
  */
 public function getSitePrefixes($showHidden = false)
 {
     if ($showHidden) {
         if ($this->mAllPrefixes == '') {
             $this->mAllPrefixes = HuijiPrefix::getAllPrefixes($showHidden);
         }
         return $this->mAllPrefixes;
     } else {
         if ($this->mNonHiddenPrefixes == '') {
             $this->mNonHiddenPrefixes = HuijiPrefix::getAllPrefixes($showHidden);
         }
         return $this->mNonHiddenPrefixes;
     }
 }
Example #4
0
 /**
  * Show the special page
  *
  * @param $params Mixed: parameter(s) passed to the page or null
  */
 public function execute($params)
 {
     global $wgUser, $wgSitename, $wgHuijiPrefix, $wgUserLevels;
     $out = $this->getOutput();
     $this->setHeaders();
     $out->addHtml(TopUsersPoints::getRankingDropdown('站点排行榜'));
     $output = '<i>' . $this->msg('editranknote')->plain() . '</i>';
     // Add CSS
     $out->addModuleStyles('ext.socialprofile.userstats.css');
     $yesterday = date('Y-m-d', strtotime('-1 days'));
     $beforeyesterday = date('Y-m-d', strtotime('-2 days'));
     $allSiteRank = AllSitesInfo::getAllSitesRankData('', $yesterday);
     $beforeallSiteRank = AllSitesInfo::getAllSitesRankData('', $beforeyesterday);
     $beforeArr = array();
     foreach ($beforeallSiteRank as $value) {
         $beforeArr[$value['site_prefix']] = $value['site_rank'];
     }
     $output .= '<div class="top-users">';
     $total = count($allSiteRank);
     if ($total > 50) {
         $allSiteRank = array_slice($allSiteRank, 0, 50);
     } elseif ($total == 0) {
         $output .= '<p>站点排行榜正在生成中...请刷新重试!</p>';
         $output .= '</div><div class="cleared"></div>';
         $out->addHTML($output);
         return;
     }
     foreach ($allSiteRank as $key => $value) {
         $diff = abs($value['site_rank'] - $beforeArr[$value['site_prefix']]);
         if ($diff == 0) {
             $diff = '';
         }
         if ($value['site_rank'] > $beforeArr[$value['site_prefix']]) {
             $change = 'glyphicon glyphicon-arrow-down red';
         } elseif ($value['site_rank'] < $beforeArr[$value['site_prefix']]) {
             $change = 'glyphicon glyphicon-arrow-up green';
         } else {
             $change = 'glyphicon glyphicon-minus';
         }
         $output .= "<div class=\"top-fan-row\">\r\n\t\t\t\t<span class=\"top-fan-num\">{$value['site_rank']}.</span>\r\n\t\t\t\t<span class=\"top-fan\"><a href='" . HuijiPrefix::prefixToUrl($value['site_prefix']) . "'>" . (new wSiteAvatar($value['site_prefix'], 's'))->getAvatarHtml() . HuijiPrefix::prefixToSiteName($value['site_prefix']) . "</a><i class= \"" . $change . " hidden-sm hidden-xs\">" . $diff . "</i><i class=\"fa fa-flag-checkered hidden-sm hidden-xs\">" . $value['best_rank'] . "</i></span><span class=\"top-fan-points\">" . $value['site_score'] . '马赫</sp>';
         $output .= '<div class="cleared"></div>';
         $output .= '</div>';
     }
     $output .= '</div><div class="cleared"></div>';
     $out->addHTML($output);
 }
 /**
  * Function to render the {{#siteavatar:Prefix}} function
  *
  * @param Parser $parser: MW parser object
  * @param string $username: Username of user to show avatar for
  * @param string $size: Size of avatar to return (s/m/ml/l), or px value (100px, 10px, etc)
  * @return array: output of function, and options for the parser
  */
 static function renderSiteAvatarParserFunction($parser, $prefix = '', $givenSize = 'm')
 {
     global $wgUploadPath;
     $sizes = array('s', 'm', 'ml', 'l');
     if (in_array($givenSize, $sizes)) {
         // if given size is a code,
         $size = $givenSize;
         // use code,
         $px = '';
         // and leave px value empty
     } elseif (substr($givenSize, -2) == 'px') {
         //given size is a value in px
         $givenPx = intval(substr($givenSize, 0, strlen($givenSize) - 2));
         //get int value of given px size
         if (!is_int($givenPx)) {
             // if px value is not int
             $size = 'm';
             // give default avatar
             $px = '';
             // with no px value
         }
         if ($givenPx <= 16) {
             // if given px value is smaller than small,
             $size = 's';
             // use the small avatar,
             $px = $givenSize;
             // and the given px value
         } elseif ($givenPx <= 30) {
             // if given px value is smaller than medium,
             $size = 'm';
             // use the medium avatar,
             $px = $givenSize;
             // and the given px value
         } elseif ($givenPx <= 50) {
             // if given px value is smaller than medium-large,
             $size = 'ml';
             // use the medium-large avatar,
             $px = $givenSize;
             // and the given px value
         } else {
             // if given px value is bigger then medium large,
             $size = 'l';
             // use the large avatar,
             $px = $givenSize;
             // and the given px value
         }
     } else {
         // size value is not code or px
         $size = 'm';
         // give default avatar
         $px = '';
         // with no px value
     }
     if (HuijiPrefix::hasPrefix($prefix)) {
         $id = $prefix;
         $avatar = new wSiteAvatar($id, $size);
     } else {
         // Fallback for the case where an invalid (nonexistent) user name
         // was supplied...
         $avatar = new wAvatar(-1, 'm');
         // not very nice, but -1 will get the default avatar
     }
     if ($px) {
         // if px value needed, set height to it
         $output = $avatar->getAvatarHtml(array('height' => $px));
     } else {
         // but if not needed, don't
         $output = $avatar->getAvatarHtml();
     }
     return array($output, 'noparse' => true, 'isHTML' => true);
 }
Example #6
0
    /**
     * Get common interests with the user you are watching
     *
     * @param $target_user_id:current user; $user_id:his id
     * @return array
     */
    function getCommonInterest($user_id, $target_user_id)
    {
        global $wgUser;
        $user_id = $this->user_id;
        $target_user_id = $wgUser->getId();
        $res = UserSiteFollow::getCommonInterest($user_id, $target_user_id);
        $us = new UserStatus($this->user);
        $gender = $us->getGender();
        if ($gender == 'male') {
            $genderIcon = '他';
        } elseif ($gender == 'female') {
            $genderIcon = '她';
        } else {
            $genderIcon = 'TA';
        }
        $output = '<div class="panel panel-default"><div class="user-section-heading panel-heading">
				<div class="user-section-title">我和' . $genderIcon . '的共同兴趣:
				</div>
				<div class="user-section-actions">
					<div class="action-right">
					</div>
					<div class="action-left">
					</div>
					<div class="cleared"></div>
				</div>
			</div>
			<div class="cleared"></div>
			<div class="common-interest-container panel-body">';
        if (!empty($res)) {
            foreach ($res as $value) {
                $Iname = HuijiPrefix::prefixToSiteName($value);
                $Iurl = HuijiPrefix::prefixToUrl($value);
                $output .= '<span class="label label-primary"><a href="' . $Iurl . '">' . $Iname . '&nbsp;</a></span>';
            }
        } else {
            $output .= '<p>&nbsp;您和' . $genderIcon . '还没有共同兴趣~</p>';
        }
        $output .= '</div></div>';
        return $output;
    }
 /**
  * Sort The User Followed Sites by edits
  *
  *
  * @param $followedByTargetUser: array, sites that are followed by the target user
  * @param $followedByCurrentUser: array, Sites that are followed by the current user (wgUser).
  *        defaut to null.
  * @return array
  */
 public static function sortFollowedSiteWithDetails($targetUser, $followedByTargetUser, $followedByCurrentUser = null, $limit = null)
 {
     $fs = array();
     if (!empty($followedByCurrentUser)) {
         foreach ($followedByCurrentUser as $value) {
             $fs[] = $value;
         }
     }
     $followed = array();
     foreach ($followedByTargetUser as $row) {
         $temp = array();
         $domain = $row;
         $siteName = HuijiPrefix::prefixToSiteName($domain);
         $temp['count'] = UserStats::getSiteEditsCount($targetUser, $domain);
         $temp['key'] = $domain;
         $temp['val'] = $siteName;
         if (in_array($domain, $fs)) {
             $is_follow = 'Y';
         } else {
             $is_follow = 'N';
         }
         $temp['is'] = $is_follow;
         $followed[] = $temp;
     }
     $count = array();
     foreach ($followed as $key => $value) {
         $count[$key] = $value['count'];
     }
     array_multisort($count, SORT_DESC, $followed);
     if (!empty($limit)) {
         $followed = array_slice($followed, 0, $limit);
     }
     return $followed;
 }
 /**
  * Get full list of followed sites from the
  * database and cache it.
  *
  * @param $user: vist user id;$target_user_id:visted id
  * @return array
  */
 public static function getFullFollowedSites($user_id, $target_user_id)
 {
     $dbr = wfGetDB(DB_SLAVE);
     $followed = array();
     $fs = array();
     $tuser = User::newFromId($target_user_id);
     $res = self::getUserFollowingSites($tuser);
     $user = User::newFromId($user_id);
     $s = self::getUserFollowingSites($user);
     foreach ($s as $value) {
         $fs[] = $value;
     }
     foreach ($res as $row) {
         $temp = array();
         $domain = $row;
         $siteName = HuijiPrefix::prefixToSiteName($domain);
         $temp['count'] = UserStats::getSiteEditsCount($tuser, $domain);
         $temp['key'] = $domain;
         $temp['val'] = $siteName;
         if (in_array($domain, $fs)) {
             $is_follow = 'Y';
         } else {
             $is_follow = 'N';
         }
         $temp['is'] = $is_follow;
         $followed[] = $temp;
     }
     foreach ($followed as $key => $value) {
         $count[$key] = $value['count'];
     }
     array_multisort($count, SORT_DESC, $followed);
     return $followed;
 }
 /**
  * @param $type String: activity type, such as 'friend' or 'foe' or 'edit'
  * @param $has_page Boolean: true by default
  */
 function simplifyPageActivity($type, $has_page = true)
 {
     global $wgLang, $wgMemc;
     if (!isset($this->items_grouped[$type]) || !is_array($this->items_grouped[$type])) {
         return '';
     }
     foreach ($this->items_grouped[$type] as $page_name => $page_data) {
         $timeago = HuijiFunctions::getTimeAgo($page_data['timestamp']) . '前';
         $key = wfForeignMemcKey('huiji', '', 'simplifyPageActivity', $type, $page_name, $page_data['timestamp'], count($page_data['users']), $this->show_following_sites);
         if (isset($this->displayed[$type][$page_name])) {
             continue;
         }
         $users = '';
         $pages = '';
         if ($type == 'friend' || $type == 'foe' || $type == 'user_message' || $type == 'user_user_follow') {
             $page_title = Title::newFromText($page_name, NS_USER);
         } elseif ($type == 'user_site_follow') {
             $page_title = Title::newFromText($page_name . ':');
         } elseif ($type == 'image_upload') {
             $page_title = Title::newFromText($page_name, NS_FILE);
         } else {
             $page_title = Title::newFromText($page_name);
         }
         $count_users = count($page_data['users']);
         $user_index = 0;
         $pages_count = 0;
         // Init empty variable to be used later on for GENDER processing
         // if the event is only for one user.
         $userNameForGender = '';
         foreach ($page_data['users'] as $user_name => $action) {
             /* get rid of same actions more than 1/2 day ago */
             // if ( $page_data['timestamp'] < $this->half_day_ago ) {
             // 	continue;
             // }
             $count_actions = count($action);
             if ($has_page && !isset($this->displayed[$type][$page_name])) {
                 $this->displayed[$type][$page_name] = 1;
                 $pages .= $this->fixPageTitle($page_title, $page_data);
                 /* get User Avatar for display */
                 if ($this->show_following_sites) {
                     $avatar = new wSiteAvatar($page_data['prefix'][0], 'ml');
                 } else {
                     $avatar = new wAvatar(User::idFromName($user_name), 'ml');
                 }
                 $avatarUrl = $avatar->getAvatarHtml();
                 if ($count_users == 1 && $count_actions > 1) {
                     $pages .= wfMessage('word-separator')->text();
                     $pages .= wfMessage('parentheses', wfMessage("useractivity-group-{$type}", $count_actions, $user_name)->text())->text();
                 }
                 $pages_count++;
             }
             // Single user on this action,
             // see if we can stack any other singles
             if ($count_users == 1) {
                 $userNameForGender = $user_name;
                 foreach ($this->items_grouped[$type] as $page_name2 => $page_data2) {
                     // if we find singles for this type, not displayed and not co-worked.
                     if (!isset($this->displayed[$type][$page_name2]) && count($page_data2['users']) == 1) {
                         //change since sept.7: only group pages with same prefix.
                         if (isset($page_data['prefix']) && $page_data['prefix'][0] != $page_data2['prefix'][0]) {
                             continue;
                         }
                         // don't stack the old ones.
                         /* get rid of same actions more than 1/2 day ago */
                         if ($page_data2['timestamp'] < $page_data['timestamp'] - $this->half_a_day || $page_data2['timestamp'] > $page_data['timestamp']) {
                             continue;
                         }
                         foreach ($page_data2['users'] as $user_name2 => $action2) {
                             if ($user_name2 == $user_name && $pages_count < $this->item_max) {
                                 $count_actions2 = count($action2);
                                 if ($type == 'friend' || $type == 'foe' || $type == 'user_message' || $type == 'user_user_follow') {
                                     $page_title2 = Title::newFromText($page_name2, NS_USER);
                                 } elseif ($type == 'user_site_follow') {
                                     $page_title2 = Title::newFromText($page_name2 . ':');
                                 } elseif ($type == 'image_upload') {
                                     $page_title2 = Title::newFromText($page_name2, NS_FILE);
                                 } else {
                                     $page_title2 = Title::newFromText($page_name2);
                                 }
                                 if ($pages) {
                                     $pages .= $page_title2->inNamespace(NS_FILE) ? '' : ',';
                                 }
                                 $pages .= $this->fixPageTitle($page_title2, $page_data2);
                                 if ($count_actions2 > 1) {
                                     $pages .= ' (' . wfMessage("useractivity-group-{$type}", $count_actions2)->text() . ')';
                                 }
                                 $pages_count++;
                                 // if (isset($page_data['prefix'])){
                                 // 	$page_data['prefix'] = array_merge($page_data['prefix'], $page_data2['prefix']);
                                 // }
                                 $this->displayed[$type][$page_name2] = 1;
                             }
                         }
                     }
                 }
             }
             $user_index++;
             if ($users && $count_users > 2) {
                 $users .= wfMessage('comma-separator')->text();
             }
             if ($user_index == $count_users && $count_users > 1) {
                 $users .= wfMessage('and')->text();
             }
             $user_title = Title::makeTitle(NS_USER, $user_name);
             $user_name_short = $wgLang->truncate($user_name, 15);
             $safeTitle = htmlspecialchars($user_title->getText());
             $users .= ' <b><a href="' . htmlspecialchars($user_title->getFullURL()) . "\" title=\"{$safeTitle}\">{$user_name_short}</a></b>";
         }
         /* memcache checking */
         $html = $wgMemc->get($key);
         if ($html != '') {
             $html = $this->updateTime($html, $timeago);
             $this->activityLines[] = array('type' => $type, 'timestamp' => $page_data['timestamp'], 'data' => $html);
             continue;
         }
         if ($pages || $has_page == false) {
             $prefixToName = '';
             if (isset($page_data['prefix'])) {
                 if (is_array($page_data['prefix'])) {
                     $page_data['prefix'] = array_unique($page_data['prefix']);
                     $prefixCount = count($page_data['prefix']);
                     $i = 0;
                     foreach ($page_data['prefix'] as $prefix) {
                         $prefixToName .= HuijiPrefix::prefixToSiteNameAnchor($prefix);
                         $i++;
                         if ($i < $prefixCount - 1) {
                             $prefixToName .= wfMessage('comma-separator')->text();
                         }
                         if ($i == $prefixCount - 1 && $prefixCount > 1) {
                             $prefixToName .= wfMessage('and')->text();
                         }
                     }
                 } elseif (is_string($page_data['prefix'])) {
                     $prefixToName .= HuijiPrefix::prefixToSiteNameAnchor($prefix);
                 }
             }
             /* prepare format */
             /* build html */
             $html = $this->templateParser->processTemplate('user-home-item', array('userAvatar' => $avatarUrl, 'userName' => $this->show_following_sites ? $prefixToName : $users, 'timestamp' => $timeago, 'description' => wfMessage("useractivity-{$type}", $users, $count_users, $pages, $pages_count, $userNameForGender, $prefixToName)->text(), 'hasShowcase' => false));
             $wgMemc->set($key, $html);
             $this->activityLines[] = array('type' => $type, 'timestamp' => $page_data['timestamp'], 'data' => $html);
         }
     }
 }
 static function getAllPageCount()
 {
     global $isProduction, $wgLang;
     $allSite = HuijiPrefix::getAllPrefix();
     $pageCount = 0;
     foreach ($allSite as $prefix) {
         if ($isProduction == true && ($prefix == 'www' || $prefix == 'home')) {
             $prefix = 'huiji_home';
         } elseif ($isProduction == true) {
             $prefix = 'huiji_sites-' . str_replace('.', '_', $prefix);
         } else {
             $prefix = 'huiji_' . str_replace('.', '_', $prefix);
         }
         $dbr = wfGetDB(DB_SLAVE, $groups = array(), $wiki = $prefix);
         $res = $dbr->select('page', array('COUNT(page_id) AS count'), array('1'), __METHOD__);
         if ($res) {
             foreach ($res as $value) {
                 $pageCount = $pageCount + $value->count;
             }
         }
     }
     return $wgLang->formatNum($pageCount);
 }
Example #11
0
 static function showPage()
 {
     global $wgUser, $wgParser;
     $templateParser = new TemplateParser(__DIR__ . '/View');
     $output = '';
     // Prevent E_NOTICE
     //user login
     if ($wgUser->isLoggedIn()) {
         $login = true;
     } else {
         $login = false;
         $register = Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), '注册', array(), array('type' => 'signup'));
         $active = 'active';
         $inactive = 'in active';
     }
     // check mobile device
     $mobile = mobiledetect();
     $mobileUser = $mobile && $login;
     if (!$mobileUser) {
         //right data
         $fileCount = AllSitesInfo::getAllUploadFileCount();
         $siteCount = AllSitesInfo::getSiteCountNum();
         $userCount = AllSitesInfo::getUsreCountNum();
         $editCount = AllSitesInfo::getAllSiteEditCount();
         $pageCount = AllSitesInfo::getAllPageCount();
         $userName = $wgUser->getName();
         $usreId = $wgUser->getId();
         $avatar = new wAvatar($usreId, 'l');
         $userAvatar = $avatar->getAvatarURL();
         //level
         $stats = new UserStats($usreId, $userName);
         $stats_data = $stats->getUserStats();
         $user_level = new UserLevel($stats_data['points']);
         $level_link = Title::makeTitle(NS_HELP, wfMessage('user-profile-userlevels-link')->inContentLanguage()->text());
         $levelUrl = htmlspecialchars($level_link->getFullURL());
         $userLevel = $user_level->getLevelName();
         //user info
         $notice = SpecialPage::getTitleFor('ViewFollows');
         $contributions = SpecialPage::getTitleFor('Contributions');
         $userEdit = Linker::link($contributions, $stats_data['edits'], array(), array('target' => $userName, 'contribs' => 'user'));
         $follower = Linker::link($notice, UserUserFollow::getFollowingCount($wgUser), array('id' => 'user-following-count'), array('user' => $userName, 'rel_type' => 1));
         $followee = Linker::link($notice, UserUserFollow::getFollowerCount($wgUser), array('id' => 'user-follower-count'), array('user' => $userName, 'rel_type' => 2));
         //siterank
         $yesterday = date('Y-m-d', strtotime('-1 days'));
         $allSiteRank = AllSitesInfo::getAllSitesRankData('', $yesterday);
         $siteRank = array_slice($allSiteRank, 0, 10);
         $siteInfo = array();
         foreach ($siteRank as $key => $value) {
             $siteRank[$key]['site_prefix'] = HuijiPrefix::prefixToSiteName($value['site_prefix']);
             $siteRank[$key]['site_url'] = HuijiPrefix::prefixToUrl($value['site_prefix']);
             $siteInfo = AllSitesInfo::getPageInfoByPrefix($value['site_prefix']);
             $siteRank[$key]['totalEdits'] = $siteInfo['totalEdits'];
             $siteRank[$key]['totalArticles'] = $siteInfo['totalArticles'];
             $siteRank[$key]['totalPages'] = $siteInfo['totalPages'];
             $siteRank[$key]['totalUsers'] = $siteInfo['totalUsers'];
         }
         //userrank
         $weekRank = UserStats::getUserRank(10, 'week');
         $monthRank = UserStats::getUserRank(20, 'month');
         $totalRank = UserStats::getUserRank(20, 'total');
         //小蓝格
         $ueb = new UserEditBox();
         $editBox = $editData = array();
         $userEditInfo = $ueb->getUserEditInfo($usreId);
         $maxlen = $currentMaxlen = 0;
         //init variables.
         foreach ($userEditInfo as $value) {
             if (is_object($value) && !empty($value->_id) && $value->value > 0) {
                 $editBox[$value->_id] = $value->value;
                 $editData[] = $value->_id;
             }
         }
         $today = date("Y-m-d");
         $yesterday = date("Y-m-d", strtotime("-1 day"));
         $editBox[$today] = UserEditBox::getTodayEdit($usreId);
         if (!empty($editBox[$today])) {
             $editData[] = $today;
         }
         $totalEdit = count($editData);
         if ($totalEdit > 0) {
             $resArr[] = strtotime($editData[0]);
             $maxlen = 1;
         }
         for ($k = 1; $k < count($editData); $k++) {
             if (in_array(strtotime($editData[$k]) - 86400, $resArr)) {
                 $resArr[] = strtotime($editData[$k]);
                 if (count($resArr) > $maxlen) {
                     $maxlen = count($resArr);
                 }
             } else {
                 $resArr = array();
                 $resArr[] = strtotime($editData[$k]);
             }
             if ($resArr[count($resArr) - 1] == strtotime($today) || $resArr[count($resArr) - 1] == strtotime($yesterday)) {
                 $currentMaxlen = count($resArr);
             } else {
                 $currentMaxlen = 0;
             }
         }
         $lange = '<svg width="710" height="110" class=" ">
                  <g transform="translate(20, 20)">';
         $n = 676 / 13;
         $dateArr = array();
         for ($k = 0; $k < 365; $k++) {
             $dateArr[] = date('Y-m-d', strtotime("-{$k} day"));
         }
         $desdateArr = array_reverse($dateArr);
         $translate = array();
         for ($i = 0; $i <= $n; $i++) {
             $trani = $i * 13;
             $lange .= '<g transform="translate(' . $trani . ', 0)">';
             $dayofweek = date('w', strtotime($desdateArr[0]));
             if ($i == 0) {
                 $j = $dayofweek;
                 $start = 0;
                 $m = 7 - $dayofweek;
             } else {
                 $j = 0;
                 $m = 7;
                 $start = $i * 7 - $dayofweek;
             }
             $zoneDate = array_slice($desdateArr, $start, $m);
             foreach ($zoneDate as $val) {
                 $arrDate[$j] = $val;
                 $y = $j * 13;
                 $dataCount = isset($editBox[$val]) ? $editBox[$val] : 0;
                 if ($dataCount == 0) {
                     $color = '#eee';
                 } elseif ($dataCount > 0 && $dataCount <= 8) {
                     $color = '#86beee';
                 } elseif ($dataCount > 8 && $dataCount <= 21) {
                     $color = '#5ea2de';
                 } elseif ($dataCount > 21 && $dataCount <= 55) {
                     $color = '#256fb1';
                 } else {
                     $color = '#0d5493';
                 }
                 $lange .= '<rect class="day" width="11" height="11" y="' . $y . '" fill="' . $color . '" data-count="' . $dataCount . '" data-date="' . $val . '" title="' . $val . ' 编辑' . $dataCount . '次"></rect>';
                 $j = $j >= 7 ? 0 : $j + 1;
             }
             if (!empty($arrDate[0])) {
                 $translate[$arrDate[0]] = $trani;
             }
             $lange .= '</g>';
         }
         $moninit = 1;
         for ($p = 0; $p < 12; $p++) {
             $year = date('Y') - 1;
             $mon = date('m') + $p + 1;
             if ($mon > 12) {
                 $mon = $moninit++;
                 $year = date('Y');
             }
             $sunDay = UserEditBox::getSunday($mon, $year);
             $Stime = strtotime($sunDay);
             $sunDay = date('Y-m-d', $Stime);
             if (!isset($translate[$sunDay])) {
                 $Suntime = strtotime($sunDay);
                 $Sundate = date('Y', $Suntime) - 1;
                 $sunDay = UserEditBox::getSunday($mon, $Sundate);
             }
             foreach ($translate as $key => $value) {
                 if (strtotime($key) == strtotime($sunDay)) {
                     $x = $value;
                 }
             }
             $lange .= '<text x="' . $x . '" y="-5" class="' . $year . '">' . $mon . '月</text>';
         }
         $lange .= ' <text text-anchor="middle" class="wday" dx="-10" dy="9" style="display: none;">S</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="22">M</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="35" style="display: none;">T</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="48">W</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="61" style="display: none;">T</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="74">F</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="87" style="display: none;">S</text>
                </g>
              </svg>';
         //url helpManual huijitramac
         $helpManual = 'http://www.huiji.wiki/wiki/%E5%B8%AE%E5%8A%A9:%E7%BC%96%E8%BE%91%E6%89%8B%E5%86%8C';
         $tarmac = 'http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BAwiki:%E7%81%B0%E6%9C%BA%E5%81%9C%E6%9C%BA%E5%9D%AA';
         $contact = 'http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BAwiki:%E8%81%94%E7%B3%BB%E6%88%91%E4%BB%AC';
     }
     if ($login) {
         // follow
         $followUserCount = UserUserFollow::getFollowingCount($wgUser);
         if ($followUserCount >= 5) {
             $userHidden = true;
         } else {
             $userHidden = false;
         }
         $followSiteCount = UserSiteFollow::getFollowingCount($wgUser);
         if ($followSiteCount >= 5) {
             $siteHidden = true;
         } else {
             $siteHidden = false;
         }
         //recommend user $weekRank $monthRank  $totalRank
         $uuf = new UserUserFollow();
         if (count($weekRank) >= 8) {
             $recommend = UserStats::getUserRank(10, 'week');
         } elseif (count($monthRank) >= 8) {
             $recommend = UserStats::getUserRank(20, 'month');
         } else {
             $recommend = UserStats::getUserRank(20, 'total');
         }
         $recommendRes = array();
         $flres = array();
         foreach ($recommend as $value) {
             $tuser = User::newFromName($value['user_name']);
             $isFollow = $uuf->checkUserUserFollow($wgUser, $tuser);
             if (!$isFollow && $value['user_name'] != $userName) {
                 $flres['avatar'] = $value['avatarImage'];
                 $flres['username'] = $value['user_name'];
                 $flres['userurl'] = $value['user_url'];
                 $recommendRes[] = $flres;
             }
         }
         $recommendRes = array_slice($recommendRes, 0, 5);
         //recommend site
         $usf = new UserSiteFollow();
         // $recSite = array_slice($allSiteRank,0 ,5);
         $recommendSite = array();
         foreach ($allSiteRank as $value) {
             $isFollowSite = $usf->checkUserSiteFollow($wgUser, $value['site_prefix']);
             if ($isFollowSite == false) {
                 $fsres['s_name'] = HuijiPrefix::prefixToSiteName($value['site_prefix']);
                 $fsres['s_url'] = HuijiPrefix::prefixToUrl($value['site_prefix']);
                 $fsres['s_prefix'] = $value['site_prefix'];
                 $fsres['s_avatar'] = (new wSiteAvatar($value['site_prefix'], 'l'))->getAvatarHtml();
                 $recommendSite[] = $fsres;
             }
         }
         $recommendSite = array_slice($recommendSite, 0, 5);
         if ($login && !$mobile) {
             $infoHeader = wfMessage('info-header-user')->parseAsBlock();
         } elseif (!$login) {
             $infoHeader = wfMessage('info-header-anon')->parseAsBlock();
         } else {
             $infoHeader = '';
         }
     }
     $output .= $templateParser->processTemplate('frontpage', array('mobileUser' => $mobileUser, 'infoHeader' => $infoHeader, 'fileCount' => $fileCount, 'siteCount' => $siteCount, 'userCount' => $userCount, 'editCount' => $editCount, 'pageCount' => $pageCount, 'userName' => $userName, 'userAvatar' => $userAvatar, 'levelUrl' => $levelUrl, 'userLevel' => $userLevel, 'userEdit' => $userEdit, 'follower' => $follower, 'followee' => $followee, 'siteRank' => $siteRank, 'weekRank' => $weekRank, 'monthRank' => $monthRank, 'totalRank' => $totalRank, 'lange' => $lange, 'login' => $login, 'register' => $register, 'userHidden' => $userHidden, 'siteHidden' => $siteHidden, 'active' => $active, 'inactive' => $inactive, 'recommendSite' => $recommendSite, 'recContent' => $recContent, 'followUserCount' => $followUserCount, 'followSiteCount' => $followSiteCount, 'helpManual' => $helpManual, 'tarmac' => $tarmac, 'contact' => $contact));
     return $output;
 }
 /**
  * get site's name
  * @return string site's name
  */
 public function getName()
 {
     if ($this->mPrefix === '') {
         return '';
     }
     if ($this->mName != '') {
         return $this->mName;
     }
     // Trust HuijiPrefix Cache
     $this->mName = HuijiPrefix::prefixToSiteName($this->mPrefix);
     return $this->mName;
 }