Hashar has uploaded a new change for review.
https://gerrit.wikimedia.org/r/71911
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, 26 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/11/71911/1
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 8bf680b..1687e65 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -121,6 +121,9 @@
button objects in one call.
* (bug 48256) Make brackets in section edit links accessible to CSS.
They are now wrapped in <span class="mw-editsection-bracket" />.
+* Special:PrefixIndex now let you strip the searched prefix from the displayed
+ titles. Given a list of articles named Bug1, Bug2, you can now transculde the
+ list of bug numbers using: {{Special:PrefixIndex/Bug|stripprefix=1}}
=== 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..a9a36a1 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( 'allpages-strip-prefix' )->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 10fe5ea..ccd7ca1 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -2800,6 +2800,7 @@
It may contain one or more characters that cannot be used in titles.',
'allpages-bad-ns' => '{{SITENAME}} does not have namespace "$1".',
'allpages-hide-redirects' => 'Hide redirects',
+'allpages-strip-prefix' => 'Strip prefix in list',
# SpecialCachedPage
'cachedspecial-viewing-cached-ttl' => 'You are viewing a cached version of
this page, which can be up to $1 old.',
diff --git a/languages/messages/MessagesQqq.php
b/languages/messages/MessagesQqq.php
index 8716995..4f1f602 100644
--- a/languages/messages/MessagesQqq.php
+++ b/languages/messages/MessagesQqq.php
@@ -4287,6 +4287,7 @@
'allpagesbadtitle' => 'Used in [[Special:AllPages]], [[Special:PrefixIndex]]
and [[Special:RecentChangesLinked]].',
'allpages-bad-ns' => '* $1 - namespace name',
'allpages-hide-redirects' => 'Label for a checkbox. If the checkbox is checked
redirects will not be shown in the list. Used in [[Special:PrefixIndex]] and
[[Special:Allpages]].',
+'allpages-strip-prefix' => '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]].',
# SpecialCachedPage
'cachedspecial-viewing-cached-ttl' => 'Message notifying they are watching a
cached page. $1 is a duration (ie "1 hour and 30 minutes")',
diff --git a/maintenance/language/messages.inc
b/maintenance/language/messages.inc
index 2712fae..67aa870 100644
--- a/maintenance/language/messages.inc
+++ b/maintenance/language/messages.inc
@@ -1861,6 +1861,7 @@
'allpagesbadtitle',
'allpages-bad-ns',
'allpages-hide-redirects',
+ 'allpages-strip-prefix',
),
'cachedspecial' => array(
'cachedspecial-viewing-cached-ttl',
--
To view, visit https://gerrit.wikimedia.org/r/71911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I96a0a08ea11a82016eb382abbeb2d54bfc2c4016
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits