Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2740
LocalTitles.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 21 2014, 9:11 PM
2014-11-21 21:11:59 (UTC+0)
Size
6 KB
Referenced Files
None
Subscribers
None
LocalTitles.diff
View Options
Index: skins/MonoBook.php
===================================================================
--- skins/MonoBook.php (revision 14135)
+++ skins/MonoBook.php (working copy)
@@ -93,7 +93,7 @@
<div id="content">
<a name="top" id="top"></a>
<?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
- <h1 class="firstHeading"><?php $this->data['displaytitle']!=""?$this->text('title'):$this->html('title') ?></h1>
+ <h1 class="firstHeading"><?php $this->html('fulltitle') ?></h1>
<div id="bodyContent">
<h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
<div id="contentSub"><?php $this->html('subtitle') ?></div>
Index: includes/CategoryPage.php
===================================================================
--- includes/CategoryPage.php (revision 14135)
+++ includes/CategoryPage.php (working copy)
@@ -58,6 +58,7 @@
*/
function doCategoryMagic( $from = '', $until = '' ) {
global $wgContLang,$wgUser, $wgCategoryMagicGallery, $wgCategoryPagingLimit;
+ global $wgInterlanguageTitles, $wgLanguageCode;
$fname = 'CategoryPage::doCategoryMagic';
wfProfileIn( $fname );
@@ -81,17 +82,31 @@
$flip = false;
}
$limit = $wgCategoryPagingLimit;
- $res = $dbr->select(
- array( 'page', 'categorylinks' ),
- array( 'page_title', 'page_namespace', 'page_len', 'cl_sortkey' ),
- array( $pageCondition,
- 'cl_from = page_id',
- 'cl_to' => $this->mTitle->getDBKey()),
- #'page_is_redirect' => 0),
- #+ $pageCondition,
- $fname,
- array( 'ORDER BY' => $flip ? 'cl_sortkey DESC' : 'cl_sortkey',
- 'LIMIT' => $limit + 1 ) );
+
+ if ( $wgInterlanguageTitles ) {
+ $sql= 'SELECT page_title, page_namespace, page_len, cl_sortkey, ll_title
+ FROM ' . $dbr->tableName( 'page' ) . '
+ INNER JOIN ' . $dbr->tableName( 'categorylinks' ) . ' ON cl_from = page_id
+ LEFT JOIN ' . $dbr->tableName( 'langlinks' ) . ' ON ll_from = page_id AND ll_lang = ' . $dbr->addQuotes( $wgLanguageCode ) . '
+ WHERE cl_to = ' . $dbr->addQuotes( $this->mTitle->getDBKey() ) . '
+ ' . /* AND page_is_redirect = 0 */ '
+ ORDER BY ' . ( $flip ? 'cl_sortkey DESC' : 'cl_sortkey' ) . '
+ LIMIT ' . ( $limit + 1 ) . '
+ ';
+
+ $res = $dbr->query( $sql, $fname );
+ } else {
+ $res = $dbr->select( array( 'page', 'categorylinks' ),
+ array( 'page_title', 'page_namespace', 'page_len', 'cl_sortkey' ),
+ array( $pageCondition,
+ 'cl_from = page_id',
+ 'cl_to' => $this->mTitle->getDBKey()),
+ #'page_is_redirect' => 0),
+ #+ $pageCondition,
+ $fname,
+ array( 'ORDER BY' => $flip ? 'cl_sortkey DESC' : 'cl_sortkey',
+ 'LIMIT' => $limit + 1 ) );
+ }
$sk =& $wgUser->getSkin();
$r = "<br style=\"clear:both;\"/>\n";
@@ -109,7 +124,7 @@
if( $title->getNamespace() == NS_CATEGORY ) {
// Subcategory; strip the 'Category' namespace from the link text.
- array_push( $children, $sk->makeKnownLinkObj( $title, $wgContLang->convertHtml( $title->getText() ) ) );
+ array_push( $children, $sk->makeKnownLinkObj( $title, $sk->composeDisplayTitle( $title->getText(), @$x->ll_title ) ) );
// If there's a link from Category:A to Category:B, the sortkey of the resulting
// entry in the categorylinks table is Category:A, not A, which it SHOULD be.
@@ -131,7 +146,10 @@
}
} else {
// Page in this category
- array_push( $articles, $sk->makeSizeLinkObj( $x->page_len, $title, $wgContLang->convert( $title->getPrefixedText() ) ) ) ;
+ $t = $wgContLang->convert( $title->getPrefixedText() );
+ if ( $wgInterlanguageTitles ) $t .= $sk->getLocalizedHTMLTitle( $title->getPrefixedText(), @$x->ll_title );
+
+ array_push( $articles, $sk->makeSizeLinkObj( $x->page_len, $title, $t ) );
array_push( $articles_start_char, $wgContLang->convert( $wgContLang->firstChar( $x->cl_sortkey ) ) );
}
}
Index: includes/SkinTemplate.php
===================================================================
--- includes/SkinTemplate.php (revision 14135)
+++ includes/SkinTemplate.php (working copy)
@@ -188,6 +188,8 @@
$tpl->set( 'title', $wgOut->getPageTitle() );
$tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
$tpl->set( 'displaytitle', $wgOut->mPageLinkTitle );
+ $tpl->set( 'localtitle', $this->getLocalizedTitle() );
+ $tpl->set( 'fulltitle', $this->composeDisplayTitle( $wgOut->getPageTitle(), $this->getLocalizedTitle() ) );
$tpl->setRef( "thispage", $this->thispage );
$subpagestr = $this->subPageSubtitle();
Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php (revision 14135)
+++ includes/DefaultSettings.php (working copy)
@@ -1946,6 +1946,11 @@
$wgAllowDisplayTitle = false ;
/**
+ * EXPERIMENTAL: Show translated titles based on interlanguage-links
+ */
+$wgInterlanguageTitles = false ;
+
+/**
* Array of usernames which may not be registered or logged in from
* Maintenance scripts can still use these
*/
Index: includes/Skin.php
===================================================================
--- includes/Skin.php (revision 14135)
+++ includes/Skin.php (working copy)
@@ -689,9 +689,61 @@
return $s;
}
+ function composeDisplayTitle( $title, $localTitle ) {
+ global $wgInterlanguageTitles;
+ #TODO: the display-title-magic stuff should be merged in here *somehow*
+
+ #TODO: perhaps use wgContLang->convertHtml ?!
+ $t= htmlspecialchars( $title );
+
+ if ( $wgInterlanguageTitles ) {
+ $t .= $this->getLocalizedHTMLTitle( $title, $localTitle );
+ }
+
+ return $t;
+ }
+
+ function getLocalizedHTMLTitle( $title, $localTitle ) {
+ global $wgInterlanguageTitles, $wgLanguageCode, $wgContLanguageCode;
+
+ if ( $wgInterlanguageTitles
+ && $wgContLanguageCode == $wgLanguageCode
+ && $localTitle == $title ) {
+ $localTitle = '';
+ }
+
+ if ( $wgInterlanguageTitles && $localTitle != '' ) {
+ #TODO: perhaps use wgContLang->convertHtml ?!
+ return ' <i class="localtitle" lang="' . htmlspecialchars($wgLanguageCode) . '">[' . htmlspecialchars( $localTitle ) . ']</i>';
+ } else {
+ return '';
+ }
+ }
+
+ function getLocalizedTitle() {
+ global $wgOut, $wgInterlanguageTitles, $wgLanguageCode;
+
+ if ( !$wgInterlanguageTitles ) return '';
+
+ $localTitle = '';
+
+ $langlinks = $wgOut->getLanguageLinks();
+
+ foreach ( $langlinks as $link ) {
+ list( $lang, $title ) = explode( ':', $link, 2 );
+
+ if ( $lang == $wgLanguageCode ) {
+ $localTitle = $title;
+ break;
+ }
+ }
+
+ return $localTitle;
+ }
+
function pageTitle() {
global $wgOut;
- $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
+ $s = '<h1 class="pagetitle">' . $this->composeDisplayTitle( $wgOut->getPageTitle(), $this->getLocalizedTitle() ) . '</h1>';
return $s;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314
Default Alt Text
LocalTitles.diff (6 KB)
Attached To
Mode
T7638: show translated titles per user language, based on interlanguage links (patch included)
Attached
Detach File
Event Timeline
Log In to Comment