openrat-cms

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

Input.class.php (2447B)


      1 <?php
      2 
      3 namespace template_engine\components;
      4 
      5 class InputComponent extends FieldComponent
      6 {
      7 	public $default;
      8 
      9 	public $type = 'text';
     10 
     11 	public $index;
     12 
     13 	public $name;
     14 
     15 	public $prefix;
     16 
     17 	public $value;
     18 
     19 	public $size;
     20 
     21 	public $maxlength = 256;
     22 
     23 	public $onchange;
     24 
     25 	public $hint;
     26 
     27 	public $icon;
     28 
     29 	public $required = false;
     30 
     31 	public $focus = false;
     32 
     33 	public $label;
     34 
     35 	public function begin()
     36 	{
     37 	    if   ( $this->label )
     38         {
     39             echo '<label class="or-form-row"><span class="or-form-label">'.'<?php echo lang('.$this->value($this->label).') ?>'.'</span><span class="or-form-input">';
     40         }
     41 
     42 		if(!$this->type == 'hidden')
     43 		{
     44 			// Verstecktes Feld.
     45 			$this->outputHiddenField();
     46 		}
     47 		else 
     48 		{
     49 			echo '<div class="inputholder">';
     50 			echo '<input';
     51 			if($this->readonly)
     52 				echo '<?php if ('.$this->value($this->readonly).') '."echo ' disabled=\"true\"' ?>";
     53 			if (!empty($this->hint))
     54 				echo ' placeholder="'.$this->htmlvalue($this->hint).'"';
     55 			
     56 			echo ' id="'.'<?php echo REQUEST_ID ?>_'.$this->htmlvalue($this->name).'"';
     57 			
     58 			// Output Attribute name="..."
     59             echo $this->outputNameAttribute();
     60 
     61             if($this->required)
     62                 echo ' required="required"';
     63             if($this->focus)
     64                 echo ' autofocus="autofocus"';
     65 
     66 
     67             echo ' type="'.$this->htmlvalue($this->type).'"';
     68 			echo ' maxlength="'.$this->htmlvalue($this->maxlength).'"';
     69 			echo ' class="'.$this->htmlvalue($this->class).'"';
     70 			
     71 			echo ' value="<?php echo Text::encodeHtml(';
     72 			if (isset($this->default))
     73 				echo $this->value($this->default);
     74 			else
     75 				echo '@$'.$this->varname($this->name);
     76 			echo ') ?>"';
     77 			
     78 			echo ' />';
     79 
     80 			if(isset($this->readonly))
     81 			{
     82 				echo '<?php if ('.$this->value($this->readonly).') { ?>';
     83 				$this->outputHiddenField();
     84 				echo '<?php } ?>';
     85 			}
     86 				
     87 				
     88 			if(isset($this->icon))
     89 				echo '<img src="'.OR_THEMES_DIR.'default/images/icon_'.$this->htmlvalue($this->icon). IMG_ICON_EXT .'" width="16" height="16" />';
     90 			
     91 			echo '</div>';
     92 		}
     93 
     94 
     95         if   ( $this->label )
     96         {
     97             echo '</span></label>';
     98         }
     99 	}
    100 
    101 	private function outputHiddenField()
    102 	{
    103 		echo '<input';
    104 		echo ' type="hidden"';
    105 		echo ' name="'.$this->htmlvalue($this->name).'"';
    106 
    107 		echo ' value="<?php ';
    108 
    109 		if(isset($this->default))
    110 			echo $this->value($this->default);
    111 		else
    112 			echo '$'.$this->varname($this->name);
    113 
    114 		echo ' ?>"';
    115 		echo '/>';
    116 
    117 	}
    118 }
    119 
    120 ?>