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

Last commit: Sat Mar 6 03:42:38 2021 +0100	Jan Dankert	New: Better permission checks.
1 <?php 2 namespace cms\action\page; 3 use cms\action\Method; 4 use cms\action\object\ObjectInfoAction; 5 use cms\action\object\ObjectNameAction; 6 use cms\action\PageAction; 7 use cms\model\BaseObject; 8 use cms\model\Permission; 9 use cms\model\Project; 10 use language\Messages; 11 12 class PageNameAction extends PageAction implements Method { 13 14 public function getRequiredPermission() { 15 return Permission::ACL_WRITE; 16 } 17 18 19 public function view() { 20 21 $languageId = $this->request->getText('languageid'); 22 23 $name = $this->page->getNameForLanguage($languageId); 24 25 $this->setTemplateVars( $name->getProperties() ); 26 27 $alias = $this->page->getAliasForLanguage( $languageId ); 28 29 $this->setTemplateVar( 'alias_filename', $alias->filename ); 30 $this->setTemplateVar( 'alias_folderid', $alias->parentid ); 31 32 $project = Project::create( $this->page->projectid ); 33 $this->setTemplateVar( 'folders' , $project->getAllFlatFolders() ); 34 } 35 36 37 public function post() { 38 39 $parentAction = new ObjectNameAction(); 40 $parentAction->request = $this->request; 41 $parentAction->init(); 42 $parentAction->post(); // Save name and description 43 44 $alias = $this->page->getAliasForLanguage( $this->request->getLanguageId() ); 45 46 $alias->filename = BaseObject::urlify( $this->request->getText( 'alias_filename') ); 47 $alias->parentid = $this->request->getNumber('alias_folderid'); 48 49 // If no alias, remove the alias 50 if ( ! $alias->filename ) { 51 52 $alias->delete(); 53 $this->addNoticeFor( $alias,Messages::DELETED); 54 } 55 else 56 { 57 $alias->persist(); 58 $this->addNoticeFor( $alias,Messages::SAVED); 59 } 60 61 } 62 }
Download modules/cms/action/page/PageNameAction.class.php
History 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.