'HTMLHiddenField' => 'includes/HTMLForm.php',
'HTMLInfoField' => 'includes/HTMLForm.php',
'HTMLIntField' => 'includes/HTMLForm.php',
- 'HTMLItemsPerPageField' => 'includes/Pager.php',
'HTMLMultiSelectField' => 'includes/HTMLForm.php',
'HTMLRadioField' => 'includes/HTMLForm.php',
'HTMLSelectAndOtherField' => 'includes/HTMLForm.php',
'EmailInvalidation' => 'includes/specials/SpecialConfirmemail.php',
'FewestrevisionsPage' => 'includes/specials/SpecialFewestrevisions.php',
'FileDuplicateSearchPage' => 'includes/specials/SpecialFileDuplicateSearch.php',
+ 'HTMLBlockedUsersItemSelect' => 'includes/specials/SpecialBlockList.php',
'ImportReporter' => 'includes/specials/SpecialImport.php',
'IPBlockForm' => 'includes/specials/SpecialBlock.php',
'LinkSearchPage' => 'includes/specials/SpecialLinkSearch.php',
'submit' => 'HTMLSubmitField',
'hidden' => 'HTMLHiddenField',
'edittools' => 'HTMLEditTools',
- 'namespaces' => 'HTMLNamespacesField',
- 'restrictionlevels' => 'HTMLRestrictionLevelsField',
# HTMLTextField will output the correct type="" attribute automagically.
# There are about four zillion other HTML5 input types, like url, but
public function getLegend( $key ) {
return wfMsg( "{$this->mMessagePrefix}-$key" );
}
-
- /**
- * Returns an array of fields in the form
- *
- * @return HTMLFormField[]
- */
- public function getFlatFields() {
- return $this->mFlatFields;
- }
-
- /**
- * Returns a value of a field
- *
- * @param $field string Field name
- * @return mixed
- */
- public function getVal( $field ) {
- return $this->mFieldData[$field];
- }
}
/**
return $html;
}
- /**
- * Returns the HTML name of the Field
- *
- * @return string
- */
- public function getName() {
- return $this->mName;
- }
-
function getLabel() {
return $this->mLabel;
}
. "</div></td></tr>\n";
}
}
-
-/**
- * Dropdown for namespaces
- */
-class HTMLNamespacesField extends HTMLSelectField {
- function __construct( $params ) {
- global $wgContLang;
- parent::__construct( $params );
-
- $namespaces = $wgContLang->getFormattedNamespaces();
-
- $options = array();
- $options[ wfMessage( 'namespacesall' )->escaped() ] = ''; // TODO: Make an option
-
- foreach ( $namespaces as $index => $name ) {
- // Don't include things like SpecialPages
- if ( $index < NS_MAIN ) {
- continue;
- }
-
- if ( $index === 0 ) {
- $name = wfMessage( 'blanknamespace' )->escaped();
- }
-
- $options[$name] = $index;
- }
-
- $this->mParams['options'] = $options;
- }
-}
-
-/**
- * Dropdown for protection levels
- */
-class HTMLRestrictionLevelsField extends HTMLSelectField {
-
- /**
- * Should this field be displayed? If it hits a condition where it should
- * be hidden, set this to false.
- *
- * @var bool
- */
- protected $enabled = true;
-
- function __construct( $params ) {
- global $wgRestrictionLevels;
- parent::__construct( $params );
-
- $options = array( wfMsg('restriction-level-all') => 0 ); // Temporary array
-
- // First pass to load the level names
- foreach( $wgRestrictionLevels as $type ) {
- if ( $type != '' && $type != '*' ) {
- $text = wfMsg("restriction-level-$type");
- $options[$text] = $type;
- }
- }
-
- // Is there only one level (aside from "all")?
- if( count($options) <= 2 ) {
- $this->enabled = false;
- return;
- }
-
- $this->mParams['options'] = $options;
- }
-
- /**
- * Returns false where
- *
- * @param $value
- * @return String
- */
- function getTableRow( $value ) {
- if ( $this->enabled ) {
- return parent::getTableRow( $value );
- }
-
- return '';
- }
-}
\ No newline at end of file
protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar;
- /**
- * HTMLForm object
- *
- * @var HTMLForm
- */
- protected $mHTMLForm;
-
/**
* Result object for the query. Warning: seek before use.
*
return $links;
}
- /**
- * Assembles an HTMLForm for the Pager and returns the HTML
- *
- * @return string
- */
- public function buildHTMLForm() {
- if ( $this->getHTMLFormFields() === null ) {
- throw new MWException( __METHOD__ . " was called without any form fields being defined" );
- }
-
- $this->mHTMLForm = new HTMLForm( $this->getHTMLFormFields(), $this->getContext() );
- $this->mHTMLForm->setMethod( 'get' );
- $this->mHTMLForm->setWrapperLegendMsg( $this->getHTMLFormLegend() );
- $this->mHTMLForm->setSubmitTextMsg( $this->getHTMLFormSubmit() );
- $this->addHiddenFields();
- $this->modifyHTMLForm( $this->mHTMLForm );
- $this->mHTMLForm->prepareForm();
-
- return $this->mHTMLForm->getHTML( '' );
- }
-
- /**
- * Adds hidden elements to forms for things that are in the query string.
- * This is so that parameters like offset stick through form submissions
- */
- protected function addHiddenFields() {
- $query = $this->getRequest()->getQueryValues();
- $fieldsBlacklist = array( 'title' );
- $fields = $this->mHTMLForm->getFlatFields();
- foreach ( $fields as $name => $field ) {
- $fieldsBlacklist[] = $field->getName();
- }
- foreach ( $query as $name => $value ) {
- if ( in_array( $name, $fieldsBlacklist ) ) {
- continue;
- }
- $this->mHTMLForm->addHiddenField( $name, $value );
- }
- }
-
/**
* Abstract formatting function. This should return an HTML string
* representing the result row $row. Rows will be concatenated and
* @return Boolean
*/
protected function getDefaultDirections() { return false; }
-
- /**
- * Returns an array for HTMLForm fields for the pager
- *
- * Only used if the pager makes use of HTMLForms
- *
- * @return array|null
- */
- protected function getHTMLFormFields() { return null; }
-
- /**
- * Message name for the fieldset legend text
- *
- * Only used if the pager makes use of HTMLForms
- *
- * @return string
- */
- protected function getHTMLFormLegend() { return ''; }
-
- /**
- * Message name for the submit button text
- *
- * Only used if the pager makes use of HTMLForms
- *
- * @return string
- */
- protected function getHTMLFormSubmit() { return ''; }
-
- /**
- * If the pager needs to do any modifications to the Form, override this
- * function.
- *
- * Only used if the pager makes use of HTMLForms
- *
- * @param HTMLForm $form
- */
- protected function modifyHTMLForm( HTMLForm $form ) {}
}
return $s;
}
- /**
- * Returns an HTMLFormField definition for the "Items per page:" dropdown
- *
- * @return array
- */
- protected function getHTMLFormLimitSelect() {
- $f = array(
- 'class' => 'HTMLItemsPerPageField',
- 'label-message' => 'table_pager_limit_label',
- 'options' => array(),
- 'default' => $this->mDefaultLimit,
- 'name' => 'limit',
- );
-
- foreach( $this->mLimitsShown as $limit ) {
- $f['options'][$this->getLanguage()->formatNum( $limit )] = $limit;
- }
-
- return $f;
- }
-
/**
* Get <input type="hidden"> elements for use in a method="get" form.
* Resubmits all defined elements of the query string, except for a
*/
abstract function getFieldNames();
}
-
-/**
- * Items per page dropdown for HTMLForm
- */
-class HTMLItemsPerPageField extends HTMLSelectField {
- /**
- * Basically don't do any validation. If it's a number that's fine. Also,
- * add it to the list if it's not there already
- *
- * @param $value
- * @param $alldata
- * @return bool
- */
- function validate( $value, $alldata ) {
- if ( $value == '' ) {
- return true;
- }
-
- if ( !in_array( $value, $this->mParams['options'] ) ) {
- $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value);
- asort( $this->mParams['options'] );
- }
-
- return true;
- }
-
-}
\ No newline at end of file
parent::__construct( $context );
$this->RCMaxAge = $wgActiveUserDays;
- $un = $this->getRequest()->getText( 'wpUsername', $par );
+ $un = $this->getRequest()->getText( 'username', $par );
$this->requestedUser = '';
if ( $un != '' ) {
$username = Title::makeTitleSafe( NS_USER, $un );
public function setupOptions() {
$this->opts = new FormOptions();
- $this->opts->add( 'wpHideBots', false, FormOptions::BOOL );
- $this->opts->add( 'wpHideSysops', false, FormOptions::BOOL );
+ $this->opts->add( 'hidebots', false, FormOptions::BOOL );
+ $this->opts->add( 'hidesysops', false, FormOptions::BOOL );
$this->opts->fetchValuesFromRequest( $this->getRequest() );
$this->groups = array();
- if ( $this->opts->getValue( 'wpHideBots' ) == 1 ) {
+ if ( $this->opts->getValue( 'hidebots' ) == 1 ) {
$this->groups['bot'] = true;
}
- if ( $this->opts->getValue( 'wpHideSysops' ) == 1 ) {
+ if ( $this->opts->getValue( 'hidesysops' ) == 1 ) {
$this->groups['sysop'] = true;
}
}
return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" );
}
- protected function getHTMLFormFields() {
- $f = array(
- 'Username' => array(
- 'type' => 'text',
- 'label-message' => 'activeusers-from',
- 'size' => 30,
- ),
- 'HideBots' => array(
- 'type' => 'check',
- 'label-message' => 'activeusers-hidebots',
- ),
- 'HideSysops' => array(
- 'type' => 'check',
- 'label-message' => 'activeusers-hidesysops',
- ),
- );
+ function getPageHeader() {
+ global $wgScript;
- return $f;
- }
+ $self = $this->getTitle();
+ $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : '';
- protected function getHTMLFormLegend() {
- return 'activeusers';
- }
+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag
+ $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n";
+ $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
+
+ $out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(),
+ 'username', 'offset', 20, $this->requestedUser ) . '<br />';# Username field
+
+ $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(),
+ 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ) );
+
+ $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(),
+ 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ) ) . '<br />';
+
+ $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n";# Submit button and form bottom
+ $out .= Xml::closeElement( 'fieldset' );
+ $out .= Xml::closeElement( 'form' );
- protected function getHTMLFormSubmit() {
- return 'allpagessubmit';
+ return $out;
}
}
# getBody() first to check, if empty
$usersbody = $up->getBody();
- $out->addHTML( $up->buildHTMLForm() );
+ $out->addHTML( $up->getPageHeader() );
if ( $usersbody ) {
$out->addHTML(
$up->getNavigationBar() .
$out->addModuleStyles( 'mediawiki.special' );
- $this->filter = $request->getVal( 'wpFilter', 'all' );
- $this->prefix = $request->getVal( 'wpPrefix', '' );
+ $this->filter = $request->getVal( 'filter', 'all' );
+ $this->prefix = $request->getVal( 'prefix', '' );
$this->table = new AllmessagesTablePager(
$this,
array(),
- wfGetLangObj( $request->getVal( 'wpLanguage', $par ) )
+ wfGetLangObj( $request->getVal( 'lang', $par ) )
);
$this->langcode = $this->table->lang->getCode();
- $out->addHTML( $this->table->buildHTMLForm() .
+ $out->addHTML( $this->table->buildForm() .
$this->table->getNavigationBar() .
$this->table->getBody() .
$this->table->getNavigationBar() );
$request = $this->getRequest();
- if( $request->getVal( 'wpFilter', 'all' ) === 'all' ){
+ if( $request->getVal( 'filter', 'all' ) === 'all' ){
$this->custom = null; // So won't match in either case
} else {
- $this->custom = ($request->getVal( 'wpFilter' ) == 'unmodified');
+ $this->custom = ($request->getVal( 'filter' ) == 'unmodified');
}
- $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'wpPrefix', '' ) );
- $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'wpPrefix', null ) ) : null;
+ $prefix = $this->getLanguage()->ucfirst( $request->getVal( 'prefix', '' ) );
+ $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'prefix', null ) ) : null;
if( $prefix !== null ){
$this->displayPrefix = $prefix->getDBkey();
$this->prefix = '/^' . preg_quote( $this->displayPrefix ) . '/i';
}
}
- protected function getHTMLFormFields() {
- $f = array(
- 'Prefix' => array(
- 'type' => 'text',
- 'label-message' => 'allmessages-prefix',
- 'size' => 20,
- ),
- 'Filter' => array(
- 'type' => 'radio',
- 'label-message' => 'allmessages-filter',
- 'options' => array(
- $this->msg( 'allmessages-filter-unmodified' )->text() => 'unmodified',
- $this->msg( 'allmessages-filter-all' )->text() => 'all',
- $this->msg( 'allmessages-filter-modified' )->text() => 'modified',
- ),
- 'flatlist' => true,
- ),
- 'Language' => array(
- 'type' => 'select',
- 'label-message' => 'allmessages-language',
- 'options' => array(), // This is filled in below
- 'default' => $this->langcode,
- ),
- 'Limit' => $this->getHTMLFormLimitSelect(),
- );
+ function buildForm() {
+ global $wgScript;
$languages = Language::getLanguageNames( false );
ksort( $languages );
- foreach( $languages as $code => $name ) {
- $f['Language']['options'][ "$code - $name" ] = $code;
+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) .
+ Xml::fieldset( $this->msg( 'allmessages-filter-legend' )->text() ) .
+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
+ Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" .
+ '<tr>
+ <td class="mw-label">' .
+ Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) .
+ "</td>\n
+ <td class=\"mw-input\">" .
+ Xml::input( 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), array( 'id' => 'mw-allmessages-form-prefix' ) ) .
+ "</td>\n
+ </tr>
+ <tr>\n
+ <td class='mw-label'>" .
+ $this->msg( 'allmessages-filter' )->escaped() .
+ "</td>\n
+ <td class='mw-input'>" .
+ Xml::radioLabel( $this->msg( 'allmessages-filter-unmodified' )->text(),
+ 'filter',
+ 'unmodified',
+ 'mw-allmessages-form-filter-unmodified',
+ ( $this->filter == 'unmodified' )
+ ) .
+ Xml::radioLabel( $this->msg( 'allmessages-filter-all' )->text(),
+ 'filter',
+ 'all',
+ 'mw-allmessages-form-filter-all',
+ ( $this->filter == 'all' )
+ ) .
+ Xml::radioLabel( $this->msg( 'allmessages-filter-modified' )->text(),
+ 'filter',
+ 'modified',
+ 'mw-allmessages-form-filter-modified',
+ ( $this->filter == 'modified' )
+ ) .
+ "</td>\n
+ </tr>
+ <tr>\n
+ <td class=\"mw-label\">" .
+ Xml::label( $this->msg( 'allmessages-language' )->text(), 'mw-allmessages-form-lang' ) .
+ "</td>\n
+ <td class=\"mw-input\">" .
+ Xml::openElement( 'select', array( 'id' => 'mw-allmessages-form-lang', 'name' => 'lang' ) );
+
+ foreach( $languages as $lang => $name ) {
+ $selected = $lang == $this->langcode;
+ $out .= Xml::option( $lang . ' - ' . $name, $lang, $selected ) . "\n";
}
-
- return $f;
- }
-
- protected function getHTMLFormLegend() {
- return 'allmessages-filter-legend';
- }
-
- protected function getHTMLFormSubmit() {
- return 'allmessages-filter-submit';
+ $out .= Xml::closeElement( 'select' ) .
+ "</td>\n
+ </tr>" .
+
+ '<tr>
+ <td class="mw-label">' .
+ Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) .
+ '</td>
+ <td class="mw-input">' .
+ $this->getLimitSelect() .
+ '</td>
+ <tr>
+ <td></td>
+ <td>' .
+ Xml::submitButton( $this->msg( 'allmessages-filter-submit' )->text() ) .
+ "</td>\n
+ </tr>" .
+
+ Xml::closeElement( 'table' ) .
+ $this->getHiddenFields( array( 'title', 'prefix', 'filter', 'lang', 'limit' ) ) .
+ Xml::closeElement( 'fieldset' ) .
+ Xml::closeElement( 'form' );
+ return $out;
}
function getAllMessages( $descending ) {
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
+ $lang = $this->getLanguage();
$out->setPageTitle( $this->msg( 'ipblocklist' ) );
$out->addModuleStyles( 'mediawiki.special' );
$request = $this->getRequest();
$par = $request->getVal( 'ip', $par );
$this->target = trim( $request->getVal( 'wpTarget', $par ) );
- $request->setVal( 'wpTarget', $this->target );
$this->options = $request->getArray( 'wpOptions', array() );
return;
}
+ # Just show the block list
+ $fields = array(
+ 'Target' => array(
+ 'type' => 'text',
+ 'label-message' => 'ipadressorusername',
+ 'tabindex' => '1',
+ 'size' => '45',
+ 'default' => $this->target,
+ ),
+ 'Options' => array(
+ 'type' => 'multiselect',
+ 'options' => array(
+ wfMsg( 'blocklist-userblocks' ) => 'userblocks',
+ wfMsg( 'blocklist-tempblocks' ) => 'tempblocks',
+ wfMsg( 'blocklist-addressblocks' ) => 'addressblocks',
+ wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks',
+ ),
+ 'flatlist' => true,
+ ),
+ 'Limit' => array(
+ 'class' => 'HTMLBlockedUsersItemSelect',
+ 'label-message' => 'table_pager_limit_label',
+ 'options' => array(
+ $lang->formatNum( 20 ) => 20,
+ $lang->formatNum( 50 ) => 50,
+ $lang->formatNum( 100 ) => 100,
+ $lang->formatNum( 250 ) => 250,
+ $lang->formatNum( 500 ) => 500,
+ ),
+ 'name' => 'limit',
+ 'default' => 50,
+ ),
+ );
+ $form = new HTMLForm( $fields, $this->getContext() );
+ $form->setMethod( 'get' );
+ $form->setWrapperLegend( wfMsg( 'ipblocklist-legend' ) );
+ $form->setSubmitText( wfMsg( 'ipblocklist-submit' ) );
+ $form->prepareForm();
+
+ $form->displayForm( '' );
$this->showList();
}
}
$pager = new BlockListPager( $this, $conds );
- $out->addHTML( $pager->buildHTMLForm() );
if ( $pager->getNumRows() ) {
$out->addHTML(
$pager->getNavigationBar() .
return $info;
}
- protected function getHTMLFormFields() {
- return array(
- 'Target' => array(
- 'type' => 'text',
- 'label-message' => 'ipadressorusername',
- 'tabindex' => '1',
- 'size' => '45',
- //'default' => $this->target,
- ),
- 'Options' => array(
- 'type' => 'multiselect',
- 'options' => array(
- wfMsg( 'blocklist-userblocks' ) => 'userblocks',
- wfMsg( 'blocklist-tempblocks' ) => 'tempblocks',
- wfMsg( 'blocklist-addressblocks' ) => 'addressblocks',
- wfMsg( 'blocklist-rangeblocks' ) => 'rangeblocks',
- ),
- 'flatlist' => true,
- ),
- 'Limit' => $this->getHTMLFormLimitSelect(),
- );
- }
-
- protected function getHTMLFormSubmit() {
- return 'ipblocklist-submit';
- }
-
- protected function getHTMLFormLegend() {
- return 'ipblocklist-legend';
- }
-
public function getTableClass(){
return 'TablePager mw-blocklist';
}
$lb->execute();
wfProfileOut( __METHOD__ );
}
-}
\ No newline at end of file
+}
+
+/**
+ * Items per page dropdown. Essentially a crap workaround for bug 32603.
+ *
+ * @todo Do not release 1.19 with this.
+ */
+class HTMLBlockedUsersItemSelect extends HTMLSelectField {
+ /**
+ * Basically don't do any validation. If it's a number that's fine. Also,
+ * add it to the list if it's not there already
+ *
+ * @param $value
+ * @param $alldata
+ * @return bool
+ */
+ function validate( $value, $alldata ) {
+ if ( $value == '' ) {
+ return true;
+ }
+
+ if ( !in_array( $value, $this->mParams['options'] ) ) {
+ $this->mParams['options'][ $this->mParent->getLanguage()->formatNum( $value ) ] = intval($value);
+ asort( $this->mParams['options'] );
+ }
+
+ return true;
+ }
+
+}
$this->outputHeader();
$this->getOutput()->allowClickjacking();
- $from = $this->getRequest()->getText( 'wpFrom', $par );
+ $from = $this->getRequest()->getText( 'from', $par );
$cap = new CategoryPager( $this->getContext(), $from );
$cap->doQuery();
$this->getOutput()->addHTML(
Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) .
$this->msg( 'categoriespagetext', $cap->getNumRows() )->parseAsBlock() .
- $cap->buildHTMLForm() .
+ $cap->getStartForm( $from ) .
$cap->getNavigationBar() .
'<ul>' . $cap->getBody() . '</ul>' .
$cap->getNavigationBar() .
return Xml::tags( 'li', null, $this->getLanguage()->specialList( $titleText, $count ) ) . "\n";
}
- protected function getHTMLFormFields() {
- return array(
- 'From' => array(
- 'type' => 'text',
- 'label-message' => 'categoriesfrom',
- 'size' => '20',
- ),
- );
- }
-
- protected function getHTMLFormLegend() {
- return 'categories';
- }
-
- protected function getHTMLFormSubmit() {
- return 'allpagessubmit';
+ public function getStartForm( $from ) {
+ global $wgScript;
+
+ return
+ Xml::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
+ Xml::fieldset( $this->msg( 'categories' )->text(),
+ Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(),
+ 'from', 'from', 20, $from ) .
+ ' ' .
+ Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) ) );
}
}
$userName = $par;
$search = '';
} else {
- $userName = $this->getRequest()->getText( 'wpUsername', $par );
- $search = $this->getRequest()->getText( 'wpSearch', '' );
+ $userName = $this->getRequest()->getText( 'user', $par );
+ $search = $this->getRequest()->getText( 'ilsearch', '' );
}
$pager = new ImageListPager( $this->getContext(), $userName, $search, $this->including() );
if ( $this->including() ) {
$html = $pager->getBody();
} else {
- $form = $pager->buildHTMLForm();
+ $form = $pager->getForm();
$body = $pager->getBody();
$nav = $pager->getNavigationBar();
$html = "$form<br />\n$body<br />\n$nav";
}
}
- protected function getHTMLFormFields() {
- global $wgMiserMode;
- $f = array(
- 'Limit' => $this->getHTMLFormLimitSelect(),
- );
-
+ function getForm() {
+ global $wgScript, $wgMiserMode;
+ $inputForm = array();
+ $inputForm['table_pager_limit_label'] = $this->getLimitSelect();
if ( !$wgMiserMode ) {
- $f['Search'] = array(
- 'type' => 'text',
- 'label-message' => 'listfiles_search_for',
- 'maxlength' => 255,
- );
+ $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text',
+ array(
+ 'size' => '40',
+ 'maxlength' => '255',
+ 'id' => 'mw-ilsearch',
+ ) );
}
-
- $f['Username'] = array(
- 'type' => 'text',
- 'label-message' => 'username',
- 'maxlength' => 255,
- );
-
- return $f;
- }
-
- protected function getHTMLFormLegend() {
- return 'listfiles';
- }
-
- protected function getHTMLFormSubmit() {
- return 'table_pager_limit_submit';
+ $inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array(
+ 'size' => '40',
+ 'maxlength' => '255',
+ 'id' => 'mw-listfiles-user',
+ ) );
+ return Html::openElement( 'form',
+ array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) .
+ Xml::fieldset( wfMsg( 'listfiles' ) ) .
+ Xml::buildForm( $inputForm, 'table_pager_limit_submit' ) .
+ $this->getHiddenFields( array( 'limit', 'ilsearch', 'user' ) ) .
+ Html::closeElement( 'fieldset' ) .
+ Html::closeElement( 'form' ) . "\n";
}
function getTableClass() {
$symsForAll = array( '*', 'user' );
if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) {
$this->requestedGroup = $par;
- $un = $request->getText( 'wpUsername' );
+ $un = $request->getText( 'username' );
} elseif ( count( $parms ) == 2 ) {
$this->requestedGroup = $parms[0];
$un = $parms[1];
} else {
- $this->requestedGroup = $request->getVal( 'wpGroup' );
- $un = ( $par != '' ) ? $par : $request->getText( 'wpUsername' );
+ $this->requestedGroup = $request->getVal( 'group' );
+ $un = ( $par != '' ) ? $par : $request->getText( 'username' );
}
if ( in_array( $this->requestedGroup, $symsForAll ) ) {
$this->requestedGroup = '';
}
- $this->editsOnly = $request->getBool( 'wpEditsOnly' );
- $this->creationSort = $request->getBool( 'wpCreationSort' );
+ $this->editsOnly = $request->getBool( 'editsOnly' );
+ $this->creationSort = $request->getBool( 'creationSort' );
$this->requestedUser = '';
if ( $un != '' ) {
return parent::getBody();
}
- protected function getHTMLFormFields() {
- $f = array(
- 'Username' => array(
- 'type' => 'text',
- 'label-message' => 'listusersfrom',
- 'size' => 30,
- ),
- 'Group' => array(
- 'type' => 'select',
- 'label-message' => 'group',
- 'options' => array(
- $this->msg( 'group-all' )->escaped() => '',
- ),
- ),
- 'EditsOnly' => array(
- 'type' => 'check',
- 'label-message' => 'listusers-editsonly',
- ),
- 'CreationSort' => array(
- 'type' => 'check',
- 'label-message' => 'listusers-creationsort',
- ),
- );
-
- foreach( $this->getAllGroups() as $group => $groupText ) {
- $f['Group']['options'][$groupText] = $group;
- }
-
- return $f;
- }
-
- protected function getHTMLFormSubmit() {
- return 'allpagessubmit';
- }
-
- protected function getHTMLFormLegend() {
- return 'listusers';
+ function getPageHeader( ) {
+ global $wgScript;
+ $self = $this->getTitle();
+
+ # Form tag
+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) ) .
+ Xml::fieldset( wfMsg( 'listusers' ) ) .
+ Html::hidden( 'title', $self->getPrefixedDbKey() );
+
+ # Username field
+ $out .= Xml::label( wfMsg( 'listusersfrom' ), 'offset' ) . ' ' .
+ Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' ';
+
+ # Group drop-down list
+ $out .= Xml::label( wfMsg( 'group' ), 'group' ) . ' ' .
+ Xml::openElement('select', array( 'name' => 'group', 'id' => 'group' ) ) .
+ Xml::option( wfMsg( 'group-all' ), '' );
+ foreach( $this->getAllGroups() as $group => $groupText )
+ $out .= Xml::option( $groupText, $group, $group == $this->requestedGroup );
+ $out .= Xml::closeElement( 'select' ) . '<br />';
+ $out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly );
+ $out .= ' ';
+ $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort );
+ $out .= '<br />';
+
+ wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) );
+
+ # Submit button and form bottom
+ $out .= Html::hidden( 'limit', $this->mLimit );
+ $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
+ wfRunHooks( 'SpecialListusersHeader', array( $this, &$out ) );
+ $out .= Xml::closeElement( 'fieldset' ) .
+ Xml::closeElement( 'form' );
+
+ return $out;
}
/**
# getBody() first to check, if empty
$usersbody = $up->getBody();
- $s = $up->buildHTMLForm();
+ $s = $up->getPageHeader();
if( $usersbody ) {
$s .= $up->getNavigationBar();
$s .= Html::rawElement( 'ul', array(), $usersbody );
$this->setHeaders();
$this->outputHeader();
- $out = $this->getOutput();
$pager = new NewFilesPager( $this->getContext(), $par );
if ( !$this->including() ) {
- $out->addHTML( $pager->buildHTMLForm() );
+ $form = $pager->getForm();
+ $form->prepareForm();
+ $form->displayForm( '' );
}
- $out->addHTML( $pager->getBody() );
+ $this->getOutput()->addHTML( $pager->getBody() );
if ( !$this->including() ) {
- $out->addHTML( $pager->getNavigationBar() );
+ $this->getOutput()->addHTML( $pager->getNavigationBar() );
}
}
}
);
}
- protected function getHTMLFormFields() {
+ function getForm() {
global $wgMiserMode;
$fields = array(
'type' => 'check',
'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ),
'name' => 'showbots',
+ # 'default' => $this->getRequest()->getBool( 'showbots', 0 ),
+ ),
+ 'limit' => array(
+ 'type' => 'hidden',
+ 'default' => $this->getRequest()->getText( 'limit' ),
+ 'name' => 'limit',
+ ),
+ 'offset' => array(
+ 'type' => 'hidden',
+ 'default' => $this->getRequest()->getText( 'offset' ),
+ 'name' => 'offset',
),
);
unset( $fields['like'] );
}
- return $fields;
- }
-
- protected function getHTMLFormLegend() {
- return 'newimages-legend';
- }
+ $form = new HTMLForm( $fields, $this->getContext() );
+ $form->setTitle( $this->getTitle() );
+ $form->setSubmitText( wfMsg( 'ilsubmit' ) );
+ $form->setMethod( 'get' );
+ $form->setWrapperLegend( wfMsg( 'newimages-legend' ) );
- protected function getHTMLFormSubmit() {
- return 'ilsubmit';
+ return $form;
}
}
*/
class SpecialProtectedtitles extends SpecialPage {
+ protected $IdLevel = 'level';
+ protected $IdType = 'type';
+
public function __construct() {
parent::__construct( 'Protectedtitles' );
}
Title::purgeExpiredRestrictions();
}
- $pager = new ProtectedTitlesPager( $this );
- $this->getOutput()->addHTML( $pager->buildHTMLForm() );
+ $request = $this->getRequest();
+ $type = $request->getVal( $this->IdType );
+ $level = $request->getVal( $this->IdLevel );
+ $sizetype = $request->getVal( 'sizetype' );
+ $size = $request->getIntOrNull( 'size' );
+ $NS = $request->getIntOrNull( 'namespace' );
+
+ $pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size );
+
+ $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );
if ( $pager->getNumRows() ) {
$s = $pager->getNavigationBar();
/**
* Callback function to output a restriction
*
- * @param $row
* @return string
*/
function formatRow( $row ) {
return '<li>' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "</li>\n";
}
-}
-/**
- * @todo document
- * @ingroup Pager
- */
-class ProtectedTitlesPager extends AlphabeticPager {
/**
- * @var SpecialProtectedtitles
+ * @param $namespace Integer:
+ * @param $type string
+ * @param $level string
+ * @private
*/
- public $mForm;
+ function showOptions( $namespace, $type='edit', $level ) {
+ global $wgScript;
+ $action = htmlspecialchars( $wgScript );
+ $title = $this->getTitle();
+ $special = htmlspecialchars( $title->getPrefixedDBkey() );
+ return "<form action=\"$action\" method=\"get\">\n" .
+ '<fieldset>' .
+ Xml::element( 'legend', array(), wfMsg( 'protectedtitles' ) ) .
+ Html::hidden( 'title', $special ) . " \n" .
+ $this->getNamespaceMenu( $namespace ) . " \n" .
+ $this->getLevelMenu( $level ) . " \n" .
+ " " . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
+ "</fieldset></form>";
+ }
/**
- * @var array
+ * Prepare the namespace filter drop-down; standard namespace
+ * selector, sans the MediaWiki namespace
+ *
+ * @param $namespace Mixed: pre-select namespace
+ * @return string
*/
- public $mConds;
+ function getNamespaceMenu( $namespace = null ) {
+ return Xml::label( wfMsg( 'namespace' ), 'namespace' )
+ . ' '
+ . Xml::namespaceSelector( $namespace, '' );
+ }
/**
- * @param $form SpecialProtectedtitles
- * @param $conds array
+ * @return string Formatted HTML
+ * @private
*/
- function __construct( $form, $conds = array() ) {
+ function getLevelMenu( $pr_level ) {
+ 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 = wfMsg("restriction-level-$type");
+ $m[$text] = $type;
+ }
+ }
+ // Is there only one level (aside from "all")?
+ if( count($m) <= 2 ) {
+ return '';
+ }
+ // Third pass generates sorted XHTML content
+ foreach( $m as $text => $type ) {
+ $selected = ($type == $pr_level );
+ $options[] = Xml::option( $text, $type, $selected );
+ }
+
+ return
+ Xml::label( wfMsg('restriction-level') , $this->IdLevel ) . ' ' .
+ Xml::tags( 'select',
+ array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
+ implode( "\n", $options ) );
+ }
+}
+
+/**
+ * @todo document
+ * @ingroup Pager
+ */
+class ProtectedTitlesPager extends AlphabeticPager {
+ public $mForm, $mConds;
+
+ function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype='', $size=0 ) {
$this->mForm = $form;
$this->mConds = $conds;
+ $this->level = $level;
+ $this->namespace = $namespace;
+ $this->size = intval($size);
parent::__construct( $form->getContext() );
}
function getQueryInfo() {
$conds = $this->mConds;
$conds[] = 'pt_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() );
-
- if ( $this->mHTMLForm->getVal( 'Level' ) ) {
- $conds['pt_create_perm'] = $this->mHTMLForm->getVal( 'Level' );
- }
- if ( $this->mHTMLForm->getVal( 'Namespace' ) !== '' ) {
- $conds['pt_namespace'] = $this->mHTMLForm->getVal( 'Namespace' );
- }
-
+ if( $this->level )
+ $conds['pt_create_perm'] = $this->level;
+ if( !is_null($this->namespace) )
+ $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace );
return array(
'tables' => 'protected_titles',
'fields' => 'pt_namespace,pt_title,pt_create_perm,pt_expiry,pt_timestamp',
function getIndexField() {
return 'pt_timestamp';
}
-
- protected function getHTMLFormFields() {
- return array(
- 'Namespace' => array(
- 'type' => 'namespaces',
- 'label-message' => 'namespace',
- ),
- 'Level' => array(
- 'type' => 'restrictionlevels',
- 'label-message' => 'restriction-level',
- ),
- );
- }
-
- protected function getHTMLFormSubmit() {
- return 'allpagessubmit';
- }
-
- protected function getHTMLFormLegend() {
- return 'protectedtitles';
- }
-
-
}