function __construct($view, $thread) { parent::__construct(); $this->thread = $thread; $this->view = $view; self::$change_names = array(Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans('lqt_hist_comment_edited'), Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans('lqt_hist_summary_changed'), Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans('lqt_hist_reply_created'), Threads::CHANGE_NEW_THREAD => wfMsgNoTrans('lqt_hist_thread_created'), Threads::CHANGE_DELETED => wfMsgNoTrans('lqt_hist_deleted'), Threads::CHANGE_UNDELETED => wfMsgNoTrans('lqt_hist_undeleted'), Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans('lqt_hist_moved_talkpage'), Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans('lqt_hist_edited_subject'), Threads::CHANGE_SPLIT => wfMsgNoTrans('lqt_hist_split'), Threads::CHANGE_MERGED_FROM => wfMsgNoTrans('lqt_hist_merged_from'), Threads::CHANGE_MERGED_TO => wfMsgNoTrans('lqt_hist_merged_to'), Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans('lqt_hist_split_from'), Threads::CHANGE_ROOT_BLANKED => wfMsgNoTrans('lqt_hist_root_blanked'), Threads::CHANGE_ADJUSTED_SORTKEY => wfMsgNoTrans('lqt_hist_adjusted_sortkey')); }
public function getContributorsText($title) { global $wgUser, $wgLang; $this->target = $title; $contribText = ''; if ($this->target->exists()) { $total = 0; $skin = $wgUser->getSkin(); $link = $skin->makeKnownLinkObj($this->target); $contribText .= '<h2>' . wfMsgHtml('contributors-subtitle', $link) . '</h2>'; list($contributors, $others) = $this->getMainContributors($title); $contribText .= '<ul>'; foreach ($contributors as $username => $info) { list($id, $count) = $info; $line = $skin->userLink($id, $username) . $skin->userToolLinks($id, $username); $line .= ' [' . $wgLang->formatNum($count) . ']'; $contribText .= '<li>' . $line . '</li>'; } $contribText .= '</ul>'; if ($others > 0) { $others = $wgLang->formatNum($others); $contribText .= wfMsgNoTrans('contributors-others-long', $others); } } else { $contribText .= '<p>' . htmlspecialchars(wfMsg('contributors-nosuchpage', $this->target->getPrefixedText())) . '</p>'; } return preg_replace('/"/', '\\"', $contribText); }
/** * Adds the needed JS messages to the page output. * This is for backward compatibility with pre-RL MediaWiki. * * @since 0.1 */ protected static function addJSLocalisation() { global $egLTJSMessages, $wgOut; $data = array(); foreach ($egLTJSMessages as $msg) { $data[$msg] = wfMsgNoTrans($msg); } $wgOut->addInlineScript('var wgLTEMessages = ' . FormatJson::encode($data) . ';'); }
/** * Get a message from i18n * * @param $key String: message name * @param $fallback String: default message if the message cache can't be * called by the exception * The function also has other parameters that are arguments for the message * @return String message with arguments replaced */ function msg($key, $fallback) { $args = array_slice(func_get_args(), 2); if ($this->useMessageCache()) { return wfMsgNoTrans($key, $args); } else { return wfMsgReplaceArgs($fallback, $args); } }
/** * Main execution function * @param $par Parameters passed to the page */ function execute($par) { global $wgRequest, $wgOut, $wgMakeBotPrivileged, $wgUser; $this->setHeaders(); if ($par) { $this->target = $par; } else { $this->target = $wgRequest->getVal('target', wfMsg('rootcategory')); } $this->target = trim($this->target); #HACK for undefined root category if ($this->target == '<rootcategory>' || $this->target == '<rootcategory>') { $this->target = NULL; } $this->mode = $wgRequest->getVal('mode', CT_MODE_CATEGORIES); if ($this->mode == 'all') { $this->mode = CT_MODE_ALL; } else { if ($this->mode == 'pages') { $this->mode = CT_MODE_PAGES; } else { if ($this->mode == 'categories') { $this->mode = CT_MODE_CATEGORIES; } } } $this->mode = (int) $this->mode; $wgOut->addWikiText(wfMsgNoTrans('categorytree-header')); $wgOut->addHtml($this->makeInputForm()); if ($this->target !== '' && $this->target !== NULL) { CategoryTree::setHeaders($wgOut); $title = CategoryTree::makeTitle($this->target); if ($title && $title->getArticleID()) { $html = ''; $html .= wfOpenElement('div', array('class' => 'CategoryTreeParents')); $html .= wfElement('span', array('class' => 'CategoryTreeParents'), wfMsg('categorytree-parents')) . ': '; $ct = new CategoryTree(); $parents = $ct->renderParents($title, $this->mode); if ($parents == '') { $html .= wfMsg('categorytree-nothing-found'); } else { $html .= $parents; } $html .= wfCloseElement('div'); $html .= wfOpenElement('div', array('class' => 'CategoryTreeResult')); $html .= $ct->renderNode($title, $this->mode, true, false); $html .= wfCloseElement('div'); $wgOut->addHtml($html); } else { $wgOut->addHtml(wfOpenElement('div', array('class' => 'CategoryTreeNotice'))); $wgOut->addWikiText(wfMsg('categorytree-not-found', $this->target)); $wgOut->addHtml(wfCloseElement('div')); } } }
function wfExtensionCommentbox_Add(&$op, &$text) { global $wgUser, $wgRequest, $wgCommentboxNamespaces, $wgCommentboxRows, $wgCommentboxColumns; $title = $op->getTitle(); if (!$title->exists()) { return true; } if (!$title->userCan('edit', true)) { return true; } if (!array_key_exists($title->getNamespace(), $wgCommentboxNamespaces) || !$wgCommentboxNamespaces[$title->getNamespace()]) { return true; } $action = $wgRequest->getVal('action', 'view'); if (!($action == 'view' || $action == 'purge' || $action == 'submit')) { return true; } if ($wgRequest->getCheck('wpPreview') || $wgRequest->getCheck('wpLivePreview') || $wgRequest->getCheck('wpDiff')) { return true; } if (!is_null($wgRequest->getVal('preview'))) { return true; } if (!is_null($wgRequest->getVal('diff'))) { return true; } $newaction = Title::newFromText('AddComment', NS_SPECIAL)->escapeFullURL(); $name = ''; if (!$wgUser->isLoggedIn()) { $namecomment = wfMsgExt('commentbox-name-explanation', 'parseinline'); $namelabel = wfMsgExt('commentbox-name', 'parseinline'); $name = '<br />' . $namelabel; $name .= ' <input name="wpAuthor" tabindex="2" type="text" size="30" maxlength="50" /> '; $name .= $namecomment; } $inhalt = wfMsgNoTrans('commentbox-prefill'); $save = wfMsgExt('commentbox-savebutton', 'escapenoentities'); $texttitle = htmlspecialchars(Title::makeName($title->getNamespace(), $title->getText())); $intro = wfMsgExt('commentbox-intro', 'parse'); $text .= <<<END \t<form id="commentform" name="commentform" method="post" action="{$newaction}" enctype="multipart/form-data"> \t{$intro} \t<textarea tabindex='1' accesskey="," name="wpComment" id="wpComment" \t rows='{$wgCommentboxRows}' cols='{$wgCommentboxColumns}' \t\t >{$inhalt}</textarea> \t{$name} \t<br /> \t<input type="hidden" name="wpPageName" value="{$texttitle}" /> \t<input id="wpSave" name="wpSave" type="submit" tabindex="3" value="{$save}" \t accesskey="s" title="{$save} [alt-s]" /> \t</form> END; return true; }
public static function ucscOutputBeforeHTML(&$out, &$text) { # We are done if the trust tab isn't selected global $wgRequest; $use_trust = $wgRequest->getVal('trust'); if (!isset($use_trust) || $wgRequest->getVal('action') && $wgRequest->getVal('action') != 'purge') { return true; } wfLoadExtensionMessages('WikiTrust'); self::color_addFileRefs($out); $ctext_html = "<div id='text-button'><input type='button' name='ctext' value='getColoredText' onclick='startGetColoredText()'></div>"; $vtext_html = "<div id='vote-button'><input type='button' name='vote' value='" . wfMsgNoTrans("wgVoteText") . "' onclick='startVote()' /></div><div id='vote-button-done'>" . wfMsgNoTrans("wgThankYouForVoting") . "</div>"; $out->addHTML($ctext_html); $out->addHTML($vtext_html); return true; }
/** * Constructor. */ function wfSpecialAllmessages() { global $wgOut, $wgRequest, $wgMessageCache, $wgTitle; global $wgUseDatabaseMessages, $wgLang; # The page isn't much use if the MediaWiki namespace is not being used if (!$wgUseDatabaseMessages) { $wgOut->addWikiMsg('allmessagesnotsupportedDB'); return; } wfProfileIn(__METHOD__); wfProfileIn(__METHOD__ . '-setup'); $ot = $wgRequest->getText('ot'); $navText = wfMsg('allmessagestext'); # Make sure all extension messages are available $wgMessageCache->loadAllMessages(); $sortedArray = array_merge(Language::getMessagesFor('en'), $wgMessageCache->getExtensionMessagesFor('en')); ksort($sortedArray); $messages = array(); foreach ($sortedArray as $key => $value) { $messages[$key]['enmsg'] = $value; $messages[$key]['statmsg'] = wfMsgReal($key, array(), false, false, false); $messages[$key]['msg'] = wfMsgNoTrans($key); $sortedArray[$key] = NULL; // trade bytes from $sortedArray to this } unset($sortedArray); // trade bytes from $sortedArray to this wfProfileOut(__METHOD__ . '-setup'); wfProfileIn(__METHOD__ . '-output'); $wgOut->addScriptFile('allmessages.js'); if ($ot == 'php') { $navText .= wfAllMessagesMakePhp($messages); $wgOut->addHTML($wgLang->pipeList(array('PHP', '<a href="' . $wgTitle->escapeLocalUrl('ot=html') . '">HTML</a>', '<a href="' . $wgTitle->escapeLocalUrl('ot=xml') . '">XML</a>' . '<pre>' . htmlspecialchars($navText) . '</pre>'))); } else { if ($ot == 'xml') { $wgOut->disable(); header('Content-type: text/xml'); echo wfAllMessagesMakeXml($messages); } else { $wgOut->addHTML($wgLang->pipeList(array('<a href="' . $wgTitle->escapeLocalUrl('ot=php') . '">PHP</a>', 'HTML', '<a href="' . $wgTitle->escapeLocalUrl('ot=xml') . '">XML</a>'))); $wgOut->addWikiText($navText); $wgOut->addHTML(wfAllMessagesMakeHTMLText($messages)); } } wfProfileOut(__METHOD__ . '-output'); wfProfileOut(__METHOD__); }
function show() { $filter = $this->mPage->mFilter; global $wgUser, $wgRequest, $wgOut; $sk = $wgUser->getSkin(); if (!$wgUser->isAllowed('abusefilter-revert')) { $wgOut->permissionRequired('abusefilter-revert'); return; } $this->loadParameters(); if ($this->attemptRevert()) { return; } $wgOut->addWikiMsg('abusefilter-revert-intro', $filter); $wgOut->setPageTitle(wfMsg('abusefilter-revert-title', $filter)); // First, the search form. $searchFields = array(); $searchFields['abusefilter-revert-filter'] = Xml::element('strong', null, $filter); $searchFields['abusefilter-revert-periodstart'] = Xml::input('wpPeriodStart', 45, $this->origPeriodStart); $searchFields['abusefilter-revert-periodend'] = Xml::input('wpPeriodEnd', 45, $this->origPeriodEnd); $searchForm = Xml::buildForm($searchFields, 'abusefilter-revert-search'); $searchForm .= "\n" . Xml::hidden('submit', 1); $searchForm = Xml::tags('form', array('action' => $this->getTitle("revert/{$filter}")->getLocalURL(), 'method' => 'POST'), $searchForm); $searchForm = Xml::fieldset(wfMsg('abusefilter-revert-search-legend'), $searchForm); $wgOut->addHTML($searchForm); if ($this->mSubmit) { // Add a summary of everything that will be reversed. $wgOut->addWikiMsg('abusefilter-revert-preview-intro'); // Look up all of them. $results = $this->doLookup(); $list = array(); foreach ($results as $result) { $displayActions = array(); global $wgLang; $displayActions = array_map(array('AbuseFilter', 'getActionDisplay'), $result['actions']); $msg = wfMsgExt('abusefilter-revert-preview-item', array('parseinline', 'replaceafter'), array($wgLang->timeanddate($result['timestamp'], true), $sk->userLink($result['userid'], $result['user']), $result['action'], $sk->link($result['title']), $wgLang->commaList($displayActions), $sk->link(SpecialPage::getTitleFor('AbuseLog'), wfMsgNoTrans('abusefilter-log-detailslink'), array(), array('details' => $result['id'])))); $list[] = Xml::tags('li', null, $msg); } $wgOut->addHTML(Xml::tags('ul', null, implode("\n", $list))); // Add a button down the bottom. $confirmForm = Xml::hidden('editToken', $wgUser->editToken("abusefilter-revert-{$filter}")) . Xml::hidden('title', $this->getTitle("revert/{$filter}")->getPrefixedText()) . Xml::hidden('wpPeriodStart', $this->origPeriodStart) . Xml::hidden('wpPeriodEnd', $this->origPeriodEnd) . Xml::inputLabel(wfMsg('abusefilter-revert-reasonfield'), 'wpReason', 'wpReason', 45) . "\n" . Xml::submitButton(wfMsg('abusefilter-revert-confirm')); $confirmForm = Xml::tags('form', array('action' => $this->getTitle("revert/{$filter}")->getLocalURL(), 'method' => 'post'), $confirmForm); $wgOut->addHTML($confirmForm); } }
function execute($par) { global $wgOut, $wgRequest, $haclgContLang, $wgTitle; if (!function_exists('curl_init')) { $wgOut->showErrorPage('iacl-selftest-no-curl', 'iacl-selftest-no-curl-text'); return; } $this->access_denied_page = preg_quote(SpecialPage::getTitleFor('Badtitle')->getPrefixedText()) . '|' . preg_quote($haclgContLang->getPermissionDeniedPage()); $q = $wgRequest->getValues(); if (!empty($q['do'])) { $wgOut->disable(); $this->doChecks(!empty($q['quiet'])); } else { $wgOut->setPageTitle(wfMsg('iacl-selftest-title')); $wgOut->addWikiText(wfMsgNoTrans('iacl-selftest-info', $wgTitle->getFullUrl(array('do' => 1, 'quiet' => 1)))); $wgOut->addHTML('<iframe style="border-width: 0; width: 100%; height: 500px" src="' . $wgTitle->getLocalUrl(array('do' => 1)) . '"></iframe>'); } }
/** * Show the special page * * @param mixed $par (not used) */ function wfSpecialStatistics($par = '') { global $wgOut, $wgLang, $wgRequest; $dbr = wfGetDB(DB_SLAVE); $views = SiteStats::views(); $edits = SiteStats::edits(); $good = SiteStats::articles(); $images = SiteStats::images(); $total = SiteStats::pages(); $users = SiteStats::users(); $admins = SiteStats::admins(); $numJobs = SiteStats::jobs(); if ($wgRequest->getVal('action') == 'raw') { $wgOut->disable(); header('Pragma: nocache'); echo "total={$total};good={$good};views={$views};edits={$edits};users={$users};admins={$admins};images={$images};jobs={$numJobs}\n"; return; } else { $text = "__NOTOC__\n"; $text .= '==' . wfMsgNoTrans('sitestats') . "==\n"; $text .= wfMsgExt('sitestatstext', array('parsemag'), $wgLang->formatNum($total), $wgLang->formatNum($good), $wgLang->formatNum($views), $wgLang->formatNum($edits), $wgLang->formatNum(sprintf('%.2f', $total ? $edits / $total : 0)), $wgLang->formatNum(sprintf('%.2f', $edits ? $views / $edits : 0)), $wgLang->formatNum($numJobs), $wgLang->formatNum($images)) . "\n"; $text .= "==" . wfMsgNoTrans('userstats') . "==\n"; $text .= wfMsgExt('userstatstext', array('parsemag'), $wgLang->formatNum($users), $wgLang->formatNum($admins), '[[' . wfMsgForContent('grouppage-sysop') . ']]', $wgLang->formatNum(sprintf('%.2f', $admins / $users * 100)), User::makeGroupLinkWiki('sysop')) . "\n"; global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang; if (!$wgDisableCounters && !$wgMiserMode) { $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_counter'), array('page_is_redirect' => 0, 'page_counter > 0'), __METHOD__, array('ORDER BY' => 'page_counter DESC', 'LIMIT' => 10)); if ($res->numRows() > 0) { $text .= "==" . wfMsgNoTrans('statistics-mostpopular') . "==\n"; while ($row = $res->fetchObject()) { $title = Title::makeTitleSafe($row->page_namespace, $row->page_title); if ($title instanceof Title) { $text .= '* [[:' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum($row->page_counter) . ")\n"; } } $res->free(); } } $footer = wfMsgNoTrans('statistics-footer'); if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') { $text .= "\n" . $footer; } $wgOut->addWikiText($text); } }
/** * Process the 'delvote' action. * @param Article $article The article to endorse/object to deletion of. */ public function process($article) { global $wgRequest, $wgOut, $wgUser; $errs = $article->mTitle->getUserPermissionsErrors('deletequeue-vote', $wgUser); if (count($errs) > 0) { $wgOut->showPermissionsErrorPage($errs); return; } $dqi = DeleteQueueItem::newFromArticle($article); $wgOut->setPageTitle(wfMsg('deletequeue-vote-title', $article->mTitle->getPrefixedText())); // Load form data $token = $wgRequest->getVal('wpEditToken'); $action = $wgRequest->getVal('wpVote'); $comments = $wgRequest->getText('wpComments'); if ($wgUser->matchEditToken($token) && in_array($action, array('endorse', 'object'))) { $dqi->addVote($action, $comments); if ($action == 'object' && $dqi->getQueue() == 'prod') { $dbw = wfGetDB(DB_MASTER); $dbw->begin(); $dqi->setQueue('deletediscuss', $dqi->getReason()); $lp = new LogPage('delete'); $lp->addEntry('requeue', $article->mTitle, $comments, array(wfMsgForContent('deletequeue-queue-prod'), wfMsgForContent("deletequeue-queue-deletediscuss"))); $dbw->commit(); $wgOut->addWikiMsg('deletequeue-vote-requeued', wfMsgNoTrans('deletequeue-queue-deletediscuss')); } else { $wgOut->addWikiMsg("deletequeue-vote-success-{$action}"); } return; } $wgOut->addWikiMsg('deletequeue-vote-text', $article->mTitle->getPrefixedText(), $dqi->getReason()); // Add main form. $fields = array(); $options = Xml::tags('p', null, Xml::radioLabel(wfMsg('deletequeue-vote-endorse'), 'wpVote', 'endorse', 'mw-deletequeue-vote-endorse')); $options .= Xml::tags('p', null, Xml::radioLabel(wfMsg('deletequeue-vote-object'), 'wpVote', 'object', 'mw-deletequeue-vote-object')); $fields['deletequeue-vote-action'] = $options; $fields['deletequeue-vote-reason'] = Xml::input('wpComments', 45, $comments); $article_id = $article->getId(); $title = $this->getTitle("vote/{$article_id}"); $form = Xml::buildForm($fields, 'deletequeue-vote-submit') . Html::Hidden('wpEditToken', $wgUser->editToken()) . Html::Hidden('title', $title->getPrefixedText()); $form = Xml::tags('form', array('action' => $title->getLocalURL(), 'method' => 'POST'), $form); $form = Xml::fieldset(wfMsg('deletequeue-vote-legend'), $form); $wgOut->addHTML($form); }
/** * Generate a form allowing users to enter information * * @param $title Value for context title field * @param $input Value for input textbox * @return string */ private function makeForm($title, $input) { $self = $this->getTitle(); $form = Xml::openElement('form', array('method' => 'post', 'action' => $self->getLocalUrl())); $form .= "<fieldset><legend>" . wfMsgHtml('expandtemplates') . "</legend>\n"; $form .= '<p>' . Xml::inputLabel(wfMsgNoTrans('expand_templates_title'), 'contexttitle', 'contexttitle', 60, $title) . '</p>'; $form .= '<p>' . Xml::label(wfMsg('expand_templates_input'), 'input') . '</p>'; $form .= Xml::openElement('textarea', array('name' => 'input', 'id' => 'input', 'rows' => 10, 'cols' => 10)); $form .= htmlspecialchars($input); $form .= Xml::closeElement('textarea'); $form .= '<p>' . Xml::checkLabel(wfMsg('expand_templates_remove_comments'), 'removecomments', 'removecomments', $this->removeComments) . '</p>'; $form .= '<p>' . Xml::checkLabel(wfMsg('expand_templates_remove_nowiki'), 'removenowiki', 'removenowiki', $this->removeNowiki) . '</p>'; if ($this->isNewParser) { $form .= '<p>' . Xml::checkLabel(wfMsg('expand_templates_generate_xml'), 'generate_xml', 'generate_xml', $this->generateXML) . '</p>'; } $form .= '<p>' . Xml::submitButton(wfMsg('expand_templates_ok'), array('accesskey' => 's')) . '</p>'; $form .= "</fieldset>\n"; $form .= Xml::closeElement('form'); return $form; }
function view() { global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; $diff = $wgRequest->getVal('diff'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly')); if ($this->mTitle->getNamespace() != NS_VIDEO || isset($diff) && $diffOnly) { return Article::view(); } # No need to display noarticletext, we use our own message, output in openShowImage() if ($this->getID()) { Article::view(); } else { # Just need to set the right headers $wgOut->setStatusCode(404); $wgOut->setArticleFlag(true); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $this->viewUpdates(); } # Show shared description, if needed if ($this->mExtraDescription) { $fol = wfMsgNoTrans('shareddescriptionfollows'); if ($fol != '-' && !wfEmptyMsg('shareddescriptionfollows', $fol)) { $wgOut->addWikiText($fol); } $wgOut->addHTML('<div id="shared-image-desc">' . $this->mExtraDescription . '</div>'); } $this->videoLinks(); $this->videoHistory(); if ($showmeta) { global $wgStylePath, $wgStyleVersion; $expand = htmlspecialchars(wfEscapeJsString(wfMsg('metadata-expand'))); $collapse = htmlspecialchars(wfEscapeJsString(wfMsg('metadata-collapse'))); $wgOut->addHTML(Xml::element('h2', array('id' => 'metadata'), wfMsg('metadata')) . "\n"); $wgOut->addWikiText($this->makeMetadataTable($formattedMetadata)); $wgOut->addHTML("<script type=\"text/javascript\" src=\"{$wgStylePath}/common/metadata.js?{$wgStyleVersion}\"></script>\n" . "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '{$expand}', '{$collapse}');</script>\n"); } }
/** * Take a bit of WikiText that looks like * <rss max=5>http://example.com/</rss> * and return an object that can produce rendered output. */ function __construct($url, $args) { $this->url = $url; # Get max number of headlines from argument-array if (isset($args['max'])) { $this->maxheads = $args['max']; } # Get reverse flag from argument array if (isset($args['reverse'])) { $this->reversed = true; } # Get date format from argument array # FIXME: not used yet if (isset($args['date'])) { $this->date = $args['date']; } # Get highlight terms from argument array if (isset($args['highlight'])) { # mapping to lowercase here so the regex can be case insensitive below. $this->highlight = self::explodeOnSpaces($args['highlight']); } # Get filter terms from argument array if (isset($args['filter'])) { $this->filter = self::explodeOnSpaces($args['filter']); } if (isset($args['filterout'])) { $this->filterOut = self::explodeOnSpaces($args['filterout']); } if (isset($args['template'])) { $titleObject = Title::newFromText($args['template'], NS_TEMPLATE); $article = new Article($titleObject, 0); $this->itemTemplate = $article->fetchContent(); } else { $templateName = isset($args['templatename']) ? $args['templatename'] : 'RSSPost'; $this->itemTemplate = wfMsgNoTrans('rss-item', $templateName); } }
/** * Get the error list as a wikitext formatted list * @param string $shortContext A short enclosing context message name, to be used * when there is a single error * @param string $longContext A long enclosing context message name, for a list */ function getWikiText($shortContext = false, $longContext = false) { if (count($this->errors) == 0) { if ($this->ok) { $this->fatal('internalerror_info', __METHOD__ . " called for a good result, this is incorrect\n"); } else { $this->fatal('internalerror_info', __METHOD__ . ": Invalid result object: no error text but not OK\n"); } } if (count($this->errors) == 1) { $params = array_map('wfEscapeWikiText', $this->cleanParams($this->errors[0]['params'])); $s = wfMsgReal($this->errors[0]['message'], $params, true, false, false); if ($shortContext) { $s = wfMsgNoTrans($shortContext, $s); } elseif ($longContext) { $s = wfMsgNoTrans($longContext, "* {$s}\n"); } } else { $s = ''; foreach ($this->errors as $error) { $params = array_map('wfEscapeWikiText', $this->cleanParams($error['params'])); $s .= '* ' . wfMsgReal($error['message'], $params, true, false, false) . "\n"; } if ($longContext) { $s = wfMsgNoTrans($longContext, $s); } elseif ($shortContext) { $s = wfMsgNoTrans($shortContext, "\n* {$s}\n"); } } return $s; }
/** * Adds the needed JS messages to the page output. * This is for backward compatibility with pre-RL MediaWiki. * * @since 0.1 */ protected function addJSLocalisation() { global $egRatingsStarsJSMessages; $data = array(); foreach ( $egRatingsStarsJSMessages as $msg ) { $data[$msg] = wfMsgNoTrans( $msg ); } $this->parser->getOutput()->addHeadItem( Html::inlineScript( 'var wgRatingsStarsMessages = ' . json_encode( $data ) . ';' ) ); }
/** * This method handles embedded content protection. * Must be set onto ArticleSaveComplete hook AFTER articleSaveComplete_SaveSD * in order to handle newly created page SDs. */ public static function articleSaveComplete_SaveEmbedded(&$article, &$user, $text) { // Flag to prevent recursion static $InsideSaveEmbedded; if ($InsideSaveEmbedded) { return true; } $InsideSaveEmbedded = true; global $wgRequest, $wgOut, $haclgContLang, $wgUser; $isACL = $article->getTitle()->getNamespace() == HACL_NS_ACL; if ($isACL) { $articleSD = IACLDefinition::newFromTitle($article->getTitle(), false); if (!$articleSD || $articleSD['pe_type'] != IACL::PE_PAGE) { // This is not a page SD, do nothing. return true; } } else { // FIXME possibly use the category SD for category pages // the problem here is that in ACL editor two different SDs // may be created and queried for embedded content: // for category article and for category itself $articleSD = IACLDefinition::getSDForPE(IACL::PE_PAGE, $article->getId()); if (!$articleSD) { return true; } } // Handle embedded content protection $errors = array(); foreach ($wgRequest->getValues() as $k => $v) { if (substr($k, 0, 7) == 'sd_emb_' && $v) { $wgRequest->setVal($k, false); // clear value to handle embedded content only one time $emb_pe_id = intval(substr($k, 7)); $emb_title = Title::newFromId($emb_pe_id); list($req_sd_type, $req_sd_id, $emb_sd_revid) = explode('-', $v, 3); if ($emb_title) { $emb_sd_title = Title::newFromText(IACLDefinition::nameOfSD(IACL::PE_PAGE, $emb_title)); $emb_sd_article = new WikiPage($emb_sd_title); } // Check for errors: if (!$emb_title || !$emb_title->getArticleId() || !$emb_sd_title->userCan('edit')) { // Embedded content deleted || Manage access denied $errors[] = array($emb_title, 'canedit'); } elseif ($req_sd_type && $req_sd_id && "{$req_sd_type}-{$req_sd_id}" != $articleSD['key']) { // Invalid SD requested for protection $errors[] = array($emb_title, 'invalidsd'); } elseif (!$emb_sd_revid && $emb_sd_title->exists() || $emb_sd_revid && $emb_sd_title->getLatestRevId() != $emb_sd_revid) { // Mid-air collision: SD created/changed by someone in the meantime $errors[] = array($emb_title, 'midair'); } else { // Save embedded element SD $emb_sd_article->doEdit('{{#predefined right: ' . $articleSD['def_title'] . '}}', wfMsg('hacl_comment_protect_embedded', '' . $articleSD['def_title']), EDIT_FORCE_BOT); } } } // Display errors to the user, if any // This is safe to do as we are definitely in interactive non-batch edit mode if ($errors) { foreach ($errors as &$e) { $e = "[[:" . $e[0]->getPrefixedText() . "]] (" . wfMsg('hacl_embedded_error_' . $e[1]) . ")"; } $wgOut->setTitle(Title::newFromText('Special:IntraACL')); $wgOut->addWikiText(wfMsgNoTrans('hacl_embedded_not_saved', implode(", ", $errors), $article->getTitle()->getPrefixedText())); $wgOut->setPageTitle(wfMsg('hacl_embedded_not_saved_title')); $wgOut->output(); // FIXME terminate MediaWiki more correctly wfGetDB(DB_MASTER)->commit(); exit; } // Clear flag and continue hook processing $InsideSaveEmbedded = false; return true; }
static private function direction($raw, $speakers, $block, Parser $parser, PPFrame $frame){ if ($block === true){ return '<font class="sternographDirection sternographDirectionBlock">'. Sternograph::expandSpeakers(wfMsgNoTrans('sternograph-block-pre'). $raw.wfMsgNoTrans('sternograph-block-post'), $speakers, $parser, $frame).'</font>'; }else{ return '<font class="sternographDirection sternographDirectionInline">'. Sternograph::expandSpeakers(wfMsgNoTrans('sternograph-inline-pre'). $raw.wfMsgNoTrans('sternograph-inline-post'), $speakers, $parser, $frame).'</font>'; } }
/** * Perform a deletion and output success or failure messages */ public function doDelete($reason, $suppress = false) { global $wgOut, $wgUser; $id = $this->mTitle->getArticleID(Title::GAID_FOR_UPDATE); $error = ''; if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error))) { if ($this->doDeleteArticle($reason, $suppress, $id)) { $deleted = $this->mTitle->getPrefixedText(); $wgOut->setPagetitle(wfMsg('actioncomplete')); $wgOut->setRobotPolicy('noindex,nofollow'); $loglink = '[[Special:Log/delete|' . wfMsgNoTrans('deletionlog') . ']]'; $wgOut->addWikiMsg('deletedtext', $deleted, $loglink); $wgOut->returnToMain(false); wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id)); } } else { if ($error == '') { $wgOut->showFatalError(Html::rawElement('div', array('class' => 'error mw-error-cannotdelete'), wfMsgExt('cannotdelete', array('parse'), $this->mTitle->getPrefixedText()))); $wgOut->addHTML(Xml::element('h2', null, LogPage::logName('delete'))); LogEventsList::showLogExtract($wgOut, 'delete', $this->mTitle->getPrefixedText()); } else { $wgOut->showFatalError($error); } } }
/** * main entry point * * @access public */ public function run() { global $wgUser, $wgTitle, $wgErrorLog; wfProfileIn(__METHOD__); $oldValue = $wgErrorLog; $wgErrorLog = true; /** * overwrite $wgUser for ~~~~ expanding */ $sysop = trim(wfMsgForContent("welcome-user")); if (!in_array($sysop, array("@disabled", "-"))) { $tmpUser = $wgUser; $wgUser = User::newFromName(self::WELCOMEUSER); $flags = 0; $bot_message = trim(wfMsgForContent("welcome-bot")); if ($bot_message == '@bot' || $wgUser && $wgUser->isAllowed('bot')) { $flags = EDIT_FORCE_BOT; } wfDebug(__METHOD__ . "-user: "******"-talk: " . $talkPage->getFullUrl()); if ($talkPage) { $this->mSysop = $this->getLastSysop(); $gEG = $this->mSysop->getEffectiveGroups(); $isSysop = in_array('sysop', $gEG); $isStaff = in_array('staff', $gEG); unset($gEG); $tmpTitle = $wgTitle; $sysopPage = $this->mSysop->getUserPage()->getTalkPage(); $signature = $this->expandSig(); $wgTitle = $talkPage; $welcomeMsg = false; $talkArticle = new Article($talkPage, 0); if (!self::isPosted($talkArticle, $this->mUser)) { if ($this->mAnon) { if ($this->isEnabled("message-anon")) { if ($isStaff && !$isSysop) { $key = $this->getMessageKey("anon-staff"); } else { $key = $this->getMessageKey("anon"); } $welcomeMsg = wfMsgNoTrans($key, array($this->getPrefixedText(), $sysopPage->getPrefixedText(), $signature, wfEscapeWikiText($this->mUser->getName()))); } else { wfDebug(__METHOD__ . "-talk: message-anon disabled"); } } else { /** * now create user page (if not exists of course) */ if ($this->isEnabled("page-user")) { $userPage = $this->mUser->getUserPage(); if ($userPage) { $wgTitle = $userPage; $userArticle = new Article($userPage, 0); wfDebug(__METHOD__ . "-userpage: " . $userPage->getFullUrl()); if (!$userArticle->exists()) { $pageMsg = wfMsgForContentNoTrans('welcome-user-page', $this->mUser->getName()); $userArticle->doEdit($pageMsg, false, $flags); } } else { wfDebug(__METHOD__ . "-page: user page already exists."); } } else { wfDebug(__METHOD__ . "-page: page-user disabled"); } if ($this->isEnabled("message-user")) { if ($isStaff && !$isSysop) { $key = $this->getMessageKey("user-staff"); } else { $key = $this->getMessageKey("user"); } $welcomeMsg = wfMsgNoTrans($key, array($this->getPrefixedText(), $sysopPage->getPrefixedText(), $signature, wfEscapeWikiText($this->mUser->getName()))); } else { wfDebug(__METHOD__ . "-talk: message-user disabled"); } } if ($welcomeMsg) { $wgTitle = $talkPage; /** is it necessary there? **/ //we posting it on talk page even when we have message wall //hack for notification problem global $wgCityId, $wgServer; $wgServer = WikiFactory::getVarValueByName('wgServer', $wgCityId); $this->doPost($talkArticle, $flags, wfMsgForContent("welcome-message-log"), $welcomeMsg, $wgUser, $this->mUser, $this->mSysop); } } $wgTitle = $tmpTitle; } } $wgUser = $tmpUser; $wgErrorLog = $oldValue; } else { wfDebug(__METHOD__ . "-disabled: " . $sysop); } wfProfileOut(__METHOD__); return true; }
public function beginImageHistoryList($navLinks = '') { global $wgOut, $wgUser; return Xml::element('h2', array('id' => 'filehistory'), wfMsg('filehist')) . "\n" . "<div id=\"mw-imagepage-section-filehistory\">\n" . $wgOut->parse(wfMsgNoTrans('filehist-help')) . $navLinks . "\n" . Xml::openElement('table', array('class' => 'wikitable filehistory')) . "\n" . '<tr><td></td>' . ($this->current->isLocal() && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deletedhistory')) ? '<td></td>' : '') . '<th>' . wfMsgHtml('filehist-datetime') . '</th>' . ($this->showThumb ? '<th>' . wfMsgHtml('filehist-thumb') . '</th>' : '') . '<th>' . wfMsgHtml('filehist-dimensions') . '</th>' . '<th>' . wfMsgHtml('filehist-user') . '</th>' . '<th>' . wfMsgHtml('filehist-comment') . '</th>' . "</tr>\n"; }
/** * Return the wiki text for a single error. * @param $error Mixed With an array & two values keyed by * 'message' and 'params', use those keys-value pairs. * Otherwise, if its an array, just use the first value as the * message and the remaining items as the params. * * @return String */ protected function getWikiTextForError($error) { if (is_array($error)) { if (isset($error['message']) && isset($error['params'])) { return wfMsgNoTrans($error['message'], array_map('wfEscapeWikiText', $this->cleanParams($error['params']))); } else { $message = array_shift($error); return wfMsgNoTrans($message, array_map('wfEscapeWikiText', $this->cleanParams($error))); } } else { return wfMsgNoTrans($error); } }
function showSuccess() { global $wgOut, $wgRequest, $wgUser; $old = Title::newFromText($wgRequest->getVal('oldtitle')); $new = Title::newFromText($wgRequest->getVal('newtitle')); if (is_null($old) || is_null($new)) { throw new ErrorPageError('badtitle', 'badtitletext'); } $wgOut->setPagetitle(wfMsg('movepage')); $wgOut->setSubtitle(wfMsg('pagemovedsub')); $talkmoved = $wgRequest->getVal('talkmoved'); $oldUrl = $old->getFullUrl('redirect=no'); $newUrl = $new->getFullUrl(); $oldText = $old->getPrefixedText(); $newText = $new->getPrefixedText(); $oldLink = "<span class='plainlinks'>[{$oldUrl} {$oldText}]</span>"; $newLink = "<span class='plainlinks'>[{$newUrl} {$newText}]</span>"; $s = wfMsgNoTrans('movepage-moved', $oldLink, $newLink, $oldText, $newText); if ($talkmoved == 1) { $s .= "\n\n" . wfMsgNoTrans('talkpagemoved'); } elseif ('articleexists' == $talkmoved) { $s .= "\n\n" . wfMsgNoTrans('talkexists'); } else { if (!$old->isTalkPage() && $talkmoved != 'notalkpage') { $s .= "\n\n" . wfMsgNoTrans('talkpagenotmoved', wfMsgNoTrans($talkmoved)); } } $wgOut->addWikiText($s); }
/** * @param array $errors An array of arrays returned by Title::getUserPermissionsErrors * @return string The wikitext error-messages, formatted into a list. */ public function formatPermissionsErrorMessage($errors, $action = null) { if ($action == null) { $text = wfMsgNoTrans('permissionserrorstext', count($errors)) . "\n\n"; } else { global $wgLang; $action_desc = wfMsg("action-{$action}"); $text = wfMsgNoTrans('permissionserrorstext-withaction', count($errors), $action_desc) . "\n\n"; } if (count($errors) > 1) { $text .= '<ul class="permissions-errors">' . "\n"; foreach ($errors as $error) { $text .= '<li>'; $text .= call_user_func_array('wfMsgNoTrans', $error); $text .= "</li>\n"; } $text .= '</ul>'; } else { $text .= '<div class="permissions-errors">' . call_user_func_array('wfMsgNoTrans', reset($errors)) . '</div>'; } return $text; }
/** * Returns a string with a HTML represenation of the given page. * $info must be an associative array, containing at least a Title object under the 'title' key. * @param $title Title * @param $cat Category * @param $children int * @param $loadchildren bool * @return string */ function renderNodeInfo($title, $cat, $children = 0, $loadchildren = false) { static $uniq = 0; $mode = $this->getOption('mode'); $load = false; if ($children > 0 && $loadchildren) { $uniq += 1; $load = 'ct-' . $uniq . '-' . mt_rand(1, 100000); } $ns = $title->getNamespace(); $key = $title->getDBkey(); # $trans = $title->getLocalizedText(); $trans = ''; # place holder for when translated titles are available $hideprefix = $this->getOption('hideprefix'); if ($hideprefix == CT_HIDEPREFIX_ALWAYS) { $hideprefix = true; } elseif ($hideprefix == CT_HIDEPREFIX_AUTO) { $hideprefix = $mode == CT_MODE_CATEGORIES; } elseif ($hideprefix == CT_HIDEPREFIX_CATEGORIES) { $hideprefix = $ns == NS_CATEGORY; } else { $hideprefix = true; } # when showing only categories, omit namespace in label unless we explicitely defined the configuration setting # patch contributed by Manuel Schneider <*****@*****.**>, Bug 8011 if ($hideprefix) { $label = htmlspecialchars($title->getText()); } else { $label = htmlspecialchars($title->getPrefixedText()); } if ($trans && $trans != $label) { $label .= ' ' . Xml::element('i', array('class' => 'translation'), $trans); } $labelClass = 'CategoryTreeLabel ' . ' CategoryTreeLabelNs' . $ns; if (!$title->getArticleId()) { $labelClass .= ' new'; $wikiLink = $title->getLocalURL('action=edit&redlink=1'); } else { $wikiLink = $title->getLocalURL(); } if ($ns == NS_CATEGORY) { $labelClass .= ' CategoryTreeLabelCategory'; } else { $labelClass .= ' CategoryTreeLabelPage'; } if ($ns % 2 > 0) { $labelClass .= ' CategoryTreeLabelTalk'; } $count = false; $s = ''; # NOTE: things in CategoryTree.js rely on the exact order of tags! # Specifically, the CategoryTreeChildren div must be the first # sibling with nodeName = DIV of the grandparent of the expland link. $s .= Xml::openElement('div', array('class' => 'CategoryTreeSection')); $s .= Xml::openElement('div', array('class' => 'CategoryTreeItem')); $attr = array('class' => 'CategoryTreeBullet'); # Get counts, with conversion to integer so === works # Note: $allCount is the total number of cat members, # not the count of how many members are normal pages. $allCount = $cat ? intval($cat->getPageCount()) : 0; $subcatCount = $cat ? intval($cat->getSubcatCount()) : 0; $fileCount = $cat ? intval($cat->getFileCount()) : 0; if ($ns == NS_CATEGORY) { if ($cat) { if ($mode == CT_MODE_CATEGORIES) { $count = $subcatCount; } elseif ($mode == CT_MODE_PAGES) { $count = $allCount - $fileCount; } else { $count = $allCount; } } if ($count === 0) { $bullet = wfMsgNoTrans('categorytree-empty-bullet') . ' '; $attr['class'] = 'CategoryTreeEmptyBullet'; } else { $linkattr = array(); if ($load) { $linkattr['id'] = $load; } $linkattr['class'] = "CategoryTreeToggle"; $linkattr['style'] = 'display: none;'; // Unhidden by JS $linkattr['data-ct-title'] = $key; if ($children == 0 || $loadchildren) { $tag = 'span'; $txt = wfMsgNoTrans('categorytree-expand-bullet'); # Don't load this message for ajax requests, so that we don't have to initialise $wgLang $linkattr['title'] = $this->mIsAjaxRequest ? '##LOAD##' : wfMsgNoTrans('categorytree-expand'); $linkattr['data-ct-state'] = 'collapsed'; } else { $tag = 'span'; $txt = wfMsgNoTrans('categorytree-collapse-bullet'); $linkattr['title'] = wfMsgNoTrans('categorytree-collapse'); $linkattr['data-ct-loaded'] = true; $linkattr['data-ct-state'] = 'expanded'; } if ($tag == 'a') { $linkattr['href'] = $wikiLink; } $bullet = Xml::openElement($tag, $linkattr) . $txt . Xml::closeElement($tag) . ' '; } } else { $bullet = wfMsgNoTrans('categorytree-page-bullet'); } $s .= Xml::tags('span', $attr, $bullet) . ' '; $s .= Xml::openElement('a', array('class' => $labelClass, 'href' => $wikiLink)) . $label . Xml::closeElement('a'); if ($count !== false && $this->getOption('showcount')) { $pages = $allCount - $subcatCount - $fileCount; global $wgContLang, $wgLang; $attr = array('title' => wfMsgExt('categorytree-member-counts', 'parsemag', $subcatCount, $pages, $fileCount, $allCount, $count), 'dir' => $wgLang->getDir()); $s .= $wgContLang->getDirMark() . ' '; # Create a list of category members with only non-zero member counts $memberNums = array(); if ($subcatCount) { $memberNums[] = wfMessage('categorytree-num-categories', $wgLang->formatNum($subcatCount))->text(); } if ($pages) { $memberNums[] = wfMessage('categorytree-num-pages', $wgLang->formatNum($pages))->text(); } if ($fileCount) { $memberNums[] = wfMessage('categorytree-num-files', $wgLang->formatNum($fileCount))->text(); } $memberNumsShort = $memberNums ? $wgLang->commaList($memberNums) : wfMessage('categorytree-num-empty')->text(); # Only $5 is actually used in the default message. # Other arguments can be used in a customized message. $s .= Xml::tags('span', $attr, wfMsgExt('categorytree-member-num', array('parsemag', 'escapenoentities'), $subcatCount, $pages, $fileCount, $allCount, $memberNumsShort)); } $s .= Xml::closeElement('div'); $s .= "\n\t\t"; $s .= Xml::openElement('div', array('class' => 'CategoryTreeChildren', 'style' => $children > 0 ? "display:block" : "display:none")); if ($ns == NS_CATEGORY && $children > 0 && !$loadchildren) { $children = $this->renderChildren($title, $children); if ($children == '') { $s .= Xml::openElement('i', array('class' => 'CategoryTreeNotice')); if ($mode == CT_MODE_CATEGORIES) { $s .= wfMsgExt('categorytree-no-subcategories', 'parsemag'); } elseif ($mode == CT_MODE_PAGES) { $s .= wfMsgExt('categorytree-no-pages', 'parsemag'); } elseif ($mode == CT_MODE_PARENTS) { $s .= wfMsgExt('categorytree-no-parent-categories', 'parsemag'); } else { $s .= wfMsgExt('categorytree-nothing-found', 'parsemag'); } $s .= Xml::closeElement('i'); } else { $s .= $children; } } $s .= Xml::closeElement('div'); $s .= Xml::closeElement('div'); if ($load) { $s .= "\n\t\t"; $s .= Xml::openElement('script', array('type' => 'text/javascript')); $s .= 'categoryTreeExpandNode("' . Xml::escapeJsString($key) . '", ' . $this->getOptionsAsJsStructure($children) . ', document.getElementById("' . $load . '"));'; $s .= Xml::closeElement('script'); } $s .= "\n\t\t"; return $s; }
/** * Show the special page * * @param $params Mixed: parameter(s) passed to the page or null */ public function execute( $params ) { global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts; // Can't use $this->setHeaders(); here because then it'll set the page // title to <removerelationship> and we don't want that, we'll be // messing with the page title later on in the code $wgOut->setArticleRelated( false ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' ); $usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) ); if ( !$usertitle ) { $wgOut->setPageTitle( wfMsgHtml( 'ur-error-title' ) ); $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) ); return false; } $this->user_name_to = $usertitle->getText(); $this->user_id_to = User::idFromName( $this->user_name_to ); $this->relationship_type = UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ); if ( $this->relationship_type == 1 ) { $confirmTitle = wfMsg( 'ur-remove-relationship-title-confirm-friend', $this->user_name_to ); $confirmMsg = wfMsg( 'ur-remove-relationship-message-confirm-friend', $this->user_name_to ); $error = wfMsg( 'ur-remove-error-not-loggedin-friend' ); $pending = wfMsg( 'ur-remove-error-message-pending-friend-request', $this->user_name_to ); } else { $confirmTitle = wfMsg( 'ur-remove-relationship-title-confirm-foe', $this->user_name_to ); $confirmMsg = wfMsg( 'ur-remove-relationship-message-confirm-foe', $this->user_name_to ); $error = wfMsg( 'ur-remove-error-not-loggedin-foe' ); $pending = wfMsg( 'ur-remove-error-message-pending-foe-request', $this->user_name_to ); } $out = ''; if ( $wgUser->getID() == $this->user_id_to ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); $out .= '<div class="relationship-error-message">' . wfMsg( 'ur-remove-error-message-remove-yourself' ) . '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { $out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />'; } $out .= '</div>'; $wgOut->addHTML( $out ); } elseif ( $this->relationship_type == false ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); $out .= '<div class="relationship-error-message">' . wfMsg( 'ur-remove-error-message-no-relationship', $this->user_name_to ) . '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { $out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />'; } $out .= '</div>'; $wgOut->addHTML( $out ); } elseif ( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); $out .= '<div class="relationship-error-message">' . $pending . '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { $out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />'; } $out .= '</div>'; $wgOut->addHTML( $out ); } elseif ( $wgUser->getID() == 0 ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); $out .= '<div class="relationship-error-message">' . $error . '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { $out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />'; } $out .= '</div>'; $wgOut->addHTML( $out ); } else { $rel = new UserRelationship( $wgUser->getName() ); if ( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) { $_SESSION['alreadysubmitted'] = true; $rel->removeRelationshipByUserID( $this->user_id_to, $wgUser->getID() ); $rel->sendRelationshipRemoveEmail( $this->user_id_to, $wgUser->getName(), $this->relationship_type ); $avatar = new wAvatar( $this->user_id_to, 'l' ); $wgOut->setPageTitle( $confirmTitle ); $out .= "<div class=\"relationship-action\"> {$avatar->getAvatarURL()}" . $confirmMsg . "<div class=\"relationship-buttons\"> <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/> <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-your-profile' ) . "\" size=\"20\" onclick=\"window.location='" . $wgUser->getUserPage()->escapeFullURL() . "'\"/> </div> <div class=\"cleared\"></div> </div>"; $wgOut->addHTML( $out ); } else { $_SESSION['alreadysubmitted'] = false; $wgOut->addHTML( $this->displayForm() ); } } }
$u->setPassword($conf->getSysopPass()); $u->saveSettings(); $u->addGroup("sysop"); $u->addGroup("bureaucrat"); print "<li>Created sysop account <tt>" . htmlspecialchars($conf->SysopName) . "</tt>.</li>\n"; } else { print "<li>Could not create user - already exists!</li>\n"; } } } else { print "<li>Skipped sysop account creation, no name given.</li>\n"; } $titleobj = Title::newFromText(wfMsgNoDB("mainpage")); $article = new Article($titleobj); $newid = $article->insertOn($wgDatabase); $revision = new Revision(array('page' => $newid, 'text' => wfMsg('mainpagetext') . "\n\n" . wfMsgNoTrans('mainpagedocfooter'), 'comment' => '', 'user' => 0, 'user_text' => 'MediaWiki default')); $revid = $revision->insertOn($wgDatabase); $article->updateRevisionOn($wgDatabase, $revision); } /* Write out the config file now that all is well */ print "<li style=\"list-style: none\">\n"; print "<p>Creating LocalSettings.php...</p>\n\n"; $localSettings = "<" . "?php{$endl}{$local}"; // Fix up a common line-ending problem (due to CVS on Windows) $localSettings = str_replace("\r\n", "\n", $localSettings); $f = fopen("LocalSettings.php", 'xt'); if ($f == false) { print "</li>\n"; dieout("<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" . "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" . "<pre>\n" . htmlspecialchars($localSettings) . "</pre>\n"); } if (fwrite($f, $localSettings)) {
/** * Show formatted char difference * @param $old Integer: bytes * @param $new Integer: bytes * @return String */ public static function showCharacterDifference($old, $new) { global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode; $szdiff = $new - $old; $code = $wgLang->getCode(); static $fastCharDiff = array(); if (!isset($fastCharDiff[$code])) { $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans('rc-change-size') === '$1'; } $formattedSize = $wgLang->formatNum($szdiff); if (!$fastCharDiff[$code]) { $formattedSize = wfMsgExt('rc-change-size', array('parsemag'), $formattedSize); } if (abs($szdiff) > abs($wgRCChangedSizeThreshold)) { $tag = 'strong'; } else { $tag = 'span'; } if ($szdiff === 0) { $formattedSizeClass = 'mw-plusminus-null'; } if ($szdiff > 0) { $formattedSize = '+' . $formattedSize; $formattedSizeClass = 'mw-plusminus-pos'; } if ($szdiff < 0) { $formattedSizeClass = 'mw-plusminus-neg'; } $formattedTotalSize = wfMsgExt('rc-change-size-new', 'parsemag', $wgLang->formatNum($new)); return Html::element($tag, array('dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize), wfMessage('parentheses', $formattedSize)->plain()) . $wgLang->getDirMark(); }
protected function showHeader() { global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang; if ($this->mTitle->isTalkPage()) { $wgOut->addWikiMsg('talkpagetext'); } # Optional notices on a per-namespace and per-page basis $editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace(); $editnotice_ns_message = wfMessage($editnotice_ns)->inContentLanguage(); if ($editnotice_ns_message->exists()) { $wgOut->addWikiText($editnotice_ns_message->plain()); } if (MWNamespace::hasSubpages($this->mTitle->getNamespace())) { $parts = explode('/', $this->mTitle->getDBkey()); $editnotice_base = $editnotice_ns; while (count($parts) > 0) { $editnotice_base .= '-' . array_shift($parts); $editnotice_base_msg = wfMessage($editnotice_base)->inContentLanguage(); if ($editnotice_base_msg->exists()) { $wgOut->addWikiText($editnotice_base_msg->plain()); } } } else { # Even if there are no subpages in namespace, we still don't want / in MW ns. $editnoticeText = $editnotice_ns . '-' . str_replace('/', '-', $this->mTitle->getDBkey()); $editnoticeMsg = wfMessage($editnoticeText)->inContentLanguage(); if ($editnoticeMsg->exists()) { $wgOut->addWikiText($editnoticeMsg->plain()); } } if ($this->isConflict) { $wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1\n</div>", 'explainconflict'); $this->edittime = $this->mArticle->getTimestamp(); } else { if ($this->section != '' && !$this->isSectionEditSupported()) { // We use $this->section to much before this and getVal('wgSection') directly in other places // at this point we can't reset $this->section to '' to fallback to non-section editing. // Someone is welcome to try refactoring though $wgOut->showErrorPage('sectioneditnotsupported-title', 'sectioneditnotsupported-text'); return false; } if ($this->section != '' && $this->section != 'new') { if (!$this->summary && !$this->preview && !$this->diff) { $sectionTitle = self::extractSectionTitle($this->textbox1); if ($sectionTitle !== false) { $this->summary = "/* {$sectionTitle} */ "; } } } if ($this->missingComment) { $wgOut->wrapWikiMsg("<div id='mw-missingcommenttext'>\n\$1\n</div>", 'missingcommenttext'); } if ($this->missingSummary && $this->section != 'new') { $wgOut->wrapWikiMsg("<div id='mw-missingsummary'>\n\$1\n</div>", 'missingsummary'); } if ($this->missingSummary && $this->section == 'new') { $wgOut->wrapWikiMsg("<div id='mw-missingcommentheader'>\n\$1\n</div>", 'missingcommentheader'); } if ($this->hookError !== '') { $wgOut->addWikiText($this->hookError); } if (!$this->checkUnicodeCompliantBrowser()) { $wgOut->addWikiMsg('nonunicodebrowser'); } if ($this->section != 'new') { $revision = $this->mArticle->getRevisionFetched(); if ($revision) { // Let sysop know that this will make private content public if saved if (!$revision->userCan(Revision::DELETED_TEXT)) { $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-permission'); } elseif ($revision->isDeleted(Revision::DELETED_TEXT)) { $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-view'); } if (!$revision->isCurrent()) { $this->mArticle->setOldSubtitle($revision->getId()); $wgOut->addWikiMsg('editingold'); } } elseif ($this->mTitle->exists()) { // Something went wrong $wgOut->wrapWikiMsg("<div class='errorbox'>\n\$1\n</div>\n", array('missing-article', $this->mTitle->getPrefixedText(), wfMsgNoTrans('missingarticle-rev', $this->oldid))); } } } if (wfReadOnly()) { $wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason())); } elseif ($wgUser->isAnon()) { if ($this->formtype != 'preview') { $wgOut->wrapWikiMsg("<div id=\"mw-anon-edit-warning\">\n\$1</div>", 'anoneditwarning'); } else { $wgOut->wrapWikiMsg("<div id=\"mw-anon-preview-warning\">\n\$1</div>", 'anonpreviewwarning'); } } else { if ($this->isCssJsSubpage) { # Check the skin exists if ($this->isWrongCaseCssJsPage) { $wgOut->wrapWikiMsg("<div class='error' id='mw-userinvalidcssjstitle'>\n\$1\n</div>", array('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage())); } if ($this->getTitle()->isSubpageOf($wgUser->getUserPage())) { if ($this->formtype !== 'preview') { if ($this->isCssSubpage) { $wgOut->wrapWikiMsg("<div id='mw-usercssyoucanpreview'>\n\$1\n</div>", array('usercssyoucanpreview')); } if ($this->isJsSubpage) { $wgOut->wrapWikiMsg("<div id='mw-userjsyoucanpreview'>\n\$1\n</div>", array('userjsyoucanpreview')); } } } } } if ($this->mTitle->getNamespace() != NS_MEDIAWIKI && $this->mTitle->isProtected('edit')) { # Is the title semi-protected? if ($this->mTitle->isSemiProtected()) { $noticeMsg = 'semiprotectedpagewarning'; } else { # Then it must be protected based on static groups (regular) $noticeMsg = 'protectedpagewarning'; } LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle, '', array('lim' => 1, 'msgKey' => array($noticeMsg))); } if ($this->mTitle->isCascadeProtected()) { # Is this page under cascading protection from some source pages? list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources(); $notice = "<div class='mw-cascadeprotectedwarning'>\n\$1\n"; $cascadeSourcesCount = count($cascadeSources); if ($cascadeSourcesCount > 0) { # Explain, and list the titles responsible foreach ($cascadeSources as $page) { $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; } } $notice .= '</div>'; $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount)); } if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create')) { LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle, '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('titleprotectedwarning'), 'wrap' => "<div class=\"mw-titleprotectedwarning\">\n\$1</div>")); } if ($this->kblength === false) { $this->kblength = (int) (strlen($this->textbox1) / 1024); } if ($this->tooBig || $this->kblength > $wgMaxArticleSize) { $wgOut->wrapWikiMsg("<div class='error' id='mw-edit-longpageerror'>\n\$1\n</div>", array('longpageerror', $wgLang->formatNum($this->kblength), $wgLang->formatNum($wgMaxArticleSize))); } else { if (!wfMessage('longpage-hint')->isDisabled()) { $wgOut->wrapWikiMsg("<div id='mw-edit-longpage-hint'>\n\$1\n</div>", array('longpage-hint', $wgLang->formatSize(strlen($this->textbox1)), strlen($this->textbox1))); } } }