本文整理汇总了PHP中wfMsgReplaceArgs函数的典型用法代码示例。如果您正苦于以下问题:PHP wfMsgReplaceArgs函数的具体用法?PHP wfMsgReplaceArgs怎么用?PHP wfMsgReplaceArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfMsgReplaceArgs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleAutoEdit
/**
* Handles autoedit Ajax call from #autoedit parser function and from save
* and continue button.
*
* @param String $optionsString the options/data string
* @param String $prefillFromExisting String set to 'true' to retain existing form values (unset by save and continue)
* @return String
*/
static function handleAutoEdit( $optionsString = null, $prefillFromExisting = 'true' ) {
global $wgParser;
$handler = new self( null, 'sfautoedit' );
$handler->isApiQuery( false );
$options = $handler->setOptionsString( $optionsString );
// get oktext (or use default)
if ( array_key_exists( 'ok text', $options ) ) {
$oktext = $options['ok text'];
} else {
$oktext = wfMsg( 'sf_autoedit_success' );
}
// get errortext (or use default)
if ( array_key_exists( 'error text', $options ) ) {
$errortext = $options['error text'];
} else {
$errortext = '$1';
}
// process data
// result will be true or an error message
$result = $handler->storeSemanticData( $prefillFromExisting === 'true' );
// wrap result in ok/error message
if ( $result === true ) {
$options = $handler->getOptions();
$result = wfMsgReplaceArgs( $oktext, array( $options['target'], $options['form'] ) );
} else {
$result->setResponseCode( '400 Bad Request' );
$result = wfMsgReplaceArgs( $errortext, array( $result ) );
}
// initialize parser
$title = Title::newFromText( 'DummyTitle' );
if ( !StubObject::isRealObject( $wgParser ) ) {
$wgParser->_unstub();
}
$parseroptions = $wgParser->getOptions();
if ( $parseroptions == null ) {
$parseroptions = new ParserOptions();
$wgParser->Options( $parseroptions );
}
$parseroptions->enableLimitReport( false );
$result = new AjaxResponse( $wgParser->parse( $result, $title, $parseroptions )->getText() );
$result->setContentType( 'text/html' );
return $result;
}
示例2: getMessage
function getMessage($messageCode)
{
$messageParameters = func_get_args();
array_shift($messageParameters);
$message = \wfMsgGetKey($messageCode, true, $this->languageCode);
$message = \wfMsgReplaceArgs($message, $messageParameters);
return $message;
}
示例3: msg
/**
* 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);
}
}
示例4: intFunction
static function intFunction($parser, $part1 = '')
{
if (strval($part1) !== '') {
$args = array_slice(func_get_args(), 2);
$message = wfMsgGetKey($part1, true, false, false);
$message = wfMsgReplaceArgs($message, $args);
$message = $parser->replaceVariables($message);
// like $wgMessageCache->transform()
return $message;
} else {
return array('found' => false);
}
}
示例5: plural
public static function plural($data, $params, $parser)
{
list($from, $to) = self::getRange(@$params['n']);
$args = explode('|', $data);
$lang = self::languageObject($params);
$format = isset($params['format']) ? $params['format'] : '%s';
$format = str_replace('\\n', "\n", $format);
$s = '';
for ($i = $from; $i <= $to; $i++) {
$t = $lang->convertPlural($i, $args);
$fmtn = $lang->formatNum($i);
$s .= str_replace(array('%d', '%s'), array($i, wfMsgReplaceArgs($t, array($fmtn))), $format);
}
return $s;
}
示例6: run
/**
* Run the job
* @return boolean success
*/
function run()
{
global $wgUser, $wgCommandLineMode;
$oldUser = $wgUser;
$wgUser = User::newFromId($this->params['user']);
unset($this->params['user']);
$this->params['form'] = $this->title->getText();
$handler = new SFAutoeditAPI(null, 'sfautoedit');
$handler->isApiQuery(false);
$handler->setOptions($this->params);
$result = $handler->storeSemanticData(false);
// wrap result in ok/error message
if ($result === true) {
$options = $handler->getOptions();
$result = wfMsg('sf_autoedit_success', $options['target'], $options['form']);
} else {
$result = wfMsgReplaceArgs('$1', array($result));
}
$this->params = array('result' => $result, 'user' => $wgUser->getName());
wfDebugLog('sps', 'Page Creation Job: ' . $result);
$wgUser = $oldUser;
}
示例7: parseMsg
/**
* Return the error message related to a certain array
* @param array $error Element of a getUserPermissionsErrors()-style array
* @return array('code' => code, 'info' => info)
*/
public function parseMsg($error)
{
$error = (array) $error;
// It seems strings sometimes make their way in here
$key = array_shift($error);
// Check whether the error array was nested
// array( array( <code>, <params> ), array( <another_code>, <params> ) )
if (is_array($key)) {
$error = $key;
$key = array_shift($error);
}
if ($key instanceof IApiMessage) {
return array('code' => $key->getApiCode(), 'info' => $key->inLanguage('en')->useDatabase(false)->text(), 'data' => $key->getApiData());
}
if (isset(self::$messageMap[$key])) {
return array('code' => wfMsgReplaceArgs(self::$messageMap[$key]['code'], $error), 'info' => wfMsgReplaceArgs(self::$messageMap[$key]['info'], $error));
}
// If the key isn't present, throw an "unknown error"
return $this->parseMsg(array('unknownerror', $key));
}
示例8: msgExt
/**
* Returns message in the requested format after parsing wikitext to html
* This is meant to be equivalent to wfMsgExt() with parse, parsemag and
* escape as available options but using the DPL local parser instead of
* the global one (bugfix).
*/
function msgExt($key, $options)
{
$args = func_get_args();
array_shift($args);
array_shift($args);
if (!is_array($options)) {
$options = array($options);
}
$string = wfMsgNoTrans($key);
$string = wfMsgReplaceArgs($string, $args);
if (in_array('parse', $options)) {
$this->mParserOptions->setInterfaceMessage(true);
$string = $this->mParser->recursiveTagParse($string);
$this->mParserOptions->setInterfaceMessage(false);
// $string = $parserOutput->getText();
} elseif (in_array('parsemag', $options)) {
$parser = new Parser();
$parserOptions = new ParserOptions();
$parserOptions->setInterfaceMessage(true);
$parser->startExternalParse($this->mParserTitle, $parserOptions, OT_MSG);
$string = $parser->transformMsg($string, $parserOptions);
}
if (in_array('escape', $options)) {
$string = htmlspecialchars($string);
}
return $string;
}
示例9: msg
/**
* @param string $key
* @param string $fallback Unescaped alternative error text in case the
* message cache cannot be used. Can contain parameters as in regular
* messages, that should be passed as additional parameters.
* @return string Unprocessed plain error text with parameters replaced
*/
function msg($key, $fallback)
{
$args = array_slice(func_get_args(), 2);
if ($this->useMessageCache()) {
return wfMessage($key, $args)->useDatabase(false)->text();
} else {
return wfMsgReplaceArgs($fallback, $args);
}
}
示例10: wfMsgExt
/**
* Returns message in the requested format
* @param string $key Key of the message
* @param array $options Processing rules:
* <i>parse<i>: parses wikitext to html
* <i>parseinline<i>: parses wikitext to html and removes the surrounding p's added by parser or tidy
* <i>escape<i>: filters message trough htmlspecialchars
* <i>replaceafter<i>: parameters are substituted after parsing or escaping
*/
function wfMsgExt($key, $options)
{
global $wgOut, $wgMsgParserOptions, $wgParser;
$args = func_get_args();
array_shift($args);
array_shift($args);
if (!is_array($options)) {
$options = array($options);
}
$string = wfMsgGetKey($key, true, false, false);
if (!in_array('replaceafter', $options)) {
$string = wfMsgReplaceArgs($string, $args);
}
if (in_array('parse', $options)) {
$string = $wgOut->parse($string, true, true);
} elseif (in_array('parseinline', $options)) {
$string = $wgOut->parse($string, true, true);
$m = array();
if (preg_match("~^<p>(.*)\n?</p>\$~", $string, $m)) {
$string = $m[1];
}
} elseif (in_array('parsemag', $options)) {
global $wgTitle;
$parser = new Parser();
$parserOptions = new ParserOptions();
$parserOptions->setInterfaceMessage(true);
$parser->startExternalParse($wgTitle, $parserOptions, OT_MSG);
$string = $parser->transformMsg($string, $parserOptions);
}
if (in_array('escape', $options)) {
$string = htmlspecialchars($string);
}
if (in_array('replaceafter', $options)) {
$string = wfMsgReplaceArgs($string, $args);
}
return $string;
}
示例11: msgExt
/**
* Returns message in the requested format after parsing wikitext to html
* This is meant to be equivalent to wfMsgExt() with parse, parsemag and escape as available options but using the DPL local parser instead of the global one (bugfix).
*/
function msgExt($key, $options)
{
$args = func_get_args();
array_shift($args);
array_shift($args);
if (!is_array($options)) {
$options = array($options);
}
$string = wfMsgNoTrans($key);
$string = wfMsgReplaceArgs($string, $args);
$this->mParserOptions->setInterfaceMessage(true);
$string = $this->mParser->recursiveTagParse($string);
$this->mParserOptions->setInterfaceMessage(false);
if (in_array('escape', $options)) {
$string = htmlspecialchars($string);
}
return $string;
}
示例12: execute
public function execute()
{
$params = $this->extractRequestParams();
global $wgLang;
$oldLang = null;
if (!is_null($params['lang'])) {
$oldLang = $wgLang;
// Keep $wgLang for restore later
$wgLang = Language::factory($params['lang']);
}
$prop = array_flip((array) $params['prop']);
// Determine which messages should we print
if (in_array('*', $params['messages'])) {
$message_names = array_keys(Language::getMessagesFor('en'));
sort($message_names);
$messages_target = $message_names;
} else {
$messages_target = $params['messages'];
}
// Filter messages
if (isset($params['filter'])) {
$messages_filtered = array();
foreach ($messages_target as $message) {
// !== is used because filter can be at the beginning of the string
if (strpos($message, $params['filter']) !== false) {
$messages_filtered[] = $message;
}
}
$messages_target = $messages_filtered;
}
// Get all requested messages and print the result
$skip = !is_null($params['from']);
$useto = !is_null($params['to']);
$result = $this->getResult();
foreach ($messages_target as $message) {
// Skip all messages up to $params['from']
if ($skip && $message === $params['from']) {
$skip = false;
}
if ($useto && $message > $params['to']) {
break;
}
if (!$skip) {
$a = array('name' => $message);
$args = null;
if (isset($params['args']) && count($params['args']) != 0) {
$args = $params['args'];
}
// Check if the parser is enabled:
if ($params['enableparser']) {
$msg = wfMsgExt($message, array('parsemag'), $args);
} elseif ($args) {
$msgString = wfMsgGetKey($message, true, false, false);
$msg = wfMsgReplaceArgs($msgString, $args);
} else {
$msg = wfMsgGetKey($message, true, false, false);
}
if (wfEmptyMsg($message, $msg)) {
$a['missing'] = '';
} else {
ApiResult::setContent($a, $msg);
if (isset($prop['default'])) {
$default = wfMsgGetKey($message, false, false, false);
if ($default !== $msg) {
if (wfEmptyMsg($message, $default)) {
$a['defaultmissing'] = '';
} else {
$a['default'] = $default;
}
}
}
}
$fit = $result->addValue(array('query', $this->getModuleName()), null, $a);
if (!$fit) {
$this->setContinueEnumParameter('from', $message);
break;
}
}
}
$result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'message');
if (!is_null($oldLang)) {
$wgLang = $oldLang;
// Restore $oldLang
}
}
示例13: reallyMakeHelpMsg
/**
* @return mixed|string
*/
public function reallyMakeHelpMsg()
{
$this->setHelp();
// Use parent to make default message for the main module
$msg = parent::makeHelpMsg();
$astriks = str_repeat('*** ', 14);
$msg .= "\n\n{$astriks} Modules {$astriks}\n\n";
foreach (array_keys($this->mModules) as $moduleName) {
$module = new $this->mModules[$moduleName]($this, $moduleName);
$msg .= self::makeHelpMsgHeader($module, 'action');
$msg2 = $module->makeHelpMsg();
if ($msg2 !== false) {
$msg .= $msg2;
}
$msg .= "\n";
}
$msg .= "\n{$astriks} Permissions {$astriks}\n\n";
foreach (self::$mRights as $right => $rightMsg) {
$groups = User::getGroupsWithPermission($right);
$msg .= "* " . $right . " *\n " . wfMsgReplaceArgs($rightMsg['msg'], $rightMsg['params']) . "\nGranted to:\n " . str_replace('*', 'all', implode(', ', $groups)) . "\n\n";
}
$msg .= "\n{$astriks} Formats {$astriks}\n\n";
foreach (array_keys($this->mFormats) as $formatName) {
$module = $this->createPrinterByName($formatName);
$msg .= self::makeHelpMsgHeader($module, 'format');
$msg2 = $module->makeHelpMsg();
if ($msg2 !== false) {
$msg .= $msg2;
}
$msg .= "\n";
}
$msg .= "\n*** Credits: ***\n " . implode("\n ", $this->getCredits()) . "\n";
return $msg;
}
示例14: parserFunction_ev
/**
* Embeds video of the chosen service
* @param Parser $parser Instance of running Parser.
* @param String $service Which online service has the video.
* @param String $id Identifier of the chosen service
* @param String $width Width of video (optional)
* @param String $desc description to show (optional)
* @param String $align alignment of the video (optional)
* @return String Encoded representation of input params (to be processed later)
*/
public static function parserFunction_ev($parser, $service = null, $id = null, $width = null, $align = null, $desc = null)
{
global $wgScriptPath;
// Initialize things once
if (!self::$initialized) {
self::VerifyWidthMinAndMax();
self::$initialized = true;
}
// Get the name of the host
if ($service === null || $id === null) {
return self::errMissingParams($service, $id);
}
$service = trim($service);
$id = trim($id);
$desc = $parser->recursiveTagParse($desc);
$entry = self::getServiceEntry($service);
if (!$entry) {
return self::errBadService($service);
}
if (!self::sanitizeWidth($entry, $width)) {
return self::errBadWidth($width);
}
$height = self::getHeight($entry, $width);
$hasalign = $align !== null || $align == 'auto';
if ($hasalign) {
$align = trim($align);
if (!self::validateAlignment($align)) {
return self::errBadAlignment($align);
}
$desc = self::getDescriptionMarkup($desc);
}
// If the service has an ID pattern specified, verify the id number
if (!self::verifyID($entry, $id)) {
return self::errBadID($service, $id);
}
$url = null;
// If service is Yandex -> use own parser
if ($service == 'yandex' || $service == 'yandexvideo') {
$url = self::getYandex($id);
$url = htmlspecialchars_decode($url);
}
// if the service has it's own custom extern declaration, use that instead
if (array_key_exists('extern', $entry) && ($clause = $entry['extern']) != NULL) {
if ($service == 'screen9') {
$clause = self::parseScreen9Id($id, $width, $height);
if ($clause == null) {
return self::errBadScreen9Id();
}
} else {
$clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, $width, $height, $url));
}
if ($hasalign) {
$clause = self::generateAlignExternClause($clause, $align, $desc, $width, $height);
}
return array($clause, 'noparse' => true, 'isHTML' => true);
}
// Build URL and output embedded flash object
$url = wfMsgReplaceArgs($entry['url'], array($id, $width, $height));
$clause = "";
// If service is RuTube -> use own parser
if ($service == 'rutube') {
$url = self::getRuTube($id);
}
if ($hasalign) {
$clause = self::generateAlignClause($url, $width, $height, $align, $desc);
} else {
$clause = self::generateNormalClause($url, $width, $height);
}
return array($clause, 'noparse' => true, 'isHTML' => true);
}
示例15: parseMsg
/**
* Return the error message related to a certain array
* @param $error array Element of a getUserPermissionsErrors()-style array
* @return array('code' => code, 'info' => info)
*/
public function parseMsg($error)
{
$key = array_shift($error);
if (isset(self::$messageMap[$key])) {
return array('code' => wfMsgReplaceArgs(self::$messageMap[$key]['code'], $error), 'info' => wfMsgReplaceArgs(self::$messageMap[$key]['info'], $error));
}
// If the key isn't present, throw an "unknown error"
return $this->parseMsg(array('unknownerror', $key));
}