'HTMLFileCache' => __DIR__ . '/includes/cache/HTMLFileCache.php',
'HTMLFloatField' => __DIR__ . '/includes/htmlform/HTMLFloatField.php',
'HTMLForm' => __DIR__ . '/includes/htmlform/HTMLForm.php',
+ 'HTMLFormFieldWithButton' => __DIR__ . '/includes/htmlform/HTMLFormFieldWithButton.php',
'HTMLFormField' => __DIR__ . '/includes/htmlform/HTMLFormField.php',
'HTMLFormFieldCloner' => __DIR__ . '/includes/htmlform/HTMLFormFieldCloner.php',
'HTMLFormFieldRequiredOptionsException' => __DIR__ . '/includes/htmlform/HTMLFormFieldRequiredOptionsException.php',
'HTMLSelectField' => __DIR__ . '/includes/htmlform/HTMLSelectField.php',
'HTMLSelectLimitField' => __DIR__ . '/includes/htmlform/HTMLSelectLimitField.php',
'HTMLSelectNamespace' => __DIR__ . '/includes/htmlform/HTMLSelectNamespace.php',
+ 'HTMLSelectNamespaceWithButton' => __DIR__ . '/includes/htmlform/HTMLSelectNamespaceWithButton.php',
'HTMLSelectOrOtherField' => __DIR__ . '/includes/htmlform/HTMLSelectOrOtherField.php',
'HTMLSubmitField' => __DIR__ . '/includes/htmlform/HTMLSubmitField.php',
'HTMLTagFilter' => __DIR__ . '/includes/htmlform/HTMLTagFilter.php',
'HTMLTextAreaField' => __DIR__ . '/includes/htmlform/HTMLTextAreaField.php',
'HTMLTextField' => __DIR__ . '/includes/htmlform/HTMLTextField.php',
+ 'HTMLTextFieldWithButton' => __DIR__ . '/includes/htmlform/HTMLTextFieldWithButton.php',
'HWLDFWordAccumulator' => __DIR__ . '/includes/diff/DairikiDiff.php',
'HashBagOStuff' => __DIR__ . '/includes/libs/objectcache/HashBagOStuff.php',
'HashConfig' => __DIR__ . '/includes/config/HashConfig.php',
function getLabel() {
if ( $this->mParent instanceof OOUIHTMLForm ) {
return $this->mLabel;
+ } elseif (
+ $this->mParent instanceof HTMLForm &&
+ $this->mParent->getDisplayFormat() === 'div'
+ ) {
+ return '';
} else {
return ' ';
}
public static $typeMappings = array(
'api' => 'HTMLApiField',
'text' => 'HTMLTextField',
+ 'textwithbutton' => 'HTMLTextFieldWithButton',
'textarea' => 'HTMLTextAreaField',
'select' => 'HTMLSelectField',
'radio' => 'HTMLRadioField',
'selectorother' => 'HTMLSelectOrOtherField',
'selectandother' => 'HTMLSelectAndOtherField',
'namespaceselect' => 'HTMLSelectNamespace',
+ 'namespaceselectwithbutton' => 'HTMLSelectNamespaceWithButton',
'tagfilter' => 'HTMLTagFilter',
'submit' => 'HTMLSubmitField',
'hidden' => 'HTMLHiddenField',
'mw-htmlform-nolabel' => ( $label === '' )
);
- $field = Html::rawElement(
- 'div',
- array( 'class' => $outerDivClass ) + $cellAttributes,
- $inputHtml . "\n$errors"
- );
- $divCssClasses = array( "mw-htmlform-field-$fieldType", $this->mClass, $this->mVFormClass, $errorClass );
+ $horizontalLabel = isset( $this->mParams['horizontal-label'] )
+ ? $this->mParams['horizontal-label'] : false;
+
+ if ( $horizontalLabel ) {
+ $field = ' ' . $inputHtml . "\n$errors";
+ } else {
+ $field = Html::rawElement(
+ 'div',
+ array( 'class' => $outerDivClass ) + $cellAttributes,
+ $inputHtml . "\n$errors"
+ );
+ }
+ $divCssClasses = array( "mw-htmlform-field-$fieldType",
+ $this->mClass, $this->mVFormClass, $errorClass );
$wrapperAttributes = array(
'class' => $divCssClasses,
$displayFormat = $this->mParent->getDisplayFormat();
$html = '';
+ $horizontalLabel = isset( $this->mParams['horizontal-label'] )
+ ? $this->mParams['horizontal-label'] : false;
if ( $displayFormat === 'table' ) {
$html =
array( 'class' => 'mw-label' ) + $cellAttributes,
Html::rawElement( 'label', $for, $labelValue ) );
} elseif ( $hasLabel || $this->mShowEmptyLabels ) {
- if ( $displayFormat === 'div' ) {
+ if ( $displayFormat === 'div' && !$horizontalLabel ) {
$html =
Html::rawElement( 'div',
array( 'class' => 'mw-label' ) + $cellAttributes,
--- /dev/null
+<?php
+/**
+ * Enables HTMLFormField elements to be build with a button.
+ */
+class HTMLFormFieldWithButton extends HTMLFormField {
+ /** @var string $mButtonClass CSS class for the button in this field */
+ protected $mButtonClass = '';
+
+ /** @var string|integer $mButtonId Element ID for the button in this field */
+ protected $mButtonId = '';
+
+ /** @var string $mButtonName Name the button in this field */
+ protected $mButtonName = '';
+
+ /** @var string $mButtonType Type of the button in this field (e.g. button or submit) */
+ protected $mButtonType = 'submit';
+
+ /** @var string $mButtonType Value for the button in this field */
+ protected $mButtonValue;
+
+ public function __construct( $info ) {
+ if ( isset( $info['buttonclass'] ) ) {
+ $this->mButtonClass = $info['buttonclass'];
+ }
+ if ( isset( $info['buttonid'] ) ) {
+ $this->mButtonId = $info['buttonid'];
+ }
+ if ( isset( $info['buttonname'] ) ) {
+ $this->mButtonName = $info['buttonname'];
+ }
+ if ( isset( $info['buttondefault'] ) ) {
+ $this->mButtonValue = $info['buttondefault'];
+ }
+ if ( isset( $info['buttontype'] ) ) {
+ $this->mButtonType = $info['buttontype'];
+ }
+ parent::__construct( $info );
+ }
+
+ public function getInputHTML( $value ) {
+ $attr = array(
+ 'class' => 'mw-htmlform-submit ' . $this->mButtonClass,
+ 'id' => $this->mButtonId,
+ ) + $this->getAttributes( array( 'disabled', 'tabindex' ) );
+
+ return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr );
+ }
+
+ /**
+ * Combines the passed element with a button.
+ * @param String $element Element to combine the button with.
+ * @return String
+ */
+ public function getElement( $element ) {
+ return $element . ' ' . $this->getInputHTML( '' );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Creates a Html::namespaceSelector input field with a button assigned to the input field.
+ */
+class HTMLSelectNamespaceWithButton extends HTMLSelectNamespace {
+ /** @var HTMLFormClassWithButton $mClassWithButton */
+ protected $mClassWithButton = null;
+
+ public function __construct( $info ) {
+ $this->mClassWithButton = new HTMLFormFieldWithButton( $info );
+ parent::__construct( $info );
+ }
+
+ public function getInputHTML( $value ) {
+ return $this->mClassWithButton->getElement( parent::getInputHTML( $value ) );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Creates a text input field with a button assigned to the input field.
+ */
+class HTMLTextFieldWithButton extends HTMLTextField {
+ /** @var HTMLFormClassWithButton $mClassWithButton */
+ protected $mClassWithButton = null;
+
+ public function __construct( $info ) {
+ $this->mClassWithButton = new HTMLFormFieldWithButton( $info );
+ parent::__construct( $info );
+ }
+
+ public function getInputHTML( $value ) {
+ return $this->mClassWithButton->getElement( parent::getInputHTML( $value ) );
+ }
+}
\ No newline at end of file
$categoryName = '';
}
- $form = Xml::openElement( 'form', array( 'method' => 'post',
- 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ) ) );
- $form .= Xml::inputLabel(
- $this->msg( 'export-addcattext' )->text(),
- 'catname',
- 'catname',
- 40,
- $categoryName
- ) . ' ';
- $form .= Xml::submitButton(
- $this->msg( 'export-addcat' )->text(),
- array( 'name' => 'addcat' )
- ) . '<br />';
-
+ $formDescriptor = array(
+ 'catname' => array(
+ 'type' => 'textwithbutton',
+ 'name' => 'catname',
+ 'horizontal-label' => true,
+ 'label-message' => 'export-addcattext',
+ 'default' => $categoryName,
+ 'size' => 40,
+ 'buttontype' => 'submit',
+ 'buttonname' => 'addcat',
+ 'buttondefault' => $this->msg( 'export-addcat' )->text(),
+ ),
+ );
if ( $config->get( 'ExportFromNamespaces' ) ) {
- $form .= Html::namespaceSelector(
- array(
- 'selected' => $nsindex,
- 'label' => $this->msg( 'export-addnstext' )->text()
- ), array(
+ $formDescriptor += array(
+ 'nsindex' => array(
+ 'type' => 'namespaceselectwithbutton',
+ 'default' => $nsindex,
+ 'label-message' => 'export-addnstext',
+ 'horizontal-label' => true,
'name' => 'nsindex',
'id' => 'namespace',
- 'class' => 'namespaceselector',
- )
- ) . ' ';
- $form .= Xml::submitButton(
- $this->msg( 'export-addns' )->text(),
- array( 'name' => 'addns' )
- ) . '<br />';
+ 'cssclass' => 'namespaceselector',
+ 'buttontype' => 'submit',
+ 'buttonname' => 'addns',
+ 'buttondefault' => $this->msg( 'export-addns' )->text(),
+ ),
+ );
}
if ( $config->get( 'ExportAllowAll' ) ) {
- $form .= Xml::checkLabel(
- $this->msg( 'exportall' )->text(),
- 'exportall',
- 'exportall',
- $request->wasPosted() ? $request->getCheck( 'exportall' ) : false
- ) . '<br />';
+ $formDescriptor += array(
+ 'exportall' => array(
+ 'type' => 'check',
+ 'label-message' => 'exportall',
+ 'name' => 'exportall',
+ 'id' => 'exportall',
+ 'default' => $request->wasPosted() ? $request->getCheck( 'exportall' ) : false,
+ ),
+ );
}
- $form .= Xml::element(
- 'textarea',
- array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ),
- $page,
- false
+ $formDescriptor += array(
+ 'textarea' => array(
+ 'class' => 'HTMLTextAreaField',
+ 'name' => 'pages',
+ 'nodata' => true,
+ 'cols' => 40,
+ 'rows' => 10,
+ 'default' => $page,
+ ),
);
- $form .= '<br />';
if ( $config->get( 'ExportAllowHistory' ) ) {
- $form .= Xml::checkLabel(
- $this->msg( 'exportcuronly' )->text(),
- 'curonly',
- 'curonly',
- $request->wasPosted() ? $request->getCheck( 'curonly' ) : true
- ) . '<br />';
+ $formDescriptor += array(
+ 'curonly' => array(
+ 'type' => 'check',
+ 'label-message' => 'exportcuronly',
+ 'name' => 'curonly',
+ 'id' => 'curonly',
+ 'default' => $request->wasPosted() ? $request->getCheck( 'curonly' ) : true,
+ ),
+ );
} else {
$out->addWikiMsg( 'exportnohistory' );
}
- $form .= Xml::checkLabel(
- $this->msg( 'export-templates' )->text(),
- 'templates',
- 'wpExportTemplates',
- $request->wasPosted() ? $request->getCheck( 'templates' ) : false
- ) . '<br />';
+ $formDescriptor += array(
+ 'templates' => array(
+ 'type' => 'check',
+ 'label-message' => 'export-templates',
+ 'name' => 'templates',
+ 'id' => 'wpExportTemplates',
+ 'default' => $request->wasPosted() ? $request->getCheck( 'templates' ) : false,
+ ),
+ );
if ( $config->get( 'ExportMaxLinkDepth' ) || $this->userCanOverrideExportDepth() ) {
- $form .= Xml::inputLabel(
- $this->msg( 'export-pagelinks' )->text(),
- 'pagelink-depth',
- 'pagelink-depth',
- 20,
- 0
- ) . '<br />';
+ $formDescriptor += array(
+ 'pagelink-depth' => array(
+ 'type' => 'text',
+ 'name' => 'pagelink-depth',
+ 'id' => 'pagelink-depth',
+ 'label-message' => 'export-pagelinks',
+ 'default' => '0',
+ 'size' => 20,
+ ),
+ );
}
- /* Enable this when we can do something useful exporting/importing image information.
- $form .= Xml::checkLabel(
- $this->msg( 'export-images' )->text(),
- 'images',
- 'wpExportImages',
- false
- ) . '<br />';
- */
- $form .= Xml::checkLabel(
- $this->msg( 'export-download' )->text(),
- 'wpDownload',
- 'wpDownload',
- $request->wasPosted() ? $request->getCheck( 'wpDownload' ) : true
- ) . '<br />';
+ $formDescriptor += array(
+ /* Enable this when we can do something useful exporting/importing image information.
+ 'images' => array(
+ 'type' => 'check',
+ 'name' => 'images',
+ 'id' => 'wpExportImages',
+ 'default' => false,
+ ),*/
+ 'wpDownload' => array(
+ 'type' => 'check',
+ 'name' =>'wpDownload',
+ 'id' => 'wpDownload',
+ 'default' => $request->wasPosted() ? $request->getCheck( 'wpDownload' ) : true,
+ 'label-message' => 'export-download',
+ ),
+ );
if ( $config->get( 'ExportAllowListContributors' ) ) {
- $form .= Xml::checkLabel(
- $this->msg( 'exportlistauthors' )->text(),
- 'listauthors',
- 'listauthors',
- $request->wasPosted() ? $request->getCheck( 'listauthors' ) : false
- ) . '<br />';
+ $formDescriptor += array(
+ 'listauthors' => array(
+ 'type' => 'check',
+ 'label-message' => 'exportlistauthors',
+ 'default' => $request->wasPosted() ? $request->getCheck( 'listauthors' ) : false,
+ 'name' => 'listauthors',
+ 'id' => 'listauthors',
+ ),
+ );
}
- $form .= Xml::submitButton(
- $this->msg( 'export-submit' )->text(),
- Linker::tooltipAndAccesskeyAttribs( 'export' )
- );
- $form .= Xml::closeElement( 'form' );
-
- $out->addHTML( $form );
+ $htmlForm = HTMLForm::factory( 'div', $formDescriptor, $this->getContext() );
+ $htmlForm->setSubmitTextMsg( 'export-submit' );
+ $htmlForm->prepareForm()->displayForm( false );
$this->addHelpLink( 'Help:Export' );
}