Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3303
HideSub.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 9:26 PM
2014-11-21 21:26:43 (UTC+0)
Size
10 KB
Referenced Files
None
Subscribers
None
HideSub.patch
View Options
Index: includes/specials/SpecialAllpages.php
===================================================================
--- includes/specials/SpecialAllpages.php (revision 114555)
+++ includes/specials/SpecialAllpages.php (working copy)
@@ -70,6 +70,7 @@
$from = $request->getVal( 'from', null );
$to = $request->getVal( 'to', null );
$namespace = $request->getInt( 'namespace' );
+ $hideSubPages = $request->getBool('hideSub',false);
$namespaces = $wgContLang->getNamespaces();
@@ -81,11 +82,11 @@
$out->addModuleStyles( 'mediawiki.special' );
if( $par !== null ) {
- $this->showChunk( $namespace, $par, $to );
+ $this->showChunk( $namespace, $par, $to ,$hideSubPages);
} elseif( $from !== null && $to === null ) {
- $this->showChunk( $namespace, $from, $to );
+ $this->showChunk( $namespace, $from, $to,$hideSubPages );
} else {
- $this->showToplevel( $namespace, $from, $to );
+ $this->showToplevel( $namespace, $from, $to,$hideSubPages );
}
}
@@ -97,7 +98,7 @@
* @param $to String: dbKey we are ending listing at.
* @return string
*/
- function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '' ) {
+ function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '',$hideSubPages ) {
global $wgScript;
$t = $this->getTitle();
@@ -134,7 +135,16 @@
) . ' ' .
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
" </td>
-</tr>";
+</tr>".
+ "</tr>".
+ "<tr>
+ <td class='mw-label'>".
+ Xml::label(wfMsg('prefixhidesub'),'hideSub').
+ "</td>".
+ "<td class='mw-input'>".
+ Xml::check('hideSub',$hideSubPages,array('id'=>'hideSub')).
+ "</td>".
+ "</tr>" ;
$out .= Xml::closeElement( 'table' );
$out .= Xml::closeElement( 'fieldset' );
$out .= Xml::closeElement( 'form' );
@@ -147,7 +157,7 @@
* @param $from String: list all pages from this name
* @param $to String: list all pages to this name
*/
- function showToplevel( $namespace = NS_MAIN, $from = '', $to = '' ) {
+ function showToplevel( $namespace = NS_MAIN, $from = '', $to = '',$hideSubPages ) {
$output = $this->getOutput();
# TODO: Either make this *much* faster or cache the title index points
@@ -166,6 +176,8 @@
$where[] = 'page_title >= '.$dbr->addQuotes( $from );
if( isset($to) )
$where[] = 'page_title <= '.$dbr->addQuotes( $to );
+ if($hideSubPages)
+ $where[] = 'page_title NOT'.$dbr->buildLike($dbr->anyString(),'/',$dbr->anyString());
global $wgMemc;
$key = wfMemcKey( 'allpages', 'ns', $namespace, $from, $to );
@@ -225,9 +237,9 @@
// Instead, display the first section directly.
if( count( $lines ) <= 2 ) {
if( !empty($lines) ) {
- $this->showChunk( $namespace, $from, $to );
+ $this->showChunk( $namespace, $from, $to,$hideSubPages );
} else {
- $output->addHTML( $this->namespaceForm( $namespace, $from, $to ) );
+ $output->addHTML( $this->namespaceForm( $namespace, $from, $to,$hideSubPages ) );
}
return;
}
@@ -240,7 +252,7 @@
$out .= $this->showline( $inpoint, $outpoint, $namespace );
}
$out .= Xml::closeElement( 'table' );
- $nsForm = $this->namespaceForm( $namespace, $from, $to );
+ $nsForm = $this->namespaceForm( $namespace, $from, $to,$hideSubPages );
# Is there more?
if( $this->including() ) {
@@ -297,7 +309,7 @@
* @param $from String: list all pages from this name (default FALSE)
* @param $to String: list all pages to this name (default FALSE)
*/
- function showChunk( $namespace = NS_MAIN, $from = false, $to = false ) {
+ function showChunk( $namespace = NS_MAIN, $from = false, $to = false ,$hideSubPages) {
global $wgContLang;
$output = $this->getOutput();
@@ -321,6 +333,9 @@
'page_namespace' => $namespace,
'page_title >= ' . $dbr->addQuotes( $fromKey )
);
+ if($hideSubPages)
+ $conds[]='page_title NOT'.$dbr->buildLike($dbr->anyString(),'/',$dbr->anyString());
+
if( $toKey !== "" ) {
$conds[] = 'page_title <= ' . $dbr->addQuotes( $toKey );
}
@@ -374,10 +389,13 @@
} else {
# Get the last title from previous chunk
$dbr = wfGetDB( DB_SLAVE );
+ $conditions=array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from));
+ if($hiddenSubPages)
+ $conditions[] ='page_title NOT'.$dbr->buildLike($dbr->anyString(),'/',$dbr->anyString());
$res_prev = $dbr->select(
'page',
'page_title',
- array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ),
+ $conditions,
__METHOD__,
array( 'ORDER BY' => 'page_title DESC',
'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 )
@@ -395,8 +413,11 @@
if ( ! $dbr->implicitOrderby() ) {
$options['ORDER BY'] = 'page_title';
}
+ $newConditions = array( 'page_namespace' => $namespace);
+ if($hideSubPages)
+ $newConditions[]='page_title NOT'.$dbr->buildLike($dbr->anyString(),'/',$dbr->anyString());
$reallyFirstPage_title = $dbr->selectField( 'page', 'page_title',
- array( 'page_namespace' => $namespace ), __METHOD__, $options );
+ $newConditions, __METHOD__, $options );
# Show the previous link if it s not the current requested chunk
if( $from != $reallyFirstPage_title ) {
$prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );
@@ -408,7 +429,7 @@
$self = $this->getTitle();
- $nsForm = $this->namespaceForm( $namespace, $from, $to );
+ $nsForm = $this->namespaceForm( $namespace, $from, $to,$hideSubPages );
$out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ).
'<tr>
<td>' .
Index: includes/specials/SpecialPrefixindex.php
===================================================================
--- includes/specials/SpecialPrefixindex.php (revision 114555)
+++ includes/specials/SpecialPrefixindex.php (working copy)
@@ -51,6 +51,7 @@
$from = $request->getVal( 'from', '' );
$prefix = $request->getVal( 'prefix', '' );
$ns = $request->getIntOrNull( 'namespace' );
+ $hideSubPage= $request->getBool('hideSub',false);
$namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
$namespaces = $wgContLang->getNamespaces();
@@ -73,9 +74,9 @@
// Bug 27864: if transcluded, show all pages instead of the form.
if ( $this->including() || $showme != '' || $ns !== null ) {
- $this->showPrefixChunk( $namespace, $showme, $from );
+ $this->showPrefixChunk( $namespace, $showme, $from,$hideSubPage );
} else {
- $out->addHTML( $this->namespacePrefixForm( $namespace, null ) );
+ $out->addHTML( $this->namespacePrefixForm( $namespace, null,$hideSubPage ) );
}
}
@@ -85,7 +86,7 @@
* @param $from String: dbKey we are starting listing at.
* @return string
*/
- function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
+ function namespacePrefixForm( $namespace = NS_MAIN, $from = '',$hideSubPage ) {
global $wgScript;
$out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
@@ -113,10 +114,18 @@
'name' => 'namespace',
'id' => 'namespace',
'class' => 'namespaceselector',
- ) ) .
+ ) ) .
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
- "</td>
- </tr>";
+ "</td>
+ </tr>".
+ "<tr>
+ <td class='mw-label'>".
+ Xml::label(wfMsg('prefixhidesub'),'hideSub').
+ "</td>".
+ "<td class='mw-input'>".
+ Xml::check('hideSub',$hideSubPage,array('id'=>'hideSub')).
+ "</td>".
+ "</tr>" ;
$out .= Xml::closeElement( 'table' );
$out .= Xml::closeElement( 'fieldset' );
$out .= Xml::closeElement( 'form' );
@@ -129,7 +138,7 @@
* @param $prefix String
* @param $from String: list all pages from this name (default FALSE)
*/
- function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) {
+ function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null,$hideSub ) {
global $wgContLang;
if ( $from === null ) {
@@ -151,16 +160,17 @@
list( /* $fromNS */, $fromKey, ) = $fromList;
### @todo FIXME: Should complain if $fromNs != $namespace
-
+
$dbr = wfGetDB( DB_SLAVE );
-
+ $whereConds = array(
+ 'page_namespace' => $namespace,
+ 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ),
+ 'page_title >= ' . $dbr->addQuotes( $fromKey ));
+ if($hideSub)
+ $whereConds[]='page_title NOT'.$dbr->buildLike($dbr->anyString(),'/',$dbr->anyString());
$res = $dbr->select( 'page',
array( 'page_namespace', 'page_title', 'page_is_redirect' ),
- array(
- 'page_namespace' => $namespace,
- 'page_title' . $dbr->buildLike( $prefixKey, $dbr->anyString() ),
- 'page_title >= ' . $dbr->addQuotes( $fromKey ),
- ),
+ $whereConds,
__METHOD__,
array(
'ORDER BY' => 'page_title',
@@ -177,7 +187,7 @@
while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
- if( $t ) {
+ if( $t) {
$link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
Linker::linkKnown(
$t,
@@ -209,7 +219,7 @@
if ( $this->including() ) {
$out2 = '';
} else {
- $nsForm = $this->namespacePrefixForm( $namespace, $prefix );
+ $nsForm = $this->namespacePrefixForm( $namespace, $prefix ,$hideSub);
$self = $this->getTitle();
$out2 = Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-prefixindex-nav-table' ) ) .
'<tr>
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 114555)
+++ languages/messages/MessagesEn.php (working copy)
@@ -2571,6 +2571,7 @@
'prefixindex' => 'All pages with prefix',
'prefixindex-namespace' => 'All pages with prefix ($1 namespace)',
'prefixindex-summary' => '', # do not translate or duplicate this message to other languages
+'prefixhidesub' => 'Hide Sub Pages',
'shortpages' => 'Short pages',
'shortpages-summary' => '', # do not translate or duplicate this message to other languages
'longpages' => 'Long pages',
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2872
Default Alt Text
HideSub.patch (10 KB)
Attached To
Mode
T9184: Optionally exclude subpages from Special:Allpages and Special:Prefixindex
Attached
Detach File
Event Timeline
Log In to Comment