Esempio n. 1
0
 /**
  * @param $unused Unused
  * @param $addContentType bool
  *
  * @return string HTML tag links to be put in the header.
  */
 public function getHeadLinks($unused = null, $addContentType = false)
 {
     global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgRightsPage, $wgRightsUrl, $wgDevelEnvironment, $wgStagingEnvironment;
     $tags = array();
     if ($addContentType) {
         if ($wgHtml5) {
             # More succinct than <meta http-equiv=Content-Type>, has the
             # same effect
             $tags[] = Html::element('meta', array('charset' => 'UTF-8'));
         } else {
             $tags[] = Html::element('meta', array('http-equiv' => 'Content-Type', 'content' => "{$wgMimeType}; charset=UTF-8"));
             $tags[] = Html::element('meta', array('http-equiv' => 'Content-Style-Type', 'content' => 'text/css'));
         }
     }
     $tags[] = Html::element('meta', array('name' => 'generator', 'content' => "MediaWiki {$wgVersion}"));
     $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
     // Wikia change - begin
     if (!empty($wgDevelEnvironment) || !empty($wgStagingEnvironment)) {
         $p = "noindex,nofollow";
     }
     // Wikia change - end
     if ($p !== 'index,follow') {
         // http://www.robotstxt.org/wc/meta-user.html
         // Only show if it's different from the default robots policy
         $tags[] = Html::element('meta', array('name' => 'robots', 'content' => $p));
     }
     if (count($this->mKeywords) > 0) {
         $strip = array("/<.*?" . ">/" => '', "/_/" => ' ');
         $tags[] = Html::element('meta', array('name' => 'keywords', 'content' => preg_replace(array_keys($strip), array_values($strip), implode(',', $this->mKeywords))));
     }
     foreach ($this->mMetatags as $tag) {
         if (0 == strcasecmp('http:', substr($tag[0], 0, 5))) {
             $a = 'http-equiv';
             $tag[0] = substr($tag[0], 5);
         } elseif (0 == strcasecmp('property:', substr($tag[0], 0, 9))) {
             $a = 'property';
             $tag[0] = substr($tag[0], 9);
         } else {
             $a = 'name';
         }
         $tags[] = Html::element('meta', array($a => $tag[0], 'content' => $tag[1]));
     }
     foreach ($this->mLinktags as $tag) {
         $tags[] = Html::element('link', $tag);
     }
     # Universal edit button
     if ($wgUniversalEditButton && $this->isArticleRelated()) {
         $user = $this->getUser();
         if ($this->getTitle()->quickUserCan('edit', $user) && ($this->getTitle()->exists() || $this->getTitle()->quickUserCan('create', $user))) {
             // Original UniversalEditButton
             $msg = $this->msg('edit')->text();
             $tags[] = Html::element('link', array('rel' => 'alternate', 'type' => 'application/x-wiki', 'title' => $msg, 'href' => $this->getTitle()->getLocalURL('action=edit')));
             // Alternate edit link
             $tags[] = Html::element('link', array('rel' => 'edit', 'title' => $msg, 'href' => $this->getTitle()->getLocalURL('action=edit')));
         }
     }
     # Generally the order of the favicon and apple-touch-icon links
     # should not matter, but Konqueror (3.5.9 at least) incorrectly
     # uses whichever one appears later in the HTML source. Make sure
     # apple-touch-icon is specified first to avoid this.
     if ($wgAppleTouchIcon !== false) {
         // Wikia change begin - @author: macbre
         $appleTouchIcon = wfReplaceImageServer($wgAppleTouchIcon, SassUtil::getCacheBuster());
         // Wikia change end
         $tags[] = Html::element('link', array('rel' => 'apple-touch-icon', 'href' => $appleTouchIcon));
     }
     $tags[] = Html::element('link', array('rel' => 'shortcut icon', 'href' => Wikia::getFaviconFullUrl()));
     # OpenSearch description link
     $tags[] = Html::element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => wfScript('opensearch_desc'), 'title' => $this->msg('opensearch-desc')->inContentLanguage()->text()));
     if ($wgEnableAPI) {
         # Real Simple Discovery link, provides auto-discovery information
         # for the MediaWiki API (and potentially additional custom API
         # support such as WordPress or Twitter-compatible APIs for a
         # blogging extension, etc)
         $tags[] = Html::element('link', array('rel' => 'EditURI', 'type' => 'application/rsd+xml', 'href' => wfExpandUrl(wfAppendQuery(wfScript('api'), array('action' => 'rsd')), PROTO_RELATIVE)));
     }
     # Language variants
     if (!$wgDisableLangConversion && $wgCanonicalLanguageLinks) {
         $lang = $this->getTitle()->getPageLanguage();
         if ($lang->hasVariants()) {
             $urlvar = $lang->getURLVariant();
             if (!$urlvar) {
                 $variants = $lang->getVariants();
                 foreach ($variants as $_v) {
                     $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $_v, 'href' => $this->getTitle()->getLocalURL(array('variant' => $_v))));
                 }
             } else {
                 $tags[] = Html::element('link', array('rel' => 'canonical', 'href' => $this->getTitle()->getCanonicalUrl()));
             }
         }
     }
     # Copyright
     $copyright = '';
     if ($wgRightsPage) {
         $copy = Title::newFromText($wgRightsPage);
         if ($copy) {
             $copyright = $copy->getLocalURL();
         }
     }
     if (!$copyright && $wgRightsUrl) {
         $copyright = $wgRightsUrl;
     }
     if ($copyright) {
         $tags[] = Html::element('link', array('rel' => 'copyright', 'href' => $copyright));
     }
     # Feeds
     if ($wgFeed) {
         foreach ($this->getSyndicationLinks() as $format => $link) {
             # Use the page name for the title.  In principle, this could
             # lead to issues with having the same name for different feeds
             # corresponding to the same page, but we can't avoid that at
             # this low a level.
             $tags[] = $this->feedLink($format, $link, $this->msg("page-{$format}-feed", $this->getTitle()->getPrefixedText())->text());
         }
         # Recent changes feed should appear on every page (except recentchanges,
         # that would be redundant). Put it after the per-page feed to avoid
         # changing existing behavior. It's still available, probably via a
         # menu in your browser. Some sites might have a different feed they'd
         # like to promote instead of the RC feed (maybe like a "Recent New Articles"
         # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
         # If so, use it instead.
         if ($wgOverrideSiteFeed) {
             foreach ($wgOverrideSiteFeed as $type => $feedUrl) {
                 // Note, this->feedLink escapes the url.
                 $tags[] = $this->feedLink($type, $feedUrl, $this->msg("site-{$type}-feed", $wgSitename)->text());
             }
         } elseif (!$this->getTitle()->isSpecial('Recentchanges')) {
             $rctitle = SpecialPage::getTitleFor('Recentchanges');
             foreach ($wgAdvertisedFeedTypes as $format) {
                 $tags[] = $this->feedLink($format, $rctitle->getLocalURL("feed={$format}"), $this->msg("site-{$format}-feed", $wgSitename)->text());
             }
         }
     }
     return implode("\n", $tags);
 }
 public function executeWordmarkTab()
 {
     $this->faviconUrl = Wikia::getFaviconFullUrl();
 }