/**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendGalleriaModel::existsCategory($this->id)) {
         parent::execute();
         // is this category allowed to be deleted?
         if (!BackendGalleriaModel::deleteCategoryAllowed($this->id)) {
             $this->redirect(BackendModel::createURLForAction('categories') . '&error=category-not-deletable');
         } else {
             // get category
             $this->record = BackendGalleriaModel::getCategoryFromId($this->id);
             // delete category
             BackendGalleriaModel::deleteCategoryById($this->id);
             BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id));
             $this->redirect(BackendModel::createURLForAction('categories') . '&report=category-deleted&var=' . urlencode($this->record['title']));
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing');
     }
 }
Ejemplo n.º 2
0
 /**
  * Execute the action
  *
  * @return void
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exists?
     if ($this->id !== null && BackendGalleriaModel::existsCategory($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // get all data for the item we want to edit
         $this->getData();
         // load the form
         $this->loadForm();
         // validate the form
         $this->validateForm();
         // parse the form
         $this->parse();
         // display the page
         $this->display();
     } else {
         $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing');
     }
 }