jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/370688 )

Change subject: Modified self-links to determine display text identically to 
non-self-links.
......................................................................


Modified self-links to determine display text identically to non-self-links.

Change-Id: I0b02457931e907450360d982d9b117288c23a807
---
M DisplayTitleHooks.php
M extension.json
2 files changed, 30 insertions(+), 18 deletions(-)

Approvals:
  Cicalese: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DisplayTitleHooks.php b/DisplayTitleHooks.php
index e3bb63a..3990273 100644
--- a/DisplayTitleHooks.php
+++ b/DisplayTitleHooks.php
@@ -58,10 +58,6 @@
         * Implements LinkBegin hook.
         * See https://www.mediawiki.org/wiki/Manual:Hooks/LinkBegin
         * Handle links. Implements LinkBegin hook of Linker class.
-        * If a link is customized by a user (e. g. [[Target|Text]]) it should
-        * remain intact. Let us assume a link is not customized if its html is
-        * the prefixed or (to support Semantic MediaWiki queries) non-prefixed 
title
-        * of the target page.
         *
         * @since 1.0
         * @param string $dummy no longer used
@@ -75,18 +71,7 @@
         */
        public static function onLinkBegin( $dummy, Title $target, &$html,
                &$customAttribs, &$query, &$options, &$ret ) {
-               if ( isset( $html ) && is_string( $html ) ) {
-                       $title = Title::newFromText( $html );
-                       if ( !is_null( $title ) &&
-                               $title->getText() === $target->getText() &&
-                               ( $title->getSubjectNsText() === 
$target->getSubjectNsText() ||
-                               $title->getSubjectNsText() === '' ) ) {
-                               self::getDisplayTitle( $target, $html );
-                       }
-               } else {
-                       self::getDisplayTitle( $target, $html );
-               }
-               return true;
+               return self::handleLink( $target, $html );
        }
 
        /**
@@ -104,7 +89,34 @@
         */
        public static function onSelfLinkBegin( Title $nt, &$html, &$trail,
                &$prefix, &$ret ) {
-               self::getDisplayTitle( $nt, $html );
+               return self::handleLink( $nt, $html );
+       }
+
+       /**
+        * Helper function. Determines link text for self-links and standard 
links.
+        *
+        * Handle links. If a link is customized by a user (e. g. 
[[Target|Text]])
+        * it should remain intact. Let us assume a link is not customized if 
its
+        * html is the prefixed or (to support Semantic MediaWiki queries)
+        * non-prefixed title of the target page.
+        *
+        * @since 1.3
+        * @param Title $target the Title object that the link is pointing to
+        * @param string &$html the HTML of the link text
+        * @return bool continue checking hooks
+        */
+       private static function handleLink( Title $target, &$html ) {
+               if ( isset( $html ) && is_string( $html ) ) {
+                       $title = Title::newFromText( $html );
+                       if ( !is_null( $title ) &&
+                               $title->getText() === $target->getText() &&
+                               ( $title->getSubjectNsText() === 
$target->getSubjectNsText() ||
+                               $title->getSubjectNsText() === '' ) ) {
+                               self::getDisplayTitle( $target, $html );
+                       }
+               } else {
+                       self::getDisplayTitle( $target, $html );
+               }
                return true;
        }
 
diff --git a/extension.json b/extension.json
index a4dd8df..1d85b6e 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "DisplayTitle",
-       "version": "1.2",
+       "version": "1.3",
        "author": [
                "[https://www.mediawiki.org/wiki/User:Cindy.cicalese Cindy 
Cicalese]",
                "[https://www.semantic-mediawiki.org/wiki/User:Oetterer Tobias 
Oetterer]"

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0b02457931e907450360d982d9b117288c23a807
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/DisplayTitle
Gerrit-Branch: master
Gerrit-Owner: Kji <k...@mitre.org>
Gerrit-Reviewer: Cicalese <cin...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to