From: Aaron Schulz Date: Wed, 21 Mar 2007 09:43:21 +0000 (+0000) Subject: *Add namespace filter to protectpages (bug 9326), type and level added too X-Git-Tag: 1.31.0-rc.0~53665 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=3922ee49d1742381115b773f8726f43270a273e8;p=lhc%2Fweb%2Fwiklou.git *Add namespace filter to protectpages (bug 9326), type and level added too --- diff --git a/includes/SpecialProtectedpages.php b/includes/SpecialProtectedpages.php index f89355a110..9d9a15f579 100644 --- a/includes/SpecialProtectedpages.php +++ b/includes/SpecialProtectedpages.php @@ -10,7 +10,7 @@ */ class ProtectedPagesForm { function showList( $msg = '' ) { - global $wgOut; + global $wgOut, $wgRequest; $wgOut->setPagetitle( wfMsg( "protectedpages" ) ); if ( "" != $msg ) { @@ -22,7 +22,13 @@ class ProtectedPagesForm { Title::purgeExpiredRestrictions(); } - $pager = new ProtectedPagesPager( $this ); + $type = $wgRequest->getVal( 'type' ); + $level = $wgRequest->getVal( 'level' ); + $NS = $wgRequest->getIntOrNull( 'namespace' ); + + $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS ); + + $wgOut->addHTML( $this->showOptions( $NS, $type, $level ) ); if ( $pager->getNumRows() ) { $s = $pager->getNavigationBar(); @@ -54,7 +60,7 @@ class ProtectedPagesForm { $description_items = array (); - $protType = wfMsg( 'restriction-level-' . $row->pr_level ); + $protType = wfMsgHtml( 'restriction-level-' . $row->pr_level ); $description_items[] = $protType; @@ -72,6 +78,92 @@ class ProtectedPagesForm { return '
  • ' . wfSpecialList( $link, implode( $description_items, ', ' ) ) . "
  • \n"; } + + /** + * @param $namespace int + * @param $type string + * @param $level string + * @private + */ + function showOptions( $namespace, $type, $level ) { + global $wgScript; + $action = htmlspecialchars( $wgScript ); + $title = SpecialPage::getTitleFor( 'ProtectedPages' ); + $special = htmlspecialchars( $title->getPrefixedDBkey() ); + return "
    \n" . + '
    ' . + Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) . + Xml::hidden( 'title', $special ) . "\n" . + $this->getNamespaceMenu( $namespace ) . "\n" . + $this->getTypeMenu( $type ) . "\n" . + $this->getLevelMenu( $level ) . "\n" . + Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . + "
    "; + } + + function getNamespaceMenu( $namespace=NULL ) { + return "" . HTMLnamespaceselector($namespace, ''); + } + + /** + * @return string Formatted HTML + * @private + */ + function getTypeMenu( $pr_type ) { + global $wgRestrictionTypes, $wgUser; + + $out = "'; + return ": " . $out; + } + + /** + * @return string Formatted HTML + * @private + */ + function getLevelMenu( $pr_level ) { + global $wgRestrictionLevels, $wgUser; + + $out = "'; + return ": " . $out; + } } /** @@ -81,9 +173,12 @@ class ProtectedPagesForm { class ProtectedPagesPager extends ReverseChronologicalPager { public $mForm, $mConds; - function __construct( $form, $conds = array() ) { + function __construct( $form, $conds = array(), $type, $level, $namespace ) { $this->mForm = $form; $this->mConds = $conds; + $this->type = ( $type ) ? $type : 'edit'; + $this->level = $level; + $this->namespace = $namespace; parent::__construct(); } @@ -112,9 +207,14 @@ class ProtectedPagesPager extends ReverseChronologicalPager { $conds = $this->mConds; $conds[] = 'pr_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ); $conds[] = 'page_id=pr_page'; + $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type ); + if ( $this->level ) + $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level ); + if ( $this->namespace ) + $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace ); return array( 'tables' => array( 'page_restrictions', 'page' ), - 'fields' => 'max(pr_id) AS pr_id,page_namespace,page_title,pr_level,pr_expiry', + 'fields' => 'max(pr_id) AS pr_id,page_namespace,page_title,pr_type,pr_level,pr_expiry', 'conds' => $conds, 'options' => array( 'GROUP BY' => 'page_namespace,page_title,pr_level,pr_expiry' ), ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 7ab0302651..cf0d5b28d3 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1813,6 +1813,8 @@ page protection levels. Here are the current settings for the page $1 'cascading', 'protect-expiring' => 'expires $1 (UTC)', 'protect-cascade' => 'Cascading protection - protect any pages included in this page.', +'restriction-type' => 'Permission', +'restriction-level' => 'Restriction level', # restrictions (nouns) 'restriction-edit' => 'Edit', @@ -1821,6 +1823,7 @@ page protection levels. Here are the current settings for the page $1 'full protected', 'restriction-level-autoconfirmed' => 'semi protected', +'restriction-level-all' => 'any level', # Undelete