public function execute($subpage) { global $wgOut, $wgRequest, $wgUser, $wgCacheEpoch, $wgCityId; wfProfileIn(__METHOD__); $this->setHeaders(); $this->mTitle = SpecialPage::getTitleFor('cacheepoch'); if ($this->isRestricted() && !$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); wfProfileOut(__METHOD__); return; } //no WikiFactory (internal wikis) if (empty($wgCityId)) { $wgOut->addHTML(wfMsg('cacheepoch-no-wf')); wfProfileOut(__METHOD__); return; } if ($wgRequest->wasPosted()) { $wgCacheEpoch = wfTimestampNow(); $status = WikiFactory::setVarByName('wgCacheEpoch', $wgCityId, $wgCacheEpoch, wfMsg('cacheepoch-wf-reason')); if ($status) { $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-updated', $wgCacheEpoch) . '</h2>'); } else { $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-not-updated') . '</h2>'); } } else { $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-header') . '</h2>'); } $wgOut->addHTML(Xml::openElement('form', array('action' => $this->mTitle->getFullURL(), 'method' => 'post'))); $wgOut->addHTML(wfMsg('cacheepoch-value', $wgCacheEpoch) . '<br>'); $wgOut->addHTML(Xml::submitButton(wfMsg('cacheepoch-submit'))); $wgOut->addHTML(Xml::closeElement('form')); wfProfileOut(__METHOD__); }
function execute($par) { /** * Some satellite ISPs use broken precaching schemes that log people out straight after * they're logged in (bug 17790). Luckily, there's a way to detect such requests. */ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&') !== false) { wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n"); throw new HttpError(400, $this->msg('suspicious-userlogout'), $this->msg('loginerror')); } $this->setHeaders(); $this->outputHeader(); // Make sure it's possible to log out $session = MediaWiki\Session\SessionManager::getGlobalSession(); if (!$session->canSetUser()) { throw new ErrorPageError('cannotlogoutnow-title', 'cannotlogoutnow-text', [$session->getProvider()->describe(RequestContext::getMain()->getLanguage())]); } $user = $this->getUser(); $oldName = $user->getName(); $user->logout(); $loginURL = SpecialPage::getTitleFor('Userlogin')->getFullURL($this->getRequest()->getValues('returnto', 'returntoquery')); $out = $this->getOutput(); $out->addWikiMsg('logouttext', $loginURL); // Hook. $injected_html = ''; Hooks::run('UserLogoutComplete', [&$user, &$injected_html, $oldName]); $out->addHTML($injected_html); $out->returnToMain(); }
/** * Main execution point * * @param string $subpage */ function execute($subpage) { // Anons don't get a watchlist $this->requireLogin('watchlistanontext'); $output = $this->getOutput(); $request = $this->getRequest(); $this->addHelpLink('Help:Watching pages'); $output->addModules(array('mediawiki.special.changeslist.visitedstatus')); $mode = SpecialEditWatchlist::getMode($request, $subpage); if ($mode !== false) { if ($mode === SpecialEditWatchlist::EDIT_RAW) { $title = SpecialPage::getTitleFor('EditWatchlist', 'raw'); } elseif ($mode === SpecialEditWatchlist::EDIT_CLEAR) { $title = SpecialPage::getTitleFor('EditWatchlist', 'clear'); } else { $title = SpecialPage::getTitleFor('EditWatchlist'); } $output->redirect($title->getLocalURL()); return; } $this->checkPermissions(); $user = $this->getUser(); $opts = $this->getOptions(); $config = $this->getConfig(); if (($config->get('EnotifWatchlist') || $config->get('ShowUpdatedMarker')) && $request->getVal('reset') && $request->wasPosted()) { $user->clearAllNotifications(); $output->redirect($this->getPageTitle()->getFullURL($opts->getChangedValues())); return; } parent::execute($subpage); }
static function formatLogEntry($type, $action, $title, $sk, $parameters) { $msg = "lqt-log-action-{$action}"; switch ($action) { case 'merge': if ($parameters[0]) { $msg = 'lqt-log-action-merge-across'; } else { $msg = 'lqt-log-action-merge-down'; } break; case 'move': $smt = new SpecialMoveThread(); $rightsCheck = $smt->checkUserRights($parameters[1] instanceof Title ? $parameters[1] : Title::newFromText($parameters[1]), $parameters[0] instanceof Title ? $parameters[0] : Title::newFromText($parameters[0])); if ($rightsCheck === true) { $parameters[] = Message::rawParam(Linker::link(SpecialPage::getTitleFor('MoveThread', $title), wfMessage('revertmove')->text(), array(), array('dest' => $parameters[0]))); } else { $parameters[] = ''; } break; default: // Give grep a chance to find the usages: // lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit, // lqt-log-action-resort, lqt-log-action-signatureedit $msg = "lqt-log-action-{$action}"; break; } array_unshift($parameters, $title->getPrefixedText()); $html = wfMessage($msg, $parameters); if ($sk === null) { return StringUtils::delimiterReplace('<', '>', '', $html->inContentLanguage()->parse()); } return $html->parse(); }
public function getActionLinks() { if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden || $this->entry->getSubtype() !== 'move' || !$this->context->getUser()->isAllowed( 'move' ) ) { return ''; } $params = $this->extractParameters(); $destTitle = Title::newFromText( $params[3] ); if ( !$destTitle ) { return ''; } $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Movepage' ), $this->msg( 'revertmove' )->escaped(), array(), array( 'wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(), 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(), 'wpMovetalk' => 0 ) ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); }
function doTagRow($tag, $hitcount) { $user = $this->getUser(); $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); if ($user->isAllowed('editinterface')) { $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); } $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); if ($user->isAllowed('editinterface')) { $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); } $newRow .= Xml::tags('td', null, $desc); $active = isset($this->definedTags[$tag]) ? 'tags-active-yes' : 'tags-active-no'; $active = $this->msg($active)->escaped(); $newRow .= Xml::tags('td', null, $active); $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcountLink = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, array(), array('tagfilter' => $tag)); // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters $newRow .= Xml::tags('td', array('data-sort-value' => $hitcount), $hitcountLink); return Xml::tags('tr', null, $newRow) . "\n"; }
/** * Constructor */ public function __construct() { global $wgUser; parent::__construct('ChangeAuthor', 'changeauthor'); $this->selfTitle = SpecialPage::getTitleFor('ChangeAuthor'); $this->skin = $wgUser->getSkin(); }
/** * (non-PHPdoc) * @see EPPager::getFormattedValue() */ protected function getFormattedValue($name, $value) { switch ($name) { case 'id': $value = Linker::linkKnown(SpecialPage::getTitleFor('Student', $value), htmlspecialchars($this->getLanguage()->formatNum($value, true))); break; case 'user_id': $user = User::newFromId($value); $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); $value = Linker::userLink($value, $name) . Linker::userToolLinks($value, $name); break; case 'first_enroll': case 'last_active': $value = htmlspecialchars($this->getLanguage()->date($value)); break; case 'active_enroll': $value = wfMsgHtml($value === '1' ? 'epstudentpager-yes' : 'epstudentpager-no'); break; case '_courses_current': $value = $this->getLanguage()->pipeList(array_map(function (EPCourse $course) { return $course->getLink(); }, $this->currentObject->getCoursesWithState('current', 'name'))); break; } return $value; }
public function logFeedback($params, $itemId) { $title = SpecialPage::getTitleFor('FeedbackDashboard', $itemId); $reason = wfMessage('moodbar-log-reason')->params($params['type'], $params['comment'])->text(); $log = new LogPage('moodbar'); $log->addEntry('feedback', $title, $reason); }
/** * This method will be called before an article is displayed or previewed. * For display and preview we strip out the semantic properties and append them * at the end of the article. * * @param Parser $parser * @param string $text */ static public function onInternalParseBeforeLinks( &$parser, &$text ) { global $smwgStoreAnnotations, $smwgLinksInValues; SMWParseData::stripMagicWords( $text, $parser ); // Store the results if enabled (we have to parse them in any case, // in order to clean the wiki source for further processing). $smwgStoreAnnotations = smwfIsSemanticsProcessed( $parser->getTitle()->getNamespace() ); SMWParserExtensions::$mTempStoreAnnotations = true; // used for [[SMW::on]] and [[SMW:off]] // Process redirects, if any (it seems that there is indeed no more direct way of getting this info from MW) if ( $smwgStoreAnnotations ) { $rt = Title::newFromRedirect( $text ); if ( !is_null( $rt ) ) { $p = new SMWDIProperty( '_REDI' ); $di = SMWDIWikiPage::newFromTitle( $rt, '__red' ); SMWParseData::getSMWData( $parser )->addPropertyObjectValue( $p, $di ); } } // only used in subsequent callbacks, forgotten afterwards SMWParserExtensions::$mTempParser = $parser; // In the regexp matches below, leading ':' escapes the markup, as known for Categories. // Parse links to extract semantic properties. if ( $smwgLinksInValues ) { // More complex regexp -- lib PCRE may cause segfaults if text is long :-( $semanticLinkPattern = '/\[\[ # Beginning of the link (?:([^:][^]]*):[=:])+ # Property name (or a list of those) ( # After that: (?:[^|\[\]] # either normal text (without |, [ or ]) |\[\[[^]]*\]\] # or a [[link]] |\[[^]]*\] # or an [external link] )*) # all this zero or more times (?:\|([^]]*))? # Display text (like "text" in [[link|text]]), optional \]\] # End of link /xu'; $text = preg_replace_callback( $semanticLinkPattern, array( 'SMWParserExtensions', 'parsePropertiesCallback' ), $text ); } else { // Simpler regexps -- no segfaults found for those, but no links in values. $semanticLinkPattern = '/\[\[ # Beginning of the link (?:([^:][^]]*):[=:])+ # Property name (or a list of those) ([^\[\]]*) # content: anything but [, |, ] \]\] # End of link /xu'; $text = preg_replace_callback( $semanticLinkPattern, array( 'SMWParserExtensions', 'simpleParsePropertiesCallback' ), $text ); } // Add link to RDF to HTML header. // TODO: do escaping via Html or Xml class. SMWOutputs::requireHeadItem( 'smw_rdf', '<link rel="alternate" type="application/rdf+xml" title="' . htmlspecialchars( $parser->getTitle()->getPrefixedText() ) . '" href="' . htmlspecialchars( SpecialPage::getTitleFor( 'ExportRDF', $parser->getTitle()->getPrefixedText() )->getLocalUrl( 'xmlmime=rdf' ) ) . "\" />" ); SMWOutputs::commitToParser( $parser ); return true; // always return true, in order not to stop MW's hook processing! }
function actionCreate($action, $article) { if ($action != 'create') { return true; } global $wgRequest; $prefix = $wgRequest->getVal('prefix'); $text = $wgRequest->getVal('title'); if ($prefix && strpos($text, $prefix) !== 0) { $title = Title::newFromText($prefix . $text); if (is_null($title)) { global $wgTitle; $wgTitle = SpecialPage::getTitleFor('Badtitle'); throw new ErrorPageError('badtitle', 'badtitletext'); } elseif ($title->getArticleID() == 0) { acRedirect($title, 'edit'); } else { acRedirect($title, 'create'); } } elseif ($wgRequest->getVal('section') == 'new' || $article->getID() == 0) { acRedirect($article->getTitle(), 'edit'); } else { global $wgOut; $text = $article->getTitle()->getPrefixedText(); $wgOut->setPageTitle($text); $wgOut->setHTMLTitle(wfMsg('pagetitle', $text . ' - ' . wfMsg('createbox-create'))); $wgOut->addWikiMsg('createbox-exists'); } return false; }
protected function showLanguage($code, $users) { $out = $this->getOutput(); $lang = $this->getLanguage(); $usernames = array_keys($users); $userStats = $this->getUserStats($usernames); // Information to be used inside the foreach loop. $linkInfo = array(); $linkInfo['rc']['title'] = SpecialPage::getTitleFor('Recentchanges'); $linkInfo['rc']['msg'] = $this->msg('supportedlanguages-recenttranslations')->escaped(); $linkInfo['stats']['title'] = SpecialPage::getTitleFor('LanguageStats'); $linkInfo['stats']['msg'] = $this->msg('languagestats')->escaped(); $local = Language::fetchLanguageName($code, $lang->getCode(), 'all'); $native = Language::fetchLanguageName($code, null, 'all'); if ($local !== $native) { $headerText = $this->msg('supportedlanguages-portallink')->params($code, $local, $native)->escaped(); } else { // No CLDR, so a less localised header and link title. $headerText = $this->msg('supportedlanguages-portallink-nocldr')->params($code, $native)->escaped(); } $out->addHtml(Html::rawElement('h2', array('id' => $code), $headerText)); // Add useful links for language stats and recent changes for the language. $links = array(); $links[] = Linker::link($linkInfo['stats']['title'], $linkInfo['stats']['msg'], array(), array('code' => $code, 'suppresscomplete' => '1'), array('known', 'noclasses')); $links[] = Linker::link($linkInfo['rc']['title'], $linkInfo['rc']['msg'], array(), array('translations' => 'only', 'trailer' => "/" . $code), array('known', 'noclasses')); $linkList = $lang->listToText($links); $out->addHTML("<p>" . $linkList . "</p>\n"); $this->makeUserList($users, $userStats); }
/** * Sends the notification about a new gift to the user who received the * gift, if the user wants notifications about new gifts and their e-mail * is confirmed. * * @param $user_id_to Integer: user ID of the receiver of the gift * @param $user_from Mixed: name of the user who sent the gift * @param $gift_id Integer: ID number of the given gift * @param $type Integer: gift type; unused */ public function sendGiftNotificationEmail( $user_id_to, $user_from, $gift_id, $type ) { $gift = Gifts::getGift( $gift_id ); $user = User::newFromId( $user_id_to ); $user->loadFromDatabase(); if ( $user->isEmailConfirmed() && $user->getIntOption( 'notifygift', 1 ) ) { $giftsLink = SpecialPage::getTitleFor( 'ViewGifts' ); $updateProfileLink = SpecialPage::getTitleFor( 'UpdateProfile' ); if ( trim( $user->getRealName() ) ) { $name = $user->getRealName(); } else { $name = $user->getName(); } $subject = wfMsgExt( 'gift_received_subject', 'parsemag', $user_from, $gift['gift_name'] ); $body = wfMsgExt( 'gift_received_body', 'parsemag', $name, $user_from, $gift['gift_name'], $giftsLink->getFullURL(), $updateProfileLink->getFullURL() ); $user->sendMail( $subject, $body ); } }
function execute($query) { global $wgOut; wfProfileIn('SpecialURIResolver::execute (SMW)'); if (is_null($query) || trim($query) === '') { if (stristr($_SERVER['HTTP_ACCEPT'], 'RDF')) { $wgOut->redirect(SpecialPage::getTitleFor('ExportRDF')->getFullURL(array('stats' => '1')), '303'); } else { $this->setHeaders(); $wgOut->addHTML('<p>' . wfMessage('smw_uri_doc', 'http://www.w3.org/2001/tag/issues.html#httpRange-14')->parse() . '</p>'); } } else { $query = SMWExporter::decodeURI($query); $query = str_replace('_', '%20', $query); $query = urldecode($query); $title = Title::newFromText($query); // In case the title doesn't exists throw an error page if ($title === null) { $wgOut->showErrorPage('badtitle', 'badtitletext'); } else { $wgOut->redirect(stristr($_SERVER['HTTP_ACCEPT'], 'RDF') ? SpecialPage::getTitleFor('ExportRDF', $title->getPrefixedText())->getFullURL(array('xmlmime' => 'rdf')) : $title->getFullURL(), '303'); } } wfProfileOut('SpecialURIResolver::execute (SMW)'); }
public function execute() { $params = $this->extractRequestParams(); global $wgFeed, $wgFeedClasses, $wgSitename, $wgLanguageCode; if (!$wgFeed) { $this->dieUsage('Syndication feeds are not available', 'feed-unavailable'); } if (!isset($wgFeedClasses[$params['feedformat']])) { $this->dieUsage('Invalid subscription feed type', 'feed-invalid'); } global $wgMiserMode; if ($params['showsizediff'] && $wgMiserMode) { $this->dieUsage('Size difference is disabled in Miser Mode', 'sizediffdisabled'); } $msg = wfMessage('Contributions')->inContentLanguage()->text(); $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']'; $feedUrl = SpecialPage::getTitleFor('Contributions', $params['user'])->getFullURL(); $target = $params['user'] == 'newbies' ? 'newbies' : Title::makeTitleSafe(NS_USER, $params['user'])->getText(); $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl); $pager = new ContribsPager($this->getContext(), array('target' => $target, 'namespace' => $params['namespace'], 'year' => $params['year'], 'month' => $params['month'], 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'showSizeDiff' => $params['showsizediff'])); $feedItems = array(); if ($pager->getNumRows() > 0) { foreach ($pager->mResult as $row) { $feedItems[] = $this->feedItem($row); } } ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems); }
function doTagRow($tag, $hitcount) { static $doneTags = array(); if (in_array($tag, $doneTags)) { return ''; } $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); $newRow .= Xml::tags('td', null, $desc); $hitcount = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcount = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
/** * Make a "what links here" link for a given title * * @param Title $title Title to make the link for * @param Skin $skin Skin to use * @param object $result Result row * @return string */ private function makeWlhLink($title, $skin, $result) { global $wgLang; $wlh = SpecialPage::getTitleFor('Whatlinkshere'); $label = wfMsgExt('nlinks', array('parsemag', 'escape'), $wgLang->formatNum($result->value)); return $skin->link($wlh, $label, array(), array('target' => $title->getPrefixedText())); }
/** * @param $tpl * @return bool */ public static function addToolboxLink( &$tpl ) { global $wgOut, $wgShortUrlPrefix; if ( !is_string( $wgShortUrlPrefix ) ) { $urlPrefix = SpecialPage::getTitleFor( 'ShortUrl' )->getCanonicalUrl() . '/'; } else { $urlPrefix = $wgShortUrlPrefix; } $title = $wgOut->getTitle(); if ( ShortUrlUtils::needsShortUrl( $title ) ) { $shortId = ShortUrlUtils::encodeTitle( $title ); $shortURL = $urlPrefix . $shortId; $html = Html::rawElement( 'li', array( 'id' => 't-shorturl' ), Html::Element( 'a', array( 'href' => $shortURL, 'title' => wfMsg( 'shorturl-toolbox-title' ) ), wfMsg( 'shorturl-toolbox-text' ) ) ); echo $html; } return true; }
public function getRedirectTarget() { if ($this->getTitle()->getPrefixedText() === 'Redirected') { return SpecialPage::getTitleFor('Blankpage'); } return null; }
function displayEditForm() { global $wgOut, $wgRequest; $url = $wgRequest->getVal('_url'); $title = $wgRequest->getVal('_title'); $l = new Link(); $link = $l->getLinkByPageID($wgRequest->getInt('id')); if (is_array($link)) { $url = htmlspecialchars($link['url'], ENT_QUOTES); $description = htmlspecialchars($link['description'], ENT_QUOTES); } else { $title = SpecialPage::getTitleFor('LinkSubmit'); $wgOut->redirect($title->getFullURL()); } $wgOut->setPageTitle(wfMsg('linkfilter-edit-title', $link['title'])); $_SESSION['alreadysubmitted'] = false; $output = '<div class="lr-left"> <div class="link-home-navigation"> <a href="' . Link::getHomeLinkURL() . '">' . wfMsg('linkfilter-home-button') . '</a>'; if (Link::canAdmin()) { $output .= ' <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>'; } $output .= '<div class="cleared"></div> </div> <form name="link" id="linksubmit" method="post" action=""> <div class="link-submit-title"> <label>' . wfMsg('linkfilter-url') . '</label> </div> <input tabindex="2" class="lr-input" type="text" name="lf_URL" id="lf_URL" value="' . $url . '"/> <div class="link-submit-title"> <label>' . wfMsg('linkfilter-description') . '</label> </div> <div class="link-characters-left">' . wfMsg('linkfilter-description-max') . ' - ' . wfMsg('linkfilter-description-left', '<span id="desc-remaining">300</span>') . '</div> <textarea tabindex="3" class="lr-input" rows="4" name="lf_desc" id="lf_desc">' . $description . '</textarea> <div class="link-submit-title"> <label>' . wfMsg('linkfilter-type') . '</label> </div> <select tabindex="4" name="lf_type" id="lf_type"> <option value="">-</option>'; $linkTypes = Link::getLinkTypes(); foreach ($linkTypes as $id => $type) { $selected = ''; if ($link['type'] == $id) { $selected = ' selected="selected"'; } $output .= "<option value=\"{$id}\"{$selected}>{$type}</option>"; } $output .= '</select> <div class="link-submit-button"> <input tabindex="5" class="site-button" type="button" id="link-submit-button" value="' . wfMsg('linkfilter-submit-button') . '" /> </div> </form> </div>'; $output .= '<div class="lr-right">' . wfMsgExt('linkfilter-instructions', 'parse') . '</div> <div class="cleared"></div>'; return $output; }
function formatResult($skin, $result) { $title = Title::makeTitle(NS_TEMPLATE, $result->title); $pageLink = $skin->linkKnown($title, null, array(), array('redirect' => 'no')); $wlhLink = $skin->linkKnown(SpecialPage::getTitleFor('Whatlinkshere'), wfMsgHtml('unusedtemplateswlh'), array(), array('target' => $title->getPrefixedText())); return wfSpecialList($pageLink, $wlhLink); }
/** * Show the special page * * @param $params Mixed: parameter(s) passed to the page or null */ public function execute($params) { $out = $this->getOutput(); $user = $this->getUser(); // Set the page title, robot policies, etc. $this->setHeaders(); /** * Redirect anonymous users to the login page * It will automatically return them to the ViewRelationshipRequests page */ if (!$user->isLoggedIn()) { $out->setPageTitle($this->msg('ur-error-page-title')->plain()); $login = SpecialPage::getTitleFor('Userlogin'); $out->redirect($login->getFullURL('returnto=Special:ViewRelationshipRequests')); return false; } // Add CSS & JS $out->addModuleStyles('ext.socialprofile.userrelationship.css'); $out->addModules('ext.socialprofile.userrelationship.js'); $rel = new UserRelationship($user->getName()); $friend_request_count = $rel->getOpenRequestCount($user->getID(), 1); $foe_request_count = $rel->getOpenRequestCount($user->getID(), 2); if ($this->getRequest()->wasPosted() && $_SESSION['alreadysubmitted'] == false) { $_SESSION['alreadysubmitted'] = true; $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST['message']); $output = '<br /><span class="title">' . $this->msg('ur-already-submitted')->plain() . '</span><br /><br />'; $out->addHTML($output); } else { $_SESSION['alreadysubmitted'] = false; $output = ''; $out->setPageTitle($this->msg('ur-requests-title')->plain()); $requests = $rel->getRequestList(0); if ($requests) { foreach ($requests as $request) { $user_from = Title::makeTitle(NS_USER, $request['user_name_from']); $avatar = new wAvatar($request['user_id_from'], 'l'); $avatar_img = $avatar->getAvatarURL(); if ($request['type'] == 'Foe') { $msg = $this->msg('ur-requests-message-foe', htmlspecialchars($user_from->getFullURL()), $request['user_name_from'])->text(); } else { $msg = $this->msg('ur-requests-message-friend', htmlspecialchars($user_from->getFullURL()), $request['user_name_from'])->text(); } $message = $out->parse(trim($request['message']), false); $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request['id']}\">\n\t\t\t\t\t \t{$avatar_img}" . $msg; if ($request['message']) { $output .= '<div class="relationship-message">' . $message . '</div>'; } $output .= '<div class="cleared"></div> <div class="relationship-buttons"> <input type="button" class="site-button" value="' . $this->msg('ur-accept')->plain() . '" data-response="1" /> <input type="button" class="site-button" value="' . $this->msg('ur-reject')->plain() . '" data-response="-1" /> </div> </div>'; } } else { $output = $this->msg('ur-no-requests-message')->parse(); } $out->addHTML($output); } }
public function execute() { global $wgUser, $wgTranslateWorkflowStates; if (!$wgTranslateWorkflowStates) { $this->dieUsage('Message group review not in use', 'disabled'); } if (!$wgUser->isallowed(self::$right)) { $this->dieUsage('Permission denied', 'permissiondenied'); } $requestParams = $this->extractRequestParams(); $group = MessageGroups::getGroup($requestParams['group']); if (!$group) { $this->dieUsageMsg(array('missingparam', 'group')); } $languages = Language::getLanguageNames(false); if (!isset($languages[$requestParams['language']])) { $this->dieUsageMsg(array('missingparam', 'language')); } $dbr = wfGetDB(DB_SLAVE); $groupid = $group->getId(); $currentState = $dbr->selectField('translate_groupreviews', 'tgr_state', array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language']), __METHOD__); if ($currentState == $requestParams['state']) { $this->dieUsage('The requested state is identical to the current state', 'sameworkflowstate'); } $dbw = wfGetDB(DB_MASTER); $table = 'translate_groupreviews'; $row = array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language'], 'tgr_state' => $requestParams['state']); $index = array('tgr_group', 'tgr_language'); $res = $dbw->replace($table, array($index), $row, __METHOD__); $logger = new LogPage('translationreview'); $logParams = array($requestParams['language'], $group->getLabel(), $currentState, $requestParams['state']); $logger->addEntry('group', SpecialPage::getTitleFor('Translate', $groupid), '', $logParams, $wgUser); $output = array('review' => array('group' => $group->getId(), 'language' => $requestParams['language'], 'state' => $requestParams['state'])); $this->getResult()->addValue(null, $this->getModuleName(), $output); }
/** * @param Skin $skin * @param object $result Result row * @return string */ function formatResult($skin, $result) { $title = Title::makeTitle(NS_TEMPLATE, $result->title); $pageLink = Linker::linkKnown($title, null, array(), array('redirect' => 'no')); $wlhLink = Linker::linkKnown(SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText()), $this->msg('unusedtemplateswlh')->escaped()); return $this->getLanguage()->specialList($pageLink, $wlhLink); }
function doTagRow($tag, $hitcount) { static $sk = null, $doneTags = array(); if (!$sk) { $sk = $this->getSkin(); } if (in_array($tag, $doneTags)) { return ''; } global $wgLang; $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsgHtml('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $disp); $msg = wfMessage("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsgHtml('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $desc); $hitcount = wfMsgExt('tags-hitcount', array('parsemag'), $wgLang->formatNum($hitcount)); $hitcount = $sk->link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
function showForm($form, $errmsg = null) { global $wgOut, $wgRequest, $wgParser, $wgUser, $wgSpecialFormRecaptcha; $self = SpecialPage::getTitleFor(wfMsgForContent('form') . '/' . $form->name); $wgOut->setPageTitle($form->title); if (!is_null($form->instructions)) { $wgOut->addHTML(Xml::openElement('div', array('class' => 'instructions')) . $wgOut->parse($form->instructions) . Xml::closeElement('div') . Xml::element('br')); } if (!is_null($errmsg)) { $wgOut->addHTML(Xml::openElement('div', array('class' => 'error')) . $wgOut->parse($errmsg) . Xml::closeElement('div') . Xml::element('br')); } $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $self->getLocalURL()))); foreach ($form->fields as $field) { $wgOut->addHTML($field->render($wgRequest->getText($field->name)) . Xml::element('br') . "\n"); } # Anonymous user, use recaptcha if ($wgUser->getId() == 0 && $wgSpecialFormRecaptcha) { require_once 'recaptchalib.php'; global $recaptcha_public_key; # same as used by Recaptcha plugin $wgOut->addHTML(recaptcha_get_html($recaptcha_public_key)); } $wgOut->addHTML(Xml::element('input', array('type' => 'submit', 'value' => wfMsg('formsave')))); $wgOut->addHTML(Xml::closeElement('form')); }
public function onView() { $rc = RecentChange::newFromId($this->getRequest()->getInt('rcid')); if (is_null($rc)) { throw new ErrorPageError('markedaspatrollederror', 'markedaspatrollederrortext'); } $errors = $rc->doMarkPatrolled($this->getUser()); if (in_array(array('rcpatroldisabled'), $errors)) { throw new ErrorPageError('rcpatroldisabled', 'rcpatroldisabledtext'); } if (in_array(array('hookaborted'), $errors)) { // The hook itself has handled any output return; } # It would be nice to see where the user had actually come from, but for now just guess $returnto = $rc->getAttribute('rc_type') == RC_NEW ? 'Newpages' : 'Recentchanges'; $return = SpecialPage::getTitleFor($returnto); if (in_array(array('markedaspatrollederror-noautopatrol'), $errors)) { $this->getOutput()->setPageTitle(wfMsg('markedaspatrollederror')); $this->getOutput()->addWikiMsg('markedaspatrollederror-noautopatrol'); $this->getOutput()->returnToMain(null, $return); return; } if (!empty($errors)) { $this->getOutput()->showPermissionsErrorPage($errors); return; } # Inform the user $this->getOutput()->setPageTitle(wfMsg('markedaspatrolled')); $this->getOutput()->addWikiMsg('markedaspatrolledtext', $rc->getTitle()->getPrefixedText()); $this->getOutput()->returnToMain(null, $return); }
public static function notificator_Render($parser, $receiver = '', $receiverLabel = '') { global $wgScript, $wgTitle; if (!$receiverLabel) { $receiverLabel = $receiver; } // Check that the database table is in place if (!Notificator::checkDatabaseTableExists()) { $output = '<span class="error">' . htmlspecialchars(wfMsg('notificator-db-table-does-not-exist')) . '</span>'; return array($output, 'noparse' => true, 'isHTML' => true); } // The rendering is different, depending on whether a valid e-mail address // has been provided, or not - the differing part of the HTML form is being // built here if (Notificator::receiverIsValid($receiver)) { // Valid e-mail address available, so build a hidden input with that address // set, and a button $receiverInputAndSubmitButton = Html::hidden('receiver', $receiver) . Html::element('input', array('type' => 'submit', 'value' => wfMsg('notificator-notify-address-or-name', $receiverLabel))); } else { // No (valid) e-mail address available, build a text input and a button $receiverInputAndSubmitButton = Html::element('input', array('type' => 'text', 'name' => 'receiver', 'value' => wfMsg('notificator-e-mail-address'), 'onfocus' => 'if (this.value == \'' . wfMsg('notificator-e-mail-address') . '\') {this.value=\'\'}')) . Html::element('input', array('type' => 'submit', 'value' => wfMsg('notificator-notify'))); } // Now we assemble the form, consisting of two hidden inputs for page ID and rev ID, // as well as the $receiverInputAndSubmitButton built above $output = Html::rawElement('form', array('action' => SpecialPage::getTitleFor('Notificator')->getLocalURL(), 'method' => 'post', 'enctype' => 'multipart/form-data'), Html::hidden('pageId', $wgTitle->getArticleID()) . Html::hidden('revId', $wgTitle->getLatestRevID()) . $receiverInputAndSubmitButton); return $parser->insertStripItem($output, $parser->mStripState); }
function doTagRow($tag, $hitcount) { static $sk = null, $doneTags = array(); if (!$sk) { global $wgUser; $sk = $wgUser->getSkin(); } if (in_array($tag, $doneTags)) { return ''; } $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsg('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $disp); $desc = wfMsgExt("tag-{$tag}-description", 'parseinline'); $desc = wfEmptyMsg("tag-{$tag}-description", $desc) ? '' : $desc; $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsg('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $desc); $hitcount = wfMsg('tags-hitcount', $hitcount); $hitcount = $sk->link(SpecialPage::getTitleFor('RecentChanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
/** * For administrators, add a link to the special 'AdminLinks' page * among the user's "personal URLs" at the top, if they have * the 'adminlinks' permission. * * @param array $personal_urls * @param Title $title * * @return bool true */ public static function addURLToUserLinks(array &$personal_urls, Title &$title) { global $wgUser; // if user is a sysop, add link if ($wgUser->isAllowed('adminlinks')) { $al = SpecialPage::getTitleFor('AdminLinks'); $href = $al->getLocalURL(); $admin_links_vals = array('text' => wfMessage('adminlinks')->text(), 'href' => $href, 'active' => $href == $title->getLocalURL()); // find the location of the 'my preferences' link, and // add the link to 'AdminLinks' right before it. // this is a "key-safe" splice - it preserves both the // keys and the values of the array, by editing them // separately and then rebuilding the array. // based on the example at http://us2.php.net/manual/en/function.array-splice.php#31234 $tab_keys = array_keys($personal_urls); $tab_values = array_values($personal_urls); $prefs_location = array_search('preferences', $tab_keys); array_splice($tab_keys, $prefs_location, 0, 'adminlinks'); array_splice($tab_values, $prefs_location, 0, array($admin_links_vals)); $personal_urls = array(); for ($i = 0; $i < count($tab_keys); $i++) { $personal_urls[$tab_keys[$i]] = $tab_values[$i]; } } return true; }