本文整理匯總了PHP中DerivativeContext::msg方法的典型用法代碼示例。如果您正苦於以下問題:PHP DerivativeContext::msg方法的具體用法?PHP DerivativeContext::msg怎麽用?PHP DerivativeContext::msg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DerivativeContext
的用法示例。
在下文中一共展示了DerivativeContext::msg方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: closePrinter
/**
* Finish printing and output buffered data.
*/
public function closePrinter()
{
if ($this->mDisabled) {
return;
}
$mime = $this->getMimeType();
if ($this->getIsHtml() && $mime !== null) {
$format = $this->getFormat();
$lcformat = strtolower($format);
$result = $this->getBuffer();
$context = new DerivativeContext($this->getMain());
$context->setSkin(SkinFactory::getDefaultInstance()->makeSkin('apioutput'));
$context->setTitle(SpecialPage::getTitleFor('ApiHelp'));
$out = new OutputPage($context);
$context->setOutput($out);
$out->addModuleStyles('mediawiki.apipretty');
$out->setPageTitle($context->msg('api-format-title'));
if (!$this->getIsWrappedHtml()) {
// When the format without suffix 'fm' is defined, there is a non-html version
if ($this->getMain()->getModuleManager()->isDefined($lcformat, 'format')) {
$msg = $context->msg('api-format-prettyprint-header')->params($format, $lcformat);
} else {
$msg = $context->msg('api-format-prettyprint-header-only-html')->params($format);
}
$header = $msg->parseAsBlock();
$out->addHTML(Html::rawElement('div', ['class' => 'api-pretty-header'], ApiHelp::fixHelpLinks($header)));
}
if (Hooks::run('ApiFormatHighlight', [$context, $result, $mime, $format])) {
$out->addHTML(Html::element('pre', ['class' => 'api-pretty-content'], $result));
}
if ($this->getIsWrappedHtml()) {
// This is a special output mode mainly intended for ApiSandbox use
$time = microtime(true) - $this->getConfig()->get('RequestTime');
$json = FormatJson::encode(['html' => $out->getHTML(), 'modules' => array_values(array_unique(array_merge($out->getModules(), $out->getModuleScripts(), $out->getModuleStyles()))), 'time' => round($time * 1000)], false, FormatJson::ALL_OK);
// Bug 66776: wfMangleFlashPolicy() is needed to avoid a nasty bug in
// Flash, but what it does isn't friendly for the API, so we need to
// work around it.
if (preg_match('/\\<\\s*cross-domain-policy\\s*\\>/i', $json)) {
$json = preg_replace('/\\<(\\s*cross-domain-policy\\s*)\\>/i', '\\u003C$1\\u003E', $json);
}
echo $json;
} else {
// API handles its own clickjacking protection.
// Note, that $wgBreakFrames will still override $wgApiFrameOptions for format mode.
$out->allowClickjacking();
$out->output();
}
} else {
// For non-HTML output, clear all errors that might have been
// displayed if display_errors=On
ob_clean();
echo $this->getBuffer();
}
}
示例2: closePrinter
/**
* Finish printing and output buffered data.
*/
public function closePrinter()
{
if ($this->mDisabled) {
return;
}
$mime = $this->getMimeType();
if ($this->getIsHtml() && $mime !== null) {
$format = $this->getFormat();
$lcformat = strtolower($format);
$result = $this->getBuffer();
$context = new DerivativeContext($this->getMain());
$context->setSkin(SkinFactory::getDefaultInstance()->makeSkin('apioutput'));
$context->setTitle(SpecialPage::getTitleFor('ApiHelp'));
$out = new OutputPage($context);
$context->setOutput($out);
$out->addModuleStyles('mediawiki.apipretty');
$out->setPageTitle($context->msg('api-format-title'));
// When the format without suffix 'fm' is defined, there is a non-html version
if ($this->getMain()->getModuleManager()->isDefined($lcformat, 'format')) {
$msg = $context->msg('api-format-prettyprint-header')->params($format, $lcformat);
} else {
$msg = $context->msg('api-format-prettyprint-header-only-html')->params($format);
}
$header = $msg->parseAsBlock();
$out->addHTML(Html::rawElement('div', array('class' => 'api-pretty-header'), ApiHelp::fixHelpLinks($header)));
if (Hooks::run('ApiFormatHighlight', array($context, $result, $mime, $format))) {
$out->addHTML(Html::element('pre', array('class' => 'api-pretty-content'), $result));
}
// API handles its own clickjacking protection.
// Note, that $wgBreakFrames will still override $wgApiFrameOptions for format mode.
$out->allowClickJacking();
$out->output();
} else {
// For non-HTML output, clear all errors that might have been
// displayed if display_errors=On
ob_clean();
echo $this->getBuffer();
}
}
示例3: diffWikitext
protected function diffWikitext($title, $wikitext)
{
$apiParams = array('action' => 'query', 'prop' => 'revisions', 'titles' => $title->getPrefixedDBkey(), 'rvdifftotext' => $this->pstWikitext($title, $wikitext));
$api = new ApiMain(new DerivativeRequest($this->getRequest(), $apiParams, false), false);
$api->execute();
if (defined('ApiResult::META_CONTENT')) {
$result = $api->getResult()->getResultData(null, array('BC' => array(), 'Types' => array()));
} else {
$result = $api->getResultData();
}
if (!isset($result['query']['pages'][$title->getArticleID()]['revisions'][0]['diff']['*'])) {
return array('result' => 'fail');
}
$diffRows = $result['query']['pages'][$title->getArticleID()]['revisions'][0]['diff']['*'];
if ($diffRows !== '') {
$context = new DerivativeContext($this->getContext());
$context->setTitle($title);
$engine = new DifferenceEngine($context);
return array('result' => 'success', 'diff' => $engine->addHeader($diffRows, $context->msg('currentrev')->parse(), $context->msg('yourtext')->parse()));
} else {
return array('result' => 'nochanges');
}
}
示例4: getWarningMessageText
/**
* Returns warning messages in situations where a revision cannot be viewed by a user
* explaining to them why.
* Returns empty string when the revision can be viewed.
*
* @return string
*/
public function getWarningMessageText()
{
$msg = '';
if ($this->isHiddenFromUser()) {
$allowed = $this->isUserAllowedToSee();
$suppressed = $this->isSuppressedDiff();
// This IContextSource object will be used to get a message object for the
// messages used in this function. We need to to this to allow the message to
// get the correct value for the FULLPAGENAME inclusion (which is used in
// rev-suppressed-no-diff, e.g.). Otherwise it would use Special:MobileDiff as
// the target for Special:Log/delete?page=Special:MobileDiff/..., which isn't
// correct and very helpful. To fix this bug, we create a new context from the
// current one and set the title object (which we can get from the new revision).
// Bug: T122984
$context = new DerivativeContext($this->getContext());
$revision = $this->mNewRev;
$context->setTitle($revision->getTitle());
if (!$allowed) {
$msg = $context->msg($suppressed ? 'rev-suppressed-no-diff' : 'rev-deleted-no-diff')->parse();
} else {
# Give explanation and add a link to view the diff...
$query = $this->getRequest()->appendQueryValue('unhide', '1', true);
$link = $this->getTitle()->getFullURL($query);
$msg = $context->msg($suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff', $link)->parse();
}
}
return $msg;
}