| Index: trunk/phase3/includes/HTMLForm.php |
| — | — | @@ -845,6 +845,15 @@ |
| 846 | 846 | public function getLegend( $key ) { |
| 847 | 847 | return wfMsg( "{$this->mMessagePrefix}-$key" ); |
| 848 | 848 | } |
| | 849 | + |
| | 850 | + /** |
| | 851 | + * Returns an array of fields in the form |
| | 852 | + * |
| | 853 | + * @return HTMLFormField[] |
| | 854 | + */ |
| | 855 | + public function getFlatFields() { |
| | 856 | + return $this->mFlatFields; |
| | 857 | + } |
| 849 | 858 | } |
| 850 | 859 | |
| 851 | 860 | /** |
| — | — | @@ -1071,6 +1080,15 @@ |
| 1072 | 1081 | return $html; |
| 1073 | 1082 | } |
| 1074 | 1083 | |
| | 1084 | + /** |
| | 1085 | + * Returns the HTML name of the Field |
| | 1086 | + * |
| | 1087 | + * @return string |
| | 1088 | + */ |
| | 1089 | + public function getName() { |
| | 1090 | + return $this->mName; |
| | 1091 | + } |
| | 1092 | + |
| 1075 | 1093 | function getLabel() { |
| 1076 | 1094 | return $this->mLabel; |
| 1077 | 1095 | } |
| Index: trunk/phase3/includes/AutoLoader.php |
| — | — | @@ -104,6 +104,7 @@ |
| 105 | 105 | 'HTMLHiddenField' => 'includes/HTMLForm.php', |
| 106 | 106 | 'HTMLInfoField' => 'includes/HTMLForm.php', |
| 107 | 107 | 'HTMLIntField' => 'includes/HTMLForm.php', |
| | 108 | + 'HTMLItemsPerPageField' => 'includes/Pager.php', |
| 108 | 109 | 'HTMLMultiSelectField' => 'includes/HTMLForm.php', |
| 109 | 110 | 'HTMLRadioField' => 'includes/HTMLForm.php', |
| 110 | 111 | 'HTMLSelectAndOtherField' => 'includes/HTMLForm.php', |
| — | — | @@ -743,7 +744,6 @@ |
| 744 | 745 | 'EmailInvalidation' => 'includes/specials/SpecialConfirmemail.php', |
| 745 | 746 | 'FewestrevisionsPage' => 'includes/specials/SpecialFewestrevisions.php', |
| 746 | 747 | 'FileDuplicateSearchPage' => 'includes/specials/SpecialFileDuplicateSearch.php', |
| 747 | | - 'HTMLBlockedUsersItemSelect' => 'includes/specials/SpecialBlockList.php', |
| 748 | 748 | 'ImportReporter' => 'includes/specials/SpecialImport.php', |
| 749 | 749 | 'IPBlockForm' => 'includes/specials/SpecialBlock.php', |
| 750 | 750 | 'LinkSearchPage' => 'includes/specials/SpecialLinkSearch.php', |
| Index: trunk/phase3/includes/specials/SpecialAllmessages.php |
| — | — | @@ -62,18 +62,18 @@ |
| 63 | 63 | |
| 64 | 64 | $out->addModuleStyles( 'mediawiki.special' ); |
| 65 | 65 | |
| 66 | | - $this->filter = $request->getVal( 'filter', 'all' ); |
| 67 | | - $this->prefix = $request->getVal( 'prefix', '' ); |
| | 66 | + $this->filter = $request->getVal( 'wpFilter', 'all' ); |
| | 67 | + $this->prefix = $request->getVal( 'wpPrefix', '' ); |
| 68 | 68 | |
| 69 | 69 | $this->table = new AllmessagesTablePager( |
| 70 | 70 | $this, |
| 71 | 71 | array(), |
| 72 | | - wfGetLangObj( $request->getVal( 'lang', $par ) ) |
| | 72 | + wfGetLangObj( $request->getVal( 'wpLanguage', $par ) ) |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | 75 | $this->langcode = $this->table->lang->getCode(); |
| 76 | 76 | |
| 77 | | - $out->addHTML( $this->table->buildForm() . |
| | 77 | + $out->addHTML( $this->table->buildHTMLForm() . |
| 78 | 78 | $this->table->getNavigationBar() . |
| 79 | 79 | $this->table->getBody() . |
| 80 | 80 | $this->table->getNavigationBar() ); |
| — | — | @@ -120,14 +120,14 @@ |
| 121 | 121 | |
| 122 | 122 | $request = $this->getRequest(); |
| 123 | 123 | |
| 124 | | - if( $request->getVal( 'filter', 'all' ) === 'all' ){ |
| | 124 | + if( $request->getVal( 'wpFilter', 'all' ) === 'all' ){ |
| 125 | 125 | $this->custom = null; // So won't match in either case |
| 126 | 126 | } else { |
| 127 | | - $this->custom = ($request->getVal( 'filter' ) == 'unmodified'); |
| | 127 | + $this->custom = ($request->getVal( 'wpFilter' ) == 'unmodified'); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | | - $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'prefix', '' ) ); |
| 131 | | - $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'prefix', null ) ) : null; |
| | 130 | + $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'wpPrefix', '' ) ); |
| | 131 | + $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'wpPrefix', null ) ) : null; |
| 132 | 132 | if( $prefix !== null ){ |
| 133 | 133 | $this->displayPrefix = $prefix->getDBkey(); |
| 134 | 134 | $this->prefix = '/^' . preg_quote( $this->displayPrefix ) . '/i'; |
| — | — | @@ -145,85 +145,50 @@ |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | | - function buildForm() { |
| 150 | | - global $wgScript; |
| | 149 | + protected function getHTMLFormFields() { |
| | 150 | + $f = array( |
| | 151 | + 'Prefix' => array( |
| | 152 | + 'type' => 'text', |
| | 153 | + 'label-message' => 'allmessages-prefix', |
| | 154 | + 'size' => 20, |
| | 155 | + ), |
| | 156 | + 'Filter' => array( |
| | 157 | + 'type' => 'radio', |
| | 158 | + 'label-message' => 'allmessages-filter', |
| | 159 | + 'options' => array( |
| | 160 | + $this->msg( 'allmessages-filter-unmodified' )->text() => 'unmodified', |
| | 161 | + $this->msg( 'allmessages-filter-all' )->text() => 'all', |
| | 162 | + $this->msg( 'allmessages-filter-modified' )->text() => 'modified', |
| | 163 | + ), |
| | 164 | + 'flatlist' => true, |
| | 165 | + ), |
| | 166 | + 'Language' => array( |
| | 167 | + 'type' => 'select', |
| | 168 | + 'label-message' => 'allmessages-language', |
| | 169 | + 'options' => array(), // This is filled in below |
| | 170 | + 'default' => $this->langcode, |
| | 171 | + ), |
| | 172 | + 'Limit' => $this->getHTMLFormLimitSelect(), |
| | 173 | + ); |
| 151 | 174 | |
| 152 | 175 | $languages = Language::getLanguageNames( false ); |
| 153 | 176 | ksort( $languages ); |
| 154 | 177 | |
| 155 | | - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) . |
| 156 | | - Xml::fieldset( $this->msg( 'allmessages-filter-legend' )->text() ) . |
| 157 | | - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
| 158 | | - Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" . |
| 159 | | - '<tr> |
| 160 | | - <td class="mw-label">' . |
| 161 | | - Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) . |
| 162 | | - "</td>\n |
| 163 | | - <td class=\"mw-input\">" . |
| 164 | | - Xml::input( 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), array( 'id' => 'mw-allmessages-form-prefix' ) ) . |
| 165 | | - "</td>\n |
| 166 | | - </tr> |
| 167 | | - <tr>\n |
| 168 | | - <td class='mw-label'>" . |
| 169 | | - $this->msg( 'allmessages-filter' )->escaped() . |
| 170 | | - "</td>\n |
| 171 | | - <td class='mw-input'>" . |
| 172 | | - Xml::radioLabel( $this->msg( 'allmessages-filter-unmodified' )->text(), |
| 173 | | - 'filter', |
| 174 | | - 'unmodified', |
| 175 | | - 'mw-allmessages-form-filter-unmodified', |
| 176 | | - ( $this->filter == 'unmodified' ) |
| 177 | | - ) . |
| 178 | | - Xml::radioLabel( $this->msg( 'allmessages-filter-all' )->text(), |
| 179 | | - 'filter', |
| 180 | | - 'all', |
| 181 | | - 'mw-allmessages-form-filter-all', |
| 182 | | - ( $this->filter == 'all' ) |
| 183 | | - ) . |
| 184 | | - Xml::radioLabel( $this->msg( 'allmessages-filter-modified' )->text(), |
| 185 | | - 'filter', |
| 186 | | - 'modified', |
| 187 | | - 'mw-allmessages-form-filter-modified', |
| 188 | | - ( $this->filter == 'modified' ) |
| 189 | | - ) . |
| 190 | | - "</td>\n |
| 191 | | - </tr> |
| 192 | | - <tr>\n |
| 193 | | - <td class=\"mw-label\">" . |
| 194 | | - Xml::label( $this->msg( 'allmessages-language' )->text(), 'mw-allmessages-form-lang' ) . |
| 195 | | - "</td>\n |
| 196 | | - <td class=\"mw-input\">" . |
| 197 | | - Xml::openElement( 'select', array( 'id' => 'mw-allmessages-form-lang', 'name' => 'lang' ) ); |
| 198 | | - |
| 199 | | - foreach( $languages as $lang => $name ) { |
| 200 | | - $selected = $lang == $this->langcode; |
| 201 | | - $out .= Xml::option( $lang . ' - ' . $name, $lang, $selected ) . "\n"; |
| | 178 | + foreach( $languages as $code => $name ) { |
| | 179 | + $f['Language']['options'][ "$code - $name" ] = $code; |
| 202 | 180 | } |
| 203 | | - $out .= Xml::closeElement( 'select' ) . |
| 204 | | - "</td>\n |
| 205 | | - </tr>" . |
| 206 | 181 | |
| 207 | | - '<tr> |
| 208 | | - <td class="mw-label">' . |
| 209 | | - Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) . |
| 210 | | - '</td> |
| 211 | | - <td class="mw-input">' . |
| 212 | | - $this->getLimitSelect() . |
| 213 | | - '</td> |
| 214 | | - <tr> |
| 215 | | - <td></td> |
| 216 | | - <td>' . |
| 217 | | - Xml::submitButton( $this->msg( 'allmessages-filter-submit' )->text() ) . |
| 218 | | - "</td>\n |
| 219 | | - </tr>" . |
| | 182 | + return $f; |
| | 183 | + } |
| 220 | 184 | |
| 221 | | - Xml::closeElement( 'table' ) . |
| 222 | | - $this->getHiddenFields( array( 'title', 'prefix', 'filter', 'lang', 'limit' ) ) . |
| 223 | | - Xml::closeElement( 'fieldset' ) . |
| 224 | | - Xml::closeElement( 'form' ); |
| 225 | | - return $out; |
| | 185 | + protected function getHTMLFormLegend() { |
| | 186 | + return 'allmessages-filter-legend'; |
| 226 | 187 | } |
| 227 | 188 | |
| | 189 | + protected function getHTMLFormSubmit() { |
| | 190 | + return 'allmessages-filter-submit'; |
| | 191 | + } |
| | 192 | + |
| 228 | 193 | function getAllMessages( $descending ) { |
| 229 | 194 | wfProfileIn( __METHOD__ ); |
| 230 | 195 | $messageNames = Language::getLocalisationCache()->getSubitemList( 'en', 'messages' ); |
| Index: trunk/phase3/includes/specials/SpecialBlockList.php |
| — | — | @@ -43,7 +43,6 @@ |
| 44 | 44 | $this->setHeaders(); |
| 45 | 45 | $this->outputHeader(); |
| 46 | 46 | $out = $this->getOutput(); |
| 47 | | - $lang = $this->getLanguage(); |
| 48 | 47 | $out->setPageTitle( $this->msg( 'ipblocklist' ) ); |
| 49 | 48 | $out->addModuleStyles( 'mediawiki.special' ); |
| 50 | 49 | |
| — | — | @@ -62,46 +61,6 @@ |
| 63 | 62 | return; |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | | - # Just show the block list |
| 67 | | - $fields = array( |
| 68 | | - 'Target' => array( |
| 69 | | - 'type' => 'text', |
| 70 | | - 'label-message' => 'ipadressorusername', |
| 71 | | - 'tabindex' => '1', |
| 72 | | - 'size' => '45', |
| 73 | | - 'default' => $this->target, |
| 74 | | - ), |
| 75 | | - 'Options' => array( |
| 76 | | - 'type' => 'multiselect', |
| 77 | | - 'options' => array( |
| 78 | | - wfMsg( 'blocklist-userblocks' ) => 'userblocks', |
| 79 | | - wfMsg( 'blocklist-tempblocks' ) => 'tempblocks', |
| 80 | | - wfMsg( 'blocklist-addressblocks' ) => 'addressblocks', |
| 81 | | - wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks', |
| 82 | | - ), |
| 83 | | - 'flatlist' => true, |
| 84 | | - ), |
| 85 | | - 'Limit' => array( |
| 86 | | - 'class' => 'HTMLBlockedUsersItemSelect', |
| 87 | | - 'label-message' => 'table_pager_limit_label', |
| 88 | | - 'options' => array( |
| 89 | | - $lang->formatNum( 20 ) => 20, |
| 90 | | - $lang->formatNum( 50 ) => 50, |
| 91 | | - $lang->formatNum( 100 ) => 100, |
| 92 | | - $lang->formatNum( 250 ) => 250, |
| 93 | | - $lang->formatNum( 500 ) => 500, |
| 94 | | - ), |
| 95 | | - 'name' => 'limit', |
| 96 | | - 'default' => 50, |
| 97 | | - ), |
| 98 | | - ); |
| 99 | | - $form = new HTMLForm( $fields, $this->getContext() ); |
| 100 | | - $form->setMethod( 'get' ); |
| 101 | | - $form->setWrapperLegend( wfMsg( 'ipblocklist-legend' ) ); |
| 102 | | - $form->setSubmitText( wfMsg( 'ipblocklist-submit' ) ); |
| 103 | | - $form->prepareForm(); |
| 104 | | - |
| 105 | | - $form->displayForm( '' ); |
| 106 | 65 | $this->showList(); |
| 107 | 66 | } |
| 108 | 67 | |
| — | — | @@ -176,6 +135,7 @@ |
| 177 | 136 | } |
| 178 | 137 | |
| 179 | 138 | $pager = new BlockListPager( $this, $conds ); |
| | 139 | + $out->addHTML( $pager->buildHTMLForm() ); |
| 180 | 140 | if ( $pager->getNumRows() ) { |
| 181 | 141 | $out->addHTML( |
| 182 | 142 | $pager->getNavigationBar() . |
| — | — | @@ -399,6 +359,37 @@ |
| 400 | 360 | return $info; |
| 401 | 361 | } |
| 402 | 362 | |
| | 363 | + protected function getHTMLFormFields() { |
| | 364 | + return array( |
| | 365 | + 'Target' => array( |
| | 366 | + 'type' => 'text', |
| | 367 | + 'label-message' => 'ipadressorusername', |
| | 368 | + 'tabindex' => '1', |
| | 369 | + 'size' => '45', |
| | 370 | + //'default' => $this->target, |
| | 371 | + ), |
| | 372 | + 'Options' => array( |
| | 373 | + 'type' => 'multiselect', |
| | 374 | + 'options' => array( |
| | 375 | + wfMsg( 'blocklist-userblocks' ) => 'userblocks', |
| | 376 | + wfMsg( 'blocklist-tempblocks' ) => 'tempblocks', |
| | 377 | + wfMsg( 'blocklist-addressblocks' ) => 'addressblocks', |
| | 378 | + wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks', |
| | 379 | + ), |
| | 380 | + 'flatlist' => true, |
| | 381 | + ), |
| | 382 | + 'Limit' => $this->getHTMLFormLimitSelect(), |
| | 383 | + ); |
| | 384 | + } |
| | 385 | + |
| | 386 | + protected function getHTMLFormSubmit() { |
| | 387 | + return 'ipblocklist-submit'; |
| | 388 | + } |
| | 389 | + |
| | 390 | + protected function getHTMLFormLegend() { |
| | 391 | + return 'ipblocklist-legend'; |
| | 392 | + } |
| | 393 | + |
| 403 | 394 | public function getTableClass(){ |
| 404 | 395 | return 'TablePager mw-blocklist'; |
| 405 | 396 | } |
| — | — | @@ -447,33 +438,4 @@ |
| 448 | 439 | $lb->execute(); |
| 449 | 440 | wfProfileOut( __METHOD__ ); |
| 450 | 441 | } |
| 451 | | -} |
| 452 | | - |
| 453 | | -/** |
| 454 | | - * Items per page dropdown. Essentially a crap workaround for bug 32603. |
| 455 | | - * |
| 456 | | - * @todo Do not release 1.19 with this. |
| 457 | | - */ |
| 458 | | -class HTMLBlockedUsersItemSelect extends HTMLSelectField { |
| 459 | | - /** |
| 460 | | - * Basically don't do any validation. If it's a number that's fine. Also, |
| 461 | | - * add it to the list if it's not there already |
| 462 | | - * |
| 463 | | - * @param $value |
| 464 | | - * @param $alldata |
| 465 | | - * @return bool |
| 466 | | - */ |
| 467 | | - function validate( $value, $alldata ) { |
| 468 | | - if ( $value == '' ) { |
| 469 | | - return true; |
| 470 | | - } |
| 471 | | - |
| 472 | | - if ( !in_array( $value, $this->mParams['options'] ) ) { |
| 473 | | - $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value); |
| 474 | | - asort( $this->mParams['options'] ); |
| 475 | | - } |
| 476 | | - |
| 477 | | - return true; |
| 478 | | - } |
| 479 | | - |
| 480 | | -} |
| | 442 | +} |
| \ No newline at end of file |
| Index: trunk/phase3/includes/specials/SpecialListfiles.php |
| — | — | @@ -35,8 +35,8 @@ |
| 36 | 36 | $userName = $par; |
| 37 | 37 | $search = ''; |
| 38 | 38 | } else { |
| 39 | | - $userName = $this->getRequest()->getText( 'user', $par ); |
| 40 | | - $search = $this->getRequest()->getText( 'ilsearch', '' ); |
| | 39 | + $userName = $this->getRequest()->getText( 'wpUsername', $par ); |
| | 40 | + $search = $this->getRequest()->getText( 'wpSearch', '' ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $pager = new ImageListPager( $this->getContext(), $userName, $search, $this->including() ); |
| — | — | @@ -44,7 +44,7 @@ |
| 45 | 45 | if ( $this->including() ) { |
| 46 | 46 | $html = $pager->getBody(); |
| 47 | 47 | } else { |
| 48 | | - $form = $pager->getForm(); |
| | 48 | + $form = $pager->buildHTMLForm(); |
| 49 | 49 | $body = $pager->getBody(); |
| 50 | 50 | $nav = $pager->getNavigationBar(); |
| 51 | 51 | $html = "$form<br />\n$body<br />\n$nav"; |
| — | — | @@ -234,32 +234,37 @@ |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | | - function getForm() { |
| 239 | | - global $wgScript, $wgMiserMode; |
| 240 | | - $inputForm = array(); |
| 241 | | - $inputForm['table_pager_limit_label'] = $this->getLimitSelect(); |
| | 238 | + protected function getHTMLFormFields() { |
| | 239 | + global $wgMiserMode; |
| | 240 | + $f = array( |
| | 241 | + 'Limit' => $this->getHTMLFormLimitSelect(), |
| | 242 | + ); |
| | 243 | + |
| 242 | 244 | if ( !$wgMiserMode ) { |
| 243 | | - $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text', |
| 244 | | - array( |
| 245 | | - 'size' => '40', |
| 246 | | - 'maxlength' => '255', |
| 247 | | - 'id' => 'mw-ilsearch', |
| 248 | | - ) ); |
| | 245 | + $f['Search'] = array( |
| | 246 | + 'type' => 'text', |
| | 247 | + 'label-message' => 'listfiles_search_for', |
| | 248 | + 'maxlength' => 255, |
| | 249 | + ); |
| 249 | 250 | } |
| 250 | | - $inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array( |
| 251 | | - 'size' => '40', |
| 252 | | - 'maxlength' => '255', |
| 253 | | - 'id' => 'mw-listfiles-user', |
| 254 | | - ) ); |
| 255 | | - return Html::openElement( 'form', |
| 256 | | - array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) . |
| 257 | | - Xml::fieldset( wfMsg( 'listfiles' ) ) . |
| 258 | | - Xml::buildForm( $inputForm, 'table_pager_limit_submit' ) . |
| 259 | | - $this->getHiddenFields( array( 'limit', 'ilsearch', 'user' ) ) . |
| 260 | | - Html::closeElement( 'fieldset' ) . |
| 261 | | - Html::closeElement( 'form' ) . "\n"; |
| | 251 | + |
| | 252 | + $f['Username'] = array( |
| | 253 | + 'type' => 'text', |
| | 254 | + 'label-message' => 'username', |
| | 255 | + 'maxlength' => 255, |
| | 256 | + ); |
| | 257 | + |
| | 258 | + return $f; |
| 262 | 259 | } |
| 263 | 260 | |
| | 261 | + protected function getHTMLFormLegend() { |
| | 262 | + return 'listfiles'; |
| | 263 | + } |
| | 264 | + |
| | 265 | + protected function getHTMLFormSubmit() { |
| | 266 | + return 'table_pager_limit_submit'; |
| | 267 | + } |
| | 268 | + |
| 264 | 269 | function getTableClass() { |
| 265 | 270 | return 'listfiles ' . parent::getTableClass(); |
| 266 | 271 | } |
| Index: trunk/phase3/includes/specials/SpecialListusers.php |
| — | — | @@ -44,19 +44,19 @@ |
| 45 | 45 | $symsForAll = array( '*', 'user' ); |
| 46 | 46 | if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) { |
| 47 | 47 | $this->requestedGroup = $par; |
| 48 | | - $un = $request->getText( 'username' ); |
| | 48 | + $un = $request->getText( 'wpUsername' ); |
| 49 | 49 | } elseif ( count( $parms ) == 2 ) { |
| 50 | 50 | $this->requestedGroup = $parms[0]; |
| 51 | 51 | $un = $parms[1]; |
| 52 | 52 | } else { |
| 53 | | - $this->requestedGroup = $request->getVal( 'group' ); |
| 54 | | - $un = ( $par != '' ) ? $par : $request->getText( 'username' ); |
| | 53 | + $this->requestedGroup = $request->getVal( 'wpGroup' ); |
| | 54 | + $un = ( $par != '' ) ? $par : $request->getText( 'wpUsername' ); |
| 55 | 55 | } |
| 56 | 56 | if ( in_array( $this->requestedGroup, $symsForAll ) ) { |
| 57 | 57 | $this->requestedGroup = ''; |
| 58 | 58 | } |
| 59 | | - $this->editsOnly = $request->getBool( 'editsOnly' ); |
| 60 | | - $this->creationSort = $request->getBool( 'creationSort' ); |
| | 59 | + $this->editsOnly = $request->getBool( 'wpEditsOnly' ); |
| | 60 | + $this->creationSort = $request->getBool( 'wpCreationSort' ); |
| 61 | 61 | |
| 62 | 62 | $this->requestedUser = ''; |
| 63 | 63 | if ( $un != '' ) { |
| — | — | @@ -182,41 +182,43 @@ |
| 183 | 183 | return parent::getBody(); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | | - function getPageHeader( ) { |
| 187 | | - global $wgScript; |
| 188 | | - $self = $this->getTitle(); |
| | 186 | + protected function getHTMLFormFields() { |
| | 187 | + $f = array( |
| | 188 | + 'Username' => array( |
| | 189 | + 'type' => 'text', |
| | 190 | + 'label-message' => 'listusersfrom', |
| | 191 | + 'size' => 30, |
| | 192 | + ), |
| | 193 | + 'Group' => array( |
| | 194 | + 'type' => 'select', |
| | 195 | + 'label-message' => 'group', |
| | 196 | + 'options' => array( |
| | 197 | + $this->msg( 'group-all' )->escaped() => '', |
| | 198 | + ), |
| | 199 | + ), |
| | 200 | + 'EditsOnly' => array( |
| | 201 | + 'type' => 'check', |
| | 202 | + 'label-message' => 'listusers-editsonly', |
| | 203 | + ), |
| | 204 | + 'CreationSort' => array( |
| | 205 | + 'type' => 'check', |
| | 206 | + 'label-message' => 'listusers-creationsort', |
| | 207 | + ), |
| | 208 | + ); |
| 189 | 209 | |
| 190 | | - # Form tag |
| 191 | | - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) ) . |
| 192 | | - Xml::fieldset( wfMsg( 'listusers' ) ) . |
| 193 | | - Html::hidden( 'title', $self->getPrefixedDbKey() ); |
| | 210 | + foreach( $this->getAllGroups() as $group => $groupText ) { |
| | 211 | + $f['Group']['options'][$groupText] = $group; |
| | 212 | + } |
| 194 | 213 | |
| 195 | | - # Username field |
| 196 | | - $out .= Xml::label( wfMsg( 'listusersfrom' ), 'offset' ) . ' ' . |
| 197 | | - Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' '; |
| | 214 | + return $f; |
| | 215 | + } |
| 198 | 216 | |
| 199 | | - # Group drop-down list |
| 200 | | - $out .= Xml::label( wfMsg( 'group' ), 'group' ) . ' ' . |
| 201 | | - Xml::openElement('select', array( 'name' => 'group', 'id' => 'group' ) ) . |
| 202 | | - Xml::option( wfMsg( 'group-all' ), '' ); |
| 203 | | - foreach( $this->getAllGroups() as $group => $groupText ) |
| 204 | | - $out .= Xml::option( $groupText, $group, $group == $this->requestedGroup ); |
| 205 | | - $out .= Xml::closeElement( 'select' ) . '<br />'; |
| 206 | | - $out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly ); |
| 207 | | - $out .= ' '; |
| 208 | | - $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort ); |
| 209 | | - $out .= '<br />'; |
| | 217 | + protected function getHTMLFormSubmit() { |
| | 218 | + return 'allpagessubmit'; |
| | 219 | + } |
| 210 | 220 | |
| 211 | | - wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) ); |
| 212 | | - |
| 213 | | - # Submit button and form bottom |
| 214 | | - $out .= Html::hidden( 'limit', $this->mLimit ); |
| 215 | | - $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ); |
| 216 | | - wfRunHooks( 'SpecialListusersHeader', array( $this, &$out ) ); |
| 217 | | - $out .= Xml::closeElement( 'fieldset' ) . |
| 218 | | - Xml::closeElement( 'form' ); |
| 219 | | - |
| 220 | | - return $out; |
| | 221 | + protected function getHTMLFormLegend() { |
| | 222 | + return 'listusers'; |
| 221 | 223 | } |
| 222 | 224 | |
| 223 | 225 | /** |
| — | — | @@ -295,7 +297,7 @@ |
| 296 | 298 | # getBody() first to check, if empty |
| 297 | 299 | $usersbody = $up->getBody(); |
| 298 | 300 | |
| 299 | | - $s = $up->getPageHeader(); |
| | 301 | + $s = $up->buildHTMLForm(); |
| 300 | 302 | if( $usersbody ) { |
| 301 | 303 | $s .= $up->getNavigationBar(); |
| 302 | 304 | $s .= Html::rawElement( 'ul', array(), $usersbody ); |
| Index: trunk/phase3/includes/specials/SpecialActiveusers.php |
| — | — | @@ -53,7 +53,7 @@ |
| 54 | 54 | parent::__construct( $context ); |
| 55 | 55 | |
| 56 | 56 | $this->RCMaxAge = $wgActiveUserDays; |
| 57 | | - $un = $this->getRequest()->getText( 'username', $par ); |
| | 57 | + $un = $this->getRequest()->getText( 'wpUsername', $par ); |
| 58 | 58 | $this->requestedUser = ''; |
| 59 | 59 | if ( $un != '' ) { |
| 60 | 60 | $username = Title::makeTitleSafe( NS_USER, $un ); |
| — | — | @@ -68,16 +68,16 @@ |
| 69 | 69 | public function setupOptions() { |
| 70 | 70 | $this->opts = new FormOptions(); |
| 71 | 71 | |
| 72 | | - $this->opts->add( 'hidebots', false, FormOptions::BOOL ); |
| 73 | | - $this->opts->add( 'hidesysops', false, FormOptions::BOOL ); |
| | 72 | + $this->opts->add( 'wpHideBots', false, FormOptions::BOOL ); |
| | 73 | + $this->opts->add( 'wpHideSysops', false, FormOptions::BOOL ); |
| 74 | 74 | |
| 75 | 75 | $this->opts->fetchValuesFromRequest( $this->getRequest() ); |
| 76 | 76 | |
| 77 | 77 | $this->groups = array(); |
| 78 | | - if ( $this->opts->getValue( 'hidebots' ) == 1 ) { |
| | 78 | + if ( $this->opts->getValue( 'wpHideBots' ) == 1 ) { |
| 79 | 79 | $this->groups['bot'] = true; |
| 80 | 80 | } |
| 81 | | - if ( $this->opts->getValue( 'hidesysops' ) == 1 ) { |
| | 81 | + if ( $this->opts->getValue( 'wpHideSysops' ) == 1 ) { |
| 82 | 82 | $this->groups['sysop'] = true; |
| 83 | 83 | } |
| 84 | 84 | } |
| — | — | @@ -143,30 +143,32 @@ |
| 144 | 144 | return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" ); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | | - function getPageHeader() { |
| 148 | | - global $wgScript; |
| | 147 | + protected function getHTMLFormFields() { |
| | 148 | + $f = array( |
| | 149 | + 'Username' => array( |
| | 150 | + 'type' => 'text', |
| | 151 | + 'label-message' => 'activeusers-from', |
| | 152 | + 'size' => 30, |
| | 153 | + ), |
| | 154 | + 'HideBots' => array( |
| | 155 | + 'type' => 'check', |
| | 156 | + 'label-message' => 'activeusers-hidebots', |
| | 157 | + ), |
| | 158 | + 'HideSysops' => array( |
| | 159 | + 'type' => 'check', |
| | 160 | + 'label-message' => 'activeusers-hidesysops', |
| | 161 | + ), |
| | 162 | + ); |
| 149 | 163 | |
| 150 | | - $self = $this->getTitle(); |
| 151 | | - $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : ''; |
| | 164 | + return $f; |
| | 165 | + } |
| 152 | 166 | |
| 153 | | - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag |
| 154 | | - $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n"; |
| 155 | | - $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n"; |
| | 167 | + protected function getHTMLFormLegend() { |
| | 168 | + return 'activeusers'; |
| | 169 | + } |
| 156 | 170 | |
| 157 | | - $out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(), |
| 158 | | - 'username', 'offset', 20, $this->requestedUser ) . '<br />';# Username field |
| 159 | | - |
| 160 | | - $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(), |
| 161 | | - 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ) ); |
| 162 | | - |
| 163 | | - $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(), |
| 164 | | - 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ) ) . '<br />'; |
| 165 | | - |
| 166 | | - $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n";# Submit button and form bottom |
| 167 | | - $out .= Xml::closeElement( 'fieldset' ); |
| 168 | | - $out .= Xml::closeElement( 'form' ); |
| 169 | | - |
| 170 | | - return $out; |
| | 171 | + protected function getHTMLFormSubmit() { |
| | 172 | + return 'allpagessubmit'; |
| 171 | 173 | } |
| 172 | 174 | } |
| 173 | 175 | |
| — | — | @@ -202,7 +204,7 @@ |
| 203 | 205 | # getBody() first to check, if empty |
| 204 | 206 | $usersbody = $up->getBody(); |
| 205 | 207 | |
| 206 | | - $out->addHTML( $up->getPageHeader() ); |
| | 208 | + $out->addHTML( $up->buildHTMLForm() ); |
| 207 | 209 | if ( $usersbody ) { |
| 208 | 210 | $out->addHTML( |
| 209 | 211 | $up->getNavigationBar() . |
| Index: trunk/phase3/includes/Pager.php |
| — | — | @@ -560,6 +560,48 @@ |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
| | 564 | + * Assembles an HTMLForm for the Pager and returns the HTML |
| | 565 | + * |
| | 566 | + * @return string |
| | 567 | + */ |
| | 568 | + public function buildHTMLForm() { |
| | 569 | + if ( $this->getHTMLFormFields() === null ) { |
| | 570 | + throw new MWException( __METHOD__ . " was called without any form fields being defined" ); |
| | 571 | + } |
| | 572 | + |
| | 573 | + $form = new HTMLForm( $this->getHTMLFormFields(), $this->getContext() ); |
| | 574 | + $form->setMethod( 'get' ); |
| | 575 | + $form->setWrapperLegendMsg( $this->getHTMLFormLegend() ); |
| | 576 | + $form->setSubmitTextMsg( $this->getHTMLFormSubmit() ); |
| | 577 | + $this->addHiddenFields( $form ); |
| | 578 | + $this->modifyHTMLForm( $form ); |
| | 579 | + $form->prepareForm(); |
| | 580 | + |
| | 581 | + return $form->getHTML( '' ); |
| | 582 | + } |
| | 583 | + |
| | 584 | + /** |
| | 585 | + * Adds hidden elements to forms for things that are in the query string. |
| | 586 | + * This is so that parameters like offset stick through form submissions |
| | 587 | + * |
| | 588 | + * @param HTMLForm $form |
| | 589 | + */ |
| | 590 | + protected function addHiddenFields( HTMLForm $form ) { |
| | 591 | + $query = $this->getRequest()->getQueryValues(); |
| | 592 | + $fieldsBlacklist = array( 'title' ); |
| | 593 | + $fields = $form->getFlatFields(); |
| | 594 | + foreach ( $fields as $name => $field ) { |
| | 595 | + $fieldsBlacklist[] = $field->getName(); |
| | 596 | + } |
| | 597 | + foreach ( $query as $name => $value ) { |
| | 598 | + if ( in_array( $name, $fieldsBlacklist ) ) { |
| | 599 | + continue; |
| | 600 | + } |
| | 601 | + $form->addHiddenField( $name, $value ); |
| | 602 | + } |
| | 603 | + } |
| | 604 | + |
| | 605 | + /** |
| 564 | 606 | * Abstract formatting function. This should return an HTML string |
| 565 | 607 | * representing the result row $row. Rows will be concatenated and |
| 566 | 608 | * returned by getBody() |
| — | — | @@ -635,6 +677,43 @@ |
| 636 | 678 | * @return Boolean |
| 637 | 679 | */ |
| 638 | 680 | protected function getDefaultDirections() { return false; } |
| | 681 | + |
| | 682 | + /** |
| | 683 | + * Returns an array for HTMLForm fields for the pager |
| | 684 | + * |
| | 685 | + * Only used if the pager makes use of HTMLForms |
| | 686 | + * |
| | 687 | + * @return array|null |
| | 688 | + */ |
| | 689 | + protected function getHTMLFormFields() { return null; } |
| | 690 | + |
| | 691 | + /** |
| | 692 | + * Message name for the fieldset legend text |
| | 693 | + * |
| | 694 | + * Only used if the pager makes use of HTMLForms |
| | 695 | + * |
| | 696 | + * @return string |
| | 697 | + */ |
| | 698 | + protected function getHTMLFormLegend() { return ''; } |
| | 699 | + |
| | 700 | + /** |
| | 701 | + * Message name for the submit button text |
| | 702 | + * |
| | 703 | + * Only used if the pager makes use of HTMLForms |
| | 704 | + * |
| | 705 | + * @return string |
| | 706 | + */ |
| | 707 | + protected function getHTMLFormSubmit() { return ''; } |
| | 708 | + |
| | 709 | + /** |
| | 710 | + * If the pager needs to do any modifications to the Form, override this |
| | 711 | + * function. |
| | 712 | + * |
| | 713 | + * Only used if the pager makes use of HTMLForms |
| | 714 | + * |
| | 715 | + * @param HTMLForm $form |
| | 716 | + */ |
| | 717 | + protected function modifyHTMLForm( HTMLForm $form ) {} |
| 639 | 718 | } |
| 640 | 719 | |
| 641 | 720 | |
| — | — | @@ -1072,6 +1151,27 @@ |
| 1073 | 1152 | } |
| 1074 | 1153 | |
| 1075 | 1154 | /** |
| | 1155 | + * Returns an HTMLFormField definition for the "Items per page:" dropdown |
| | 1156 | + * |
| | 1157 | + * @return array |
| | 1158 | + */ |
| | 1159 | + protected function getHTMLFormLimitSelect() { |
| | 1160 | + $f = array( |
| | 1161 | + 'class' => 'HTMLItemsPerPageField', |
| | 1162 | + 'label-message' => 'table_pager_limit_label', |
| | 1163 | + 'options' => array(), |
| | 1164 | + 'default' => $this->mDefaultLimit, |
| | 1165 | + 'name' => 'limit', |
| | 1166 | + ); |
| | 1167 | + |
| | 1168 | + foreach( $this->mLimitsShown as $limit ) { |
| | 1169 | + $f['options'][$this->getLanguage()->formatNum( $limit )] = $limit; |
| | 1170 | + } |
| | 1171 | + |
| | 1172 | + return $f; |
| | 1173 | + } |
| | 1174 | + |
| | 1175 | + /** |
| 1076 | 1176 | * Get <input type="hidden"> elements for use in a method="get" form. |
| 1077 | 1177 | * Resubmits all defined elements of the query string, except for a |
| 1078 | 1178 | * blacklist, passed in the $blacklist parameter. |
| — | — | @@ -1158,3 +1258,30 @@ |
| 1159 | 1259 | */ |
| 1160 | 1260 | abstract function getFieldNames(); |
| 1161 | 1261 | } |
| | 1262 | + |
| | 1263 | +/** |
| | 1264 | + * Items per page dropdown for HTMLForm |
| | 1265 | + */ |
| | 1266 | +class HTMLItemsPerPageField extends HTMLSelectField { |
| | 1267 | + /** |
| | 1268 | + * Basically don't do any validation. If it's a number that's fine. Also, |
| | 1269 | + * add it to the list if it's not there already |
| | 1270 | + * |
| | 1271 | + * @param $value |
| | 1272 | + * @param $alldata |
| | 1273 | + * @return bool |
| | 1274 | + */ |
| | 1275 | + function validate( $value, $alldata ) { |
| | 1276 | + if ( $value == '' ) { |
| | 1277 | + return true; |
| | 1278 | + } |
| | 1279 | + |
| | 1280 | + if ( !in_array( $value, $this->mParams['options'] ) ) { |
| | 1281 | + $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value); |
| | 1282 | + asort( $this->mParams['options'] ); |
| | 1283 | + } |
| | 1284 | + |
| | 1285 | + return true; |
| | 1286 | + } |
| | 1287 | + |
| | 1288 | +} |
| \ No newline at end of file |