File modules/cms/action/element/ElementPropAction.class.php
Last commit: Wed Mar 10 23:51:22 2021 +0100 Jan Dankert Refactoring: Cleaned the Request params.
1 <?php 2 namespace cms\action\element; 3 use cms\action\Action; 4 use cms\action\ElementAction; 5 use cms\action\Method; 6 use cms\action\RequestParams; 7 use cms\model\Element; 8 use language\Messages; 9 10 11 class ElementPropAction extends ElementAction implements Method { 12 public function view() { 13 // Name und Beschreibung 14 $this->setTemplateVar('name' ,$this->element->name); 15 $this->setTemplateVar('label' ,$this->element->label); 16 17 $this->setTemplateVar('description',$this->element->desc); 18 19 // Die verschiedenen Element-Typen 20 $types = array(); 21 22 foreach( Element::getAvailableTypes() as $typeId=>$typeKey ) 23 $types[ $typeId ] = 'EL_'.$typeKey; 24 25 // Code-Element nur fuer Administratoren (da voller Systemzugriff!) 26 if ( !$this->userIsAdmin() ) 27 unset( $types['code'] ); 28 29 // Liste aller Elementtypen 30 $this->setTemplateVar('types',$types); 31 32 // Aktueller Typ 33 $this->setTemplateVar('typeid',$this->element->typeid); 34 } 35 36 37 public function post() { 38 if ( !$this->userIsAdmin() && $this->request->getText('type') == 'code' ) 39 // Code-Elemente fuer Nicht-Administratoren nicht benutzbar 40 throw new \util\exception\ValidationException('type'); 41 42 $this->element->typeid = $this->request->getNumber('typeid'); 43 44 $this->element->name = $this->request->getAlphanum('name' ); 45 $this->element->label= $this->request->getText('label' ); 46 $this->element->desc = $this->request->getText('description'); 47 48 $this->element->save(); 49 50 $this->addNoticeFor( $this->element, Messages::SAVED); 51 } 52 }
Downloadmodules/cms/action/element/ElementPropAction.class.php
History Wed, 10 Mar 2021 23:51:22 +0100 Jan Dankert Refactoring: Cleaned the Request params. 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.