/** * @param $message String: wiki message name * @param ... parameters to pass to wfMsg() */ function WikiErrorMsg($message) { $args = func_get_args(); array_shift($args); $this->mMessage = wfMsgReal($message, $args, true); $this->mMsgKey = $message; $this->mMsgArgs = $args; }
function msg($key, $fallback) { $args = array_slice(func_get_args(), 2); if ($this->useMessageCache()) { return wfMsgReal($key, $args); } else { return wfMsgReplaceArgs($fallback, $args); } }
static function intFunction($parser, $part1 = '') { if (strval($part1) !== '') { $args = array_slice(func_get_args(), 2); return wfMsgReal($part1, $args, true); } else { return array('found' => false); } }
/** * Notifies a single user of the changes made to properties in a single edit. * * @since 0.1 * * @param SWLGroup $group * @param User $user * @param SWLChangeSet $changeSet * @param boolean $describeChanges * * @return Status */ public static function notifyUser(SWLGroup $group, User $user, SWLChangeSet $changeSet, $describeChanges) { global $wgLang, $wgPasswordSender, $wgPasswordSenderName; $emailText = wfMsgExt('swl-email-propschanged-long', 'parse', $GLOBALS['wgSitename'], $changeSet->getEdit()->getUser()->getName(), SpecialPage::getTitleFor('SemanticWatchlist')->getFullURL(), $wgLang->time($changeSet->getEdit()->getTime()), $wgLang->date($changeSet->getEdit()->getTime())); if ($describeChanges) { $emailText .= '<h3> ' . wfMsgExt('swl-email-changes', 'parse', $changeSet->getEdit()->getTitle()->getFullText(), $changeSet->getEdit()->getTitle()->getFullURL()) . ' </h3>'; $emailText .= self::getChangeListHTML($changeSet, $group); } $title = wfMsgReal('swl-email-propschanged', array($changeSet->getEdit()->getTitle()->getFullText()), true, $user->getOption('language')); wfRunHooks('SWLBeforeEmailNotify', array($group, $user, $changeSet, $describeChanges, &$title, &$emailText)); return UserMailer::send(new MailAddress($user), new MailAddress($wgPasswordSender, $wgPasswordSenderName), $title, $emailText, null, 'text/html; charset=ISO-8859-1'); }
/** * 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 parseResponse( $text ) { if ( strval( $text ) == '' ) { // lastError should have been set by post/postFile, but just in case, we'll // set a fallback message here. if ( strval( $this->lastError ) == '' ) { $this->setError( 'webstore_no_response' ); } return false; } wfSuppressWarnings(); try { $response = new SimpleXMLElement( $text ); } catch ( Exception $e ) { $response = false; } wfRestoreWarnings(); if ( !$response ) { $this->setError( 'webstore_invalid_response', $text ) . "\n"; return false; } if ( $response->errors ) { $errors = array(); foreach ( $response->errors->children() as $error ) { $message = strval( $error->message ); $params = array(); if ( isset( $error->params ) ) { foreach ( $error->params->children as $param ) { $params[] = strval( $param ); } } $errors[] = wfMsgReal( $message, $params ); } if ( count( $errors ) == 1 ) { $this->lastError = wfMsg( 'webstore_backend_error', $errors[0] ) . "\n"; } else { $errorsText = ''; foreach ( $errors as $error ) { $errorsText .= '* ' . str_replace( "\n", ' ', $error ); } $this->lastError = wfMsg( 'webstore_backend_error', $errorsText ) . "\n"; } } return $response; }
/** * UI entry point for blocking * Wraps around doBlock() */ function doSubmit() { global $wgOut; $retval = $this->doBlock(); if (empty($retval)) { $titleObj = SpecialPage::getTitleFor('Blockip'); $wgOut->redirect($titleObj->getFullURL('action=success&ip=' . urlencode($this->BlockAddress))); return; } $key = array_shift($retval); $this->showForm(wfMsgReal($key, $retval)); }
/** * @static */ function actionText($type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks = false, $translate = false) { global $wgLang, $wgContLang, $wgLogActions; $key = "{$type}/{$action}"; if (isset($wgLogActions[$key])) { if (is_null($title)) { $rv = wfMsg($wgLogActions[$key]); } else { if ($skin) { switch ($type) { case 'move': $titleLink = $skin->makeLinkObj($title, $title->getPrefixedText(), 'redirect=no'); $params[0] = $skin->makeLinkObj(Title::newFromText($params[0]), $params[0]); break; case 'block': if (substr($title->getText(), 0, 1) == '#') { $titleLink = $title->getText(); } else { $titleLink = $skin->makeLinkObj($title, $title->getText()); $titleLink .= ' (' . $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Contributions/' . $title->getDBkey()), wfMsg('contribslink')) . ')'; } break; case 'rights': $text = $wgContLang->ucfirst($title->getText()); $titleLink = $skin->makeLinkObj(Title::makeTitle(NS_USER, $text)); break; default: $titleLink = $skin->makeLinkObj($title); } } else { $titleLink = $title->getPrefixedText(); } if ($key == 'rights/rights') { if ($skin) { $rightsnone = wfMsg('rightsnone'); } else { $rightsnone = wfMsgForContent('rightsnone'); } if (!isset($params[0]) || trim($params[0]) == '') { $params[0] = $rightsnone; } if (!isset($params[1]) || trim($params[1]) == '') { $params[1] = $rightsnone; } } if (count($params) == 0) { if ($skin) { $rv = wfMsg($wgLogActions[$key], $titleLink); } else { $rv = wfMsgForContent($wgLogActions[$key], $titleLink); } } else { array_unshift($params, $titleLink); if ($translate && $key == 'block/block') { $params[1] = $wgLang->translateBlockExpiry($params[1]); } $rv = wfMsgReal($wgLogActions[$key], $params, true, !$skin); } } } else { wfDebug("LogPage::actionText - unknown action {$key}\n"); $rv = "{$action}"; } if ($filterWikilinks) { $rv = str_replace("[[", "", $rv); $rv = str_replace("]]", "", $rv); } return $rv; }
public function setMsg($msg, $params) { $this->_labels['MSG'] = wfMsgReal($msg, $params, true); }
/** * Show a short informational message. * Output looks like a list. * * @param $msg string */ public function showMessage($msg) { $args = func_get_args(); array_shift($args); $html = '<div class="config-message">' . $this->parse(wfMsgReal($msg, $args, false, false, false)) . "</div>\n"; $this->output->addHTML($html); }
function sp_getMessageText( $id ) { foreach ( $this->errors as $error ) { if ( $error['securepoll-id'] !== $id ) { continue; } return wfMsgReal( $error['message'], $error['params'] ); } }
function __construct($msg, $width, $height) { $args = array_slice(func_get_args(), 3); $htmlArgs = array_map('htmlspecialchars', $args); $htmlArgs = array_map('nl2br', $htmlArgs); $this->htmlMsg = wfMsgReplaceArgs(htmlspecialchars(wfMsgGetKey($msg, true)), $htmlArgs); $this->textMsg = wfMsgReal($msg, $args); $this->width = intval($width); $this->height = intval($height); $this->url = false; $this->path = false; }
/** * Get a CategoryTree message, "categorytree-" prefix added automatically */ static function msg($msg) { wfLoadExtensionMessages('CategoryTree'); if ($msg === false) { return null; } $args = func_get_args(); $msg = array_shift($args); if ($msg == '') { return wfMsgReal($msg, $args); } else { return wfMsgReal("categorytree-{$msg}", $args); } }
/** * @static */ function actionText($type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks = false) { static $actions = array('block/block' => 'blocklogentry', 'block/unblock' => 'unblocklogentry', 'protect/protect' => 'protectedarticle', 'protect/unprotect' => 'unprotectedarticle', 'rights/rights' => 'bureaucratlogentry', 'rights/addgroup' => 'addgrouplogentry', 'rights/rngroup' => 'renamegrouplogentry', 'rights/chgroup' => 'changegrouplogentry', 'delete/delete' => 'deletedarticle', 'delete/restore' => 'undeletedarticle', 'upload/upload' => 'uploadedimage', 'upload/revert' => 'uploadedimage', 'move/move' => '1movedto2', 'move/move_redir' => '1movedto2_redir'); $key = "{$type}/{$action}"; if (isset($actions[$key])) { if (is_null($title)) { $rv = wfMsgForContent($actions[$key]); } else { if ($skin) { if ($type == 'move') { $titleLink = $skin->makeLinkObj($title, $title->getPrefixedText(), 'redirect=no'); // Change $param[0] into a link to the title specified in $param[0] $movedTo = Title::newFromText($params[0]); $params[0] = $skin->makeLinkObj($movedTo, $params[0]); } else { $titleLink = $skin->makeLinkObj($title); } } else { $titleLink = $title->getPrefixedText(); } if (count($params) == 0) { $rv = wfMsgForContent($actions[$key], $titleLink); } else { array_unshift($params, $titleLink); $rv = wfMsgReal($actions[$key], $params, true, true); } } } else { wfDebug("LogPage::actionText - unknown action {$key}\n"); $rv = "{$action}"; } if ($filterWikilinks) { $rv = str_replace("[[", "", $rv); $rv = str_replace("]]", "", $rv); } return $rv; }
/** * Constructor. * * In addition to a message key, the constructor may include optional * arguments of any number, as in: * new WCException( 'message-1', ... ); * @param messageKey string The message key * @param optionalArgs string = any number of arguments * @return string Value of object. */ public function __construct( $messageKey ) { $args = func_get_args(); array_shift( $args ); $transformedMessage = wfMsgReal( $messageKey, $args, true ); parent::__construct( $transformedMessage ); }
/** * Sends a Reflect email in response to a new bullet or response. * * @param $threadObj A reference to the relevant LQT Thread * @param $to A User object to whom the email will be sent * @param $catalystUser A User object who triggered this series of events * @param $msgType The name of the message type to be used in accessing localized msg * @param $bodyParams Additional parameters to be used in the sprintf of the body text * @param $subjectParams Additional parameters to be used in the sprintf of the subject text * */ private function sendMail($threadObj, $to, $catalystUser, $msgType, $bodyParams, $subjectParams) { global $wgPasswordSender, $wgLanguageCode; // TODO: create Reflect mailing preferences for individuals & respect them if (!$to) { return; } $from = new MailAddress($wgPasswordSender, 'WikiAdmin'); $permaLink = LqtView::linkInContextURL($threadObj); $params = array($to->getName(), $catalystUser->getName(), $threadObj->subjectWithoutIncrement(), $permaLink); $bodyParams = array_merge($params, $bodyParams); $subjectParams = array_merge($params, $subjectParams); $msg = wfMsgReal($msgType, $bodyParams, true, $wgLanguageCode, true); $subject = wfMsgReal($msgType . '-subject', $subjectParams, true, $wgLanguageCode, true); UserMailer::send(new MailAddress($to), $from, $subject, $msg); }
function MediaPlaceholderMatch($text, $box = 0, $isVideo = false) { global $wgContLang; // Get the namesapace translations in the content language for files and videos $ns = NS_FILE; $ns_vid = $wgContLang->getFormattedNsText($ns); $ns_img = ImagePlaceholderTranslateNsImage(); // Get the same as above but for english $en_ns_vid = MWNamespace::getCanonicalName($ns); $oldWgContLang = $wgContLang; $wgContLang = Language::factory('en'); $en_ns_img = ImagePlaceholderTranslateNsImage(); $wgContLang = $oldWgContLang; // Get the placeholder text in both the content language and in english $placeholder_msg = wfMsgForContent('imgplc-placeholder'); $en_placeholder_msg = wfMsgReal('imgplc-placeholder', array(), true, 'en'); $placeholder = '(?:' . implode('|', array($ns_vid . ':' . $placeholder_msg, $ns_vid . ':' . $en_placeholder_msg, $ns_img . ':' . $placeholder_msg, $ns_img . ':' . $en_placeholder_msg, $en_ns_vid . ':' . $en_placeholder_msg, $en_ns_vid . ':' . $placeholder_msg, $en_ns_img . ':' . $en_placeholder_msg, $en_ns_img . ':' . $placeholder_msg)) . ')'; preg_match_all('/\\[\\[' . $placeholder . '[^\\]]*\\]\\]/si', $text, $matches, PREG_OFFSET_CAPTURE); // Make sure we have matches and that there exists a match at index $box if (is_array($matches)) { $matchArr = $matches[0]; for ($x = 0; $x < count($matchArr); $x++) { $match = $matchArr[$x]; if ($isVideo) { if (!preg_match('/\\|video/', $match[0])) { array_splice($matchArr, $x, 1); } } else { if (preg_match('/video/', $match[0])) { array_splice($matchArr, $x, 1); } } } if (count($matchArr) > $box) { return $matchArr[$box]; } } return null; }
function doSubmit() { global $wgOut; $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range); if (!empty($retval)) { $key = array_shift($retval); $this->showForm(wfMsgReal($key, $retval)); return; } # Report to the user $titleObj = SpecialPage::getTitleFor("Ipblocklist"); $success = $titleObj->getFullURL("action=success&successip=" . urlencode($this->ip)); $wgOut->redirect($success); }
/** * Return the text of a template, after recursively * replacing any variables or templates within the template. * * @param array $piece The parts of the template * $piece['text']: matched text * $piece['title']: the title, i.e. the part before the | * $piece['parts']: the parameter array * @return string the text of the template * @private */ function braceSubstitution($piece) { global $wgContLang, $wgLang, $wgAllowDisplayTitle, $action; $fname = 'Parser::braceSubstitution'; wfProfileIn($fname); # Flags $found = false; # $text has been filled $nowiki = false; # wiki markup in $text should be escaped $noparse = false; # Unsafe HTML tags should not be stripped, etc. $noargs = false; # Don't replace triple-brace arguments in $text $replaceHeadings = false; # Make the edit section links go to the template not the article $isHTML = false; # $text is HTML, armour it against wikitext transformation $forceRawInterwiki = false; # Force interwiki transclusion to be done in raw mode not rendered # Title object, where $text came from $title = NULL; $linestart = ''; # $part1 is the bit before the first |, and must contain only title characters # $args is a list of arguments, starting from index 0, not including $part1 $part1 = $piece['title']; # If the third subpattern matched anything, it will start with | if (null == $piece['parts']) { $replaceWith = $this->variableSubstitution(array($piece['text'], $piece['title'])); if ($replaceWith != $piece['text']) { $text = $replaceWith; $found = true; $noparse = true; $noargs = true; } } $args = null == $piece['parts'] ? array() : $piece['parts']; $argc = count($args); # SUBST if (!$found) { $mwSubst =& MagicWord::get(MAG_SUBST); if ($mwSubst->matchStartAndRemove($part1) xor $this->mOutputType == OT_WIKI) { # One of two possibilities is true: # 1) Found SUBST but not in the PST phase # 2) Didn't find SUBST and in the PST phase # In either case, return without further processing $text = $piece['text']; $found = true; $noparse = true; $noargs = true; } } # MSG, MSGNW, INT and RAW if (!$found) { # Check for MSGNW: $mwMsgnw =& MagicWord::get(MAG_MSGNW); if ($mwMsgnw->matchStartAndRemove($part1)) { $nowiki = true; } else { # Remove obsolete MSG: $mwMsg =& MagicWord::get(MAG_MSG); $mwMsg->matchStartAndRemove($part1); } # Check for RAW: $mwRaw =& MagicWord::get(MAG_RAW); if ($mwRaw->matchStartAndRemove($part1)) { $forceRawInterwiki = true; } # Check if it is an internal message $mwInt =& MagicWord::get(MAG_INT); if ($mwInt->matchStartAndRemove($part1)) { if ($this->incrementIncludeCount('int:' . $part1)) { $text = $linestart . wfMsgReal($part1, $args, true); $found = true; } } } # Parser functions if (!$found) { wfProfileIn(__METHOD__ . '-pfunc'); $colonPos = strpos($part1, ':'); if ($colonPos !== false) { # Case sensitive functions $function = substr($part1, 0, $colonPos); if (isset($this->mFunctionSynonyms[1][$function])) { $function = $this->mFunctionSynonyms[1][$function]; } else { # Case insensitive functions $function = strtolower($function); if (isset($this->mFunctionSynonyms[0][$function])) { $function = $this->mFunctionSynonyms[0][$function]; } else { $function = false; } } if ($function) { $funcArgs = array_map('trim', $args); $funcArgs = array_merge(array(&$this, trim(substr($part1, $colonPos + 1))), $funcArgs); $result = call_user_func_array($this->mFunctionHooks[$function], $funcArgs); $found = true; // The text is usually already parsed, doesn't need triple-brace tags expanded, etc. //$noargs = true; //$noparse = true; if (is_array($result)) { if (isset($result[0])) { $text = $linestart . $result[0]; unset($result[0]); } // Extract flags into the local scope // This allows callers to set flags such as nowiki, noparse, found, etc. extract($result); } else { $text = $linestart . $result; } } } wfProfileOut(__METHOD__ . '-pfunc'); } # Template table test # Did we encounter this template already? If yes, it is in the cache # and we need to check for loops. if (!$found && isset($this->mTemplates[$piece['title']])) { $found = true; # Infinite loop test if (isset($this->mTemplatePath[$part1])) { $noparse = true; $noargs = true; $found = true; $text = $linestart . '{{' . $part1 . '}}' . '<!-- WARNING: template loop detected -->'; wfDebug("{$fname}: template loop broken at '{$part1}'\n"); } else { # set $text to cached message. $text = $linestart . $this->mTemplates[$piece['title']]; } } # Load from database $lastPathLevel = $this->mTemplatePath; if (!$found) { wfProfileIn(__METHOD__ . '-loadtpl'); $ns = NS_TEMPLATE; # declaring $subpage directly in the function call # does not work correctly with references and breaks # {{/subpage}}-style inclusions $subpage = ''; $part1 = $this->maybeDoSubpageLink($part1, $subpage); if ($subpage !== '') { $ns = $this->mTitle->getNamespace(); } $title = Title::newFromText($part1, $ns); if (!is_null($title)) { $checkVariantLink = sizeof($wgContLang->getVariants()) > 1; # Check for language variants if the template is not found if ($checkVariantLink && $title->getArticleID() == 0) { $wgContLang->findVariantLink($part1, $title); } if (!$title->isExternal()) { # Check for excessive inclusion $dbk = $title->getPrefixedDBkey(); if ($this->incrementIncludeCount($dbk)) { if ($title->getNamespace() == NS_SPECIAL && $this->mOptions->getAllowSpecialInclusion() && $this->mOutputType != OT_WIKI) { $text = SpecialPage::capturePath($title); if (is_string($text)) { $found = true; $noparse = true; $noargs = true; $isHTML = true; $this->disableCache(); } } else { $articleContent = $this->fetchTemplate($title); if ($articleContent !== false) { $found = true; $text = $articleContent; $replaceHeadings = true; } } } # If the title is valid but undisplayable, make a link to it if ($this->mOutputType == OT_HTML && !$found) { $text = '[[' . $title->getPrefixedText() . ']]'; $found = true; } } elseif ($title->isTrans()) { // Interwiki transclusion if ($this->mOutputType == OT_HTML && !$forceRawInterwiki) { $text = $this->interwikiTransclude($title, 'render'); $isHTML = true; $noparse = true; } else { $text = $this->interwikiTransclude($title, 'raw'); $replaceHeadings = true; } $found = true; } # Template cache array insertion # Use the original $piece['title'] not the mangled $part1, so that # modifiers such as RAW: produce separate cache entries if ($found) { if ($isHTML) { // A special page; don't store it in the template cache. } else { $this->mTemplates[$piece['title']] = $text; } $text = $linestart . $text; } } wfProfileOut(__METHOD__ . '-loadtpl'); } # Recursive parsing, escaping and link table handling # Only for HTML output if ($nowiki && $found && $this->mOutputType == OT_HTML) { $text = wfEscapeWikiText($text); } elseif (($this->mOutputType == OT_HTML || $this->mOutputType == OT_WIKI) && $found) { if ($noargs) { $assocArgs = array(); } else { # Clean up argument array $assocArgs = array(); $index = 1; foreach ($args as $arg) { $eqpos = strpos($arg, '='); if ($eqpos === false) { $assocArgs[$index++] = $arg; } else { $name = trim(substr($arg, 0, $eqpos)); $value = trim(substr($arg, $eqpos + 1)); if ($value === false) { $value = ''; } if ($name !== false) { $assocArgs[$name] = $value; } } } # Add a new element to the templace recursion path $this->mTemplatePath[$part1] = 1; } if (!$noparse) { # If there are any <onlyinclude> tags, only include them if (in_string('<onlyinclude>', $text) && in_string('</onlyinclude>', $text)) { preg_match_all('/<onlyinclude>(.*?)\\n?<\\/onlyinclude>/s', $text, $m); $text = ''; foreach ($m[1] as $piece) { $text .= $piece; } } # Remove <noinclude> sections and <includeonly> tags $text = preg_replace('/<noinclude>.*?<\\/noinclude>/s', '', $text); $text = strtr($text, array('<includeonly>' => '', '</includeonly>' => '')); if ($this->mOutputType == OT_HTML) { # Strip <nowiki>, <pre>, etc. $text = $this->strip($text, $this->mStripState); $text = Sanitizer::removeHTMLtags($text, array(&$this, 'replaceVariables'), $assocArgs); } $text = $this->replaceVariables($text, $assocArgs); # If the template begins with a table or block-level # element, it should be treated as beginning a new line. if (!$piece['lineStart'] && preg_match('/^({\\||:|;|#|\\*)/', $text)) { $text = "\n" . $text; } } elseif (!$noargs) { # $noparse and !$noargs # Just replace the arguments, not any double-brace items # This is used for rendered interwiki transclusion $text = $this->replaceVariables($text, $assocArgs, true); } } # Prune lower levels off the recursion check path $this->mTemplatePath = $lastPathLevel; if (!$found) { wfProfileOut($fname); return $piece['text']; } else { wfProfileIn(__METHOD__ . '-placeholders'); if ($isHTML) { # Replace raw HTML by a placeholder # Add a blank line preceding, to prevent it from mucking up # immediately preceding headings $text = "\n\n" . $this->insertStripItem($text, $this->mStripState); } else { # replace ==section headers== # XXX this needs to go away once we have a better parser. if ($this->mOutputType != OT_WIKI && $replaceHeadings) { if (!is_null($title)) { $encodedname = base64_encode($title->getPrefixedDBkey()); } else { $encodedname = base64_encode(""); } $m = preg_split('/(^={1,6}.*?={1,6}\\s*?$)/m', $text, -1, PREG_SPLIT_DELIM_CAPTURE); $text = ''; $nsec = 0; for ($i = 0; $i < count($m); $i += 2) { $text .= $m[$i]; if (!isset($m[$i + 1]) || $m[$i + 1] == "") { continue; } $hl = $m[$i + 1]; if (strstr($hl, "<!--MWTEMPLATESECTION")) { $text .= $hl; continue; } preg_match('/^(={1,6})(.*?)(={1,6})\\s*?$/m', $hl, $m2); $text .= $m2[1] . $m2[2] . "<!--MWTEMPLATESECTION=" . $encodedname . "&" . base64_encode("{$nsec}") . "-->" . $m2[3]; $nsec++; } } } wfProfileOut(__METHOD__ . '-placeholders'); } # Prune lower levels off the recursion check path $this->mTemplatePath = $lastPathLevel; if (!$found) { wfProfileOut($fname); return $piece['text']; } else { wfProfileOut($fname); return $text; } }
/** * Get a message from the language file, for the content */ function wfMsgNoDBForContent($key) { global $wgForceUIMsgAsContentMsg; $args = func_get_args(); array_shift($args); $forcontent = true; if (is_array($wgForceUIMsgAsContentMsg) && in_array($key, $wgForceUIMsgAsContentMsg)) { $forcontent = false; } return wfMsgReal($key, $args, false, $forcontent); }
/** * 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; }
/** * @static * @return HTML string */ static function actionText($type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks = false) { global $wgLang, $wgContLang, $wgLogActions, $wgMessageCache; $wgMessageCache->loadAllMessages(); $key = "{$type}/{$action}"; # Defer patrol log to PatrolLog class if ($key == 'patrol/patrol') { return PatrolLog::makeActionText($title, $params, $skin); } if (isset($wgLogActions[$key])) { if (is_null($title)) { $rv = wfMsg($wgLogActions[$key]); } else { $titleLink = self::getTitleLink($type, $skin, $title, $params); if ($key == 'rights/rights') { if ($skin) { $rightsnone = wfMsg('rightsnone'); foreach ($params as &$param) { $groupArray = array_map('trim', explode(',', $param)); $groupArray = array_map(array('User', 'getGroupName'), $groupArray); $param = $wgLang->listToText($groupArray); } } else { $rightsnone = wfMsgForContent('rightsnone'); } if (!isset($params[0]) || trim($params[0]) == '') { $params[0] = $rightsnone; } if (!isset($params[1]) || trim($params[1]) == '') { $params[1] = $rightsnone; } } if (count($params) == 0) { if ($skin) { $rv = wfMsg($wgLogActions[$key], $titleLink); } else { $rv = wfMsgForContent($wgLogActions[$key], $titleLink); } } else { $details = ''; array_unshift($params, $titleLink); if ($key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock') { if ($skin) { $params[1] = '<span title="' . htmlspecialchars($params[1]) . '">' . $wgLang->translateBlockExpiry($params[1]) . '</span>'; } else { $params[1] = $wgContLang->translateBlockExpiry($params[1]); } $params[2] = isset($params[2]) ? self::formatBlockFlags($params[2], is_null($skin)) : ''; } else { if ($type == 'protect' && count($params) == 3) { $details .= " {$params[1]}"; // restrictions and expiries if ($params[2]) { $details .= ' [' . wfMsg('protect-summary-cascade') . ']'; } } else { if ($type == 'move' && count($params) == 3) { if ($params[2]) { $details .= ' [' . wfMsg('move-redirect-suppressed') . ']'; } } } } $rv = wfMsgReal($wgLogActions[$key], $params, true, !$skin) . $details; } } } else { global $wgLogActionsHandlers; if (isset($wgLogActionsHandlers[$key])) { $args = func_get_args(); $rv = call_user_func_array($wgLogActionsHandlers[$key], $args); } else { wfDebug("LogPage::actionText - unknown action {$key}\n"); $rv = "{$action}"; } } if ($filterWikilinks) { $rv = str_replace("[[", "", $rv); $rv = str_replace("]]", "", $rv); } return $rv; }
/** * wfMsg wrapper * @see wfMsg */ public function msg($key) { $args = func_get_args(); array_shift($args); return wfMsgReal($key, $args, true); }
/** * Suppresses a local account of a user. * * @param $suppress Bool * @param $wiki String * @param $by String * @param $reason String * @return Array|null Error array on failure */ public function doLocalSuppression($suppress, $wiki, $by, $reason) { global $wgConf; $lb = wfGetLB($wiki); $dbw = $lb->getConnection(DB_MASTER, array(), $wiki); $data = $this->localUserData($wiki); if ($suppress) { list($site, $lang) = $wgConf->siteFromDB($wiki); $langNames = Language::getLanguageNames(); $lang = isset($langNames[$lang]) ? $lang : 'en'; $blockReason = wfMsgReal('centralauth-admin-suppressreason', array($by, $reason), true, $lang); $block = new Block($this->mName, $data['id'], 0, $blockReason, wfTimestampNow(), false, $dbw->getInfinity(), false, true, true, true, true, false, $by); # On normal block, BlockIp hook would be run here, but doing # that from CentralAuth doesn't seem a good idea... if (!$block->insert($dbw)) { return array('ipb_already_blocked'); } # Ditto for BlockIpComplete hook. RevisionDeleteUser::suppressUserName($this->mName, $data['id'], $dbw); # Locally log to suppress ? } else { $dbw->delete('ipblocks', array('ipb_user' => $data['id'], 'ipb_by' => 0, 'ipb_deleted' => true), __METHOD__); // Unsuppress only if unblocked if ($dbw->affectedRows()) { RevisionDeleteUser::unsuppressUserName($this->mName, $data['id'], $dbw); } } return null; }
/** * Message function that takes into account the language parameter. * * @since 1.0.1 * * @param string $key * @param ... $args * * @return string */ protected function msg() { $args = func_get_args(); $key = array_shift($args); return wfMsgReal($key, $args, true, $this->language); }
/** * @param $type * @param $action * @param $title * @param $skin Skin * @param $params * @param $filterWikilinks bool * @return String */ function efHandleWikiSetLogEntry($type, $action, $title, $skin, $params, $filterWikilinks = false) { $link = Linker::makeLinkObj($title, htmlspecialchars($params[0])); switch ($action) { case 'newset': $args = array(WikiSet::formatType($params[1]), $params[2]); break; case 'setrename': $args = array($params[1]); break; case 'setnewtype': $args = array(WikiSet::formatType($params[1]), WikiSet::formatType($params[2])); break; case 'setchange': $args = array($params[1] ? $params[1] : wfMsg('rightsnone'), $params[2] ? $params[2] : wfMsg('rightsnone')); break; default: //'deleteset' $args = array(); } return wfMsgReal("centralauth-rightslog-entry-{$action}", array_merge(array($link), $args), true, !$skin); }
public function showForm($err) { global $wgOut, $wgUser, $wgSysopUserBans; $wgOut->setPageTitle(wfMsg('blockip-title')); $wgOut->addWikiMsg('blockiptext'); if ($wgSysopUserBans) { $mIpaddress = Xml::label(wfMsg('ipadressorusername'), 'mw-bi-target'); } else { $mIpaddress = Xml::label(wfMsg('ipaddress'), 'mw-bi-target'); } $mIpbexpiry = Xml::label(wfMsg('ipbexpiry'), 'wpBlockExpiry'); $mIpbother = Xml::label(wfMsg('ipbother'), 'mw-bi-other'); $mIpbreasonother = Xml::label(wfMsg('ipbreason'), 'wpBlockReasonList'); $mIpbreason = Xml::label(wfMsg('ipbotherreason'), 'mw-bi-reason'); $titleObj = SpecialPage::getTitleFor('Blockip'); $user = User::newFromName($this->BlockAddress); $alreadyBlocked = false; $otherBlockedMsgs = array(); if ($err && $err[0] != 'ipb_already_blocked') { $key = array_shift($err); $msg = wfMsgReal($key, $err); $wgOut->setSubtitle(wfMsgHtml('formerror')); $wgOut->addHTML(Xml::tags('p', array('class' => 'error'), $msg)); } elseif ($this->BlockAddress) { # Get other blocks, i.e. from GlobalBlocking or TorBlock extension wfRunHooks('OtherBlockLogLink', array(&$otherBlockedMsgs, $this->BlockAddress)); $userId = is_object($user) ? $user->getId() : 0; $currentBlock = Block::newFromDB($this->BlockAddress, $userId); if (!is_null($currentBlock) && !$currentBlock->mAuto && ($currentBlock->mRangeStart == $currentBlock->mRangeEnd || $currentBlock->mAddress == $this->BlockAddress)) { $alreadyBlocked = true; # Set the block form settings to the existing block if (!$this->wasPosted) { $this->BlockAnonOnly = $currentBlock->mAnonOnly; $this->BlockCreateAccount = $currentBlock->mCreateAccount; $this->BlockEnableAutoblock = $currentBlock->mEnableAutoblock; $this->BlockEmail = $currentBlock->mBlockEmail; $this->BlockHideName = $currentBlock->mHideName; $this->BlockAllowUsertalk = $currentBlock->mAllowUsertalk; if ($currentBlock->mExpiry == 'infinity') { $this->BlockOther = 'indefinite'; } else { $this->BlockOther = wfTimestamp(TS_ISO_8601, $currentBlock->mExpiry); } $this->BlockReason = $currentBlock->mReason; } } } # Show other blocks from extensions, i.e. GlockBlocking and TorBlock if (count($otherBlockedMsgs)) { $wgOut->addHTML(Html::rawElement('h2', array(), wfMsgExt('ipb-otherblocks-header', 'parseinline', count($otherBlockedMsgs))) . "\n"); $list = ''; foreach ($otherBlockedMsgs as $link) { $list .= Html::rawElement('li', array(), $link) . "\n"; } $wgOut->addHTML(Html::rawElement('ul', array('class' => 'mw-blockip-alreadyblocked'), $list) . "\n"); } # Username/IP is blocked already locally if ($alreadyBlocked) { $wgOut->addWikiMsg('ipb-needreblock', $this->BlockAddress); } $scBlockExpiryOptions = wfMsgForContent('ipboptions'); $showblockoptions = $scBlockExpiryOptions != '-'; if (!$showblockoptions) { $mIpbother = $mIpbexpiry; } $blockExpiryFormOptions = Xml::option(wfMsg('ipbotheroption'), 'other'); foreach (explode(',', $scBlockExpiryOptions) as $option) { if (strpos($option, ':') === false) { $option = "{$option}:{$option}"; } list($show, $value) = explode(':', $option); $show = htmlspecialchars($show); $value = htmlspecialchars($value); $blockExpiryFormOptions .= Xml::option($show, $value, $this->BlockExpiry === $value ? true : false) . "\n"; } $reasonDropDown = Xml::listDropDown('wpBlockReasonList', wfMsgForContent('ipbreason-dropdown'), wfMsgForContent('ipbreasonotherlist'), $this->BlockReasonList, 'wpBlockDropDown', 4); global $wgStylePath, $wgStyleVersion; $wgOut->addHTML(Xml::tags('script', array('type' => 'text/javascript', 'src' => "{$wgStylePath}/common/block.js?{$wgStyleVersion}"), '') . Xml::openElement('form', array('method' => 'post', 'action' => $titleObj->getLocalURL('action=submit'), 'id' => 'blockip')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('blockip-legend')) . Xml::openElement('table', array('border' => '0', 'id' => 'mw-blockip-table')) . "<tr>\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpaddress}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Html::input('wpBlockAddress', $this->BlockAddress, 'text', array('tabindex' => '1', 'id' => 'mw-bi-target', 'onchange' => 'updateBlockOptions()', 'size' => '45', 'required' => '') + ($this->BlockAddress ? array() : array('autofocus'))) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>"); if ($showblockoptions) { $wgOut->addHTML("\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbexpiry}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Xml::tags('select', array('id' => 'wpBlockExpiry', 'name' => 'wpBlockExpiry', 'onchange' => 'considerChangingExpiryFocus()', 'tabindex' => '2'), $blockExpiryFormOptions) . "</td>"); } $wgOut->addHTML("\n\t\t\t</tr>\n\t\t\t<tr id='wpBlockOther'>\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbother}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('wpBlockOther', 45, $this->BlockOther, array('tabindex' => '3', 'id' => 'mw-bi-other')) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbreasonother}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>\n\t\t\t\t\t{$reasonDropDown}\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id=\"wpBlockReason\">\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbreason}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Html::input('wpBlockReason', $this->BlockReason, 'text', array('tabindex' => '5', 'id' => 'mw-bi-reason', 'maxlength' => '200', 'size' => '45') + ($this->BlockAddress ? array('autofocus') : array())) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id='wpAnonOnlyRow'>\n\t\t\t\t<td> </td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbanononly'), 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly, array('tabindex' => '6')) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id='wpCreateAccountRow'>\n\t\t\t\t<td> </td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbcreateaccount'), 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount, array('tabindex' => '7')) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id='wpEnableAutoblockRow'>\n\t\t\t\t<td> </td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbenableautoblock'), 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock, array('tabindex' => '8')) . "\n\t\t\t\t</td>\n\t\t\t</tr>"); if (self::canBlockEmail($wgUser)) { $wgOut->addHTML("\n\t\t\t\t<tr id='wpEnableEmailBan'>\n\t\t\t\t\t<td> </td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbemailban'), 'wpEmailBan', 'wpEmailBan', $this->BlockEmail, array('tabindex' => '9')) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>"); } // Allow some users to hide name from block log, blocklist and listusers if ($wgUser->isAllowed('hideuser')) { $wgOut->addHTML("\n\t\t\t\t<tr id='wpEnableHideUser'>\n\t\t\t\t\t<td> </td>\n\t\t\t\t\t<td class='mw-input'><strong>" . Xml::checkLabel(wfMsg('ipbhidename'), 'wpHideName', 'wpHideName', $this->BlockHideName, array('tabindex' => '10')) . "\n\t\t\t\t\t</strong></td>\n\t\t\t\t</tr>"); } # Watchlist their user page? (Only if user is logged in) if ($wgUser->isLoggedIn()) { $wgOut->addHTML("\n\t\t\t<tr id='wpEnableWatchUser'>\n\t\t\t\t<td> </td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbwatchuser'), 'wpWatchUser', 'wpWatchUser', $this->BlockWatchUser, array('tabindex' => '11')) . "\n\t\t\t\t</td>\n\t\t\t</tr>"); } # Can we explicitly disallow the use of user_talk? global $wgBlockAllowsUTEdit; if ($wgBlockAllowsUTEdit) { $wgOut->addHTML("\n\t\t\t\t<tr id='wpAllowUsertalkRow'>\n\t\t\t\t\t<td> </td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipballowusertalk'), 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk, array('tabindex' => '12')) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>"); } $wgOut->addHTML("\n\t\t\t<tr>\n\t\t\t\t<td style='padding-top: 1em'> </td>\n\t\t\t\t<td class='mw-submit' style='padding-top: 1em'>" . Xml::submitButton(wfMsg($alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit'), array('name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's')) . "\n\t\t\t\t</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::hidden('wpEditToken', $wgUser->editToken()) . ($alreadyBlocked ? Xml::hidden('wpChangeBlock', 1) : "") . Xml::closeElement('fieldset') . Xml::closeElement('form') . Xml::tags('script', array('type' => 'text/javascript'), 'updateBlockOptions()') . "\n"); $wgOut->addHTML($this->getConvenienceLinks()); if (is_object($user)) { $this->showLogFragment($wgOut, $user->getUserPage()); } elseif (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $this->BlockAddress)) { $this->showLogFragment($wgOut, Title::makeTitle(NS_USER, $this->BlockAddress)); } elseif (preg_match('/^\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}/', $this->BlockAddress)) { $this->showLogFragment($wgOut, Title::makeTitle(NS_USER, $this->BlockAddress)); } }
/** * @param $message String: wiki message name * @param ... parameters to pass to wfMsg() * * @deprecated since 1.17 */ function __construct($message) { wfDeprecated(__METHOD__); $args = func_get_args(); array_shift($args); $this->mMessage = wfMsgReal($message, $args, true); $this->mMsgKey = $message; $this->mMsgArgs = $args; }
/** * Same as above except doesn't transform the message * * @deprecated since 1.18 * * @param string $key * @return string */ function wfMsgForContentNoTrans($key) { wfDeprecated(__METHOD__, '1.21'); global $wgForceUIMsgAsContentMsg; $args = func_get_args(); array_shift($args); $forcontent = true; if (is_array($wgForceUIMsgAsContentMsg) && in_array($key, $wgForceUIMsgAsContentMsg)) { $forcontent = false; } return wfMsgReal($key, $args, true, $forcontent, false); }
static function notifyUsersByMail($t, $watching_users, $timestamp, $type) { $messages = array(Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-newthread'); $subjects = array(Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread'); if (!isset($messages[$type]) || !isset($subjects[$type])) { wfDebugLog('LiquidThreads', "Email notification failed: type {$type} unrecognised"); return; } else { $msgName = $messages[$type]; $subjectMsg = $subjects[$type]; } // Send email notification, fetching all the data in one go $dbr = wfGetDB(DB_SLAVE); $tables = array('user', 'tc_prop' => 'user_properties', 'l_prop' => 'user_properties'); $fields = array($dbr->tableName('user') . '.*', 'tc_prop.up_value AS timecorrection', 'l_prop.up_value as language'); $join_conds = array('tc_prop' => array('LEFT JOIN', array('tc_prop.up_user=user_id', 'tc_prop.up_property' => 'timecorrection')), 'l_prop' => array('LEFT JOIN', array('l_prop.up_user=user_id', 'l_prop.up_property' => 'language'))); $res = $dbr->select($tables, $fields, array('user_id' => $watching_users), __METHOD__, array(), $join_conds); // Set up one-time data. global $wgPasswordSender; $link_title = clone $t->getTitle(); $link_title->setFragment('#' . $t->getAnchorName()); $permalink = LqtView::linkInContextCanonicalURL($t); $talkPage = $t->getTitle()->getPrefixedText(); $from = new MailAddress($wgPasswordSender, 'WikiAdmin'); $threadSubject = $t->subject(); // Parse content and strip HTML of post content foreach ($res as $row) { $u = User::newFromRow($row); if ($row->language) { $langCode = $row->language; } else { global $wgLanguageCode; $langCode = $wgLanguageCode; } $lang = Language::factory($langCode); // Adjust with time correction $timeCorrection = $row->timecorrection; $adjustedTimestamp = $lang->userAdjust($timestamp, $timeCorrection); $date = $lang->date($adjustedTimestamp); $time = $lang->time($adjustedTimestamp); $params = array($u->getName(), $t->subjectWithoutIncrement(), $date, $time, $talkPage, $permalink, $t->root()->getContent(), $t->author()->getName()); // Get message in user's own language, bug 20645 $msg = wfMsgReal($msgName, $params, true, $langCode, true); $to = new MailAddress($u); $subject = wfMsgReal($subjectMsg, array($threadSubject), true, $langCode, true); UserMailer::send($to, $from, $subject, $msg); } }