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
0
 /**
  * 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;
 }
 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
0
 /**
  * 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
0
 /**
  * @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());
 }