コード例 #1
0
 public function deletemodule($parameters = array())
 {
     $view = new ui($this);
     $flash = new popupController();
     $model = new processedmoduleModel();
     $modules = $model->getfromId($parameters['moduleid']);
     if (count($modules) == 1) {
         $module = $modules[0];
         $linkmodel = new modulepageModel();
         $links = $linkmodel->getfromModuleid($parameters['moduleid']);
         $pages = array();
         if (count($links) > 0) {
             $all = false;
             foreach ($links as $link) {
                 $pageids[] = $link->getPageid();
                 if ($link->getPageid() == -1) {
                     $all = true;
                 }
             }
             $pagemodel = new pageModel();
             $pages = $pagemodel->get(array('id' => array('mode' => 'IN', 'value' => $pageids)));
             if ($all) {
                 $newpage = new pageObject();
                 $newpage->setId(-1);
                 $newpage->setTitle('Alle pagina\'s');
                 array_unshift($pages, $newpage);
             }
         }
         if ($parameters['sure'] == 'sure') {
             try {
                 $linkmodel->deletebyModuleid($parameters['moduleid']);
                 $model->delete($module);
             } catch (Exception $e) {
                 $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De module werd niet goed verwijderd!'));
                 return false;
             }
             $flash->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De module werd goed verwijderd.'));
             $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', '');
             return true;
         } else {
             $view->assign('module', $module);
             $view->assign('pages', $pages);
             return $view->fetch('mymoduleadmin_deletemodule.tpl');
         }
     } else {
         $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De module werd niet gevonden!'));
         return false;
     }
 }
コード例 #2
0
 public function addpage($parameters = array())
 {
     $view = new ui($this);
     $form = new mygridform($parameters, $parameters['-gridid-'], 'edit');
     $form->addField(new hiddenField('parentid', $parameters['parentid']));
     $form->addField(new textField('title', 'Titel', '', array('required')));
     if ($form->validate()) {
         $pagemodel = new pageModel();
         $newpage = new pageObject();
         $newpage->setTemplate('page.tpl');
         $newpage->setParentid($parameters['parentid']);
         $newpage->setTitle($parameters['title']);
         $newpage->setOrder($pagemodel->getmax('order', array('parentid' => array('mode' => '=', 'value' => $parameters['parentid']))) + 1);
         $flash = new popupController();
         try {
             $pagemodel->save($newpage);
         } catch (Exception $e) {
             $flash->createflash(array('name' => 'err', 'type' => 'error', 'content' => 'De gegevens zijn niet goed bewaard! Raadpleeg de informaticadienst.'));
             return false;
         }
         $flash->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De gegevens zijn goed bewaard.'));
         $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', '');
         return true;
     } elseif (!$form->isSent()) {
         $view->assign('form', $form);
         return $view->fetch('mypageadmin_addpage.tpl');
     }
 }