File modules/cms/action/template/TemplateSrcAction.class.php
Last commit: Sat Jan 28 19:10:47 2023 +0100 Jan Dankert New: Templates may be rendered as Mustache, Script and Script template.
1 <?php 2 namespace cms\action\template; 3 use cms\action\Action; 4 use cms\action\Method; 5 use cms\action\RequestParams; 6 use cms\action\TemplateAction; 7 use cms\model\Element; 8 use cms\model\Project; 9 use cms\model\TemplateModel; 10 use language\Messages; 11 12 13 class TemplateSrcAction extends TemplateAction implements Method { 14 public function view() { 15 $modelId = $this->request->getModelId(); 16 17 $templateModel = new TemplateModel( $this->template->templateid, $modelId ); 18 $templateModel->load(); 19 20 $this->setTemplateVar( 'modelid' ,$modelId ); 21 $this->setTemplateVar( 'source' ,$templateModel->getSource() ); 22 $this->setTemplateVar( 'extension',$templateModel->extension ); 23 $this->setTemplateVar( 'format' ,$templateModel->getFormat() ); 24 } 25 26 27 /** 28 * Saving template source. 29 */ 30 public function post() { 31 $modelId = $this->request->getModelId(); 32 33 $templatemodel = new TemplateModel($this->template->templateid, $modelId); 34 $templatemodel->load(); 35 36 $newSource = $this->request->getRaw('source'); 37 38 $templatemodel->src = $newSource; 39 $templatemodel->extension = $this->request->getText('extension'); 40 $templatemodel->public = $this->request->isTrue('release'); 41 $templatemodel->format = $this->request->getNumber('format'); 42 $templatemodel->persist(); 43 44 $this->addNoticeFor($this->template,Messages::SAVED); 45 } 46 }
Downloadmodules/cms/action/template/TemplateSrcAction.class.php
History Sat, 28 Jan 2023 19:10:47 +0100 Jan Dankert New: Templates may be rendered as Mustache, Script and Script template. Sat, 27 Nov 2021 04:38:28 +0100 Jan Dankert New: Option to explicitly release a new template source. Tue, 9 Nov 2021 23:52:56 +0100 Jan Dankert Some fixes for reading content from the new content table. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Thu, 19 Nov 2020 14:49:58 +0100 Jan Dankert Fix: Action::addNotice() is replaced by Action::addNoticeFor() Wed, 18 Nov 2020 01:46:36 +0100 Jan Dankert Refactoring of model classes: New method persist() and some other cleanups. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.