openrat-cms

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

Text.class.php (1764B)


      1 <?php
      2 
      3 namespace template_engine\components;
      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 			default:
     52 				$tag = 'span';
     53 		}
     54 
     55 		$text = new CMSElement($tag);
     56 
     57 		$text->setEscaping($this->escape);
     58 
     59 
     60         if	( $this->class)
     61 			$text->addStyleClass( $this->class);
     62 
     63        if	( $this->title )
     64             $text->addAttribute('title',$this->title);
     65 
     66         //if   ( $this->newline)
     67 		//    $functions[] = 'nl2br(@)';
     68 
     69 		
     70 		//if	( !empty($this->accesskey) )
     71 		//	$functions[] = "Text::accessKey('".$this->accesskey."',@)";
     72 
     73 		if	( $this->value )
     74 			$text->content( $this->value );
     75 
     76 
     77 		if   ( $this->label ) {
     78 			$span  = (new HtmlElement('span' ))->addStyleClass('form-input');
     79 			$label = (new HtmlElement('label'))->addChild($span)->addStyleClass('form-row')->addChild( (new CMSElement('span'))->addStyleClass('form-label')->content('${message:'.$this->label.'}'));
     80 
     81 			$this->adoptiveElement = $text;
     82 			return $label;
     83 
     84 		}else {
     85 			return $text;
     86 		}
     87 
     88 	}
     89 }
     90 
     91