本文整理匯總了PHP中DerivativeContext::setSkin方法的典型用法代碼示例。如果您正苦於以下問題:PHP DerivativeContext::setSkin方法的具體用法?PHP DerivativeContext::setSkin怎麽用?PHP DerivativeContext::setSkin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DerivativeContext
的用法示例。
在下文中一共展示了DerivativeContext::setSkin方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
public function execute()
{
$params = $this->extractRequestParams();
$modules = array();
foreach ($params['modules'] as $path) {
$modules[] = $this->getModuleFromPath($path);
}
// Get the help
$context = new DerivativeContext($this->getMain()->getContext());
$context->setSkin(SkinFactory::getDefaultInstance()->makeSkin('apioutput'));
$context->setLanguage($this->getMain()->getLanguage());
$context->setTitle(SpecialPage::getTitleFor('ApiHelp'));
$out = new OutputPage($context);
$out->setCopyrightUrl('https://www.mediawiki.org/wiki/Special:MyLanguage/Copyright');
$context->setOutput($out);
self::getHelp($context, $modules, $params);
// Grab the output from the skin
ob_start();
$context->getOutput()->output();
$html = ob_get_clean();
$result = $this->getResult();
if ($params['wrap']) {
$data = array('mime' => 'text/html', 'help' => $html);
ApiResult::setSubelementsList($data, 'help');
$result->addValue(null, $this->getModuleName(), $data);
} else {
$result->reset();
$result->addValue(null, 'text', $html, ApiResult::NO_SIZE_CHECK);
$result->addValue(null, 'mime', 'text/html', ApiResult::NO_SIZE_CHECK);
}
}
示例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'));
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();
}
}
示例3: 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();
}
}