return true;
}
+ /**
+ * Override the last modified timestamp
+ *
+ * @param $timestamp String: new timestamp, in a format readable by
+ * wfTimestamp()
+ */
+ public function setLastModified( $timestamp ) {
+ $this->mLastModified = wfTimestamp( TS_RFC2822, $timestamp );
+ }
+
/**
* Set the robot policy for the page: <http://www.robotstxt.org/meta.html>
}
/**
- * "HTML title" means the contents of <title>. It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.
+ * "HTML title" means the contents of <title>.
+ * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.
*/
public function setHTMLTitle( $name ) {
$this->mHTMLtitle = $name;
$this->mTemplateIds[$ns] = $dbks;
}
}
- // Page title
- $title = $parserOutput->getTitleText();
- if ( $title != '' ) {
- $this->setPageTitle( $title );
- }
// Hooks registered in the object
global $wgParserOutputHooks;
* For example:
* /w/index.php?title=Main_page should always be served; but
* /w/index.php?title=Main_page&variant=zh-cn should never be served.
- *
- * patched by Liangent and Philip
*/
function addAcceptLanguage() {
global $wgRequest, $wgContLang;
// Wiki is read only
$this->setPageTitle( wfMsg( 'readonly' ) );
$reason = wfReadOnlyReason();
- $this->wrapWikiMsg( '<div class="mw-readonly-error">\n$1</div>', array( 'readonlytext', $reason ) );
+ $this->wrapWikiMsg( "<div class='mw-readonly-error'>\n$1</div>", array( 'readonlytext', $reason ) );
}
// Show source, if supplied
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' );
}
}
if ( $this->getHTMLTitle() == '' ) {
- $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
+ $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
}
$dir = $wgContLang->getDir();
+ $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir );
if ( $wgHtml5 ) {
if ( $wgWellFormedXml ) {
# Unknown elements and attributes are okay in XML, but unknown
# Much saner.
$ret .= "<!doctype html>\n";
}
- $ret .= "<html lang=\"$wgContLanguageCode\" dir=\"$dir\"";
- if ( $wgHtml5Version ) $ret .= " version=\"$wgHtml5Version\"";
- $ret .= ">\n";
+ if ( $wgHtml5Version ) {
+ $htmlAttribs['version'] = $wgHtml5Version;
+ }
} else {
$ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
- $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
- foreach($wgXhtmlNamespaces as $tag => $ns) {
- $ret .= "xmlns:{$tag}=\"{$ns}\" ";
+ $htmlAttribs['xmlns'] = $wgXhtmlDefaultNamespace;
+ foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
+ $htmlAttribs["xmlns:$tag"] = $ns;
}
- $ret .= "lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
+ $this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" );
}
+ $ret .= Html::openElement( 'html', $htmlAttribs ) . "\n";
- $ret .= "<head>\n";
+ $openHead = Html::openElement( 'head' );
+ if ( $openHead ) {
+ # Don't bother with the newline if $head == ''
+ $ret .= "$openHead\n";
+ }
$ret .= "<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
+
+ if ( $wgHtml5 ) {
+ # More succinct than <meta http-equiv=Content-Type>, has the
+ # same effect
+ $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n";
+ }
+
$ret .= implode( "\n", array(
$this->getHeadLinks(),
$this->buildCssLinks(),
$this->getHeadScripts( $sk ),
$this->getHeadItems(),
- ));
- if( $sk->usercss ){
+ ) );
+ if ( $sk->usercss ) {
$ret .= Html::inlineStyle( $sk->usercss );
}
- if ($wgUseTrackbacks && $this->isArticleRelated())
+ if ( $wgUseTrackbacks && $this->isArticleRelated() ) {
$ret .= $this->getTitle()->trackbackRDF();
+ }
- $ret .= "</head>\n";
+ $closeHead = Html::closeElement( 'head' );
+ if ( $closeHead ) {
+ $ret .= "$closeHead\n";
+ }
$bodyAttrs = array();