array_push( $this->mMetatags, array( $name, $val ) );
}
- function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
- function addScript( $script ) { $this->mScripts .= "\t\t".$script; }
+ function addKeyword( $text ) {
+ if( is_array( $text )) {
+ $this->mKeywords = array_merge( $this->mKeywords, $text );
+ }
+ else {
+ array_push( $this->mKeywords, $text );
+ }
+ }
+ function addScript( $script ) { $this->mScripts .= "\t" . $script . "\n"; }
function addExtensionStyle( $url ) {
$linkarr = array( 'rel' => 'stylesheet', 'href' => $url, 'type' => 'text/css' );
*/
function addInlineScript( $script ) {
global $wgJsMimeType;
- $this->mScripts .= "<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n$script\n/*]]>*/</script>";
+ $this->mScripts .= "\t\t<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n\t\t$script\n\t\t/*]]>*/</script>\n";
}
function getScript() {
if ( array_key_exists( $category, $categories ) )
continue;
$text = $wgContLang->convertHtml( $title->getText() );
- $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
+ $this->mCategoryLinks[$type][] = $sk->link( $title, $text );
}
}
}
* @param bool $linestart
*/
public function addWikiText( $text, $linestart = true ) {
- $this->addWikiTextTitle( $text, $this->getTitle(), $linestart );
+ $title = $this->getTitle(); // Work arround E_STRICT
+ $this->addWikiTextTitle( $text, $title, $linestart );
}
public function addWikiTextWithTitle($text, &$title, $linestart = true) {
* @deprecated Use Article::outputWikitext
*/
public function addPrimaryWikiText( $text, $article, $cache = true ) {
- global $wgParser, $wgUser;
+ global $wgParser;
wfDeprecated( __METHOD__ );
* Add wikitext with tidy enabled
*/
public function addWikiTextTidy( $text, $linestart = true ) {
- $this->addWikiTextTitleTidy($text, $this->getTitle(), $linestart);
+ $title = $this->getTitle();
+ $this->addWikiTextTitleTidy($text, $title, $linestart);
}
/**
* @param Article $article
* @param User $user
+ *
+ * @deprecated
*
* @return bool True if successful, else false.
*/
public function tryParserCache( &$article ) {
- $parserCache = ParserCache::singleton();
- $parserOutput = $parserCache->get( $article, $this->parserOptions() );
- if ( $parserOutput !== false ) {
+ wfDeprecated( __METHOD__ );
+ $parserOutput = ParserCache::singleton()->get( $article, $article->getParserOptions() );
+
+ if ($parserOutput !== false) {
$this->addParserOutput( $parserOutput );
return true;
} else {
*/
public static function setEncodings() {
global $wgInputEncoding, $wgOutputEncoding;
- global $wgUser, $wgContLang;
+ global $wgContLang;
$wgInputEncoding = strtolower( $wgInputEncoding );
* @param string $permission key required
*/
public function permissionRequired( $permission ) {
- global $wgUser, $wgLang;
+ global $wgLang;
$this->setPageTitle( wfMsg( 'badaccess' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setArticleFlag( false );
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
- $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $this->getTitle()->getPrefixedUrl() );
+ $loginLink = $skin->link(
+ $loginTitle,
+ wfMsgHtml( 'loginreqlink' ),
+ array(),
+ array( 'returnto' => $this->getTitle()->getPrefixedText() ),
+ array( 'known', 'noclasses' )
+ );
$this->addHTML( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
$this->addHTML( "\n<!--" . $this->getTitle()->getPrefixedUrl() . "-->" );
$text = wfMsgNoTrans( 'permissionserrorstext', count($errors)). "\n\n";
} else {
global $wgLang;
- $action_desc = wfMsg( "action-$action" );
+ $action_desc = wfMsgNoTrans( "action-$action" );
$text = wfMsgNoTrans( 'permissionserrorstext-withaction', count($errors), $action_desc ) . "\n\n";
}
}
$text .= '</ul>';
} else {
- $text .= '<div class="permissions-errors">' . call_user_func_array( 'wfMsgNoTrans', reset( $errors ) ) . '</div>';
+ $text .= "<div class=\"permissions-errors\">\n" . call_user_func_array( 'wfMsgNoTrans', reset( $errors ) ) . "\n</div>";
}
return $text;
// Permissions error
if( $source ) {
$this->setPageTitle( wfMsg( 'viewsource' ) );
- $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $this->getTitle() ) ) );
+ $this->setSubtitle(
+ wfMsg(
+ 'viewsourcefor',
+ $skin->link(
+ $this->getTitle(),
+ null,
+ array(),
+ array(),
+ array( 'known', 'noclasses' )
+ )
+ )
+ );
} else {
$this->setPageTitle( wfMsg( 'badaccess' ) );
}
public function addReturnTo( $title ) {
global $wgUser;
$this->addLink( array( 'rel' => 'next', 'href' => $title->getFullUrl() ) );
- $link = wfMsg( 'returnto', $wgUser->getSkin()->makeLinkObj( $title ) );
- $this->addHTML( "<p>{$link}</p>\n" );
+ $link = wfMsgHtml( 'returnto', $wgUser->getSkin()->link( $title ) );
+ $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
}
/**
}
/**
- * This function takes the title (first item of mGoodLinks), categories, existing and broken links for the page
+ * This function takes the title (first item of mGoodLinks), categories,
+ * existing and broken links for the page
* and uses the first 10 of them for META keywords
*
* @param ParserOutput &$parserOutput
*/
private function addKeywords( &$parserOutput ) {
- $this->addKeyword( $this->getTitle()->getPrefixedText() );
+ global $wgContLang;
+ // Get an array of keywords if there are more than one
+ // variant of the site language
+ $text = $wgContLang->autoConvertToAllVariants( $this->getTitle()->getPrefixedText());
+ // array_values: We needn't to merge variant's code name
+ // into $this->mKeywords;
+ // array_unique: We should insert a keyword just for once
+ if( is_array( $text ))
+ $text = array_unique( array_values( $text ));
+ $this->addKeyword( $text );
$count = 1;
$links2d =& $parserOutput->getLinks();
if ( !is_array( $links2d ) ) {
}
foreach ( $links2d as $dbkeys ) {
foreach( $dbkeys as $dbkey => $unused ) {
+ $dbkey = $wgContLang->autoConvertToAllVariants( $dbkey );
+ if( is_array( $dbkey ))
+ $dbkey = array_unique( array_values( $dbkey ));
$this->addKeyword( $dbkey );
if ( ++$count > 10 ) {
break 2;
public function headElement( Skin $sk ) {
global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
- global $wgUser, $wgContLang, $wgUseTrackbacks, $wgStyleVersion;
+ global $wgContLang, $wgUseTrackbacks, $wgStyleVersion;
- $this->addMeta( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" );
- $this->addStyle( 'common/wikiprintable.css', 'print' );
+ $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
+ if ( $sk->commonPrintStylesheet() ) {
+ $this->addStyle( 'common/wikiprintable.css', 'print' );
+ }
$sk->setupUserCss( $this );
$ret = '';
$ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
}
- $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
+ $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
if ( '' == $this->getHTMLTitle() ) {
$this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
}
- $rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
+ $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$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(
+ $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
+ $ret .= "<head>\n\t<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n\t";
+ $ret .= implode( "\n", array(
$this->getHeadLinks(),
$this->buildCssLinks(),
- $sk->getHeadScripts( $this->mAllowUserJs ),
- $this->mScripts,
+ $sk->getHeadScripts( $this->mAllowUserJs, $this->mScripts ),
$this->getHeadItems(),
));
if( $sk->usercss ){
protected function addDefaultMeta() {
global $wgVersion;
+
+ static $called = false;
+ if ( $called ) {
+ # Don't run this twice
+ return;
+ }
+ $called = true;
+
$this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
$this->addMeta( 'generator', "MediaWiki $wgVersion" );
}
}
- return implode( "\n\t\t", $tags ) . "\n";
+ return implode( "\n\t", $tags ) . "\n";
}
/**
$links[] = $link;
}
- return implode( "\n\t\t", $links );
+ return "\t" . implode( "\n\t", $links );
}
protected function styleLink( $style, $options ) {
*
* In the $wrap, $1 is replaced with the first message, $2 with the second, and so
* on. The subsequent arguments may either be strings, in which case they are the
- * message names, or an arrays, in which case the first element is the message name,
+ * message names, or arrays, in which case the first element is the message name,
* and subsequent elements are the parameters to that message.
*
* The special named parameter 'options' in a message specification array is passed