* @private
*/
function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
+ $list = '';
if ( count ( $articles ) > $cutoff ) {
$list = self::columnList( $articles, $articles_start_char );
} elseif ( count( $articles ) > 0 ) {
// for short lists of articles in categories.
$list = self::shortList( $articles, $articles_start_char );
}
- global $wgBetterDirectionality;
+ global $wgBetterDirectionality, $wgTitle;
if( $wgBetterDirectionality ) {
- global $wgOut, $wgContLang;
- $getPageLang = $wgOut->parserOptions()->getTargetLanguage();
- $pageLang = ( $getPageLang ? Language::factory( $getPageLang ) : $wgContLang );
- $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
- $list = Html::rawElement( 'div', $realBodyAttribs, $list );
+ $pageLang = $wgTitle->getPageLanguage();
+ $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
+ $list = Html::rawElement( 'div', $attribs, $list );
}
return $list;
global $wgBetterDirectionality, $wgContLang;
if( $wgBetterDirectionality ) {
- $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle );
- $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
+ $pageLang = $this->mTitle->getPageLanguage();
$attribs['lang'] = $pageLang->getCode();
$attribs['dir'] = $pageLang->getDir();
}
wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
+ // In which language to parse the page
+ // (Should this still be only for MediaWiki pages, or for all pages?)
+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
+ $parserOptions->setTargetLanguage( $this->mTitle->getPageLanguage() );
+ }
+ $parserOptions->setTargetLanguage( $this->mTitle->getPageLanguage() );
$parserOptions->setTidy( true );
$parserOptions->enableLimitReport();
$parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
'<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" .
$wgOut->parse( $note ) . $conflict . "</div>\n";
- global $wgBetterDirectionality, $wgContLang;
+ global $wgBetterDirectionality;
if( $wgBetterDirectionality ) {
- $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $this->mTitle );
- $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
- $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
- $previewHTML = Html::rawElement( 'div', $realBodyAttribs, $previewHTML );
+ $pageLang = $this->mTitle->getPageLanguage();
+ $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
+ $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML );
}
wfProfileOut( __METHOD__ );
return $previewhead . $previewHTML . $this->previewTextAfterContent;
if( $this->getTitle()->getNamespace() != NS_SPECIAL &&
in_array( $action, array( 'view', 'render', 'print' ) ) &&
( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) {
- $getPageLang = $out->parserOptions()->getTargetLanguage( $this->getTitle() );
- $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
+ $pageLang = $this->getTitle()->getPageLanguage();
$realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() );
$out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
}
var $mRedirect = null; // /< Is the article at this title a redirect?
var $mNotificationTimestamp = array(); // /< Associative array of user ID -> timestamp/false
var $mBacklinkCache = null; // /< Cache of links to this title
+ var $mPageLanguage;
// @}
}
return $unprefixed;
}
+
+ /**
+ * Get the language this page is written in
+ * Defaults to $wgContLang
+ *
+ * @return object Language
+ */
+ public function getPageLanguage() {
+ global $wgContLang;
+ $this->mPageLanguage = $wgContLang;
+ if ( $this->isCssOrJsPage() ) {
+ // css/js should always be LTR and is, in fact, English
+ $this->mPageLanguage = Language::factory( 'en' );
+ } elseif ( $this->getNamespace() == NS_MEDIAWIKI ) {
+ // Parse mediawiki messages with correct target language
+ list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->getText() );
+ $this->mPageLanguage = wfGetLangObj( $lang );
+ }
+ return $this->mPageLanguage;
+ }
}
/**
* @return string
*/
static function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) {
- global $wgBetterDirectionality;
+ global $wgBetterDirectionality, $wgTitle;
$dirclass = '';
if( $wgBetterDirectionality ) {
- global $wgContLang, $wgOut, $wgTitle;
// shared.css sets diff in interface language/dir,
// but the actual content should be in the page language/dir
- $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $wgTitle );
- $pageLang = ( $getPageLang ? $getPageLang : $wgContLang );
+ $pageLang = $wgTitle->getPageLanguage();
$dirclass = ' diff-contentalign-'.$pageLang->alignStart();
}
$header = "<table class='diff $dirclass'>";
function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
function getTidy() { return $this->mTidy; }
function getInterfaceMessage() { return $this->mInterfaceMessage; }
- function getTargetLanguage( $title = null ) {
- if ( $title && $title->isCssOrJsPage() ) {
- return Language::factory( 'en' ); // css/js should always be LTR
- } elseif ( $title && $title->getNamespace() == NS_MEDIAWIKI ) {
- // Parse mediawiki messages with correct target language
- list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
- $obj = wfGetLangObj( $lang );
- return $obj;
- }
- return $this->mTargetLanguage;
-}
+ function getTargetLanguage() { return $this->mTargetLanguage; }
function getMaxIncludeSize() { return $this->mMaxIncludeSize; }
function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; }
function getMaxPPExpandDepth() { return $this->mMaxPPExpandDepth; }