コード例 #1
0
    /**
     * Displays the form for sending board blasts
     */
    function displayForm()
    {
        global $wgUser;
        $stats = new UserStats($wgUser->getID(), $wgUser->getName());
        $stats_data = $stats->getUserStats();
        $friendCount = $stats_data['friend_count'];
        $foeCount = $stats_data['foe_count'];
        $output = '<div class="board-blast-message-form">
				<h2>' . wfMsg('boardblaststep1') . '</h2>
				<form method="post" name="blast" action="">
					<input type="hidden" name="ids" id="ids" />
					<div class="blast-message-text">' . wfMsg('boardblastprivatenote') . '</div>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>
				</form>
		</div>
		<div class="blast-nav">
				<h2>' . wfMsg('boardblaststep2') . '</h2>
				<div class="blast-nav-links">
					<a href="javascript:void(0);" onclick="javascript:select_all()">' . wfMsg('boardlinkselectall') . '</a> -
					<a href="javascript:void(0);" onclick="javascript:unselect_all()">' . wfMsg('boardlinkunselectall') . '</a> ';
        if ($friendCount > 0 && $foeCount > 0) {
            $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_friends(1)">' . wfMsg('boardlinkselectfriends') . '</a> -';
            $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_friends(0)">' . wfMsg('boardlinkunselectfriends') . '</a>';
        }
        if ($foeCount > 0 && $friendCount > 0) {
            $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_foes(1)">' . wfMsg('boardlinkselectfoes') . '</a> -';
            $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_foes(0)">' . wfMsg('boardlinkunselectfoes') . '</a>';
        }
        $output .= '</div>
		</div>';
        $rel = new UserRelationship($wgUser->getName());
        $relationships = $rel->getRelationshipList();
        $output .= '<div id="blast-friends-list" class="blast-friends-list">';
        $x = 1;
        $per_row = 3;
        if (count($relationships) > 0) {
            foreach ($relationships as $relationship) {
                if ($relationship['type'] == 1) {
                    $class = 'friend';
                } else {
                    $class = 'foe';
                }
                $id = $relationship['user_id'];
                $output .= '<div class="blast-' . $class . "-unselected\" id=\"user-{$id}\" onclick=\"javascript:toggle_user({$id})\">\r\n\t\t\t\t\t\t{$relationship['user_name']}\r\n\t\t\t\t\t</div>";
                if ($x == count($relationships) || $x != 1 && $x % $per_row == 0) {
                    $output .= '<div class="cleared"></div>';
                }
                $x++;
            }
        } else {
            $output .= '<div>' . wfMsg('boardnofriends') . '</div>';
        }
        $output .= '</div>

			<div class="cleared"></div>';
        $output .= '<div class="blast-message-box-button">
			<input type="button" value="' . wfMsg('boardsendbutton') . '" class="site-button" onclick="javascript:send_messages();" />
		</div>';
        return $output;
    }
コード例 #2
0
    /**
     * Displays the form for sending board blasts
     */
    function displayForm()
    {
        $user = $this->getUser();
        $stats = new UserStats($user->getID(), $user->getName());
        $stats_data = $stats->getUserStats();
        $friendCount = $stats_data['friend_count'];
        $foeCount = $stats_data['foe_count'];
        $output = '<div class="board-blast-message-form">
				<h2>' . $this->msg('boardblaststep1')->escaped() . '</h2>
				<form method="post" name="blast" action="">
					<input type="hidden" name="ids" id="ids" />
					<div class="blast-message-text">' . $this->msg('boardblastprivatenote')->escaped() . '</div>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>
				</form>
		</div>
		<div class="blast-nav">
				<h2>' . $this->msg('boardblaststep2')->escaped() . '</h2>
				<div class="blast-nav-links">
					<a href="javascript:void(0);" class="blast-select-all-link">' . $this->msg('boardlinkselectall')->escaped() . '</a> -
					<a href="javascript:void(0);" class="blast-unselect-all-link">' . $this->msg('boardlinkunselectall')->escaped() . '</a> ';
        $output .= '</div>
		</div>';
        $uuf = new UserUserFollow();
        $follows = $uuf->getFollowList($user, 0);
        $output .= '<div id="blast-friends-list" class="blast-friends-list">';
        $x = 1;
        $per_row = 3;
        if (count($follows) > 0) {
            foreach ($follows as $follow) {
                if ($follow['type'] == 1) {
                    $class = 'friend';
                } else {
                    $class = 'foe';
                }
                $id = $follow['user_id'];
                $output .= '<div class="blast-' . $class . "-unselected\" id=\"user-{$id}\">\n\t\t\t\t\t\t{$follow['user_name']}\n\t\t\t\t\t</div>";
                if ($x == count($follows) || $x != 1 && $x % $per_row == 0) {
                    $output .= '<div class="cleared"></div>';
                }
                $x++;
            }
        } else {
            $output .= '<div>' . $this->msg('boardnofriends')->escaped() . '</div>';
        }
        $output .= '</div>

			<div class="cleared"></div>';
        $output .= '<div class="blast-message-box-button">
			<input type="button" value="' . $this->msg('boardsendbutton')->escaped() . '" class="site-button" />
		</div>';
        return $output;
    }
コード例 #3
0
ファイル: UserWelcome.php プロジェクト: Reasno/SocialProfile
function getWelcome()
{
    global $wgUser, $wgOut, $wgLang;
    // Add CSS
    $wgOut->addModuleStyles('ext.socialprofile.userwelcome.css');
    // Get stats and user level
    $stats = new UserStats($wgUser->getID(), $wgUser->getName());
    $stats_data = $stats->getUserStats();
    $user_level = new UserLevel($stats_data['points']);
    // Safe links
    $level_link = Title::makeTitle(NS_HELP, wfMessage('mp-userlevels-link')->inContentLanguage()->plain());
    $avatar_link = SpecialPage::getTitleFor('UploadAvatar');
    // Make an avatar
    $avatar = new wAvatar($wgUser->getID(), 'l');
    // Profile top images/points
    $output = '<div class="mp-welcome-logged-in">
	<h2>' . wfMessage('mp-welcome-logged-in', $wgUser->getName())->parse() . '</h2>
	<div class="mp-welcome-image">
	<a href="' . htmlspecialchars($wgUser->getUserPage()->getFullURL()) . '" rel="nofollow">' . $avatar->getAvatarURL() . '</a>';
    if (strpos($avatar->getAvatarImage(), 'default_') !== false) {
        $uploadOrEditMsg = 'mp-welcome-upload';
    } else {
        $uploadOrEditMsg = 'mp-welcome-edit';
    }
    $output .= '<div><a href="' . htmlspecialchars($avatar_link->getFullURL()) . '" rel="nofollow">' . wfMessage($uploadOrEditMsg)->plain() . '</a></div>';
    $output .= '</div>';
    global $wgUserLevels;
    if ($wgUserLevels) {
        $output .= '<div class="mp-welcome-points">
			<div class="points-and-level">
				<div class="total-points">' . wfMessage('mp-welcome-points', $wgLang->formatNum($stats_data['points']))->parse() . '</div>
				<div class="honorific-level"><a href="' . htmlspecialchars($level_link->getFullURL()) . '">(' . $user_level->getLevelName() . ')</a></div>
			</div>
			<div class="cleared"></div>
			<div class="needed-points">
				<br />' . wfMessage('mp-welcome-needed-points', htmlspecialchars($level_link->getFullURL()), $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance())->text() . '</div>
		</div>';
    }
    $output .= '<div class="cleared"></div>';
    $output .= getRequests();
    $output .= '</div>';
    return $output;
}
コード例 #4
0
function getWelcome()
{
    global $wgUser, $wgOut, $wgScriptPath, $wgUploadPath;
    // Add CSS
    $wgOut->addExtensionStyle($wgScriptPath . '/extensions/SocialProfile/UserWelcome/UserWelcome.css');
    // Get stats and user level
    $stats = new UserStats($wgUser->getID(), $wgUser->getName());
    $stats_data = $stats->getUserStats();
    $user_level = new UserLevel($stats_data['points']);
    // Safe links
    $level_link = Title::makeTitle(NS_HELP, wfMsgForContent('mp-userlevels-link'));
    $avatar_link = SpecialPage::getTitleFor('UploadAvatar');
    // Make an avatar
    $avatar = new wAvatar($wgUser->getID(), 'l');
    // Profile top images/points
    $output = '<div class="mp-welcome-logged-in">
	<h2>' . wfMsg('mp-welcome-logged-in', $wgUser->getName()) . '</h2>
	<div class="mp-welcome-image">
	<a href="' . $wgUser->getUserPage()->escapeFullURL() . '" rel="nofollow"><img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0"/></a>';
    if (strpos($avatar->getAvatarImage(), 'default_') !== false) {
        $output .= '<div><a href="' . $avatar_link->escapeFullURL() . '" rel="nofollow">' . wfMsg('mp-welcome-upload') . '</a></div>';
    } else {
        $output .= '<div><a href="' . $avatar_link->escapeFullURL() . '" rel="nofollow">' . wfMsg('mp-welcome-edit') . '</a></div>';
    }
    $output .= '</div>';
    global $wgUserLevels;
    if ($wgUserLevels) {
        $output .= '<div class="mp-welcome-points">
			<div class="points-and-level">
				<div class="total-points">' . wfMsgExt('mp-welcome-points', 'parsemag', $stats_data['points']) . '</div>
				<div class="honorific-level"><a href="' . $level_link->escapeFullURL() . '">(' . $user_level->getLevelName() . ')</a></div>
			</div>
			<div class="cleared"></div>
			<div class="needed-points">
				<br />' . wfMsgExt('mp-welcome-needed-points', 'parsemag', $level_link->escapeFullURL(), $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance()) . '</div>
		</div>';
    }
    $output .= '<div class="cleared"></div>';
    $output .= getRequests();
    $output .= '</div>';
    return $output;
}
コード例 #5
0
	function renderWelcomePage() {
		global $wgRequest, $wgUser, $wgOut, $wgHooks;

		// No access for blocked users
		if( $wgUser->isBlocked() ) {
			$wgOut->blockedPage( false );
			return false;
		}

		/**
		 * Create Quiz Thresholds based on User Stats
		 */
		global $wgCreateQuizThresholds;
		if( is_array( $wgCreateQuizThresholds ) && count( $wgCreateQuizThresholds ) > 0 ) {
			$can_create = true;

			$stats = new UserStats( $wgUser->getID(), $wgUser->getName() );
			$stats_data = $stats->getUserStats();

			$threshold_reason = '';
			foreach( $wgCreateQuizThresholds as $field => $threshold ) {
				if ( $stats_data[$field] < $threshold ) {
					$can_create = false;
					$threshold_reason .= ( ( $threshold_reason ) ? ', ' : '' ) . "$threshold $field";
				}
			}

			if( $can_create == false ) {
				global $wgSupressPageTitle;
				$wgSupressPageTitle = false;
				$wgOut->setPageTitle( wfMsg( 'quiz-create-threshold-title' ) );
				$wgOut->addHTML( wfMsg( 'quiz-create-threshold-reason', $threshold_reason ) );
				return '';
			}
		}

		$chain = time();
		$key = md5( $this->SALT . $chain );
		$max_answers = 8;

		// Add i18n messages (and max_answers) for the JS file
		$wgHooks['MakeGlobalVariablesScript'][] = 'QuizGameHome::addJSGlobalsForRenderWelcomePage';

		$wgOut->setPageTitle( wfMsg( 'quiz-create-title' ) );

		$output = '<div id="quiz-container" class="quiz-container">

			<div class="create-message">
				<h1>' . wfMsg( 'quiz-create-title' ) . '</h1>
				<p>' . wfMsgExt( 'quiz-create-message', 'parse' ) . '</p>
				<p><input class="site-button" type="button" onclick="document.location=\'' .
					$this->getTitle()->escapeFullURL( 'questionGameAction=launchGame' ) .
					'\'" value="' . wfMsg( 'quiz-play-quiz' ) . '" /></p>
			</div>

			<div class="quizgame-create-form" id="quizgame-create-form">
				<form id="quizGameCreate" name="quizGameCreate" method="post" action="' .
					$this->getTitle()->escapeFullURL( 'questionGameAction=createGame' ) . '">
				<div id="quiz-game-errors" style="color:red"></div>

				<h1>' . wfMsg( 'quiz-create-write-question' ) . '</h1>
				<input name="quizgame-question" id="quizgame-question" type="text" value="" size="64" />
				<h1 class="write-answer">' . wfMsg( 'quiz-create-write-answers' ) . '</h1>
				<span style="margin-top:10px;">' . wfMsg( 'quiz-create-check-correct' ) . '</span>';

		for( $x = 1; $x <= $max_answers; $x++ ) {
			$output .= "<div id=\"quizgame-answer-container-{$x}\" class=\"quizgame-answer\"" .
				( ( $x > 2 ) ? ' style="display:none;"' : '' ) . ">
				<span class=\"quizgame-answer-number\">{$x}.</span>
				<input name=\"quizgame-answer-{$x}\" id=\"quizgame-answer-{$x}\" type=\"text\" value=\"\" size=\"32\" onkeyup=\"QuizGame.updateAnswerBoxes();\" />
				<input type=\"checkbox\" onclick=\"javascript:QuizGame.welcomePage_toggleCheck(this)\" id=\"quizgame-isright-{$x}\" name=\"quizgame-isright-{$x}\">
			</div>";
		}

		$output .= '<input id="quizGamePictureName" name="quizGamePictureName" type="hidden" value="" />
				<input id="key" name="key" type="hidden" value="' . $key . '" />
				<input id="chain" name="chain" type="hidden" value="' . $chain . '" />

			</form>

			<h1 style="margin-top:20px">' .
				wfMsg( 'quiz-create-add-picture' ) . '</h1>
			<div id="quizgame-picture-upload" style="display:block;">

				<div id="real-form" style="display:block; height:90px;">
					<iframe id="imageUpload-frame" class="imageUpload-frame" width="650"
						scrolling="no" border="0" frameborder="0" src="' .
						SpecialPage::getTitleFor( 'QuestionGameUpload' )->escapeFullURL( 'wpThumbWidth=75&wpCategory=Quizgames' ) . '">
					</iframe>
				</div>
			</div>
			<div id="quizgame-picture-preview" class="quizgame-picture-preview"></div>
			<p id="quizgame-picture-reupload" style="display:none">
				<a href="javascript:QuizGame.showAttachPicture()">' .
					wfMsg( 'quiz-create-edit-picture' ) . '</a>
			</p>
			</div>

			<div id="startButton" class="startButton">
				<input type="button" class="site-button" onclick="QuizGame.startGame()" value="' . wfMsg( 'quiz-create-play' ) . '" />
			</div>

			</div>';

		$wgOut->addHTML( $output );
	}
コード例 #6
0
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgHooks, $wgUserBoardScripts;
        // This hooked function adds a global JS variable that UserBoard.js
        // uses to the HTML
        $wgHooks['MakeGlobalVariablesScript'][] = 'SpecialViewUserBoard::addJSGlobals';
        // Add CSS & JS
        $wgOut->addExtensionStyle($wgUserBoardScripts . '/UserBoard.css');
        $wgOut->addScriptFile($wgUserBoardScripts . '/UserBoard.js');
        $ub_messages_show = 25;
        $user_name = $wgRequest->getVal('user');
        $user_name_2 = $wgRequest->getVal('conv');
        $user_id_2 = '';
        // Prevent E_NOTICE
        $page = $wgRequest->getInt('page', 1);
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the UserBoard page
         */
        if ($wgUser->getID() == 0 && $user_name == '') {
            $login = SpecialPage::getTitleFor('Userlogin');
            $wgOut->redirect($login->getFullURL('returnto=Special:UserBoard'));
            return false;
        }
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $wgUser->getName();
        }
        $user_id = User::idFromName($user_name);
        $user = Title::makeTitle(NS_USER, $user_name);
        $user_safe = str_replace('&', '%26', $user_name);
        if ($user_name_2) {
            $user_id_2 = User::idFromName($user_name_2);
            $user_2 = Title::makeTitle(NS_USER, $user_name);
            $user_safe_2 = urlencode($user_name_2);
        }
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $wgOut->showErrorPage('error', 'userboard_noexist');
            return false;
        }
        /**
         * Config for the page
         */
        $per_page = $ub_messages_show;
        $b = new UserBoard();
        $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
        if (!$user_id_2) {
            $stats = new UserStats($user_id, $user_name);
            $stats_data = $stats->getUserStats();
            $total = $stats_data['user_board'];
            // If user is viewing their own board or is allowed to delete
            // others' board messages, show the total count of board messages
            // to them (public + private messages)
            if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
                $total = $total + $stats_data['user_board_priv'];
            }
        } else {
            $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
        }
        if (!$user_id_2) {
            if (!($wgUser->getName() == $user_name)) {
                $wgOut->setPageTitle(wfMsg('userboard_owner', $user_name));
            } else {
                $b->clearNewMessageCount($wgUser->getID());
                $wgOut->setPageTitle(wfMsg('userboard_yourboard'));
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $wgOut->setPageTitle(wfMsg('userboard_yourboardwith', $user_name_2));
            } else {
                $wgOut->setPageTitle(wfMsg('userboard_otherboardwith', $user_name, $user_name_2));
            }
        }
        $output = '<div class="user-board-top-links">';
        $output .= '<a href="' . $user->escapeFullURL() . '">&lt; ' . wfMsg('userboard_backprofile', $user_name) . '</a>';
        $output .= '</div>';
        $board_to_board = '';
        // Prevent E_NOTICE
        if ($page == 1) {
            $start = 1;
        } else {
            $start = ($page - 1) * $per_page + 1;
        }
        $end = $start + count($ub_messages) - 1;
        if ($wgUser->getName() != $user_name) {
            $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($wgUser->getName(), $user_name) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
        }
        if ($total) {
            $output .= '<div class="user-page-message-top">
			<span class="user-page-message-count">' . wfMsg('userboard_showingmessages', $total, $start, $end, $end - $start + 1) . "</span> {$board_to_board}\n\t\t\t</div>";
        }
        /**
         * Build next/prev nav
         */
        $qs = '';
        if ($user_id_2) {
            $qs = "&conv={$user_safe_2}";
        }
        $numofpages = $total / $per_page;
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page - 1) . "{$qs}\">" . wfMsg('userboard_prevpage') . '</a>';
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
                if ($numofpages >= $total / $per_page) {
                    $numofpages = $total / $per_page + 1;
                }
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page={$i}{$qs}\">{$i}</a> ";
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= ' <a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page + 1) . "{$qs}\">" . wfMsg('userboard_nextpage') . '</a>';
            }
            $output .= '</div><p>';
        }
        /**
         * Build next/prev nav
         */
        $can_post = false;
        $user_name_from = '';
        // Prevent E_NOTICE
        if (!$user_id_2) {
            if ($wgUser->getName() != $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name, ENT_QUOTES);
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name_2, ENT_QUOTES);
                $user_name_from = htmlspecialchars($user_name, ENT_QUOTES);
            }
        }
        if ($wgUser->isBlocked()) {
            // only let them post to admins
            //$user_to = User::newFromId( $user_id );
            // if( !$user_to->isAllowed( 'delete' ) ) {
            $can_post = false;
            // }
        }
        if ($can_post) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
					<input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
					<input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
					<span class="user-board-message-type">' . wfMsg('userboard_messagetype') . ' </span>
					<select id="message_type">
						<option value="0">' . wfMsg('userboard_public') . '</option>
						<option value="1">' . wfMsg('userboard_private') . '</option>
					</select>
					<p>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>

					<div class="user-page-message-box-button">
						<input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:UserBoard.sendMessage(' . $per_page . ');" />
					</div>

				</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMsg('userboard_loggedout', $login_link->escapeFullURL()) . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        if ($ub_messages) {
            foreach ($ub_messages as $ub_message) {
                $user = Title::makeTitle(NS_USER, $ub_message['user_name_from']);
                $avatar = new wAvatar($ub_message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $ub_message_type_label = '';
                $delete_link = '';
                if ($wgUser->getName() != $ub_message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from']) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_sendmessage', $ub_message['user_name_from']) . '</a>';
                } else {
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_myboard') . '</a>';
                }
                // If the user owns this private message or they are allowed to
                // delete board messages, show the "delete" link to them
                if ($wgUser->getName() == $ub_message['user_name'] || $wgUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" onclick=\"javascript:UserBoard.deleteMessage({$ub_message['id']})\">" . wfMsg('userboard_delete') . '</a>
					</span>';
                }
                // Mark private messages as such
                if ($ub_message['type'] == 1) {
                    $ub_message_type_label = '(' . wfMsg('userboard_private') . ')';
                }
                // had global function to cut link text if too long and no breaks
                // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
                $ub_message_text = $ub_message['message_text'];
                $output .= "<div class=\"user-board-message\">\n\t\t\t\t\t<div class=\"user-board-message-from\">\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"user-board-message-time\">" . wfMsgHtml('userboard_posted_ago', $b->getTimeAgo($ub_message['timestamp'])) . "</div>\n\t\t\t\t\t<div class=\"user-board-message-content\">\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\n\t\t\t\t\t\t\t{$ub_message_text}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"cleared\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"user-board-message-links\">\n\t\t\t\t\t\t{$board_link}\n\t\t\t\t\t\t{$board_to_board}\n\t\t\t\t\t\t{$delete_link}\n\t\t\t\t\t</div>\n\t\t\t\t</div>";
            }
        } else {
            $invite_title = SpecialPage::getTitleFor('InviteContacts');
            $output .= '<p>' . wfMsg('userboard_nomessages', $invite_title->escapeFullURL()) . '</p>';
        }
        $output .= '</div>';
        $wgOut->addHTML($output);
    }
コード例 #7
0
 /**
  * get site followers
  * @param  boolean $expanded if true return user detail info,eles return simple info
  * @return array
  */
 public function getFollowers($expanded = false)
 {
     if (!$this->mFollowers) {
         // return $this->mFollowers;
         $usf = new UserSiteFollow();
         $this->mFollowers = $usf->getSiteFollowers($this->mPrefix);
         $siteCache = self::getSiteCache();
         $siteCache->set($this->mPrefix, $this);
         //return $this->mFollowers;
     }
     if (!$expanded) {
         return $this->mFollowers;
     } else {
         $request = array();
         foreach ($this->mFollowers as $value) {
             $u_name = $value['user_name'];
             $temp['user'] = $u_name;
             // $temp['user'] = User::getEffectiveGroups($user);
             $userPage = Title::makeTitle(NS_USER, $u_name);
             $userPageURL = htmlspecialchars($userPage->getFullURL());
             $temp['userUrl'] = $userPageURL;
             $user_id = User::idFromName($u_name);
             $temp['userId'] = $user_id;
             $stats = new UserStats($user_id, $u_name);
             $stats_data = $stats->getUserStats();
             $user_level = new UserLevel($stats_data['points']);
             $temp['level'] = $user_level->getLevelName();
             $avatar = new wAvatar($user_id, 'm');
             $temp['url'] = $avatar->getAvatarURL();
             $tuser = User::newFromName($u_name);
             $temp['count'] = UserStats::getSiteEditsCount($tuser, $this->mPrefix);
             // if(in_array($u_name, $follower)){
             // 	$is_follow = 'Y';
             // }else{
             // 	$is_follow = 'N';
             // }
             // $temp['is_follow'] = $is_follow;
             $request[] = $temp;
         }
         foreach ($request as $key => $value) {
             $count[$key] = $value['count'];
         }
         array_multisort($count, SORT_DESC, $request);
         return $request;
     }
 }
コード例 #8
0
	/**
	 * Shows the initial page that prompts the image upload.
	 */
	function showHomePage() {
		global $wgRequest, $wgUser, $wgOut, $wgScriptPath;

		// You need to be logged in to create a new picture game (because
		// usually only registered users can upload files)
		if( !$wgUser->isLoggedIn() ) {
			$wgOut->setPageTitle( wfMsg( 'picturegame-creategametitle' ) );
			$output = wfMsg( 'picturegame-creategamenotloggedin' );
			$output .= "<p>
				<input type=\"button\" class=\"site-button\" onclick=\"window.location='" .
					SpecialPage::getTitleFor( 'Userlogin', 'signup' )->escapeFullURL() .
					"'\" value=\"" . wfMsg( 'picturegame-signup' ) . "\" />
				<input type=\"button\" class=\"site-button\" onclick=\"window.location='" .
					SpecialPage::getTitleFor( 'Userlogin' )->escapeFullURL() .
					"'\" value=\"" . wfMsg( 'picturegame-login' ) . "\" />
			</p>";
			$wgOut->addHTML( $output );
			return;
		}

		/**
		 * Create Picture Game Thresholds based on User Stats
		 */
		global $wgCreatePictureGameThresholds;
		if( is_array( $wgCreatePictureGameThresholds ) && count( $wgCreatePictureGameThresholds ) > 0 ) {
			$can_create = true;

			$stats = new UserStats( $wgUser->getID(), $wgUser->getName() );
			$stats_data = $stats->getUserStats();

			$threshold_reason = '';
			foreach( $wgCreatePictureGameThresholds as $field => $threshold ) {
				if ( str_replace( ',', '', $stats_data[$field] ) < $threshold ) {
					$can_create = false;
					$threshold_reason .= ( ( $threshold_reason ) ? ', ' : '' ) . "$threshold $field";
				}
			}

			if( $can_create == false ) {
				global $wgSupressPageTitle;
				$wgSupressPageTitle = false;
				$wgOut->setPageTitle( wfMsg( 'picturegame-create-threshold-title' ) );
				$wgOut->addHTML( wfMsg( 'picturegame-create-threshold-reason', $threshold_reason ) );
				return '';
			}
		}

		// Show a link to the admin panel for picture game admins
		if( $wgUser->isAllowed( 'picturegameadmin' ) ) {
			$adminlink = '<a href="' . $this->getTitle()->escapeFullURL( 'picGameAction=adminPanel' ) . '"> ' .
				wfMsg( 'picturegame-adminpanel' ) . ' </a>';
		}

		$dbr = wfGetDB( DB_MASTER );

		$excludedIds = $dbr->select(
			'picturegame_votes',
			'picid',
			array( 'username' => $wgUser->getName() ),
			__METHOD__
		);

		$excluded = array();
		foreach ( $excludedIds as $excludedId ) {
			$excluded[] = $excludedId->picid;
		}

		$canSkip = false;
		if ( !empty( $excluded ) ) {
			$myCount = (int)$dbr->selectField(
				'picturegame_images',
				'COUNT(*) AS mycount',
				array(
					'id NOT IN(' . implode( ',', $excluded  ) . ')',
					'flag != ' . PICTUREGAME_FLAG_FLAGGED,
					"img1 <> ''",
					"img2 <> ''"
				),
				__METHOD__
			);
			if ( $myCount > 0 ) {
				$canSkip = true;
			}
		}
		/*$sql = "SELECT COUNT(*) AS mycount FROM picturegame_images WHERE picturegame_images.id NOT IN
				(SELECT picid FROM picturegame_votes WHERE picturegame_votes.username='******')
			AND flag != " . PICTUREGAME_FLAG_FLAGGED . " AND img1 <> '' AND img2 <> '' LIMIT 1;";
		$res = $dbr->query( $sql, __METHOD__ );
		$row = $dbr->fetchObject( $res );

		$canSkip = ( $row->mycount != 0 ? true : false );*/

		// used for the key
		$now = time();

		$wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'picturegame-creategametitle' ) ) );

		$wgOut->addExtensionStyle( $wgScriptPath . '/extensions/PictureGame/picturegame/startgame.css' );
		// Anonymous functions are fun :) Too bad for you, PHP <= 5.2.x users!
		// @see http://php.net/manual/en/functions.anonymous.php
		global $wgHooks;
		$wgHooks['MakeGlobalVariablesScript'][] = function( $vars ) {
			// for the upload form (see PictureGame.js, the uploadComplete
			// functions)
			$vars['__picturegame_edit__'] = wfMsg( 'picturegame-js-edit' );
			return true;
		};

		$output = "\t\t" . '<div class="pick-game-welcome-message">
			<h1>' . wfMsg( 'picturegame-creategametitle' ) . '</h1>';
		$output .= wfMsg( 'picturegame-creategamewelcome' );
		$output .= '<br />

			<div id="skipButton" class="startButton">';
		$play_button_text = wfMsg( 'picturegame-creategameplayinstead' );
		$skipButton = '';
		if ( $canSkip ) {
			$skipButton = "<input class=\"site-button\" type=\"button\" onclick=\"javascript:PictureGame.skipToGame()\" value=\"{$play_button_text}\"/>";
		}
		$output .= $skipButton .
				'</div>
			</div>

			<div class="uploadLeft">
				<div id="uploadTitle" class="uploadTitle">
					<form id="picGamePlay" name="picGamePlay" method="post" action="' .
						$this->getTitle()->escapeFullURL( 'picGameAction=createGame' ) . '">
						<h1>' . wfMsg( 'picturegame-creategamegametitle' ) . '</h1>
						<div class="picgame-errors" id="picgame-errors"></div>
						<p>
							<input name="picGameTitle" id="picGameTitle" type="text" value="" size="40" />
						</p>
						<input name="picOneURL" id="picOneURL" type="hidden" value="" />
						<input name="picTwoURL" id="picTwoURL" type="hidden" value="" />';
						/*<input name=\"picOneDesc\" id=\"picOneDesc\" type=\"hidden\" value=\"\" />
						<input name=\"picTwoDesc\" id=\"picTwoDesc\" type=\"hidden\" value=\"\" />*/
		$uploadObj = SpecialPage::getTitleFor( 'PictureGameAjaxUpload' );
		$output .= '<input name="key" type="hidden" value="' . md5( $now . $this->SALT ) . '" />
						<input name="chain" type="hidden" value="' . $now . '" />
					</form>
				</div>

				<div class="content">
					<div id="uploadImageForms" class="uploadImage">

						<div id="imageOneUpload" class="imageOneUpload">
							<h1>' . wfMsg( 'picturegame-createeditfirstimage' ) . '</h1>
							<!--Caption:<br /><input name="picOneDesc" id="picOneDesc" type="text" value="" /><br />-->
							<div id="imageOneUploadError"></div>
							<div id="imageOneLoadingImg" class="loadingImg" style="display:none">
								<img src="' . $wgScriptPath . '/extensions/PictureGame/images/ajax-loader-white.gif" alt="" />
							</div>
							<div id="imageOne" class="imageOne" style="display:none;"></div>
							<iframe class="imageOneUpload-frame" scrolling="no" frameborder="0" width="400" id="imageOneUpload-frame" src="' .
								$uploadObj->escapeFullURL( 'callbackPrefix=imageOne_' ) . '"></iframe>
						</div>

						<div id="imageTwoUpload" class="imageTwoUpload">
							<h1>' . wfMsg( 'picturegame-createeditsecondimage' ) . '</h1>
							<!--Caption:<br /><input name="picTwoDesc" id="picTwoDesc" type="text" value="" /><br />-->
							<div id="imageTwoUploadError"></div>
							<div id="imageTwoLoadingImg" class="loadingImg" style="display:none">
								<img src="' . $wgScriptPath . '/extensions/PictureGame/images/ajax-loader-white.gif" alt="" />
							</div>
							<div id="imageTwo" class="imageTwo" style="display:none;"></div>
							<iframe id="imageTwoUpload-frame" scrolling="no" frameborder="0" width="610" src="' .
								$uploadObj->escapeFullURL( 'callbackPrefix=imageTwo_' ) . '"></iframe>
						</div>

						<div class="cleared"></div>
					</div>
				</div>
			</div>

			<div id="startButton" class="startButton" style="display: none;">
				<input type="button" onclick="PictureGame.startGame()" value="' . wfMsg( 'picturegame-creategamecreateplay' ) . '" />
			</div>';

		$wgOut->addHTML( $output );
	}
コード例 #9
0
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        $lang = $this->getLanguage();
        $out = $this->getOutput();
        $request = $this->getRequest();
        $user = $this->getUser();
        // Set the page title, robot policies, etc.
        $this->setHeaders();
        // Add CSS
        $out->addModuleStyles('ext.socialprofile.userrelationship.css');
        $output = '';
        /**
         * Get query string variables
         */
        $user_name = $request->getVal('user');
        $rel_type = $request->getInt('rel_type');
        $page = $request->getInt('page');
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the ViewRelationships page
         */
        if (!$user->isLoggedIn() && $user_name == '') {
            $out->setPageTitle($this->msg('ur-error-page-title')->plain());
            $login = SpecialPage::getTitleFor('Userlogin');
            $out->redirect(htmlspecialchars($login->getFullURL('returnto=Special:ViewRelationships')));
            return false;
        }
        /**
         * Set up config for page / default values
         */
        if (!$page || !is_numeric($page)) {
            $page = 1;
        }
        if (!$rel_type || !is_numeric($rel_type)) {
            $rel_type = 1;
        }
        $per_page = 50;
        $per_row = 2;
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $user->getName();
        }
        $user_id = User::idFromName($user_name);
        $userPage = Title::makeTitle(NS_USER, $user_name);
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $out->setPageTitle($this->msg('ur-error-title')->plain());
            $output = '<div class="relationship-error-message">' . $this->msg('ur-error-message-no-user')->plain() . '</div>
			<div class="relationship-request-buttons">
				<input type="button" class="site-button" value="' . $this->msg('ur-main-page')->plain() . '" onclick=\'window.location="index.php?title=' . $this->msg('mainpage')->inContentLanguage()->escaped() . '"\' />';
            if ($user->isLoggedIn()) {
                $output .= '<input type="button" class="site-button" value="' . $this->msg('ur-your-profile')->plain() . '" onclick=\'window.location="' . htmlspecialchars($user->getUserPage()->getFullURL()) . '"\' />';
            }
            $output .= '</div>';
            $out->addHTML($output);
            return false;
        }
        /**
         * Get all relationships
         */
        $rel = new UserRelationship($user_name);
        $relationships = $rel->getRelationshipList($rel_type, $per_page, $page);
        $stats = new UserStats($rel->user_id, $rel->user_name);
        $stats_data = $stats->getUserStats();
        $friend_count = $stats_data['friend_count'];
        $foe_count = $stats_data['foe_count'];
        $back_link = Title::makeTitle(NS_USER, $rel->user_name);
        if ($rel_type == 1) {
            $out->setPageTitle($this->msg('ur-title-friend', $rel->user_name)->parse());
            $total = $friend_count;
            $rem = $this->msg('ur-remove-relationship-friend')->plain();
            $output .= '<div class="back-links">
			<a href="' . htmlspecialchars($back_link->getFullURL()) . '">' . $this->msg('ur-backlink', $rel->user_name)->parse() . '</a>
		</div>
		<div class="relationship-count">' . $this->msg('ur-relationship-count-friends', $rel->user_name, $total)->text() . '</div>';
        } else {
            $out->setPageTitle($this->msg('ur-title-foe', $rel->user_name)->parse());
            $total = $foe_count;
            $rem = $this->msg('ur-remove-relationship-foe')->plain();
            $output .= '<div class="back-links">
			<a href="' . htmlspecialchars($back_link->getFullURL()) . '">' . $this->msg('ur-backlink', $rel->user_name)->parse() . '</a>
		</div>
		<div class="relationship-count">' . $this->msg('ur-relationship-count-foes', $rel->user_name, $total)->text() . '</div>';
        }
        if ($relationships) {
            $x = 1;
            foreach ($relationships as $relationship) {
                $indivRelationship = UserRelationship::getUserRelationshipByID($relationship['user_id'], $user->getID());
                // Safe titles
                $userPage = Title::makeTitle(NS_USER, $relationship['user_name']);
                $addRelationshipLink = SpecialPage::getTitleFor('AddRelationship');
                $removeRelationshipLink = SpecialPage::getTitleFor('RemoveRelationship');
                $giveGiftLink = SpecialPage::getTitleFor('GiveGift');
                $userPageURL = htmlspecialchars($userPage->getFullURL());
                $avatar = new wAvatar($relationship['user_id'], 'ml');
                $avatar_img = $avatar->getAvatarURL();
                $username_length = strlen($relationship['user_name']);
                $username_space = stripos($relationship['user_name'], ' ');
                if (($username_space == false || $username_space >= "30") && $username_length > 30) {
                    $user_name_display = substr($relationship['user_name'], 0, 30) . ' ' . substr($relationship['user_name'], 30, 50);
                } else {
                    $user_name_display = $relationship['user_name'];
                }
                $output .= "<div class=\"relationship-item\">\n\t\t\t\t\t<a href=\"{$userPageURL}\">{$avatar_img}</a>\n\t\t\t\t\t<div class=\"relationship-info\">\n\t\t\t\t\t\t<div class=\"relationship-name\">\n\t\t\t\t\t\t\t<a href=\"{$userPageURL}\">{$user_name_display}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"relationship-actions\">";
                if ($indivRelationship == false) {
                    $output .= $lang->pipeList(array(Linker::link($addRelationshipLink, $this->msg('ur-add-friend')->plain(), array(), array('user' => $relationship['user_name'], 'rel_type' => 1)), Linker::link($addRelationshipLink, $this->msg('ur-add-foe')->plain(), array(), array('user' => $relationship['user_name'], 'rel_type' => 2)), ''));
                } elseif ($user_name == $user->getName()) {
                    $output .= Linker::link($removeRelationshipLink, $rem, array(), array('user' => $relationship['user_name']));
                    $output .= $this->msg('pipe-separator')->escaped();
                }
                $output .= Linker::link($giveGiftLink, $this->msg('ur-give-gift')->plain(), array(), array('user' => $relationship['user_name']));
                $output .= '</div>
					<div class="cleared"></div>
				</div>';
                $output .= '</div>';
                if ($x == count($relationships) || $x != 1 && $x % $per_row == 0) {
                    $output .= '<div class="cleared"></div>';
                }
                $x++;
            }
        }
        /**
         * Build next/prev nav
         */
        $total = intval(str_replace(',', '', $total));
        $numofpages = $total / $per_page;
        $pageLink = $this->getPageTitle();
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= Linker::link($pageLink, $this->msg('ur-previous')->plain(), array(), array('user' => $user_name, 'rel_type' => $rel_type, 'page' => $page - 1)) . $this->msg('word-separator')->plain();
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
            }
            if ($numofpages >= $total / $per_page) {
                $numofpages = $total / $per_page + 1;
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= Linker::link($pageLink, $i, array(), array('user' => $user_name, 'rel_type' => $rel_type, 'page' => $i)) . $this->msg('word-separator')->plain();
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= $this->msg('word-separator')->plain() . Linker::link($pageLink, $this->msg('ur-next')->plain(), array(), array('user' => $user_name, 'rel_type' => $rel_type, 'page' => $page + 1));
            }
            $output .= '</div>';
        }
        $out->addHTML($output);
    }
コード例 #10
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgContLang, $wgHooks, $wgSupressPageTitle, $wgPollScripts;
     $wgSupressPageTitle = true;
     // Blocked users cannot create polls
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage(false);
         return false;
     }
     // Check that the DB isn't locked
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     /**
      * Redirect anonymous users to login page
      * It will automatically return them to the CreatePoll page
      */
     if ($wgUser->getID() == 0) {
         $wgOut->setPageTitle(wfMsgHtml('poll-woops'));
         $login = SpecialPage::getTitleFor('Userlogin');
         $wgOut->redirect($login->getLocalURL('returnto=Special:CreatePoll'));
         return false;
     }
     /**
      * Create Poll Thresholds based on User Stats
      */
     global $wgCreatePollThresholds;
     if (is_array($wgCreatePollThresholds) && count($wgCreatePollThresholds) > 0) {
         $canCreate = true;
         $stats = new UserStats($wgUser->getID(), $wgUser->getName());
         $stats_data = $stats->getUserStats();
         $threshold_reason = '';
         foreach ($wgCreatePollThresholds as $field => $threshold) {
             if ($stats_data[$field] < $threshold) {
                 $canCreate = false;
                 $threshold_reason .= ($threshold_reason ? ', ' : '') . "{$threshold} {$field}";
             }
         }
         if ($canCreate == false) {
             $wgSupressPageTitle = false;
             $wgOut->setPageTitle(wfMsg('poll-create-threshold-title'));
             $wgOut->addHTML(wfMsg('poll-create-threshold-reason', $threshold_reason));
             return '';
         }
     }
     // i18n for JS
     $wgHooks['MakeGlobalVariablesScript'][] = 'CreatePoll::addJSGlobals';
     // Add CSS & JS
     $wgOut->addScriptFile($wgPollScripts . '/Poll.js');
     $wgOut->addExtensionStyle($wgPollScripts . '/Poll.css');
     // If the request was POSTed, try creating the poll
     if ($wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false) {
         $_SESSION['alreadysubmitted'] = true;
         // Add poll
         $poll_title = Title::makeTitleSafe(NS_POLL, $wgRequest->getVal('poll_question'));
         if (is_null($poll_title) && !$poll_title instanceof Title) {
             $wgSupressPageTitle = false;
             $wgOut->setPageTitle(wfMsg('poll-create-threshold-title'));
             $wgOut->addHTML(wfMsg('poll-create-threshold-reason', $threshold_reason));
             return '';
         }
         // Put choices in wikitext (so we can track changes)
         $choices = '';
         for ($x = 1; $x <= 10; $x++) {
             if ($wgRequest->getVal("answer_{$x}")) {
                 $choices .= $wgRequest->getVal("answer_{$x}") . "\n";
             }
         }
         // Create poll wiki page
         $localizedCategoryNS = $wgContLang->getNsText(NS_CATEGORY);
         $article = new Article($poll_title);
         $article->doEdit("<userpoll>\n{$choices}</userpoll>\n\n[[" . $localizedCategoryNS . ':' . wfMsgForContent('poll-category') . "]]\n" . '[[' . $localizedCategoryNS . ':' . wfMsgForContent('poll-category-user', $wgUser->getName()) . "]]\n" . '[[' . $localizedCategoryNS . ":{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}, {{subst:CURRENTYEAR}}]]\n\n__NOEDITSECTION__", wfMsgForContent('poll-edit-desc'));
         $newPageId = $article->getID();
         $p = new Poll();
         $poll_id = $p->addPollQuestion($wgRequest->getVal('poll_question'), $wgRequest->getVal('poll_image_name'), $newPageId);
         // Add choices
         for ($x = 1; $x <= 10; $x++) {
             if ($wgRequest->getVal("answer_{$x}")) {
                 $p->addPollChoice($poll_id, $wgRequest->getVal("answer_{$x}"), $x);
             }
         }
         // Clear poll cache
         $key = wfMemcKey('user', 'profile', 'polls', $wgUser->getID());
         $wgMemc->delete($key);
         // Redirect to new poll page
         $wgOut->redirect($poll_title->getFullURL());
     } else {
         $_SESSION['alreadysubmitted'] = false;
         include 'create-poll.tmpl.php';
         $template = new CreatePollTemplate();
         $wgOut->addTemplate($template);
     }
 }
コード例 #11
0
 /**
  * GET USER DETAIL INFO
  * @param user UserName
  * 
  * @return result array
  */
 public function getUserAllInfo()
 {
     global $wgUser;
     $dbr = wfGetDB(DB_SLAVE);
     $result = array();
     $result['username'] = $this->username;
     $user_id = $this->userid;
     $avatar = new wAvatar($user_id, 'ml');
     $result['url'] = $avatar->getAvatarURL();
     $gender = $this->getGender();
     $status = $this->getStatus();
     $result['gender'] = $gender;
     $result['status'] = $status;
     //¹Ø×¢Êý
     $usercount = UserUserFollow::getFollowingCount($this->user);
     $result['usercounts'] = $usercount;
     //±»¹Ø×¢Êý
     $usercounted = UserUserFollow::getFollowerCount($this->user);
     $result['usercounted'] = $usercounted;
     //±à¼­Êý
     $stats = new UserStats($this->userid, $this->username);
     $stats_data = $stats->getUserStats();
     $result['editcount'] = $stats_data['edits'];
     //µÈ¼¶
     $user_level = new UserLevel($stats_data['points']);
     $result['level'] = $user_level->getLevelName();
     //ÊÇ·ñ¹Ø×¢
     if ($wgUser->isLoggedIn()) {
         $current_user = $wgUser->getName();
         // return $current_user;
         $follower = UserUserFollow::getFollowedByUser($current_user);
         if (in_array($this->username, $follower)) {
             $result['is_follow'] = 'Y';
         } else {
             $result['is_follow'] = 'N';
         }
         //¹²Í¬¹Ø×¢
         $cfollow = array();
         $t_user = $this->username;
         $ufollower = UserUserFollow::getFollowedByUser($t_user);
         if ($ufollower != null) {
             foreach ($follower as $valuea) {
                 if (in_array($valuea, $ufollower)) {
                     $cfollow[] = $valuea;
                 }
             }
         } else {
             $cfollow = array();
         }
         $result['commonfollow'] = $cfollow;
         //ÎÒ¹Ø×¢µÄË­Ò²¹Ø×¢Ëû
         $result['minefollowerhim'] = self::getFollowingFollowsUser($t_user, $current_user);
     } else {
         $result['is_follow'] = '';
         $result['commonfollow'] = '';
         $result['minefollowerhim'] = '';
     }
     // $wgMemc->set( $key, $result );
     return $result;
 }
コード例 #12
0
	/**
	 * Show the special page
	 *
	 * @param $input Mixed: parameter passed to the page or null
	 */
	public function execute( $input ) {
		global $wgOut, $wgUser, $wgScriptPath;

		if( !$input ) {
			$input = 'points';
		}

		$wgOut->addExtensionStyle( $wgScriptPath . '/extensions/QuizGame/questiongame.css' );

		$whereConds = array();

		switch( $input ) {
			case 'correct':
				$wgOut->setPageTitle( wfMsg( 'quiz-leaderboard-most-correct' ) );
				$field = 'stats_quiz_questions_correct';
				break;
			case 'percentage':
				$wgOut->setPageTitle( wfMsg( 'quiz-leaderboard-highest-percent' ) );
				$field = 'stats_quiz_questions_correct_percent';
				$whereConds[] = 'stats_quiz_questions_answered >= 50';
				break;
			case 'points':
				$wgOut->setPageTitle( wfMsg( 'quiz-leaderboard-most-points' ) );
				$field = 'stats_quiz_points';
				break;
		}

		$dbr = wfGetDB( DB_MASTER );
		$whereConds[] = 'stats_user_id <> 0';
		$res = $dbr->select(
			'user_stats',
			array(
				'stats_user_id', 'stats_user_name', 'stats_quiz_points',
				'stats_quiz_questions_correct',
				'stats_quiz_questions_correct_percent'
			),
			$whereConds,
			__METHOD__,
			array( 'ORDER BY' => "{$field} DESC", 'LIMIT' => 50, 'OFFSET' => 0 )
		);

		$quizgame_title = SpecialPage::getTitleFor( 'QuizGameHome' );

		$output = '<div class="quiz-leaderboard-nav">';

		if( $wgUser->isLoggedIn() ) {
			$stats = new UserStats( $wgUser->getID(), $wgUser->getName() );
			$stats_data = $stats->getUserStats();

			// Get users rank
			$quiz_rank = 0;
			$s = $dbr->selectRow(
				'user_stats',
				array( 'COUNT(*) AS count' ),
				array( 'stats_quiz_points >' . str_replace( ',', '', $stats_data['quiz_points'] ) ),
				__METHOD__
			);
			if ( $s !== false ) {
				$quiz_rank = $s->count + 1;
			}
			$avatar = new wAvatar( $wgUser->getID(), 'm' );

			$output .= "<div class=\"user-rank-lb\">
				<h2>{$avatar->getAvatarURL()} " . wfMsg( 'quiz-leaderboard-scoretitle' ) . '</h2>

					<p><b>' . wfMsg( 'quiz-leaderboard-quizpoints' ) . "</b></p>
					<p class=\"user-rank-points\">{$stats_data['quiz_points']}</p>
					<div class=\"cleared\"></div>

					<p><b>" . wfMsg( 'quiz-leaderboard-correct' ) . "</b></p>
					<p>{$stats_data['quiz_correct']}</p>
					<div class=\"cleared\"></div>

					<p><b>" . wfMsg( 'quiz-leaderboard-answered' ) . "</b></p>
					<p>{$stats_data['quiz_answered']}</p>
					<div class=\"cleared\"></div>

					<p><b>" . wfMsg( 'quiz-leaderboard-pctcorrect' ) . "</b></p>
					<p>{$stats_data['quiz_correct_percent']}%</p>
					<div class=\"cleared\"></div>

					<p><b>" . wfMsg( 'quiz-leaderboard-rank' ) . "</b></p>
					<p>{$quiz_rank}</p>
					<div class=\"cleared\"></div>

				</div>";
		}

		// Build nav
		$menu = array(
			wfMsg( 'quiz-leaderboard-menu-points' ) => 'points',
			wfMsg( 'quiz-leaderboard-menu-correct' ) => 'correct',
			wfMsg( 'quiz-leaderboard-menu-pct' ) => 'percentage'
		);

		$output .= '<h1>' . wfMsg( 'quiz-leaderboard-order-menu' ) . '</h1>';

		foreach( $menu as $title => $qs ) {
			if ( $input != $qs ) {
				$output .= "<p><a href=\"{$this->getTitle()->getFullURL()}/{$qs}\">{$title}</a><p>";
			} else {
				$output .= "<p><b>{$title}</b></p>";
			}
		}

		$output .= '</div>';

		$output .= '<div class="quiz-leaderboard-top-links">
			<a href="' . $quizgame_title->getFullURL( 'questionGameAction=launchGame' ) . '">'
				. wfMsg( 'quiz-admin-back' ) .
			'</a>
		</div>';

		$x = 1;
		$output .= '<div class="top-users">';

		foreach ( $res as $row ) {
		    $user_name = $row->stats_user_name;
		    $user_title = Title::makeTitle( NS_USER, $row->stats_user_name );
		    $avatar = new wAvatar( $row->stats_user_id, 'm' );
			if ( $user_name == substr( $user_name, 0, 18 ) ) {
				$user_name_short = $user_name;
			} else {
				$user_name_short = substr( $user_name, 0, 18 ) . wfMsg( 'ellipsis' );
			}

		    $output .= "<div class=\"top-fan-row\">
		 		   <span class=\"top-fan-num\">{$x}.</span>
				   <span class=\"top-fan\">{$avatar->getAvatarURL()}
				   <a href='" . $user_title->getFullURL() . "'>" . $user_name_short . '</a>
				</span>';

			switch( $input ) {
				case 'correct':
					$stat = number_format( $row->$field ) . ' ' . wfMsg( 'quiz-leaderboard-desc-correct' );
					break;
				case 'percentage':
					$stat = number_format( $row->$field * 100, 2 ) . wfMsg( 'quiz-leaderboard-desc-pct' );
					break;
				case 'points':
					$stat = number_format( $row->$field ) . ' ' . wfMsg( 'quiz-leaderboard-desc-points' );
					break;
			}

			$output .= "<span class=\"top-fan-points\"><b>{$stat}</b></span>";
		    $output .= '<div class="cleared"></div>';
		    $output .= '</div>';
		    $x++;
		}
		$output .= '</div><div class="cleared"></div>';

		$wgOut->addHTML( $output );

	}
コード例 #13
0
 /**
  * Show the special page
  *
  * @param $section Mixed: parameter passed to the page or null
  */
 public function execute($section)
 {
     global $wgUpdateProfileInRecentChanges, $wgUserProfileThresholds, $wgSupressPageTitle, $wgAutoConfirmCount;
     $out = $this->getOutput();
     $request = $this->getRequest();
     $user = $this->getUser();
     $wgSupressPageTitle = true;
     // Set the page title, robot policies, etc.
     $this->setHeaders();
     $out->setHTMLTitle($this->msg('pagetitle', $this->msg('edit-profile-title')->plain())->parse());
     // This feature is only available for logged-in users.
     if (!$user->isLoggedIn()) {
         $out->setPageTitle($this->msg('user-profile-update-notloggedin-title')->plain());
         $out->addWikiMsg('user-profile-update-notloggedin-text');
         return;
     }
     // No need to allow blocked users to access this page, they could abuse it, y'know.
     if ($user->isBlocked()) {
         $out->blockedPage(false);
         return false;
     }
     // Database operations require write mode
     if (wfReadOnly()) {
         $out->readOnlyPage();
         return;
     }
     /**
      * Create thresholds based on user stats
      */
     if (is_array($wgUserProfileThresholds) && count($wgUserProfileThresholds) > 0) {
         $can_create = true;
         $stats = new UserStats($user->getId(), $user->getName());
         $stats_data = $stats->getUserStats();
         $thresholdReasons = array();
         foreach ($wgUserProfileThresholds as $field => $threshold) {
             // If the threshold is greater than the user's amount of whatever
             // statistic we're looking at, then it means that they can't use
             // this special page.
             // Why, oh why did I want to be so f*****g smart with these
             // field names?! This str_replace() voodoo all over the place is
             // outright painful.
             $correctField = str_replace('-', '_', $field);
             if ($stats_data[$correctField] < $threshold) {
                 $can_create = false;
                 $thresholdReasons[$threshold] = $field;
             }
         }
         $hasEqualEditThreshold = isset($wgUserProfileThresholds['edit']) && $wgUserProfileThresholds['edit'] == $wgAutoConfirmCount ? true : false;
         $can_create = $user->isAllowed('createpage') && $hasEqualEditThreshold ? true : $can_create;
         // Boo, go away!
         if ($can_create == false) {
             global $wgSupressPageTitle;
             $wgSupressPageTitle = false;
             $out->setPageTitle($this->msg('user-profile-create-threshold-title')->text());
             $thresholdMessages = array();
             foreach ($thresholdReasons as $requiredAmount => $reason) {
                 // Replace underscores with hyphens for consistency in i18n
                 // message names.
                 $reason = str_replace('_', '-', $reason);
                 /**
                  * For grep:
                  * user-profile-create-threshold-edits
                  * user-profile-create-threshold-votes
                  * user-profile-create-threshold-comments
                  * user-profile-create-threshold-comment-score-plus
                  * user-profile-create-threshold-comment-score-minus
                  * user-profile-create-threshold-recruits
                  * user-profile-create-threshold-friend-count
                  * user-profile-create-threshold-foe-count
                  * user-profile-create-threshold-weekly-wins
                  * user-profile-create-threshold-monthly-wins
                  * user-profile-create-threshold-poll-votes
                  * user-profile-create-threshold-picture-game-votes
                  * user-profile-create-threshold-quiz-created
                  * user-profile-create-threshold-quiz-answered
                  * user-profile-create-threshold-quiz-correct
                  * user-profile-create-threshold-quiz-points
                  */
                 $thresholdMessages[] = $this->msg('user-profile-create-threshold-' . $reason)->numParams($requiredAmount)->parse();
             }
             $out->addHTML($this->msg('user-profile-create-threshold-reason', $this->getLanguage()->commaList($thresholdMessages))->parse());
             return '';
         }
     }
     // Add CSS & JS
     $out->addModuleStyles('ext.socialprofile.userprofile.css');
     $out->addModules('ext.userProfile.updateProfile');
     if ($request->wasPosted()) {
         if (!$section) {
             $section = 'basic';
         }
         switch ($section) {
             case 'basic':
                 $this->saveProfileBasic($user);
                 $this->saveSettings_basic($user);
                 break;
             case 'personal':
                 $this->saveProfilePersonal($user);
                 break;
             case 'custom':
                 $this->saveProfileCustom($user);
                 break;
             case 'preferences':
                 $this->saveSettings_pref();
                 break;
         }
         UserProfile::clearCache($user->getID());
         $log = new LogPage('profile');
         if (!$wgUpdateProfileInRecentChanges) {
             $log->updateRecentChanges = false;
         }
         $log->addEntry('profile', $user->getUserPage(), $this->msg('user-profile-update-log-section')->inContentLanguage()->text() . " '{$section}'");
         $out->addHTML('<span class="profile-on">' . $this->msg('user-profile-update-saved')->plain() . '</span><br /><br />');
         // create the user page if it doesn't exist yet
         $title = Title::makeTitle(NS_USER, $user->getName());
         $article = new Article($title);
         if (!$article->exists()) {
             $article->doEdit('', 'create user page', EDIT_SUPPRESS_RC);
         }
     }
     if (!$section) {
         $section = 'basic';
     }
     switch ($section) {
         case 'basic':
             $out->addHTML($this->displayBasicForm($user));
             break;
         case 'personal':
             $out->addHTML($this->displayPersonalForm($user));
             break;
         case 'custom':
             $out->addHTML($this->displayCustomForm($user));
             break;
         case 'preferences':
             $out->addHTML($this->displayPreferencesForm());
             break;
     }
 }
コード例 #14
0
    /**
     * Show a list of this user's blog articles in their user profile page.
     *
     * @param $userProfile Object: instance of UserProfilePage
     * @return Boolean: true
     */
    public static function getArticles($userProfile)
    {
        global $wgUserProfileDisplay, $wgMemc, $wgOut;
        if (!$wgUserProfileDisplay['articles']) {
            return '';
        }
        $user_name = $userProfile->user_name;
        $output = '';
        // Try cache first
        $key = wfMemcKey('user', 'profile', 'articles', $userProfile->user_id);
        $data = $wgMemc->get($key);
        $articles = array();
        if ($data != '') {
            wfDebugLog('BlogPage', "Got UserProfile articles for user {$user_name} from cache\n");
            $articles = $data;
        } else {
            wfDebugLog('BlogPage', "Got UserProfile articles for user {$user_name} from DB\n");
            $categoryTitle = Title::newFromText(wfMsgForContent('blog-by-user-category', wfMsgForContent('blog-category')) . " {$user_name}");
            $dbr = wfGetDB(DB_SLAVE);
            /**
             * I changed the original query a bit, since it wasn't returning
             * what it should've.
             * I added the DISTINCT to prevent one page being listed five times
             * and added the page_namespace to the WHERE clause to get only
             * blog pages and the cl_from = page_id to the WHERE clause so that
             * the cl_to stuff actually, y'know, works :)
             */
            $res = $dbr->select(array('page', 'categorylinks'), array('DISTINCT page_id', 'page_title', 'page_namespace'), array('cl_from = page_id', 'cl_to' => array($categoryTitle->getDBkey()), 'page_namespace' => NS_BLOG), __METHOD__, array('ORDER BY' => 'page_id DESC', 'LIMIT' => 5));
            foreach ($res as $row) {
                $articles[] = array('page_title' => $row->page_title, 'page_namespace' => $row->page_namespace, 'page_id' => $row->page_id);
            }
            $wgMemc->set($key, $articles, 60);
        }
        // Load opinion count via user stats;
        $stats = new UserStats($userProfile->user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $articleCount = $stats_data['opinions_created'];
        $articleLink = Title::makeTitle(NS_CATEGORY, wfMsgForContent('blog-by-user-category', wfMsgForContent('blog-category')) . " {$user_name}");
        if (count($articles) > 0) {
            $output .= '<div class="user-section-heading">
				<div class="user-section-title">' . wfMsg('blog-user-articles-title') . '</div>
				<div class="user-section-actions">
					<div class="action-right">';
            if ($articleCount > 5) {
                $output .= '<a href="' . $articleLink->escapeFullURL() . '" rel="nofollow">' . wfMsg('user-view-all') . '</a>';
            }
            $output .= '</div>
					<div class="action-left">' . wfMsgExt('user-count-separator', 'parsemag', count($articles), $articleCount) . '</div>
					<div class="cleared"></div>
				</div>
			</div>
			<div class="cleared"></div>
			<div class="user-articles-container">';
            $x = 1;
            foreach ($articles as $article) {
                $articleTitle = Title::makeTitle($article['page_namespace'], $article['page_title']);
                $voteCount = BlogPage::getVotesForPage($article['page_id']);
                $commentCount = BlogPage::getCommentsForPage($article['page_id']);
                if ($x == 1) {
                    $divClass = 'article-item-top';
                } else {
                    $divClass = 'article-item';
                }
                $output .= '<div class="' . $divClass . "\">\n\t\t\t\t\t<div class=\"number-of-votes\">\n\t\t\t\t\t\t<div class=\"vote-number\">{$voteCount}</div>\n\t\t\t\t\t\t<div class=\"vote-text\">" . wfMsgExt('blog-user-articles-votes', 'parsemag', $voteCount) . '</div>
					</div>
					<div class="article-title">
						<a href="' . $articleTitle->escapeFullURL() . "\">{$articleTitle->getText()}</a>\n\t\t\t\t\t\t<span class=\"item-small\">" . wfMsgExt('blog-user-article-comment', 'parsemag', $commentCount) . '</span>
					</div>
					<div class="cleared"></div>
				</div>';
                $x++;
            }
            $output .= '</div>';
        }
        $wgOut->addHTML($output);
        return true;
    }
コード例 #15
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;
 }
コード例 #16
0
ファイル: PollPage.php プロジェクト: schwarer2006/wikia
    /**
     * Called on every poll page view.
     */
    public function view()
    {
        global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgScriptPath, $wgUploadPath, $wgLang;
        global $wgSupressPageTitle, $wgNameSpacesWithEditMenu;
        // Perform no custom handling if the poll in question has been deleted
        if (!$this->getID()) {
            parent::view();
        }
        $wgSupressPageTitle = true;
        $wgOut->setHTMLTitle($wgTitle->getText());
        $wgOut->setPageTitle($wgTitle->getText());
        $wgNameSpacesWithEditMenu[] = NS_POLL;
        $wgOut->addScript("<script type=\"text/javascript\">\n\t\t\t\$( function() { LightBox.init(); PollNY.show(); } );\n\t\t</script>\n");
        $createPollObj = SpecialPage::getTitleFor('CreatePoll');
        $wgOut->addHTML("<script type=\"text/javascript\">\n\t\t\tvar _POLL_OPEN_MESSAGE = \"" . addslashes(wfMsg('poll-open-message')) . "\";\n\t\t\tvar _POLL_CLOSE_MESSAGE = \"" . addslashes(wfMsg('poll-close-message')) . "\";\n\t\t\tvar _POLL_FLAGGED_MESSAGE = \"" . addslashes(wfMsg('poll-flagged-message')) . "\";\n\t\t\tvar _POLL_FINISHED = \"" . addslashes(wfMsg('poll-finished', $createPollObj->getFullURL(), $wgTitle->getFullURL())) . "\";\n\t\t</script>");
        // Get total polls count so we can tell the user how many they have
        // voted for out of total
        $dbr = wfGetDB(DB_MASTER);
        $total_polls = 0;
        $s = $dbr->selectRow('poll_question', array('COUNT(*) AS count'), array(), __METHOD__);
        if ($s !== false) {
            $total_polls = number_format($s->count);
        }
        $stats = new UserStats($wgUser->getID(), $wgUser->getName());
        $stats_current_user = $stats->getUserStats();
        $sk = $wgUser->getSkin();
        $p = new Poll();
        $poll_info = $p->getPoll($wgTitle->getArticleID());
        if (!isset($poll_info['id'])) {
            return '';
        }
        // Set up submitter data
        $user_title = Title::makeTitle(NS_USER, $poll_info['user_name']);
        $avatar = new wAvatar($poll_info['user_id'], 'l');
        $avatarID = $avatar->getAvatarImage();
        $stats = new UserStats($poll_info['user_id'], $poll_info['user_name']);
        $stats_data = $stats->getUserStats();
        $user_name_short = $wgLang->truncate($poll_info['user_name'], 27);
        $output = '<div class="poll-right">';
        // Show the "create a poll" link to registered users
        if ($wgUser->isLoggedIn()) {
            $output .= '<div class="create-link">
				<a href="' . $createPollObj->escapeFullURL() . '">
					<img src="' . $wgScriptPath . '/extensions/PollNY/images/addIcon.gif" alt="" />' . wfMsg('poll-create') . '</a>
			</div>';
        }
        $output .= '<div class="credit-box">
					<h1>' . wfMsg('poll-submitted-by') . "</h1>\n\t\t\t\t\t<div class=\"submitted-by-image\">\n\t\t\t\t\t\t<a href=\"{$user_title->getFullURL()}\">\n\t\t\t\t\t\t\t<img src=\"{$wgUploadPath}/avatars/{$avatarID}\" style=\"border:1px solid #d7dee8; width:50px; height:50px;\"/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"submitted-by-user\">\n\t\t\t\t\t\t<a href=\"{$user_title->getFullURL()}\">{$user_name_short}</a>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<img src=\"{$wgScriptPath}/extensions/PollNY/images/voteIcon.gif\" alt=\"\" />\n\t\t\t\t\t\t\t\t{$stats_data['votes']}\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<img src=\"{$wgScriptPath}/extensions/PollNY/images/pencilIcon.gif\" alt=\"\" />\n\t\t\t\t\t\t\t\t{$stats_data['edits']}\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<img src=\"{$wgScriptPath}/extensions/PollNY/images/commentsIcon.gif\" alt=\"\" />\n\t\t\t\t\t\t\t\t{$stats_data['comments']}\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"cleared\"></div>\n\n\t\t\t\t\t<a href=\"" . SpecialPage::getTitleFor('ViewPoll')->escapeFullURL('user='******'user_name']) . '">' . wfMsgExt('poll-view-all-by', 'parsemag', $user_name_short) . '</a>

				</div>';
        $output .= '<div class="poll-stats">';
        if ($wgUser->isLoggedIn()) {
            $output .= wfMsgExt('poll-voted-for', 'parsemag', '<b>' . $stats_current_user['poll_votes'] . '</b>', $total_polls, number_format($stats_current_user['poll_votes'] * 5));
        } else {
            $output .= wfMsgExt('poll-would-have-earned', 'parse', number_format($total_polls * 5));
        }
        $output .= '</div>' . "\n";
        $toggle_flag_label = $poll_info['status'] == 1 ? wfMsg('poll-flag-poll') : wfMsg('poll-unflag-poll');
        $toggle_flag_status = $poll_info['status'] == 1 ? 2 : 1;
        if ($poll_info['status'] == 1) {
            // Creator and admins can change the status of a poll
            $toggle_label = $poll_info['status'] == 1 ? wfMsg('poll-close-poll') : wfMsg('poll-open-poll');
            $toggle_status = $poll_info['status'] == 1 ? 0 : 1;
        }
        $output .= '<div class="poll-links">' . "\n";
        // Poll administrators can access the poll admin panel
        if ($wgUser->isAllowed('polladmin')) {
            $output .= '<a href="' . SpecialPage::getTitleFor('AdminPoll')->escapeFullURL() . '">' . wfMsg('poll-admin-panel') . '</a> | ';
        }
        if ($poll_info['status'] == 1 && ($poll_info['user_id'] == $wgUser->getID() || $wgUser->isAllowed('polladmin'))) {
            $output .= "<a href=\"javascript:void(0)\" onclick=\"PollNY.toggleStatus({$toggle_status});\">{$toggle_label}</a> |";
        }
        if ($poll_info['status'] == 1 || $wgUser->isAllowed('polladmin')) {
            $output .= " <a href=\"javascript:void(0)\" onclick=\"PollNY.toggleStatus({$toggle_flag_status});\">{$toggle_flag_label}</a>";
        }
        $output .= "\n" . '</div>' . "\n";
        // .poll-links
        $output .= '</div>' . "\n";
        // .poll-right
        $output .= '<div class="poll">' . "\n";
        $output .= "<h1 class=\"pagetitle\">{$wgTitle->getText()}</h1>\n";
        if ($poll_info['image']) {
            $poll_image_width = 150;
            $poll_image = wfFindFile($poll_info['image']);
            $poll_image_url = $width = '';
            if (is_object($poll_image)) {
                $poll_image_url = $poll_image->createThumb($poll_image_width);
                if ($poll_image->getWidth() >= $poll_image_width) {
                    $width = $poll_image_width;
                } else {
                    $width = $poll_image->getWidth();
                }
            }
            $poll_image_tag = '<img width="' . $width . '" alt="" src="' . $poll_image_url . '"/>';
            $output .= "<div class=\"poll-image\">{$poll_image_tag}</div>";
        }
        // Display question and let user vote
        if (!$p->userVoted($wgUser->getName(), $poll_info['id']) && $poll_info['status'] == 1) {
            $output .= '<div id="loading-poll">' . wfMsg('poll-js-loading') . '</div>' . "\n";
            $output .= '<div id="poll-display" style="display:none;">' . "\n";
            $output .= '<form name="poll"><input type="hidden" id="poll_id" name="poll_id" value="' . $poll_info['id'] . '"/>' . "\n";
            foreach ($poll_info['choices'] as $choice) {
                $output .= '<div class="poll-choice">
					<input type="radio" name="poll_choice" onclick="PollNY.vote()" id="poll_choice" value="' . $choice['id'] . '" />' . $choice['choice'] . '</div>';
            }
            $output .= '</form>
					</div>' . "\n";
            $output .= '<div class="poll-timestamp">' . wfMsg('poll-createdago', Poll::getTimeAgo($poll_info['timestamp'])) . '</div>' . "\n";
            $output .= "\t\t\t\t\t" . '<div class="poll-button">
					<a href="javascript:PollNY.skip();">' . wfMsg('poll-skip') . '</a>
				</div>';
            if ($wgRequest->getInt('prev_id')) {
                $p = new Poll();
                $poll_info_prev = $p->getPoll($wgRequest->getInt('prev_id'));
                $poll_title = Title::makeTitle(NS_POLL, $poll_info_prev['question']);
                $output .= '<div class="previous-poll">';
                $output .= '<div class="previous-poll-title">' . wfMsg('poll-previous-poll') . " - <a href=\"{$poll_title->getFullURL()}\">{$poll_info_prev['question']}</a></div>\n\t\t\t\t\t<div class=\"previous-sub-title\">" . wfMsgExt('poll-view-answered-times', 'parsemag', $poll_info_prev['votes']) . '</div>';
                $x = 1;
                foreach ($poll_info_prev['choices'] as $choice) {
                    if ($poll_info_prev['votes'] > 0) {
                        $percent = round($choice['votes'] / $poll_info_prev['votes'] * 100);
                        $bar_width = floor(360 * ($choice['votes'] / $poll_info_prev['votes']));
                    } else {
                        $percent = 0;
                        $bar_width = 0;
                    }
                    if (empty($choice['votes'])) {
                        $choice['votes'] = 0;
                    }
                    $bar_img = '<img src="' . $wgScriptPath . '/extensions/PollNY/images/vote-bar-' . $x . '.gif" class="image-choice-' . $x . '" style="width:' . $bar_width . 'px;height:11px;"/>';
                    $output .= "<div class=\"previous-poll-choice\">\n\t\t\t\t\t\t\t\t<div class=\"previous-poll-choice-left\">{$choice['choice']} ({$percent}%)</div>";
                    $output .= "<div class=\"previous-poll-choice-right\">{$bar_img} <span class=\"previous-poll-choice-votes\">" . wfMsgExt('poll-votes', 'parsemag', $choice['votes']) . '</span></div>';
                    $output .= '</div>';
                    $x++;
                }
                $output .= '</div>';
            }
        } else {
            $show_results = true;
            // Display message if poll has been closed for voting
            if ($poll_info['status'] == 0) {
                $output .= '<div class="poll-closed">' . wfMsg('poll-closed') . '</div>';
            }
            // Display message if poll has been flagged
            if ($poll_info['status'] == 2) {
                $output .= '<div class="poll-closed">' . wfMsg('poll-flagged') . '</div>';
                if (!$wgUser->isAllowed('polladmin')) {
                    $show_results = false;
                }
            }
            if ($show_results) {
                $x = 1;
                foreach ($poll_info['choices'] as $choice) {
                    if ($poll_info['votes'] > 0) {
                        $percent = round($choice['votes'] / $poll_info['votes'] * 100);
                        $bar_width = floor(480 * ($choice['votes'] / $poll_info['votes']));
                    } else {
                        $percent = 0;
                        $bar_width = 0;
                    }
                    // If it's not set, it means that no-one has voted for that
                    // choice yet...it also means that we need to set it
                    // manually here so that i18n displays properly
                    if (empty($choice['votes'])) {
                        $choice['votes'] = 0;
                    }
                    $bar_img = "<img src=\"{$wgScriptPath}/extensions/PollNY/images/vote-bar-{$x}.gif\" class=\"image-choice-{$x}\" style=\"width:{$bar_width}px;height:12px;\"/>";
                    $output .= "<div class=\"poll-choice\">\n\t\t\t\t\t<div class=\"poll-choice-left\">{$choice['choice']} ({$percent}%)</div>";
                    $output .= "<div class=\"poll-choice-right\">{$bar_img} <span class=\"poll-choice-votes\">" . wfMsgExt('poll-votes', 'parsemag', $choice['votes']) . '</span></div>';
                    $output .= '</div>';
                    $x++;
                }
            }
            $output .= '<div class="poll-total-votes">(' . wfMsgExt('poll-based-on-votes', 'parsemag', $poll_info['votes']) . ')</div>
			<div class="poll-timestamp">' . wfMsg('poll-createdago', Poll::getTimeAgo($poll_info['timestamp'])) . '</div>


			<div class="poll-button">
				<input type="hidden" id="poll_id" name="poll_id" value="' . $poll_info['id'] . '" />
				<a href="javascript:PollNY.loadingLightBox();PollNY.goToNewPoll();">' . wfMsg('poll-next-poll') . '</a>
			</div>';
        }
        // "Embed this on a wiki page" feature
        $poll_embed_name = htmlspecialchars($wgTitle->getText(), ENT_QUOTES);
        $output .= '<br />
			<table cellpadding="0" cellspacing="2" border="0">
				<tr>
					<td>
						<b>' . wfMsg('poll-embed') . "</b>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<form name=\"embed_poll\">\n\t\t\t\t\t\t\t<input name='embed_code' style='width:300px;font-size:10px;' type='text' value='<pollembed title=\"{$poll_embed_name}\" />' onclick='javascript:document.embed_poll.embed_code.focus();document.embed_poll.embed_code.select();' readonly='readonly' />\n\t\t\t\t\t\t</form>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n";
        $output .= '</div>' . "\n";
        // .poll
        $output .= '<div class="cleared"></div>';
        $wgOut->addHTML($output);
        global $wgPollDisplay;
        if ($wgPollDisplay['comments']) {
            $wgOut->addWikiText('<comments/>');
        }
    }
コード例 #17
0
 /**
  * Get site followed users 
  *
  * @param $user:current username; $site_name:servername
  * @return array
  */
 public static function getSiteFollowersWithDetails($user, $site_name)
 {
     // return '';
     $dbr = wfGetDB(DB_SLAVE);
     $request = array();
     // $follower = UserUserFollow::getFollowedByUser( $user->getName() );
     $res = self::getSiteFollowers($user, $site_name);
     foreach ($res as $value) {
         $u_name = $value['user_name'];
         $temp['user'] = $u_name;
         // $temp['user'] = User::getEffectiveGroups($user);
         $userPage = Title::makeTitle(NS_USER, $u_name);
         $userPageURL = htmlspecialchars($userPage->getFullURL());
         $temp['userUrl'] = $userPageURL;
         $user_id = User::idFromName($u_name);
         $stats = new UserStats($user_id, $u_name);
         $stats_data = $stats->getUserStats();
         $user_level = new UserLevel($stats_data['points']);
         $temp['level'] = $user_level->getLevelName();
         $avatar = new wAvatar($user_id, 'm');
         $temp['url'] = $avatar->getAvatarURL();
         $tuser = User::newFromName($u_name);
         $temp['count'] = UserStats::getSiteEditsCount($tuser, $site_name);
         // if(in_array($u_name, $follower)){
         // 	$is_follow = 'Y';
         // }else{
         // 	$is_follow = 'N';
         // }
         // $temp['is_follow'] = $is_follow;
         $request[] = $temp;
     }
     foreach ($request as $key => $value) {
         $count[$key] = $value['count'];
     }
     array_multisort($count, SORT_DESC, $request);
     return $request;
 }
コード例 #18
0
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgUserBoardScripts;
        // Add CSS
        $wgOut->addExtensionStyle($wgUserBoardScripts . '/UserBoard.css');
        $ub_messages_show = 25;
        $user_name = $wgRequest->getVal('user');
        $user_name_2 = $wgRequest->getVal('conv');
        $user_id_2 = '';
        // Prevent E_NOTICE
        $page = $wgRequest->getVal('page');
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the UserBoard page
         */
        if ($wgUser->getID() == 0 && $user_name == '') {
            $login = SpecialPage::getTitleFor('Userlogin');
            $wgOut->redirect($login->getFullURL('returnto=Special:UserBoard'));
            return false;
        }
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $wgUser->getName();
        }
        $user_id = User::idFromName($user_name);
        $user = Title::makeTitle(NS_USER, $user_name);
        $user_safe = str_replace('&', '%26', $user_name);
        if ($user_name_2) {
            $user_id_2 = User::idFromName($user_name_2);
            $user_2 = Title::makeTitle(NS_USER, $user_name);
            $user_safe_2 = urlencode($user_name_2);
        }
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $wgOut->showErrorPage('error', 'userboard_noexist');
            return false;
        }
        /**
         * Config for the page
         */
        $per_page = $ub_messages_show;
        if (!$page || !is_numeric($page)) {
            $page = 1;
        }
        $b = new UserBoard();
        $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
        if (!$user_id_2) {
            $stats = new UserStats($user_id, $user_name);
            $stats_data = $stats->getUserStats();
            $total = $stats_data['user_board'];
            // If user is viewing their own board or is allowed to delete
            // others' board messages, show the total count of board messages
            // to them (public + private messages)
            if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
                $total = $total + $stats_data['user_board_priv'];
            }
        } else {
            $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
        }
        if (!$user_id_2) {
            if (!($wgUser->getName() == $user_name)) {
                $wgOut->setPageTitle(wfMsg('userboard_owner', $user_name));
            } else {
                $b->clearNewMessageCount($wgUser->getID());
                $wgOut->setPageTitle(wfMsg('userboard_yourboard'));
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $wgOut->setPageTitle(wfMsg('userboard_yourboardwith', $user_name_2));
            } else {
                $wgOut->setPageTitle(wfMsg('userboard_otherboardwith', $user_name, $user_name_2));
            }
        }
        $output = '<div class="user-board-top-links">';
        $output .= '<a href="' . $user->escapeFullURL() . '">&lt; ' . wfMsg('userboard_backprofile', $user_name) . '</a>';
        $output .= '</div>';
        $output .= "<script type=\"text/javascript\">/*<![CDATA[*/\r\n\t\t\tvar _DELETE_CONFIRM = \"" . wfMsg('userboard_confirmdelete') . "\";\r\n\t\t\tvar posted = 0;\r\n\t\t\tfunction send_message() {\r\n\t\t\t\tif( document.getElementById('message').value && !posted ) {\r\n\t\t\t\t\tposted = 1;\r\n\t\t\t\t\tencodedName = encodeURIComponent( document.getElementById('user_name_to').value );\r\n\t\t\t\t\tencodedMsg = encodeURIComponent( document.getElementById('message').value );\r\n\t\t\t\t\tmessageType = document.getElementById('message_type').value;\r\n\t\t\t\t\tsajax_request_type = 'POST';\r\n\t\t\t\t\tsajax_do_call( 'wfSendBoardMessage', [ encodedName, encodedMsg, messageType, {$per_page} ], function( originalRequest ) {\r\n\t\t\t\t\t\t\tposted = 0;\r\n\t\t\t\t\t\t\tif( document.getElementById('user_name_from').value ) { // its a board to board\r\n\t\t\t\t\t\t\t\tuser_1 = document.getElementById('user_name_from').value;\r\n\t\t\t\t\t\t\t\tuser_2 = document.getElementById('user_name_to').value;\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\tuser_1 = document.getElementById('user_name_to').value;\r\n\t\t\t\t\t\t\t\tuser_2 = '';\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tvar params = ( user_2 ) ? '&conv=' + user_2 : '';\r\n\t\t\t\t\t\t\tvar url = wgScriptPath + '/index.php?title=Special:UserBoard&user='******'POST';\r\n\t\t\t\t\tsajax_do_call( 'wfDeleteBoardMessage', [ id ], function( originalRequest ) {\r\n\t\t\t\t\t\twindow.location.reload();\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t/*]]>*/</script>";
        $board_to_board = '';
        // Prevent E_NOTICE
        if ($page == 1) {
            $start = 1;
        } else {
            $start = ($page - 1) * $per_page + 1;
        }
        $end = $start + count($ub_messages) - 1;
        if ($wgUser->getName() != $user_name) {
            $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($wgUser->getName(), $user_name) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
        }
        if ($total) {
            $output .= '<div class="user-page-message-top">
			<span class="user-page-message-count" style="font-size:11px;color:#666666;">' . wfMsg('userboard_showingmessages', $total, $start, $end, $end - $start + 1) . ".</span> {$board_to_board}</span>\r\n\t\t\t</div>";
        }
        /**
         * Build next/prev nav
         */
        if ($user_id_2) {
            $qs = "&conv={$user_safe_2}";
        }
        $numofpages = $total / $per_page;
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page - 1) . "{$qs}\">" . wfMsg('userboard_prevpage') . '</a>';
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
                if ($numofpages >= $total / $per_page) {
                    $numofpages = $total / $per_page + 1;
                }
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page={$i}{$qs}\">{$i}</a> ";
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= ' <a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page + 1) . "{$qs}\">" . wfMsg('userboard_nextpage') . '</a>';
            }
            $output .= '</div><p>';
        }
        /**
         * Build next/prev nav
         */
        $can_post = false;
        $user_name_from = '';
        // Prevent E_NOTICE
        if (!$user_id_2) {
            if ($wgUser->getName() != $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name, ENT_QUOTES);
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name_2, ENT_QUOTES);
                $user_name_from = htmlspecialchars($user_name, ENT_QUOTES);
            }
        }
        if ($wgUser->isBlocked()) {
            // only let them post to admins
            $user_to = User::newFromId($user_id);
            $user_to->loadFromId();
            // if( !$user_to->isAllowed( 'delete' ) ) {
            $can_post = false;
            // }
        }
        if ($can_post) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
					<input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
					<input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
					<span style="color:#797979;">' . wfMsg('userboard_messagetype') . ' </span>
					<select id="message_type">
						<option value="0">' . wfMsg('userboard_public') . '</option>
						<option value="1">' . wfMsg('userboard_private') . '</option>
					</select>
					<p>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>

					<div class="user-page-message-box-button">
						<input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:send_message();" />
					</div>

				</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMsg('userboard_loggedout', $login_link->escapeFullURL()) . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        if ($ub_messages) {
            foreach ($ub_messages as $ub_message) {
                $user = Title::makeTitle(NS_USER, $ub_message['user_name_from']);
                $avatar = new wAvatar($ub_message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $ub_message_type_label = '';
                $delete_link = '';
                if ($wgUser->getName() != $ub_message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from']) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_sendmessage', $ub_message['user_name_from']) . '</a>';
                } else {
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_myboard') . '</a>';
                }
                if ($wgUser->getName() == $ub_message['user_name'] || $wgUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\r\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$ub_message['id']})\">" . wfMsg('userboard_delete') . '</a>
					</span>';
                }
                if ($ub_message['type'] == 1) {
                    $ub_message_type_label = '(' . wfMsg('userboard_private') . ')';
                }
                // had global function to cut link text if too long and no breaks
                // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
                $ub_message_text = $ub_message['message_text'];
                $output .= "<div class=\"user-board-message\" style=\"width:550px\">\r\n\t\t\t\t\t<div class=\"user-board-message-from\">\r\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"user-board-message-time\">" . wfMsgHtml('userboard_posted_ago', $b->getTimeAgo($ub_message['timestamp'])) . "</div>\r\n\t\t\t\t\t<div class=\"user-board-message-content\">\r\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\r\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\r\n\t\t\t\t\t\t\t{$ub_message_text}\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"cleared\"></div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"user-board-message-links\">\r\n\t\t\t\t\t\t{$board_link}\r\n\t\t\t\t\t\t{$board_to_board}\r\n\t\t\t\t\t\t{$delete_link}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>";
            }
        } else {
            $invite_title = SpecialPage::getTitleFor('InviteContacts');
            $output .= '<p>' . wfMsg('userboard_nomessages', $invite_title->escapeFullURL()) . '</p>';
        }
        $output .= '</div>';
        $wgOut->addHTML($output);
    }
コード例 #19
0
    /**
     * Get the user board for a given user.
     *
     * @param $user_id Integer: user's ID number
     * @param $user_name String: user name
     */
    function getUserBoard($user_id, $user_name)
    {
        global $wgUser, $wgOut, $wgUserProfileDisplay;
        // Anonymous users cannot have user boards
        if ($user_id == 0) {
            return '';
        }
        // Don't display anything if user board on social profiles isn't
        // enabled in site configuration
        if ($wgUserProfileDisplay['board'] == false) {
            return '';
        }
        $output = '';
        // Prevent E_NOTICE
        // Add JS
        $wgOut->addModules('ext.socialprofile.userprofile.js');
        $rel = new UserRelationship($user_name);
        $friends = $rel->getRelationshipList(1, 4);
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $total = $stats_data['user_board'];
        // If the user is viewing their own profile or is allowed to delete
        // board messages, add the amount of private messages to the total
        // sum of board messages.
        if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
            $total = $total + $stats_data['user_board_priv'];
        }
        $output .= '<div class="panel panel-default"><div class="user-section-heading panel-heading">
			<div class="user-section-title">' . wfMessage('user-board-title')->escaped() . '</div>
			<div class="user-section-actions">
				<div class="action-right">';
        if ($wgUser->getName() == $user_name) {
            if ($friends) {
                $output .= '<a href="' . UserBoard::getBoardBlastURL() . '">' . wfMessage('user-send-board-blast')->escaped() . '</a>';
            }
            if ($total > 10) {
                $output .= wfMessage('pipe-separator')->escaped();
            }
        }
        if ($total > 10) {
            $output .= '<a href="' . UserBoard::getUserBoardURL($user_name) . '">' . wfMessage('user-view-all')->escaped() . '</a>';
        }
        $output .= '</div>
				<div class="action-left">';
        if ($total > 10) {
            $output .= wfMessage('user-count-separator', '10', $total)->escaped();
        } elseif ($total > 0) {
            $output .= wfMessage('user-count-separator', $total, $total)->escaped();
        }
        $output .= '</div>
				<div class="cleared"></div>
			</div>
		</div>
		<div class="cleared"></div> <div class="panel-body">';
        if ($wgUser->getName() != $user_name) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
						<input type="hidden" id="user_name_to" name="user_name_to" value="' . addslashes($user_name) . '" />
						<span class="profile-board-message-type">' . wfMessage('userboard_messagetype')->escaped() . '</span>
						<select id="message_type">
							<option value="0">' . wfMessage('userboard_public')->escaped() . '</option>
							<option value="1">' . wfMessage('userboard_private')->escaped() . '</option>
						</select><p><div class="form-group" style="padding:14px;">
                                      <textarea class="form-control" name="message" id="message" placeholder=""></textarea>
                                    </div>
						
						<div class="user-page-message-box-button">
							<input type="button" value="' . wfMessage('userboard_sendbutton')->escaped() . '" class="site-button mw-ui-button mw-ui-progressive" />
						</div>
					</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMessage('user-board-login-message', $login_link->getFullURL())->escaped() . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        $b = new UserBoard();
        $output .= $b->displayMessages($user_id, 0, 10);
        $output .= '</div></div></div>';
        return $output;
    }
コード例 #20
0
function getRandomUser( $input, $args, $parser ) {
	global $wgMemc, $wgRandomFeaturedUser;

	wfProfileIn( __METHOD__ );

	$parser->disableCache();

	$period = ( isset( $args['period'] ) ) ? $args['period'] : '';
	if( $period != 'weekly' && $period != 'monthly' ) {
		return '';
	}

	$user_list = array();
	$count = 20;
	$realCount = 10;

	// Try cache
	$key = wfMemcKey( 'user_stats', 'top', 'points', 'weekly', $realCount );
	$data = $wgMemc->get( $key );

	if( $data != '' ) {
		wfDebug( "Got top $period users by points ({$count}) from cache\n" );
		$user_list = $data;
	} else {
		wfDebug( "Got top $period users by points ({$count}) from DB\n" );

		$dbr = wfGetDB( DB_SLAVE );
		$res = $dbr->select(
			'user_points_' . $period,
			array( 'up_user_id', 'up_user_name', 'up_points' ),
			array( 'up_user_id <> 0' ),
			__METHOD__,
			array(
				'ORDER BY' => 'up_points DESC',
				'LIMIT' => $count
			)
		);
		$loop = 0;
		foreach( $res as $row ) {
			// Prevent blocked users from appearing
			$user = User::newFromId( $row->up_user_id );
			if( !$user->isBlocked() ) {
				$user_list[] = array(
					'user_id' => $row->up_user_id,
					'user_name' => $row->up_user_name,
					'points' => $row->up_points
				);
				$loop++;
			}
			if( $loop >= 10 ) {
				break;
			}
		}

		if( count( $user_list ) > 0 ) {
			$wgMemc->set( $key, $user_list, 60 * 60 );
		}
	}

	// Make sure we have some data
	if( !is_array( $user_list ) || count( $user_list ) == 0 ) {
		return '';
	}

	$random_user = $user_list[array_rand( $user_list, 1 )];

	// Make sure we have a user
	if( !$random_user['user_id'] ) {
		return '';
	}

	$output = '<div class="random-featured-user">';

	if( $wgRandomFeaturedUser['points'] == true ) {
		$stats = new UserStats( $random_user['user_id'], $random_user['user_name'] );
		$stats_data = $stats->getUserStats();
		$points = $stats_data['points'];
	}

	if( $wgRandomFeaturedUser['avatar'] == true ) {
		$user_title = Title::makeTitle( NS_USER, $random_user['user_name'] );
		$avatar = new wAvatar( $random_user['user_id'], 'ml' );
		$avatarImage = $avatar->getAvatarURL();

		$output .= "<a href=\"{$user_title->escapeFullURL()}\">{$avatarImage}</a>\n";
	}

	$output .= "<div class=\"random-featured-user-title\">
					<a href=\"{$user_title->escapeFullURL()}\">" .
					wordwrap( $random_user['user_name'], 12, "<br />\n", true ) .
					"</a><br /> $points " .
				wfMsg( "random-user-points-{$period}" ) .
			"</div>\n\n";

	if( $wgRandomFeaturedUser['about'] == true ) {
		$p = new Parser();
		$profile = new UserProfile( $random_user['user_name'] );
		$profile_data = $profile->getProfile();
		$about = ( isset( $profile_data['about'] ) ) ? $profile_data['about'] : '';
		// Remove templates
		$about = preg_replace( '@{{.*?}}@si', '', $about );
		if( !empty( $about ) ) {
			global $wgTitle, $wgOut;
			$output .= '<div class="random-featured-user-about-title">' .
				wfMsg( 'random-user-about-me' ) . '</div>' .
				$p->parse( $about, $wgTitle, $wgOut->parserOptions(), false )->getText();
		}
	}

	$output .= '</div><div class="cleared"></div>';

	wfProfileOut( __METHOD__ );

	return $output;
}
コード例 #21
0
    /**
     * Get the user board for a given user.
     *
     * @param $user_id Integer: user's ID number
     * @param $user_name String: user name
     */
    function getUserBoard($user_id, $user_name)
    {
        global $wgUser, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts;
        // Anonymous users cannot have user boards
        if ($user_id == 0) {
            return '';
        }
        // Don't display anything if user board on social profiles isn't
        // enabled in site configuration
        if ($wgUserProfileDisplay['board'] == false) {
            return '';
        }
        $output = '';
        // Prevent E_NOTICE
        $wgOut->addScriptFile($wgUserProfileScripts . '/UserProfilePage.js');
        $rel = new UserRelationship($user_name);
        $friends = $rel->getRelationshipList(1, 4);
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $total = $stats_data['user_board'];
        // If the user is viewing their own profile or is allowed to delete
        // board messages, add the amount of private messages to the total
        // sum of board messages.
        if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
            $total = $total + $stats_data['user_board_priv'];
        }
        $output .= '<div class="user-section-heading">
			<div class="user-section-title">' . wfMsg('user-board-title') . '</div>
			<div class="user-section-actions">
				<div class="action-right">';
        if ($wgUser->getName() == $user_name) {
            if ($friends) {
                $output .= '<a href="' . UserBoard::getBoardBlastURL() . '">' . wfMsg('user-send-board-blast') . '</a>';
            }
            if ($total > 10) {
                $output .= wfMsgExt('pipe-separator', 'escapenoentities');
            }
        }
        if ($total > 10) {
            $output .= '<a href="' . UserBoard::getUserBoardURL($user_name) . '">' . wfMsg('user-view-all') . '</a>';
        }
        $output .= '</div>
				<div class="action-left">';
        if ($total > 10) {
            $output .= wfMsg('user-count-separator', '10', $total);
        } elseif ($total > 0) {
            $output .= wfMsg('user-count-separator', $total, $total);
        }
        $output .= '</div>
				<div class="cleared"></div>
			</div>
		</div>
		<div class="cleared"></div>';
        if ($wgUser->getName() !== $user_name) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
						<input type="hidden" id="user_name_to" name="user_name_to" value="' . addslashes($user_name) . '" />
						<span style="color:#797979;">' . wfMsgHtml('userboard_messagetype') . '</span>
						<select id="message_type">
							<option value="0">' . wfMsgHtml('userboard_public') . '</option>
							<option value="1">' . wfMsgHtml('userboard_private') . '</option>
						</select><p>
						<textarea name="message" id="message" cols="43" rows="4"/></textarea>
						<div class="user-page-message-box-button">
							<input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:send_message();" />
						</div>
					</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMsg('user-board-login-message', $login_link->escapeFullURL()) . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        $b = new UserBoard();
        $output .= $b->displayMessages($user_id, 0, 10);
        $output .= '</div>';
        return $output;
    }
コード例 #22
0
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        $out = $this->getOutput();
        $request = $this->getRequest();
        $currentUser = $this->getUser();
        // Set the page title, robot policies, etc.
        $this->setHeaders();
        // Add CSS & JS
        $out->addModuleStyles('ext.socialprofile.userboard.css');
        $out->addModules('ext.socialprofile.userboard.js');
        $ub_messages_show = 25;
        $user_name = $request->getVal('user');
        $user_name_2 = $request->getVal('conv');
        $user_id_2 = '';
        // Prevent E_NOTICE
        $page = $request->getInt('page', 1);
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the UserBoard page
         */
        if ($currentUser->getID() == 0 && $user_name == '') {
            $login = SpecialPage::getTitleFor('Userlogin');
            $out->redirect($login->getFullURL('returnto=Special:UserBoard'));
            return false;
        }
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $currentUser->getName();
        }
        $user_id = User::idFromName($user_name);
        $user = Title::makeTitle(NS_USER, $user_name);
        if ($user_name_2) {
            $user_id_2 = User::idFromName($user_name_2);
            $user_2 = Title::makeTitle(NS_USER, $user_name);
        }
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $out->showErrorPage('error', 'userboard_noexist');
            return false;
        }
        /**
         * Config for the page
         */
        $per_page = $ub_messages_show;
        $b = new UserBoard();
        $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
        if (!$user_id_2) {
            $stats = new UserStats($user_id, $user_name);
            $stats_data = $stats->getUserStats();
            $total = $stats_data['user_board'];
            // If user is viewing their own board or is allowed to delete
            // others' board messages, show the total count of board messages
            // to them (public + private messages)
            if ($currentUser->getName() == $user_name || $currentUser->isAllowed('userboard-delete')) {
                $total = $total + $stats_data['user_board_priv'];
            }
        } else {
            $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
        }
        if (!$user_id_2) {
            if (!($currentUser->getName() == $user_name)) {
                $out->setPageTitle($this->msg('userboard_owner', $user_name)->parse());
            } else {
                $b->clearNewMessageCount($currentUser->getID());
                $out->setPageTitle($this->msg('userboard_yourboard')->parse());
            }
        } else {
            if ($currentUser->getName() == $user_name) {
                $out->setPageTitle($this->msg('userboard_yourboardwith', $user_name_2)->parse());
            } else {
                $out->setPageTitle($this->msg('userboard_otherboardwith', $user_name, $user_name_2)->parse());
            }
        }
        $output = '<div class="user-board-top-links">';
        $output .= '<a href="' . htmlspecialchars($user->getFullURL()) . '">&lt; ' . $this->msg('userboard_backprofile', $user_name)->parse() . '</a>';
        $output .= '</div>';
        $board_to_board = '';
        // Prevent E_NOTICE
        if ($page == 1) {
            $start = 1;
        } else {
            $start = ($page - 1) * $per_page + 1;
        }
        $end = $start + count($ub_messages) - 1;
        if ($currentUser->getName() != $user_name) {
            $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($currentUser->getName(), $user_name) . '">' . $this->msg('userboard_boardtoboard')->plain() . '</a>';
        }
        if ($total) {
            $output .= '<div class="user-page-message-top">
			<span class="user-page-message-count">' . $this->msg('userboard_showingmessages', $total, $start, $end, $end - $start + 1)->parse() . "</span> {$board_to_board}\n\t\t\t</div>";
        }
        /**
         * Build next/prev navigation links
         */
        $qs = array();
        if ($user_id_2) {
            $qs['conv'] = $user_name_2;
        }
        $numofpages = $total / $per_page;
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= Linker::link($this->getPageTitle(), $this->msg('userboard_prevpage')->plain(), array(), array('user' => $user_name, 'page' => $page - 1) + $qs);
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
                if ($numofpages >= $total / $per_page) {
                    $numofpages = $total / $per_page + 1;
                }
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= Linker::link($this->getPageTitle(), $i, array(), array('user' => $user_name, 'page' => $i) + $qs) . $this->msg('word-separator')->plain();
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= $this->msg('word-separator')->plain() . Linker::link($this->getPageTitle(), $this->msg('userboard_nextpage')->plain(), array(), array('user' => $user_name, 'page' => $page + 1) + $qs);
            }
            $output .= '</div><p>';
        }
        $can_post = false;
        $user_name_from = '';
        // Prevent E_NOTICE
        if (!$user_id_2) {
            if ($currentUser->getName() != $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name, ENT_QUOTES);
            }
        } else {
            if ($currentUser->getName() == $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name_2, ENT_QUOTES);
                $user_name_from = htmlspecialchars($user_name, ENT_QUOTES);
            }
        }
        if ($currentUser->isBlocked()) {
            // only let them post to admins
            //$user_to = User::newFromId( $user_id );
            // if( !$user_to->isAllowed( 'delete' ) ) {
            $can_post = false;
            // }
        }
        if ($can_post) {
            if ($currentUser->isLoggedIn() && !$currentUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
					<input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
					<input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
					<span class="user-board-message-type">' . $this->msg('userboard_messagetype')->plain() . ' </span>
					<select id="message_type">
						<option value="0">' . $this->msg('userboard_public')->plain() . '</option>
						<option value="1">' . $this->msg('userboard_private')->plain() . '</option>
					</select>
					<p>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>

					<div class="user-page-message-box-button">
						<input type="button" value="' . $this->msg('userboard_sendbutton')->plain() . '" class="site-button" data-per-page="' . $per_page . '" />
					</div>

				</div>';
            } else {
                $output .= '<div class="user-page-message-form">' . $this->msg('userboard_loggedout')->parse() . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        if ($ub_messages) {
            foreach ($ub_messages as $ub_message) {
                $user = Title::makeTitle(NS_USER, $ub_message['user_name_from']);
                $avatar = new wAvatar($ub_message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $ub_message_type_label = '';
                $delete_link = '';
                if ($currentUser->getName() != $ub_message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from']) . '">' . $this->msg('userboard_boardtoboard')->plain() . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . $this->msg('userboard_sendmessage', $ub_message['user_name_from'])->parse() . '</a>';
                } else {
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . $this->msg('userboard_myboard')->plain() . '</a>';
                }
                // If the user owns this private message or they are allowed to
                // delete board messages, show the "delete" link to them
                if ($currentUser->getName() == $ub_message['user_name'] || $currentUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" data-message-id=\"{$ub_message['id']}\">" . $this->msg('userboard_delete')->plain() . '</a>
					</span>';
                }
                // Mark private messages as such
                if ($ub_message['type'] == 1) {
                    $ub_message_type_label = '(' . $this->msg('userboard_private')->plain() . ')';
                }
                // had global function to cut link text if too long and no breaks
                // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
                $ub_message_text = $ub_message['message_text'];
                $userPageURL = htmlspecialchars($user->getFullURL());
                $output .= "<div class=\"user-board-message\">\n\t\t\t\t\t<div class=\"user-board-message-content\">\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\n\t\t\t\t\t\t\t<a href=\"{$userPageURL}\" title=\"{$ub_message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<a href=\"{$userPageURL}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}\n\t\t\t\t\t\t<div class=\"user-board-message-time\">" . $this->msg('userboard_posted_ago', $b->getTimeAgo($ub_message['timestamp']))->parse() . "</div>\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\n\t\t\t\t\t\t\t{$ub_message_text}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"cleared\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"user-board-message-links\">\n\t\t\t\t\t\t{$board_link}\n\t\t\t\t\t\t{$board_to_board}\n\t\t\t\t\t\t{$delete_link}\n\t\t\t\t\t</div>\n\t\t\t\t</div>";
            }
        } else {
            $output .= '<p>' . $this->msg('userboard_nomessages')->parse() . '</p>';
        }
        $output .= '</div>';
        $out->addHTML($output);
    }
コード例 #23
0
	/**
	 * Show the special page
	 *
	 * @param $params Mixed: parameter(s) passed to the page or null
	 */
	public function execute( $params ) {
		global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts, $wgLang;

		$wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' );

		$output = '';

		/**
		 * Get query string variables
		 */
		$user_name = $wgRequest->getVal( 'user' );
		$rel_type = $wgRequest->getInt( 'rel_type' );
		$page = $wgRequest->getInt( 'page' );

		/**
		 * Redirect Non-logged in users to Login Page
		 * It will automatically return them to the ViewRelationships page
		 */
		if ( !$wgUser->isLoggedIn() && $user_name == '' ) {
			$wgOut->setPageTitle( wfMsg( 'ur-error-page-title' ) );
			$login = SpecialPage::getTitleFor( 'Userlogin' );
			$wgOut->redirect( $login->escapeFullURL( 'returnto=Special:ViewRelationships' ) );
			return false;
		}

		/**
		 * Set up config for page / default values
		 */
		if ( !$page || !is_numeric( $page ) ) {
			$page = 1;
		}
		if ( !$rel_type || !is_numeric( $rel_type ) ) {
			$rel_type = 1;
		}
		$per_page = 50;
		$per_row = 2;

		/**
		 * If no user is set in the URL, we assume its the current user
		 */
		if ( !$user_name ) {
			$user_name = $wgUser->getName();
		}
		$user_id = User::idFromName( $user_name );
		$userPage = Title::makeTitle( NS_USER, $user_name );

		/**
		 * Error message for username that does not exist (from URL)
		 */
		if ( $user_id == 0 ) {
			$wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
			$out = '<div class="relationship-error-message">' .
				wfMsg( 'ur-error-message-no-user' ) .
			'</div>
			<div class="relationship-request-buttons">
				<input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
			if ( $wgUser->isLoggedIn() ) {
				$out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
			}
			$out .= '</div>';
			$wgOut->addHTML( $out );
			return false;
		}

		/**
		 * Get all relationships
		 */
		$rel = new UserRelationship( $user_name );
		$relationships = $rel->getRelationshipList( $rel_type, $per_page, $page );

		$stats = new UserStats( $rel->user_id, $rel->user_name );
		$stats_data = $stats->getUserStats();
		$friend_count = $stats_data['friend_count'];
		$foe_count = $stats_data['foe_count'];

		$back_link = Title::makeTitle( NS_USER, $rel->user_name );
		$inviteContactsLink = SpecialPage::getTitleFor( 'InviteContacts' );

		if ( $rel_type == 1 ) {
			$output .= $wgOut->setPageTitle( wfMsg( 'ur-title-friend', $rel->user_name ) );
			$total = $friend_count;
			$rem = wfMsg( 'ur-remove-relationship-friend' );
			$output .= '<div class="back-links">
			<a href="' . $back_link->escapeFullURL() . '">' .
				wfMsg( 'ur-backlink', $rel->user_name ) .
			'</a>
		</div>
		<div class="relationship-count">' .
			wfMsgExt(
				'ur-relationship-count-friends',
				'parsemag',
				$rel->user_name,
				$total,
				$inviteContactsLink->escapeFullURL()
			) . '</div>';
		} else {
			$output .= $wgOut->setPageTitle( wfMsg( 'ur-title-foe', $rel->user_name ) );
			$total = $foe_count;
			$rem = wfMsg( 'ur-remove-relationship-foe' );
			$output .= '<div class="back-links">
			<a href="' . $back_link->escapeFullURL() . '">' .
				wfMsg( 'ur-backlink', $rel->user_name ) .
			'</a>
		</div>
		<div class="relationship-count">'
			. wfMsgExt(
				'ur-relationship-count-foes',
				'parsemag',
				$rel->user_name,
				$total,
				$inviteContactsLink->escapeFullURL()
			) . '</div>';
		}

		if ( $relationships ) {
			$x = 1;

			foreach ( $relationships as $relationship ) {
				$indivRelationship = UserRelationship::getUserRelationshipByID(
					$relationship['user_id'],
					$wgUser->getID()
				);

				// Safe titles
				$userPage = Title::makeTitle( NS_USER, $relationship['user_name'] );
				$addRelationshipLink = SpecialPage::getTitleFor( 'AddRelationship' );
				$removeRelationshipLink = SpecialPage::getTitleFor( 'RemoveRelationship' );
				$giveGiftLink = SpecialPage::getTitleFor( 'GiveGift' );

				$avatar = new wAvatar( $relationship['user_id'], 'ml' );

				$avatar_img = $avatar->getAvatarURL();

				$user_safe = urlencode( $relationship['user_name'] );

				$username_length = strlen( $relationship['user_name'] );
				$username_space = stripos( $relationship['user_name'], ' ' );

				if ( ( $username_space == false || $username_space >= "30" ) && $username_length > 30 ) {
					$user_name_display = substr( $relationship['user_name'], 0, 30 ) .
						' ' . substr( $relationship['user_name'], 30, 50 );
				} else {
					$user_name_display = $relationship['user_name'];
				}

				$output .= "<div class=\"relationship-item\">
					<a href=\"{$userPage->escapeFullURL()}\">{$avatar_img}</a>
					<div class=\"relationship-info\">
						<div class=\"relationship-name\">
							<a href=\"{$userPage->escapeFullURL()}\">{$user_name_display}</a>
						</div>
					<div class=\"relationship-actions\">";
				if ( $indivRelationship == false ) {
					$output .= $wgLang->pipeList( array(
						'<a href="' . $addRelationshipLink->escapeFullURL( 'user='******'&rel_type=1' ) . '">' . wfMsg( 'ur-add-friend' ) . '</a>',
						'<a href="' . $addRelationshipLink->escapeFullURL( 'user='******'&rel_type=2' ) . '">' . wfMsg( 'ur-add-foe' ) . '</a>',
						''
					) );
				} elseif ( $user_name == $wgUser->getName() ) {
					$output .= '<a href="' . $removeRelationshipLink->escapeFullURL( 'user='******'">' . $rem . '</a>';
					$output .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
				}
				$output .= '<a href="' . $giveGiftLink->escapeFullURL( 'user='******'">' . wfMsg( 'ur-give-gift' ) . '</a>';

				$output .= '</div>
					<div class="cleared"></div>
				</div>';

				$output .= '</div>';
				if ( $x == count( $relationships ) || $x != 1 && $x % $per_row == 0 ) {
					$output .= '<div class="cleared"></div>';
				}
				$x++;
			}
		}

		/**
		 * Build next/prev nav
		 */
		$total = intval( str_replace( ',', '', $total ) );
		$numofpages = $total / $per_page;

		$pageLink = SpecialPage::getTitleFor( 'ViewRelationships' );

		if ( $numofpages > 1 ) {
			$output .= '<div class="page-nav">';
			if ( $page > 1 ) {
				$output .= '<a href="' . $pageLink->escapeFullURL( 'user='******'&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'ur-previous' ) . '</a> ';
			}

			if ( ( $total % $per_page ) != 0 ) {
				$numofpages++;
			}
			if ( $numofpages >= 9 && $page < $total ) {
				$numofpages = 9 + $page;
			}
			if ( $numofpages >= ( $total / $per_page ) ) {
				$numofpages = ( $total / $per_page ) + 1;
			}

			for ( $i = 1; $i <= $numofpages; $i++ ) {
				if ( $i == $page ) {
					$output .= ( $i . ' ' );
				} else {
					$output .= '<a href="' . $pageLink->escapeFullURL( 'user='******'&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> ";
				}
			}

			if ( ( $total - ( $per_page * $page ) ) > 0 ) {
				$output .= ' <a href="' . $pageLink->escapeFullURL( 'user='******'&rel_type=' . $rel_type . '&page=' . ( $page + 1 ) ) . '">' . wfMsg( 'ur-next' ) . '</a>';
			}
			$output .= '</div>';
		}

		$wgOut->addHTML( $output );
	}
コード例 #24
0
 /**
  * get user stats
  * @param  string $prefix if $prefix is null, return this user stats of all sites, else return the prefix stats
  * @return array
  */
 public function getStats($prefix = '')
 {
     $statsObj = new UserStats($this->mUser->getId(), $this->mUser->getName());
     if ($prefix === '') {
         return $statsObj->getUserStats();
     } else {
         $result = array();
         $result['edits'] = $statsObj->getSiteEditsCount($this->mUser, $prefix);
         return $result;
     }
     // getSiteEditsCount( $user, $prefix )
 }
コード例 #25
0
 /**
  * Updates the total amount of points the user has.
  *
  * @return Array
  */
 public function updateTotalPoints()
 {
     global $wgEnableFacebook, $wgUserLevels;
     if ($this->user_id == 0) {
         return array();
     }
     $stats_data = array();
     if (is_array($wgUserLevels)) {
         // Load points before update
         $stats = new UserStats($this->user_id, $this->user_name);
         $stats_data = $stats->getUserStats();
         $points_before = $stats_data['points'];
         // Load Honorific Level before update
         $user_level = new UserLevel($points_before);
         $level_number_before = $user_level->getLevelNumber();
     }
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->select('user_stats', '*', array("stats_user_id = {$this->user_id}"), __METHOD__);
     $row = $dbw->fetchObject($res);
     if ($row) {
         // recaculate point total
         $new_total_points = 1000;
         if ($this->point_values) {
             foreach ($this->point_values as $point_field => $point_value) {
                 if ($this->stats_fields[$point_field]) {
                     $field = $this->stats_fields[$point_field];
                     $new_total_points += $point_value * $row->{$field};
                 }
             }
         }
         if ($wgEnableFacebook) {
             $s = $dbw->selectRow('fb_link_view_opinions', array('fb_user_id', 'fb_user_session_key'), array('fb_user_id_wikia' => $this->user_id), __METHOD__);
             if ($s !== false) {
                 $new_total_points += $this->point_values['facebook'];
             }
         }
         $dbw->update('user_stats', array('stats_total_points' => $new_total_points), array('stats_user_id' => $this->user_id), __METHOD__);
         // If user levels is in settings, check to see if user advanced with update
         if (is_array($wgUserLevels)) {
             // Get New Honorific Level
             $user_level = new UserLevel($new_total_points);
             $level_number_after = $user_level->getLevelNumber();
             // Check if the user advanced to a new level on this update
             if ($level_number_after > $level_number_before) {
                 $m = new UserSystemMessage();
                 $m->addMessage($this->user_name, 2, wfMessage('level-advanced-to', $user_level->getLevelName())->inContentLanguage()->parse());
                 $m->sendAdvancementNotificationEmail($this->user_id, $user_level->getLevelName());
             }
         }
         $this->clearCache();
     }
     return $stats_data;
 }
コード例 #26
0
	/**
	 * Show the special page
	 *
	 * @param $par Mixed: parameter passed to the special page or null
	 */
	public function execute( $par ) {
		global $wgRequest, $wgOut, $wgUser, $wgScriptPath;

		$messages_show = 25;
		$output = '';
		$user_name = $wgRequest->getVal( 'user', $par );
		$page = $wgRequest->getInt( 'page', 1 );

		/**
		 * Redirect Non-logged in users to Login Page
		 * It will automatically return them to their Status page
		 */
		if( $wgUser->getID() == 0 && $user_name == '' ) {
			$wgOut->setPageTitle( wfMsg( 'userstatus-woops' ) );
			$login = SpecialPage::getTitleFor( 'Userlogin' );
			$wgOut->redirect( $login->getFullURL( 'returnto=Special:UserStatus' ) );
			return false;
		}

		/**
		 * If no user is set in the URL, we assume its the current user
		 */
		if( !$user_name ) {
			$user_name = $wgUser->getName();
		}
		$user_id = User::idFromName( $user_name );
		$user = Title::makeTitle( NS_USER, $user_name );

		/**
		 * Error message for username that does not exist (from URL)
		 */
		if( $user_id == 0 ) {
			$wgOut->setPageTitle( wfMsg( 'userstatus-woops' ) );
			$wgOut->addHTML( wfMsg( 'userstatus-no-user' ) );
			return false;
		}

		/**
		 * Config for the page
		 */
		$per_page = $messages_show;

		$stats = new UserStats( $user_id, $user_name );
		$stats_data = $stats->getUserStats();
		$total = $stats_data['user_status_count'];

		$s = new UserStatus();
		$messages = $s->getStatusMessages( $user_id, 0, 0, $messages_show, $page );

		if ( !( $wgUser->getName() == $user_name ) ) {
			$wgOut->setPageTitle( wfMsg( 'userstatus-user-thoughts', $user_name ) );
		} else {
			$wgOut->setPageTitle( wfMsg( 'userstatus-your-thoughts' ) );
		}

		$output .= '<div class="gift-links">';
		if ( !( $wgUser->getName() == $user_name ) ) {
			$output .= "<a href=\"{$user->getFullURL()}\">" .
				wfMsg( 'userstatus-back-user-profile', $user_name ) . '</a>';
		} else {
			$output .= '<a href="' . $wgUser->getUserPage()->getFullURL() . '">' .
				wfMsg( 'userstatus-back-your-profile' ) . '</a>';
		}
		$output .= '</div>';

		if( $page == 1 ) {
			$start = 1;
		} else {
			$start = ( $page - 1 ) * $per_page + 1;
		}

		$end = $start + ( count( $messages ) ) - 1;
		wfDebug( "total = {$total}" );

		if( $total ) {
			$output .= '<div class="user-page-message-top">
				<span class="user-page-message-count" style="font-size: 11px; color: #666666;">' .
					wfMsgExt( 'userstatus-showing-thoughts', 'parsemag', $start, $end, $total ) .
				'</span>
			</div>';
		}

		/**
		 * Build next/prev navigation
		 */
		$numofpages = $total / $per_page;

		if( $numofpages > 1 ) {
			$output .= '<div class="page-nav">';
			if( $page > 1 ) {
				$output .= '<a href="' . $this->getTitle()->getFullURL( array(
					'user' => $user_name, 'page' => ( $page - 1 ) ) ) . '">' .
					wfMsg( 'userstatus-prev' ) . '</a> ';
			}

			if( ( $total % $per_page ) != 0 ) {
				$numofpages++;
			}
			if( $numofpages >= 9 && $page < $total ) {
				$numofpages = 9 + $page;
				if( $numofpages >= ( $total / $per_page ) ) {
					$numofpages = ( $total / $per_page ) + 1;
				}
			}

			for( $i = 1; $i <= $numofpages; $i++ ) {
				if( $i == $page ) {
					$output .= ( $i . ' ' );
				} else {
					$output .= '<a href="' . $this->getTitle()->getFullURL(
						array( 'user' => $user_name, 'page' => $i ) ) .
						"\">$i</a> ";
				}
			}

			if( ( $total - ( $per_page * $page ) ) > 0 ) {
				$output .= ' <a href="' . $this->getTitle()->getFullURL( array(
					'user' => $user_name, 'page' => ( $page + 1 ) ) ) . '">' .
					wfMsg( 'userstatus-next' ) . '</a>';
			}
			$output .= '</div><p>';
		}

		// Add CSS & JS
		if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
			$wgOut->addModuleStyles( 'ext.userStatus' );
			$wgOut->addModuleScripts( 'ext.userStatus' );
		} else {
			$wgOut->addExtensionStyle( $wgScriptPath . '/extensions/UserStatus/UserStatus.css' );
			$wgOut->addScriptFile( $wgScriptPath . '/extensions/UserStatus/UserStatus.js' );
		}

		$output .= '<div class="user-status-container">';
		$thought_link = SpecialPage::getTitleFor( 'ViewThought' );
		if( $messages ) {
			foreach ( $messages as $message ) {
				$user = Title::makeTitle( NS_USER, $message['user_name'] );
				$avatar = new wAvatar( $message['user_id'], 'm' );

				$network_link = '<a href="' . SportsTeams::getNetworkURL( $message['sport_id'], $message['team_id'] ) . '">' .
					wfMsg( 'userstatus-all-team-updates', SportsTeams::getNetworkName( $message['sport_id'], $message['team_id'] ) ) .
				'</a>';

				$delete_link = '';
				if( $wgUser->getName() == $message['user_name'] ) {
					$delete_link = "<span class=\"user-board-red\">
						<a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message['id']})\">" .
						wfMsg( 'userstatus-delete-thought-text' ) ."</a>
					</span>";
				}

				$message_text = preg_replace_callback(
					'/(<a[^>]*>)(.*?)(<\/a>)/i',
					array( 'UserStatus', 'cutLinkText' ),
					$message['text']
				);
				$vote_count = wfMsgExt( 'userstatus-num-agree', 'parsemag', $message['plus_count'] );

				$vote_link = '';
				if( $wgUser->isLoggedIn() && $wgUser->getName() != $message['user_name'] ) {
					if( !$message['voted'] ) {
						$vote_link = "<a href=\"javascript:void(0);\" onclick=\"vote_status({$message['id']},1)\">[" .
							wfMsg( 'userstatus-_agree' ) . "]</a>";
					} else {
						$vote_link = $vote_count;
					}
				}

				$view_thought_link = '<a href="' . $thought_link->getFullURL( "id={$message['id']}" ) . '">[' .
					wfMsg( 'userstatus-see-who-agrees' ) . ']</a>';

				$output .= '<div class="user-status-row">

					<div class="user-status-logo">

						<a href="' . SportsTeams::getNetworkURL( $message['sport_id'], $message['team_id'] ) . '">' .
							SportsTeams::getLogo( $message['sport_id'], $message['team_id'], 'm' ) .
						"</a>

					</div>

					<div class=\"user-status-message\">

						{$message_text}

						<div class=\"user-status-date\">" . 
							wfMsg( 'userstatus-ago', UserStatus::getTimeAgo( $message['timestamp'] ) ) .
							"<span class=\"user-status-vote\" id=\"user-status-vote-{$message['id']}\">
								{$vote_link}
							</span>
							{$view_thought_link}
							<span class=\"user-status-links\">
								{$delete_link}
							</span>
						</div>

					</div>

					<div class=\"cleared\"></div>

				</div>";
			}
		} else {
			$output .= '<p>' . wfMsg( 'userstatus-no-updates' ) . '</p>';
		}

		$output .= '</div>';

		$wgOut->addHTML( $output );
	}