jenkins-bot has submitted this change and it was merged.
Change subject: option to strip requested prefix index in the list
......................................................................
option to strip requested prefix index in the list
[[Special:PrefixIndex]] could be transcluded to generate a dynamic list
of pages. Since all pages share the same prefix, it is not always
wanted, specially when looking for subpages.
Given articles named:
- Project/Alix
- Project/FixBug20281
- Project/S3cretPlan
- Projects roadmap
{{Special:PrefixIndex/Project}} yields:
Project/Alix Project/FixBug20281 Project/S3cretPlan
Projects roadmap
Adding |stripprefix=1 get rid of the prefix:
{{Special:PrefixIndex/Project|stripprefix=1}}
/Alix /FixBug20281 /S3cretPlan
s roadmap
{{Special:PrefixIndex/Project/|stripprefix=1}}
Alix FixBug20281 S3cretPlan
The patch adds a checkbox to activate the prefix stripping.
For the implementation, I have chosen a protected class property instead
of adding parameters to various methods. That seems easier to handle.
Change-Id: I96a0a08ea11a82016eb382abbeb2d54bfc2c4016
---
M RELEASE-NOTES-1.22
M includes/specials/SpecialPrefixindex.php
M languages/messages/MessagesEn.php
M languages/messages/MessagesQqq.php
M maintenance/language/messages.inc
5 files changed, 27 insertions(+), 1 deletion(-)
Approvals:
Parent5446: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 9ba8f5b..68e14dc 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -154,6 +154,10 @@
* (bug 21912) Watchlist token implementation has been refactored and
Special:ResetTokens was added to allow users to reset their tokens
instead of presenting them in Preferences.
+* Special:PrefixIndex now lets you strip the searched prefix from the displayed
+ titles. Given a list of articles named Bug1, Bug2, you can now transclude the
+ list of bug numbers using: {{Special:PrefixIndex/Bug|stripprefix=1}}.
+ The special page form received a new checkbox matching that option.
=== Bug fixes in 1.22 ===
* Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
diff --git a/includes/specials/SpecialPrefixindex.php
b/includes/specials/SpecialPrefixindex.php
index 1322d54..f2efd0f 100644
--- a/includes/specials/SpecialPrefixindex.php
+++ b/includes/specials/SpecialPrefixindex.php
@@ -27,6 +27,13 @@
* @ingroup SpecialPage
*/
class SpecialPrefixindex extends SpecialAllpages {
+
+ /**
+ * Whether to remove the searched prefix from the displayed link. Useful
+ * for inclusion of a set of sub pages in a root page.
+ */
+ protected $stripPrefix = false;
+
// Inherit $maxPerPage
function __construct() {
@@ -53,6 +60,7 @@
$ns = $request->getIntOrNull( 'namespace' );
$namespace = (int)$ns; // if no namespace given, use 0
(NS_MAIN).
$hideredirects = $request->getBool( 'hideredirects', false );
+ $this->stripPrefix = $request->getBool( 'stripprefix',
$this->stripPrefix );
$namespaces = $wgContLang->getNamespaces();
$out->setPageTitle(
@@ -121,6 +129,12 @@
'hideredirects',
'hideredirects',
$hideredirects
+ ) . ' ' .
+ Xml::checkLabel(
+ $this->msg( 'prefixindex-strip' )->text(),
+ 'stripprefix',
+ 'stripprefix',
+ $this->stripPrefix
) . ' ' .
Xml::submitButton( $this->msg( 'allpagessubmit'
)->text() ) .
"</td>
@@ -191,13 +205,18 @@
if ( $res->numRows() > 0 ) {
$out = Xml::openElement( 'table', array( 'id'
=> 'mw-prefixindex-list-table' ) );
+ $prefixLength = strlen( $prefix );
while ( ( $n < $this->maxPerPage ) && ( $s =
$res->fetchObject() ) ) {
$t = Title::makeTitle(
$s->page_namespace, $s->page_title );
if ( $t ) {
+ $displayed = $t->getText();
+ if ( $this->stripPrefix ) {
+ $displayed = substr(
$displayed, $prefixLength );
+ }
$link = ( $s->page_is_redirect
? '<div class="allpagesredirect">' : '' ) .
Linker::linkKnown(
$t,
-
htmlspecialchars( $t->getText() ),
+
htmlspecialchars( $displayed ),
$s->page_is_redirect ? array( 'class' => 'mw-redirect' ) : array()
) .
( $s->page_is_redirect
? '</div>' : '' );
diff --git a/languages/messages/MessagesEn.php
b/languages/messages/MessagesEn.php
index a26b7cf..3bf18ca 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -2745,6 +2745,7 @@
'mostrevisions-summary' => '', # do not translate or duplicate this
message to other languages
'prefixindex' => 'All pages with prefix',
'prefixindex-namespace' => 'All pages with prefix ($1 namespace)',
+'prefixindex-strip' => 'Strip prefix in list',
'prefixindex-summary' => '', # do not translate or duplicate this
message to other languages
'shortpages' => 'Short pages',
'shortpages-summary' => '', # do not translate or duplicate this
message to other languages
diff --git a/languages/messages/MessagesQqq.php
b/languages/messages/MessagesQqq.php
index 272dd8a..7772843 100644
--- a/languages/messages/MessagesQqq.php
+++ b/languages/messages/MessagesQqq.php
@@ -4200,6 +4200,7 @@
'prefixindex' => '{{doc-special|PrefixIndex}}
When the user limits the list to a certain namespace,
{{msg-mw|allinnamespace}} is used instead.',
'prefixindex-namespace' => 'The page title of [[Special:PrefixIndex]] limited
to a specific namespace. Similar to {{msg-mw|allinnamespace}}. $1 is the name
of the namespace',
+'prefixindex-strip' => 'Label for a checkbox. If the checkbox is checked, the
prefix searched will be removed from the title displayed in the list. Used in
[[Special:PrefixIndex]].',
'shortpages' => '{{doc-special|ShortPages}}',
'longpages' => '{{doc-special|LongPages}}',
'deadendpages' => '{{doc-special|DeadendPages}}',
diff --git a/maintenance/language/messages.inc
b/maintenance/language/messages.inc
index c1af4aa..7adcdeb 100644
--- a/maintenance/language/messages.inc
+++ b/maintenance/language/messages.inc
@@ -1807,6 +1807,7 @@
'prefixindex',
'prefixindex-namespace',
'prefixindex-summary',
+ 'prefixindex-strip',
'shortpages',
'shortpages-summary',
'longpages',
--
To view, visit https://gerrit.wikimedia.org/r/71911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I96a0a08ea11a82016eb382abbeb2d54bfc2c4016
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: IAlex <[email protected]>
Gerrit-Reviewer: Matmarex <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits