From 56af4f4d3849aa29bdb3883ef090ded39ab32e39 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Thu, 18 Oct 2007 12:33:57 +0000 Subject: [PATCH] * (bug 11649) Show input form when Special:Whatlinkshere has no parameters * Make Special:Whatlinkshere visible to Special:SpecialPages * Move 2 messages in language (maintenance) files to a more generic place as they are no longer used by Special:Whatlinkshere but by other special pages furthermore * Kill whitespaces --- RELEASE-NOTES | 2 +- includes/SpecialPage.php | 2 +- includes/SpecialWhatlinkshere.php | 40 +++++++++++++++---------------- languages/messages/MessagesDe.php | 7 +++--- languages/messages/MessagesEn.php | 7 +++--- maintenance/language/messages.inc | 5 ++-- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ed9098054b..bc49cb7c3d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -39,7 +39,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN against the previous revision, whether currently deleted or live. * Added accesskey and tooltip for the "Go" button, and tooltip for the "Search" button. - +* (bug 11649) Show input form when Special:Whatlinkshere has no parameters === Bug fixes in 1.12 === diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 10f334e36f..852b0b86a6 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -123,7 +123,7 @@ class SpecialPage 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ), 'Contributions' => array( 'SpecialPage', 'Contributions' ), 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ), - 'Whatlinkshere' => array( 'UnlistedSpecialPage', 'Whatlinkshere' ), + 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ), 'Recentchangeslinked' => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ), 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ), 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ), diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index d944f6b467..8f2750dfaf 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -44,19 +44,19 @@ class WhatLinksHerePage { $targetString = isset($this->par) ? $this->par : $this->request->getVal( 'target' ); - if (is_null($targetString)) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); + if ( is_null( $targetString ) ) { + $wgOut->addHTML( $this->whatlinkshereForm() ); return; } $this->target = Title::newFromURL( $targetString ); if( !$this->target ) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); + $wgOut->addHTML( $this->whatlinkshereForm() ); return; } $this->selfTitle = Title::makeTitleSafe( NS_SPECIAL, 'Whatlinkshere/' . $this->target->getPrefixedDBkey() ); - + $wgOut->setPageTitle( wfMsg( 'whatlinkshere-title', $this->target->getPrefixedText() ) ); $wgOut->setSubtitle( wfMsg( 'linklistsub' ) ); @@ -113,34 +113,32 @@ class WhatLinksHerePage { // Read an extra row as an at-end check $queryLimit = $limit + 1; - + // enforce join order, sometimes namespace selector may // trigger filesorts which are far less efficient than scanning many entries $options[] = 'STRAIGHT_JOIN'; - + $options['LIMIT'] = $queryLimit; $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' ); $options['ORDER BY'] = 'pl_from'; $plRes = $dbr->select( array( 'pagelinks', 'page' ), $fields, $plConds, $fname, $options ); - + $options['ORDER BY'] = 'tl_from'; $tlRes = $dbr->select( array( 'templatelinks', 'page' ), $fields, $tlConds, $fname, $options ); - + if ( !$dbr->numRows( $plRes ) && !$dbr->numRows( $tlRes ) ) { - if ( 0 == $level && !isset( $this->namespace ) ) { - // really no links to here - $wgOut->addWikiText( wfMsg( 'nolinkshere', $this->target->getPrefixedText() ) ); - } elseif ( 0 == $level && isset( $this->namespace ) ) { - // no links from requested namespace to here + if ( 0 == $level ) { $options = array(); // reinitialize for a further namespace search + // really no links to here $options['namespace'] = $this->namespace; $options['target'] = $this->target->getPrefixedText(); list( $options['limit'], $options['offset']) = wfCheckLimits(); $wgOut->addHTML( $this->whatlinkshereForm( $options ) ); - $wgOut->addWikiText( wfMsg( 'nolinkshere-ns', $this->target->getPrefixedText() ) ); + $errMsg = isset( $this->namespace ) ? 'nolinkshere-ns' : 'nolinkshere'; + $wgOut->addWikiText( wfMsg( $errMsg, $this->target->getPrefixedText() ) ); } return; } @@ -295,24 +293,26 @@ class WhatLinksHerePage { return $this->makeSelfLink( $fmtLimit, $query ); } - function whatlinkshereForm( $options ) { + function whatlinkshereForm( $options = array( 'target' => '', 'namespace' => '' ) ) { global $wgScript, $wgTitle; $options['title'] = $wgTitle->getPrefixedText(); $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => "$wgScript" ) ) . - '
' . - Xml::element( 'legend', array(), wfMsg( 'whatlinkshere' ) ); + Xml::openElement( 'fieldset' ) . + Xml::element( 'legend', array(), wfMsg( 'whatlinkshere' ) ) . + Xml::inputLabel( wfMsg( 'whatlinkshere-page' ), 'target', 'mw-whatlinkshere-target', 40, $options['target'] ) . ' '; foreach ( $options as $name => $value ) { - if( $name === 'namespace') continue; + if( $name === 'namespace' || $name === 'target' ) + continue; $f .= "\t" . Xml::hidden( $name, $value ). "\n"; } $f .= Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' . Xml::namespaceSelector( $options['namespace'], '' ) . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . - '
' . + Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ) . "\n"; return $f; @@ -324,5 +324,3 @@ class WhatLinksHerePage { } } - - diff --git a/languages/messages/MessagesDe.php b/languages/messages/MessagesDe.php index ae501a25a3..2d665f9c1c 100644 --- a/languages/messages/MessagesDe.php +++ b/languages/messages/MessagesDe.php @@ -1307,6 +1307,8 @@ auf die bereits die erste Weiterleitung zeigen sollte.', 'movethispage' => 'Seite verschieben', 'unusedimagestext' => '

Bitte beachte, dass andere Webseiten dieses Bild mit einer direkten URL verlinken können. Diese wird nicht als Verwendung erkannt, so dass das Bild hier aufgeführt wird.

', 'unusedcategoriestext' => 'Diese Spezialseite zeigt alle Kategorien, die selber keiner Kategorie zugewiesen wurden.', +'notargettitle' => 'Keine Seite angegeben', +'notargettext' => 'Du hast nicht angegeben, auf welche Seite diese Funktion angewendet werden soll.', # Book sources 'booksources' => 'ISBN-Suche', @@ -1596,11 +1598,10 @@ $1', 'sp-newimages-showfrom' => 'Zeige neue Dateien ab $1', # What links here -'whatlinkshere' => 'Links auf diese Seite', +'whatlinkshere' => 'Linkliste', 'whatlinkshere-title' => 'Seiten, die auf „$1“ verlinken', 'whatlinkshere-summary' => 'Diese Spezialseite listet alle internen Links auf eine bestimmte Seite auf. Die möglichen Zusätze „(Vorlageneinbindung)“ und „(Weiterleitungsseite)“ zeigen jeweils an, dass die Seite nicht durch einen normalen Wikilink eingebunden ist. ', -'notargettitle' => 'Keine Seite angegeben', -'notargettext' => 'Du hast nicht angegeben, auf welche Seite diese Funktion angewendet werden soll.', +'whatlinkshere-page' => 'Seite:', 'linklistsub' => '(Linkliste)', 'linkshere' => "Die folgenden Seiten verlinken auf '''„[[:$1]]“''':", 'nolinkshere' => "Keine Seite verlinkt auf '''„[[:$1]]“'''.", diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 4dd3ae22e9..013bf9c8e5 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1674,6 +1674,8 @@ The [http://meta.wikimedia.org/wiki/Help:Job_queue job queue] length is '''$7''' a direct URL, and so may still be listed here despite being in active use.

', 'unusedcategoriestext' => 'The following category pages exist although no other article or category make use of them.', +'notargettitle' => 'No target', +'notargettext' => 'You have not specified a target page or user to perform this function on.', # Book sources 'booksources' => 'Book sources', @@ -1994,11 +1996,10 @@ Consult the [[Special:Log/delete|deletion log]] for a record of recent deletions # What links here 'whatlinkshere' => 'What links here', -'whatlinkshere-title' => 'Pages that link to $1', +'whatlinkshere-title' => 'Pages that link to $1', 'whatlinkshere-summary' => '', # only translate this message to other languages if you have to change it 'whatlinkshere-barrow' => '<', # only translate this message to other languages if you have to change it -'notargettitle' => 'No target', -'notargettext' => 'You have not specified a target page or user to perform this function on.', +'whatlinkshere-page' => 'Page:', 'linklistsub' => '(List of links)', 'linkshere' => "The following pages link to '''[[:$1]]''':", 'nolinkshere' => "No pages link to '''[[:$1]]'''.", diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 6cc4b1297c..cdf56d72f3 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1058,6 +1058,8 @@ $wgMessageStructure = array( 'movethispage', 'unusedimagestext', 'unusedcategoriestext', + 'notargettitle', + 'notargettext', ), 'booksources' => array( 'booksources', @@ -1320,9 +1322,8 @@ $wgMessageStructure = array( 'whatlinkshere', 'whatlinkshere-title', 'whatlinkshere-summary', + 'whatlinkshere-page', 'whatlinkshere-barrow', - 'notargettitle', - 'notargettext', 'linklistsub', 'linkshere', 'nolinkshere', -- 2.20.1