当前位置: 首页>>代码示例>>PHP>>正文


PHP OutputPage::getLanguage方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:smalyshev,项目名称:Hreflang-extension,代码行数:42,代码来源:Hreflang.hooks.php

示例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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:FeaturedFeeds.body.php

示例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;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-AltLangRelLinks,代码行数:18,代码来源:AltLangRelLinks.php

示例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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:ResourceLoader.php

示例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());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:9,代码来源:ListToggle.php


注:本文中的OutputPage::getLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。