openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ElementPropAction.class.php (1682B)


      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 }