Index: branches/robchurch/pr_timestamp/includes/SpecialProtectedpages.php |
— | — | @@ -1,18 +1,31 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
| 5 | + * Special page listing all protected pages in the wiki |
4 | 6 | * |
5 | 7 | * @addtogroup SpecialPage |
6 | 8 | */ |
| 9 | +class SpecialProtectedPages extends SpecialPage { |
7 | 10 | |
8 | | -/** |
9 | | - * @todo document |
10 | | - * @addtogroup SpecialPage |
11 | | - */ |
12 | | -class ProtectedPagesForm { |
13 | | - |
14 | 11 | protected $IdLevel = 'level'; |
15 | 12 | protected $IdType = 'type'; |
16 | 13 | |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + public function __construct() { |
| 18 | + parent::__construct( 'Protectedpages' ); |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Special page execution function |
| 23 | + * |
| 24 | + * @param mixed $par Parameters passed to the page |
| 25 | + */ |
| 26 | + public function execute( $par = false ) { |
| 27 | + $this->showList(); |
| 28 | + } |
| 29 | + |
17 | 30 | function showList( $msg = '' ) { |
18 | 31 | global $wgOut, $wgRequest; |
19 | 32 | |
— | — | @@ -86,106 +99,120 @@ |
87 | 100 | } |
88 | 101 | |
89 | 102 | /** |
90 | | - * @param $namespace int |
91 | | - * @param $type string |
92 | | - * @param $level string |
93 | | - * @param $minsize int |
94 | | - * @private |
| 103 | + * Build the filtering option panel |
| 104 | + * |
| 105 | + * @param int $namespace Pre-select namespace |
| 106 | + * @param string $type Pre-select type |
| 107 | + * @param string $level Pre-select level |
| 108 | + * @param string $sizetype Pre-select size bound |
| 109 | + * @param string $size Pre-fill size |
| 110 | + * @return string |
95 | 111 | */ |
96 | | - function showOptions( $namespace, $type='edit', $level, $sizetype, $size ) { |
| 112 | + function showOptions( $namespace, $type = 'edit', $level, $sizetype, $size ) { |
97 | 113 | global $wgScript; |
98 | | - $action = htmlspecialchars( $wgScript ); |
99 | | - $title = SpecialPage::getTitleFor( 'ProtectedPages' ); |
100 | | - $special = htmlspecialchars( $title->getPrefixedDBkey() ); |
101 | | - return "<form action=\"$action\" method=\"get\">\n" . |
102 | | - '<fieldset>' . |
103 | | - Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) . |
104 | | - Xml::hidden( 'title', $special ) . " \n" . |
105 | | - $this->getNamespaceMenu( $namespace ) . " \n" . |
106 | | - $this->getTypeMenu( $type ) . " \n" . |
107 | | - $this->getLevelMenu( $level ) . "<br/>\n" . |
108 | | - $this->getSizeLimit( $sizetype, $size ) . "\n" . |
109 | | - " " . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
110 | | - "</fieldset></form>"; |
| 114 | + $self = SpecialPage::getTitleFor( 'Protectedpages' ); |
| 115 | + return |
| 116 | + Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) |
| 117 | + . Xml::hidden( 'title', $self->getPrefixedUrl() ) |
| 118 | + . '<fieldset><legend>' . wfMsgHtml( 'protectedpages-legend' ). '</legend>' |
| 119 | + . '<table>' |
| 120 | + . '<tr>' . $this->getNamespaceMenu( $namespace ) . '</tr>' |
| 121 | + . '<tr>' . $this->getTypeMenu( $type ) . '</tr>' |
| 122 | + . '<tr>' . $this->getLevelMenu( $level ) . '</tr>' |
| 123 | + . '<tr>' . $this->getSizeLimit( $sizetype, $size ) . '</tr>' |
| 124 | + . '<tr><td></td><td>' . Xml::submitButton( wfMsg( 'protectedpages-submit' ) ) . '</td></tr>' |
| 125 | + . '</table></fieldset></form>'; |
111 | 126 | } |
112 | 127 | |
113 | | - function getNamespaceMenu( $namespace=NULL ) { |
114 | | - return "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>" . HTMLnamespaceselector($namespace, ''); |
115 | | - } |
116 | | - |
117 | 128 | /** |
118 | | - * @return string Formatted HTML |
119 | | - * @private |
| 129 | + * Build a namespace selector |
| 130 | + * |
| 131 | + * @param int $select Pre-selected namespace |
| 132 | + * @return string |
120 | 133 | */ |
121 | | - function getSizeLimit( $sizetype, $size ) { |
122 | | - $out = Xml::radio( 'sizetype', 'min', ($sizetype=='min'), array('id' => 'wpmin') ); |
123 | | - $out .= Xml::label( wfMsg("minimum-size"), 'wpmin' ); |
124 | | - $out .= " ".Xml::radio( 'sizetype', 'max', ($sizetype=='max'), array('id' => 'wpmax') ); |
125 | | - $out .= Xml::label( wfMsg("maximum-size"), 'wpmax' ); |
126 | | - $out .= " ".Xml::input('size', 9, $size, array( 'id' => 'wpsize' ) ); |
127 | | - $out .= ' '.wfMsgHtml('pagesize'); |
128 | | - return $out; |
| 134 | + private function getNamespaceMenu( $select = null ) { |
| 135 | + return |
| 136 | + '<td><label for="namespace">' . wfMsgHtml( 'namespace' ) . '</label></td>' |
| 137 | + . '<td>' . Xml::namespaceSelector( $select, '' ) . '</td>'; |
129 | 138 | } |
130 | | - |
| 139 | + |
131 | 140 | /** |
132 | | - * @return string Formatted HTML |
133 | | - * @private |
| 141 | + * Build a type selection list |
| 142 | + * |
| 143 | + * @param string $select Pre-selected type |
| 144 | + * @return string |
134 | 145 | */ |
135 | | - function getTypeMenu( $pr_type ) { |
| 146 | + private function getTypeMenu( $select ) { |
136 | 147 | global $wgRestrictionTypes; |
137 | | - |
138 | | - $m = array(); // Temporary array |
139 | 148 | $options = array(); |
140 | | - |
141 | | - // First pass to load the log names |
142 | 149 | foreach( $wgRestrictionTypes as $type ) { |
143 | | - $text = wfMsg("restriction-$type"); |
144 | | - $m[$text] = $type; |
| 150 | + $options[] = Xml::option( |
| 151 | + wfMsg( 'restriction-' . $type ), |
| 152 | + $type, |
| 153 | + $type == $select |
| 154 | + ); |
145 | 155 | } |
146 | | - |
147 | | - // Third pass generates sorted XHTML content |
148 | | - foreach( $m as $text => $type ) { |
149 | | - $selected = ($type == $pr_type ); |
150 | | - $options[] = Xml::option( $text, $type, $selected ) . "\n"; |
151 | | - } |
152 | | - |
153 | 156 | return |
154 | | - Xml::label( wfMsg('restriction-type') , $this->IdType ) . ' ' . |
155 | | - Xml::tags( 'select', |
156 | | - array( 'id' => $this->IdType, 'name' => $this->IdType ), |
157 | | - implode( "\n", $options ) ); |
| 157 | + '<td><label for="type">' . wfMsgHtml( 'restriction-type' ) . '</label></td>' |
| 158 | + . '<td>' . Xml::tags( 'select', array( 'id' => 'type', 'name' => 'type' ), |
| 159 | + implode( '', $options ) ) . '</td>'; |
158 | 160 | } |
159 | 161 | |
160 | 162 | /** |
161 | | - * @return string Formatted HTML |
162 | | - * @private |
163 | | - */ |
164 | | - function getLevelMenu( $pr_level ) { |
| 163 | + * Build a level selection menu |
| 164 | + * |
| 165 | + * @param int $select Pre-selected level |
| 166 | + * @return string |
| 167 | + */ |
| 168 | + private function getLevelMenu( $select ) { |
165 | 169 | global $wgRestrictionLevels; |
166 | | - |
167 | | - $m = array( wfMsg('restriction-level-all') => 0 ); // Temporary array |
168 | 170 | $options = array(); |
169 | | - |
170 | | - // First pass to load the log names |
171 | | - foreach( $wgRestrictionLevels as $type ) { |
172 | | - if ( $type !='' && $type !='*') { |
173 | | - $text = wfMsg("restriction-level-$type"); |
174 | | - $m[$text] = $type; |
| 171 | + $options[] = Xml::option( |
| 172 | + wfMsg( 'restriction-level-all' ), |
| 173 | + 0, |
| 174 | + $select == 0 |
| 175 | + ); |
| 176 | + foreach( $wgRestrictionLevels as $level ) { |
| 177 | + if( $level != '' && $level != '*' ) { |
| 178 | + $options[] = Xml::option( |
| 179 | + wfMsg( 'restriction-level-' . $level ), |
| 180 | + $level, |
| 181 | + $level == $select |
| 182 | + ); |
175 | 183 | } |
176 | 184 | } |
| 185 | + return |
| 186 | + '<td><label for="level">' . wfMsgHtml( 'restriction-level' ) . '</label></td>' |
| 187 | + . '<td>' . Xml::tags( 'select', array( 'id' => 'level', 'name' => 'level' ), |
| 188 | + implode( '', $options ) ); |
| 189 | + } |
177 | 190 | |
178 | | - // Third pass generates sorted XHTML content |
179 | | - foreach( $m as $text => $type ) { |
180 | | - $selected = ($type == $pr_level ); |
181 | | - $options[] = Xml::option( $text, $type, $selected ); |
| 191 | + |
| 192 | + /** |
| 193 | + * Build a size limit box |
| 194 | + * |
| 195 | + * @param int $select Pre-select min or max |
| 196 | + * @param int $size Pre-fill size value |
| 197 | + * @return string |
| 198 | + */ |
| 199 | + private function getSizeLimit( $select, $size ) { |
| 200 | + $radios = array(); |
| 201 | + foreach( array( 'min', 'max' ) as $bound ) { |
| 202 | + $radios[] = Xml::radioLabel( |
| 203 | + wfMsg( 'protectedpages-size-' . $bound ), |
| 204 | + 'sizetype', |
| 205 | + $bound, |
| 206 | + 'wpSize' . $bound, |
| 207 | + $bound == $select |
| 208 | + ); |
182 | 209 | } |
183 | | - |
184 | 210 | return |
185 | | - Xml::label( wfMsg('restriction-level') , $this->IdLevel ) . ' ' . |
186 | | - Xml::tags( 'select', |
187 | | - array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ), |
188 | | - implode( "\n", $options ) ); |
| 211 | + '<tr><td><label for="wpSize">' . wfMsgHtml( 'protectedpages-size' ) . '</label></td>' |
| 212 | + . '<td>' . Xml::input( 'size', 9, $size, array( 'id' => 'wpSize' ) ) |
| 213 | + . ' ' . wfMsgHtml( 'pagesize' ) . '</td></tr><tr><td></td><td>' |
| 214 | + . implode( ' ', $radios ) . '</td>'; |
189 | 215 | } |
| 216 | + |
190 | 217 | } |
191 | 218 | |
192 | 219 | /** |
— | — | @@ -254,16 +281,4 @@ |
255 | 282 | } |
256 | 283 | } |
257 | 284 | |
258 | | -/** |
259 | | - * Constructor |
260 | | - */ |
261 | | -function wfSpecialProtectedpages() { |
262 | | - |
263 | | - list( $limit, $offset ) = wfCheckLimits(); |
264 | | - |
265 | | - $ppForm = new ProtectedPagesForm(); |
266 | | - |
267 | | - $ppForm->showList(); |
268 | | -} |
269 | | - |
270 | 285 | ?> |
Index: branches/robchurch/pr_timestamp/includes/AutoLoader.php |
— | — | @@ -200,6 +200,8 @@ |
201 | 201 | 'UnlistedSpecialPage' => 'includes/SpecialPage.php', |
202 | 202 | 'IncludableSpecialPage' => 'includes/SpecialPage.php', |
203 | 203 | 'PopularPagesPage' => 'includes/SpecialPopularpages.php', |
| 204 | + 'SpecialProtectedPages' => 'includes/SpecialProtectedpages.php', |
| 205 | + 'ProtectedPagesPager' => 'includes/Specialprotectedpages.php', |
204 | 206 | 'PreferencesForm' => 'includes/SpecialPreferences.php', |
205 | 207 | 'SpecialPrefixindex' => 'includes/SpecialPrefixindex.php', |
206 | 208 | 'PasswordResetForm' => 'includes/SpecialResetpass.php', |
Index: branches/robchurch/pr_timestamp/includes/SpecialPage.php |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | 'Newpages' => array( 'IncludableSpecialPage', 'Newpages' ), |
112 | 112 | 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ), |
113 | 113 | 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ), |
114 | | - 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ), |
| 114 | + 'Protectedpages' => 'SpecialProtectedPages', |
115 | 115 | 'Allpages' => array( 'IncludableSpecialPage', 'Allpages' ), |
116 | 116 | 'Prefixindex' => array( 'IncludableSpecialPage', 'Prefixindex' ) , |
117 | 117 | 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ), |
Index: branches/robchurch/pr_timestamp/languages/messages/MessagesEn.php |
— | — | @@ -1600,6 +1600,11 @@ |
1601 | 1601 | 'deadendpagestext' => 'The following pages do not link to other pages in this wiki.', |
1602 | 1602 | 'protectedpages' => 'Protected pages', |
1603 | 1603 | 'protectedpages-summary' => '', |
| 1604 | +'protectedpages-legend' => 'List protected pages', |
| 1605 | +'protectedpages-size' => 'Size:', |
| 1606 | +'protectedpages-size-min' => '(min)', |
| 1607 | +'protectedpages-size-max' => '(max)', |
| 1608 | +'protectedpages-submit' => 'Go', |
1604 | 1609 | 'protectedpagestext' => 'The following pages are protected from moving or editing', |
1605 | 1610 | 'protectedpagesempty' => 'No pages are currently protected with these parameters.', |
1606 | 1611 | 'listusers' => 'User list', |