2007-01-22 05:01:37 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* Implements Special:Protectedpages
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-15 07:16:58 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2007-01-22 05:01:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* A special page that lists protected pages
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2007-01-22 05:01:37 +00:00
|
|
|
*/
|
2010-08-15 16:57:07 +00:00
|
|
|
class SpecialProtectedpages extends SpecialPage {
|
2007-05-03 14:32:52 +00:00
|
|
|
|
|
|
|
|
protected $IdLevel = 'level';
|
|
|
|
|
protected $IdType = 'type';
|
|
|
|
|
|
2010-08-15 16:57:07 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct( 'Protectedpages' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute( $par ) {
|
|
|
|
|
$this->setHeaders();
|
|
|
|
|
$this->outputHeader();
|
2007-01-22 05:01:37 +00:00
|
|
|
|
2007-02-15 11:16:42 +00:00
|
|
|
// Purge expired entries on one in every 10 queries
|
2009-01-09 13:38:43 +00:00
|
|
|
if( !mt_rand( 0, 10 ) ) {
|
2007-02-15 11:16:42 +00:00
|
|
|
Title::purgeExpiredRestrictions();
|
|
|
|
|
}
|
2007-01-22 05:01:37 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$type = $request->getVal( $this->IdType );
|
|
|
|
|
$level = $request->getVal( $this->IdLevel );
|
|
|
|
|
$sizetype = $request->getVal( 'sizetype' );
|
|
|
|
|
$size = $request->getIntOrNull( 'size' );
|
|
|
|
|
$NS = $request->getIntOrNull( 'namespace' );
|
|
|
|
|
$indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0;
|
|
|
|
|
$cascadeOnly = $request->getBool('cascadeonly') ? 1 : 0;
|
2007-03-21 09:43:21 +00:00
|
|
|
|
2008-08-13 15:40:47 +00:00
|
|
|
$pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS, $sizetype, $size, $indefOnly, $cascadeOnly );
|
2007-03-21 09:43:21 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly ) );
|
2007-01-22 05:01:37 +00:00
|
|
|
|
2009-01-09 13:38:43 +00:00
|
|
|
if( $pager->getNumRows() ) {
|
2012-04-03 21:04:37 +00:00
|
|
|
$this->getOutput()->addHTML(
|
|
|
|
|
$pager->getNavigationBar() .
|
|
|
|
|
'<ul>' . $pager->getBody() . '</ul>' .
|
|
|
|
|
$pager->getNavigationBar()
|
|
|
|
|
);
|
2007-02-15 11:16:42 +00:00
|
|
|
} else {
|
2012-04-03 21:04:37 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'protectedpagesempty' );
|
2007-02-15 11:16:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-01-22 05:01:37 +00:00
|
|
|
|
|
|
|
|
/**
|
2007-02-15 11:16:42 +00:00
|
|
|
* Callback function to output a restriction
|
2008-04-15 10:26:53 +00:00
|
|
|
* @param $row object Protected title
|
|
|
|
|
* @return string Formatted <li> element
|
2007-01-22 05:01:37 +00:00
|
|
|
*/
|
2008-04-13 16:07:48 +00:00
|
|
|
public function formatRow( $row ) {
|
2007-02-15 11:16:42 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2007-01-22 05:01:37 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
static $infinity = null;
|
2007-02-15 11:16:42 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
if( is_null( $infinity ) ){
|
2011-05-18 19:29:50 +00:00
|
|
|
$infinity = wfGetDB( DB_SLAVE )->getInfinity();
|
2011-03-18 19:15:56 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-02-15 11:16:42 +00:00
|
|
|
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
|
2011-09-20 20:00:05 +00:00
|
|
|
$link = Linker::link( $title );
|
2007-01-22 05:01:37 +00:00
|
|
|
|
2007-01-22 08:57:40 +00:00
|
|
|
$description_items = array ();
|
|
|
|
|
|
2012-04-03 21:04:37 +00:00
|
|
|
$protType = $this->msg( 'restriction-level-' . $row->pr_level )->escaped();
|
2007-01-22 05:01:37 +00:00
|
|
|
|
2007-01-22 08:57:40 +00:00
|
|
|
$description_items[] = $protType;
|
|
|
|
|
|
2009-01-09 13:38:43 +00:00
|
|
|
if( $row->pr_cascade ) {
|
2012-04-03 21:04:37 +00:00
|
|
|
$description_items[] = $this->msg( 'protect-summary-cascade' )->text();
|
2007-07-17 10:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-15 10:26:53 +00:00
|
|
|
$stxt = '';
|
2011-11-21 16:13:21 +00:00
|
|
|
$lang = $this->getLanguage();
|
2007-01-22 08:57:40 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$expiry = $lang->formatExpiry( $row->pr_expiry, TS_MW );
|
2011-03-18 22:28:39 +00:00
|
|
|
if( $expiry != $infinity ) {
|
2012-04-03 21:04:37 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
$description_items[] = $this->msg(
|
2011-08-02 11:55:05 +00:00
|
|
|
'protect-expiring-local',
|
2012-04-03 21:04:37 +00:00
|
|
|
$lang->userTimeAndDate( $expiry, $user ),
|
|
|
|
|
$lang->userDate( $expiry, $user ),
|
|
|
|
|
$lang->userTime( $expiry, $user )
|
|
|
|
|
)->escaped();
|
2007-01-22 08:57:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-01-09 13:38:43 +00:00
|
|
|
if(!is_null($size = $row->page_len)) {
|
2011-09-20 20:00:05 +00:00
|
|
|
$stxt = $lang->getDirMark() . ' ' . Linker::formatRevisionSize( $size );
|
2007-03-21 18:29:31 +00:00
|
|
|
}
|
2008-04-15 10:26:53 +00:00
|
|
|
|
|
|
|
|
# Show a link to the change protection form for allowed users otherwise a link to the protection log
|
2011-09-20 20:00:05 +00:00
|
|
|
if( $this->getUser()->isAllowed( 'protect' ) ) {
|
2012-02-26 13:08:41 +00:00
|
|
|
$changeProtection = Linker::linkKnown(
|
2009-06-07 18:45:52 +00:00
|
|
|
$title,
|
2012-04-03 21:04:37 +00:00
|
|
|
$this->msg( 'protect_change' )->escaped(),
|
2009-06-07 18:45:52 +00:00
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'unprotect' )
|
2012-02-26 13:08:41 +00:00
|
|
|
);
|
2008-04-15 10:26:53 +00:00
|
|
|
} else {
|
|
|
|
|
$ltitle = SpecialPage::getTitleFor( 'Log' );
|
2012-02-26 13:08:41 +00:00
|
|
|
$changeProtection = Linker::linkKnown(
|
2009-06-07 18:45:52 +00:00
|
|
|
$ltitle,
|
2012-04-03 21:04:37 +00:00
|
|
|
$this->msg( 'protectlogpage' )->escaped(),
|
2009-06-07 18:45:52 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'type' => 'protect',
|
2009-06-15 12:32:59 +00:00
|
|
|
'page' => $title->getPrefixedText()
|
2009-06-07 18:45:52 +00:00
|
|
|
)
|
2012-02-26 13:08:41 +00:00
|
|
|
);
|
2008-04-15 10:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-26 14:02:54 +00:00
|
|
|
$changeProtection = ' ' . $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped();
|
2012-02-26 13:08:41 +00:00
|
|
|
|
2007-02-15 11:16:42 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
|
2009-09-30 13:59:29 +00:00
|
|
|
return Html::rawElement(
|
|
|
|
|
'li',
|
|
|
|
|
array(),
|
2011-10-13 11:46:21 +00:00
|
|
|
$lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n";
|
2007-02-15 11:16:42 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-03-21 09:43:21 +00:00
|
|
|
/**
|
2010-03-13 21:09:39 +00:00
|
|
|
* @param $namespace Integer
|
|
|
|
|
* @param $type String: restriction type
|
|
|
|
|
* @param $level String: restriction level
|
|
|
|
|
* @param $sizetype String: "min" or "max"
|
|
|
|
|
* @param $size Integer
|
|
|
|
|
* @param $indefOnly Boolean: only indefinie protection
|
|
|
|
|
* @param $cascadeOnly Boolean: only cascading protection
|
|
|
|
|
* @return String: input form
|
2007-03-21 09:43:21 +00:00
|
|
|
*/
|
2008-08-13 15:40:47 +00:00
|
|
|
protected function showOptions( $namespace, $type='edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly ) {
|
2007-03-21 09:43:21 +00:00
|
|
|
global $wgScript;
|
2011-09-20 20:00:05 +00:00
|
|
|
$title = $this->getTitle();
|
2008-04-15 10:26:53 +00:00
|
|
|
return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
|
|
|
|
|
Xml::openElement( 'fieldset' ) .
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::element( 'legend', array(), $this->msg( 'protectedpages' )->text() ) .
|
2010-10-31 16:20:48 +00:00
|
|
|
Html::hidden( 'title', $title->getPrefixedDBkey() ) . "\n" .
|
2010-05-30 17:33:59 +00:00
|
|
|
$this->getNamespaceMenu( $namespace ) . " \n" .
|
|
|
|
|
$this->getTypeMenu( $type ) . " \n" .
|
|
|
|
|
$this->getLevelMenu( $level ) . " \n" .
|
2009-11-14 20:59:15 +00:00
|
|
|
"<br /><span style='white-space: nowrap'>" .
|
2010-05-30 17:33:59 +00:00
|
|
|
$this->getExpiryCheck( $indefOnly ) . " \n" .
|
|
|
|
|
$this->getCascadeCheck( $cascadeOnly ) . " \n" .
|
2009-11-14 20:59:15 +00:00
|
|
|
"</span><br /><span style='white-space: nowrap'>" .
|
2010-05-30 17:33:59 +00:00
|
|
|
$this->getSizeLimit( $sizetype, $size ) . " \n" .
|
2008-04-13 16:07:48 +00:00
|
|
|
"</span>" .
|
2012-04-03 21:04:37 +00:00
|
|
|
" " . Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n" .
|
2008-04-15 10:26:53 +00:00
|
|
|
Xml::closeElement( 'fieldset' ) .
|
|
|
|
|
Xml::closeElement( 'form' );
|
2007-03-21 09:43:21 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-04 12:20:41 +00:00
|
|
|
/**
|
|
|
|
|
* Prepare the namespace filter drop-down; standard namespace
|
|
|
|
|
* selector, sans the MediaWiki namespace
|
|
|
|
|
*
|
2010-03-13 21:09:39 +00:00
|
|
|
* @param $namespace Mixed: pre-select namespace
|
|
|
|
|
* @return String
|
2007-08-04 12:20:41 +00:00
|
|
|
*/
|
2008-04-13 16:07:48 +00:00
|
|
|
protected function getNamespaceMenu( $namespace = null ) {
|
2012-03-19 14:34:27 +00:00
|
|
|
return Html::rawElement( 'span', array( 'style' => 'white-space: nowrap;' ),
|
2012-03-19 12:30:52 +00:00
|
|
|
Html::namespaceSelector(
|
|
|
|
|
array(
|
|
|
|
|
'selected' => $namespace,
|
|
|
|
|
'all' => '',
|
|
|
|
|
'label' => $this->msg( 'namespace' )->text()
|
|
|
|
|
), array(
|
|
|
|
|
'name' => 'namespace',
|
|
|
|
|
'id' => 'namespace',
|
|
|
|
|
'class' => 'namespaceselector',
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
2008-04-13 16:07:48 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 16:07:48 +00:00
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
|
|
|
|
*/
|
|
|
|
|
protected function getExpiryCheck( $indefOnly ) {
|
2008-04-17 19:16:27 +00:00
|
|
|
return
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::checkLabel( $this->msg( 'protectedpages-indef' )->text(), 'indefonly', 'indefonly', $indefOnly ) . "\n";
|
2007-03-21 09:43:21 +00:00
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2008-08-13 15:40:47 +00:00
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
|
|
|
|
*/
|
|
|
|
|
protected function getCascadeCheck( $cascadeOnly ) {
|
|
|
|
|
return
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::checkLabel( $this->msg( 'protectedpages-cascade' )->text(), 'cascadeonly', 'cascadeonly', $cascadeOnly ) . "\n";
|
2008-08-13 15:40:47 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-03-21 21:07:15 +00:00
|
|
|
/**
|
|
|
|
|
* @return string Formatted HTML
|
|
|
|
|
*/
|
2008-04-14 07:45:50 +00:00
|
|
|
protected function getSizeLimit( $sizetype, $size ) {
|
2008-04-17 19:16:27 +00:00
|
|
|
$max = $sizetype === 'max';
|
|
|
|
|
|
|
|
|
|
return
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::radioLabel( $this->msg( 'minimum-size' )->text(), 'sizetype', 'min', 'wpmin', !$max ) .
|
2010-05-30 17:33:59 +00:00
|
|
|
' ' .
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::radioLabel( $this->msg( 'maximum-size' )->text(), 'sizetype', 'max', 'wpmax', $max ) .
|
2010-05-30 17:33:59 +00:00
|
|
|
' ' .
|
2008-04-17 19:16:27 +00:00
|
|
|
Xml::input( 'size', 9, $size, array( 'id' => 'wpsize' ) ) .
|
2010-05-30 17:33:59 +00:00
|
|
|
' ' .
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::label( $this->msg( 'pagesize' )->text(), 'wpsize' );
|
2007-03-21 21:07:15 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-03-21 09:43:21 +00:00
|
|
|
/**
|
2009-09-30 13:59:29 +00:00
|
|
|
* Creates the input label of the restriction type
|
|
|
|
|
* @param $pr_type string Protection type
|
2007-03-21 09:43:21 +00:00
|
|
|
* @return string Formatted HTML
|
|
|
|
|
*/
|
2008-04-13 16:07:48 +00:00
|
|
|
protected function getTypeMenu( $pr_type ) {
|
2007-03-21 09:43:21 +00:00
|
|
|
$m = array(); // Temporary array
|
2007-05-03 14:32:52 +00:00
|
|
|
$options = array();
|
2007-03-21 09:43:21 +00:00
|
|
|
|
|
|
|
|
// First pass to load the log names
|
2011-02-26 16:29:48 +00:00
|
|
|
foreach( Title::getFilteredRestrictionTypes( true ) as $type ) {
|
2012-04-03 21:04:37 +00:00
|
|
|
$text = $this->msg( "restriction-$type" )->text();
|
2007-03-21 09:43:21 +00:00
|
|
|
$m[$text] = $type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Third pass generates sorted XHTML content
|
|
|
|
|
foreach( $m as $text => $type ) {
|
|
|
|
|
$selected = ($type == $pr_type );
|
2007-05-03 14:32:52 +00:00
|
|
|
$options[] = Xml::option( $text, $type, $selected ) . "\n";
|
2007-03-21 09:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-13 16:07:48 +00:00
|
|
|
return "<span style='white-space: nowrap'>" .
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::label( $this->msg( 'restriction-type' )->text(), $this->IdType ) . ' ' .
|
2007-05-03 14:32:52 +00:00
|
|
|
Xml::tags( 'select',
|
|
|
|
|
array( 'id' => $this->IdType, 'name' => $this->IdType ),
|
2008-04-13 16:07:48 +00:00
|
|
|
implode( "\n", $options ) ) . "</span>";
|
2007-03-21 09:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-09-30 13:59:29 +00:00
|
|
|
* Creates the input label of the restriction level
|
|
|
|
|
* @param $pr_level string Protection level
|
2007-03-21 09:43:21 +00:00
|
|
|
* @return string Formatted HTML
|
2008-04-14 07:45:50 +00:00
|
|
|
*/
|
2008-04-13 16:07:48 +00:00
|
|
|
protected function getLevelMenu( $pr_level ) {
|
2007-05-03 14:32:52 +00:00
|
|
|
global $wgRestrictionLevels;
|
|
|
|
|
|
2012-04-03 21:04:37 +00:00
|
|
|
$m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); // Temporary array
|
2007-05-03 14:32:52 +00:00
|
|
|
$options = array();
|
2007-03-21 09:43:21 +00:00
|
|
|
|
|
|
|
|
// First pass to load the log names
|
|
|
|
|
foreach( $wgRestrictionLevels as $type ) {
|
2009-06-07 18:45:52 +00:00
|
|
|
// Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
|
2009-01-09 13:38:43 +00:00
|
|
|
if( $type !='' && $type !='*') {
|
2012-04-03 21:04:37 +00:00
|
|
|
$text = $this->msg( "restriction-level-$type" )->text();
|
2007-03-21 09:43:21 +00:00
|
|
|
$m[$text] = $type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Third pass generates sorted XHTML content
|
|
|
|
|
foreach( $m as $text => $type ) {
|
|
|
|
|
$selected = ($type == $pr_level );
|
2007-05-03 14:32:52 +00:00
|
|
|
$options[] = Xml::option( $text, $type, $selected );
|
2007-03-21 09:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-30 13:59:29 +00:00
|
|
|
return "<span style='white-space: nowrap'>" .
|
2012-04-03 21:04:37 +00:00
|
|
|
Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . ' ' .
|
2007-05-03 14:32:52 +00:00
|
|
|
Xml::tags( 'select',
|
|
|
|
|
array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
|
2009-09-30 13:59:29 +00:00
|
|
|
implode( "\n", $options ) ) . "</span>";
|
2007-03-21 09:43:21 +00:00
|
|
|
}
|
2007-02-15 11:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2007-04-04 05:22:37 +00:00
|
|
|
* @todo document
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Pager
|
2007-02-15 11:16:42 +00:00
|
|
|
*/
|
2007-05-01 20:22:51 +00:00
|
|
|
class ProtectedPagesPager extends AlphabeticPager {
|
2007-02-15 11:16:42 +00:00
|
|
|
public $mForm, $mConds;
|
2008-04-13 16:07:48 +00:00
|
|
|
private $type, $level, $namespace, $sizetype, $size, $indefonly;
|
2007-02-15 11:16:42 +00:00
|
|
|
|
2011-03-18 20:37:11 +00:00
|
|
|
function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype='', $size=0,
|
2009-01-09 13:38:43 +00:00
|
|
|
$indefonly = false, $cascadeonly = false )
|
|
|
|
|
{
|
2007-02-15 11:16:42 +00:00
|
|
|
$this->mForm = $form;
|
|
|
|
|
$this->mConds = $conds;
|
2007-03-21 09:43:21 +00:00
|
|
|
$this->type = ( $type ) ? $type : 'edit';
|
|
|
|
|
$this->level = $level;
|
|
|
|
|
$this->namespace = $namespace;
|
2007-05-01 20:22:51 +00:00
|
|
|
$this->sizetype = $sizetype;
|
|
|
|
|
$this->size = intval($size);
|
2008-04-13 16:07:48 +00:00
|
|
|
$this->indefonly = (bool)$indefonly;
|
2008-08-13 15:40:47 +00:00
|
|
|
$this->cascadeonly = (bool)$cascadeonly;
|
2011-09-20 20:00:05 +00:00
|
|
|
parent::__construct( $form->getContext() );
|
2007-02-15 11:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStartBody() {
|
|
|
|
|
# Do a link batch query
|
|
|
|
|
$lb = new LinkBatch;
|
2010-10-13 23:11:40 +00:00
|
|
|
foreach ( $this->mResult as $row ) {
|
2007-05-09 14:46:44 +00:00
|
|
|
$lb->add( $row->page_namespace, $row->page_title );
|
2007-02-15 11:16:42 +00:00
|
|
|
}
|
|
|
|
|
$lb->execute();
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-02-15 11:16:42 +00:00
|
|
|
function formatRow( $row ) {
|
|
|
|
|
return $this->mForm->formatRow( $row );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQueryInfo() {
|
|
|
|
|
$conds = $this->mConds;
|
2009-03-17 15:27:48 +00:00
|
|
|
$conds[] = '(pr_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
|
|
|
|
|
'OR pr_expiry IS NULL)';
|
2007-02-15 11:16:42 +00:00
|
|
|
$conds[] = 'page_id=pr_page';
|
2007-03-21 09:43:21 +00:00
|
|
|
$conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2007-05-08 09:09:46 +00:00
|
|
|
if( $this->sizetype=='min' ) {
|
2007-05-01 20:22:51 +00:00
|
|
|
$conds[] = 'page_len>=' . $this->size;
|
2011-06-17 16:05:05 +00:00
|
|
|
} elseif( $this->sizetype=='max' ) {
|
2007-05-01 20:22:51 +00:00
|
|
|
$conds[] = 'page_len<=' . $this->size;
|
2007-05-08 09:09:46 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 16:07:48 +00:00
|
|
|
if( $this->indefonly ) {
|
2011-04-23 14:24:42 +00:00
|
|
|
$db = wfGetDB( DB_SLAVE );
|
|
|
|
|
$conds[] = "pr_expiry = {$db->addQuotes( $db->getInfinity() )} OR pr_expiry IS NULL";
|
2008-04-13 16:07:48 +00:00
|
|
|
}
|
2009-01-09 13:38:43 +00:00
|
|
|
if( $this->cascadeonly ) {
|
2008-08-13 15:40:47 +00:00
|
|
|
$conds[] = "pr_cascade = '1'";
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-05-01 20:22:51 +00:00
|
|
|
if( $this->level )
|
2007-03-21 09:43:21 +00:00
|
|
|
$conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
|
2007-05-01 20:22:51 +00:00
|
|
|
if( !is_null($this->namespace) )
|
2007-03-21 09:43:21 +00:00
|
|
|
$conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace );
|
2007-02-15 11:16:42 +00:00
|
|
|
return array(
|
|
|
|
|
'tables' => array( 'page_restrictions', 'page' ),
|
2007-07-17 10:27:23 +00:00
|
|
|
'fields' => 'pr_id,page_namespace,page_title,page_len,pr_type,pr_level,pr_expiry,pr_cascade',
|
2007-05-04 16:09:09 +00:00
|
|
|
'conds' => $conds
|
2007-02-15 11:16:42 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getIndexField() {
|
2007-03-21 21:07:15 +00:00
|
|
|
return 'pr_id';
|
2007-01-22 05:01:37 +00:00
|
|
|
}
|
|
|
|
|
}
|