APIEDIT BRANCH MERGE:
[lhc/web/wiklou.git] / includes / SpecialProtectedpages.php
index 40143e5..60a8d60 100644 (file)
@@ -9,6 +9,10 @@
  * @addtogroup SpecialPage
  */
 class ProtectedPagesForm {
+
+       protected $IdLevel = 'level';
+       protected $IdType  = 'type';
+
        function showList( $msg = '' ) {
                global $wgOut, $wgRequest;
 
@@ -22,8 +26,8 @@ class ProtectedPagesForm {
                        Title::purgeExpiredRestrictions();
                }
 
-               $type = $wgRequest->getVal( 'type' );
-               $level = $wgRequest->getVal( 'level' );
+               $type = $wgRequest->getVal( $this->IdType );
+               $level = $wgRequest->getVal( $this->IdLevel );
                $sizetype = $wgRequest->getVal( 'sizetype' );
                $size = $wgRequest->getIntOrNull( 'size' );
                $NS = $wgRequest->getIntOrNull( 'namespace' );
@@ -48,7 +52,7 @@ class ProtectedPagesForm {
         * Callback function to output a restriction
         */
        function formatRow( $row ) {
-               global $wgUser, $wgLang;
+               global $wgUser, $wgLang, $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
@@ -66,6 +70,10 @@ class ProtectedPagesForm {
 
                $description_items[] = $protType;
 
+               if ( $row->pr_cascade ) {
+                       $description_items[] = wfMsg( 'protect-summary-cascade' );
+               }
+
                $expiry_description = ''; $stxt = '';
 
                if ( $row->pr_expiry != 'infinity' && strlen($row->pr_expiry) ) {
@@ -81,6 +89,7 @@ class ProtectedPagesForm {
                                $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
                        else
                                $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum( $size ) ) . '</small>';
+                       $stxt = $wgContLang->getDirMark() . $stxt;
                }
                wfProfileOut( __METHOD__ );
 
@@ -102,19 +111,28 @@ class ProtectedPagesForm {
                return "<form action=\"$action\" method=\"get\">\n" .
                        '<fieldset>' .
                        Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) .
-                       Xml::hidden( 'title', $special ) . "&nbsp\n" .
-                       $this->getNamespaceMenu( $namespace ) . "&nbsp\n" .
-                       $this->getTypeMenu( $type ) . "&nbsp\n" .
+                       Xml::hidden( 'title', $special ) . "&nbsp;\n" .
+                       $this->getNamespaceMenu( $namespace ) . "&nbsp;\n" .
+                       $this->getTypeMenu( $type ) . "&nbsp;\n" .
                        $this->getLevelMenu( $level ) . "<br/>\n" .
                        $this->getSizeLimit( $sizetype, $size ) . "\n" .
-                       "&nbsp" . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
+                       "&nbsp;" . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
                        "</fieldset></form>";
        }
        
-       function getNamespaceMenu( $namespace=NULL ) {
-               return "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>" . HTMLnamespaceselector($namespace, '');
+       /**
+        * Prepare the namespace filter drop-down; standard namespace
+        * selector, sans the MediaWiki namespace
+        *
+        * @param mixed $namespace Pre-select namespace
+        * @return string
+        */
+       function getNamespaceMenu( $namespace = null ) {
+               return Xml::label( wfMsg( 'namespace' ), 'namespace' )
+                       . '&nbsp;'
+                       . Xml::namespaceSelector( $namespace, '' );
        }
-
+       
        /**
         * @return string Formatted HTML
         * @private
@@ -122,10 +140,10 @@ class ProtectedPagesForm {
        function getSizeLimit( $sizetype, $size ) {     
                $out = Xml::radio( 'sizetype', 'min', ($sizetype=='min'), array('id' => 'wpmin') );
                $out .= Xml::label( wfMsg("minimum-size"), 'wpmin' );
-               $out .= "&nbsp".Xml::radio( 'sizetype', 'max', ($sizetype=='max'), array('id' => 'wpmax') );
+               $out .= "&nbsp;".Xml::radio( 'sizetype', 'max', ($sizetype=='max'), array('id' => 'wpmax') );
                $out .= Xml::label( wfMsg("maximum-size"), 'wpmax' );
-               $out .= "&nbsp".Xml::input('size', 9, $size, array( 'id' => 'wpsize' ) );
-               $out .= ' '.wfMsg('pagesize');
+               $out .= "&nbsp;".Xml::input('size', 9, $size, array( 'id' => 'wpsize' ) );
+               $out .= ' '.wfMsgHtml('pagesize');
                return $out;
        }
                
@@ -134,28 +152,28 @@ class ProtectedPagesForm {
         * @private
         */
        function getTypeMenu( $pr_type ) {
-               global $wgRestrictionTypes, $wgUser;
+               global $wgRestrictionTypes;
        
-               $out = "<select name='type'>\n";
                $m = array(); // Temporary array
+               $options = array();
 
                // First pass to load the log names
                foreach( $wgRestrictionTypes as $type ) {
-                       $text = wfMsgHtml("restriction-$type");
+                       $text = wfMsg("restriction-$type");
                        $m[$text] = $type;
                }
 
-               // Second pass to sort by name
-               ksort($m);
-
                // Third pass generates sorted XHTML content
                foreach( $m as $text => $type ) {
                        $selected = ($type == $pr_type );
-                       $out .= Xml::option( $text, $type, $selected ) . "\n";
+                       $options[] = Xml::option( $text, $type, $selected ) . "\n";
                }
 
-               $out .= '</select>';
-               return "<label for='type'>" . wfMsgHtml('restriction-type') . "</label>: " . $out;
+               return
+                       Xml::label( wfMsg('restriction-type') , $this->IdType ) . '&nbsp;' .
+                       Xml::tags( 'select',
+                               array( 'id' => $this->IdType, 'name' => $this->IdType ),
+                               implode( "\n", $options ) );
        }
 
        /**
@@ -163,30 +181,30 @@ class ProtectedPagesForm {
         * @private
         */     
        function getLevelMenu( $pr_level ) {
-               global $wgRestrictionLevels, $wgUser;
-       
-               $out = "<select name='level'>\n";
-               $m = array( wfMsgHtml('restriction-level-all') => 0 ); // Temporary array
+               global $wgRestrictionLevels;
+
+               $m = array( wfMsg('restriction-level-all') => 0 ); // Temporary array
+               $options = array();
 
                // First pass to load the log names
                foreach( $wgRestrictionLevels as $type ) {
                        if ( $type !='' && $type !='*') {
-                               $text = wfMsgHtml("restriction-level-$type");
+                               $text = wfMsg("restriction-level-$type");
                                $m[$text] = $type;
                        }
                }
 
-               // Second pass to sort by name
-               ksort($m);
-
                // Third pass generates sorted XHTML content
                foreach( $m as $text => $type ) {
                        $selected = ($type == $pr_level );
-                       $out .= Xml::option( $text, $type, $selected ) . "\n";
+                       $options[] = Xml::option( $text, $type, $selected );
                }
 
-               $out .= '</select>';
-               return "<label for='level'>" . wfMsgHtml('restriction-level') . "</label>: " . $out;
+               return
+                       Xml::label( wfMsg('restriction-level') , $this->IdLevel ) . '&nbsp;' .
+                       Xml::tags( 'select',
+                               array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
+                               implode( "\n", $options ) );
        }
 }
 
@@ -215,8 +233,7 @@ class ProtectedPagesPager extends AlphabeticPager {
                $lb = new LinkBatch;
 
                while ( $row = $this->mResult->fetchObject() ) {
-                       $name = str_replace( ' ', '_', $row->page_title );
-                       $lb->add( $row->page_namespace, $name );
+                       $lb->add( $row->page_namespace, $row->page_title );
                }
 
                $lb->execute();
@@ -225,7 +242,6 @@ class ProtectedPagesPager extends AlphabeticPager {
        }
        
        function formatRow( $row ) {
-               $block = new Block;
                return $this->mForm->formatRow( $row );
        }
 
@@ -235,10 +251,11 @@ class ProtectedPagesPager extends AlphabeticPager {
                $conds[] = 'page_id=pr_page';
                $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
                
-               if( $this->sizetype=='min' )
+               if( $this->sizetype=='min' ) {
                        $conds[] = 'page_len>=' . $this->size;
-               else if( $this->sizetype=='max' )
+               } else if( $this->sizetype=='max' ) {
                        $conds[] = 'page_len<=' . $this->size;
+               }
                
                if( $this->level )
                        $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
@@ -246,9 +263,8 @@ class ProtectedPagesPager extends AlphabeticPager {
                        $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,page_len,pr_type,pr_level,pr_expiry',
-                       'conds' => $conds,
-                       'options' => array( 'GROUP BY' => 'page_namespace,page_title,page_len,pr_type,pr_level,pr_expiry' ),
+                       'fields' => 'pr_id,page_namespace,page_title,page_len,pr_type,pr_level,pr_expiry,pr_cascade',
+                       'conds' => $conds
                );
        }
 
@@ -262,11 +278,10 @@ class ProtectedPagesPager extends AlphabeticPager {
  */
 function wfSpecialProtectedpages() {
 
-       list( $limit, $offset ) = wfCheckLimits();
-
        $ppForm = new ProtectedPagesForm();
 
        $ppForm->showList();
 }
 
-?>
+
+