File modules/cms/action/file/FileAdvancedAction.class.php
Last commit: Sun Jan 29 00:20:21 2023 +0100 Jan Dankert New node type "Script".
1 <?php 2 namespace cms\action\file; 3 use cms\action\FileAction; 4 use cms\action\Method; 5 use cms\action\RequestParams; 6 use cms\generator\FileContext; 7 use cms\generator\FileGenerator; 8 use cms\model\BaseObject; 9 use cms\model\Permission; 10 use language\Messages; 11 use util\exception\ValidationException; 12 13 14 class FileAdvancedAction extends FileAction implements Method { 15 16 17 public function view() { 18 // Eigenschaften der Datei uebertragen 19 $this->setTemplateVar( 'extension',$this->file->extension ); 20 $this->setTemplateVar( 'mimetype' ,$this->getMimeType() ); 21 22 $this->setTemplateVar( 'type' ,$this->file->type ); 23 $this->setTemplateVar( 'types' ,[ 24 BaseObject::TYPEID_FILE => \cms\base\Language::lang('file' ), 25 BaseObject::TYPEID_IMAGE => \cms\base\Language::lang('image' ), 26 BaseObject::TYPEID_TEXT => \cms\base\Language::lang('text' ), 27 BaseObject::TYPEID_SCRIPT=> \cms\base\Language::lang('script') 28 ] ); 29 } 30 31 32 public function post() { 33 34 $this->file->extension = $this->request->getFilename('extension'); 35 36 $typeid = $this->request->getNumber('type' ); 37 38 if ( ! in_array($typeid,[BaseObject::TYPEID_FILE,BaseObject::TYPEID_IMAGE,BaseObject::TYPEID_TEXT])) 39 throw new ValidationException('type'); 40 41 $this->file->typeid = $typeid; 42 $this->file->updateType(); 43 $this->file->save(); 44 45 $this->addNoticeFor( $this->file, Messages::PROP_SAVED); 46 } 47 48 49 public function getRequiredPermission() 50 { 51 return Permission::ACL_PROP; 52 } 53 }
Downloadmodules/cms/action/file/FileAdvancedAction.class.php
History Sun, 29 Jan 2023 00:20:21 +0100 Jan Dankert New node type "Script". Fri, 3 Dec 2021 23:36:56 +0100 dankert Some security enhancements. Wed, 10 Mar 2021 23:51:22 +0100 Jan Dankert Refactoring: Cleaned the Request params. Thu, 4 Mar 2021 03:39:25 +0100 Jan Dankert New: Separate edit action for images and texts. 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() Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.