private function getBadgesData() { global $wgContLang; // get achievement lists $rankingService = new AchRankingService(); $userProfileService = new AchUserProfileService(); $userProfileService->getHTML(); // have to call this because it creates our data as a side effect $this->ownerName = $userProfileService->mUserOwner->getName(); $this->ownerBadges = $userProfileService->mOwnerBadgesSimple; $this->ownerCounters = $userProfileService->mOwnerCounters; $this->ownerRank = $rankingService->getUserRankingPosition($userProfileService->mUserOwner); $this->ownerScore = $wgContLang->formatNum($rankingService->getUserScore($userProfileService->mUserOwner->getId())); if($userProfileService->mUserViewer && $userProfileService->mUserViewer->isLoggedIn() && $userProfileService->mUserViewer->getId() == $userProfileService->mUserOwner->getId()) { $this->viewer_is_owner = true; $challengesBadges = $userProfileService->mChallengesBadges; // Let's prune the challengesBadges list to the correct length before passing it to the template if ($this->max_challenges != "all") { while (count($challengesBadges) > $this->max_challenges) array_pop($challengesBadges); } $this->challengesBadges = $challengesBadges; } // UI elements $this->leaderboard_url = Skin::makeSpecialUrl("Leaderboard"); if($userProfileService->mUserViewer && $userProfileService->mUserViewer->isAllowed('editinterface')) { $this->customize_url = Skin::makeSpecialUrl("AchievementsCustomize"); } }
/** * Modify personal URLs list */ private function setupPersonalUrls() { global $wgUser; // Import the starting set of urls from the skin template $this->personal_urls = F::app()->getSkinTemplateObj()->data['personal_urls']; if ($wgUser->isAnon()) { // add login and register links for anons //$skin = RequestContext::getMain()->getSkin(); // where to redirect after login $query = F::app()->wg->Request->getValues(); if (isset($query['title'])) { if (!self::isBlacklisted($query['title'])) { $returnto = $query['title']; } else { $returnto = Title::newMainPage()->getPartialURL(); } } else { $returnto = Title::newMainPage()->getPartialURL(); } $returnto = wfGetReturntoParam($returnto); $this->personal_urls['login'] = array('text' => wfMsg('login'), 'href' => Skin::makeSpecialUrl('UserLogin', $returnto), 'class' => 'ajaxLogin', 'afterText' => Xml::element('img', array('src' => $this->wg->BlankImgUrl, 'class' => 'chevron', 'width' => '0', 'height' => '0'), '')); $this->personal_urls['register'] = array('text' => wfMsg('oasis-signup'), 'href' => Skin::makeSpecialUrl('UserSignup'), 'class' => 'ajaxRegister'); } else { // use Mypage message for userpage entry $this->personal_urls['userpage']['text'] = wfMsg('mypage'); } }
private function getUsersData($usersObjects) { $key = 0; $usersInvolved = array(); $sorting = array(); foreach ($usersObjects as $user) { if ($user->isAnon()) { $name = wfMsg('oasis-anon-user'); } $username = $user->getName(); $userpage = $user->getUserPage()->getFullUrl(); $usersInvolved[$key]['userpage'] = $userpage; if (empty($name)) { $usersInvolved[$key]['name1'] = $username; $sorting[$key] = $username; } else { $usersInvolved[$key]['name1'] = $name; $usersInvolved[$key]['name2'] = $username; // if user has real name and is not an anon use the real name // if he's an anon use username $sorting[$key] = $user->isAnon() ? $username : $name; } $usersInvolved[$key]['username'] = $username; $usersInvolved[$key]['userpage'] = $userpage; $usersInvolved[$key]['userwall'] = Title::newFromText($username, NS_USER_WALL)->getFullUrl(); $usersInvolved[$key]['usertalk'] = Title::newFromText($username, NS_USER_TALK)->getFullUrl(); $usersInvolved[$key]['usercontribs'] = Skin::makeSpecialUrl('Contributions') . '/' . $username; $usersInvolved[$key]['userblock'] = Skin::makeSpecialUrl('Block') . '/' . $username; $key++; } $sorting = array_map('mb_strtolower', $sorting); array_multisort($sorting, SORT_ASC, SORT_STRING, $usersInvolved); return $usersInvolved; }
public function getHTML() { wfProfileIn(__METHOD__); if ($this->isVisible()) { $ownerName = $this->ownerUser->getName(); $tmplData = array(); $tmplData['ownerBadges'] = $this->getBadgesAnnotated(); $tmplData['challengesBadges'] = $this->getChallengesAnnotated(); $tmplData['title_no'] = wfMsg('achievements-profile-title-no', $ownerName); $tmplData['title'] = wfMsgExt('achievements-profile-title', array('parsemag'), $ownerName, $this->owner->getBadgesCount()); $tmplData['title_challenges'] = wfMsg('achievements-profile-title-challenges', $ownerName); $tmplData['leaderboard_url'] = Skin::makeSpecialUrl("Leaderboard"); if ($this->owner->getBadgesCount() > 0) { $rankingService = new AchRankingService(); $tmplData['user_rank'] = $rankingService->getUserRankingPosition($this->ownerUser); } if ($this->viewerUser->isAllowed('editinterface')) { $tmplData['customize_url'] = Skin::makeSpecialUrl("AchievementsCustomize"); } $template = new EasyTemplate(dirname(__FILE__) . '/../templates'); $template->set_vars($tmplData); $out = $template->render('ProfileBox'); } else { $out = ''; } wfProfileOut(__METHOD__); return $out; }
function PeerReview_AddActionContentHook2($skin, &$links) { global $wgTitle; if ($wgTitle->getNamespace() != NS_SPECIAL) { $links['actions']['ownership'] = array('class' => false, 'text' => "Ownership", 'href' => Skin::makeSpecialUrl('PageOwner') . "/" . $skin->mTitle->getEscapedText()); } return true; }
function wfSudoPersonalUrls( &$personal_urls, &$wgTitle ) { // Replace logout link with a unsudo link while in a sudo login. if( isset( $_SESSION['wsSudoId'] ) && $_SESSION['wsSudoId'] > 0 ) { $personal_urls['logout'] = array( 'text' => wfMsg( 'sudo-personal-unsudo' ), 'href' => Skin::makeSpecialUrl( 'Sudo', 'mode=unsudo' ), 'active' => false ); } return true; }
function renderNewpage($input, $argv, &$parser) { # $argv is an array containing any arguments passed to the # extension like <example argument="foo" bar>.. # Put this on the sandbox page: (works in MediaWiki 1.5.5) # <example argument="foo" argument2="bar">Testing text **example** in between the new tags</example> $saneinput = empty($argv['emptysearchbox']) ? $parser->getTitle()->getText() : ''; $action = Skin::makeSpecialUrl('NewWebsite'); $header = wfMsgExt('newmark-header', array('parseinline')); $submit = wfMsg('newmark-submit'); $output = "<p />\n\t\t<form action=\"{$action}\" method=\"get\">\n\t\t{$header}\n\t\t<input type=\"text\" name=\"param\" size=\"40\" maxlength=\"80\" value=\"{$saneinput}\" />\n\t\t<input type=\"submit\" value=\"{$submit}\" />\n\t\t</form><p />"; return $output; }
/** * Adds several Facebook Connect variables to the page: * * fbAppId - Wikia's App ID * fbScript * fbLogo * fbLogoutURL - (deprecated) The URL to be redirected to on a disconnect * fbReturnToTitle * fbScriptLangCode * */ public static function MakeGlobalVariablesScript(&$vars) { global $fbScript, $fbAppId, $fbLogo; $wg = F::app()->wg; $thisurl = $wg->Title->getPrefixedURL(); $vars['fbAppId'] = $fbAppId; $vars['fbScript'] = $fbScript; $vars['fbLogo'] = (bool) $fbLogo; $vars['fbLogoutURL'] = Skin::makeSpecialUrl('Userlogout', $wg->Title->isSpecial('Preferences') ? '' : "returnto={$thisurl}"); $vals = $wg->Request->getValues(); if (!empty($vals['title'])) { $vars['fbReturnToTitle'] = $vals['title']; } // macbre: needed for channelUrl $vars['fbScriptLangCode'] = FacebookClientLocale::getLocale(); $vars['wgEnableFacebookClientExt'] = F::app()->wg->EnableFacebookClientExt; return true; }
function WidgetCommunity($id, $params) { global $wgEnableCommunityWidget, $wgTitle; if (empty($wgEnableCommunityWidget)) { return ''; } if ($params['skinname'] != 'oasis') { return ''; } if (!class_exists('ActivityFeedHelper')) { return ''; } wfProfileIn(__METHOD__); global $wgUser, $wgLang, $wgLanguageCode, $wgStylePath, $wgEnableMyHomeExt, $wgContentNamespaces; $total = SiteStats::articles(); /* RT#64490: Strange Article Count in Latest Activity on some new wikis */ if ($total < 0 || $total > 1.0E+18) { $total = 0; } $total = $wgLang->formatNum($total); $footerButton = array(); if (!empty($wgEnableMyHomeExt)) { $footerButton['text'] = wfMsg('widget-community-more'); $footerButton['href'] = Skin::makeSpecialUrl($wgUser->isLoggedIn() ? 'MyHome' : 'ActivityFeed'); $footerButton['class'] = 'wikia-button forward'; } else { $footerButton['text'] = wfMsg('recentchanges'); $footerButton['href'] = Skin::makeSpecialUrl('RecentChanges'); $footerButton['class'] = 'wikia-button forward'; } $maxElements = 5; $includeNamespaces = implode('|', $wgContentNamespaces); $uselang = $wgLang->getCode(); //this should be the same as in /extensions/wikia/MyHome/ActivityFeedHelper.php $parameters = array('type' => 'widget', 'tagid' => $id, 'maxElements' => $maxElements, 'flags' => array('shortlist'), 'uselang' => $uselang, 'includeNamespaces' => $includeNamespaces); $userLangEqContent = $uselang == $wgLanguageCode; $feedHTML = ActivityFeedHelper::getListForWidget($parameters, $userLangEqContent); // template stuff $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('tagid' => $id, 'timestamp' => wfTimestampNow(), 'header' => wfMsg('monaco-articles-on', $total), 'feedHTML' => $feedHTML, 'footerButton' => $footerButton)); $output = $tmpl->render('WidgetCommunity'); wfProfileOut(__METHOD__); return $output; }
public function generateReadHtml() { $config = $this->campaign->getParsedConfig(); $campaignTitle = array_key_exists('title', $config) ? $config['title'] : $this->campaign->getName(); $campaignDescription = array_key_exists('description', $config) ? $config['description'] : ''; $campaignViewMoreLink = $this->campaign->getTrackingCategory()->getFullURL(); $gallery = ImageGalleryBase::factory('packed-hover'); $gallery->setContext($this->context); $gallery->setWidths(180); $gallery->setHeights(180); $gallery->setShowBytes(false); $this->context->getOutput()->setSquidMaxage(UploadWizardConfig::getSetting('campaignSquidMaxAge')); $this->context->getOutput()->setHTMLTitle($this->context->msg('pagetitle', $campaignTitle)); $images = $this->campaign->getUploadedMedia(); if ($this->context->getUser()->isAnon()) { $urlParams = array('returnto' => $this->campaign->getTitle()->getPrefixedText()); if ($this->isCampaignExtensionEnabled()) { $campaignTemplate = UploadWizardConfig::getSetting('campaignCTACampaignTemplate'); $urlParams['campaign'] = str_replace('$1', $this->campaign->getName(), $campaignTemplate); } $createAccountUrl = Skin::makeSpecialUrlSubpage('UserLogin', 'signup', $urlParams); $uploadLink = Html::element('a', array('class' => 'mw-ui-big mw-ui-button mw-ui-primary', 'href' => $createAccountUrl), wfMessage('mwe-upwiz-campaign-create-account-button')->text()); } else { $uploadUrl = Skin::makeSpecialUrl('UploadWizard', array('campaign' => $this->campaign->getName())); $uploadLink = Html::element('a', array('class' => 'mw-ui-big mw-ui-button mw-ui-primary', 'href' => $uploadUrl), wfMessage('mwe-upwiz-campaign-upload-button')->text()); } if (count($images) === 0) { $body = Html::element('div', array('id' => 'mw-campaign-no-uploads-yet'), wfMessage('mwe-upwiz-campaign-no-uploads-yet')->plain()); } else { foreach ($images as $image) { $gallery->add($image); } $body = Html::rawElement('div', array('id' => 'mw-campaign-images'), $gallery->toHTML()) . Html::rawElement('a', array('id' => 'mw-campaign-view-all', 'href' => $campaignViewMoreLink), Html::rawElement('span', array('class' => 'mw-campaign-chevron mw-campaign-float-left'), ' ') . wfMessage('mwe-upwiz-campaign-view-all-media')->escaped() . Html::rawElement('span', array('class' => 'mw-campaign-chevron mw-campaign-float-right'), ' ')); } if (UploadWizardConfig::getSetting('campaignExpensiveStatsEnabled') === true) { $uploaderCount = $this->campaign->getTotalContributorsCount(); $campaignExpensiveStats = Html::rawElement('div', array('class' => 'mw-campaign-number-container'), Html::element('div', array('class' => 'mw-campaign-number'), $this->context->getLanguage()->formatNum($uploaderCount)) . Html::element('span', array('class' => 'mw-campaign-number-desc'), wfMessage('mwe-upwiz-campaign-contributors-count-desc')->numParams($uploaderCount)->text())); } else { $campaignExpensiveStats = ''; } $uploadCount = $this->campaign->getUploadedMediaCount(); $result = Html::rawElement('div', array('id' => 'mw-campaign-container'), Html::rawElement('div', array('id' => 'mw-campaign-header'), Html::rawElement('div', array('id' => 'mw-campaign-primary-info'), Html::rawElement('p', array('id' => 'mw-campaign-title'), $campaignTitle) . Html::rawElement('p', array('id' => 'mw-campaign-description'), $campaignDescription) . $uploadLink) . Html::rawElement('div', array('id' => 'mw-campaign-numbers'), $campaignExpensiveStats . Html::rawElement('div', array('class' => 'mw-campaign-number-container'), Html::element('div', array('class' => 'mw-campaign-number'), $this->context->getLanguage()->formatNum($uploadCount)) . Html::element('span', array('class' => 'mw-campaign-number-desc'), wfMessage('mwe-upwiz-campaign-media-count-desc')->numParams($uploadCount)->text())))) . $body); return $result; }
/** * Modify personal URLs list */ private function setupPersonalUrls() { global $wgUser, $wgComboAjaxLogin; // Import the starting set of urls from the skin template $this->personal_urls = F::app()->getSkinTemplateObj()->data['personal_urls']; if ($wgUser->isAnon()) { // add login and register links for anons //$skin = RequestContext::getMain()->getSkin(); // where to redirect after login $returnto = wfGetReturntoParam(); if(empty($wgComboAjaxLogin)) { $signUpHref = Skin::makeSpecialUrl('UserLogin', $returnto); } else { $signUpHref = Skin::makeSpecialUrl('Signup', $returnto); } $this->personal_urls['login'] = array( 'text' => wfMsg('login'), 'href' => $signUpHref . "&type=login", 'class' => 'ajaxLogin', 'afterText' => Xml::element('img', array( 'src' => $this->wg->BlankImgUrl, 'class' => 'chevron', 'width' => '0', 'height' => '0', ), ''), ); $this->personal_urls['register'] = array( 'text' => wfMsg('oasis-signup'), 'href' => $signUpHref . "&type=signup", 'class' => 'ajaxRegister' ); } else { // use Mypage message for userpage entry $this->personal_urls['userpage']['text'] = wfMsg('mypage'); } }
public function getHTML() { wfProfileIn(__METHOD__); global $wgTitle, $wgUser; //fix #10881, get correct username from user namespace subpages $this->mUserOwner = F::build('User', array(UserPagesHeaderController::getUserName($wgTitle, BodyController::getUserPagesNamespaces())), 'newFromName'); if (in_array(strtolower(RequestContext::getMain()->getSkin()->getSkinName()), array('oasis')) && $this->mUserOwner && AchAwardingService::canEarnBadges($this->mUserOwner) && $this->mUserOwner->isLoggedIn() && !($wgUser->getId() == $this->mUserOwner->getId() && $wgUser->getOption('hidepersonalachievements'))) { $this->mUserViewer = $wgUser; if ($this->mUserViewer->isLoggedIn() && $this->mUserViewer->getId() != $this->mUserOwner->getId()) { $this->loadViewerBadges(); $this->loadViewerCounters(); } $this->loadOwnerBadges(); $this->loadOwnerCounters(); $this->prepareChallenges(); $tmplData = array(); $tmplData['ownerBadges'] = $this->mOwnerBadgesSimple; $tmplData['challengesBadges'] = $this->mChallengesBadges; $tmplData['title_no'] = wfMsg('achievements-profile-title-no', $this->mUserOwner->getName()); $tmplData['title'] = wfMsgExt('achievements-profile-title', array('parsemag'), $this->mUserOwner->getName(), count($this->mOwnerBadgesSimple)); $tmplData['title_challenges'] = wfMsg('achievements-profile-title-challenges', $this->mUserOwner->getName()); $tmplData['leaderboard_url'] = Skin::makeSpecialUrl("Leaderboard"); if (count($this->mOwnerBadgesExtended) > 0) { $rankingService = new AchRankingService(); $tmplData['user_rank'] = $rankingService->getUserRankingPosition($this->mUserOwner); } if ($this->mUserViewer->isAllowed('editinterface')) { $tmplData['customize_url'] = Skin::makeSpecialUrl("AchievementsCustomize"); } $template = new EasyTemplate(dirname(__FILE__) . '/../templates'); $template->set_vars($tmplData); $out = $template->render('ProfileBox'); } else { $out = ''; } wfProfileOut(__METHOD__); return $out; }
public function executeIndex() { global $wgContLang; wfProfileIn(__METHOD__); $userProfileService = new AchUserProfileService(); if (!$userProfileService->isVisible()) { $this->skipRendering(); wfProfileOut(__METHOD__); return; } // add CSS and JS for this module $this->response->addAsset('achievements_css'); $this->response->addAsset('achievements_js'); $rankingService = new AchRankingService(); // get achievement lists $this->ownerName = $userProfileService->getOwnerUser()->getName(); $this->ownerBadgesCount = $userProfileService->getBadgesCount(); $this->ownerBadges = $userProfileService->getBadgesAnnotated(0); $this->ownerCounters = $userProfileService->getCounters(); $this->ownerRank = $rankingService->getUserRankingPosition($userProfileService->getOwnerUser()); $this->ownerScore = $wgContLang->formatNum($rankingService->getUserScore($userProfileService->getOwnerUser()->getId())); // if user is viewing their own page if ($userProfileService->getViewerUser() && !$userProfileService->getViewerUser()->isAnon() && $userProfileService->getViewerUser()->getId() == $userProfileService->getOwnerUser()->getId()) { $this->viewer_is_owner = true; $challengesBadges = $userProfileService->getChallengesAnnotated(); // Let's prune the challengesBadges list to the correct length before passing it to the template if ($this->max_challenges != "all") { $challengesBadges = array_slice($challengesBadges, 0, $this->max_challenges); } $this->challengesBadges = $challengesBadges; } // UI elements $this->leaderboard_url = Skin::makeSpecialUrl("Leaderboard"); if ($userProfileService->getViewerUser() && $userProfileService->getViewerUser()->isAllowed('editinterface')) { $this->customize_url = Skin::makeSpecialUrl("AchievementsCustomize"); } wfProfileOut(__METHOD__); }
/** * Get URL to user page / Special:Contributions */ static function getUrl($userName) { wfProfileIn(__METHOD__); static $linksCache; $url = ''; if (isset($linksCache[$userName])) { $url = $linksCache[$userName]; } else { if (User::isIP($userName)) { // anon: point to Special:Contributions $url = Skin::makeSpecialUrl('Contributions') . '/' . $userName; } else { // user: point to user page $userPage = Title::newFromText($userName, NS_USER); if (!is_null($userPage)) { $url = $userPage->getLocalUrl(); } } $linksCache[$userName] = $url; } wfProfileOut(__METHOD__); return $url; }
/** * Return array of links (href, text, id) for expert tools box * Author: Inez Korczynski (inez at wikia.com) * @return array */ public final function GetExpertTools() { wfProfileIn(__METHOD__); $links = array(); # Create page $url = Skin::makeSpecialUrl('Createpage'); $text = self::Translate('createpage'); $id = 'createpage'; $links[] = array('url' => $url, 'text' => $text, 'id' => $id); # Recent changes $url = SpecialPage::getTitleFor('Recentchanges')->getLocalURL(); $text = self::Translate('recentchanges'); $id = 'recentchanges'; $links[] = array('url' => $url, 'text' => $text, 'id' => $id); if (!is_null($this->skin) && !empty($this->skin->data['nav_urls'])) { foreach ($this->skin->data['nav_urls'] as $key => $val) { if (!empty($val) && $key != 'mainpage' && $key != 'print') { $links[] = array('url' => $val['href'], 'text' => self::Translate($key), 'id' => $key); } } } if (!is_null($this->skin) && !empty($this->skin->data['feeds'])) { foreach ($this->skin->data['feeds'] as $key => $val) { if (!empty($val) && $key != 'mainpage' && $key != 'print') { $links[] = array('url' => $val['href'], 'text' => $val['text'], 'id' => $key); } } } wfProfileOut(__METHOD__); return $links; }
/** * Outputs the HTML for the the badge. If 'compact' is set to true, displays a version with less info * that is used on the ActivityFeed (since the user's name, etc. are already on the associated RecentChange). * * @param badgeWrapper - not an AchBadge, but rather an associative array which contains an AchBadge and some other info. */ public static function renderForActivityFeed($badgeWrapper, $compact = true) { wfProfileIn(__METHOD__); $badge_name = htmlspecialchars($badgeWrapper['badge']->getName()); $badge_url = $badgeWrapper['badge']->getPictureUrl(82); $badge_url_hover = $badgeWrapper['badge']->getPictureUrl(90); $badge_details = $badgeWrapper['badge']->getDetails(); $linkToLeaderboard = Skin::makeSpecialUrl('Leaderboard'); if ($compact) { $info = wfMsg('achievements-activityfeed-info', $badge_name, $badgeWrapper['badge']->getGiveFor(), $linkToLeaderboard); } else { // This was for the sidebar on the leaderboard page. Not sure if it makes sense to keep it in this function as an option. $info = wfMsg('achievements-recent-info', $badgeWrapper['user']->getUserPage()->getLocalURL(), $badgeWrapper['user']->getName(), $badge_name, $badgeWrapper['badge']->getGiveFor(), wfTimeFormatAgo($badgeWrapper['date'])); } ?> <div class='achievement-in-activity-feed'> <div class="profile-hover"> <img src="<?php echo $badge_url_hover; ?> " height="90" width="90" /> <div class="profile-hover-text"> <h3><?php echo $badge_name; ?> </h3> <p><?php echo $badge_details; ?> </p> </div> </div> <a href="<?php echo $linkToLeaderboard; ?> " class='achievement-image-link'> <img rel="leaderboard" src="<?php echo $badge_url; ?> " alt="<?php echo $badge_name; ?> " height="82" width="82" /> </a> <div class="badge-text"> <p><?php echo $info; ?> </p> </div> </div> <div class="feed-clear"></div> <?php wfProfileOut(__METHOD__); }
/** * Insert global watchlist page link into the personal URLs. * * @access public * @param array Peronsal URLs array. * @param object Title object for the current page. * @param object SkinTemplate instance that is setting up personal urls * @return boolean True */ public static function onPersonalUrls(array &$personalUrls, Title $title, SkinTemplate $skin) { $URL = Skin::makeSpecialUrl('GlobalWatchlist'); if (!$skin->getUser()->isAnon()) { $globalwatchlist = ['globalwatchlist' => ['text' => wfMessage('globalwatchlist')->text(), 'href' => $URL, 'active' => true]]; Curse::array_insert_before_key($personalUrls, 'watchlist', $globalwatchlist); } return true; }
function Ach_GetMenu(&$nodes) { $nodes[0]['children'][] = count($nodes); $nodes[] = array('text' => wfMsg('achievements-leaderboard-navigation-item'), 'href' => Skin::makeSpecialUrl("Leaderboard")); return true; }
/** * @author Federico "Lox" Lucignano * * Adds a reference to an article related to this list's contents * * @param Title $relatedArticle a Title instance for the article to reference * * @return mixed true in case of success, otherwise a multidimensional array of error messages in this form: array( array( 'msg' => MESSAGE_KEY, 'params' => array() ) ) */ public function setPicture(Title $picture = null) { if (!empty($picture)) { if (!$picture->exists() || $picture->getNamespace() != NS_FILE) { $pictureName = $picture->getText(); $errors[] = array('msg' => 'toplists-error-picture-not-exists', 'params' => array($pictureName, Skin::makeSpecialUrl("Upload", array('wpDestFile' => $pictureName)))); } } $this->mPicture = $picture; return true; }
private function add($item, $res) { wfProfileIn(__METHOD__); global $wgMemc; if ($this->removeDuplicatesType == 0) { //default $key = $res['user'] . '#' . $res['title'] . '#' . $res['comment']; if (is_array($res['rc_params']) && !empty($res['rc_params']['imageInserts'])) { $key .= json_encode($res['rc_params']['imageInserts']); } if (is_array($res['rc_params']) && !empty($res['rc_params']['categoryInserts'])) { $key .= json_encode($res['rc_params']['categoryInserts']); } global $wgWallNS; if (!empty($res['ns']) && !empty($wgWallNS) && in_array(MWNamespace::getSubject($res['ns']), $wgWallNS)) { $key = $res['title']; } } elseif ($this->removeDuplicatesType == 1) { //used in `shortlist`, activity tag $key = $res['title']; } if (!isset($this->results[$key])) { $item['timestamp'] = $res['timestamp']; if (!isset(self::$users[$res['user']])) { if (isset($res['anon'])) { $users[$res['user']] = Xml::element('a', array('href' => Skin::makeSpecialUrl('Contributions') . '/' . $res['user'], 'rel' => 'nofollow'), wfMsg('masthead-anonymous-user')); } else { $ut = Title::newFromText($res['user'], NS_USER); if (empty($ut)) { //we have malformed user names in UTF-8 that causes above function to fail (see FB#1731) wfProfileOut(__METHOD__); return; } if ($ut->isKnown()) { $users[$res['user']] = Xml::element('a', array('href' => $ut->getLocalUrl(), 'rel' => 'nofollow'), $res['user']); } else { $users[$res['user']] = Xml::element('a', array('href' => $ut->getLocalUrl(), 'rel' => 'nofollow', 'class' => 'new'), $res['user']); //$users[$res['user']] = Xml::element('a', array('href' => Skin::makeSpecialUrl('Contributions').'/'.$res['user'], 'rel' => 'nofollow'), $res['user']); } } } $item['user'] = $users[$res['user']]; $item['username'] = $res['user']; if (is_array($res['rc_params'])) { $useflags = !empty($this->parameters['flags']); $shortlist = $useflags && in_array('shortlist', $this->parameters['flags']); $hideimages = $useflags && ($shortlist || in_array('hideimages', $this->parameters['flags'])); $hidevideos = $useflags && ($shortlist || in_array('hidevideos', $this->parameters['flags'])); if (isset($res['rc_params']['autosummaryType'])) { $item['autosummaryType'] = $res['rc_params']['autosummaryType']; } if (isset($res['rc_params']['imageInserts'])) { $item['new_images'] = $item['new_videos'] = array(); foreach ($res['rc_params']['imageInserts'] as $imageName) { if (!$hidevideos && $imageName[0] == ':') { // video $video = self::getThumb(substr($imageName, 1)); if ($video) { $item['new_videos'][] = $video; } } elseif (!$hideimages) { // image if (!isset(self::$images[$imageName])) { wfProfileIn(__METHOD__ . "-imagelinks-count"); $memcKey = wfMemcKey('ac_image_cnt', $imageName); self::$images[$imageName] = $wgMemc->get($memcKey); // Note that memcache returns null if record does not exists in cache // versus 0 returned from database when image does not link to anything if (self::$images[$imageName] === false) { $dbr = wfGetDB(DB_SLAVE); self::$images[$imageName] = $dbr->selectField('imagelinks', 'count(*) as cnt', array('il_to' => $imageName), __METHOD__); $wgMemc->set($memcKey, self::$images[$imageName], 60 * 60 * 12); } wfProfileOut(__METHOD__ . "-imagelinks-count"); } if (self::$images[$imageName] < 20) { $imgageObj = false; $image = self::getThumb($imageName, $imgageObj); if ($image) { if (WikiaFileHelper::isFileTypeVideo($imgageObj)) { $item['new_videos'][] = $image; } else { $item['new_images'][] = $image; } } else { // this trick will avoid checking more then one time if image exists when it does not exists self::$images[$imageName] = 20; } } } } if (count($item['new_images']) == 0) { unset($item['new_images']); } if (count($item['new_videos']) == 0) { unset($item['new_videos']); } } if (isset($res['rc_params']['categoryInserts']) && count($res['rc_params']['categoryInserts'])) { $item['new_categories'] = $res['rc_params']['categoryInserts']; } if (isset($res['rc_params']['viewMode'])) { $item['viewMode'] = $res['rc_params']['viewMode']; } if (isset($res['rc_params']['CategorySelect'])) { $item['CategorySelect'] = $res['rc_params']['CategorySelect']; } if (isset($res['rc_params']['Badge'])) { $item['Badge'] = $res['rc_params']['Badge']; } } if (class_exists('Wall') && !empty($item['wall'])) { $wh = F::build('WallHelper', array()); if (!empty($item['parent-id'])) { $data = $wh->getWallComments($item['parent-id']); $item['comments'] = $data['comments']; $item['comments-count'] = $data['count']; } else { $data = $wh->getWallComments($item['article-id']); $item['comments'] = $data['comments']; $item['comments-count'] = $data['count']; } } $item['ns'] = $res['ns']; $this->results[$key] = $item; } wfProfileOut(__METHOD__); }
function doSpecialCreateForm($query) { global $wgOut, $wgRequest, $sfgScriptPath; $db = wfGetDB(DB_SLAVE); if (!is_null($query)) { $presetFormName = str_replace('_', ' ', $query); $wgOut->setPageTitle(wfMessage('sf-createform-with-name', $presetFormName)->text()); $form_name = $presetFormName; } else { $presetFormName = null; $form_name = $wgRequest->getVal('form_name'); } // Create Javascript to populate fields to let the user input // parameters for the field, based on the input type selected // in the dropdown. $url = Skin::makeSpecialUrl('CreateForm', "showinputtypeoptions=' + this.val() + '&formfield=' + this.attr('formfieldid') + '"); foreach ($wgRequest->getValues() as $param => $value) { $url .= '¶ms[' . Xml::escapeJsString($param) . ']=' . Xml::escapeJsString($value); } $wgOut->addModules('ext.semanticforms.collapsible'); $section_name_error_str = '<font color="red" id="section_error">' . wfMessage('sf_blank_error')->escaped() . '</font>'; $wgOut->addScript("<script>\njQuery.fn.displayInputParams = function() {\n\tinputParamsDiv = this.closest('.formField').find('.otherInputParams');\n\tjQuery.ajax({\n\t\turl: '{$url}',\n\t\tcontext: document.body,\n\t\tsuccess: function(data){\n\t\t\tinputParamsDiv.html(data);\n\t\t}\n\t});\n};\njQuery(document).ready(function() {\n\tjQuery('.inputTypeSelector').change( function() {\n\t\tjQuery(this).displayInputParams();\n\t});\n\tjQuery('#addsection').click( function(event) {\n\tif(jQuery('#sectionname').val() == '') {\n\t\t\tevent.preventDefault();\n\t\t\tjQuery('#section_error').remove();\n\t\t\tjQuery('<div/>').append('{$section_name_error_str}').appendTo('#sectionerror');\n\t}\n });\n});\n</script>"); // Get the names of all templates on this site. $all_templates = array(); $res = $db->select('page', 'page_title', array('page_namespace' => NS_TEMPLATE, 'page_is_redirect' => 0), __METHOD__, array('ORDER BY' => 'page_title')); if ($db->numRows($res) > 0) { while ($row = $db->fetchRow($res)) { $template_name = str_replace('_', ' ', $row[0]); $all_templates[] = $template_name; } } $deleted_template_loc = null; $deleted_section_loc = null; // To keep the templates and sections $form_items = array(); // Handle inputs. foreach ($wgRequest->getValues() as $var => $val) { # ignore variables that are not of the right form if (strpos($var, "_") != false) { # get the template declarations and work from there list($action, $id) = explode("_", $var, 2); if ($action == "template") { // If the button was pressed to remove // this template, just don't add it to // the array. if ($wgRequest->getVal("del_{$id}") != null) { $deleted_template_loc = $id; } else { $form_template = SFTemplateInForm::create($val, $wgRequest->getVal("label_{$id}"), $wgRequest->getVal("allow_multiple_{$id}")); $form_items[] = array('type' => 'template', 'name' => $form_template->getTemplateName(), 'item' => $form_template); } } elseif ($action == "section") { if ($wgRequest->getVal("delsection_{$id}") != null) { $deleted_section_loc = $id; } else { $form_section = SFPageSection::create($val); $form_items[] = array('type' => 'section', 'name' => $form_section->getSectionName(), 'item' => $form_section); } } } } if ($wgRequest->getVal('add_field') != null) { $form_template = SFTemplateInForm::create($wgRequest->getVal('new_template'), "", false); $template_loc = $wgRequest->getVal('before_template'); $template_count = 0; if ($template_loc === null) { $new_template_loc = 0; $template_loc = 0; } else { // Count the number of templates before the // location of the template to be added for ($i = 0; $i < $template_loc; $i++) { if ($form_items[$i]['type'] == 'template') { $template_count++; } } $new_template_loc = $template_count; } // @HACK - array_splice() doesn't work for objects, so // we have to first insert a stub element into the // array, then replace that with the actual object. array_splice($form_items, $template_loc, 0, "stub"); $form_items[$template_loc] = array('type' => 'template', 'name' => $form_template->getTemplateName(), 'item' => $form_template); } else { $template_loc = null; $new_template_loc = null; } if ($wgRequest->getVal('add_section') != null) { $form_section = SFPageSection::create($wgRequest->getVal('sectionname')); $section_loc = $wgRequest->getVal('before_section'); $section_count = 0; if ($section_loc === null) { $new_section_loc = 0; $section_loc = 0; } else { // Count the number of sections before the // location of the section to be added for ($i = 0; $i < $section_loc; $i++) { if ($form_items[$i]['type'] == 'section') { $section_count++; } } $new_section_loc = $section_count; } // The same used hack for templates array_splice($form_items, $section_loc, 0, "stub"); $form_items[$section_loc] = array('type' => 'section', 'name' => $form_section->getSectionName(), 'item' => $form_section); } else { $section_loc = null; $new_section_loc = null; } // Now cycle through the templates and fields, modifying each // one per the query variables. $templates = 0; $sections = 0; foreach ($form_items as $fi) { if ($fi['type'] == 'template') { foreach ($fi['item']->getFields() as $j => $field) { $old_i = SFFormUtils::getChangedIndex($templates, $new_template_loc, $deleted_template_loc); foreach ($wgRequest->getValues() as $key => $value) { if (($pos = strpos($key, '_' . $old_i . '_' . $j)) != false) { $paramName = substr($key, 0, $pos); // Spaces got replaced by // underlines in the query. $paramName = str_replace('_', ' ', $paramName); } else { continue; } if ($paramName == 'label') { $field->template_field->setLabel($value); } elseif ($paramName == 'input type') { $input_type = $wgRequest->getVal("input_type_" . $old_i . "_" . $j); if ($input_type == 'hidden') { $field->template_field->setInputType($input_type); $field->setIsHidden(true); } elseif (substr($input_type, 0, 1) == '.') { // It's the default input type - // don't do anything. } else { $field->template_field->setInputType($input_type); } } else { if (!empty($value)) { if ($value == 'on') { $value = true; } $field->setFieldArg($paramName, $value); } } } } $templates++; } elseif ($fi['type'] == 'section') { $section = $fi['item']; $old_i = SFFormUtils::getChangedIndex($sections, $new_section_loc, $deleted_section_loc); foreach ($wgRequest->getValues() as $key => $value) { if (($pos = strpos($key, '_section_' . $old_i)) != false) { $paramName = substr($key, 0, $pos); $paramName = str_replace('_', ' ', $paramName); } else { continue; } if (!empty($value)) { if ($value == 'on') { $value = true; } if ($paramName == 'level') { $section->setSectionLevel($value); } elseif ($paramName == 'hidden') { $section->setIsHidden($value); } elseif ($paramName == 'restricted') { $section->setIsRestricted($value); } elseif ($paramName == 'mandatory') { $section->setIsMandatory($value); } else { $section->setSectionArgs($paramName, $value); } } } $sections++; } } $form = SFForm::create($form_name, $form_items); // If a submit button was pressed, create the form-definition // file, then redirect. $save_page = $wgRequest->getCheck('wpSave'); $preview_page = $wgRequest->getCheck('wpPreview'); if ($save_page || $preview_page) { $validToken = $this->getUser()->matchEditToken($wgRequest->getVal('csrf'), 'CreateForm'); if (!$validToken) { $text = "This appears to be a cross-site request forgery; canceling save."; $wgOut->addHTML($text); return; } // Validate form name. if ($form->getFormName() == "") { $form_name_error_str = wfMessage('sf_blank_error')->text(); } else { // Redirect to wiki interface. $wgOut->setArticleBodyOnly(true); $title = Title::makeTitleSafe(SF_NS_FORM, $form->getFormName()); $full_text = $form->createMarkup(); $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null); $wgOut->addHTML($text); return; } } $text = "\t" . '<form action="" method="post">' . "\n"; if (is_null($presetFormName)) { // Set 'title' field, in case there's no URL niceness $text .= Html::hidden('title', $this->getTitle()->getPrefixedText()); $text .= "\n\t<p>" . wfMessage('sf_createform_nameinput')->escaped() . ' ' . wfMessage('sf_createform_nameinputdesc')->escaped() . Html::input('form_name', $form_name, 'text', array('size' => 25)); if (!empty($form_name_error_str)) { $text .= "\t" . Html::element('font', array('color' => 'red'), $form_name_error_str); } $text .= "</p>\n"; } $text .= $form->creationHTML(); $text .= "<h2> " . wfMessage('sf_createform_addelements')->escaped() . " </h2>"; $text .= "\t<p>" . wfMessage('sf_createform_addtemplate')->escaped() . "\n"; $select_body = ""; foreach ($all_templates as $template) { $select_body .= "\t" . Html::element('option', array('value' => $template), $template) . "\n"; } $text .= "\t" . Html::rawElement('select', array('name' => 'new_template'), $select_body) . "\n"; // If a template has already been added, show a dropdown letting // the user choose where in the list to add a new dropdown. $select_body = ""; foreach ($form_items as $i => $fi) { if ($fi['type'] == 'template') { $option_str = wfMessage('sf_createform_template')->escaped(); } elseif ($fi['type'] == 'section') { $option_str = wfMessage('sf_createform_pagesection')->escaped(); } $option_str .= $fi['name']; $select_body .= "\t" . Html::element('option', array('value' => $i), $option_str) . "\n"; } $final_index = count($form_items); $at_end_msg = wfMessage('sf_createform_atend')->escaped(); $select_body .= "\t" . Html::element('option', array('value' => $final_index, 'selected' => 'selected'), $at_end_msg); // Selection for before which item this template should be placed if (count($form_items) > 0) { $text .= wfMessage('sf_createform_before')->escaped(); $text .= Html::rawElement('select', array('name' => 'before_template'), $select_body) . "\n"; } // Disable 'save' and 'preview' buttons if user has not yet // added any templates. $add_button_text = wfMessage('sf_createform_add')->text(); $text .= "\t" . Html::input('add_field', $add_button_text, 'submit') . "\n"; // The form HTML for page sections $text .= "</br></br>" . Html::rawElement('span', null, wfMessage('sf_createform_addsection')->text() . ":") . "\n"; $text .= Html::input('sectionname', '', 'text', array('size' => '30', 'placeholder' => wfMessage('sf_createform_sectionname')->text(), 'id' => 'sectionname')) . "\n"; // Selection for before which item this section should be placed if (count($form_items) > 0) { $text .= wfMessage('sf_createform_before')->escaped(); $text .= Html::rawElement('select', array('name' => 'before_section'), $select_body) . "\n"; } $add_section_text = wfMessage('sf_createform_addsection')->text(); $text .= "\t" . Html::input('add_section', $add_section_text, 'submit', array('id' => 'addsection')); $text .= "\n\t" . Html::rawElement('div', array('id' => 'sectionerror')); $text .= <<<END </p> \t<br /> END; $text .= "\t" . Html::hidden('csrf', $this->getUser()->getEditToken('CreateForm')) . "\n"; $saveAttrs = array('id' => 'wpSave'); if (count($form_items) == 0) { $saveAttrs['disabled'] = true; } $editButtonsText = "\t" . Html::input('wpSave', wfMessage('savearticle')->text(), 'submit', $saveAttrs) . "\n"; $previewAttrs = array('id' => 'wpPreview'); if (count($form_items) == 0) { $previewAttrs['disabled'] = true; } $editButtonsText .= "\t" . Html::input('wpPreview', wfMessage('preview')->text(), 'submit', $previewAttrs) . "\n"; $text .= "\t" . Html::rawElement('div', array('class' => 'editButtons'), Html::rawElement('p', array(), $editButtonsText) . "\n") . "\n"; // Explanatory message if buttons are disabled because no // templates have been added. if (count($form_items) == 0) { $text .= "\t" . Html::element('p', null, "(" . wfMessage('sf_createform_additembeforesave')->text() . ")"); } $text .= <<<END \t</form> END; $wgOut->addExtensionStyle($sfgScriptPath . "/skins/SemanticForms.css"); $wgOut->addHTML($text); //Don't submit the form if enter is pressed on a text input box or a select $wgOut->addScript('<script> jQuery("input,select").keypress(function(event) { return event.keyCode != 13; }); </script>'); }
/** * Generates a template with the login form and registration form already filled into * it and other settings populated as well. This template can then be executed with * different EasyTemplates to give different results such as one view for ajax dialogs * and one view for standalone pages (such as Special:Signup). */ public static function getTemplateForCombinedForms($static = false, $lastmsg = "", &$ajaxLoginForm = "") { global $wgRequest; // Setup the data for the templates, similar to GetComboAjaxLogin. if (session_id() == '') { wfSetupSession(); } // TODO: Invstigate why this was here. //if ($wgRequest->getCheck( 'wpCreateaccount' )) { // return "error"; //} $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); $response = new AjaxResponse(); $type = $wgRequest->getVal('type', ''); if (!wfReadOnly()) { if (empty($ajaxLoginForm)) { $ajaxLoginForm = new AjaxLoginForm($wgRequest); } $ajaxLoginForm->execute($type); if (!empty($ajaxLoginForm->ajaxTemplate)) { $lastmsg = $ajaxLoginForm->ajaxTemplate->data['message']; $tmpl->set('message', $ajaxLoginForm->ajaxTemplate->data['message']); $tmpl->set('messagetype', $ajaxLoginForm->ajaxTemplate->data['messagetype']); } $tmpl->set("registerAjax", $ajaxLoginForm->ajaxRender()); } $isReadOnly = wfReadOnly() ? 1 : 0; $tmpl->set("isReadOnly", $isReadOnly); if (!LoginForm::getLoginToken()) { LoginForm::setLoginToken(); } $tmpl->set("loginToken", LoginForm::getLoginToken()); if (!LoginForm::getCreateaccountToken()) { LoginForm::setCreateaccountToken(); } $tmpl->set("createToken", LoginForm::getCreateaccountToken()); // Use the existing settings to generate the login portion of the form, which will then // be fed back into the bigger template in this case (it is not always fed into ComboAjaxLogin template). $returnto = $wgRequest->getVal('returnto', ''); if (!($returnto == '')) { $returnto = "&returnto=" . wfUrlencode($returnto); } $returntoquery = $wgRequest->getVal('returntoquery', ''); if (!($returntoquery == '')) { $returntoquery = "&returntoquery=" . wfUrlencode($returntoquery); } $loginaction = Skin::makeSpecialUrl('Signup', "type=login&action=submitlogin" . $returnto . $returntoquery); $signupaction = Skin::makeSpecialUrl('Signup', "type=signup" . $returnto . $returntoquery); $tmpl->set("loginaction", $loginaction); $tmpl->set("signupaction", $signupaction); $tmpl->set("loginerror", $lastmsg); $tmpl->set("actiontype", $type); $tmpl->set("showRegister", false); $tmpl->set("showLogin", false); if ($static) { if (strtolower($type) == "login") { $tmpl->set("showLogin", true); } else { if (!$isReadOnly) { $tmpl->set("showRegister", true); } } } $tmpl->set("ajaxLoginComponent", $tmpl->render('AjaxLoginComponent')); return $tmpl; }
/** * Return a HTML representation of the image gallery * * The new gallery disables the old perrow control, and automatically fit the gallery to the available space in the browser. */ private function renderGallery() { wfProfileIn(__METHOD__); // do not render empty gallery if (empty($this->mFiles)) { wfProfileOut(__METHOD__); return ''; } // Route to the mobile gallery or the new MediaGallery if (F::app()->checkSkin('wikiamobile')) { $html = $this->renderWikiaMobileMediaGroup(); wfProfileOut(__METHOD__); return $html; } elseif ($this->canRenderMediaGallery()) { $html = $this->renderMediaGallery(); // remove spaces from html produced by mustache template $html = trim(preg_replace('/\\n+/', ' ', $html)); wfProfileOut(__METHOD__); return $html; } /** @var Skin|Linker $skin The skin object falls back to Linker methods via __call */ $skin = RequestContext::getMain()->getSkin(); $thumbSize = $this->mWidths; $orientation = $this->getParam('orientation'); $ratio = WikiaPhotoGalleryHelper::getRatioFromOption($orientation); $crop = $this->mCrop; //calculate height of the biggest image $maxHeight = 0; $fileObjectsCache = array(); $heights = array(); $widths = array(); $thumbParams = array(); // loop through the images and get height of the tallest one foreach ($this->mFiles as $imageData) { $img = $this->getImage($imageData[0]); $fileObjectsCache[] = $img; if (!empty($img)) { // get thumbnail limited only by given width if ($img->width > $thumbSize) { $imageHeight = round($img->height * ($thumbSize / $img->width)); $imageWidth = $thumbSize; } else { $imageHeight = $img->height; $imageWidth = $img->width; } $heights[] = $imageHeight; $widths[] = $imageWidth; if ($imageHeight > $maxHeight) { $maxHeight = $imageHeight; } } } // calculate height based on gallery width $height = round($thumbSize / $ratio); if ($orientation == 'none') { $this->enableCropping($crop = false); // use the biggest height found if ($maxHeight > 0) { $height = $maxHeight; } // limit height (RT #59355) $height = min($height, $thumbSize); // recalculate dimensions (RT #59355) foreach ($this->mFiles as $index => $image) { if (!empty($heights[$index]) && !empty($widths[$index])) { //fix #59355, min() added to let borders wrap images with smaller width //fix #63886, round ( $tmpFloat ) != floor ( $tmpFloat ) added to check if thumbnail will be generated from proper width $tmpFloat = $widths[$index] * $height / $heights[$index]; $widths[$index] = min($widths[$index], floor($tmpFloat)); $heights[$index] = min($height, $heights[$index]); if (round($tmpFloat) != floor($tmpFloat)) { $heights[$index]--; } } else { $widths[$index] = $thumbSize; $heights[$index] = $height; } } } $useBuckets = $this->getParam('buckets'); $useRowDivider = $this->getParam('rowdivider'); $captionColor = $this->getParam('captiontextcolor'); $borderColor = $this->getParam('bordercolor'); $perRow = $this->mPerRow > 0 ? $this->mPerRow : 'dynamic'; $position = $this->getParam('position'); $captionsPosition = $this->getParam('captionposition', 'below'); $captionsAlign = $this->getParam('captionalign'); $captionsSize = $this->getParam('captionsize'); $captionsColor = !empty($captionColor) ? $captionColor : null; $spacing = $this->getParam('spacing'); $borderSize = $this->getParam('bordersize'); $borderColor = !empty($borderColor) ? $borderColor : 'accent'; $isTemplate = isset($this->mData['params']['source']) && $this->mData['params']['source'] == "template"; $hash = $this->mData['hash']; $id = 'gallery-' . $this->mData['id']; $showAddButton = $this->mShowAddButton == true; $hideOverflow = $this->getParam('hideoverflow'); if (in_array($borderColor, array('accent', 'color1'))) { $borderColorClass = " {$borderColor}"; } else { $borderColorCSS = " border-color: {$borderColor};"; if ($captionsPosition == 'within') { $captionsBackgroundColor = $borderColor; } } $html = Xml::openElement('div', array('id' => $id, 'hash' => $hash, 'class' => 'wikia-gallery' . ($isTemplate ? ' template' : null) . " wikia-gallery-caption-{$captionsPosition}" . " wikia-gallery-position-{$position}" . " wikia-gallery-spacing-{$spacing}" . " wikia-gallery-border-{$borderSize}" . " wikia-gallery-captions-{$captionsAlign}" . " wikia-gallery-caption-size-{$captionsSize}")); // render gallery caption (RT #59241) if ($this->mCaption !== false) { $html .= Xml::openElement('div', array('class' => 'wikia-gallery-caption')) . $this->mCaption . Xml::closeElement('div'); } $itemWrapperWidth = $thumbSize; $thumbWrapperHeight = $height; //compensate image wrapper width depending on the border size switch ($borderSize) { case 'large': $itemWrapperWidth += 10; //5px * 2 $thumbWrapperHeight += 10; break; case 'medium': $itemWrapperWidth += 4; //2px * 2 $thumbWrapperHeight += 4; break; case 'small': $itemWrapperWidth += 2; //1px * 2 $thumbWrapperHeight += 2; break; } //adding more width for the padding $outeritemWrapperWidth = $itemWrapperWidth + 20; $rowDividerCSS = ''; if ($useRowDivider) { $rowDividerCSS = "height: " . ($thumbWrapperHeight + 100) . "px; padding: 30px 15px 20px 15px; margin: 0px; border-bottom: solid 1px #CCCCCC;"; } if ($useBuckets) { $itemSpanStyle = "width:{$outeritemWrapperWidth}px; " . ($useRowDivider ? $rowDividerCSS : 'margin: 4px;'); $itemDivStyle = "background-color: #f9f9f9; height:{$thumbWrapperHeight}px; text-align: center; border: solid 1px #CCCCCC; padding: " . ($outeritemWrapperWidth - $thumbWrapperHeight) / 2 . "px 5px;"; } else { $itemSpanStyle = "width:{$itemWrapperWidth}px; {$rowDividerCSS}"; $itemDivStyle = "height:{$thumbWrapperHeight}px;"; } foreach ($this->mFiles as $index => $imageData) { if ($perRow != 'dynamic' && $index % $perRow == 0) { $html .= Xml::openElement('div', array('class' => 'wikia-gallery-row')); } $html .= Xml::openElement('div', array('class' => 'wikia-gallery-item', 'style' => $itemSpanStyle)); $html .= Xml::openElement('div', array('class' => 'thumb', 'style' => $itemDivStyle)); $image = array(); // let's properly scale image (don't make it bigger than original size) /** * @var $imageTitle Title * @var $fileObject LocalFile */ $imageTitle = $imageData[0]; $fileObject = $fileObjectsCache[$index]; $imageTitleText = $imageTitle->getText(); $image['height'] = $height; $image['width'] = $thumbSize; $image['caption'] = $imageData[1]; if (!is_object($fileObject) || $imageTitle->getNamespace() != NS_FILE) { $image['linkTitle'] = $image['titleText'] = $imageTitleText; $image['thumbnail'] = false; $image['link'] = Skin::makeSpecialUrl("Upload", array('wpDestFile' => $image['linkTitle'])); $image['classes'] = 'image broken-image accent new'; } else { $thumbParams = WikiaPhotoGalleryHelper::getThumbnailDimensions($fileObject, $thumbSize, $height, $crop); $image['thumbnail'] = $fileObject->createThumb($thumbParams['width'], $thumbParams['height']); $image['DBKey'] = $fileObject->getTitle()->getDBKey(); $image['fileTitle'] = $fileObject->getTitle()->getText(); $image['height'] = $orientation == 'none' ? $heights[$index] : min($thumbParams['height'], $height); $imgHeightCompensation = ($height - $image['height']) / 2; if ($imgHeightCompensation > 0) { $image['heightCompensation'] = $imgHeightCompensation; } $image['width'] = min($widths[$index], $thumbSize); //Fix #59914, shared.css has auto-alignment rules /*$imgWidthCompensation = ($thumbSize - $image['width']) / 2; if ($imgHeightCompensation > 0) $image['widthCompensation'] = $imgWidthCompensation;*/ $image['link'] = $imageData[2]; $linkAttribs = $this->parseLink($imageTitle->getLocalUrl(), $imageTitleText, $image['link']); $image['link'] = $linkAttribs['href']; $image['linkTitle'] = $linkAttribs['title']; $image['classes'] = $linkAttribs['class']; $image['bytes'] = $fileObject->getSize(); if ($this->mParser && $fileObject->getHandler()) { $fileObject->getHandler()->parserTransformHook($this->mParser, $fileObject); } } wfRunHooks('GalleryBeforeRenderImage', array(&$image)); //see Image SEO project $wrapperId = preg_replace('/[^a-z0-9_]/i', '-', Sanitizer::escapeId($image['linkTitle'])); $html .= Xml::openElement('div', array('class' => 'gallery-image-wrapper' . (!$useBuckets && !empty($borderColorClass) ? $borderColorClass : null), 'id' => $wrapperId, 'style' => 'position: relative;' . ($useBuckets ? " width: {$itemWrapperWidth}px; border-style: none;" : " height:{$image['height']}px; width:{$image['width']}px;") . (!empty($image['heightCompensation']) ? " top:{$image['heightCompensation']}px;" : null) . (!empty($borderColorCSS) ? $borderColorCSS : null))); $imgStyle = null; $isVideo = WikiaFileHelper::isFileTypeVideo($fileObject); # Fix 59913 - thumbnail goes as <img /> not as <a> background. if ($orientation != 'none') { # margin calculation for image positioning if ($thumbParams['height'] > $image['height']) { $tempTopMargin = -1 * ($thumbParams['height'] - $image['height']) / 2; } else { unset($tempTopMargin); } if ($thumbParams['width'] > $image['width']) { $tempLeftMargin = -1 * ($thumbParams['width'] - $image['width']) / 2; } else { unset($tempLeftMargin); } $imgStyle = (!empty($tempTopMargin) ? " margin-top:" . $tempTopMargin . "px;" : null) . (!empty($tempLeftMargin) ? " margin-left:" . $tempLeftMargin . "px;" : null); if ($isVideo) { $image['classes'] .= ' force-lightbox'; } } $linkAttribs = array('class' => empty($image['thumbnail']) ? 'image-no-lightbox' : $image['classes'], 'href' => $image['link'], 'title' => $image['linkTitle'] . (isset($image['bytes']) ? ' (' . $skin->formatSize($image['bytes']) . ')' : ""), 'style' => "height:{$image['height']}px; width:{$image['width']}px;"); if (!empty($image['thumbnail'])) { if ($isVideo) { $thumbHtml = ''; $duration = $fileObject->getMetadataDuration(); if (!empty($duration)) { $duration = WikiaFileHelper::formatDuration($duration); $thumbHtml .= '<span class="duration">' . $duration . '</span>'; } $playButtonSize = ThumbnailHelper::getThumbnailSize($image['width']); $thumbHtml .= $this->videoPlayButton; $linkAttribs['class'] .= ' video video-thumbnail ' . $playButtonSize; } else { $thumbHtml = ''; } $imgAttribs = array('style' => (!empty($image['titleText']) ? " line-height:{$image['height']}px;" : null) . $imgStyle, 'src' => $image['thumbnail'] ? $image['thumbnail'] : null, 'title' => $image['linkTitle'] . (isset($image['bytes']) ? ' (' . $skin->formatSize($image['bytes']) . ')' : ""), 'class' => 'thumbimage', 'alt' => preg_replace('/\\.[^\\.]+$/', '', $image['linkTitle'])); if ($isVideo) { $imgAttribs['data-video-name'] = htmlspecialchars($image['fileTitle']); $imgAttribs['data-video-key'] = urlencode(htmlspecialchars($image['DBKey'])); } else { $imgAttribs['data-image-name'] = htmlspecialchars($image['fileTitle']); $imgAttribs['data-image-key'] = urlencode(htmlspecialchars($image['DBKey'])); } if (!empty($image['data-caption'])) { $imgAttribs['data-caption'] = $image['data-caption']; } if (isset($image['thumbnail-classes']) && isset($image['thumbnail-src']) && isset($image['thumbnail-onload'])) { $thumbHtml .= '<noscript>' . Xml::openElement('img', $imgAttribs) . '</noscript>'; $imgAttribs['class'] .= ' ' . $image['thumbnail-classes']; $imgAttribs['data-src'] = $imgAttribs['src']; $imgAttribs['src'] = $image['thumbnail-src']; $imgAttribs['onload'] = $image['thumbnail-onload']; } $thumbHtml .= Xml::openElement('img', $imgAttribs); } else { $thumbHtml = $image['linkTitle']; } $html .= Xml::openElement('a', $linkAttribs); $html .= $thumbHtml; $html .= Xml::closeElement('a'); if ($captionsPosition == 'below') { $html .= Xml::closeElement('div'); $html .= Xml::closeElement('div'); } // Insert video titles here if ($isVideo) { $html .= '<div class="title">' . $imageTitleText . '</div>'; } if (!empty($image['caption'])) { $html .= Xml::openElement('div', array('class' => 'lightbox-caption' . (!empty($borderColorClass) && $captionsPosition == 'within' ? $borderColorClass : null), 'style' => ($captionsPosition == 'below' ? "width:{$thumbSize}px;" : null) . (!empty($captionsColor) ? " color:{$captionsColor};" : null) . (!empty($captionsBackgroundColor) ? " background-color:{$captionsBackgroundColor}" : null) . ($useBuckets ? " margin-top: 0px;" : '') . (!empty($hideOverflow) ? " overflow: hidden" : null))); $html .= $image['caption']; $html .= Xml::closeElement('div'); } if ($captionsPosition == 'within') { $html .= Xml::closeElement('div'); $html .= Xml::closeElement('div'); } $html .= Xml::closeElement('div'); // /div.wikia-gallery-item if ($perRow != 'dynamic' && ($index % $perRow == $perRow - 1 || $index == count($this->mFiles) - 1)) { $html .= Xml::closeElement('div'); } } // "Add image to this gallery" button (this button is shown by JS only in Monaco) if ($showAddButton) { if ($perRow == 'dynamic') { $html .= Xml::element('br'); } // add button for Oasis $html .= Xml::openElement('a', array('class' => 'wikia-photogallery-add wikia-button noprint', 'style' => 'display: none')); $html .= Xml::element('img', array('src' => F::app()->wg->BlankImgUrl, 'class' => 'sprite photo', 'width' => 26, 'height' => 16)); $html .= wfMessage('wikiaPhotoGallery-viewmode-addphoto')->inContentLanguage()->text(); $html .= Xml::closeElement('a'); } $html .= Xml::closeElement('div'); wfProfileOut(__METHOD__); return $html; }
<p><?php echo wfMsg('recipes-template-toggle-label'); ?> </p> <fieldset class="recipes-template-toggle accent reset"> <ul> <?php global $wgTitle; $currentPage = $wgTitle->getText(); foreach ($toggles as $toggle) { $selected = $currentPage == $toggle['specialPage']; if (!empty($toggle['type'])) { $href = htmlspecialchars(Skin::makeSpecialUrl($toggle['specialPage'], array('type' => $toggle['type']))); } else { $href = htmlspecialchars(Skin::makeSpecialUrl($toggle['specialPage'])); } $label = htmlspecialchars(wfMsg("recipes-template-toggle-{$toggle['name']}-label")); ?> <li<?php echo $selected ? ' class="accent"' : ''; ?> ><a href="<?php echo $href; ?> " ref="<?php echo $toggle['name']; ?> "><?php echo $label; ?> </a></li>
static function AddRestrictedPagesTab(&$personal_urls, $title ) { global $wgUser, $wgWhiteListRestrictedGroup; $userIsRestricted = in_array( $wgWhiteListRestrictedGroup, $wgUser->getGroups() ); if ($wgUser->isLoggedIn() && $userIsRestricted) { $personal_urls['mypages'] = array( 'text' => wfMsg('mywhitelistpages'), 'href' => Skin::makeSpecialUrl('WhiteList') ); } return true; }
public function boardThread() { $this->wf->ProfileIn(__METHOD__); $wallMessage = $this->getWallMessage(); if (!$wallMessage instanceof WallMessage) { $this->forward(__CLASS__, 'message_error'); return true; } $this->response->setVal('id', $wallMessage->getId()); $this->response->setVal('feedtitle', htmlspecialchars($wallMessage->getMetaTitle())); $this->response->setVal('isWatched', $wallMessage->isWatched($this->wg->User) || $this->request->getVal('new', false)); $this->response->setVal('fullpageurl', $wallMessage->getMessagePageUrl()); $this->response->setVal('kudosNumber', $wallMessage->getVoteCount()); $replies = $this->getVal('replies', array()); $repliesCount = count($replies); $this->response->setVal('repliesNumber', $repliesCount); $lastReply = $this->getLastReply($replies); if ($lastReply === false) { $lastReply = $wallMessage; } // even though $data['author'] is a User object already // it's a cached object, and we need to make sure that we are // using newest RealName // cache invalidation in this case would require too many queries $authorUser = User::newFromName($lastReply->getUser()->getName()); if ($authorUser) { $name = $authorUser->getName(); } else { $name = $lastReply->getUser()->getName(); } if ($lastReply->getUser()->getId() == 0) { // anynymous contributor $displayname = wfMsg('oasis-anon-user'); $displayname2 = $lastReply->getUser()->getName(); $url = Skin::makeSpecialUrl('Contributions') . '/' . $lastReply->getUser()->getName(); } else { $displayname = $name; $displayname2 = ''; $url = F::build('Title', array($name, NS_USER_WALL), 'newFromText')->getFullUrl(); } $this->response->setVal('username', $name); $this->response->setVal('displayname', $displayname); $this->response->setVal('displayname2', $displayname2); $this->response->setVal('user_author_url', $url); $this->response->setVal('iso_timestamp', $lastReply->getCreatTime(TS_ISO_8601)); $this->response->setVal('fmt_timestamp', $this->wg->Lang->timeanddate($lastReply->getCreatTime(TS_MW))); $this->wf->ProfileOut(__METHOD__); }
/** * @brief Gets wall comments data from memc/db * * @param array $comments an array with WallMessage instances * * @author Andrzej 'nAndy' Åukaszewski */ private function getCommentsData($comments) { $app = F::app(); $app->wf->ProfileIn(__METHOD__); $timeNow = time(); $items = array(); $i = 0; foreach ($comments as $wm) { $data = $wm->getData(false, null, 30); if (!$data['author'] instanceof User) { // bugId:22820 // in case of Page table entries without corresponding revision // there is no content for specific article (and consequently - wall message) // and there is no user // it's safe to ignore such entries error_log("WallHelper.class.php NO_AUTHOR_FOR_AC:" . $wm->getId()); continue; } $items[$i]['avatar'] = $data['avatarSmall']; $items[$i]['user-profile-url'] = $data['userurl']; $user = User::newFromName($data['author']->getName()); if ($user) { $items[$i]['real-name'] = $user->getName(); $userWallTitle = F::build('Title', array($user->getName(), NS_USER_WALL), 'newFromText'); $items[$i]['user-profile-url'] = $userWallTitle->getFullUrl(); } else { $items[$i]['real-name'] = ''; } $items[$i]['author'] = $data['username']; $items[$i]['wall-comment'] = $this->shortenText($this->strip_wikitext($data['rawtext'])) . ' '; if (User::isIP($data['username'])) { $items[$i]['user-profile-url'] = Skin::makeSpecialUrl('Contributions') . '/' . $data['username']; $items[$i]['real-name'] = wfMsg('oasis-anon-user'); } else { $items[$i]['author'] = ""; } //if message is older than 3 days we don't show its timestamp $items[$i]['timestamp'] = $msgTimestamp = $data['rawmwtimestamp']; $ago = $timeNow - strtotime($msgTimestamp) + 1; if ($ago <= self::WA_WALL_COMMENTS_EXPIRED_TIME) { $items[$i]['timestamp'] = $msgTimestamp; } else { $items[$i]['timestamp'] = null; } $items[$i]['wall-message-url'] = $wm->getMessagePageUrl(); $i++; } unset($data); $app->wf->ProfileOut(__METHOD__); return $items; }
function doSpecialCreateForm($query) { global $wgOut, $wgRequest, $sfgScriptPath; $db = wfGetDB(DB_SLAVE); if (!is_null($query)) { $presetFormName = str_replace('_', ' ', $query); $wgOut->setPageTitle(wfMessage('sf-createform-with-name', $presetFormName)->text()); $form_name = $presetFormName; } else { $presetFormName = null; $form_name = $wgRequest->getVal('form_name'); } // Create Javascript to populate fields to let the user input // parameters for the field, based on the input type selected // in the dropdown. $url = Skin::makeSpecialUrl('CreateForm', "showinputtypeoptions=' + this.val() + '&formfield=' + this.attr('formfieldid') + '"); foreach ($wgRequest->getValues() as $param => $value) { $url .= '¶ms[' . Xml::escapeJsString($param) . ']=' . Xml::escapeJsString($value); } $wgOut->addModules('ext.semanticforms.collapsible'); $wgOut->addScript("<script>\njQuery.fn.displayInputParams = function() {\n\tinputParamsDiv = this.closest('.formField').find('.otherInputParams');\n\tjQuery.ajax({\n\t\turl: '{$url}',\n\t\tcontext: document.body,\n\t\tsuccess: function(data){\n\t\t\tinputParamsDiv.html(data);\n\t\t}\n\t});\n};\njQuery(document).ready(function() {\n\tjQuery('.inputTypeSelector').change( function() {\n\t\tjQuery(this).displayInputParams();\n\t});\n});\n</script>"); // Get the names of all templates on this site. $all_templates = array(); $res = $db->select('page', 'page_title', array('page_namespace' => NS_TEMPLATE, 'page_is_redirect' => 0), array('ORDER BY' => 'page_title')); if ($db->numRows($res) > 0) { while ($row = $db->fetchRow($res)) { $template_name = str_replace('_', ' ', $row[0]); $all_templates[] = $template_name; } } $form_templates = array(); $deleted_template_loc = null; // Handle inputs. foreach ($wgRequest->getValues() as $var => $val) { # ignore variables that are not of the right form if (strpos($var, "_") != false) { # get the template declarations and work from there list($action, $id) = explode("_", $var, 2); if ($action == "template") { // If the button was pressed to remove // this template, just don't add it to // the array. if ($wgRequest->getVal("del_{$id}") != null) { $deleted_template_loc = $id; } else { $form_template = SFTemplateInForm::create($val, $wgRequest->getVal("label_{$id}"), $wgRequest->getVal("allow_multiple_{$id}")); $form_templates[] = $form_template; } } } } if ($wgRequest->getVal('add_field') != null) { $form_template = SFTemplateInForm::create($wgRequest->getVal('new_template'), "", false); $new_template_loc = $wgRequest->getVal('before_template'); if ($new_template_loc === null) { $new_template_loc = 0; } // @HACK - array_splice() doesn't work for objects, so // we have to first insert a stub element into the // array, then replace that with the actual object. array_splice($form_templates, $new_template_loc, 0, "stub"); $form_templates[$new_template_loc] = $form_template; } else { $new_template_loc = null; } // Now cycle through the templates and fields, modifying each // one per the query variables. foreach ($form_templates as $i => $ft) { foreach ($ft->getFields() as $j => $field) { // handle the change in indexing if a new template was // inserted before the end, or one was deleted $old_i = $i; if ($new_template_loc != null) { if ($i > $new_template_loc) { $old_i = $i - 1; } elseif ($i == $new_template_loc) { // it's the new template; it shouldn't // get any query-string data $old_i = -1; } } elseif ($deleted_template_loc != null) { if ($i >= $deleted_template_loc) { $old_i = $i + 1; } } foreach ($wgRequest->getValues() as $key => $value) { if (($pos = strpos($key, '_' . $old_i . '_' . $j)) != false) { $paramName = substr($key, 0, $pos); // Spaces got replaced by // underlines in the query. $paramName = str_replace('_', ' ', $paramName); } else { continue; } if ($paramName == 'label') { $field->template_field->setLabel($value); } elseif ($paramName == 'input type') { $input_type = $wgRequest->getVal("input_type_" . $old_i . "_" . $j); if ($input_type == 'hidden') { $field->template_field->setInputType($input_type); $field->setIsHidden(true); } elseif (substr($input_type, 0, 1) == '.') { // It's the default input type - // don't do anything. } else { $field->template_field->setInputType($input_type); } } else { if (!empty($value)) { if ($value == 'on') { $value = true; } $field->setFieldArg($paramName, $value); } } } } } $form = SFForm::create($form_name, $form_templates); // If a submit button was pressed, create the form-definition // file, then redirect. $save_page = $wgRequest->getCheck('wpSave'); $preview_page = $wgRequest->getCheck('wpPreview'); if ($save_page || $preview_page) { // Validate form name if ($form->getFormName() == "") { $form_name_error_str = wfMessage('sf_blank_error')->text(); } else { // Redirect to wiki interface $wgOut->setArticleBodyOnly(true); $title = Title::makeTitleSafe(SF_NS_FORM, $form->getFormName()); $full_text = $form->createMarkup(); $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null); $wgOut->addHTML($text); return; } } $text = "\t" . '<form action="" method="post">' . "\n"; if (is_null($presetFormName)) { // Set 'title' field, in case there's no URL niceness $text .= Html::hidden('title', $this->getTitle()->getPrefixedText()); $text .= "\n\t<p>" . wfMessage('sf_createform_nameinput')->escaped() . ' ' . wfMessage('sf_createform_nameinputdesc')->escaped() . Html::input('form_name', $form_name, 'text', array('size' => 25)); if (!empty($form_name_error_str)) { $text .= "\t" . Html::element('font', array('color' => 'red'), $form_name_error_str); } $text .= "</p>\n"; } $text .= $form->creationHTML(); $text .= "\t<p>" . wfMessage('sf_createform_addtemplate')->escaped() . "\n"; $select_body = ""; foreach ($all_templates as $template) { $select_body .= "\t" . Html::element('option', array('value' => $template), $template) . "\n"; } $text .= "\t" . Html::rawElement('select', array('name' => 'new_template'), $select_body) . "\n"; // If a template has already been added, show a dropdown letting // the user choose where in the list to add a new dropdown. if (count($form_templates) > 0) { $text .= wfMessage('sf_createform_beforetemplate')->escaped(); $select_body = ""; foreach ($form_templates as $i => $ft) { $select_body .= "\t" . Html::element('option', array('value' => $i), $ft->getTemplateName()) . "\n"; } $final_index = count($form_templates); $at_end_msg = wfMessage('sf_createform_atend')->escaped(); $select_body .= "\t" . Html::element('option', array('value' => $final_index, 'selected' => 'selected'), $at_end_msg); $text .= Html::rawElement('select', array('name' => 'before_template'), $select_body) . "\n"; } // Disable 'save' and 'preview' buttons if user has not yet // added any templates. $add_button_text = wfMessage('sf_createform_add')->text(); $text .= "\t" . Html::input('add_field', $add_button_text, 'submit'); $text .= <<<END </p> \t<br /> END; $saveAttrs = array('id' => 'wpSave'); if (count($form_templates) == 0) { $saveAttrs['disabled'] = true; } $editButtonsText = "\t" . Html::input('wpSave', wfMessage('savearticle')->text(), 'submit', $saveAttrs) . "\n"; $previewAttrs = array('id' => 'wpPreview'); if (count($form_templates) == 0) { $previewAttrs['disabled'] = true; } $editButtonsText .= "\t" . Html::input('wpPreview', wfMessage('preview')->text(), 'submit', $previewAttrs) . "\n"; $text .= "\t" . Html::rawElement('div', array('class' => 'editButtons'), Html::rawElement('p', array(), $editButtonsText) . "\n") . "\n"; // Explanatory message if buttons are disabled because no // templates have been added. if (count($form_templates) == 0) { $text .= "\t" . Html::element('p', null, "(" . wfMessage('sf_createtemplate_addtemplatebeforesave')->text() . ")"); } $text .= <<<END \t</form> END; $wgOut->addExtensionStyle($sfgScriptPath . "/skins/SemanticForms.css"); $wgOut->addHTML($text); }
/** * Generate links for user menu - depends on if user is logged in or not * * @return array * @author Inez Korczynski <*****@*****.**> */ private function getUserLinks($tpl) { wfProfileIn( __METHOD__ ); global $wgUser, $wgTitle; $data = array(); if(!$wgUser->isLoggedIn()) { $returnto = wfGetReturntoParam(); $signUpHref = Skin::makeSpecialUrl( 'Signup', $returnto ); $data['login'] = array( 'text' => wfMsg('login'), 'href' => $signUpHref . "&type=login" ); $data['register'] = array( 'text' => wfMsg('nologinlink'), 'href' => $signUpHref . "&type=signup" ); } else { $data['userpage'] = array( 'text' => $wgUser->getName(), 'href' => $tpl->data['personal_urls']['userpage']['href'] ); $data['mytalk'] = array( 'text' => $tpl->data['personal_urls']['mytalk']['text'], 'href' => $tpl->data['personal_urls']['mytalk']['href'] ); $data['watchlist'] = array( /*'text' => $tpl->data['personal_urls']['watchlist']['text'],*/ 'text' => wfMsg('prefs-watchlist'), 'href' => $tpl->data['personal_urls']['watchlist']['href'] ); // In some cases, logout will be removed explicitly (such as when it is replaced by fblogout). if(isset($tpl->data['personal_urls']['logout'])){ $data['logout'] = array( 'text' => $tpl->data['personal_urls']['logout']['text'], 'href' => $tpl->data['personal_urls']['logout']['href'] ); } $data['more']['userpage'] = array( 'text' => wfMsg('mypage'), 'href' => $tpl->data['personal_urls']['userpage']['href'] ); if(isset($tpl->data['personal_urls']['userprofile'])) { $data['more']['userprofile'] = array( 'text' => $tpl->data['personal_urls']['userprofile']['text'], 'href' => $tpl->data['personal_urls']['userprofile']['href'] ); } $data['more']['mycontris'] = array( 'text' => wfMsg('mycontris'), 'href' => $tpl->data['personal_urls']['mycontris']['href'] ); $data['more']['widgets'] = array( 'text' => wfMsg('manage_widgets'), 'href' => '#' ); $data['more']['preferences'] = array( 'text' => $tpl->data['personal_urls']['preferences']['text'], 'href' => $tpl->data['personal_urls']['preferences']['href'] ); } // This function ignores anything from PersonalUrls hook which it doesn't expect. This // loops lets it expect anything starting with "fb*" (because we need that for facebook connect). // Perhaps we should have some system to let PersonalUrls hook work again on its own? // - Sean Colombo foreach($tpl->data['personal_urls'] as $urlName => $urlData){ if(strpos($urlName, "fb") === 0){ $data[$urlName] = $urlData; } } wfProfileOut( __METHOD__ ); return $data; }
public static function addPersonalUrl(&$personal_urls, &$title) { wfProfileIn(__METHOD__); // don't touch anon users global $wgUser; if ($wgUser->isAnon()) { wfProfileOut(__METHOD__); return true; } // only for Oasis users // replace 'watchlist' with 'followed pages' if (get_class(RequestContext::getMain()->getSkin()) == 'SkinOasis') { $personal_urls['watchlist'] = array('text' => wfMsg('wikiafollowedpages-special-title-userbar'), 'href' => Skin::makeSpecialUrl('following')); } wfProfileOut(__METHOD__); return true; }