From 7c624542f0098899da5e0c9618f974955b80c2d7 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Wed, 6 Jul 2011 02:26:06 +0000 Subject: [PATCH] (bug 6100; follow-up to r91315) Being bold and removing $wgBetterDirectionality (and dependent wfUILang) in core, as most or all work is finished. Also: * Introduce classes mw-float-end, mw-float-start so we don't have to use inline css depending on wfUILang()/$wgLang (see HistoryPage and SpecialFileDuplicateSearch) * Add direction mark to protection log * Remove specialpageattributes as it is obsoleted by this commit (also fixes bug 28572) * Add two direction marks in wfSpecialList, which makes ltr links on rtl wiki (and vice versa) display nicely as well (only on those special pages however) * Revert r91340 partially: use mw-content-ltr/rtl class anyway in shared.css. Both ways have their [dis]advantages... * Set the direction of input fields by default to the content language direction (except buttons etc.) in shared.css --- RELEASE-NOTES-1.19 | 4 +- includes/Article.php | 6 +-- includes/CategoryPage.php | 26 ++++------ includes/ChangesList.php | 9 ++-- includes/DefaultSettings.php | 7 ++- includes/EditPage.php | 21 +++----- includes/GlobalFunctions.php | 28 ++++++---- includes/HistoryPage.php | 6 +-- includes/ImagePage.php | 6 +-- includes/LogEventsList.php | 3 +- includes/LogPage.php | 2 +- includes/OutputPage.php | 17 +++--- includes/Pager.php | 4 +- includes/SkinTemplate.php | 52 ++++++++----------- includes/diff/DifferenceEngine.php | 12 ++--- .../resourceloader/ResourceLoaderContext.php | 7 +-- includes/specials/SpecialAllmessages.php | 3 +- includes/specials/SpecialBrokenRedirects.php | 2 +- includes/specials/SpecialContributions.php | 4 +- includes/specials/SpecialDisambiguations.php | 4 +- includes/specials/SpecialDoubleRedirects.php | 4 +- .../specials/SpecialFileDuplicateSearch.php | 4 +- includes/specials/SpecialListredirects.php | 3 +- includes/specials/SpecialNewpages.php | 2 +- includes/specials/SpecialProtectedpages.php | 4 +- includes/specials/SpecialShortpages.php | 2 +- includes/specials/SpecialWhatlinkshere.php | 4 +- languages/Language.php | 8 ++- skins/Modern.php | 2 +- skins/MonoBook.php | 2 +- skins/Vector.php | 6 +-- skins/common/shared.css | 45 +++++++++++----- 32 files changed, 162 insertions(+), 147 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index fcb8b39d5b..4b09da318a 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -139,8 +139,8 @@ production. * Make sure Backlink cache does not retrieve interwiki redirects when looking for redirects to a local page. * (bug 6100) Allow different directionality (LTR/RTL) for user interface - and wiki content, when $wgBetterDirectionality is enabled, along with - many RTL improvements (such as bugs 28030, 12406, 28349) + and wiki content, along with many other RTL and directionality improvements + (such as bugs 28030, 12406, 28349) * (bug 29712) Removed broken defaultUserOptionOverrides in MessagesXx files and unneeded CSS flipping of quickbar. Instead, introduce option 5 which sets left/right according to the directionality of your interface language. diff --git a/includes/Article.php b/includes/Article.php index 585dfd9160..84bb07a7db 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1043,13 +1043,13 @@ class Article extends Page { * @return string containing HMTL with redirect link */ public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { - global $wgOut, $wgStylePath; + global $wgOut, $wgLang, $wgStylePath; if ( !is_array( $target ) ) { $target = array( $target ); } - $imageDir = wfUILang()->getDir(); + $imageDir = $wgLang->getDir(); if ( $appendSubtitle ) { $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) ); @@ -1065,7 +1065,7 @@ class Article extends Page { } $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png'; - $alt = wfUILang()->isRTL() ? '←' : '→'; + $alt = $wgLang->isRTL() ? '←' : '→'; // Automatically append redirect=no to each link, since most of them are redirect pages themselves. foreach ( $target as $rt ) { $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) ); diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 7d072993e1..850256f071 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -143,7 +143,7 @@ class CategoryViewer { * @return string HTML output */ public function getHTML() { - global $wgOut, $wgCategoryMagicGallery, $wgContLang, $wgBetterDirectionality; + global $wgOut, $wgCategoryMagicGallery, $wgContLang; wfProfileIn( __METHOD__ ); $this->showGallery = $wgCategoryMagicGallery && !$wgOut->mNoGallery; @@ -174,13 +174,11 @@ class CategoryViewer { $r = wfMsgExt( 'category-empty', array( 'parse' ) ); } - if( $wgBetterDirectionality ) { - $pageLang = $this->title->getPageLanguage(); - $langAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); - # close the previous div, show the headings in user language, - # then open a new div with the page content language again - $r = '' . $r . Html::openElement( 'div', $langAttribs ); - } + $pageLang = $this->title->getPageLanguage(); + $langAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); + # close the previous div, show the headings in user language, + # then open a new div with the page content language again + $r = '' . $r . Html::openElement( 'div', $langAttribs ); wfProfileOut( __METHOD__ ); return $wgContLang->convert( $r ); @@ -492,8 +490,6 @@ class CategoryViewer { * @private */ function formatList( $articles, $articles_start_char, $cutoff = 6 ) { - global $wgBetterDirectionality; - $list = ''; if ( count ( $articles ) > $cutoff ) { $list = self::columnList( $articles, $articles_start_char ); @@ -502,12 +498,10 @@ class CategoryViewer { $list = self::shortList( $articles, $articles_start_char ); } - if( $wgBetterDirectionality ) { - $pageLang = $this->title->getPageLanguage(); - $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), - 'class' => 'mw-content-'.$pageLang->getDir() ); - $list = Html::rawElement( 'div', $attribs, $list ); - } + $pageLang = $this->title->getPageLanguage(); + $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-'.$pageLang->getDir() ); + $list = Html::rawElement( 'div', $attribs, $list ); return $list; } diff --git a/includes/ChangesList.php b/includes/ChangesList.php index e8698b4cc4..55e9403103 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -323,6 +323,7 @@ class ChangesList { * @return void */ public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) { + global $wgLang; # If it's a new article, there is no diff link, but if it hasn't been # patrolled yet, we need to give users a way to do so $params = array(); @@ -354,7 +355,7 @@ class ChangesList { $articlelink = "{$articlelink}"; } # RTL/LTR marker - $articlelink .= wfUILang()->getDirMark(); + $articlelink .= $wgLang->getDirMark(); wfRunHooks( 'ChangesListInsertArticleLink', array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) ); @@ -590,7 +591,7 @@ class OldChangesList extends ChangesList { # User tool links $this->insertUserRelatedLinks( $s, $rc ); # LTR/RTL direction mark - $s .= wfUILang()->getDirMark(); + $s .= $wgLang->getDirMark(); # Log action text (if any) $this->insertAction( $s, $rc ); # Edit or log comment @@ -868,7 +869,7 @@ class EnhancedChangesList extends ChangesList { $users = array(); foreach( $userlinks as $userlink => $count) { $text = $userlink; - $text .= wfUILang()->getDirMark(); + $text .= $wgLang->getDirMark(); if( $count > 1 ) { $text .= ' (' . $wgLang->formatNum( $count ) . '×)'; } @@ -910,7 +911,7 @@ class EnhancedChangesList extends ChangesList { $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched ); } - $r .= wfUILang()->getDirMark(); + $r .= $wgLang->getDirMark(); $queryParams['curid'] = $curId; # Changes message diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index cf92dd42a7..8dbe338920 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2408,9 +2408,12 @@ $wgVectorShowVariantName = false; $wgEdititis = false; /** - * Experimental better directionality support. + * Better directionality support (bug 6100 and related). + * Removed in 1.19, still kept here for LiquidThreads backwards compatibility. + * + * @deprecated since 1.19 */ -$wgBetterDirectionality = false; +$wgBetterDirectionality = true; /** @} */ # End of output format settings } diff --git a/includes/EditPage.php b/includes/EditPage.php index a62cbfe5ce..a17b4b1377 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1814,12 +1814,9 @@ HTML 'style' => '' // avoid php notices when appending preferences (appending allows customAttribs['style'] to still work ); - global $wgBetterDirectionality; - if( $wgBetterDirectionality ) { - $pageLang = $this->mTitle->getPageLanguage(); - $attribs['lang'] = $pageLang->getCode(); - $attribs['dir'] = $pageLang->getDir(); - } + $pageLang = $this->mTitle->getPageLanguage(); + $attribs['lang'] = $pageLang->getCode(); + $attribs['dir'] = $pageLang->getDir(); $wgOut->addHTML( Html::textarea( $name, $wikitext, $attribs ) ); } @@ -2095,13 +2092,11 @@ HTML '

' . htmlspecialchars( wfMsg( 'preview' ) ) . "

" . $wgOut->parse( $note ) . $conflict . "\n"; - global $wgBetterDirectionality; - if( $wgBetterDirectionality ) { - $pageLang = $this->mTitle->getPageLanguage(); - $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), - 'class' => 'mw-content-'.$pageLang->getDir() ); - $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML ); - } + $pageLang = $this->mTitle->getPageLanguage(); + $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-'.$pageLang->getDir() ); + $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML ); + wfProfileOut( __METHOD__ ); return $previewhead . $previewHTML . $this->previewTextAfterContent; } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 0ff0f9885b..6d917326a5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -910,17 +910,15 @@ function wfGetLangObj( $langcode = false ) { } /** - * Use this instead of $wgContLang, when working with user interface. - * User interface is currently hard coded according to wiki content language - * in many ways, especially regarding to text direction. There is lots stuff - * to fix, hence this function to keep the old behaviour unless the global - * $wgBetterDirectionality is enabled (or removed when everything works). + * Old function when $wgBetterDirectionality existed + * Removed in core, kept in extensions for backwards compat. * + * @deprecated since 1.19 * @return Language */ function wfUILang() { - global $wgBetterDirectionality; - return wfGetLangObj( !$wgBetterDirectionality ); + global $wgLang; + return $wgLang; } /** @@ -2542,8 +2540,20 @@ function in_string( $needle, $str, $insensitive = false ) { return $func( $str, $needle ) !== false; } -function wfSpecialList( $page, $details ) { - $details = $details ? ' ' . wfUILang()->getDirMark() . "($details)" : ''; +/** + * Make a list item, used by various special pages + * + * @param $page String Page link + * @param $details String Text between brackets + * @param $oppositedm Boolean Add the direction mark opposite to your + * language, to display text properly + * @return String + */ +function wfSpecialList( $page, $details, $oppositedm = true ) { + global $wgLang; + $dirmark = ( $oppositedm ? $wgLang->getDirMark( true ) : '' ) . + $wgLang->getDirMark(); + $details = $details ? $dirmark . "($details)" : ''; return $page . $details; } diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 678c24b109..340c1520dd 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -410,15 +410,13 @@ class HistoryPager extends ReverseChronologicalPager { private function getRevisionButton( $name, $msg ) { $this->preventClickjacking(); - $float = wfUILang()->alignEnd(); # Note bug #20966,