File modules/cms/action/folder/FolderCreatepageAction.class.php

Last commit: Mon Jun 13 22:03:01 2022 +0200	Jan Dankert	Fix: Show a nice validation notice if there is no template.
1 <?php 2 namespace cms\action\folder; 3 use cms\action\Action; 4 use cms\action\FolderAction; 5 use cms\action\Method; 6 use cms\model\BaseObject; 7 use cms\model\Page; 8 use cms\model\Permission; 9 use cms\model\Project; 10 use language\Messages; 11 use util\exception\ValidationException; 12 13 14 class FolderCreatepageAction extends FolderAction implements Method { 15 16 public function getRequiredPermission() { 17 return Permission::ACL_CREATE_PAGE; 18 } 19 20 21 22 public function view() { 23 $project = new Project( $this->folder->projectid ); 24 25 $all_templates = $project->getTemplates(); 26 $this->setTemplateVar('templates' ,$all_templates ); 27 $this->setTemplateVar('objectid' ,$this->folder->objectid ); 28 29 if ( count($all_templates) == 0 ) 30 $this->addWarningFor($this->folder,Messages::NO_TEMPLATES_AVAILABLE ); 31 } 32 33 34 public function post() { 35 $name = $this->request->getText('name' ); 36 $filename = $this->request->getText('filename' ); 37 $description = $this->request->getText('description'); 38 39 $page = new Page(); 40 $page->filename = BaseObject::urlify( $name ); 41 $page->templateid = $this->request->getRequiredNumber('templateid'); 42 43 $page->parentid = $this->folder->objectid; 44 $page->projectid = $this->folder->projectid; 45 46 47 $page->persist(); 48 $page->setNameForAllLanguages( $name,$description ); 49 50 $this->addNoticeFor( $page, Messages::ADDED ); 51 $this->setTemplateVar('objectid',$page->objectid); 52 53 $this->folder->setTimestamp(); 54 } 55 }
Download modules/cms/action/folder/FolderCreatepageAction.class.php
History Mon, 13 Jun 2022 22:03:01 +0200 Jan Dankert Fix: Show a nice validation notice if there is no template. Sat, 6 Mar 2021 03:42:38 +0100 Jan Dankert New: Better permission checks. 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.