2023-06-23 19:38:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTML form generation using Codex components.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
2024-02-08 15:30:18 +00:00
|
|
|
namespace MediaWiki\HTMLForm;
|
|
|
|
|
|
2023-06-23 19:38:08 +00:00
|
|
|
use MediaWiki\Html\Html;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Codex based HTML form
|
|
|
|
|
*
|
|
|
|
|
* @since 1.41
|
|
|
|
|
*/
|
|
|
|
|
class CodexHTMLForm extends HTMLForm {
|
2023-07-10 16:53:50 +00:00
|
|
|
|
|
|
|
|
protected $displayFormat = 'codex';
|
2023-06-23 19:38:08 +00:00
|
|
|
|
|
|
|
|
public static function loadInputFromParameters( $fieldname, $descriptor,
|
|
|
|
|
HTMLForm $parent = null
|
|
|
|
|
) {
|
|
|
|
|
$field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
|
|
|
|
|
$field->setShowEmptyLabel( false );
|
|
|
|
|
return $field;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getHTML( $submitResult ) {
|
|
|
|
|
$this->getOutput()->addModuleStyles( [
|
|
|
|
|
'codex-styles',
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
return parent::getHTML( $submitResult );
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-10 16:53:50 +00:00
|
|
|
/**
|
|
|
|
|
* @inheritDoc
|
|
|
|
|
*/
|
|
|
|
|
protected function formatField( HTMLFormField $field, $value ) {
|
2024-03-04 23:46:07 +00:00
|
|
|
return $field->getCodex( $value );
|
2023-07-10 16:53:50 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-23 19:38:08 +00:00
|
|
|
protected function getFormAttributes() {
|
|
|
|
|
$attribs = parent::getFormAttributes();
|
|
|
|
|
$attribs['class'] = [ 'mw-htmlform', 'mw-htmlform-codex' ];
|
|
|
|
|
return $attribs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function wrapForm( $html ) {
|
|
|
|
|
return Html::rawElement( 'form', $this->getFormAttributes(), $html );
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-08 15:30:18 +00:00
|
|
|
|
|
|
|
|
/** @deprecated since 1.42 */
|
|
|
|
|
class_alias( CodexHTMLForm::class, 'CodexHTMLForm' );
|