public function execute() { $user = $this->getUser(); // Blocked users cannot submit new comments, and neither can those users // without the necessary privileges. Also prevent obvious cross-site request // forgeries (CSRF) $id = $this->getMain()->getVal('userid'); $name = $this->getMain()->getVal('username'); $size = $this->getMain()->getVal('size'); if ($id == '') { if ($name != '') { $id = User::idFromName($name); } else { $id = 0; } } if ($size = '') { $size = 'l'; } $avatar = new wAvatar($id, $size); $responseBody = array('state' => 200, 'message' => '', 'html' => $avatar->getAvatarHtml(), 'url' => $avatar->getAvatarUrlPath()); $result = $this->getResult(); $result->addValue($this->getModuleName(), 'res', $responseBody); return true; }
/** * Show the special page * * @param $params Mixed: parameter(s) passed to the page or null */ public function execute($params) { $out = $this->getOutput(); $user = $this->getUser(); // Set the page title, robot policies, etc. $this->setHeaders(); /** * Redirect anonymous users to the login page * It will automatically return them to the ViewRelationshipRequests page */ if (!$user->isLoggedIn()) { $out->setPageTitle($this->msg('ur-error-page-title')->plain()); $login = SpecialPage::getTitleFor('Userlogin'); $out->redirect($login->getFullURL('returnto=Special:ViewRelationshipRequests')); return false; } // Add CSS & JS $out->addModuleStyles('ext.socialprofile.userrelationship.css'); $out->addModules('ext.socialprofile.userrelationship.js'); $rel = new UserRelationship($user->getName()); $friend_request_count = $rel->getOpenRequestCount($user->getID(), 1); $foe_request_count = $rel->getOpenRequestCount($user->getID(), 2); if ($this->getRequest()->wasPosted() && $_SESSION['alreadysubmitted'] == false) { $_SESSION['alreadysubmitted'] = true; $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST['message']); $output = '<br /><span class="title">' . $this->msg('ur-already-submitted')->plain() . '</span><br /><br />'; $out->addHTML($output); } else { $_SESSION['alreadysubmitted'] = false; $output = ''; $out->setPageTitle($this->msg('ur-requests-title')->plain()); $requests = $rel->getRequestList(0); if ($requests) { foreach ($requests as $request) { $user_from = Title::makeTitle(NS_USER, $request['user_name_from']); $avatar = new wAvatar($request['user_id_from'], 'l'); $avatar_img = $avatar->getAvatarURL(); if ($request['type'] == 'Foe') { $msg = $this->msg('ur-requests-message-foe', htmlspecialchars($user_from->getFullURL()), $request['user_name_from'])->text(); } else { $msg = $this->msg('ur-requests-message-friend', htmlspecialchars($user_from->getFullURL()), $request['user_name_from'])->text(); } $message = $out->parse(trim($request['message']), false); $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request['id']}\">\n\t\t\t\t\t \t{$avatar_img}" . $msg; if ($request['message']) { $output .= '<div class="relationship-message">' . $message . '</div>'; } $output .= '<div class="cleared"></div> <div class="relationship-buttons"> <input type="button" class="site-button" value="' . $this->msg('ur-accept')->plain() . '" data-response="1" /> <input type="button" class="site-button" value="' . $this->msg('ur-reject')->plain() . '" data-response="-1" /> </div> </div>'; } } else { $output = $this->msg('ur-no-requests-message')->parse(); } $out->addHTML($output); } }
function wfRelationshipRequestResponse($response, $requestId) { global $wgUser; $out = ''; $rel = new UserRelationship($wgUser->getName()); if ($rel->verifyRelationshipRequest($requestId) == true) { $request = $rel->getRequest($requestId); $user_name_from = $request[0]['user_name_from']; $user_id_from = User::idFromName($user_name_from); $rel_type = strtolower($request[0]['type']); $response = isset($_POST['response']) ? $_POST['response'] : $response; $rel->updateRelationshipRequestStatus($requestId, intval($response)); $avatar = new wAvatar($user_id_from, 'l'); $avatar_img = $avatar->getAvatarURL(); if ($response == 1) { $rel->addRelationship($requestId); $out .= "<div class=\"relationship-action red-text\">\n\t\t\t\t{$avatar_img}" . wfMessage("ur-requests-added-message-{$rel_type}", $user_name_from)->escaped() . '<div class="cleared"></div> </div>'; } else { $out .= "<div class=\"relationship-action red-text\">\n\t\t\t\t{$avatar_img}" . wfMessage("ur-requests-reject-message-{$rel_type}", $user_name_from)->escaped() . '<div class="cleared"></div> </div>'; } $rel->deleteRequest($requestId); } return $out; }
/** * Get the given amount of top users for the given timeframe. * * @return String: HTML */ function getTopUsersForTag($input, $args, $parser) { global $wgLang; // Don't allow showing OVER 9000...I mean, over 50 users, duh. // Performance and all that stuff. if (!empty($args['limit']) && is_numeric($args['limit']) && $args['limit'] < 50) { $limit = intval($args['limit']); } else { $limit = 5; } if (!empty($args['period']) && strtolower($args['period']) == 'monthly') { $period = 'monthly'; } else { // "period" argument not supplied/it's not "monthly", so assume weekly $period = 'weekly'; } $fans = UserStats::getTopFansListPeriod($limit, $period); $x = 1; $topfans = ''; foreach ($fans as $fan) { $avatar = new wAvatar($fan['user_id'], 'm'); $user = Title::makeTitle(NS_USER, $fan['user_name']); $topfans .= "<div class=\"top-fan\">\n\t\t\t\t<span class=\"top-fan-number\">{$x}.</span>\n\t\t\t\t<a href=\"{$user->getFullURL()}\">{$avatar->getAvatarURL()}</a>\n\t\t\t\t<span class=\"top-fans-user\"><a href=\"{$user->getFullURL()}\">{$fan['user_name']}</a></span>\n\t\t\t\t<span class=\"top-fans-points\"><b>+" . $wgLang->formatNum($fan['points']) . '</b> ' . wfMessage('top-fans-points')->plain() . '</span> </div>'; $x++; } return $topfans; }
function execute() { global $wgUser, $wgOut; $wgOut->setPagetitle("Top Users"); $dbr =& wfGetDB(DB_MASTER); $sql = "SELECT stats_user_id,stats_user_name, stats_total_points from user_stats where stats_year_id = 1 and stats_user_id <> 0 ORDER BY stats_total_points DESC LIMIT 0,50"; $res = $dbr->query($sql); $header = wfMsg("topusersheader"); if ($header != "<topusersheader>") { $out = $header; } // $out = "<span style='font-size:11px;color:#666666;'>Here are the top users since the new \"season\" started on March 7th, 2007. Points are based on a super secret formula.<p><a href=\"index.php?title=ArmchairGM Top Users: Year 1\">Click here for the Top Users of the Inaugural Year</a></span><p>"; $x = 1; $out .= "<div class=\"top-users\">\n <div class=\"top-user-header\"><span class=\"top-user-num\">#</span><span class=\"top-user\">User</span><span class=\"top-user-points\">Points</span></div>"; while ($row = $dbr->fetchObject($res)) { $user_name = $row->stats_user_name; $user_title = Title::makeTitle(NS_USER, $row->stats_user_name); $avatar = new wAvatar($row->stats_user_id, "s"); $CommentIcon = $avatar->getAvatarImage(); $out .= "<div class=\"top-user-row\">\n\t \t\t<span class=\"top-user-num\">{$x}</span><span class=\"top-user\"><img src='images/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->getFullURL() . "' class=\"top-user-link\">" . $row->stats_user_name . "</a><a href='" . $user_title->getTalkPage()->getFullURL() . "' class=\"top-user-talk\"><img src=\"images/commentIcon.gif\" border=\"0\" hspace=\"3\" align=\"middle\" alt=\"\" /></a>\n\t\t\t</span>"; $out .= "<span class=\"top-user-points\">" . $row->stats_total_points . "</span>\n\t \t</div>"; $x++; } $out .= "</div>"; $wgOut->addHTML($out); }
/** * Get comments of the day -- five newest comments within the last 24 hours * * @return String: HTML */ function getCommentsOfTheDay($input, $args, $parser) { global $wgMemc, $wgUploadPath; $oneDay = 60 * 60 * 24; // Try memcached first $key = wfMemcKey('comments-of-the-day', 'standalone-hook'); $data = $wgMemc->get($key); if ($data) { // success, got it from memcached! $commentsOfTheDay = $data; } elseif (!$data || $args['nocache']) { // just query the DB $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('Comments', 'page'), array('Comment_Username', 'comment_ip', 'comment_text', 'comment_date', 'Comment_user_id', 'CommentID', 'IFNULL(Comment_Plus_Count - Comment_Minus_Count,0) AS Comment_Score', 'Comment_Plus_Count AS CommentVotePlus', 'Comment_Minus_Count AS CommentVoteMinus', 'Comment_Parent_ID', 'page_title', 'page_namespace'), array('comment_page_id = page_id', 'UNIX_TIMESTAMP(comment_date) > ' . (time() - $oneDay)), __METHOD__, array('ORDER BY' => '(Comment_Plus_Count) DESC', 'LIMIT' => 5)); $commentsOfTheDay = array(); foreach ($res as $row) { $commentsOfTheDay[] = array('username' => $row->Comment_Username, 'userid' => $row->Comment_user_id, 'score' => $row->CommentVotePlus, 'text' => $row->comment_text, 'id' => $row->CommentID, 'pagens' => $row->page_namespace, 'pagetitle' => $row->page_title); } $wgMemc->set($key, $commentsOfTheDay, $oneDay); } $comments = ''; foreach ($commentsOfTheDay as $commentOfTheDay) { $title2 = Title::makeTitle($commentOfTheDay['pagens'], $commentOfTheDay['pagetitle']); if ($commentOfTheDay['userid'] != 0) { $title = Title::makeTitle(NS_USER, $commentOfTheDay['username']); $commentPoster_Display = $commentOfTheDay['username']; $commentPoster = '<a href="' . $title->getFullURL() . '" title="' . $title->getText() . '" rel="nofollow">' . $commentOfTheDay['username'] . '</a>'; $avatar = new wAvatar($commentOfTheDay['userid'], 's'); $commentIcon = $avatar->getAvatarImage(); } else { $commentPoster_Display = wfMsg('comment-anon-name'); $commentPoster = wfMsg('comment-anon-name'); $commentIcon = 'default_s.gif'; } $comment_text = substr($commentOfTheDay['text'], 0, 50 - strlen($commentPoster_Display)); if ($comment_text != $commentOfTheDay['text']) { $comment_text .= wfMsg('ellipsis'); } $comments .= '<div class="cod">'; $sign = ''; if ($commentOfTheDay['score'] > 0) { $sign = '+'; } elseif ($commentOfTheDay['score'] < 0) { $sign = '-'; // this *really* shouldn't be happening... } $comments .= '<span class="cod-score">' . $sign . $commentOfTheDay['score'] . '</span> <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" align="middle" style="margin-bottom:8px;" border="0"/> <span class="cod-poster">' . $commentPoster . '</span>'; $comments .= '<span class="cod-comment"><a href="' . $title2->getFullURL() . '#comment-' . $commentOfTheDay['id'] . '" title="' . $title2->getText() . '">' . $comment_text . '</a></span>'; $comments .= '</div>'; } $output = ''; if (!empty($comments)) { $output .= $comments; } else { $output .= wfMsg('comments-no-comments-of-day'); } return $output; }
/** * Show the special page * * @param $params Mixed: parameter(s) passed to the page or null */ public function execute($params) { global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts; /** * Redirect Non-logged in users to Login Page * It will automatically return them to the ViewRelationshipRequests page */ if ($wgUser->getID() == 0) { $wgOut->setPageTitle(wfMsg('ur-error-page-title')); $login = SpecialPage::getTitleFor('Userlogin'); $wgOut->redirect($login->getFullURL('returnto=Special:ViewRelationshipRequests')); return false; } $wgOut->addScriptFile($wgUserRelationshipScripts . '/UserRelationship.js'); $wgOut->addExtensionStyle($wgUserRelationshipScripts . '/UserRelationship.css'); $rel = new UserRelationship($wgUser->getName()); $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1); $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2); if (count($_POST) && $_SESSION['alreadysubmitted'] == false) { $_SESSION['alreadysubmitted'] = true; $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST['message']); $out = '<br /><span class="title">' . wfMsg('ur-already-submitted') . '</span><br /><br />'; $wgOut->addHTML($out); } else { $_SESSION['alreadysubmitted'] = false; $output = ''; $wgOut->setPageTitle(wfMsg('ur-requests-title')); $requests = $rel->getRequestList(0); if ($requests) { foreach ($requests as $request) { $user_from = Title::makeTitle(NS_USER, $request['user_name_from']); $avatar = new wAvatar($request['user_id_from'], 'l'); $avatar_img = $avatar->getAvatarURL(); if ($request['type'] == 'Foe') { $msg = wfMsg('ur-requests-message-foe', $user_from->escapeFullURL(), $request['user_name_from']); } else { $msg = wfMsg('ur-requests-message-friend', $user_from->escapeFullURL(), $request['user_name_from']); } $message = $wgOut->parse(trim($request['message']), false); $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request['id']}\">\r\n\t\t\t\t\t \t{$avatar_img}" . $msg; if ($request['message']) { $output .= '<div class="relationship-message">' . $message . '</div>'; } $output .= '<div class="cleared"></div> <div class="relationship-buttons"> <input type="button" class="site-button" value="' . wfMsg('ur-accept') . '" onclick="javascript:requestResponse(1,' . $request['id'] . ')" /> <input type="button" class="site-button" value="' . wfMsg('ur-reject') . '" onclick="javascript:requestResponse(-1,' . $request['id'] . ')" /> </div> </div>'; } } else { $inviteLink = SpecialPage::getTitleFor('InviteContacts'); $output = wfMsg('ur-no-requests-message', $inviteLink->escapeFullURL()); } $wgOut->addHTML($output); } }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgRequest, $wgOut, $wgUser, $wgUploadPath, $wgScriptPath, $wgSystemGiftsScripts; // Variables $gift_name_check = ''; $x = 0; $category_number = $wgRequest->getInt('category'); // System gift class array $categories = array(array('category_name' => 'Edit', 'category_threshold' => '500', 'category_id' => 1), array('category_name' => 'Vote', 'category_threshold' => '2000', 'category_id' => 2), array('category_name' => 'Comment', 'category_threshold' => '1000', 'category_id' => 3), array('category_name' => 'Recruit', 'category_threshold' => '0', 'category_id' => 7), array('category_name' => 'Friend', 'category_threshold' => '25', 'category_id' => 8)); // Set title if (!$category_number || $category_number > 4) { $category_number = 0; $page_category = $categories[$category_number]['category_name']; } else { $page_category = $categories[$category_number]['category_name']; } // Database calls $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('user_system_gift', 'system_gift'), array('sg_user_name', 'sg_user_id', 'gift_category', 'MAX(gift_threshold) AS top_gift'), array("gift_category = {$categories[$category_number]['category_id']}", "gift_threshold > {$categories[$category_number]['category_threshold']}"), __METHOD__, array('GROUP BY' => 'sg_user_name', 'ORDER BY' => 'top_gift DESC'), array('system_gift' => array('INNER JOIN', 'gift_id=sg_gift_id'))); // Page title $wgOut->setPageTitle("Top Awards - {$page_category} Milestones"); // Add CSS $wgOut->addExtensionStyle($wgSystemGiftsScripts . '/SystemGift.css'); $output = '<div class="top-awards-navigation"> <h1>Award Categories</h1>'; $nav_x = 0; foreach ($categories as $award_type) { if ($nav_x == $category_number) { $output .= "<p><b>{$award_type['category_name']}s</b></p>"; } else { $output .= "<p><a href=\"" . $wgScriptPath . "/index.php?title=Special:TopAwards&category={$nav_x}\">{$award_type['category_name']}s</a></p>"; } $nav_x++; } $output .= '</div>'; $output .= '<div class="top-awards">'; foreach ($res as $row) { $user_name = $row->sg_user_name; $user_id = $row->sg_user_id; $avatar = new wAvatar($user_id, 'm'); $top_gift = $row->top_gift; $gift_name = number_format($top_gift) . " {$categories[$category_number][category_name]}" . ($top_gift > 1 ? 's' : '') . " Milestone"; if ($gift_name !== $gift_name_check) { $x = 1; $output .= "<div class=\"top-award-title\">\r\n\t\t\t\t\t{$gift_name}\r\n\t\t\t\t</div>"; } else { $x++; } $userLink = $wgUser->getSkin()->link(Title::makeTitle(NS_USER, $row->sg_user_name), $user_name); $output .= "<div class=\"top-award\">\r\n\t\t\t\t\t<span class=\"top-award-number\">{$x}.</span>\r\n\t\t\t\t\t{$avatar->getAvatarURL()}\r\n\t\t\t\t\t{$userLink}\r\n\t\t\t\t</div>"; $gift_name_check = $gift_name; } $output .= '</div> <div class="cleared"></div>'; $wgOut->addHTML($output); }
function wfGetUserAvatar($username) { if ($username == true) { $user_id = User::idFromName($username); $avatar = new wAvatar($user_id, 'm'); $useravatar = $avatar->getAvatarURL(); $ret = array('success' => true, 'result' => $useravatar); $out = json_encode($ret); return $out; } }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgSystemGiftsScripts; $wgOut->addExtensionStyle($wgSystemGiftsScripts . '/SystemGift.css'); $output = ''; // Prevent E_NOTICE // If gift ID wasn't passed in the URL parameters or if it's not // numeric, display an error message $giftId = $wgRequest->getInt('gift_id'); if (!$giftId || !is_numeric($giftId)) { $wgOut->setPageTitle(wfMsg('ga-error-title')); $wgOut->addHTML(wfMsg('ga-error-message-invalid-link')); return false; } $gift = UserSystemGifts::getUserGift($giftId); if ($gift) { if ($gift['status'] == 1) { if ($gift['user_name'] == $wgUser->getName()) { $g = new UserSystemGifts($gift['user_name']); $g->clearUserGiftStatus($gift['id']); $g->decNewSystemGiftCount($wgUser->getID()); } } // DB stuff $dbr = wfGetDB(DB_MASTER); $res = $dbr->select('user_system_gift', array('DISTINCT sg_user_name', 'sg_user_id', 'sg_gift_id', 'sg_date'), array("sg_gift_id = {$gift['gift_id']}", "sg_user_name <> '" . $dbr->strencode($gift['user_name']) . "'"), __METHOD__, array('GROUP BY' => 'sg_user_name', 'ORDER BY' => 'sg_date DESC', 'OFFSET' => 0, 'LIMIT' => 6)); $wgOut->setPageTitle(wfMsg('ga-gift-title', $gift['user_name'], $gift['name'])); $profileURL = Title::makeTitle(NS_USER, $gift['user_name'])->escapeFullURL(); $output .= '<div class="back-links">' . wfMsg('ga-back-link', $profileURL, $gift['user_name']) . '</div>'; $message = $wgOut->parse(trim($gift['description']), false); $output .= '<div class="ga-description-container">'; $giftImage = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($gift['gift_id'], 'l') . '" border="0" alt=""/>'; $output .= "<div class=\"ga-description\">\r\n\t\t\t\t\t{$giftImage}\r\n\t\t\t\t\t<div class=\"ga-name\">{$gift['name']}</div>\r\n\t\t\t\t\t<div class=\"ga-timestamp\">({$gift['timestamp']})</div>\r\n\t\t\t\t\t<div class=\"ga-description-message\">\"{$message}\"</div>"; $output .= '<div class="cleared"></div> </div>'; $output .= '<div class="ga-recent"> <div class="ga-recent-title">' . wfMsg('ga-recent-recipients-award') . '</div> <div class="ga-gift-count">' . wfMsgExt('ga-gift-given-count', 'parsemag', $gift['gift_count']) . '</div>'; foreach ($res as $row) { $userToId = $row->sg_user_id; $avatar = new wAvatar($userToId, 'ml'); $userNameLink = Title::makeTitle(NS_USER, $row->sg_user_name); $output .= '<a href="' . $userNameLink->escapeFullURL() . "\">\r\n\t\t\t\t\t{$avatar->getAvatarURL()}\r\n\t\t\t\t</a>"; } $output .= '<div class="cleared"></div> </div> </div>'; $wgOut->addHTML($output); } else { $wgOut->setPageTitle(wfMsg('ga-error-title')); $wgOut->addHTML(wfMsg('ga-error-message-invalid-link')); } }
/** * Callback function for the <newusers> tag. * Queries the user_register_track database table for new users and renders * the list of newest users and their avatars, wrapped in a div with the class * "new-users". * Disables parser cache and caches the database query results in memcached. */ function getNewUsers($input, $args, $parser) { global $wgMemc; $parser->disableCache(); $count = 10; $per_row = 5; if (isset($args['count']) && is_numeric($args['count'])) { $count = intval($args['count']); } if (isset($args['row']) && is_numeric($args['row'])) { $per_row = intval($args['row']); } // Try cache $key = wfMemcKey('users', 'new', $count); $data = $wgMemc->get($key); if (!$data) { $dbr = wfGetDB(DB_SLAVE); if ($dbr->tableExists('user_register_track')) { $res = $dbr->select('user_register_track', array('ur_user_id', 'ur_user_name'), array(), __METHOD__, array('ORDER BY' => 'ur_date', 'LIMIT' => $count)); } else { // If user_register_track table doesn't exist, use the core logging // table $res = $dbr->select('logging', array('log_user AS ur_user_id', 'log_user_text AS ur_user_name'), array('log_type' => 'newusers'), __METHOD__, array('ORDER BY' => 'log_timestamp DESC', 'LIMIT' => $count)); } $list = array(); foreach ($res as $row) { $list[] = array('user_id' => $row->ur_user_id, 'user_name' => $row->ur_user_name); } // Cache in memcached for 10 minutes $wgMemc->set($key, $list, 60 * 10); } else { wfDebugLog('NewUsersList', 'Got new users from cache'); $list = $data; } $output = '<div class="new-users">'; if (!empty($list)) { $x = 1; foreach ($list as $user) { $avatar = new wAvatar($user['user_id'], 'ml'); $userLink = Title::makeTitle(NS_USER, $user['user_name']); $output .= '<a href="' . $userLink->escapeFullURL() . '" rel="nofollow">' . $avatar->getAvatarURL() . '</a>'; if ($x == $count || $x != 1 && $x % $per_row == 0) { $output .= '<div class="cleared"></div>'; } $x++; } } $output .= '<div class="cleared"></div></div>'; return $output; }
function displayChallenge() { global $wgUser; $out = "<br><span class=pagetitle>ArmchairGM Challenge Info</span><br><br>"; $avatar1 = new wAvatar($this->challenge_username1, "l"); $avatar2 = new wAvatar($this->challenge_username2, "l"); $title1 = Title::makeTitle(NS_USER, $this->challenge_username1); $title2 = Title::makeTitle(NS_USER, $this->challenge_username2); $out .= "<table cellpadding=8 bgcolor=#eeeeee cellspacing=0 style='border:1px solid #666666'><tr><td>\n\t\t\t<img src='images/avatars/" . $avatar1->getAvatarImage() . "alt='' border=''>\n\t\t\t</td>"; $out .= "<td><span class=challenge-user-title><a href=" . $title1->getFullURL() . " class=challenge-user-title>" . $title1->getText() . "</a></span> (" . $this->getRecord($this->challenge_user_id_1) . ")\n\t\t\t\t<b>vs.</b> "; $out .= "</td><td><img src='images/avatars/" . $avatar2->getAvatarImage() . "alt='' border=''></td><td><span class=challenge-user-title>"; $out .= "<a href=" . $title2->getFullURL() . " class=challenge-user-title>" . $title2->getText() . "</a> </span> (" . $this->getRecord($this->challenge_user_id_2) . ")</td></tr></table><br>"; $out .= "<table ><tr><td><b>Event:</b> <span class=challenge-event>" . $this->challenge_info . " [" . $this->challenge_event_date . "]</span>"; $out .= "<br><b>" . $this->challenge_username1 . "'s description: </b><span class=challenge-description>" . $this->challenge_description . "</span></td></tr></table>"; $out .= "</td></tr></table><br><table cellpadding=0 cellspacing=0 ><tr><td valign=top><span class=title>if " . $this->challenge_username1 . " wins, " . $this->challenge_username2 . " has to . . . </span>"; $out .= "<table cellpadding=0 cellspacing=0 class=challenge-terms width=300><tr><td>" . $this->challenge_win_terms . "</td></tr></table><br>"; $out .= "</td><td width=20> </td><td valign=top><span class=title>if " . $this->challenge_username2 . " wins, " . $this->challenge_username1 . " has to . . . </span>"; $out .= "<table cellpadding=0 cellspacing=0 class=challenge-terms width=300><tr><td>" . $this->challenge_lose_terms . "</td></tr></table>"; $out .= "</td></tr></table>"; if ($wgUser->isAllowed('protect') && $this->challenge_user_id_2 != $wgUser->mId && $this->challenge_user_id_1 != $wgUser->mId) { $out .= "<a href=javascript:challengeCancel(" . $this->challenge_id . ") style='color:#990000'>Admin Cancel Challenge Due to Abuse</a>"; } $out .= "<hr><span class=challenge-status>\n\t\t\t\t<span class=title>Challenge Status</span><br><span id=challange-status>\n\t\t\t"; switch ($this->challenge_status) { case 0: $out .= $this->getStatusOpen(); break; case 1: if (1 == 2) { $out .= $this->getStatusAccepted(); } else { $out .= $this->getStatusAwaitingApproval(); } break; case -1: $out .= $this->getStatusRejected(); break; case -2: $out .= "<span class=challenge-rejected>Removed due to violation of rules</span>"; break; case 3: $out .= $this->getStatusCompleted(); break; } $out .= "</span></span><span id=status2></span>"; return $out; }
function getNYAvatar($user_id) { global $wgUploadDirectory; $avatar = new wAvatar($user_id, 'l'); $img = $avatar->getAvatarImage(); if ( $img ) { if ( substr(trim($img), 0, 7) != 'default' ) { $img = preg_replace("/\?(.*)/", '', $img); $img = $wgUploadDirectory . "/avatars/" . trim($img); } else { $img = '-'; } } else { $img = '-'; } echo $img; }
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; }
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; }
function execute() { global $wgUser, $wgOut, $wgRequest; //$wgOut->addHTML("Coming Soon"); $out = ""; $out .= "<br><span class=pagetitle>ArmchairGM Challenge Standings</span><br><br>"; $out .= "<table cellpadding=3 cellspacing=0 border=0><tr>\n\t\t\t<td class=challenge-standings-title>#</td>\n\t\t\t<td class=challenge-standings-title>user</td>\n\t\t\t<td class=challenge-standings-title>W</td>\n\t\t\t<td class=challenge-standings-title>L</td>\n\t\t\t<td class=challenge-standings-title>T</td>\n\t\t\t<td class=challenge-standings-title>%</td>\n\t\t\t<td class=challenge-standings-title></td>\n\t\t\t</tr>"; $dbr =& wfGetDB(DB_SLAVE); $sql = "SELECT challenge_record_username, challenge_wins, challenge_losses, challenge_ties, (challenge_wins / (challenge_wins + challenge_losses + challenge_ties) ) as winning_percentage FROM challenge_user_record ORDER BY (challenge_wins / (challenge_wins + challenge_losses + challenge_ties) ) DESC, challenge_wins DESC LIMIT 0,25"; $res = $dbr->query($sql); $x = 1; while ($row = $dbr->fetchObject($res)) { $avatar1 = new wAvatar($row->challenge_record_username, "s"); $out .= "<tr>\n\t\t\t\t\t\t\t<td class=challenge-standings>" . $x . "</td>\n\t\t\t\t\t\t\t<td class=challenge-standings><img src='images/avatars/" . $avatar1->getAvatarImage() . "' align=absmiddle><a href=index.php?title=Special:ChallengeHistory&user="******" style='font-weight:bold;font-size:13px'>" . $row->challenge_record_username . "</a> " . $user1Icon . "</td>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<td class=challenge-standings>" . $row->challenge_wins . "</td>\n\t\t\t\t\t\t\t<td class=challenge-standings>" . $row->challenge_losses . "</td>\n\t\t\t\t\t\t\t<td class=challenge-standings>" . $row->challenge_ties . "</td>\n\t\t\t\t\t\t\t<td class=challenge-standings>" . str_replace(".0", ".", number_format($row->winning_percentage, 3)) . "</td>"; if ($row->challenge_record_username != $wgUser->mName) { $out .= "<td class=challenge-standings><a href=index.php?title=Special:ChallengeUser&user="******" style='color:#666666'>challenge user</a></td>"; } $out .= "</td>\n\t\t\t\t</tr>"; $x++; } $wgOut->addHTML($out); }
/** * Get the current user's avatar image. * * @param int $width 20 or 40, used for the img ID and class attributes * @return string Valid <\img\> tag suitable for output */ private function getAvatar($width) { $skin = $this->getSkin(); // Default avatar is what we start with $avatarImage = Html::element('img', array('class' => 'userIcon' . (int) $width, 'src' => htmlspecialchars($skin->getSkinStylePath('images/Transparent.gif')), 'alt' => '')); if ($this->config->get('MetrolookDisableAvatar')) { if (class_exists('wAvatar')) { // SocialProfile is installed $avatar = new wAvatar($skin->getUser()->getId(), 'l'); $avatarImage = $avatar->getAvatarURL(array('width' => (int) $width, 'class' => 'userIcon' . (int) $width . ' socialprofile-avatar')); } } return $avatarImage; }
public static function getReply( $reply, $posted, $buttons, $id, $userId ) { $avatar = ''; if ( $userId && class_exists( 'wAvatar' ) ) { $avatarObj = new wAvatar( $userId, 'l' ); $avatar = '<div class="wikiforum-avatar-image">'; $avatar .= $avatarObj->getAvatarURL(); $avatar .= '</div>'; } return '<tr><td class="mw-wikiforum-thread-sub" colspan="2" id="reply_' . intval( $id ) . '">' . $avatar . $reply . self::getBottomLine( $posted, $buttons ) . '</td></tr>'; }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgRequest, $wgOut, $wgUser, $wgUploadPath, $wgHooks, $wgPollScripts; // If the user doesn't have the required permission, display an error if (!$wgUser->isAllowed('polladmin')) { $wgOut->permissionRequired('polladmin'); return; } // Show a message if the database is in read-only mode if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } // If user is blocked, s/he doesn't need to access this page if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } // Add CSS & JS $wgOut->addExtensionStyle($wgPollScripts . '/Poll.css'); $wgOut->addScriptFile($wgPollScripts . '/Poll.js'); // Add i18n JS variables via a hook (yes, this works, I've tested this) $wgHooks['MakeGlobalVariablesScript'][] = 'AdminPoll::addJSGlobals'; // Pagination $per_page = 20; $page = $wgRequest->getInt('page', 1); $current_status = $wgRequest->getVal('status'); if (!$current_status) { $current_status = 'all'; } $limit = $per_page; $nav = array('all' => wfMsg('poll-admin-viewall'), 'open' => wfMsg('poll-admin-open'), 'closed' => wfMsg('poll-admin-closed'), 'flagged' => wfMsg('poll-admin-flagged')); $output = '<div class="view-poll-top-links"> <a href="javascript:history.go(-1);">' . wfMsg('poll-take-button') . '</a> </div> <div class="view-poll-navigation"> <h2>' . wfMsg('poll-admin-status-nav') . '</h2>'; foreach ($nav as $status => $title) { $output .= '<p>'; if ($current_status != $status) { $output .= '<a href="' . $this->getTitle()->escapeFullURL("status={$status}") . "\">{$title}</a>"; } else { $output .= "<b>{$title}</b>"; } $output .= '</p>'; } $output .= '</div>'; $wgOut->setPageTitle(wfMsg('poll-admin-title-' . $current_status)); $params['ORDER BY'] = 'poll_date DESC'; if ($limit > 0) { $params['LIMIT'] = $limit; } if ($page) { $params['OFFSET'] = $page * $limit - $limit; } $status_int = -1; switch ($current_status) { case 'open': $status_int = 1; break; case 'closed': $status_int = 0; break; case 'flagged': $status_int = 2; break; } $where = array(); if ($status_int > -1) { $where['poll_status'] = $status_int; } $dbr = wfGetDB(DB_MASTER); $res = $dbr->select(array('poll_question', 'page'), array('poll_id', 'poll_user_id', 'UNIX_TIMESTAMP(poll_date) AS poll_time', 'poll_status', 'poll_vote_count', 'poll_user_name', 'poll_text', 'poll_page_id', 'page_id'), $where, __METHOD__, $params, array('page' => array('INNER JOIN', 'poll_page_id = page_id'))); if ($status_int > -1) { $where['poll_status'] = $status; } $s = $dbr->selectRow('poll_question', array('COUNT(*) AS count'), $where, __METHOD__, $params); $total = $s->count; $output .= '<div class="view-poll">'; $x = ($page - 1) * $per_page + 1; // If we have nothing, show an error(-ish) message, but don't return // because it could be that we have plenty of polls in the database, // but none of 'em matches the given criteria (status param in the URL) // For example, there are no flagged polls or closed polls. This msg // gets shown even then. if (!$dbr->numRows($res)) { $wgOut->addWikiMsg('poll-admin-no-polls'); } foreach ($res as $row) { $user_create = $row->poll_user_name; $user_id = $row->poll_user_id; $avatar = new wAvatar($user_id, 'm'); $poll_title = $row->poll_text; $poll_date = $row->poll_time; $poll_answers = $row->poll_vote_count; $rowId = "poll-row-{$x}"; $title = Title::makeTitle(NS_POLL, $poll_title); $p = new Poll(); $poll_choices = $p->getPollChoices($row->poll_id); if ($x < $dbr->numRows($res) && $x % $per_page != 0) { $output .= "<div class=\"view-poll-row\" id=\"{$rowId}\">"; } else { $output .= "<div class=\"view-poll-row-bottom\" id=\"{$rowId}\">"; } $output .= "<div class=\"view-poll-number\">{$x}.</div>\n\t\t\t\t\t<div class=\"view-poll-user-image\"><img src=\"{$wgUploadPath}/avatars/{$avatar->getAvatarImage()}\" alt=\"\" /></div>\n\t\t\t\t\t<div class=\"view-poll-user-name\">{$user_create}</div>\n\t\t\t\t\t<div class=\"view-poll-text\">\n\t\t\t\t\t<p><b><a href=\"{$title->escapeFullURL()}\">{$poll_title}</a></b></p>\n\t\t\t\t\t<p>"; foreach ($poll_choices as $choice) { $output .= "{$choice['choice']}<br />"; } $output .= '</p> <p class="view-poll-num-answers">' . wfMsgExt('poll-view-answered-times', 'parsemag', $poll_answers) . '</p> <p class="view-poll-time">(' . wfMsg('poll-ago', Poll::getTimeAgo($poll_date)) . ")</p>\n\t\t\t\t\t\t<div id=\"poll-{$row->poll_id}-controls\">"; if ($row->poll_status == 2) { $output .= "<a href=\"javascript:void(0)\" onclick=\"PollNY.poll_admin_status({$row->poll_id},1);\">" . wfMsg('poll-unflag-poll') . '</a>'; } if ($row->poll_status == 0) { $output .= " <a href=\"javascript:void(0)\" onclick=\"PollNY.poll_admin_status({$row->poll_id},1);\">" . wfMsg('poll-open-poll') . '</a>'; } if ($row->poll_status == 1) { $output .= " <a href=\"javascript:void(0)\" onclick=\"PollNY.poll_admin_status({$row->poll_id},0);\">" . wfMsg('poll-close-poll') . '</a>'; } $output .= " <a href=\"javascript:void(0)\" onclick=\"PollNY.poll_delete({$row->poll_id});\">" . wfMsg('poll-delete-poll') . '</a> </div> </div> <div class="cleared"></div> </div>'; $x++; } $output .= '</div> <div class="cleared"></div>'; $output .= $this->buildPagination($total, $per_page, $page); $wgOut->addHTML($output); }
public function displayMessages($user_id, $user_id_2 = 0, $count = 10, $page = 0) { global $wgUser, $wgTitle; $output = ''; // Prevent E_NOTICE $messages = $this->getUserBoardMessages($user_id, $user_id_2, $count, $page); if ($messages) { foreach ($messages as $message) { $user = Title::makeTitle(NS_USER, $message['user_name_from']); $avatar = new wAvatar($message['user_id_from'], 'm'); $board_to_board = ''; $board_link = ''; $message_type_label = ''; $delete_link = ''; if ($wgUser->getName() != $message['user_name_from']) { $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($message['user_name'], $message['user_name_from']) . '">' . wfMsgHtml('userboard_board-to-board') . '</a>'; $board_link = '<a href="' . UserBoard::getUserBoardURL($message['user_name_from']) . '">' . wfMsgHtml('userboard_sendmessage', $message['user_name_from']) . '</a>'; } if ($wgUser->getName() == $message['user_name'] || $wgUser->isAllowed('userboard-delete')) { $delete_link = "<span class=\"user-board-red\">\r\n\t\t\t\t\t\t\t<a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message['id']})\">" . wfMsgHtml('userboard_delete') . '</a> </span>'; } if ($message['type'] == 1) { $message_type_label = '(' . wfMsgHtml('userboard_private') . ')'; } $message_text = $message['message_text']; # $message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $message['message_text'] ); $output .= "<div class=\"user-board-message\">\r\n\t\t\t\t\t<div class=\"user-board-message-from\">\r\n\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$message['user_name_from']}\">{$message['user_name_from']}</a> {$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', $this->getTimeAgo($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=\"{$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{$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>"; } } elseif ($wgUser->getName() == $wgTitle->getText()) { $output .= '<div class="no-info-container">' . wfMsgHtml('userboard_nomessages') . '</div>'; } return $output; }
/** * Function to render the {{#siteavatar:Prefix}} function * * @param Parser $parser: MW parser object * @param string $username: Username of user to show avatar for * @param string $size: Size of avatar to return (s/m/ml/l), or px value (100px, 10px, etc) * @return array: output of function, and options for the parser */ static function renderSiteAvatarParserFunction($parser, $prefix = '', $givenSize = 'm') { global $wgUploadPath; $sizes = array('s', 'm', 'ml', 'l'); if (in_array($givenSize, $sizes)) { // if given size is a code, $size = $givenSize; // use code, $px = ''; // and leave px value empty } elseif (substr($givenSize, -2) == 'px') { //given size is a value in px $givenPx = intval(substr($givenSize, 0, strlen($givenSize) - 2)); //get int value of given px size if (!is_int($givenPx)) { // if px value is not int $size = 'm'; // give default avatar $px = ''; // with no px value } if ($givenPx <= 16) { // if given px value is smaller than small, $size = 's'; // use the small avatar, $px = $givenSize; // and the given px value } elseif ($givenPx <= 30) { // if given px value is smaller than medium, $size = 'm'; // use the medium avatar, $px = $givenSize; // and the given px value } elseif ($givenPx <= 50) { // if given px value is smaller than medium-large, $size = 'ml'; // use the medium-large avatar, $px = $givenSize; // and the given px value } else { // if given px value is bigger then medium large, $size = 'l'; // use the large avatar, $px = $givenSize; // and the given px value } } else { // size value is not code or px $size = 'm'; // give default avatar $px = ''; // with no px value } if (HuijiPrefix::hasPrefix($prefix)) { $id = $prefix; $avatar = new wSiteAvatar($id, $size); } else { // Fallback for the case where an invalid (nonexistent) user name // was supplied... $avatar = new wAvatar(-1, 'm'); // not very nice, but -1 will get the default avatar } if ($px) { // if px value needed, set height to it $output = $avatar->getAvatarHtml(array('height' => $px)); } else { // but if not needed, don't $output = $avatar->getAvatarHtml(); } return array($output, 'noparse' => true, 'isHTML' => true); }
/** * Display all the comments for the current page. * CSS and JS is loaded in Comment.php, function displayComments. */ function display() { global $wgUser, $wgOut, $wgScriptPath, $wgMemc, $wgUserLevels; $output = ''; // Try cache $key = wfMemcKey('comment', 'list', $this->PageID); $data = $wgMemc->get($key); if (!$data) { wfDebug("Loading comments for page {$this->PageID} from DB\n"); $comments = $this->getCommentList(); $wgMemc->set($key, $comments); } else { wfDebug("Loading comments for page {$this->PageID} from cache\n"); $comments = $data; } // Try cache for voted list for this user $voted = array(); if ($wgUser->isLoggedIn()) { $key = wfMemcKey('comment', 'voted', $this->PageID, 'user_id', $wgUser->getID()); $data = $wgMemc->get($key); if (!$data) { $voted = $this->getCommentVotedList(); $wgMemc->set($key, $voted); } else { wfDebug("Loading comment voted for page {$this->PageID} for user {$wgUser->getID()} from cache\n"); $voted = $data; } } // Load complete blocked list for logged in user so they don't see their comments $block_list = array(); if ($wgUser->getID() != 0) { $block_list = $this->getBlockList($wgUser->getId()); } $AFCounter = 1; $AFBucket = array(); if ($comments) { foreach ($comments as $comment) { $CommentScore = $comment['Comment_Score']; $CommentPosterLevel = ''; if ($comment['Comment_user_id'] != 0) { $title = Title::makeTitle(NS_USER, $comment['Comment_Username']); $CommentPoster = '<a href="' . $title->escapeFullURL() . '" rel="nofollow">' . $comment['Comment_Username'] . '</a>'; $CommentReplyTo = $comment['Comment_Username']; if ($wgUserLevels && class_exists('UserLevel')) { $user_level = new UserLevel($comment['Comment_user_points']); $CommentPosterLevel = "{$user_level->getLevelName()}"; } } else { if (!array_key_exists($comment['Comment_Username'], $AFBucket)) { $AFBucket[$comment['Comment_Username']] = $AFCounter; $AFCounter++; } $CommentPoster = wfMsgForContent('comment-anon-name') . ' #' . $AFBucket[$comment['Comment_Username']]; $CommentReplyTo = wfMsgForContent('comment-anon-name'); } // Comment delete button for privileged users $dlt = ''; if ($wgUser->isAllowed('commentadmin')) { $dlt = " | <span class=\"c-delete\"><a href=\"javascript:document.commentform.commentid.value={$comment['CommentID']};document.commentform.submit();\">" . wfMsg('comment-delete-link') . '</a></span>'; } // Reply Link (does not appear on child comments) $replyRow = ''; if ($wgUser->isAllowed('comment')) { if ($comment['Comment_Parent_ID'] == 0) { if ($replyRow) { $replyRow .= ' | '; } $replyRow .= " | <a href=\"#end\" rel=\"nofollow\" class=\"comments-reply-to\" data-comment-id=\"{$comment['CommentID']}\" data-comments-safe-username=\"" . htmlspecialchars($CommentReplyTo, ENT_QUOTES) . '">' . wfMsg('comment-reply') . '</a>'; } } if ($comment['Comment_Parent_ID'] == 0) { $container_class = 'full'; $comment_class = 'f-message'; } else { $container_class = 'reply'; $comment_class = 'r-message'; } // Display Block icon for logged in users for comments of users // that are already not in your block list $block_link = ''; if ($wgUser->getID() != 0 && $wgUser->getID() != $comment['Comment_user_id'] && !in_array($comment['Comment_Username'], $block_list)) { $block_link = '<a href="javascript:void(0);" rel="nofollow" class="comments-block-user" data-comments-safe-username="******" data-comments-comment-id="' . $comment['CommentID'] . '" data-comments-user-id="' . $comment['Comment_user_id'] . "\">\n\t\t\t\t\t<img src=\"{$wgScriptPath}/extensions/Comments/images/block.png\" border=\"0\" alt=\"\"/>\n\t\t\t\t</a>"; } // If you are ignoring the author of the comment, display message in comment box, // along with a link to show the individual comment $hide_comment_style = ''; if (in_array($comment['Comment_Username'], $block_list)) { $hide_comment_style = 'display:none;'; $blockListTitle = SpecialPage::getTitleFor('CommentIgnoreList'); $output .= "<div id=\"ignore-{$comment['CommentID']}\" class=\"c-ignored {$container_class}\">\n"; $output .= wfMsgExt('comment-ignore-message', 'parsemag'); $output .= '<div class="c-ignored-links">' . "\n"; $output .= "<a href=\"javascript:void(0);\" data-comment-id=\"{$comment['CommentID']}\">" . wfMsg('comment-show-comment-link') . '</a> | '; $output .= "<a href=\"{$blockListTitle->escapeFullURL()}\">" . wfMsg('comment-manage-blocklist-link') . '</a>'; $output .= '</div>' . "\n"; $output .= '</div>' . "\n"; } // Default avatar image, if SocialProfile extension isn't // enabled global $wgCommentsDefaultAvatar; $avatar_img = '<img src="' . $wgCommentsDefaultAvatar . '" alt="" border="0" />'; // If SocialProfile *is* enabled, then use its wAvatar class // to get the avatars for each commenter if (class_exists('wAvatar')) { $avatar = new wAvatar($comment['Comment_user_id'], 'ml'); $avatar_img = $avatar->getAvatarURL() . "\n"; } $output .= "<div id=\"comment-{$comment['CommentID']}\" class=\"c-item {$container_class}\" style=\"{$hide_comment_style}\">" . "\n"; $output .= "<div class=\"c-avatar\">{$avatar_img}</div>" . "\n"; $output .= '<div class="c-container">' . "\n"; $output .= '<div class="c-user">' . "\n"; $output .= "{$CommentPoster}"; $output .= "<span class=\"c-user-level\">{$CommentPosterLevel}</span> {$block_link}" . "\n"; wfSuppressWarnings(); // E_STRICT bitches about strtotime() $output .= '<div class="c-time">' . wfMsg('comments-time-ago', self::getTimeAgo(strtotime($comment['Comment_Date']))) . '</div>' . "\n"; wfRestoreWarnings(); $output .= '<div class="c-score">' . "\n"; if ($this->AllowMinus == true || $this->AllowPlus == true) { $output .= '<span class="c-score-title">' . wfMsg('comment-score-text') . " <span id=\"Comment{$comment['CommentID']}\">{$CommentScore}</span></span>"; // Voting is possible only when database is unlocked if (!wfReadOnly()) { if (!in_array($comment['CommentID'], $voted)) { // You can only vote for other people's comments, // not for your own if ($wgUser->getName() != $comment['Comment_Username']) { $output .= "<span id=\"CommentBtn{$comment['CommentID']}\">"; if ($this->AllowPlus == true) { $output .= $this->getVoteLink($comment['CommentID'], 1); } if ($this->AllowMinus == true) { $output .= $this->getVoteLink($comment['CommentID'], -1); } $output .= '</span>'; } else { $output .= wfMsg('comment-you'); } } else { // Already voted? $output .= '<img src="' . $wgScriptPath . '/extensions/Comments/images/voted.gif" border="0" alt="" />' . wfMsg('comment-voted-label'); } } } $output .= '</div>' . "\n"; // $wgTitle points to Special:CommentListGet...and that special // page shouldn't even exist, so we certainly don't want to // advertise it...let's point the permalink to the current page // instead :) $title = Title::newFromID($this->PageID); $output .= '</div>' . "\n"; $output .= "<div class=\"c-comment {$comment_class}\">" . "\n"; $output .= $this->getCommentText($comment['Comment_Text']); $output .= '</div>' . "\n"; $output .= '<div class="c-actions">' . "\n"; $output .= '<a href="' . $title->escapeFullURL() . "#comment-{$comment['CommentID']}\" rel=\"nofollow\">" . wfMsg('comment-permalink') . '</a> '; if ($replyRow || $dlt) { $output .= "{$replyRow} {$dlt}" . "\n"; } $output .= '</div>' . "\n"; $output .= '</div>' . "\n"; $output .= '<div class="cleared"></div>' . "\n"; $output .= '</div>' . "\n"; } } $output .= '<a id="end" name="end" rel="nofollow"></a>'; return $output; }
/** * Fetches the two images to be voted on * * @param $isPermalink Boolean: false by default * @param $imgID Integer: is present if rendering a permalink * @param $lastID Integer: optional; the last image ID the user saw */ function getImageDivs( $isPermalink = false, $imgID = -1, $lastID = -1 ) { global $wgRequest, $wgUser, $wgOut, $wgScriptPath, $wgUseEditButtonFloat, $wgUploadPath, $wgLang; $totalVotes = 0; $dbr = wfGetDB( DB_SLAVE ); // if imgID is -1 then we need some random IDs if( $imgID == -1 ) { $query = $dbr->select( 'picturegame_votes', 'picid', array( 'username' => $wgUser->getName() ), __METHOD__ ); $picIds = array(); foreach ( $query as $resultRow ) { $picIds[] = $resultRow->picid; } // If there are no picture games in the database, the above query // won't add anything to the picIds array, and trying to implode // an empty array...well, you'll get id NOT IN () which in turn is // invalid SQL. if ( !empty( $picIds ) ) { $res = $dbr->select( 'picturegame_images', '*', array( 'id NOT IN (' . implode( ',', $picIds ) . ')', 'flag <> ' . PICTUREGAME_FLAG_FLAGGED, "img1 <> ''", "img2 <> ''" ), __METHOD__, array( 'LIMIT' => 1 ) ); /*$sql = "SELECT * 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 ); $imgID = isset( $row->id ) ? $row->id : 0; } $imgID = 0; } else { $res = $dbr->select( 'picturegame_images', '*', array( 'flag <> ' . PICTUREGAME_FLAG_FLAGGED, "img1 <> ''", "img2 <> ''", 'id' => $imgID ), __METHOD__ ); $row = $dbr->fetchObject( $res ); } // Early return here in case if we have *nothing* in the database to // prevent fatals etc. if( empty( $row ) ) { $wgOut->setPageTitle( wfMsg( 'picturegame-nomoretitle' ) ); // can't use addWikiMsg() because we can't make an internal link // to Special:PictureGameHome?picGameAction=startCreate :P $wgOut->addHTML( wfMsg( 'picturegame-empty', $this->getTitle()->escapeFullURL( 'picGameAction=startCreate' ) ) ); return; } $user_title = Title::makeTitle( NS_USER, $row->username ); if( $imgID ) { global $wgPictureGameID; $wgPictureGameID = $imgID; $toExclude = $dbr->select( 'picturegame_votes', 'picid', array( 'username' => $wgUser->getName() ), __METHOD__ ); $excludedImgIds = array(); foreach ( $toExclude as $excludedRow ) { $excludedImgIds[] = $excludedRow->picid; } $next_id = 0; if ( !empty( $excludedImgIds ) ) { $nextres = $dbr->select( 'picturegame_images', '*', array( "id <> {$imgID}", 'id NOT IN (' . implode( ',', $excludedImgIds ) . ')', 'flag != ' . PICTUREGAME_FLAG_FLAGGED, "img1 <> ''", "img2 <> ''" ), __METHOD__, array( 'LIMIT' => 1 ) ); /*$sql = "SELECT * FROM picturegame_images WHERE picturegame_images.id <> {$imgID} AND 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;"; $nextres = $dbr->query( $sql, __METHOD__ );*/ $nextrow = $dbr->fetchObject( $nextres ); $next_id = ( isset( $nextrow->id ) ? $nextrow->id : 0 ); } if( $next_id ) { $img_one = wfFindFile( $nextrow->img1 ); if( is_object( $img_one ) ) { $preload_thumb = $img_one->getThumbnail( 256 ); } if( is_object( $preload_thumb ) ) { $preload_one_tag = $preload_thumb->toHtml(); } $img_two = wfFindFile( $nextrow->img2 ); if( is_object( $img_two ) ) { $preload_thumb = $img_two->getThumbnail( 256 ); } if( is_object( $preload_thumb ) ) { $preload_two_tag = $preload_thumb->toHtml(); } $preload = $preload_one_tag . $preload_two_tag; } } if( ( $imgID < 0 ) || !is_numeric( $imgID ) || is_null( $row ) ) { $wgOut->setPageTitle( wfMsg( 'picturegame-nomoretitle' ) ); // @todo FIXME: fugly i18n $out = '<div>' . wfMsg( 'picturegame-nomore' ) . '<br />' . wfMsg( 'picturegame-nomore-2' ) . '<a href="' . $this->getTitle()->escapeFullURL( 'picGameAction=startCreate' ) . '">' . wfMsg( 'picturegame-nomorecreatelink' ) . '</a> ' . wfMsg( 'picturegame-nomoreor' ) . ' <a href="' . $wgScriptPath . '/index.php?title=Special:RandomPoll">' . wfMsg( 'picturegame-nomoretakepolls' ) . '</a> </div>'; return $out; } // snag the images to vote on and grab some thumbnails // modify this query so that if the current user has voted on this // image pair don't show it again $imgOneCount = $row->img0_votes; $imgTwoCount = $row->img1_votes; $user_name = $wgLang->truncate( $row->username, 20 ); $title_text_length = strlen( $row->title ); $title_text_space = stripos( $row->title, ' ' ); if( ( $title_text_space == false || $title_text_space >= '48' ) && $title_text_length > 48 ) { $title_text = substr( $row->title, 0, 48 ) . '<br />' . substr( $row->title, 48, 48 ); } elseif( $title_text_length > 48 && substr( $row->title, 48, 1 ) == ' ' ) { $title_text = substr( $row->title, 0, 48 ) . '<br />' . substr( $row->title, 48, 48 ); } elseif( $title_text_length > 48 && substr( $row->title, 48, 1 ) != ' ' ) { $title_text_lastspace = strrpos( substr( $row->title, 0, 48 ), ' ' ); $title_text = substr( $row->title, 0, $title_text_lastspace ) . '<br />' . substr( $row->title, $title_text_lastspace, 30 ); } else { $title_text = $row->title; } $x = 1; $img1_caption_text = ''; $img1caption_array = str_split( $row->img1_caption ); foreach( $img1caption_array as $img1_character ) { if( $x % 30 == 0 ) { $img1_caption_text .= $img1_character . '<br />'; } else { $img1_caption_text .= $img1_character; } $x++; } $x = 1; $img2_caption_text = ''; $img1caption_array = str_split( $row->img2_caption ); foreach( $img1caption_array as $img2_character ) { if( $x % 30 == 0 ) { $img2_caption_text .= $img2_character . '<br />'; } else { $img2_caption_text .= $img2_character; } $x++; } // I assume MediaWiki does some caching with these functions $img_one = wfFindFile( $row->img1 ); $thumb_one_url = ''; if( is_object( $img_one ) ) { $thumb_one_url = $img_one->createThumb( 256 ); $imageOneWidth = $img_one->getWidth(); } //$imgOne = '<img width="' . ( $imageOneWidth >= 256 ? 256 : $imageOneWidth ) . '" alt="" src="' . $thumb_one_url . ' "/>'; //$imageOneWidth = ( $imageOneWidth >= 256 ? 256 : $imageOneWidth ); //$imageOneWidth += 10; $imgOne = '<img style="width:100%;" alt="" src="' . $thumb_one_url . ' "/>'; $img_two = wfFindFile( $row->img2 ); $thumb_two_url = ''; if( is_object( $img_two ) ) { $thumb_two_url = $img_two->createThumb( 256 ); $imageTwoWidth = $img_two->getWidth(); } //$imgTwo = '<img width="' . ( $imageTwoWidth >= 256 ? 256 : $imageTwoWidth ) . '" alt="" src="' . $thumb_two_url . ' "/>'; //$imageTwoWidth = ( $imageTwoWidth >= 256 ? 256 : $imageTwoWidth ); //$imageTwoWidth += 10; $imgTwo = '<img style="width:100%;" alt="" src="' . $thumb_two_url . ' " />'; $title = $title_text; $img1_caption = $img1_caption_text; $img2_caption = $img2_caption_text; $vote_one_tag = ''; $vote_two_tag = ''; $imgOnePercent = ''; $barOneWidth = ''; $imgTwoPercent = ''; $barTwoWidth = ''; $permalinkJS = ''; $isShowVotes = false; if( $lastID > 0 ) { $res = $dbr->select( 'picturegame_images', '*', array( 'flag <> ' . PICTUREGAME_FLAG_FLAGGED, 'id' => $lastID ), __METHOD__ ); $row = $dbr->fetchObject( $res ); if( $row ) { $img_one = wfFindFile( $row->img1 ); $img_two = wfFindFile( $row->img2 ); $imgOneCount = $row->img0_votes; $imgTwoCount = $row->img1_votes; $isShowVotes = true; } } if( $isPermalink || $isShowVotes ) { if( is_object( $img_one ) ) { $vote_one_thumb = $img_one->getThumbnail( 40 ); } if( is_object( $vote_one_thumb ) ) { $vote_one_tag = $vote_one_thumb->toHtml(); } if( is_object( $img_two ) ) { $vote_two_thumb = $img_two->getThumbnail( 40 ); } if( is_object( $vote_two_thumb ) ) { $vote_two_tag = $vote_two_thumb->toHtml(); } $totalVotes = $imgOneCount + $imgTwoCount; if( $imgOneCount == 0 ) { $imgOnePercent = 0; $barOneWidth = 0; } else { $imgOnePercent = floor( $imgOneCount / $totalVotes * 100 ); $barOneWidth = floor( 200 * ( $imgOneCount / $totalVotes ) ); } if( $imgTwoCount == 0 ) { $imgTwoPercent = 0; $barTwoWidth = 0; } else { $imgTwoPercent = 100 - $imgOnePercent; $barTwoWidth = floor( 200 * ( $imgTwoCount / $totalVotes ) ); } $permalinkJS = "document.getElementById( 'voteStats' ).style.display = 'inline'; document.getElementById( 'voteStats' ).style.visibility = 'visible';"; } $output = ''; // set the page title //$wgOut->setPageTitle( $title_text ); // figure out if the user is an admin / the creator $editlinks = ''; if( $wgUser->isAllowed( 'picturegameadmin' ) ) { // If the user can edit, throw in some links $editlinks = ' - <a href="' . $this->getTitle()->escapeFullURL( 'picGameAction=adminPanel' ) . '"> ' . wfMsg( 'picturegame-adminpanel' ) . "</a> - <a href=\"javascript:PictureGame.protectImages('" . str_replace( "'", "\'", wfMsg( 'picturegame-protectimgconfirm' ) ) . "')\"> " . wfMsg( 'picturegame-protectimages' ) . '</a>'; } $createLink = ''; // Only registered users can create new picture games if( $wgUser->isLoggedIn() ) { $createLink = ' <div class="create-link"> <a href="' . $this->getTitle()->escapeFullURL( 'picGameAction=startCreate' ) . '"> <img src="' . $wgScriptPath . '/extensions/PictureGame/images/addIcon.gif" border="0" alt="" />' . wfMsg( 'picturegame-createlink' ) . '</a> </div>'; } $editLink = ''; if( $wgUser->isLoggedIn() && $wgUser->isAllowed( 'picturegameadmin' ) && $wgUseEditButtonFloat == true ) { $editLink .= '<div class="edit-menu-pic-game"> <div class="edit-button-pic-game"> <img src="' . $wgScriptPath . '/extensions/PictureGame/images/editIcon.gif" alt="" /> <a href="javascript:PictureGame.editPanel()">' . wfMsg( 'edit' ) . '</a> </div> </div>'; } $id = User::idFromName( $user_title->getText() ); $avatar = new wAvatar( $id, 'l' ); $avatarID = $avatar->getAvatarImage(); $stats = new UserStats( $id, $user_title->getText() ); $stats_data = $stats->getUserStats(); $preload = ''; $wgOut->setHTMLTitle( wfMsg( 'pagetitle', $title ) ); $wgOut->addScriptFile( $wgScriptPath . '/extensions/PictureGame/picturegame/LightBox.js' ); $next_id = ( isset( $next_id ) ? $next_id : 0 ); $output .= " <script type=\"text/javascript\">var next_id = \"{$next_id}\";</script> {$editLink} <div class=\"editDiv\" id=\"editDiv\" style=\"display: none\"> </div> <div class=\"serverMessages\" id=\"serverMessages\"></div> <div class=\"imgContent\" id=\"imgContent\"> <div class=\"imgTitle\" id=\"imgTitle\">" . $title . "</div> <div class=\"imgContainer\" id=\"imgContainer\" style=\"width:45%;\"> <div class=\"imgCaption\" id=\"imgOneCaption\">" . $img1_caption . "</div> <div class=\"imageOne\" id=\"imageOne\" style=\"padding:5px;\" onclick=\"PictureGame.castVote(0)\" onmouseover=\"PictureGame.doHover('imageOne')\" onmouseout=\"PictureGame.endHover('imageOne')\"> " . $imgOne . " </div> </div> <div class=\"imgContainer\" id=\"imgContainer\" style=\"width:45%;\"> <div class=\"imgCaption\" id=\"imgTwoCaption\">" . $img2_caption . "</div> <div class=\"imageTwo\" id=\"imageTwo\" style=\"padding:5px;\" onclick=\"PictureGame.castVote(1)\" onmouseover=\"PictureGame.doHover('imageTwo')\" onmouseout=\"PictureGame.endHover('imageTwo')\"> " . $imgTwo . " </div> </div> <div class=\"cleared\"></div> <div class=\"pic-game-navigation\"> <ul> <li id=\"backButton\" style=\"display:" . ( $lastID > 0 ? 'block' : 'none' ) . "\"> <a href=\"javascript:window.parent.document.location='" . $this->getTitle()->escapeFullURL( 'picGameAction=renderPermalink' ) . "&id=' + document.getElementById('lastid').value\">" . wfMsg( 'picturegame-backbutton' ) . "</a> </li> <li id=\"skipButton\" style=\"display:" . ( $next_id > 0 ? 'block' : 'none' ) . "\"> <a href=\"" . $this->getTitle()->escapeFullURL( 'picGameAction=startGame' ) . '">' . wfMsg( 'picturegame-skipbutton' ) . '</a> </li> </ul> </div> <form id="picGameVote" name="picGameVote" method="post" action="' . $this->getTitle()->escapeFullURL( 'picGameAction=castVote' ) . "\"> <input id=\"key\" name=\"key\" type=\"hidden\" value=\"" . md5( $imgID . $this->SALT ) . "\" /> <input id=\"id\" name=\"id\" type=\"hidden\" value=\"" . $imgID . "\" /> <input id=\"lastid\" name=\"lastid\" type=\"hidden\" value=\"" . $lastID . "\" /> <input id=\"nextid\" name=\"nextid\" type=\"hidden\" value=\"" . $next_id . "\" /> <input id=\"img\" name=\"img\" type=\"hidden\" value=\"\" /> </form> </div> <div class=\"other-info\"> {$createLink} <div class=\"credit-box\" id=\"creditBox\"> <h1>" . wfMsg( 'picturegame-submittedby' ) . "</h1> <div class=\"submitted-by-image\"> <a href=\"{$user_title->getFullURL()}\"> <img src=\"{$wgUploadPath}/avatars/{$avatarID}\" style=\"border:1px solid #d7dee8; width:50px; height:50px;\" alt=\"\" /> </a> </div> <div class=\"submitted-by-user\"> <a href=\"{$user_title->getFullURL()}\">{$user_name}</a> <ul> <li> <img src=\"{$wgScriptPath}/extensions/PictureGame/images/voteIcon.gif\" border=\"0\" alt=\"\" /> {$stats_data['votes']} </li> <li> <img src=\"{$wgScriptPath}/extensions/PictureGame/images/pencilIcon.gif\" border=\"0\" alt=\"\" /> {$stats_data['edits']} </li> <li> <img src=\"{$wgScriptPath}/extensions/PictureGame/images/commentsIcon.gif\" border=\"0\" alt=\"\" /> {$stats_data['comments']} </li> </ul> </div> <div class=\"cleared\"></div> </div> <div class=\"voteStats\" id=\"voteStats\" style=\"display:none\"> <div id=\"vote-stats-text\"> <h1>" . wfMsg( 'picturegame-previousgame' ) . " ({$totalVotes})</h1></div> <div class=\"vote-bar\"> <span class=\"vote-thumbnail\" id=\"one-vote-thumbnail\">{$vote_one_tag}</span> <span class=\"vote-percent\" id=\"one-vote-percent\">{$imgOnePercent}%</span> <span class=\"vote-blue\"> <img src=\"{$wgScriptPath}/extensions/PictureGame/images/vote-bar-blue.gif\" id=\"one-vote-width\" border=\"0\" style=\"width:{$barOneWidth}px;height:11px;\" alt=\"\" /> </span> </div> <div class=\"vote-bar\"> <span class=\"vote-thumbnail\" id=\"two-vote-thumbnail\">{$vote_two_tag}</span> <span class=\"vote-percent\" id=\"two-vote-percent\">{$imgTwoPercent}%</span> <span class=\"vote-red\"> <img src=\"{$wgScriptPath}/extensions/PictureGame/images/vote-bar-red.gif\" id=\"two-vote-width\" border=\"0\" style=\"width:{$barTwoWidth}px;height:11px;\" alt=\"\" /> </span> </div> </div> <div class=\"utilityButtons\" id=\"utilityButtons\"> <a href=\"javascript:PictureGame.flagImg('" . str_replace( "'", "\'", wfMsg( 'picturegame-flagimgconfirm' ) ) . "')\">" . wfMsg( 'picturegame-reportimages' ) . " </a> - <a href=\"javascript:window.parent.document.location='" . $this->getTitle()->escapeFullURL( 'picGameAction=renderPermalink' ) . "&id=' + document.getElementById('id').value\">" . wfMsg( 'picturegame-permalink' ) . '</a>' . $editlinks . " </div> </div> <div class=\"cleared\"></div> <script language=\"javascript\">{$permalinkJS}</script> <div id=\"preload\" style=\"display:none\"> {$preload} <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"75\" height=\"75\" title=\"hourglass\"> <param name=\"movie\" value=\"" . $wgScriptPath . "/extensions/PictureGame/picturegame/ajax-loading.swf\" /> <param name=\"quality\" value=\"high\" /> <param name=\"wmode\" value=\"transparent\" /> <param name=\"bgcolor\" value=\"#ffffff\" /> <embed src=\"" . $wgScriptPath . "/extensions/PictureGame/picturegame/ajax-loading.swf\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#ffffff\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"100\"> </embed> </object> </div>"; // fix syntax coloring return $output; }
/** * Displays the form for removing a friend or a foe * @return $form Mixed: HTML code for the form */ function displayForm() { global $wgOut; $avatar = new wAvatar( $this->user_id_to, 'l' ); if ( $this->relationship_type == 1 ) { $title = wfMsg( 'ur-remove-relationship-title-friend', $this->user_name_to ); $remove = wfMsg( 'ur-remove-relationship-message-friend', $this->user_name_to, wfMsg( 'ur-remove' ) ); } else { $title = wfMsg( 'ur-remove-relationship-title-foe', $this->user_name_to ); $remove = wfMsg( 'ur-remove-relationship-message-foe', $this->user_name_to, wfMsg( 'ur-remove' ) ); } $wgOut->setPageTitle( $title ); $form = "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\"> <div class=\"relationship-action\"> {$avatar->getAvatarURL()}" . $remove . '<div class="relationship-buttons"> <input type="hidden" name="user" value="' . addslashes( $this->user_name_to ) . '" /> <input type="button" class="site-button" value="' . wfMsg( 'ur-remove' ) . '" size="20" onclick="document.form1.submit()" /> <input type="button" class="site-button" value="' . wfMsg( 'ur-cancel' ) . '" size="20" onclick="history.go(-1)" /> </div> <div class="cleared"></div> </div> </form>'; return $form; }
/** * 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 ); }
/** * 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); }
/** * How many % of this user's profile is complete? * Currently unused, I think that this might've been used in some older * ArmchairGM code, but this looks useful enough to be kept around. * * @return Integer */ public function getProfileComplete() { global $wgUser; $complete_count = 0; // Check all profile fields $profile = $this->getProfile(); foreach ( $this->profile_fields as $field ) { if ( $profile[$field] ) { $complete_count++; } $this->profile_fields_count++; } // Check if the user has a non-default avatar $this->profile_fields_count++; $avatar = new wAvatar( $wgUser->getID(), 'l' ); if ( strpos( $avatar->getAvatarImage(), 'default_' ) === false ) { $complete_count++; } return round( $complete_count / $this->profile_fields_count * 100 ); }
function wfUpdateStatus( $user_id, $user_name, $text, $date, $next_row ) { $user = User::newFromId( $user_id ); // Don't do anything if the user is blocked or the DB is read-only if ( $user->isBlocked() || wfReadOnly() ) { return ''; } // Get a database handler $dbw = wfGetDB( DB_MASTER ); // Write new data to user_status $dbw->insert( 'user_status', array( 'us_user_id' => $user_id, 'us_user_name' => $user_name, 'us_text' => $text, 'us_date' => $date, ), __METHOD__ ); // Grab all rows from user_status $res = $dbw->select( 'user_status', array( 'us_user_id', 'us_user_name', 'us_text', 'UNIX_TIMESTAMP(us_date) AS unix_time' ), array( 'us_id' => intval( $next_row ) ), __METHOD__ ); $x = 1; foreach ( $res as $row ) { $db_user_id = $row->us_user_id; $db_user_name = $row->us_user_name; $db_status_text = $row->us_text; $user_status_date = $row->unix_time; $avatar = new wAvatar( $db_user_id, 'ml' ); $userTitle = Title::makeTitle( NS_USER, $db_user_name ); $output .= "<div class=\"user-status-row\"> {$avatar->getAvatarURL()} <a href=\"{$userTitle->escapeFullURL()}\"><b>{$db_user_name}</b></a> {$db_status_text} <span class=\"user-status-date\">" . wfMsg( 'userstatus-just-added' ) . '</span> </div>'; $x++; } return $output; }
<li class="sidebar-brand left-manager"> <a>管理员</a> <div> <?php $fanbox_link = SpecialPage::getTitleFor('UserList'); $group = 'sysop'; $ums = self::getSiteManager($wgHuijiPrefix, $group); foreach ($ums as $value) { $uname = User::newFromId($value); $user_group = $uname->getEffectiveGroups(); if (!in_array('bot', $user_group) && !in_array('bot-global', $user_group)) { $usersys['user_name'] = $uname->getName(); $usersys['count'] = UserStats::getSiteEditsCount($uname, $wgHuijiPrefix); $userPage = Title::makeTitle(NS_USER, $uname->getName()); $usersys['url'] = htmlspecialchars($userPage->getFullURL()); $avatar = new wAvatar($value, 'm'); $usersys['avatar'] = $avatar->getAvatarURL(); $sysop[] = $usersys; } } foreach ($sysop as $key => $value) { $count[$key] = $value['count']; } array_multisort($count, SORT_DESC, $sysop); $nums = count($ums) > 5 ? 5 : count($ums); for ($j = 0; $j < $nums; $j++) { echo '<a href="' . $sysop[$j]['url'] . '" title="' . $sysop[$j]['user_name'] . '">' . $sysop[$j]['avatar'] . '</a>'; } if (count($ums) > 5) { echo Linker::link($fanbox_link, '>>', array('class' => 'more'), array('group' => $group, 'limit' => 50)); }
/** * Create the thumbnails and delete old files */ public function performUpload( $comment, $pageText, $watch, $user ) { global $wgUploadDirectory, $wgUser, $wgDBname, $wgMemc; $this->avatarUploadDirectory = $wgUploadDirectory . '/avatars'; $imageInfo = getimagesize( $this->mTempPath ); switch ( $imageInfo[2] ) { case 1: $ext = 'gif'; break; case 2: $ext = 'jpg'; break; case 3: $ext = 'png'; break; default: return Status::newFatal( 'filetype-banned-type' ); } $dest = $this->avatarUploadDirectory; $uid = $wgUser->getId(); $avatar = new wAvatar( $uid, 'l' ); // If this is the user's first custom avatar, update statistics (in // case if we want to give out some points to the user for uploading // their first avatar) if ( strpos( $avatar->getAvatarImage(), 'default_' ) !== false ) { $stats = new UserStatsTrack( $uid, $wgUser->getName() ); $stats->incStatField( 'user_image' ); } $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_l', 75 ); $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_ml', 50 ); $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_m', 30 ); $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname . '_' . $uid . '_s', 16 ); if ( $ext != 'jpg' ) { if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.jpg' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.jpg' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.jpg' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.jpg' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.jpg' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.jpg' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.jpg' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.jpg' ); } } if ( $ext != 'gif' ) { if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.gif' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.gif' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.gif' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.gif' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.gif' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.gif' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.gif' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.gif' ); } } if ( $ext != 'png' ) { if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.png' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_s.png' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.png' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_m.png' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.png' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_l.png' ); } if ( is_file( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.png' ) ) { unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $uid . '_ml.png' ); } } $key = wfMemcKey( 'user', 'profile', 'avatar', $uid, 's' ); $data = $wgMemc->delete( $key ); $key = wfMemcKey( 'user', 'profile', 'avatar', $uid, 'm' ); $data = $wgMemc->delete( $key ); $key = wfMemcKey( 'user', 'profile', 'avatar', $uid , 'l' ); $data = $wgMemc->delete( $key ); $key = wfMemcKey( 'user', 'profile', 'avatar', $uid, 'ml' ); $data = $wgMemc->delete( $key ); $this->mExtension = $ext; return Status::newGood(); }