TemplateEditAction.class.php (2438B)
1 <?php 2 namespace cms\action\template; 3 use cms\action\Method; 4 use cms\action\TemplateAction; 5 use cms\model\Element; 6 use cms\model\Project; 7 use cms\model\TemplateModel; 8 9 10 class TemplateEditAction extends TemplateAction implements Method { 11 public function view() { 12 // Elemente laden 13 $list = array(); 14 15 foreach( $this->template->getElementIds() as $elid ) 16 { 17 $element = new Element( $elid ); 18 $element->load(); 19 20 $list[$elid] = array(); 21 $list[$elid]['id' ] = $elid; 22 $list[$elid]['name' ] = $element->name; 23 $list[$elid]['description'] = $element->desc; 24 $list[$elid]['type' ] = $element->getTypeName(); 25 $list[$elid]['typeid' ] = $element->typeid; 26 27 unset( $element ); 28 } 29 $this->setTemplateVar('elements',$list); 30 31 32 $project = new Project( $this->template->projectid ); 33 34 35 $models = array(); 36 37 foreach( $project->getModels() as $modelId => $modelName ) 38 { 39 $templatemodel = new TemplateModel( $this->template->templateid, $modelId ); 40 $templatemodel->load(); 41 42 $text = $templatemodel->src; 43 44 foreach( $this->template->getElementIds() as $elid ) 45 { 46 $element = new Element( $elid ); 47 $element->load(); 48 49 // Fix old stuff: 50 $text = str_replace('{{'.$elid.'}}', 51 '{{'.$element->name.'}}', 52 $text ); 53 $text = str_replace('{{->'.$elid.'}}', 54 '{{goto.'.$element->name.'}}', 55 $text ); 56 $text = str_replace('{{IFEMPTY:'.$elid.':BEGIN}}', 57 '{{^'.$element->name.'}}', 58 $text ); 59 $text = str_replace('{{IFEMPTY:'.$elid.':END}}', 60 '{{/'.$element->name.'}}', 61 $text ); 62 $text = str_replace('{{IFNOTEMPTY:'.$elid.':BEGIN}}', 63 '{{#'.$element->name.'}}', 64 $text ); 65 $text = str_replace('{{IFNOTEMPTY:'.$elid.':END}}', 66 '{{/'.$element->name.'}}', 67 $text ); 68 } 69 70 $models[ $modelId ] = array( 71 'name' => $modelName, 72 'source' => $text, 73 'modelid' => $modelId 74 ); 75 } 76 77 $this->setTemplateVar( 'models',$models ); 78 79 80 } 81 public function post() { 82 } 83 }