本文整理匯總了PHP中DerivativeContext::setLanguage方法的典型用法代碼示例。如果您正苦於以下問題:PHP DerivativeContext::setLanguage方法的具體用法?PHP DerivativeContext::setLanguage怎麽用?PHP DerivativeContext::setLanguage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DerivativeContext
的用法示例。
在下文中一共展示了DerivativeContext::setLanguage方法的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: newContext
/**
* @param WebRequest|null $request
* @param Language|string|null $language
* @param User|null $user
*
* @return DerivativeContext
*/
private function newContext(WebRequest $request = null, $language = null, User $user = null)
{
$context = new DerivativeContext(RequestContext::getMain());
$context->setRequest($request ?: new FauxRequest());
if ($language !== null) {
$context->setLanguage($language);
}
if ($user !== null) {
$context->setUser($user);
}
$this->setEditTokenFromUser($context);
return $context;
}
示例3: flattenArrayContentLang
/**
* Flatten an array, using the content language for any messages.
*
* @param array $vals Array of values
* @param string $type Type of array (either lang, ul, ol).
* lang = language assoc array with keys being the lang code
* ul = unordered list, ol = ordered list
* type can also come from the '_type' member of $vals.
* @param bool $noHtml If to avoid returning anything resembling HTML.
* (Ugly hack for backwards compatibility with old MediaWiki).
* @param bool|IContextSource $context
* @return string Single value (in wiki-syntax).
* @since 1.23
*/
public static function flattenArrayContentLang($vals, $type = 'ul', $noHtml = false, $context = false)
{
global $wgContLang;
$obj = new FormatMetadata();
if ($context) {
$obj->setContext($context);
}
$context = new DerivativeContext($obj->getContext());
$context->setLanguage($wgContLang);
$obj->setContext($context);
return $obj->flattenArrayReal($vals, $type, $noHtml);
}