diff options
| author | michael pereira | 2011-03-06 20:12:36 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-06 20:12:36 +0100 |
| commit | 0e017ebdc1edbbf230f0f0160f103c39ef675725 (patch) | |
| tree | e7848e531d30a01145f2f98d8a3189ea6699c54d /application/controllers/BootmenuController.php | |
| parent | Config fertig (diff) | |
| download | pbs2-0e017ebdc1edbbf230f0f0160f103c39ef675725.tar.gz pbs2-0e017ebdc1edbbf230f0f0160f103c39ef675725.tar.xz pbs2-0e017ebdc1edbbf230f0f0160f103c39ef675725.zip | |
datenbank erweitert, BootMenu, Config fertig
Diffstat (limited to 'application/controllers/BootmenuController.php')
| -rw-r--r-- | application/controllers/BootmenuController.php | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 20f471e..e20ef23 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -5,12 +5,13 @@ class BootmenuController extends Zend_Controller_Action public function init() { - /* Initialize action controller here */ - } + $db = Zend_Db_Table::getDefaultAdapter(); + } public function indexAction() { - // action body + $bootmenumapper = new Application_Model_BootMenuMapper(); + $this->view->bootmenulist = $bootmenumapper->fetchAll(); } public function addbootmenuentryAction() @@ -20,12 +21,76 @@ class BootmenuController extends Zend_Controller_Action public function createbootmenuAction() { - // action body + if (!isset($_POST["createbootmenu"])){ + $createbootmenuForm = new Application_Form_BootmenuCreate(); + } else { + + $createbootmenuForm = new Application_Form_BootmenuCreate($_POST); + + if ($createbootmenuForm->isValid($_POST)) { + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setMembershipID('1'); + $bootmenu->setCreated(time()); + $bootmenumapper = new Application_Model_BootMenuMapper(); + + try { + $bootmenumapper->save($bootmenu); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/bootmenu'); + } + } + + $this->view->createbootmenuForm = $createbootmenuForm; } public function editbootmenuAction() { - // action body + $bootmenuID = $this->_request->getParam('bootmenuID'); + + if (!isset($_POST["editbootmenu"])){ + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ + $this->_redirect('/bootmenu'); + } else { + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $editbootmenuForm = new Application_Form_BootmenuEdit(); + $editbootmenuForm->populate($bootmenu->toArray()); + } + }else{ + $editbootmenuForm = new Application_Form_BootmenuEdit($_POST); + + if ($editbootmenuForm->isValid($_POST)) { + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setMembershipID('1'); + $bootmenu->setCreated(time()); + $bootmenumapper = new Application_Model_BootMenuMapper(); + + $bootmenu->setID($bootmenuID); + + try { + $bootmenumapper->save($bootmenu); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/bootmenu'); + } + + } + + $this->view->editbootmenuForm = $editbootmenuForm; } public function editbootmenuentryAction() @@ -40,6 +105,16 @@ class BootmenuController extends Zend_Controller_Action public function deletebootmenuAction() { + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!isset($bootmenuID)){ + $this->_redirect('/bootmenu'); + } else { + $bootmenu = new Application_Model_BootMenu(); + $bootmenu->setID($bootmenuID); + $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenumapper->delete($bootmenu); + } + $this->_redirect('/bootmenu'); // action body } |
