/** * @return string The doctype, opening <html>, and head element. */ public function headElement(Skin $sk) { global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces; global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion; $this->addMeta("http:Content-type", "{$wgMimeType}; charset={$wgOutputEncoding}"); $this->addStyle('common/wikiprintable.css', 'print'); $sk->setupUserCss($this); $ret = ''; if ($wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml') { $ret .= "<?xml version=\"1.0\" encoding=\"{$wgOutputEncoding}\" ?>\n"; } $ret .= "<!DOCTYPE html PUBLIC \"{$wgDocType}\"\n \"{$wgDTD}\">\n"; if ('' == $this->getHTMLTitle()) { $this->setHTMLTitle(wfMsg('pagetitle', $this->getPageTitle())); } $rtl = $wgContLang->isRTL() ? " dir='RTL'" : ''; $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" "; foreach ($wgXhtmlNamespaces as $tag => $ns) { $ret .= "xmlns:{$tag}=\"{$ns}\" "; } $ret .= "xml:lang=\"{$wgContLanguageCode}\" lang=\"{$wgContLanguageCode}\" {$rtl}>\n"; $ret .= "<head>\n<title>" . htmlspecialchars($this->getHTMLTitle()) . "</title>\n\t\t"; $ret .= implode("\t\t", array($this->getHeadLinks(), $this->buildCssLinks(), $sk->getHeadScripts($this->mAllowUserJs), $this->mScripts, $this->getHeadItems())); if ($sk->usercss) { $ret .= "<style type='text/css'>{$sk->usercss}</style>"; } if ($wgUseTrackbacks && $this->isArticleRelated()) { $ret .= $wgTitle->trackbackRDF(); } $ret .= "</head>\n"; return $ret; }
/** * @param $sk Skin The given Skin * @param $includeStyle Unused (?) * @return String: The doctype, opening <html>, and head element. */ public function headElement(Skin $sk, $includeStyle = true) { global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version; global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5, $wgWellFormedXml; global $wgUser, $wgRequest, $wgLang; $this->addMeta("http:Content-Type", "{$wgMimeType}; charset={$wgOutputEncoding}"); if ($sk->commonPrintStylesheet()) { $this->addStyle('common/wikiprintable.css', 'print'); } $sk->setupUserCss($this); $ret = ''; if ($wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml') { $ret .= "<?xml version=\"1.0\" encoding=\"{$wgOutputEncoding}\" ?" . ">\n"; } if ($this->getHTMLTitle() == '') { $this->setHTMLTitle(wfMsg('pagetitle', $this->getPageTitle())); } $dir = $wgContLang->getDir(); if ($wgHtml5) { if ($wgWellFormedXml) { # Unknown elements and attributes are okay in XML, but unknown # named entities are well-formedness errors and will break XML # parsers. Thus we need a doctype that gives us appropriate # entity definitions. The HTML5 spec permits four legacy # doctypes as obsolete but conforming, so let's pick one of # those, although it makes our pages look like XHTML1 Strict. # Isn't compatibility great? $ret .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; } else { # Much saner. $ret .= "<!doctype html>\n"; } $ret .= "<html lang=\"{$wgContLanguageCode}\" dir=\"{$dir}\""; if ($wgHtml5Version) { $ret .= " version=\"{$wgHtml5Version}\""; } $ret .= ">\n"; } else { $ret .= "<!DOCTYPE html PUBLIC \"{$wgDocType}\" \"{$wgDTD}\">\n"; $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" "; foreach ($wgXhtmlNamespaces as $tag => $ns) { $ret .= "xmlns:{$tag}=\"{$ns}\" "; } $ret .= "lang=\"{$wgContLanguageCode}\" dir=\"{$dir}\">\n"; } $ret .= "<head>\n"; $ret .= "<title>" . htmlspecialchars($this->getHTMLTitle()) . "</title>\n"; $ret .= implode("\n", array($this->getHeadLinks(), $this->buildCssLinks(), $this->getHeadScripts($sk), $this->getHeadItems())); if ($sk->usercss) { $ret .= Html::inlineStyle($sk->usercss); } if ($wgUseTrackbacks && $this->isArticleRelated()) { $ret .= $this->getTitle()->trackbackRDF(); } $ret .= "</head>\n"; $bodyAttrs = array(); # Crazy edit-on-double-click stuff $action = $wgRequest->getVal('action', 'view'); if ($this->getTitle()->getNamespace() != NS_SPECIAL && !in_array($action, array('edit', 'submit')) && $wgUser->getOption('editondblclick')) { $bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString($this->getTitle()->getEditURL()) . "'"; } # Class bloat $bodyAttrs['class'] = "mediawiki {$dir}"; if ($wgLang->capitalizeAllNouns()) { # A <body> class is probably not the best way to do this . . . $bodyAttrs['class'] .= ' capitalize-all-nouns'; } $bodyAttrs['class'] .= ' ns-' . $this->getTitle()->getNamespace(); if ($this->getTitle()->getNamespace() == NS_SPECIAL) { $bodyAttrs['class'] .= ' ns-special'; } elseif ($this->getTitle()->isTalkPage()) { $bodyAttrs['class'] .= ' ns-talk'; } else { $bodyAttrs['class'] .= ' ns-subject'; } $bodyAttrs['class'] .= ' ' . Sanitizer::escapeClass('page-' . $this->getTitle()->getPrefixedText()); $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass($wgUser->getSkin()->getSkinName()); $ret .= Html::openElement('body', $bodyAttrs) . "\n"; return $ret; }
/** * @param $sk Skin The given Skin * @param $includeStyle Boolean: unused * @return String: The doctype, opening <html>, and head element. */ public function headElement(Skin $sk, $includeStyle = true) { global $wgContLang, $wgUseTrackbacks; $userdir = $this->getLang()->getDir(); $sitedir = $wgContLang->getDir(); if ($sk->commonPrintStylesheet()) { $this->addModuleStyles('mediawiki.legacy.wikiprintable'); } $sk->setupUserCss($this); $ret = Html::htmlHeader(array('lang' => $this->getLang()->getCode(), 'dir' => $userdir, 'class' => 'client-nojs')); if ($this->getHTMLTitle() == '') { $this->setHTMLTitle(wfMsg('pagetitle', $this->getPageTitle())); } $openHead = Html::openElement('head'); if ($openHead) { # Don't bother with the newline if $head == '' $ret .= "{$openHead}\n"; } $ret .= Html::element('title', null, $this->getHTMLTitle()) . "\n"; $ret .= implode("\n", array($this->getHeadLinks($sk, true), $this->buildCssLinks($sk), $this->getHeadScripts($sk), $this->getHeadItems())); if ($wgUseTrackbacks && $this->isArticleRelated()) { $ret .= $this->getTitle()->trackbackRDF(); } $closeHead = Html::closeElement('head'); if ($closeHead) { $ret .= "{$closeHead}\n"; } $bodyAttrs = array(); # Crazy edit-on-double-click stuff $action = $this->getRequest()->getVal('action', 'view'); if ($this->getTitle()->getNamespace() != NS_SPECIAL && in_array($action, array('view', 'purge')) && $this->getUser()->getOption('editondblclick')) { $editUrl = $this->getTitle()->getLocalUrl($sk->editUrlOptions()); $bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString($editUrl) . "'"; } # Classes for LTR/RTL directionality support $bodyAttrs['class'] = "mediawiki {$userdir} sitedir-{$sitedir}"; if ($this->getContext()->getLang()->capitalizeAllNouns()) { # A <body> class is probably not the best way to do this . . . $bodyAttrs['class'] .= ' capitalize-all-nouns'; } $bodyAttrs['class'] .= ' ' . $sk->getPageClasses($this->getTitle()); $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass($sk->getSkinName()); $sk->addToBodyAttributes($this, $bodyAttrs); // Allow skins to add body attributes they need wfRunHooks('OutputPageBodyAttributes', array($this, $sk, &$bodyAttrs)); $ret .= Html::openElement('body', $bodyAttrs) . "\n"; return $ret; }
/** * @param $sk Skin The given Skin * @param $includeStyle Boolean: unused * @return String: The doctype, opening <html>, and head element. */ public function headElement(Skin $sk, $includeStyle = true) { global $wgOutputEncoding, $wgMimeType; global $wgUseTrackbacks, $wgHtml5; global $wgUser, $wgRequest, $wgLang; if ($sk->commonPrintStylesheet()) { $this->addModuleStyles('mediawiki.legacy.wikiprintable'); } $sk->setupUserCss($this); $lang = wfUILang(); $ret = Html::htmlHeader(array('lang' => $lang->getCode(), 'dir' => $lang->getDir())); if ($this->getHTMLTitle() == '') { $this->setHTMLTitle(wfMsg('pagetitle', $this->getPageTitle())); } $openHead = Html::openElement('head'); if ($openHead) { # Don't bother with the newline if $head == '' $ret .= "{$openHead}\n"; } if ($wgHtml5) { # More succinct than <meta http-equiv=Content-Type>, has the # same effect $ret .= Html::element('meta', array('charset' => $wgOutputEncoding)) . "\n"; } else { $this->addMeta('http:Content-Type', "{$wgMimeType}; charset={$wgOutputEncoding}"); } $ret .= Html::element('title', null, $this->getHTMLTitle()) . "\n"; $ret .= implode("\n", array($this->getHeadLinks($sk), $this->buildCssLinks($sk), $this->getHeadItems())); if ($wgUseTrackbacks && $this->isArticleRelated()) { $ret .= $this->getTitle()->trackbackRDF(); } $closeHead = Html::closeElement('head'); if ($closeHead) { $ret .= "{$closeHead}\n"; } $bodyAttrs = array(); # Crazy edit-on-double-click stuff $action = $wgRequest->getVal('action', 'view'); if ($this->getTitle()->getNamespace() != NS_SPECIAL && !in_array($action, array('edit', 'submit')) && $wgUser->getOption('editondblclick')) { $editUrl = $this->getTitle()->getLocalUrl($sk->editUrlOptions()); $bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString($editUrl) . "'"; } # Class bloat $dir = wfUILang()->getDir(); $bodyAttrs['class'] = "mediawiki {$dir}"; if ($wgLang->capitalizeAllNouns()) { # A <body> class is probably not the best way to do this . . . $bodyAttrs['class'] .= ' capitalize-all-nouns'; } $bodyAttrs['class'] .= ' ns-' . $this->getTitle()->getNamespace(); if ($this->getTitle()->getNamespace() == NS_SPECIAL) { $bodyAttrs['class'] .= ' ns-special'; } elseif ($this->getTitle()->isTalkPage()) { $bodyAttrs['class'] .= ' ns-talk'; } else { $bodyAttrs['class'] .= ' ns-subject'; } $bodyAttrs['class'] .= ' ' . Sanitizer::escapeClass('page-' . $this->getTitle()->getPrefixedText()); $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass($wgUser->getSkin()->getSkinName()); $sk->addToBodyAttributes($this, $bodyAttrs); // Allow skins to add body attributes they need wfRunHooks('OutputPageBodyAttributes', array($this, $sk, &$bodyAttrs)); $ret .= Html::openElement('body', $bodyAttrs) . "\n"; return $ret; }