File modules/cms/action/template/TemplatePubAction.class.php
Last commit: Fri Mar 11 12:26:33 2022 +0100 dankert Fix: Catch error if something happens while publishing.
1 <?php 2 namespace cms\action\template; 3 use cms\action\Method; 4 use cms\action\TemplateAction; 5 use cms\generator\PageContext; 6 use cms\generator\PageGenerator; 7 use cms\generator\Producer; 8 use cms\generator\Publisher; 9 use cms\generator\PublishOrder; 10 use cms\model\Permission; 11 use cms\model\Page; 12 use cms\model\Project; 13 use language\Messages; 14 use util\exception\PublisherException; 15 use util\Session; 16 17 18 class TemplatePubAction extends TemplateAction implements Method { 19 public function view() { 20 21 } 22 public function post() { 23 24 $project = Project::create( $this->template->projectid ); 25 26 $languageIds = $project->getLanguageIds(); 27 $modelIds = $project->getModelIds(); 28 29 $objectIds = $this->template->getDependentObjectIds(); 30 31 Session::close(); 32 33 $publisher = new Publisher( $this->template->projectid ); 34 35 foreach( $objectIds as $pageId ) { 36 37 $page = new Page( $pageId ); 38 $page->load(); 39 $page->setPublishedTimestamp(); 40 41 foreach( $modelIds as $modelId ) { 42 foreach( $languageIds as $languageId ) { 43 $pageContext = new PageContext( $pageId, Producer::SCHEME_PUBLIC ); 44 $pageContext->modelId = $modelId; 45 $pageContext->languageId = $languageId; 46 47 $pageGenerator = new PageGenerator( $pageContext ); 48 49 $publisher->addOrderForPublishing( new PublishOrder( $pageGenerator->getCache()->load()->getFilename(),$pageGenerator->getPublicFilename(), $page->lastchangeDate ) ); 50 } 51 } 52 } 53 54 try { 55 $publisher->publish(); 56 57 $this->addNoticeFor( $this->template,Messages::PUBLISHED,[], 58 implode("\n",$publisher->getDestinationFilenames() ) ); 59 } catch( PublisherException $e ) { 60 $this->addErrorFor( $this->template,Messages::PUBLISHED_ERROR,[],$e->getMessage() ); 61 } 62 } 63 }
Downloadmodules/cms/action/template/TemplatePubAction.class.php
History Fri, 11 Mar 2022 12:26:33 +0100 dankert Fix: Catch error if something happens while publishing. Sat, 27 Feb 2021 00:29:39 +0100 Jan Dankert New: Set publishing date on publishing. Sat, 20 Feb 2021 00:49:37 +0100 Jan Dankert Cleanup of templates. Mon, 4 Jan 2021 19:03:18 +0100 Jan Dankert Refactoring: ACL class is renamed to Permission, because most RBAC/DMAC concepts are calling it a permission. Thu, 19 Nov 2020 14:49:58 +0100 Jan Dankert Fix: Action::addNotice() is replaced by Action::addNoticeFor() Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.