HTMLJsSelectToInputField.php

Go to the documentation of this file.
00001 <?php
00013 class HTMLJsSelectToInputField extends HTMLTextField {
00018     function getInputHTML( $value ) {
00019         $input = parent::getInputHTML( $value );
00020 
00021         if ( isset( $this->mParams['select'] ) ) {
00025             $select = $this->mParams['select'];
00026             $input = $select->getHtmlAndPrepareJs() . '<br />' . $input;
00027         }
00028 
00029         return $input;
00030     }
00031 
00036     function tidy( $value ) {
00037         $value = array_map( 'trim', explode( ',', $value ) );
00038         $value = array_unique( array_filter( $value ) );
00039 
00040         return $value;
00041     }
00042 
00048     function validate( $value, $alldata ) {
00049         $p = parent::validate( $value, $alldata );
00050 
00051         if ( $p !== true ) {
00052             return $p;
00053         }
00054 
00055         if ( !isset( $this->mParams['valid-values'] ) ) {
00056             return true;
00057         }
00058 
00059         if ( $value === 'default' ) {
00060             return true;
00061         }
00062 
00063         $codes = $this->tidy( $value );
00064         $valid = array_flip( $this->mParams['valid-values'] );
00065 
00066         foreach ( $codes as $code ) {
00067             if ( !isset( $valid[$code] ) ) {
00068                 return wfMessage( 'translate-pref-editassistlang-bad', $code )->parseAsBlock();
00069             }
00070         }
00071 
00072         return true;
00073     }
00074 
00080     function filter( $value, $alldata ) {
00081         $value = parent::filter( $value, $alldata );
00082 
00083         return implode( ', ', $this->tidy( $value ) );
00084     }
00085 }
Generated on Tue Oct 29 00:00:25 2013 for MediaWiki Translate Extension by  doxygen 1.6.3