本文整理汇总了PHP中OutputPage::getLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::getLanguage方法的具体用法?PHP OutputPage::getLanguage怎么用?PHP OutputPage::getLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPage
的用法示例。
在下文中一共展示了OutputPage::getLanguage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage $out, SkinTemplate $sk)
{
$config = $out->getConfig();
if (self::canOutputHreflang($config)) {
# Generate hreflang tags
$languageLinks = $out->getLanguageLinks();
if (empty($languageLinks)) {
// shortcut - if we don't have any language links, don't bother
return;
}
$addedLink = false;
$pages = $config->get("HreflangPages");
if (!$pages) {
$pages = array();
$foundPage = true;
} else {
$pages = array_flip($pages);
$pageName = $out->getLanguage()->getHtmlCode() . ":" . $out->getTitle()->getBaseText();
$foundPage = isset($pages[$pageName]);
}
foreach ($languageLinks as $languageLinkText) {
$languageLinkTitle = Title::newFromText($languageLinkText);
if (!$languageLinkTitle) {
continue;
}
$ilInterwikiCode = $languageLinkTitle->getInterwiki();
if (!Language::isKnownLanguageTag($ilInterwikiCode)) {
continue;
}
$foundPage = $foundPage || isset($pages[$languageLinkText]);
$tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => wfBCP47($ilInterwikiCode), 'href' => $languageLinkTitle->getFullURL()));
$addedLink = true;
}
// Only add current language link if we had any other links
if ($addedLink) {
$tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $out->getLanguage()->getHtmlCode(), 'href' => $out->getTitle()->getFullURL()));
}
}
if ($foundPage && $tags) {
$out->addHeadItem("hreflang:tags", join("\n", $tags));
}
}
示例2: beforePageDisplay
/**
* Adds feeds to the page header
*
* @param OutputPage $out
* @return bool
*/
public static function beforePageDisplay(OutputPage &$out)
{
global $wgAdvertisedFeedTypes;
if ($out->getTitle()->isMainPage()) {
foreach (self::getFeeds($out->getLanguage()->getCode()) as $feed) {
foreach ($wgAdvertisedFeedTypes as $type) {
$out->addLink(array('rel' => 'alternate', 'type' => "application/{$type}+xml", 'title' => $feed->title, 'href' => $feed->getURL($type)));
}
}
}
return true;
}
示例3: onBeforePageDisplay
static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
$languageLinks = $out->getLanguageLinks();
if (empty($languageLinks)) {
return true;
}
// this is partly a ripoff from SkinTemplate::getLanguages()
foreach ($languageLinks as $langLink) {
$languageLinkTitle = Title::newFromText($langLink);
$interwikiCode = $languageLinkTitle->getInterwiki();
$out->addLink(array('rel' => 'alternate', 'hreflang' => wfBCP47($interwikiCode), 'href' => wfExpandIRI($languageLinkTitle->getFullURL())));
}
// We also must add the current language
$currentPageLangCode = $out->getLanguage()->getCode();
$currentPageTitle = $out->getTitle();
$out->addLink(array('rel' => 'alternate', 'hreflang' => wfBCP47($currentPageLangCode), 'href' => wfExpandIRI($currentPageTitle->getFullURL())));
return true;
}
示例4: makeCustomURL
/**
* Build a load.php URL using OutputPage instance to get most of the required information
*
* @param OutputPage $out
* @param string|array $modules Module names
* @param string $only
* @param bool|string $user User name (true to get it from OutputPage)
* @param string $version
* @param array $extraQuery
* @return string
*/
public static function makeCustomURL(OutputPage $out, $modules, $only = ResourceLoaderModule::TYPE_COMBINED, $user = null, $version = null, $extraQuery = array())
{
if ($user === true) {
$user = $out->getUser()->getName();
} else {
if ($user === false || $user === null) {
$user = null;
} else {
$user = (string) $user;
}
}
$url = ResourceLoader::makeLoaderURL($modules, $out->getLanguage()->getCode(), $out->getSkin()->getSkinName(), $user, $version, ResourceLoader::inDebugMode(), $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only, $out->isPrintable(), $out->getRequest()->getBool('handheld'), $extraQuery);
return $url;
}
示例5: getHTML
/**
* @return string
*/
public function getHTML()
{
// Select: All, None, Invert
$links = [$this->checkboxLink('all'), $this->checkboxLink('none'), $this->checkboxLink('invert')];
return Html::rawElement('div', ['class' => 'mw-checkbox-toggle-controls'], $this->output->msg('checkbox-select')->rawParams($this->output->getLanguage()->commaList($links))->escaped());
}