/** * 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 ); }
/** * 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; }
/** * 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); }
/** * 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; }
/** * Display the form for giving out a gift to a user when there was no user * parameter in the URL. * * @return String: HTML */ function displayFormNoUser() { global $wgUser, $wgOut, $wgRequest, $wgFriendingEnabled; $output = $wgOut->setPageTitle(wfMsg('g-give-no-user-title')); // @todo FIXME: $wgRequest->getVal()...seriously? // Seems that this should use the proper MW function (maybe // $this->getTitle()->getFullURL() or something) instead. // Maybe that's the reason why I (and other people) frequently have // problems with this special page. // --Jack Phoenix <*****@*****.**>, 6 April 2011 $output .= '<form action="" method="get" enctype="multipart/form-data" name="gift"> <input type="hidden" name="title" value="' . $wgRequest->getVal('title') . '" /> <div class="g-message">' . wfMsg('g-give-no-user-message') . '</div> <div class="g-give-container">'; // If friending is enabled, build a dropdown menu of the user's // friends if ($wgFriendingEnabled) { $rel = new UserRelationship($wgUser->getName()); $friends = $rel->getRelationshipList(1); if ($friends) { $output .= '<div class="g-give-title">' . wfMsg('g-give-list-friends-title') . '</div> <div class="g-gift-select"> <select onchange="javascript:chooseFriend(this.value)"> <option value="#" selected="selected">' . wfMsg('g-select-a-friend') . '</option>'; foreach ($friends as $friend) { $output .= '<option value="' . urlencode($friend['user_name']) . '">' . $friend['user_name'] . '</option>'; } $output .= '</select> </div> <div class="g-give-separator">' . wfMsg('g-give-separator') . '</div>'; } } $output .= '<div class="g-give-title">' . wfMsg('g-give-enter-friend-title') . '</div> <div class="g-give-textbox"> <input type="text" width="85" name="user" value="" /> <input class="site-button" type="button" value="' . wfMsg('g-give-gift') . '" onclick="document.gift.submit()" /> </div> </div> </form>'; return $output; }
/** * Display the form for giving out a gift to a user when there was no user * parameter in the URL. * * @return String: HTML */ function displayFormNoUser() { global $wgUser, $wgOut, $wgFriendingEnabled; $wgOut->setPageTitle( wfMsg( 'g-give-no-user-title' ) ); $output = '<form action="" method="get" enctype="multipart/form-data" name="gift">' . Html::hidden( 'title', $this->getTitle() ) . '<div class="g-message">' . wfMsg( 'g-give-no-user-message' ) . '</div> <div class="g-give-container">'; // If friending is enabled, build a dropdown menu of the user's // friends if ( $wgFriendingEnabled ) { $rel = new UserRelationship( $wgUser->getName() ); $friends = $rel->getRelationshipList( 1 ); if ( $friends ) { $output .= '<div class="g-give-title">' . wfMsg( 'g-give-list-friends-title' ) . '</div> <div class="g-gift-select"> <select onchange="javascript:chooseFriend(this.value)"> <option value="#" selected="selected">' . wfMsg( 'g-select-a-friend' ) . '</option>'; foreach ( $friends as $friend ) { $output .= '<option value="' . urlencode( $friend['user_name'] ) . '">' . $friend['user_name'] . '</option>' . "\n"; } $output .= '</select> </div> <div class="g-give-separator">' . wfMsg( 'g-give-separator' ) . '</div>'; } } $output .= '<div class="g-give-title">' . wfMsg( 'g-give-enter-friend-title' ) . '</div> <div class="g-give-textbox"> <input type="text" width="85" name="user" value="" /> <input class="site-button" type="button" value="' . wfMsg( 'g-give-gift' ) . '" onclick="document.gift.submit()" /> </div> </div> </form>'; return $output; }
/** * 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; }
/** * Get the relationshipt list. * @param UserRelationship $relationships * @return string */ public function getAjaxRelationships($relationships) { $ajaxrels = array(); $relationshipList = $relationships->getRelationshipList(); foreach ($relationshipList as $relationshipName) { $rel = $relationships->get($relationshipName)->getDefinition(); $rel['lhs_module'] = translate($rel['lhs_module']); $rel['rhs_module'] = translate($rel['rhs_module']); //#28668 , translate the relationship type before render it . switch ($rel['relationship_type']) { case 'one-to-one': $rel['relationship_type_render'] = translate('LBL_ONETOONE'); break; case 'one-to-many': $rel['relationship_type_render'] = translate('LBL_ONETOMANY'); break; case 'many-to-one': $rel['relationship_type_render'] = translate('LBL_MANYTOONE'); break; case 'many-to-many': $rel['relationship_type_render'] = translate('LBL_MANYTOMANY'); break; default: $rel['relationship_type_render'] = ''; } $rel['name'] = $relationshipName; if ($rel['is_custom'] && isset($rel['from_studio']) && $rel['from_studio']) { $rel['name'] = $relationshipName . "*"; } $ajaxrels[] = $rel; } return $ajaxrels; }