@@ -376,132 +376,3 @@ public function generate_data($key, array &$attr){
376376 return array ($ id , $ name , $ value );
377377 }
378378}
379-
380- class TextAreaField extends FormInput {
381- private $ value = '' ;
382-
383- public function __construct ($ key , $ id , $ name , $ value , $ label , $ attr ) {
384- parent ::__construct ($ key , $ id , $ name , null , null , $ label , $ attr );
385- $ this ->value = $ value ;
386- }
387-
388- public function get_content (array $ extra_attr = array ()){
389- $ attr = array_merge_recursive ($ extra_attr , $ this ->attr );
390- $ value = htmlspecialchars ($ this ->value );
391- return "<textarea " . $ this ->serialize_attr ($ attr ) . " > {$ value }</textarea> " ;
392- }
393- }
394-
395- class StaticField extends FormInput {
396- protected $ text = null ;
397-
398- public function __construct ($ text , $ label , $ attr ){
399- parent ::__construct (false , false , false , null , null , $ label , $ attr );
400- $ this ->text = $ text ;
401- }
402-
403- public function render ($ layout , $ res ) {
404- $ layout ->render_static ($ this );
405- }
406-
407- public function get_content (array $ extra_attr = array ()){
408- $ attr = array_merge_recursive ($ extra_attr , $ this ->attr );
409- $ this ->pop_attr ('icon ' , $ attr , $ icon ); /* layout reads icon data, puts html back into attr */
410- return $ icon . $ this ->text ;
411- }
412-
413- public function get_hint (){ return false ; }
414- public function get_label (){ return $ this ->label ; }
415- public function layout_hints (){ return 0 ; }
416- public function get_id () { return false ; }
417- }
418-
419- class LinkField extends StaticField {
420- protected $ href = null ;
421-
422- public function __construct ($ label , $ attr ){
423- $ this ->pop_attr ('text ' , $ attr , $ text );
424- parent ::__construct ($ text , $ label , $ attr );
425- }
426-
427- public function render ($ layout , $ res ) {
428- $ layout ->render_static ($ this );
429- }
430-
431- public function get_content (array $ extra_attr = array ()){
432- $ attr = array_merge_recursive ($ extra_attr , $ this ->attr );
433- $ this ->pop_attr ('icon ' , $ attr , $ icon ); /* layout reads icon data, puts html back into attr */
434- return "<a " . $ this ->serialize_attr ($ attr ) . "> $ icon {$ this ->text }</a> " ;
435- }
436-
437- public function get_hint (){ return false ; }
438- public function get_label (){ return $ this ->label ; }
439- public function layout_hints (){ return 0 ; }
440- public function get_id () { return false ; }
441- }
442-
443- class HintField implements FormField {
444- private $ text = null ;
445- private $ label = null ;
446- private $ attr = array ('class ' => 'form-hint ' );
447- protected $ container = null ;
448-
449- public function __construct ($ text , $ label , $ attr ){
450- $ this ->text = $ text ;
451- $ this ->label = $ label ;
452- $ this ->attr = array_merge ($ this ->attr , $ attr );
453- }
454-
455- public function render ($ layout , $ res ) {
456- $ layout ->render_hint ($ this );
457- }
458-
459- public function get_hint (){ return false ; }
460- public function get_content (){ return $ this ->text ; }
461- public function get_label (){ return $ this ->label ; }
462- public function layout_hints (){ return 0 ; }
463- public function get_id () { return false ; }
464- public function set_container ($ container ){ $ this ->container = $ container ; }
465- public function get_container (){ return $ this ->container ; }
466-
467- public function attribute ($ key , $ default =false ){
468- return array_key_exists ($ key , $ this ->attr ) ? $ this ->attr [$ key ] : $ default ;
469- }
470- }
471-
472- class ManualField implements FormField {
473- private $ key = null ;
474- private $ label = null ;
475- private $ content = null ;
476- private $ hint = null ;
477- protected $ container = null ;
478-
479- public function __construct ($ key , $ label , $ content , $ hint ){
480- $ this ->key = $ key ;
481- $ this ->label = $ label ;
482- $ this ->content = $ content ;
483- $ this ->hint = $ hint ;
484- }
485-
486- public function render ($ layout , $ res ) {
487- $ layout ->render_field ($ this , $ this ->get_error ($ res ));
488- }
489-
490- public function get_error ($ res ){
491- if ( !($ this ->key && isset ($ res ->errors [$ this ->key ])) ) return false ;
492- return ucfirst ($ res ->errors [$ this ->key ][0 ]); /* get first error only */
493- }
494-
495- public function get_name (){ return $ this ->key ; }
496- public function get_label (){ return $ this ->label ; }
497- public function get_content (){ return $ this ->content ; }
498- public function get_hint (){ return $ this ->hint ; }
499- public function layout_hints (){ return 0 ; }
500- public function get_id () { return false ; }
501- public function set_container ($ container ){ $ this ->container = $ container ; }
502- public function get_container (){ return $ this ->container ; }
503-
504- public function attribute ($ key , $ default =false ){
505- return $ default ; /* no sane way to get attributes from manual fields */
506- }
507- }
0 commit comments