MediaWiki
REL1_24
|
00001 <?php 00002 00006 class HTMLSelectField extends HTMLFormField { 00007 function validate( $value, $alldata ) { 00008 $p = parent::validate( $value, $alldata ); 00009 00010 if ( $p !== true ) { 00011 return $p; 00012 } 00013 00014 $validOptions = HTMLFormField::flattenOptions( $this->getOptions() ); 00015 00016 if ( in_array( strval( $value ), $validOptions, true ) ) { 00017 return true; 00018 } else { 00019 return $this->msg( 'htmlform-select-badoption' )->parse(); 00020 } 00021 } 00022 00023 function getInputHTML( $value ) { 00024 $select = new XmlSelect( $this->mName, $this->mID, strval( $value ) ); 00025 00026 if ( !empty( $this->mParams['disabled'] ) ) { 00027 $select->setAttribute( 'disabled', 'disabled' ); 00028 } 00029 00030 $allowedParams = array( 'tabindex', 'size' ); 00031 $customParams = $this->getAttributes( $allowedParams ); 00032 foreach ( $customParams as $name => $value ) { 00033 $select->setAttribute( $name, $value ); 00034 } 00035 00036 if ( $this->mClass !== '' ) { 00037 $select->setAttribute( 'class', $this->mClass ); 00038 } 00039 00040 $select->addOptions( $this->getOptions() ); 00041 00042 return $select->getHTML(); 00043 } 00044 }