本文整理汇总了PHP中Language::fetchLanguageName方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::fetchLanguageName方法的具体用法?PHP Language::fetchLanguageName怎么用?PHP Language::fetchLanguageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::fetchLanguageName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showLanguage
protected function showLanguage($code, $users)
{
$out = $this->getOutput();
$lang = $this->getLanguage();
$usernames = array_keys($users);
$userStats = $this->getUserStats($usernames);
// Information to be used inside the foreach loop.
$linkInfo = array();
$linkInfo['rc']['title'] = SpecialPage::getTitleFor('Recentchanges');
$linkInfo['rc']['msg'] = $this->msg('supportedlanguages-recenttranslations')->escaped();
$linkInfo['stats']['title'] = SpecialPage::getTitleFor('LanguageStats');
$linkInfo['stats']['msg'] = $this->msg('languagestats')->escaped();
$local = Language::fetchLanguageName($code, $lang->getCode(), 'all');
$native = Language::fetchLanguageName($code, null, 'all');
if ($local !== $native) {
$headerText = $this->msg('supportedlanguages-portallink')->params($code, $local, $native)->escaped();
} else {
// No CLDR, so a less localised header and link title.
$headerText = $this->msg('supportedlanguages-portallink-nocldr')->params($code, $native)->escaped();
}
$out->addHtml(Html::rawElement('h2', array('id' => $code), $headerText));
// Add useful links for language stats and recent changes for the language.
$links = array();
$links[] = Linker::link($linkInfo['stats']['title'], $linkInfo['stats']['msg'], array(), array('code' => $code, 'suppresscomplete' => '1'), array('known', 'noclasses'));
$links[] = Linker::link($linkInfo['rc']['title'], $linkInfo['rc']['msg'], array(), array('translations' => 'only', 'trailer' => "/" . $code), array('known', 'noclasses'));
$linkList = $lang->listToText($links);
$out->addHTML("<p>" . $linkList . "</p>\n");
$this->makeUserList($users, $userStats);
}
示例2: makeLanguageLinks
private function makeLanguageLinks()
{
global $wgWRLanguageLinksShowOnly, $wgWRLanguageLinksShowTitles;
// Language links - ripped from SkinTemplate.php and then mangled badly
$parserLanguageLinks = $this->mParser->getOutput()->getLanguageLinks();
$language_urls = array();
$showOnly = array();
if ($wgWRLanguageLinksShowOnly != null) {
$showOnly = explode(',', $wgWRLanguageLinksShowOnly);
}
foreach ($parserLanguageLinks as $languageLinkText) {
$languageLinkTitle = Title::newFromText($languageLinkText);
if ($languageLinkTitle) {
$ilInterwikiCode = $languageLinkTitle->getInterwiki();
if (is_null($wgWRLanguageLinksShowOnly) || in_array($ilInterwikiCode, $showOnly)) {
$ilLangName = Language::fetchLanguageName($ilInterwikiCode);
if (strval($ilLangName) === '') {
$ilLangName = $languageLinkText;
}
$ilArticleName = $languageLinkTitle->getText();
$language_urls[] = array('href' => $languageLinkTitle->getFullURL(), 'text' => $wgWRLanguageLinksShowTitles ? $ilArticleName : $ilLangName, 'title' => $wgWRLanguageLinksShowTitles ? $ilLangName : $ilArticleName, 'class' => "wr-languagelinks-{$ilInterwikiCode}", 'lang' => $ilInterwikiCode);
}
}
}
return $language_urls;
}
示例3: wfGlobalInterwikis
function wfGlobalInterwikis($prefix, &$iwData)
{
global $wgInterwikiCentralDB;
// docs/hooks.txt says: Return true without providing an interwiki to continue interwiki search.
if ($wgInterwikiCentralDB === null || $wgInterwikiCentralDB === wfWikiId()) {
// No global set or this is global, nothing to add
return true;
}
if (!Language::fetchLanguageName($prefix)) {
// Check if prefix exists locally and skip
foreach (Interwiki::getAllPrefixes(null) as $id => $localPrefixInfo) {
if ($prefix === $localPrefixInfo['iw_prefix']) {
return true;
}
}
$dbr = wfGetDB(DB_SLAVE, array(), $wgInterwikiCentralDB);
$res = $dbr->selectRow('interwiki', '*', array('iw_prefix' => $prefix), __METHOD__);
if (!$res) {
return true;
}
// Excplicitly make this an array since it's expected to be one
$iwData = (array) $res;
// At this point, we can safely return false because we know that we have something
return false;
}
return true;
}
示例4: __construct
public function __construct($name = null, array $data = array(), $dataName = '', $engineName = null)
{
parent::__construct($name, $data, $dataName, $engineName);
// Skip certain tests if something isn't providing translated language names
// (bug 67343)
if (Language::fetchLanguageName('en', 'fr') === 'English') {
$msg = 'Language name translations are unavailable; ' . 'install Extension:CLDR or something similar';
$this->skipTests += array('fetchLanguageName (en,ru)' => $msg, 'fetchLanguageName (ru,en)' => $msg, 'fetchLanguageNames (de)' => $msg, 'fetchLanguageNames ([[bogus]])' => $msg);
}
}
示例5: getHtml
/**
* Fetches appropriate HTML for the tutorial portion of the wizard.
* Looks up an image on the current wiki. This will work as is on Commons, and will also work
* on test wikis that enable instantCommons.
* @param String|null $campaign Upload Wizard campaign for which the tutorial should be displayed.
* @return String html that will display the tutorial.
*/
public static function getHtml($campaign = null)
{
global $wgLang;
$error = null;
$errorHtml = '';
$tutorialHtml = '';
$langCode = $wgLang->getCode();
$tutorial = UploadWizardConfig::getSetting('tutorial', $campaign);
// getFile returns false if it can't find the right file
$tutorialFile = self::getFile($langCode, $tutorial);
if ($tutorialFile === false) {
$error = 'localized-file-missing';
foreach ($wgLang->getFallbackLanguages() as $langCode) {
$tutorialFile = self::getFile($langCode, $tutorial);
if ($tutorialFile !== false) {
// $langCode remains as the code where a file is found.
break;
}
}
}
// at this point, we have one of the following situations:
// $error is null, and tutorialFile is the right one for this language
// $error notes we couldn't find the tutorialFile for your language, and $tutorialFile is the english one
// $error notes we couldn't find the tutorialFile for your language, and $tutorialFile is still false (major file failure)
if ($tutorialFile) {
// XXX TODO if the client can handle SVG, we could also just send it the unscaled thumb, client-scaled into a DIV or something.
// if ( client can handle SVG ) {
// $tutorialThumbnailImage->getUnscaledThumb();
// }
// put it into a div of appropriate dimensions.
// n.b. File::transform() returns false if failed, MediaTransformOutput otherwise
$thumbnailImage = $tutorialFile->transform(array('width' => $tutorial['width']));
if ($thumbnailImage) {
$tutorialHtml = self::getImageHtml($thumbnailImage, $tutorial);
} else {
$error = 'cannot-transform';
}
} else {
$error = 'file-missing';
}
if ($error !== null) {
// Messages:
// mwe-upwiz-tutorial-error-localized-file-missing, mwe-upwiz-tutorial-error-file-missing,
// mwe-upwiz-tutorial-error-cannot-transform
$errorMsg = wfMessage('mwe-upwiz-tutorial-error-' . $error);
if ($error === 'localized-file-missing') {
$errorMsg->params(Language::fetchLanguageName($langCode, $wgLang->getCode()));
}
$errorHtml = Html::element('p', array('class' => 'errorbox', 'style' => 'float: none;'), $errorMsg->text());
}
return $errorHtml . $tutorialHtml;
}
示例6: getCode
/**
* Takes a language code, and attempt to obtain a better variant of it,
* checks the MediaWiki language codes for a match, otherwise checks the
* Babel language codes CDB (preferring ISO 639-1 over ISO 639-3).
*
* @param $code String: Code to try and get a "better" code for.
* @return String (language code) or false (invalid language code).
*/
public static function getCode($code)
{
wfProfileIn(__METHOD__);
global $wgBabelLanguageCodesCdb;
$mediawiki = Language::fetchLanguageName($code);
if ($mediawiki !== '') {
wfProfileOut(__METHOD__);
return $code;
}
$codesCdb = CdbReader::open($wgBabelLanguageCodesCdb);
$codes = $codesCdb->get($code);
wfProfileOut(__METHOD__);
return $codes;
}
示例7: makeRedirectContent
/**
* Returns a WikitextContent object representing a redirect to the given destination page.
*
* @param Title $destination The page to redirect to.
* @param string $text Text to include in the redirect, if possible.
*
* @return Content
*
* @see ContentHandler::makeRedirectContent
*/
public function makeRedirectContent(Title $destination, $text = '')
{
$optionalColon = '';
if ($destination->getNamespace() == NS_CATEGORY) {
$optionalColon = ':';
} else {
$iw = $destination->getInterwiki();
if ($iw && Language::fetchLanguageName($iw, null, 'mw')) {
$optionalColon = ':';
}
}
$mwRedir = MagicWord::get('redirect');
$redirectText = $mwRedir->getSynonym(0) . ' [[' . $optionalColon . $destination->getFullText() . ']]';
if ($text != '') {
$redirectText .= "\n" . $text;
}
return new WikitextContent($redirectText);
}
示例8: getCode
/**
* Takes a language code, and attempt to obtain a better variant of it,
* checks the MediaWiki language codes for a match, otherwise checks the
* Babel language codes CDB (preferring ISO 639-1 over ISO 639-3).
*
* @param $code String: Code to try and get a "better" code for.
* @return String (language code) or false (invalid language code).
*/
public static function getCode($code)
{
wfProfileIn(__METHOD__);
global $wgBabelLanguageCodesCdb;
$mediawiki = Language::fetchLanguageName($code);
if ($mediawiki !== '') {
wfProfileOut(__METHOD__);
return $code;
}
$codes = false;
try {
$codesCdb = CdbReader::open($wgBabelLanguageCodesCdb);
$codes = $codesCdb->get($code);
} catch (CdbException $e) {
wfDebug(__METHOD__ . ": CdbException caught, error message was " . $e->getMessage());
}
wfProfileOut(__METHOD__);
return $codes;
}
示例9: heading
function heading()
{
global $wgDummyLanguageCodes;
$version = SpecialVersion::getVersion('nodb');
echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
echo "'''Note:''' These statistics can be generated by running " . "<code>php maintenance/language/transstat.php</code>.\n\n";
echo "For additional information on specific languages (the message names, the actual " . "problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
echo 'English (en) is excluded because it is the default localization';
if (is_array($wgDummyLanguageCodes)) {
$dummyCodes = array();
foreach ($wgDummyLanguageCodes as $dummyCode => $correctCode) {
$dummyCodes[] = Language::fetchLanguageName($dummyCode) . ' (' . $dummyCode . ')';
}
echo ', as well as the following languages that are not intended for ' . 'system message translations, usually because they redirect to other ' . 'language codes: ' . implode(', ', $dummyCodes);
}
echo ".\n\n";
# dot to end sentence
echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' . 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
}
示例10: execute
public function execute()
{
$dbw = wfGetDB(DB_SLAVE);
// Get all Athena logs
$res = $dbw->select(array('athena_page_details'), array('al_id', 'apd_language', 'apd_content'), array(), __METHOD__, array(), array());
foreach ($res as $row) {
echo "\n----------------------------------------------\n";
echo "al_id is {$row->al_id} \n";
echo "apd_language is {$row->apd_language} \n";
$content = $row->apd_content;
if (strlen($content) == 0) {
$code = null;
} else {
file_put_contents("temp", $content);
$code = system("franc < temp");
}
$code = AthenaHelper::convertISOCode($code);
echo "Language code is {$code}\n";
$str = $dbw->strencode(Language::fetchLanguageName($code));
echo "Language name is {$str} \n";
$dbw->update('athena_page_details', array('apd_language' => $str), array('al_id' => $row->al_id), __METHOD__, null);
echo "\n----------------------------------------------\n";
}
}
示例11: getMessageParameters
protected function getMessageParameters()
{
// Get the user language for displaying language names
$userLang = $this->context->getLanguage()->getCode();
$params = parent::getMessageParameters();
// Get the language codes from log
$oldLang = $params[3];
$kOld = strrpos($oldLang, '[');
if ($kOld) {
$oldLang = substr($oldLang, 0, $kOld);
}
$newLang = $params[4];
$kNew = strrpos($newLang, '[');
if ($kNew) {
$newLang = substr($newLang, 0, $kNew);
}
// Convert language codes to names in user language
$logOld = Language::fetchLanguageName($oldLang, $userLang) . ' (' . $oldLang . ')';
$logNew = Language::fetchLanguageName($newLang, $userLang) . ' (' . $newLang . ')';
// Add the default message to languages if required
$params[3] = !$kOld ? $logOld : $logOld . ' [' . $this->msg('default') . ']';
$params[4] = !$kNew ? $logNew : $logNew . ' [' . $this->msg('default') . ']';
return $params;
}
示例12: execute
public function execute()
{
global $wgTranslateFuzzyBotName, $wgSitename;
$days = (int) $this->getOption('days', 30);
$hours = $days * 24;
$top = (int) $this->getOption('top', -1);
$bots = $this->hasOption('bots');
$namespaces = array();
if ($this->hasOption('ns')) {
$input = explode(',', $this->getOption('ns'));
foreach ($input as $namespace) {
if (is_numeric($namespace)) {
$namespaces[] = $namespace;
}
}
}
// Select set of edits to report on
// Fetch some extrac fields that normally TranslateUtils::translationChanges wont
$extraFields = array('rc_old_len', 'rc_new_len');
$rows = TranslateUtils::translationChanges($hours, $bots, $namespaces, $extraFields);
// Get counts for edits per language code after filtering out edits by FuzzyBot
$codes = array();
foreach ($rows as $_) {
// Filter out edits by $wgTranslateFuzzyBotName
if ($_->rc_user_text === $wgTranslateFuzzyBotName) {
continue;
}
$handle = new MessageHandle(Title::newFromText($_->rc_title));
$code = $handle->getCode();
if (!isset($codes[$code])) {
$codes[$code] = 0;
}
if ($this->hasOption('diff')) {
$diff = abs($_->rc_new_len - $_->rc_old_len);
} else {
$diff = $_->rc_new_len;
}
$codes[$code] += $diff;
}
// Sort counts and report descending up to $top rows.
arsort($codes);
$i = 0;
$total = 0;
$this->output("Character edit stats for last {$days} days in {$wgSitename}\n");
$this->output("code\tname\tedit\n");
$this->output("-----------------------\n");
foreach ($codes as $code => $num) {
if ($i++ === $top) {
break;
}
$language = Language::fetchLanguageName($code);
if (!$language) {
// this will be very rare, but avoid division by zero in next line
continue;
}
$charRatio = mb_strlen($language, 'UTF-8') / strlen($language);
$num = intval($num * $charRatio);
$total += $num;
$this->output("{$code}\t{$language}\t{$num}\n");
}
$this->output("-----------------------\n");
$this->output("Total\t\t{$total}\n");
}
示例13: execute
public function execute()
{
if ($this->getPageSet()->getGoodTitleCount() == 0) {
return;
}
$params = $this->extractRequestParams();
$prop = array_flip((array) $params['prop']);
if (isset($params['title']) && !isset($params['lang'])) {
$this->dieUsageMsg(array('missingparam', 'lang'));
}
// Handle deprecated param
$this->requireMaxOneParameter($params, 'url', 'prop');
if ($params['url']) {
$prop = array('url' => 1);
}
$this->addFields(array('ll_from', 'll_lang', 'll_title'));
$this->addTables('langlinks');
$this->addWhereFld('ll_from', array_keys($this->getPageSet()->getGoodTitles()));
if (!is_null($params['continue'])) {
$cont = explode('|', $params['continue']);
$this->dieContinueUsageIf(count($cont) != 2);
$op = $params['dir'] == 'descending' ? '<' : '>';
$llfrom = intval($cont[0]);
$lllang = $this->getDB()->addQuotes($cont[1]);
$this->addWhere("ll_from {$op} {$llfrom} OR " . "(ll_from = {$llfrom} AND " . "ll_lang {$op}= {$lllang})");
}
// FIXME: (follow-up) To allow extensions to add to the language links, we need
// to load them all, add the extra links, then apply paging.
// Should not be terrible, it's not going to be more than a few hundred links.
// Note that, since (ll_from, ll_lang) is a unique key, we don't need
// to sort by ll_title to ensure deterministic ordering.
$sort = $params['dir'] == 'descending' ? ' DESC' : '';
if (isset($params['lang'])) {
$this->addWhereFld('ll_lang', $params['lang']);
if (isset($params['title'])) {
$this->addWhereFld('ll_title', $params['title']);
}
$this->addOption('ORDER BY', 'll_from' . $sort);
} else {
// Don't order by ll_from if it's constant in the WHERE clause
if (count($this->getPageSet()->getGoodTitles()) == 1) {
$this->addOption('ORDER BY', 'll_lang' . $sort);
} else {
$this->addOption('ORDER BY', array('ll_from' . $sort, 'll_lang' . $sort));
}
}
$this->addOption('LIMIT', $params['limit'] + 1);
$res = $this->select(__METHOD__);
$count = 0;
foreach ($res as $row) {
if (++$count > $params['limit']) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter('continue', "{$row->ll_from}|{$row->ll_lang}");
break;
}
$entry = array('lang' => $row->ll_lang);
if (isset($prop['url'])) {
$title = Title::newFromText("{$row->ll_lang}:{$row->ll_title}");
if ($title) {
$entry['url'] = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
}
}
if (isset($prop['langname'])) {
$entry['langname'] = Language::fetchLanguageName($row->ll_lang, $params['inlanguagecode']);
}
if (isset($prop['autonym'])) {
$entry['autonym'] = Language::fetchLanguageName($row->ll_lang);
}
ApiResult::setContentValue($entry, 'title', $row->ll_title);
$fit = $this->addPageSubItem($row->ll_from, $entry);
if (!$fit) {
$this->setContinueEnumParameter('continue', "{$row->ll_from}|{$row->ll_lang}");
break;
}
}
}
示例14: getLanguages
/**
* Generates array of language links for the current page
*
* @return array
*/
public function getLanguages()
{
global $wgHideInterlanguageLinks;
if ($wgHideInterlanguageLinks) {
return array();
}
$userLang = $this->getLanguage();
$languageLinks = array();
foreach ($this->getOutput()->getLanguageLinks() as $languageLinkText) {
$languageLinkParts = explode(':', $languageLinkText, 2);
$class = 'interlanguage-link interwiki-' . $languageLinkParts[0];
unset($languageLinkParts);
$languageLinkTitle = Title::newFromText($languageLinkText);
if ($languageLinkTitle) {
$ilInterwikiCode = $languageLinkTitle->getInterwiki();
$ilLangName = Language::fetchLanguageName($ilInterwikiCode);
if (strval($ilLangName) === '') {
$ilDisplayTextMsg = wfMessage("interlanguage-link-{$ilInterwikiCode}");
if (!$ilDisplayTextMsg->isDisabled()) {
// Use custom MW message for the display text
$ilLangName = $ilDisplayTextMsg->text();
} else {
// Last resort: fallback to the language link target
$ilLangName = $languageLinkText;
}
} else {
// Use the language autonym as display text
$ilLangName = $this->formatLanguageName($ilLangName);
}
// CLDR extension or similar is required to localize the language name;
// otherwise we'll end up with the autonym again.
$ilLangLocalName = Language::fetchLanguageName($ilInterwikiCode, $userLang->getCode());
$languageLinkTitleText = $languageLinkTitle->getText();
if ($ilLangLocalName === '') {
$ilFriendlySiteName = wfMessage("interlanguage-link-sitename-{$ilInterwikiCode}");
if (!$ilFriendlySiteName->isDisabled()) {
if ($languageLinkTitleText === '') {
$ilTitle = wfMessage('interlanguage-link-title-nonlangonly', $ilFriendlySiteName->text())->text();
} else {
$ilTitle = wfMessage('interlanguage-link-title-nonlang', $languageLinkTitleText, $ilFriendlySiteName->text())->text();
}
} else {
// we have nothing friendly to put in the title, so fall back to
// displaying the interlanguage link itself in the title text
// (similar to what is done in page content)
$ilTitle = $languageLinkTitle->getInterwiki() . ":{$languageLinkTitleText}";
}
} elseif ($languageLinkTitleText === '') {
$ilTitle = wfMessage('interlanguage-link-title-langonly', $ilLangLocalName)->text();
} else {
$ilTitle = wfMessage('interlanguage-link-title', $languageLinkTitleText, $ilLangLocalName)->text();
}
$ilInterwikiCodeBCP47 = wfBCP47($ilInterwikiCode);
$languageLink = array('href' => $languageLinkTitle->getFullURL(), 'text' => $ilLangName, 'title' => $ilTitle, 'class' => $class, 'lang' => $ilInterwikiCodeBCP47, 'hreflang' => $ilInterwikiCodeBCP47);
Hooks::run('SkinTemplateGetLanguageLink', array(&$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput()));
$languageLinks[] = $languageLink;
}
}
return $languageLinks;
}
示例15: pageInfo
/**
* Returns page information in an easily-manipulated format. Array keys are used so extensions
* may add additional information in arbitrary positions. Array values are arrays with one
* element to be rendered as a header, arrays with two elements to be rendered as a table row.
*
* @return array
*/
protected function pageInfo()
{
global $wgContLang, $wgRCMaxAge;
$user = $this->getUser();
$lang = $this->getLanguage();
$title = $this->getTitle();
$id = $title->getArticleID();
// Get page information that would be too "expensive" to retrieve by normal means
$pageCounts = self::pageCounts($title, $user);
// Get page properties
$dbr = wfGetDB(DB_SLAVE);
$result = $dbr->select('page_props', array('pp_propname', 'pp_value'), array('pp_page' => $id), __METHOD__);
$pageProperties = array();
foreach ($result as $row) {
$pageProperties[$row->pp_propname] = $row->pp_value;
}
// Basic information
$pageInfo = array();
$pageInfo['header-basic'] = array();
// Display title
$displayTitle = $title->getPrefixedText();
if (!empty($pageProperties['displaytitle'])) {
$displayTitle = $pageProperties['displaytitle'];
}
$pageInfo['header-basic'][] = array($this->msg('pageinfo-display-title'), $displayTitle);
// Is it a redirect? If so, where to?
if ($title->isRedirect()) {
$pageInfo['header-basic'][] = array($this->msg('pageinfo-redirectsto'), Linker::link($this->page->getRedirectTarget()) . $this->msg('word-separator')->text() . $this->msg('parentheses', Linker::link($this->page->getRedirectTarget(), $this->msg('pageinfo-redirectsto-info')->escaped(), array(), array('action' => 'info')))->text());
}
// Default sort key
$sortKey = $title->getCategorySortKey();
if (!empty($pageProperties['defaultsort'])) {
$sortKey = $pageProperties['defaultsort'];
}
$pageInfo['header-basic'][] = array($this->msg('pageinfo-default-sort'), $sortKey);
// Page length (in bytes)
$pageInfo['header-basic'][] = array($this->msg('pageinfo-length'), $lang->formatNum($title->getLength()));
// Page ID (number not localised, as it's a database ID)
$pageInfo['header-basic'][] = array($this->msg('pageinfo-article-id'), $id);
// Language in which the page content is (supposed to be) written
$pageLang = $title->getPageLanguage()->getCode();
$pageInfo['header-basic'][] = array($this->msg('pageinfo-language'), Language::fetchLanguageName($pageLang, $lang->getCode()) . ' ' . $this->msg('parentheses', $pageLang));
// Search engine status
$pOutput = new ParserOutput();
if (isset($pageProperties['noindex'])) {
$pOutput->setIndexPolicy('noindex');
}
// Use robot policy logic
$policy = $this->page->getRobotPolicy('view', $pOutput);
$pageInfo['header-basic'][] = array($this->msg('pageinfo-robot-policy'), $this->msg("pageinfo-robot-{$policy['index']}"));
if (isset($pageCounts['views'])) {
// Number of views
$pageInfo['header-basic'][] = array($this->msg('pageinfo-views'), $lang->formatNum($pageCounts['views']));
}
if (isset($pageCounts['watchers'])) {
// Number of page watchers
$pageInfo['header-basic'][] = array($this->msg('pageinfo-watchers'), $lang->formatNum($pageCounts['watchers']));
}
// Redirects to this page
$whatLinksHere = SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText());
$pageInfo['header-basic'][] = array(Linker::link($whatLinksHere, $this->msg('pageinfo-redirects-name')->escaped(), array(), array('hidelinks' => 1, 'hidetrans' => 1)), $this->msg('pageinfo-redirects-value')->numParams(count($title->getRedirectsHere())));
// Is it counted as a content page?
if ($this->page->isCountable()) {
$pageInfo['header-basic'][] = array($this->msg('pageinfo-contentpage'), $this->msg('pageinfo-contentpage-yes'));
}
// Subpages of this page, if subpages are enabled for the current NS
if (MWNamespace::hasSubpages($title->getNamespace())) {
$prefixIndex = SpecialPage::getTitleFor('Prefixindex', $title->getPrefixedText() . '/');
$pageInfo['header-basic'][] = array(Linker::link($prefixIndex, $this->msg('pageinfo-subpages-name')->escaped()), $this->msg('pageinfo-subpages-value')->numParams($pageCounts['subpages']['total'], $pageCounts['subpages']['redirects'], $pageCounts['subpages']['nonredirects']));
}
// Page protection
$pageInfo['header-restrictions'] = array();
// Is this page effected by the cascading protection of something which includes it?
if ($title->isCascadeProtected()) {
$cascadingFrom = '';
$sources = $title->getCascadeProtectionSources();
// Array deferencing is in PHP 5.4 :(
foreach ($sources[0] as $sourceTitle) {
$cascadingFrom .= Html::rawElement('li', array(), Linker::linkKnown($sourceTitle));
}
$cascadingFrom = Html::rawElement('ul', array(), $cascadingFrom);
$pageInfo['header-restrictions'][] = array($this->msg('pageinfo-protect-cascading-from'), $cascadingFrom);
}
// Is out protection set to cascade to other pages?
if ($title->areRestrictionsCascading()) {
$pageInfo['header-restrictions'][] = array($this->msg('pageinfo-protect-cascading'), $this->msg('pageinfo-protect-cascading-yes'));
}
// Page protection
foreach ($title->getRestrictionTypes() as $restrictionType) {
$protectionLevel = implode(', ', $title->getRestrictions($restrictionType));
if ($protectionLevel == '') {
// Allow all users
$message = $this->msg('protect-default')->escaped();
//.........这里部分代码省略.........