dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
exception: Account for $call['file'] and $call['line'] being unset
[lhc/web/wiklou.git]
/
includes
/
specials
/
SpecialPrefixindex.php
diff --git
a/includes/specials/SpecialPrefixindex.php
b/includes/specials/SpecialPrefixindex.php
index
1322d54
..
28d07ff
100644
(file)
--- a/
includes/specials/SpecialPrefixindex.php
+++ b/
includes/specials/SpecialPrefixindex.php
@@
-27,6
+27,15
@@
* @ingroup SpecialPage
*/
class SpecialPrefixindex extends SpecialAllpages {
* @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;
+
+ protected $hideRedirects = false;
+
// Inherit $maxPerPage
function __construct() {
// Inherit $maxPerPage
function __construct() {
@@
-52,7
+61,8
@@
class SpecialPrefixindex extends SpecialAllpages {
$prefix = $request->getVal( 'prefix', '' );
$ns = $request->getIntOrNull( 'namespace' );
$namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
$prefix = $request->getVal( 'prefix', '' );
$ns = $request->getIntOrNull( 'namespace' );
$namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
- $hideredirects = $request->getBool( 'hideredirects', false );
+ $this->hideRedirects = $request->getBool( 'hideredirects', $this->hideRedirects );
+ $this->stripPrefix = $request->getBool( 'stripprefix', $this->stripPrefix );
$namespaces = $wgContLang->getNamespaces();
$out->setPageTitle(
$namespaces = $wgContLang->getNamespaces();
$out->setPageTitle(
@@
-74,9
+84,9
@@
class SpecialPrefixindex extends SpecialAllpages {
// Bug 27864: if transcluded, show all pages instead of the form.
if ( $this->including() || $showme != '' || $ns !== null ) {
// Bug 27864: if transcluded, show all pages instead of the form.
if ( $this->including() || $showme != '' || $ns !== null ) {
- $this->showPrefixChunk( $namespace, $showme, $from
, $hideredirects
);
+ $this->showPrefixChunk( $namespace, $showme, $from );
} else {
} else {
- $out->addHTML( $this->namespacePrefixForm( $namespace, null
, $hideredirects
) );
+ $out->addHTML( $this->namespacePrefixForm( $namespace, null ) );
}
}
}
}
@@
-84,10
+94,9
@@
class SpecialPrefixindex extends SpecialAllpages {
* HTML for the top form
* @param $namespace Integer: a namespace constant (default NS_MAIN).
* @param string $from dbKey we are starting listing at.
* HTML for the top form
* @param $namespace Integer: a namespace constant (default NS_MAIN).
* @param string $from dbKey we are starting listing at.
- * @param bool $hideredirects hide redirects (default FALSE)
* @return string
*/
* @return string
*/
-
function namespacePrefixForm( $namespace = NS_MAIN, $from = '', $hideredirects = false
) {
+
protected function namespacePrefixForm( $namespace = NS_MAIN, $from = ''
) {
global $wgScript;
$out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
global $wgScript;
$out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
@@
-120,7
+129,13
@@
class SpecialPrefixindex extends SpecialAllpages {
$this->msg( 'allpages-hide-redirects' )->text(),
'hideredirects',
'hideredirects',
$this->msg( 'allpages-hide-redirects' )->text(),
'hideredirects',
'hideredirects',
- $hideredirects
+ $this->hideRedirects
+ ) . ' ' .
+ Xml::checkLabel(
+ $this->msg( 'prefixindex-strip' )->text(),
+ 'stripprefix',
+ 'stripprefix',
+ $this->stripPrefix
) . ' ' .
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
"</td>
) . ' ' .
Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) .
"</td>
@@
-137,9
+152,8
@@
class SpecialPrefixindex extends SpecialAllpages {
* @param $namespace Integer, default NS_MAIN
* @param $prefix String
* @param string $from list all pages from this name (default FALSE)
* @param $namespace Integer, default NS_MAIN
* @param $prefix String
* @param string $from list all pages from this name (default FALSE)
- * @param bool $hideredirects hide redirects (default FALSE)
*/
*/
-
function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null, $hideredirects = false
) {
+
protected function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null
) {
global $wgContLang;
if ( $from === null ) {
global $wgContLang;
if ( $from === null ) {
@@
-170,7
+184,7
@@
class SpecialPrefixindex extends SpecialAllpages {
'page_title >= ' . $dbr->addQuotes( $fromKey ),
);
'page_title >= ' . $dbr->addQuotes( $fromKey ),
);
- if ( $
hider
edirects ) {
+ if ( $
this->hideR
edirects ) {
$conds['page_is_redirect'] = 0;
}
$conds['page_is_redirect'] = 0;
}
@@
-191,13
+205,19
@@
class SpecialPrefixindex extends SpecialAllpages {
if ( $res->numRows() > 0 ) {
$out = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-list-table' ) );
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 ) {
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
if ( $t ) {
+ $displayed = $t->getText();
+ // Try not to generate unclickable links
+ if ( $this->stripPrefix && $prefixLength !== strlen( $displayed ) ) {
+ $displayed = substr( $displayed, $prefixLength );
+ }
$link = ( $s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
Linker::linkKnown(
$t,
$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>' : '' );
$s->page_is_redirect ? array( 'class' => 'mw-redirect' ) : array()
) .
( $s->page_is_redirect ? '</div>' : '' );
@@
-228,7
+248,7
@@
class SpecialPrefixindex extends SpecialAllpages {
if ( $this->including() ) {
$out2 = '';
} else {
if ( $this->including() ) {
$out2 = '';
} else {
- $nsForm = $this->namespacePrefixForm( $namespace, $prefix
, $hideredirects
);
+ $nsForm = $this->namespacePrefixForm( $namespace, $prefix );
$self = $this->getTitle();
$out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) .
'<tr>
$self = $this->getTitle();
$out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) .
'<tr>
@@
-243,7
+263,7
@@
class SpecialPrefixindex extends SpecialAllpages {
$query = array(
'from' => $s->page_title,
'prefix' => $prefix,
$query = array(
'from' => $s->page_title,
'prefix' => $prefix,
- 'hideredirects' => $
hider
edirects,
+ 'hideredirects' => $
this->hideR
edirects,
);
if ( $namespace || $prefix == '' ) {
);
if ( $namespace || $prefix == '' ) {