Add edit link to each row on Special:WhatLinksHere
authorFlorianschmidtwelzow <florian.schmidt.welzow@t-online.de>
Mon, 27 Apr 2015 05:34:15 +0000 (07:34 +0200)
committerFlorian <florian.schmidt.stargatewissen@gmail.com>
Sun, 12 Jul 2015 19:20:39 +0000 (21:20 +0200)
Bug: T97269
Change-Id: Ic13b775bc0c0ede947086c7eb305ac5d4f2fcd12

includes/specials/SpecialWhatlinkshere.php

index be77e62..69a8074 100644 (file)
@@ -314,7 +314,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                static $msgcache = null;
                if ( $msgcache === null ) {
                        static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator',
-                               'whatlinkshere-links', 'isimage' );
+                               'whatlinkshere-links', 'isimage', 'edit' );
                        $msgcache = array();
                        foreach ( $msgs as $msg ) {
                                $msgcache[$msg] = $this->msg( $msg )->escaped();
@@ -355,7 +355,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                }
 
                # Space for utilities links, with a what-links-here link provided
-               $wlhLink = $this->wlhLink( $nt, $msgcache['whatlinkshere-links'] );
+               $wlhLink = $this->wlhLink( $nt, $msgcache['whatlinkshere-links'], $msgcache['edit'] );
                $wlh = Xml::wrapClass(
                        $this->msg( 'parentheses' )->rawParams( $wlhLink )->escaped(),
                        'mw-whatlinkshere-tools'
@@ -370,18 +370,29 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                return Xml::closeElement( 'ul' );
        }
 
-       protected function wlhLink( Title $target, $text ) {
+       protected function wlhLink( Title $target, $text, $editText ) {
                static $title = null;
                if ( $title === null ) {
                        $title = $this->getPageTitle();
                }
 
+               $editLink = '';
+               if ( $this->getUser()->isAllowed( 'edit' ) ) {
+                       $editLink = $this->msg( 'pipe-separator' )->escaped() .
+                               Linker::linkKnown(
+                                       $target,
+                                       $editText,
+                                       array(),
+                                       array( 'action' => 'edit' )
+                               );
+               }
+
                return Linker::linkKnown(
                        $title,
                        $text,
                        array(),
                        array( 'target' => $target->getPrefixedText() )
-               );
+               ) . $editLink;
        }
 
        function makeSelfLink( $text, $query ) {