openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

TextComponent.class.php (1832B)


      1 <?php
      2 
      3 namespace template_engine\components\html\component_text;
      4 
      5 use template_engine\components\html\HtmlComponent;
      6 use template_engine\element\CMSElement;use template_engine\element\HtmlElement;
      7 use template_engine\element\Value;
      8 use template_engine\element\ValueExpression;
      9 
     10 class TextComponent extends HtmlComponent
     11 {
     12 	public $title;
     13 	public $type;
     14 	public $escape = true;
     15 	public $value;
     16 	public $label;
     17 
     18 	public function createElement()
     19 	{
     20 
     21 		switch( $this->type )
     22 		{
     23 			case 'none':
     24 			case 'raw':
     25 				$tag = '';
     26 				break;
     27 			case 'emphatic':
     28 				$tag = 'em';
     29 				break;
     30 			case 'italic':
     31 				$tag = 'em';
     32 				break;
     33 			case 'strong':
     34 				$tag = 'strong';
     35 				break;
     36 			case 'bold':
     37 				$tag = 'strong';
     38 				break;
     39 			case 'tt':
     40 				$tag = 'tt';
     41 				break;
     42 			case 'teletype':
     43 				$tag = 'tt';
     44 				break;
     45 			case 'preformatted':
     46 				$tag = 'pre';
     47 				break;
     48 			case 'code':
     49 				$tag = 'code';
     50 				break;
     51 			case 'small':
     52 				$tag = 'small';
     53 				break;
     54 			default:
     55 				$tag = 'span';
     56 		}
     57 
     58 		$text = new CMSElement($tag);
     59 
     60 		$text->setEscaping($this->escape);
     61 
     62 
     63         if	( $this->class)
     64 			$text->addStyleClass( $this->class);
     65 
     66        if	( $this->title )
     67             $text->addAttribute('title',$this->title);
     68 
     69         //if   ( $this->newline)
     70 		//    $functions[] = 'nl2br(@)';
     71 
     72 		
     73 		//if	( !empty($this->accesskey) )
     74 		//	$functions[] = "Text::accessKey('".$this->accesskey."',@)";
     75 
     76 		if	( $this->value )
     77 			$text->content( $this->value );
     78 
     79 
     80 		if   ( $this->label ) {
     81 			$span  = (new HtmlElement('span' ))->addStyleClass('form-input');
     82 			$label = (new HtmlElement('label'))->addChild($span)->addStyleClass('form-row')->addChild( (new CMSElement('span'))->addStyleClass('form-label')->content('${message:'.$this->label.'}'));
     83 
     84 			$this->adoptiveElement = $text;
     85 			return $label;
     86 
     87 		}else {
     88 			return $text;
     89 		}
     90 
     91 	}
     92 }
     93 
     94