File modules/cms/action/page/PagePubAction.class.php

Last commit: Wed Oct 14 01:41:42 2026 +0200	Jan Dankert	Saving values with the new object-oriented ui objects.
1 <?php 2 namespace cms\action\page; 3 use cms\action\Method; 4 use cms\action\PageAction; 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\Page; 11 use cms\model\Permission; 12 use cms\model\Template; 13 use language\Messages; 14 use util\exception\PublisherException; 15 use util\Session; 16 17 class PagePubAction extends PageAction implements Method { 18 19 public function getRequiredPermission(): int 20 { 21 return Permission::ACL_PUBLISH; 22 } 23 24 public function view() { 25 26 } 27 public function post() { 28 29 $project = $this->page->getProject(); 30 31 $template = new Template( $this->page->templateid ); 32 $template->load(); 33 34 if ( ! $template->publish ) { 35 $this->addWarningFor( $this->page,Messages::NOPUBLISH ); 36 return; 37 } 38 39 // Nothing is written to the session from this point. so we should free the session. 40 Session::close(); 41 42 $publisher = new Publisher( $project->projectid ); 43 44 foreach( $project->getModelIds() as $modelId ) { 45 46 foreach( $project->getLanguageIds() as $languageId ) { 47 48 $pageContext = new PageContext( $this->page->objectid, Producer::SCHEME_PUBLIC ); 49 $pageContext->modelId = $modelId; 50 $pageContext->languageId = $languageId; 51 52 $pageGenerator = new PageGenerator( $pageContext ); 53 54 $publisher->addOrderForPublishing( new PublishOrder( $pageGenerator->getCache()->load()->getFilename(),$pageGenerator->getPublicFilename(), $this->page->lastchangeDate ) ); 55 } 56 } 57 58 try { 59 $publisher->publish(); 60 $this->page->setPublishedTimestamp(); 61 62 $this->addNoticeFor( $this->page, 63 'PUBLISHED', 64 array(), 65 implode("\n",$publisher->getDestinationFilenames() ) 66 ); 67 } catch( PublisherException $e ) { 68 $this->addErrorFor( $this->page,Messages::PUBLISHED_ERROR,[],$e->getMessage() ); 69 } 70 } 71 }
Download modules/cms/action/page/PagePubAction.class.php
History Wed, 14 Oct 2026 01:41:42 +0200 Jan Dankert Saving values with the new object-oriented ui objects. Fri, 11 Mar 2022 12:26:33 +0100 dankert Fix: Catch error if something happens while publishing. Sat, 6 Mar 2021 03:42:38 +0100 Jan Dankert New: Better permission checks. Sat, 27 Feb 2021 02:40:09 +0100 Jan Dankert Fix: Use the sourceObjectId from the pageContext for links. Sat, 27 Feb 2021 00:29:39 +0100 Jan Dankert New: Set publishing date on publishing. Sat, 20 Feb 2021 01:34:41 +0100 Jan Dankert New: Publish-switch for 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. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.