Index: trunk/phase3/includes/SpecialProtectedpages.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | */ |
12 | 12 | class ProtectedPagesForm { |
13 | 13 | function showList( $msg = '' ) { |
14 | | - global $wgOut; |
| 14 | + global $wgOut, $wgRequest; |
15 | 15 | |
16 | 16 | $wgOut->setPagetitle( wfMsg( "protectedpages" ) ); |
17 | 17 | if ( "" != $msg ) { |
— | — | @@ -22,8 +22,14 @@ |
23 | 23 | Title::purgeExpiredRestrictions(); |
24 | 24 | } |
25 | 25 | |
26 | | - $pager = new ProtectedPagesPager( $this ); |
| 26 | + $type = $wgRequest->getVal( 'type' ); |
| 27 | + $level = $wgRequest->getVal( 'level' ); |
| 28 | + $NS = $wgRequest->getIntOrNull( 'namespace' ); |
27 | 29 | |
| 30 | + $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS ); |
| 31 | + |
| 32 | + $wgOut->addHTML( $this->showOptions( $NS, $type, $level ) ); |
| 33 | + |
28 | 34 | if ( $pager->getNumRows() ) { |
29 | 35 | $s = $pager->getNavigationBar(); |
30 | 36 | $s .= "<ul>" . |
— | — | @@ -54,7 +60,7 @@ |
55 | 61 | |
56 | 62 | $description_items = array (); |
57 | 63 | |
58 | | - $protType = wfMsg( 'restriction-level-' . $row->pr_level ); |
| 64 | + $protType = wfMsgHtml( 'restriction-level-' . $row->pr_level ); |
59 | 65 | |
60 | 66 | $description_items[] = $protType; |
61 | 67 | |
— | — | @@ -72,6 +78,92 @@ |
73 | 79 | |
74 | 80 | return '<li>' . wfSpecialList( $link, implode( $description_items, ', ' ) ) . "</li>\n"; |
75 | 81 | } |
| 82 | + |
| 83 | + /** |
| 84 | + * @param $namespace int |
| 85 | + * @param $type string |
| 86 | + * @param $level string |
| 87 | + * @private |
| 88 | + */ |
| 89 | + function showOptions( $namespace, $type, $level ) { |
| 90 | + global $wgScript; |
| 91 | + $action = htmlspecialchars( $wgScript ); |
| 92 | + $title = SpecialPage::getTitleFor( 'ProtectedPages' ); |
| 93 | + $special = htmlspecialchars( $title->getPrefixedDBkey() ); |
| 94 | + return "<form action=\"$action\" method=\"get\">\n" . |
| 95 | + '<fieldset>' . |
| 96 | + Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) . |
| 97 | + Xml::hidden( 'title', $special ) . "\n" . |
| 98 | + $this->getNamespaceMenu( $namespace ) . "\n" . |
| 99 | + $this->getTypeMenu( $type ) . "\n" . |
| 100 | + $this->getLevelMenu( $level ) . "\n" . |
| 101 | + Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
| 102 | + "</fieldset></form>"; |
| 103 | + } |
| 104 | + |
| 105 | + function getNamespaceMenu( $namespace=NULL ) { |
| 106 | + return "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>" . HTMLnamespaceselector($namespace, ''); |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * @return string Formatted HTML |
| 111 | + * @private |
| 112 | + */ |
| 113 | + function getTypeMenu( $pr_type ) { |
| 114 | + global $wgRestrictionTypes, $wgUser; |
| 115 | + |
| 116 | + $out = "<select name='type'>\n"; |
| 117 | + $m = array(); // Temporary array |
| 118 | + |
| 119 | + // First pass to load the log names |
| 120 | + foreach( $wgRestrictionTypes as $type ) { |
| 121 | + $text = wfMsgHtml("restriction-$type"); |
| 122 | + $m[$text] = $type; |
| 123 | + } |
| 124 | + |
| 125 | + // Second pass to sort by name |
| 126 | + ksort($m); |
| 127 | + |
| 128 | + // Third pass generates sorted XHTML content |
| 129 | + foreach( $m as $text => $type ) { |
| 130 | + $selected = ($type == $pr_type ); |
| 131 | + $out .= Xml::option( $text, $type, $selected ) . "\n"; |
| 132 | + } |
| 133 | + |
| 134 | + $out .= '</select>'; |
| 135 | + return "<label for='type'>" . wfMsgHtml('restriction-type') . "</label>: " . $out; |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * @return string Formatted HTML |
| 140 | + * @private |
| 141 | + */ |
| 142 | + function getLevelMenu( $pr_level ) { |
| 143 | + global $wgRestrictionLevels, $wgUser; |
| 144 | + |
| 145 | + $out = "<select name='level'>\n"; |
| 146 | + $m = array( wfMsgHtml('restriction-level-all') => 0 ); // Temporary array |
| 147 | + |
| 148 | + // First pass to load the log names |
| 149 | + foreach( $wgRestrictionLevels as $type ) { |
| 150 | + if ( $type !='' && $type !='*') { |
| 151 | + $text = wfMsgHtml("restriction-level-$type"); |
| 152 | + $m[$text] = $type; |
| 153 | + } |
| 154 | + } |
| 155 | + |
| 156 | + // Second pass to sort by name |
| 157 | + ksort($m); |
| 158 | + |
| 159 | + // Third pass generates sorted XHTML content |
| 160 | + foreach( $m as $text => $type ) { |
| 161 | + $selected = ($type == $pr_level ); |
| 162 | + $out .= Xml::option( $text, $type, $selected ) . "\n"; |
| 163 | + } |
| 164 | + |
| 165 | + $out .= '</select>'; |
| 166 | + return "<label for='level'>" . wfMsgHtml('restriction-level') . "</label>: " . $out; |
| 167 | + } |
76 | 168 | } |
77 | 169 | |
78 | 170 | /** |
— | — | @@ -81,9 +173,12 @@ |
82 | 174 | class ProtectedPagesPager extends ReverseChronologicalPager { |
83 | 175 | public $mForm, $mConds; |
84 | 176 | |
85 | | - function __construct( $form, $conds = array() ) { |
| 177 | + function __construct( $form, $conds = array(), $type, $level, $namespace ) { |
86 | 178 | $this->mForm = $form; |
87 | 179 | $this->mConds = $conds; |
| 180 | + $this->type = ( $type ) ? $type : 'edit'; |
| 181 | + $this->level = $level; |
| 182 | + $this->namespace = $namespace; |
88 | 183 | parent::__construct(); |
89 | 184 | } |
90 | 185 | |
— | — | @@ -112,9 +207,14 @@ |
113 | 208 | $conds = $this->mConds; |
114 | 209 | $conds[] = 'pr_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ); |
115 | 210 | $conds[] = 'page_id=pr_page'; |
| 211 | + $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type ); |
| 212 | + if ( $this->level ) |
| 213 | + $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level ); |
| 214 | + if ( $this->namespace ) |
| 215 | + $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace ); |
116 | 216 | return array( |
117 | 217 | 'tables' => array( 'page_restrictions', 'page' ), |
118 | | - 'fields' => 'max(pr_id) AS pr_id,page_namespace,page_title,pr_level,pr_expiry', |
| 218 | + 'fields' => 'max(pr_id) AS pr_id,page_namespace,page_title,pr_type,pr_level,pr_expiry', |
119 | 219 | 'conds' => $conds, |
120 | 220 | 'options' => array( 'GROUP BY' => 'page_namespace,page_title,pr_level,pr_expiry' ), |
121 | 221 | ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1813,6 +1813,8 @@ |
1814 | 1814 | 'protect-summary-cascade' => 'cascading', |
1815 | 1815 | 'protect-expiring' => 'expires $1 (UTC)', |
1816 | 1816 | 'protect-cascade' => 'Cascading protection - protect any pages included in this page.', |
| 1817 | +'restriction-type' => 'Permission', |
| 1818 | +'restriction-level' => 'Restriction level', |
1817 | 1819 | |
1818 | 1820 | # restrictions (nouns) |
1819 | 1821 | 'restriction-edit' => 'Edit', |
— | — | @@ -1821,6 +1823,7 @@ |
1822 | 1824 | # restriction levels |
1823 | 1825 | 'restriction-level-sysop' => 'full protected', |
1824 | 1826 | 'restriction-level-autoconfirmed' => 'semi protected', |
| 1827 | +'restriction-level-all' => 'any level', |
1825 | 1828 | |
1826 | 1829 | |
1827 | 1830 | # Undelete |