openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

Checkbox.class.php (1268B)


      1 <?php
      2 
      3 namespace template_engine\components;
      4 
      5 class CheckboxComponent extends Component
      6 {
      7 	
      8 	public $default = false;
      9 	public $name;
     10 	public $readonly = false;
     11 	public $required = false;
     12 	public $label;
     13 
     14 	protected function begin(){
     15 
     16         if   ( $this->label )
     17             echo '<label class="or-form-row"><span class="or-form-label"></span><span class="or-form-input">';
     18 
     19 
     20         echo '<?php { ';
     21 		echo '$tmpname     = '.$this->value($this->name).';';
     22 		echo '$default  = '.$this->value($this->default).';';
     23 		echo '$readonly = '.$this->value($this->readonly).';';
     24 		echo '$required = '.$this->value($this->required).';';
     25 
     26 		echo <<<'HTML'
     27 		
     28 		if	( isset($$tmpname) )
     29 			$checked = $$tmpname;
     30 		else
     31 			$checked = $default;
     32 
     33 		?><input class="checkbox" type="checkbox" id="<?php echo REQUEST_ID ?>_<?php echo $tmpname ?>" name="<?php echo $tmpname  ?>"  <?php if ($readonly) echo ' disabled="disabled"' ?> value="1"<?php if( $checked ) echo ' checked="checked"' ?><?php if( $required ) echo ' required="required"' ?> /><?php
     34 
     35 		if ( $readonly && $checked )
     36 		{ 
     37 		?><input type="hidden" name="<?php echo $tmpname ?>" value="1" /><?php
     38 		}
     39 		} ?>
     40 HTML;
     41 
     42         if   ( $this->label )
     43             echo '&nbsp;'.lang($this->label).' </span></label>';
     44 
     45     }
     46 }
     47 
     48 
     49 ?>