本文整理汇总了PHP中wfGetLangObj函数的典型用法代码示例。如果您正苦于以下问题:PHP wfGetLangObj函数的具体用法?PHP wfGetLangObj怎么用?PHP wfGetLangObj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfGetLangObj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetPageLanguage
/**
* @dataProvider dataGetPageLanguage
*/
public function testGetPageLanguage($title, $expected)
{
if (is_string($title)) {
$title = Title::newFromText($title);
}
$expected = wfGetLangObj($expected);
$handler = ContentHandler::getForTitle($title);
$lang = $handler->getPageLanguage($title);
$this->assertEquals($expected->getCode(), $lang->getCode());
}
示例2: execute
/**
* Show the special page
*
* @param string $par Parameter passed to the page or null
*/
public function execute($par)
{
$request = $this->getRequest();
$out = $this->getOutput();
$this->setHeaders();
if (!$this->getConfig()->get('UseDatabaseMessages')) {
$out->addWikiMsg('allmessagesnotsupportedDB');
return;
}
$this->outputHeader('allmessagestext');
$out->addModuleStyles('mediawiki.special');
$this->table = new AllmessagesTablePager($this, array(), wfGetLangObj($request->getVal('lang', $par)));
$this->langcode = $this->table->lang->getCode();
$out->addHTML($this->table->buildForm());
$out->addParserOutputContent($this->table->getFullOutput());
}
示例3: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
*/
public function execute($par)
{
$request = $this->getRequest();
$out = $this->getOutput();
$this->setHeaders();
global $wgUseDatabaseMessages;
if (!$wgUseDatabaseMessages) {
$out->addWikiMsg('allmessagesnotsupportedDB');
return;
} else {
$this->outputHeader('allmessagestext');
}
$out->addModuleStyles('mediawiki.special');
$this->table = new AllmessagesTablePager($this, array(), wfGetLangObj($request->getVal('lang', $par)));
$this->langcode = $this->table->lang->getCode();
$out->addHTML($this->table->buildForm() . $this->table->getNavigationBar() . $this->table->getBody() . $this->table->getNavigationBar());
}
示例4: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
*/
public function execute($par)
{
global $wgOut, $wgRequest;
$this->setHeaders();
global $wgUseDatabaseMessages;
if (!$wgUseDatabaseMessages) {
$wgOut->addWikiMsg('allmessagesnotsupportedDB');
return;
} else {
$this->outputHeader('allmessagestext');
}
$this->filter = $wgRequest->getVal('filter', 'all');
$this->prefix = $wgRequest->getVal('prefix', '');
$this->table = new AllmessagesTablePager($this, $conds = array(), wfGetLangObj($wgRequest->getVal('lang', $par)));
$this->langCode = $this->table->lang->getCode();
$wgOut->addHTML($this->buildForm() . $this->table->getNavigationBar() . $this->table->getLimitForm() . $this->table->getBody() . $this->table->getNavigationBar());
}
示例5: executeIndex
public function executeIndex()
{
global $wgRequest, $wgContLang;
$day = $wgRequest->getVal('day');
$type = $wgRequest->getVal('type');
$lang = $wgRequest->getVal('lang', 'en');
if ($type != 'views-digest' && $type != 'complete-digest') {
$wgContLang = wfGetLangObj($lang);
}
if (!empty($day)) {
$this->previewBody = F::app()->renderView("FounderEmails", $day, array('language' => $lang));
$this->previewBody = strtr($this->previewBody, array('$USERNAME' => 'UserName', '$WIKINAME' => '<a href="#" style="color:#2C85D5;">WikiName</a>', '$HDWIKINAME' => '<a href="#" style="color:#fa5c1f;">WikiName</a>', '$UNIQUEVIEWS' => '6'));
} else {
if (!empty($type)) {
$this->previewBody = F::app()->renderView("FounderEmails", 'GeneralUpdate', array('type' => $type, 'language' => $lang, '$PAGEURL' => 'http://www.wikia.com', '$MYHOMEURL' => 'http://www.wikia.com', '$UNIQUEVIEWS' => '1', '$USEREDITS' => '2', '$USERJOINS' => '3', '$EDITORTALKPAGEURL' => 'http://www.wikia.com'));
$this->previewBody = strtr($this->previewBody, array('$USERNAME' => 'UserName', '$WIKINAME' => '<a href="#" style="color:#2C85D5;">WikiName</a>', '$PAGETITLE' => '<a href="#" style="color:#2C85D5;">PageTitle</a>', '$EDITORNAME' => '<a href="#" style="color:#2C85D5;">EditorName</a>'));
}
}
}
示例6: getPageViewLanguage
/**
* Get the language in which the content of this page is written when
* viewed by user. Defaults to $wgContLang, but in certain cases it can be
* e.g. $wgLang (such as special pages, which are in the user language).
*
* @since 1.20
* @return Language
*/
public function getPageViewLanguage()
{
global $wgLang;
if ($this->isSpecialPage()) {
// If the user chooses a variant, the content is actually
// in a language whose code is the variant code.
$variant = $wgLang->getPreferredVariant();
if ($wgLang->getCode() !== $variant) {
return Language::factory($variant);
}
return $wgLang;
}
// Checking if DB language is set
$dbPageLanguage = $this->getDbPageLanguageCode();
if ($dbPageLanguage) {
$pageLang = wfGetLangObj($dbPageLanguage);
$variant = $pageLang->getPreferredVariant();
if ($pageLang->getCode() !== $variant) {
$pageLang = Language::factory($variant);
}
return $pageLang;
}
// @note Can't be cached persistently, depends on user settings.
// @note ContentHandler::getPageViewLanguage() may need to load the
// content to determine the page language!
$contentHandler = ContentHandler::getForTitle($this);
$pageLang = $contentHandler->getPageViewLanguage($this);
return $pageLang;
}
示例7: getJsData
/**
* Returns an array of config data for this filter to be stored in the JS
* @return null
*/
public function getJsData()
{
global $wgAmericanDates;
return $this->getParamHashes($this->getQueryResults(), $this->getActualParameters()) + array('firstDay' => $wgAmericanDates ? '0' : wfMsg('srf-filtered-firstdayofweek'), 'isRTL' => wfGetLangObj(true)->isRTL());
}
示例8: getInstance
/**
* Get a DateFormatter object
*
* @param Language|string|null $lang In which language to format the date
* Defaults to the site content language
* @return DateFormatter
*/
public static function getInstance($lang = null)
{
global $wgContLang, $wgMainCacheType;
$lang = $lang ? wfGetLangObj($lang) : $wgContLang;
$cache = ObjectCache::getLocalServerInstance($wgMainCacheType);
static $dateFormatter = false;
if (!$dateFormatter) {
$dateFormatter = $cache->getWithSetCallback($cache->makeKey('dateformatter', $lang->getCode()), $cache::TTL_HOUR, function () use($lang) {
return new DateFormatter($lang);
});
}
return $dateFormatter;
}
示例9: getJsData
/**
* Returns an array of config data for this filter to be stored in the JS
* @return null
*/
public function getJsData()
{
global $wgAmericanDates;
return $this->getParamHashes($this->getQueryResults(), $this->getActualParameters()) + array('firstDay' => $wgAmericanDates ? '0' : Message::newFromKey('srf-filtered-firstdayofweek')->inContentLanguage()->text(), 'isRTL' => wfGetLangObj(true)->isRTL());
}
示例10: getPageViewLanguage
/**
* Returns the english language, because CSS is english, and should be handled as such.
*
* @param Title $title
* @param Content $content
* @return Language wfGetLangObj( 'en' )
*
* @see ContentHandler::getPageViewLanguage()
*/
public function getPageViewLanguage(Title $title, Content $content = null)
{
return wfGetLangObj('en');
}
示例11: doEditSectionLink
/**
* Create a section edit link. This supersedes editSectionLink() and
* editSectionLinkForOther().
*
* @param $nt Title The title being linked to (may not be the same as
* $wgTitle, if the section is included from a template)
* @param string $section The designation of the section being pointed to,
* to be included in the link, like "§ion=$section"
* @param string $tooltip The tooltip to use for the link: will be escaped
* and wrapped in the 'editsectionhint' message
* @param $lang string Language code
* @return string HTML to use for edit link
*/
public function doEditSectionLink(Title $nt, $section, $tooltip = null, $lang = false)
{
// HTML generated here should probably have userlangattributes
// added to it for LTR text on RTL pages
$lang = wfGetLangObj($lang);
$attribs = array();
if (!is_null($tooltip)) {
# Bug 25462: undo double-escaping.
$tooltip = Sanitizer::decodeCharReferences($tooltip);
$attribs['title'] = wfMessage('editsectionhint')->rawParams($tooltip)->inLanguage($lang)->text();
}
$link = Linker::link($nt, wfMessage('editsection')->inLanguage($lang)->text(), $attribs, array('action' => 'edit', 'section' => $section), array('noclasses', 'known'));
# Run the old hook. This takes up half of the function . . . hopefully
# we can rid of it someday.
$attribs = '';
if ($tooltip) {
$attribs = wfMessage('editsectionhint')->rawParams($tooltip)->inLanguage($lang)->escaped();
$attribs = " title=\"{$attribs}\"";
}
$result = null;
wfRunHooks('EditSectionLink', array(&$this, $nt, $section, $attribs, $link, &$result, $lang));
if (!is_null($result)) {
# For reverse compatibility, add the brackets *after* the hook is
# run, and even add them to hook-provided text. (This is the main
# reason that the EditSectionLink hook is deprecated in favor of
# DoEditSectionLink: it can't change the brackets or the span.)
$result = wfMessage('editsection-brackets')->rawParams($result)->inLanguage($lang)->escaped();
return "<span class=\"editsection\">{$result}</span>";
}
# Add the brackets and the span, and *then* run the nice new hook, with
# clean and non-redundant arguments.
$result = wfMessage('editsection-brackets')->rawParams($link)->inLanguage($lang)->escaped();
$result = "<span class=\"editsection\">{$result}</span>";
wfRunHooks('DoEditSectionLink', array($this, $nt, $section, $tooltip, &$result, $lang));
return $result;
}
示例12: wfMsgExt
/**
* Returns message in the requested format
* @param $key String: key of the message
* @param $options Array: processing rules. Can take the following options:
* <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 through htmlspecialchars
* <i>escapenoentities</i>: same, but allows entity references like   through
* <i>replaceafter</i>: parameters are substituted after parsing or escaping
* <i>parsemag</i>: transform the message using magic phrases
* <i>content</i>: fetch message for content language instead of interface
* Also can accept a single associative argument, of the form 'language' => 'xx':
* <i>language</i>: Language object or language code to fetch message for
* (overriden by <i>content</i>).
* Behavior for conflicting options (e.g., parse+parseinline) is undefined.
*
* @return String
*/
function wfMsgExt($key, $options)
{
$args = func_get_args();
array_shift($args);
array_shift($args);
$options = (array) $options;
foreach ($options as $arrayKey => $option) {
if (!preg_match('/^[0-9]+|language$/', $arrayKey)) {
# An unknown index, neither numeric nor "language"
wfWarn("wfMsgExt called with incorrect parameter key {$arrayKey}", 1, E_USER_WARNING);
} elseif (preg_match('/^[0-9]+$/', $arrayKey) && !in_array($option, array('parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter', 'parsemag', 'content'))) {
# A numeric index with unknown value
wfWarn("wfMsgExt called with incorrect parameter {$option}", 1, E_USER_WARNING);
}
}
if (in_array('content', $options, true)) {
$forContent = true;
$langCode = true;
$langCodeObj = null;
} elseif (array_key_exists('language', $options)) {
$forContent = false;
$langCode = wfGetLangObj($options['language']);
$langCodeObj = $langCode;
} else {
$forContent = false;
$langCode = false;
$langCodeObj = null;
}
$string = wfMsgGetKey($key, true, $langCode, false);
if (!in_array('replaceafter', $options, true)) {
$string = wfMsgReplaceArgs($string, $args);
}
$messageCache = MessageCache::singleton();
if (in_array('parse', $options, true)) {
$string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj)->getText();
} elseif (in_array('parseinline', $options, true)) {
$string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj)->getText();
$m = array();
if (preg_match('/^<p>(.*)\\n?<\\/p>\\n?$/sU', $string, $m)) {
$string = $m[1];
}
} elseif (in_array('parsemag', $options, true)) {
$string = $messageCache->transform($string, !$forContent, $langCodeObj);
}
if (in_array('escape', $options, true)) {
$string = htmlspecialchars($string);
} elseif (in_array('escapenoentities', $options, true)) {
$string = Sanitizer::escapeHtmlAllowEntities($string);
}
if (in_array('replaceafter', $options, true)) {
$string = wfMsgReplaceArgs($string, $args);
}
return $string;
}
示例13: doEditSectionLink
/**
* Create a section edit link. This supersedes editSectionLink() and
* editSectionLinkForOther().
*
* @param $nt Title The title being linked to (may not be the same as
* $wgTitle, if the section is included from a template)
* @param string $section The designation of the section being pointed to,
* to be included in the link, like "§ion=$section"
* @param string $tooltip The tooltip to use for the link: will be escaped
* and wrapped in the 'editsectionhint' message
* @param $lang string Language code
* @return string HTML to use for edit link
*/
public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
// HTML generated here should probably have userlangattributes
// added to it for LTR text on RTL pages
$lang = wfGetLangObj( $lang );
$attribs = array();
if ( !is_null( $tooltip ) ) {
# Bug 25462: undo double-escaping.
$tooltip = Sanitizer::decodeCharReferences( $tooltip );
$attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
->inLanguage( $lang )->text();
}
$link = Linker::link( $nt, wfMessage( 'editsection' )->inLanguage( $lang )->text(),
$attribs,
array( 'action' => 'edit', 'section' => $section ),
array( 'noclasses', 'known' )
);
# Add the brackets and the span and run the hook.
$result = '<span class="mw-editsection">'
. '<span class="mw-editsection-bracket">[</span>'
. $link
. '<span class="mw-editsection-bracket">]</span>'
. '</span>';
wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
return $result;
}
示例14: getPreviewText
/**
* Get the rendered text for previewing.
* @return string
*/
function getPreviewText()
{
global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang, $wgMessageCache;
wfProfileIn(__METHOD__);
if ($this->mTriedSave && !$this->mTokenOk) {
if ($this->mTokenOkExceptSuffix) {
$note = wfMsg('token_suffix_mismatch');
} else {
$note = wfMsg('session_fail_preview');
}
} else {
$note = wfMsg('previewnote');
}
$parserOptions = ParserOptions::newFromUser($wgUser);
$parserOptions->setEditSection(false);
$parserOptions->setIsPreview(true);
$parserOptions->setIsSectionPreview(!is_null($this->section) && $this->section !== '');
global $wgRawHtml;
if ($wgRawHtml && !$this->mTokenOk) {
// Could be an offsite preview attempt. This is very unsafe if
// HTML is enabled, as it could be an attack.
return $wgOut->parse("<div class='previewnote'>" . wfMsg('session_fail_preview_html') . "</div>");
}
# don't parse user css/js, show message about preview
# XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
if ($this->isCssJsSubpage) {
if (preg_match("/\\.css\$/", $this->mTitle->getText())) {
$previewtext = wfMsg('usercsspreview');
} else {
if (preg_match("/\\.js\$/", $this->mTitle->getText())) {
$previewtext = wfMsg('userjspreview');
}
}
$parserOptions->setTidy(true);
$parserOutput = $wgParser->parse($previewtext, $this->mTitle, $parserOptions);
$previewHTML = $parserOutput->mText;
} elseif ($rt = Title::newFromRedirectArray($this->textbox1)) {
$previewHTML = $this->mArticle->viewRedirect($rt, false);
} else {
$toparse = $this->textbox1;
# If we're adding a comment, we need to show the
# summary as the headline
if ($this->section == "new" && $this->summary != "") {
$toparse = "== {$this->summary} ==\n\n" . $toparse;
}
if ($this->mMetaData != "") {
$toparse .= "\n" . $this->mMetaData;
}
// Parse mediawiki messages with correct target language
if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
list(, $lang) = $wgMessageCache->figureMessage($this->mTitle->getText());
$obj = wfGetLangObj($lang);
$parserOptions->setTargetLanguage($obj);
}
$parserOptions->setTidy(true);
$parserOptions->enableLimitReport();
$parserOutput = $wgParser->parse($this->mArticle->preSaveTransform($toparse), $this->mTitle, $parserOptions);
$previewHTML = $parserOutput->getText();
$this->mParserOutput = $parserOutput;
$wgOut->addParserOutputNoText($parserOutput);
if (count($parserOutput->getWarnings())) {
$note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings());
}
}
$previewhead = '<h2>' . htmlspecialchars(wfMsg('preview')) . "</h2>\n" . "<div class='previewnote'>" . $wgOut->parse($note) . "</div>\n";
if ($this->isConflict) {
$previewhead .= '<h2>' . htmlspecialchars(wfMsg('previewconflict')) . "</h2>\n";
}
wfProfileOut(__METHOD__);
return $previewhead . $previewHTML;
}
示例15: get
/**
* Get a message from either the content language or the user language.
*
* @param string $key The message cache key
* @param bool $useDB Get the message from the DB, false to use only the localisation
* @param string $langcode Code of the language to get the message for, if
* it is a valid code create a language for that
* language, if it is a string but not a valid code
* then make a basic language object, if it is a
* false boolean then use the current users
* language (as a fallback for the old parameter
* functionality), or if it is a true boolean then
* use the wikis content language (also as a
* fallback).
* @param bool $isFullKey Specifies whether $key is a two part key "lang/msg".
*/
function get($key, $useDB = true, $langcode = true, $isFullKey = false)
{
global $wgContLanguageCode, $wgContLang;
$lang = wfGetLangObj($langcode);
$langcode = $lang->getCode();
# If uninitialised, someone is trying to call this halfway through Setup.php
if (!$this->mInitialised) {
return '<' . htmlspecialchars($key) . '>';
}
$message = false;
# Normalise title-case input
$lckey = $wgContLang->lcfirst($key);
$lckey = str_replace(' ', '_', $lckey);
# Try the MediaWiki namespace
if (!$this->mDisable && $useDB) {
$title = $wgContLang->ucfirst($lckey);
if (!$isFullKey && $langcode != $wgContLanguageCode) {
$title .= '/' . $langcode;
}
$message = $this->getMsgFromNamespace($title, $langcode);
}
# Try the extension array
if ($message === false && isset($this->mExtensionMessages[$langcode][$lckey])) {
$message = $this->mExtensionMessages[$langcode][$lckey];
}
if ($message === false && isset($this->mExtensionMessages['en'][$lckey])) {
$message = $this->mExtensionMessages['en'][$lckey];
}
# Try the array in the language object
if ($message === false) {
$message = $lang->getMessage($lckey);
if (is_null($message)) {
$message = false;
}
}
# Try the array of another language
$pos = strrpos($lckey, '/');
if ($message === false && $pos !== false) {
$mkey = substr($lckey, 0, $pos);
$code = substr($lckey, $pos + 1);
if ($code) {
# We may get calls for things that are http-urls from sidebar
# Let's not load nonexistent languages for those
$validCodes = array_keys(Language::getLanguageNames());
if (in_array($code, $validCodes)) {
$message = Language::getMessageFor($mkey, $code);
if (is_null($message)) {
$message = false;
}
}
}
}
# Is this a custom message? Try the default language in the db...
if (($message === false || $message === '-') && !$this->mDisable && $useDB && !$isFullKey && $langcode != $wgContLanguageCode) {
$message = $this->getMsgFromNamespace($wgContLang->ucfirst($lckey), $wgContLanguageCode);
}
# Final fallback
if ($message === false) {
return '<' . htmlspecialchars($key) . '>';
}
return $message;
}