Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/144411

Change subject: Add new Magic Word USEDISPLAYTITLE
......................................................................

Add new Magic Word USEDISPLAYTITLE

New Magic WORD usedisplaytitle for category pages. Controls if defaulttitle
is used for pages in the category or displaytitle.

Bug: 17212
Change-Id: I4699e97bbbaa15791b18f91d59d6eba5f808b572
---
M RELEASE-NOTES-1.24
M includes/CategoryViewer.php
M includes/Linker.php
M includes/MagicWord.php
4 files changed, 20 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/11/144411/1

diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index 9c605d0..265684e 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -102,6 +102,10 @@
   The feature needs to be enabled with $wgPageLanguageUseDB=true and
   permission needs to be set for 'pagelang'.
 * Upgrade Moment.js to v2.7.0.
+* (bug 17212) Add $wgAlwaysUseDisplayTitle so that the displaytitle is used on
+  category listing, recent changes, etc.
+* (bug 17212) With magic word __USEDISPLAYTITLE__ on category pages, the 
displaytitle
+  is used for the pages on this category page.
 
 === Bug fixes in 1.24 ===
 * (bug 49116) Footer copyright notice is now always displayed in user language
diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php
index cd9eaa9..7006e9a 100644
--- a/includes/CategoryViewer.php
+++ b/includes/CategoryViewer.php
@@ -72,6 +72,8 @@
        /** @var array The original query array, to be used in generating 
paging links. */
        private $query;
 
+       private $mUseDisplayTitle;
+
        /**
         * @since 1.19 $context is a second, required parameter
         * @param Title $title
@@ -107,6 +109,12 @@
 
                $this->showGallery = $wgCategoryMagicGallery && 
!$this->getOutput()->mNoGallery;
 
+               $wp = new WikiPage( $this->title );
+               $text = $wp->getContent()->getNativeData();
+               $useDisplayTitle = false;
+               if ( MagicWord::get( 'usedisplaytitle' )->match( $text ) ) {
+                       $this->mUseDisplayTitle = true;
+               }
                $this->clearCategoryState();
                $this->doCategoryQuery();
                $this->finaliseCategoryState();
@@ -249,11 +257,12 @@
         * @param string $sortkey
         * @param int $pageLength
         * @param bool $isRedirect
+        * @param bool $useDisplayTitle
         */
        function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
                global $wgContLang;
 
-               $link = Linker::link( $title );
+               $link = Linker::link( $title, null, array(), array(), array(), 
$this->mUseDisplayTitle );
                if ( $isRedirect ) {
                        // This seems kind of pointless given 'mw-redirect' 
class,
                        // but keeping for back-compatibility with user css.
diff --git a/includes/Linker.php b/includes/Linker.php
index 1c2f251..d481d61 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -191,7 +191,8 @@
         * @return string HTML <a> attribute
         */
        public static function link(
-               $target, $html = null, $customAttribs = array(), $query = 
array(), $options = array()
+               $target, $html = null, $customAttribs = array(), $query = 
array(), $options = array(),
+               $useDisplayTitle = false
        ) {
                wfProfileIn( __METHOD__ );
                if ( !$target instanceof Title ) {
@@ -246,7 +247,7 @@
                        self::linkAttribs( $target, $customAttribs, $options )
                );
                if ( is_null( $html ) ) {
-                       $html = self::linkText( $target );
+                       $html = self::linkText( $target, $useDisplayTitle );
                }
 
                $ret = null;
@@ -379,7 +380,7 @@
         *
         * @return string
         */
-       private static function linkText( $target ) {
+       private static function linkText( $target, $useDisplayTitle ) {
                global $wgAlwaysUseDisplayTitle;
                // We might be passed a non-Title by make*LinkObj().  Fail 
gracefully.
                if ( !$target instanceof Title ) {
@@ -391,7 +392,7 @@
                if ( $target->getPrefixedText() === '' && 
$target->hasFragment() ) {
                        return htmlspecialchars( $target->getFragment() );
                }
-               if ( $wgAlwaysUseDisplayTitle ) {
+               if ( $wgAlwaysUseDisplayTitle || $useDisplayTitle ) {
                        // Note, this returns html, that we want to output 
without escaping.
                        return $target->getDisplayTitle();
                } else {
diff --git a/includes/MagicWord.php b/includes/MagicWord.php
index 7decbee..2e7c07f 100644
--- a/includes/MagicWord.php
+++ b/includes/MagicWord.php
@@ -220,6 +220,7 @@
        );
 
        static public $mDoubleUnderscoreIDs = array(
+               'usedisplaytitle',
                'notoc',
                'nogallery',
                'forcetoc',

-- 
To view, visit https://gerrit.wikimedia.org/r/144411
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4699e97bbbaa15791b18f91d59d6eba5f808b572
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to