openrat-cms

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

Editor.class.php (1840B)


      1 <?php
      2 
      3 namespace template_engine\components;
      4 
      5 class EditorComponent extends FieldComponent
      6 {
      7 	public $type;
      8 	public $name;
      9 	public $mode='htmlmixed';
     10 	public $extension='';
     11 	public $mimetype = '';
     12 
     13 	protected function begin()
     14 	{
     15 		switch( $this->type )
     16 		{
     17 			case 'html':
     18 				echo '<textarea '.$this->outputNameAttribute().' class="editor html-editor" id="pageelement_edit_editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>';
     19 
     20 				break;
     21 
     22 			case 'wiki':
     23 				echo '<textarea '.$this->outputNameAttribute().' class="editor wiki-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>';
     24 				break;
     25 
     26 			case 'text':
     27 			case 'raw':
     28 				echo '<textarea '.$this->outputNameAttribute().' class="editor text-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>';
     29 				break;
     30 
     31 			case 'markdown':
     32 				echo '<textarea '.$this->outputNameAttribute().' class="editor markdown-editor"><?php echo htmlentities(${'.$this->value($this->name).'}) ?></textarea>';
     33 		        break;
     34 	            
     35 			case 'code':
     36 				echo '<textarea '.$this->outputNameAttribute().' data-extension="'.$this->htmlvalue($this->extension).'" data-mimetype="'.$this->htmlvalue($this->mimetype).'" data-mode="'.$this->htmlvalue($this->mode).'" class="editor code-editor"><?php echo htmlentities(${'.$this->value($this->name).'}) ?></textarea>';
     37 		        break;
     38 
     39 
     40 			case 'dom':
     41 			case 'tree':
     42 				echo '<?php ';
     43 		        echo '$doc = new DocumentElement();';
     44 		        echo '$tmp_text = '.$this->textasvarname($this->name).';';
     45 		        echo 'if( !is_array($tmp_text))$tmp_text = explode("\n",$tmp_text);';
     46 		        echo '$doc->parse($tmp_text);';
     47 		        echo 'echo $doc->render(\'application/html-dom\');';
     48 		        echo '?>';
     49 				break;
     50 		
     51 			default:
     52 				throw new \LogicException("Unknown editor type: ".$this->type);
     53 		}
     54 	}
     55 }
     56 
     57 
     58 ?>