/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgOut, $wgUser, $wgTitle, $wgRequest, $wgFanBoxScripts; // Redirect Non-logged in users to Login Page if ($wgUser->getID() == 0 && $user_name == '') { $login = SpecialPage::getTitleFor('Userlogin'); $wgOut->redirect($login->escapeFullURL('returnto=Special:ViewUserBoxes')); return false; } $tagParser = new Parser(); $wgOut->addScriptFile($wgFanBoxScripts . '/FanBoxes.js'); $wgOut->addExtensionStyle($wgFanBoxScripts . '/FanBoxes.css'); $wgOut->setPageTitle(wfMsgHtml('fanbox-nav-header')); // Code for viewing fanboxes for each user $output = ''; $user_name = $wgRequest->getVal('user', $par); $page = $wgRequest->getInt('page', 1); // If no user is set in the URL, we assume it's the current user if (!$user_name) { $user_name = $wgUser->getName(); } $user_id = User::idFromName($user_name); $user = Title::makeTitle(NS_USER, $user_name); // Error message for username that does not exist (from URL) if ($user_id == 0) { $wgOut->setPageTitle(wfMsg('fanbox-woops')); $wgOut->addHTML(wfMsg('fanbox-userdoesnotexist')); return false; } // Config for the page $per_page = 30; // Get all FanBoxes for this user into the array // Calls the FanBoxesClass file $userfan = new UserFanBoxes($user_name); $userFanboxes = $userfan->getUserFanboxes(0, $per_page, $page); $total = $userfan->getFanBoxCountByUsername($user_name); $per_row = 3; // Page title and top part $wgOut->setPageTitle(wfMsgHtml('f-list-title', $userfan->user_name)); $output .= '<div class="back-links"> <a href="' . $user->getFullURL() . '">' . wfMsgHtml('f-back-link', $userfan->user_name) . '</a> </div> <div class="fanbox-count">' . wfMsgExt('f-count', 'parsemag', $userfan->user_name, $total) . '</div> <div class="view-fanboxes-container clearfix">'; if ($userFanboxes) { $x = 1; foreach ($userFanboxes as $userfanbox) { $check_user_fanbox = $userfan->checkIfUserHasFanbox($userfanbox['fantag_id']); if ($userfanbox['fantag_image_name']) { $fantag_image_width = 45; $fantag_image_height = 53; $fantag_image = wfFindFile($userfanbox['fantag_image_name']); $fantag_image_url = ''; if (is_object($fantag_image)) { $fantag_image_url = $fantag_image->createThumb($fantag_image_width, $fantag_image_height); } $fantag_image_tag = '<img alt="" src="' . $fantag_image_url . '" />'; } if ($userfanbox['fantag_left_text'] == '') { $fantag_leftside = $fantag_image_tag; } else { $fantag_leftside = $userfanbox['fantag_left_text']; $fantag_leftside = $tagParser->parse($fantag_leftside, $wgTitle, $wgOut->parserOptions(), false); $fantag_leftside = $fantag_leftside->getText(); } $leftfontsize = '12px'; if ($userfanbox['fantag_left_textsize'] == 'mediumfont') { $leftfontsize = '14px'; } if ($userfanbox['fantag_left_textsize'] == 'bigfont') { $leftfontsize = '20px'; } $rightfontsize = '10px'; if ($userfanbox['fantag_right_textsize'] == 'smallfont') { $rightfontsize = '12px'; } if ($userfanbox['fantag_right_textsize'] == 'mediumfont') { $rightfontsize = '14px'; } // Get permalink $fantag_title = Title::makeTitle(NS_FANTAG, $userfanbox['fantag_title']); $right_text = $userfanbox['fantag_right_text']; $right_text = $tagParser->parse($right_text, $wgTitle, $wgOut->parserOptions(), false); $right_text = $right_text->getText(); // Output fanboxes $output .= '<span class="top-fanbox"> <div class="fanbox-item"> <div class="individual-fanboxtest" id="individualFanbox' . $userfanbox['fantag_id'] . '"> <div class="show-message-container" id="show-message-container' . $userfanbox['fantag_id'] . '"> <div class="permalink-container"> <a class="perma" style="font-size:8px; color:' . $userfanbox['fantag_right_textcolor'] . '" href="' . $fantag_title->escapeFullURL() . "\" title=\"{$userfanbox['fantag_title']}\">" . wfMsg('fanbox-perma') . "</a>\n\t\t\t\t<table class=\"fanBoxTable\" onclick=\"javascript:FanBoxes.openFanBoxPopup('fanboxPopUpBox{$userfanbox['fantag_id']}', 'individualFanbox{$userfanbox['fantag_id']}')\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td id=\"fanBoxLeftSideOutput\" style=\"color:" . $userfanbox['fantag_left_textcolor'] . "; font-size:{$leftfontsize}\" bgcolor=\"" . $userfanbox['fantag_left_bgcolor'] . '">' . $fantag_leftside . "</td>\n\t\t\t\t\t\t<td id=\"fanBoxRightSideOutput\" style=\"color:" . $userfanbox['fantag_right_textcolor'] . "; font-size:{$rightfontsize}\" bgcolor=\"" . $userfanbox['fantag_right_bgcolor'] . '">' . $right_text . '</td> </tr> </table> </div> </div> </div>'; if ($wgUser->isLoggedIn()) { if ($check_user_fanbox == 0) { $output .= ' <div class="fanbox-pop-up-box" id="fanboxPopUpBox' . $userfanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0" width="258px"> <tr> <td align="center">' . wfMsg('fanbox-add-fanbox') . '</td> </tr> <tr> <td align="center"> <input type="button" value="' . wfMsg('fanbox-add') . "\" size=\"20\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$userfanbox['fantag_id']}', 'individualFanbox{$userfanbox['fantag_id']}'); FanBoxes.showAddRemoveMessageUserPage(1, {$userfanbox['fantag_id']}, 'show-addremove-message')\" />\n\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"20\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$userfanbox['fantag_id']}', 'individualFanbox{$userfanbox['fantag_id']}')\" />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</div>"; } else { $output .= ' <div class="fanbox-pop-up-box" id="fanboxPopUpBox' . $userfanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0" width="258px"> <tr> <td align="center">' . wfMsg('fanbox-remove-fanbox') . '</td> </tr> <tr> <td align="center"> <input type="button" value="' . wfMsg('fanbox-remove') . "\" size=\"20\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$userfanbox['fantag_id']}', 'individualFanbox{$userfanbox['fantag_id']}'); FanBoxes.showAddRemoveMessageUserPage(2, {$userfanbox['fantag_id']}, 'show-addremove-message')\" />\n\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"20\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$userfanbox['fantag_id']}', 'individualFanbox{$userfanbox['fantag_id']}')\" />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</div>"; } } if ($wgUser->getID() == 0) { $login = SpecialPage::getTitleFor('Userlogin'); $output .= '<div class="fanbox-pop-up-box" id="fanboxPopUpBox' . $userfanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0" width="258px"> <tr> <td align="center">' . wfMsg('fanbox-add-fanbox-login') . "<a href=\"{$login->getFullURL()}\">" . wfMsg('fanbox-login') . '</a></td> </tr> <tr> <td align="center"> <input type="button" value="' . wfMsg('cancel') . "\" size=\"20\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$userfanbox['fantag_id']}', 'individualFanbox{$userfanbox['fantag_id']}')\" />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</div>"; } $output .= '</div></span>'; if ($x == count($userFanboxes) || $x != 1 && $x % $per_row == 0) { $output .= '<div class="cleared"></div>'; } $x++; } } $output .= '</div>'; // Build next/prev nav $numofpages = $total / $per_page; if ($numofpages > 1) { $output .= '<div class="page-nav">'; if ($page > 1) { $output .= '<a href="' . $this->getTitle()->escapeFullURL(array('user' => $user_name, 'page' => $page - 1)) . '">' . wfMsg('fanbox-prev') . '</a> '; } if ($total % $per_page != 0) { $numofpages++; } if ($numofpages >= 9 && $page < $total) { $numofpages = 9 + $page; } if ($numofpages >= $total / $per_page) { $numofpages = $total / $per_page + 1; } for ($i = 1; $i <= $numofpages; $i++) { if ($i == $page) { $output .= $i . ' '; } else { $output .= '<a href="' . $this->getTitle()->escapeFullURL(array('user' => $user_name, 'page' => $i)) . "\">{$i}</a> "; } } if ($total - $per_page * $page > 0) { $output .= ' <a href="' . $this->getTitle()->escapeFullURL(array('user' => $user_name, 'page' => $page + 1)) . '">' . wfMsg('fanbox-next') . '</a>'; } $output .= '</div>'; } // Output everything $wgOut->addHTML($output); }
/** * Gets the user's fanboxes if $wgEnableUserBoxes = true; and * $wgUserProfileDisplay['userboxes'] = true; and the FanBoxes extension is * installed. * * @param $user_name String: user name * @return String: HTML */ function getFanBoxes($user_name) { global $wgOut, $wgUser, $wgMemc, $wgUserProfileDisplay, $wgEnableUserBoxes; if (!$wgEnableUserBoxes || $wgUserProfileDisplay['userboxes'] == false) { return ''; } // Add CSS & JS $wgOut->addModules('ext.fanBoxes'); $output = ''; $f = new UserFanBoxes($user_name); // Try cache /* $key = wfForeignMemcKey( 'huiji', '', 'user', 'profile', 'fanboxes', "{$f->user_id}" ); $data = $wgMemc->get( $key ); if ( !$data ) { wfDebug( "Got profile fanboxes for user {$user_name} from DB\n" ); $fanboxes = $f->getUserFanboxes( 0, 10 ); $wgMemc->set( $key, $fanboxes ); } else { wfDebug( "Got profile fanboxes for user {$user_name} from cache\n" ); $fanboxes = $data; } */ $fanboxes = $f->getUserFanboxes(0, 10); $fanbox_count = $f->getFanBoxCountByUsername($user_name); $fanbox_link = SpecialPage::getTitleFor('ViewUserBoxes'); $per_row = 1; if ($fanboxes) { $output .= '<div class="panel panel-default"><div class="user-section-heading panel-heading"> <div class="user-section-title">' . wfMessage('user-fanbox-title')->plain() . '</div> <div class="user-section-actions"> <div class="action-right">'; // If there are more than ten fanboxes, display a "View all" link // instead of listing them all on the profile page if ($fanbox_count > 10) { $output .= Linker::link($fanbox_link, wfMessage('user-view-all')->plain(), array(), array('user' => $user_name)); } $output .= '</div> <div class="action-left">'; if ($fanbox_count > 10) { $output .= wfMessage('user-count-separator')->numParams(10, $fanbox_count)->parse(); } else { $output .= wfMessage('user-count-separator')->numParams($fanbox_count, $fanbox_count)->parse(); } $output .= '</div> <div class="cleared"></div> </div> </div> <div class="cleared"></div> <div class="user-fanbox-container panel-body clearfix">'; $x = 1; $tagParser = new Parser(); foreach ($fanboxes as $fanbox) { $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox['fantag_id']); if ($fanbox['fantag_image_name']) { $fantag_image_width = 45; $fantag_image_height = 53; $fantag_image = wfFindFile($fanbox['fantag_image_name']); $fantag_image_url = ''; if (is_object($fantag_image)) { $fantag_image_url = $fantag_image->createThumb($fantag_image_width, $fantag_image_height); } $fantag_image_tag = '<img alt="" src="' . $fantag_image_url . '" />'; } if ($fanbox['fantag_left_text'] == '') { $fantag_leftside = $fantag_image_tag; } else { $fantag_leftside = $fanbox['fantag_left_text']; $fantag_leftside = $tagParser->parse($fantag_leftside, $this->getTitle(), $wgOut->parserOptions(), false); $fantag_leftside = $fantag_leftside->getText(); } $leftfontsize = '10px'; $rightfontsize = '11px'; if ($fanbox['fantag_left_textsize'] == 'mediumfont') { $leftfontsize = '11px'; } if ($fanbox['fantag_left_textsize'] == 'bigfont') { $leftfontsize = '15px'; } if ($fanbox['fantag_right_textsize'] == 'smallfont') { $rightfontsize = '10px'; } if ($fanbox['fantag_right_textsize'] == 'mediumfont') { $rightfontsize = '11px'; } // Get permalink $fantag_title = Title::makeTitle(NS_FANTAG, $fanbox['fantag_title']); $right_text = $fanbox['fantag_right_text']; $right_text = $tagParser->parse($right_text, $this->getTitle(), $wgOut->parserOptions(), false); $right_text = $right_text->getText(); // Output fanboxes $output .= "<div class=\"fanbox-item\">\n\t\t\t\t\t<div class=\"individual-fanbox\" id=\"individualFanbox" . $fanbox['fantag_id'] . "\">\n\t\t\t\t\t\t<div class=\"show-message-container-profile\" id=\"show-message-container" . $fanbox['fantag_id'] . "\">\n\t\t\t\t\t\t\t<a class=\"perma\" style=\"font-size:8px; color:" . $fanbox['fantag_right_textcolor'] . "\" href=\"" . htmlspecialchars($fantag_title->getFullURL()) . "\" title=\"{$fanbox['fantag_title']}\">" . wfMessage('fanbox-perma')->plain() . "</a>\n\t\t\t\t\t\t\t<table class=\"fanBoxTableProfile\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td id=\"fanBoxLeftSideOutputProfile\" style=\"color:" . $fanbox['fantag_left_textcolor'] . "; font-size:{$leftfontsize}\" bgcolor=\"" . $fanbox['fantag_left_bgcolor'] . "\">" . $fantag_leftside . "</td>\n\t\t\t\t\t\t\t\t\t<td id=\"fanBoxRightSideOutputProfile\" style=\"color:" . $fanbox['fantag_right_textcolor'] . "; font-size:{$rightfontsize}\" bgcolor=\"" . $fanbox['fantag_right_bgcolor'] . "\">" . $right_text . "</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; if ($wgUser->isLoggedIn()) { if ($check_user_fanbox == 0) { $output .= '<div class="fanbox-pop-up-box-profile" id="fanboxPopUpBox' . $fanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0" align="center"> <tr> <td style="font-size:10px">' . wfMessage('fanbox-add-fanbox')->plain() . '</td> </tr> <tr> <td align="center"> <input type="button" class="fanbox-add-button-half" value="' . wfMessage('fanbox-add')->plain() . '" size="10" /> <input type="button" class="fanbox-cancel-button" value="' . wfMessage('cancel')->plain() . '" size="10" /> </td> </tr> </table> </div>'; } else { $output .= '<div class="fanbox-pop-up-box-profile" id="fanboxPopUpBox' . $fanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0" align="center"> <tr> <td style="font-size:10px">' . wfMessage('fanbox-remove-fanbox')->plain() . '</td> </tr> <tr> <td align="center"> <input type="button" class="fanbox-remove-button-half" value="' . wfMessage('fanbox-remove')->plain() . '" size="10" /> <input type="button" class="fanbox-cancel-button" value="' . wfMessage('cancel')->plain() . '" size="10" /> </td> </tr> </table> </div>'; } } // Show a message to anonymous users, prompting them to log in if ($wgUser->getID() == 0) { $output .= '<div class="fanbox-pop-up-box-profile" id="fanboxPopUpBox' . $fanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0" align="center"> <tr> <td style="font-size:10px">' . wfMessage('fanbox-add-fanbox-login')->parse() . '</td> </tr> <tr> <td align="center"> <input type="button" class="fanbox-cancel-button" value="' . wfMessage('cancel')->plain() . '" size="10" /> </td> </tr> </table> </div>'; } $output .= '</div>'; $x++; } $output .= '</div></div>'; } return $output; }
/** * Gets the user's fanboxes if $wgEnableUserBoxes = true; and * $wgUserProfileDisplay['userboxes'] = true; and the FanBoxes extension is * installed. * * @param $user_name String: user name * @return String: HTML */ function getFanBoxes($user_name) { global $wgOut, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgFanBoxScripts, $wgEnableUserBoxes; if (!$wgEnableUserBoxes || $wgUserProfileDisplay['userboxes'] == false) { return ''; } $wgOut->addScriptFile($wgFanBoxScripts . '/FanBoxes.js'); $wgOut->addExtensionStyle($wgFanBoxScripts . '/FanBoxes.css'); $output = ''; $f = new UserFanBoxes($user_name); $user_safe = $user_name; // Try cache /* $key = wfMemcKey( 'user', 'profile', 'fanboxes', "{$f->user_id}" ); $data = $wgMemc->get( $key ); if( !$data ) { wfDebug( "Got profile fanboxes for user {$user_name} from DB\n" ); $fanboxes = $f->getUserFanboxes( 0, 10 ); $wgMemc->set( $key, $fanboxes ); } else { wfDebug( "Got profile fanboxes for user {$user_name} from cache\n" ); $fanboxes = $data; } */ $fanboxes = $f->getUserFanboxes(0, 10); $fanbox_count = $f->getFanBoxCountByUsername($user_name); $fanbox_link = SpecialPage::getTitleFor('ViewUserBoxes'); $per_row = 1; if ($fanboxes) { $output .= '<div class="user-section-heading"> <div class="user-section-title">' . wfMsg('user-fanbox-title') . '</div> <div class="user-section-actions"> <div class="action-right">'; // If there are more than ten fanboxes, display a "View all" link // instead of listing them all on the profile page if ($fanbox_count > 10) { $output .= '<a href="' . $fanbox_link->escapeFullURL('user='******'" rel="nofollow">' . wfMsg('user-view-all') . '</a>'; } $output .= '</div> <div class="action-left">'; if ($fanbox_count > 10) { $output .= wfMsg('user-count-separator', '10', $fanbox_count); } else { $output .= wfMsg('user-count-separator', $fanbox_count, $fanbox_count); } $output .= '</div> <div class="cleared"></div> </div> </div> <div class="cleared"></div> <div class="user-fanbox-container clearfix">'; $x = 1; $tagParser = new Parser(); foreach ($fanboxes as $fanbox) { $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox['fantag_id']); if ($fanbox['fantag_image_name']) { $fantag_image_width = 45; $fantag_image_height = 53; $fantag_image = wfFindFile($fanbox['fantag_image_name']); $fantag_image_url = $fantag_image->createThumb($fantag_image_width, $fantag_image_height); $fantag_image_tag = '<img alt="" src="' . $fantag_image_url . '" />'; } if ($fanbox['fantag_left_text'] == '') { $fantag_leftside = $fantag_image_tag; } else { $fantag_leftside = $fanbox['fantag_left_text']; $fantag_leftside = $tagParser->parse($fantag_leftside, $wgTitle, $wgOut->parserOptions(), false); $fantag_leftside = $fantag_leftside->getText(); } $leftfontsize = '10px'; if ($fanbox['fantag_left_textsize'] == 'mediumfont') { $leftfontsize = '11px'; } if ($fanbox['fantag_left_textsize'] == 'bigfont') { $leftfontsize = '15px'; } if ($fanbox['fantag_right_textsize'] == 'smallfont') { $rightfontsize = '10px'; } if ($fanbox['fantag_right_textsize'] == 'mediumfont') { $rightfontsize = '11px'; } // Get permalink $fantag_title = Title::makeTitle(NS_FANTAG, $fanbox['fantag_title']); $right_text = $fanbox['fantag_right_text']; $right_text = $tagParser->parse($right_text, $wgTitle, $wgOut->parserOptions(), false); $right_text = $right_text->getText(); // Output fanboxes $output .= "<div class=\"fanbox-item\">\r\n\t\t\t\t\t<div class=\"individual-fanbox\" id=\"individualFanbox" . $fanbox['fantag_id'] . "\">\r\n\t\t\t\t\t\t<div class=\"show-message-container-profile\" id=\"show-message-container" . $fanbox['fantag_id'] . "\">\r\n\t\t\t\t\t\t\t<a class=\"perma\" style=\"font-size:8px; color:" . $fanbox['fantag_right_textcolor'] . "\" href=\"" . $fantag_title->escapeFullURL() . "\" title=\"{$fanbox['fantag_title']}\">" . wfMsg('fanbox-perma') . "</a>\r\n\t\t\t\t\t\t\t<table class=\"fanBoxTableProfile\" onclick=\"javascript:openFanBoxPopup('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td id=\"fanBoxLeftSideOutputProfile\" style=\"color:" . $fanbox['fantag_left_textcolor'] . "; font-size:{$leftfontsize}\" bgcolor=\"" . $fanbox['fantag_left_bgcolor'] . "\">" . $fantag_leftside . "</td>\r\n\t\t\t\t\t\t\t\t\t<td id=\"fanBoxRightSideOutputProfile\" style=\"color:" . $fanbox['fantag_right_textcolor'] . "; font-size:{$rightfontsize}\" bgcolor=\"" . $fanbox['fantag_right_bgcolor'] . "\">" . $right_text . "</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>"; if ($wgUser->isLoggedIn()) { if ($check_user_fanbox == 0) { $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox" . $fanbox['fantag_id'] . "\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td style=\"font-size:10px\">" . wfMsg('fanbox-add-fanbox') . "</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td align=\"center\">\r\n\t\t\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('fanbox-add') . "\" size=\"10\" onclick=\"closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}'); showAddRemoveMessageUserPage(1, {$fanbox['fantag_id']}, 'show-addremove-message-half')\" />\r\n\t\t\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"10\" onclick=\"closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" />\r\n\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</div>"; } else { $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox" . $fanbox['fantag_id'] . "\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td style=\"font-size:10px\">" . wfMsg('fanbox-remove-fanbox') . "</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td align=\"center\">\r\n\t\t\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('fanbox-remove') . "\" size=\"10\" onclick=\"closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}'); showAddRemoveMessageUserPage(2, {$fanbox['fantag_id']}, 'show-addremove-message-half')\" />\r\n\t\t\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"10\" onclick=\"closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" />\r\n\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</div>"; } } if ($wgUser->getID() == 0) { $login = SpecialPage::getTitleFor('Userlogin'); $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox" . $fanbox['fantag_id'] . "\">\r\n\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style=\"font-size:10px\">" . wfMsg('fanbox-add-fanbox-login') . "<a href=\"{$login->getFullURL()}\">" . wfMsg('fanbox-login') . "</a></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td align=\"center\">\r\n\t\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"10\" onclick=\"closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" />\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</div>"; } $output .= '</div>'; $x++; } $output .= '</div>'; } return $output; }
function UserBoxesHook($input, $args, $parser) { global $wgOut, $wgUser, $wgTitle, $wgMemc, $wgFanBoxScripts; $parser->disableCache(); $wgOut->addScriptFile($wgFanBoxScripts . '/FanBoxes.js'); $wgOut->addExtensionStyle($wgFanBoxScripts . '/FanBoxes.css'); $user_name = isset($args['user']) ? $args['user'] : $wgUser->getName(); $limit = 10; if (isset($args['limit']) && is_numeric($args['limit'])) { $limit = intval($args['limit']); } $f = new UserFanBoxes($user_name); // Try cache //$key = wfMemcKey( 'user', 'profile', 'fanboxes', $f->user_id ); //$data = $wgMemc->get( $key ); //if( !$data ) { // wfDebug( "Got profile fanboxes for user {$user_name} from DB\n" ); // $fanboxes = $f->getUserFanboxes( 0, $limit ); // $wgMemc->set( $key, $fanboxes ); //} else { // wfDebug( "Got profile fanboxes for user {$user_name} from cache\n" ); // $fanboxes = $data; //} $fanboxes = $f->getUserFanboxes(0, $limit); $fanbox_count = $f->getFanBoxCountByUsername($user_name); $fanbox_link = SpecialPage::getTitleFor('ViewUserBoxes'); $per_row = 1; $output = ''; if ($fanboxes) { $output .= '<div class="clearfix"><div class="user-fanbox-container">'; $x = 1; $tagParser = new Parser(); foreach ($fanboxes as $fanbox) { $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox['fantag_id']); if ($fanbox['fantag_image_name']) { $fantag_image_width = 45; $fantag_image_height = 53; $fantag_image = wfFindFile($fanbox['fantag_image_name']); $fantag_image_url = ''; if (is_object($fantag_image)) { $fantag_image_url = $fantag_image->createThumb($fantag_image_width, $fantag_image_height); } $fantag_image_tag = '<img alt="" src="' . $fantag_image_url . '" />'; } if ($fanbox['fantag_left_text'] == '') { $fantag_leftside = $fantag_image_tag; } else { $fantag_leftside = $fanbox['fantag_left_text']; $fantag_leftside = $tagParser->parse($fantag_leftside, $wgTitle, $wgOut->parserOptions(), false); $fantag_leftside = $fantag_leftside->getText(); } $leftfontsize = '10px'; if ($fanbox['fantag_left_textsize'] == 'mediumfont') { $leftfontsize = '11px'; } if ($fanbox['fantag_left_textsize'] == 'bigfont') { $leftfontsize = '15px'; } $rightfontsize = '10px'; if ($fanbox['fantag_right_textsize'] == 'smallfont') { $rightfontsize = '10px'; } if ($fanbox['fantag_right_textsize'] == 'mediumfont') { $rightfontsize = '11px'; } // Get permalink $fantag_title = Title::makeTitle(NS_FANTAG, $fanbox['fantag_title']); $right_text = $fanbox['fantag_right_text']; $right_text = $tagParser->parse($right_text, $wgTitle, $wgOut->parserOptions(), false); $right_text = $right_text->getText(); // Output fanboxes $output .= "<span class=\"top-fanbox\"><div class=\"fanbox-item\">\n\t\t\t<div class=\"individual-fanbox\" id=\"individualFanbox" . $fanbox['fantag_id'] . "\">\n\t\t\t\t<div class=\"show-message-container-profile\" id=\"show-message-container" . $fanbox['fantag_id'] . "\">\n\t\t\t\t\t<div class=\"relativeposition\">\n\t\t\t\t\t<a class=\"perma\" style=\"font-size:8px; color:" . $fanbox['fantag_right_textcolor'] . "\" href=\"" . $fantag_title->escapeFullURL() . "\" title=\"{$fanbox['fantag_title']}\">" . wfMsg('fanbox-perma') . "</a>\n\t\t\t\t\t<table class=\"fanBoxTableProfile\" onclick=\"javascript:FanBoxes.openFanBoxPopup('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td id=\"fanBoxLeftSideOutputProfile\" style=\"color:" . $fanbox['fantag_left_textcolor'] . "; font-size:{$leftfontsize}\" bgcolor=\"" . $fanbox['fantag_left_bgcolor'] . "\">" . $fantag_leftside . "</td>\n\t\t\t\t\t\t\t<td id=\"fanBoxRightSideOutputProfile\" style=\"color:" . $fanbox['fantag_right_textcolor'] . "; font-size:{$rightfontsize}\" bgcolor=\"" . $fanbox['fantag_right_bgcolor'] . "\">" . $right_text . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t</div>"; if ($wgUser->isLoggedIn()) { if ($check_user_fanbox == 0) { $output .= "\n\t\t\t\t\t<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox" . $fanbox['fantag_id'] . "\">\n\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"font-size:10px\" align=\"center\">" . wfMsg('fanbox-add-fanbox') . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align=\"center\">\n\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('fanbox-add') . "\" size=\"10\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}'); FanBoxes.showAddRemoveMessageUserPage(1, {$fanbox['fantag_id']}, 'show-addremove-message-half')\" />\n\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"10\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</div>"; } else { $output .= "\n\t\t\t\t\t<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox" . $fanbox['fantag_id'] . "\">\n\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"font-size:10px\" align=\"center\">" . wfMsg('fanbox-remove-fanbox') . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align=\"center\">\n\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('fanbox-remove') . "\" size=\"10\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}'); FanBoxes.showAddRemoveMessageUserPage(2, {$fanbox['fantag_id']}, 'show-addremove-message-half')\" />\n\t\t\t\t\t\t\t\t<input type=\"button\" value=\"" . wfMsg('cancel') . "\" size=\"10\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</div>"; } } if ($wgUser->getID() == 0) { $login = SpecialPage::getTitleFor('Userlogin'); $output .= '<div class="fanbox-pop-up-box-profile" id="fanboxPopUpBox' . $fanbox['fantag_id'] . '"> <table cellpadding="0" cellspacing="0"> <tr> <td style="font-size: 10px" align="center">' . wfMsg('fanbox-add-fanbox-login') . "<a href=\"{$login->getFullURL()}\">" . wfMsg('fanbox-login') . '</a> </td> <tr> <td align="center"> <input type="button" value="' . wfMsg('cancel') . "\" size=\"10\" onclick=\"FanBoxes.closeFanboxAdd('fanboxPopUpBox{$fanbox['fantag_id']}', 'individualFanbox{$fanbox['fantag_id']}')\" />\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div>"; } $output .= '</div></span><div class="cleared"></div>'; //if( $x == count( $fanboxes ) || $x != 1 && $x % $per_row == 0 ) $output .= '<div class="cleared"></div>'; $x++; } $output .= '</div></div>'; } return $output; }