From d3b22c724dfdf275f7feb981182d54a18310bcc0 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Mon, 7 Mar 2011 17:53:57 +0100 Subject: BootMenuEntries fertig --- application/controllers/BootmenuController.php | 64 ++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 1dfa641..dba15a7 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -11,11 +11,18 @@ class BootmenuController extends Zend_Controller_Action public function indexAction() { $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentries = array(); $this->view->bootmenulist = $bootmenumapper->fetchAll(); + foreach ($this->view->bootmenulist as $bootmenu){ + $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->find($bootmenu->getID()); + } + $this->view->bootmenuentrylist = $bootmenuentries; } public function addbootmenuentryAction() { + $bootmenuID = $this->_request->getParam('bootmenuID'); if (!isset($_POST["addbootmenuentry"])){ $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(); } else { @@ -25,6 +32,7 @@ class BootmenuController extends Zend_Controller_Action if ($addbootmenuentryForm->isValid($_POST)) { $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentry->setBootmenuID($bootmenuID); $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); try { @@ -119,18 +127,67 @@ class BootmenuController extends Zend_Controller_Action public function editbootmenuentryAction() { - // action body + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + $bootmenuID = $this->_request->getParam('bootmenuID'); + + if (!isset($_POST["editbootmenuentry"])){ + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ + $this->_redirect('/bootmenu'); + } else { + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); + + $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(); + $editbootmenuentryForm->populate($bootmenuentry->toArray()); + } + }else{ + $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit($_POST); + + if ($editbootmenuentryForm->isValid($_POST)) { + + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentry->setBootmenuID($bootmenuID); + $bootmenuentry->setID($bootmenuentryID); + + $bootmenumapper = new Application_Model_BootMenuEntriesMapper(); + + try { + $bootmenuentrymapper->save($bootmenuentry); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + } + + $this->_redirect('/bootmenu'); + } + + } + + $this->view->editbootmenuentryForm = $editbootmenuentryForm; + } public function removebootmenuentryAction() { - // action body + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ + $this->_redirect('/bootmenu'); + } else { + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentry->setID($bootmenuentryID); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentrymapper->delete($bootmenuentry); + } + $this->_redirect('/bootmenu'); } public function deletebootmenuAction() { $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!isset($bootmenuID)){ + if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ $this->_redirect('/bootmenu'); } else { $bootmenu = new Application_Model_BootMenu(); @@ -139,7 +196,6 @@ class BootmenuController extends Zend_Controller_Action $bootmenumapper->delete($bootmenu); } $this->_redirect('/bootmenu'); - // action body } -- cgit v1.2.3-55-g7522