From b457bd7b0e70b3f76fd1d30b7d31ff2d609b4de8 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 8 Mar 2011 14:53:36 +0100 Subject: BootMenuEntries select --- application/controllers/BootmenuController.php | 40 +++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 2a0ec8a..1b4bbfb 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -2,7 +2,7 @@ class BootmenuController extends Zend_Controller_Action { - + public function init() { $db = Zend_Db_Table::getDefaultAdapter(); @@ -12,24 +12,31 @@ class BootmenuController extends Zend_Controller_Action { $bootmenumapper = new Application_Model_BootMenuMapper(); $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); - $bootmenuentries = array(); + $this->view->bootmenulist = $bootmenumapper->fetchAll(); + + $bootmenuentries = array(); foreach ($this->view->bootmenulist as $bootmenu){ $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); } $this->view->bootmenuentrylist = $bootmenuentries; - } public function addbootmenuentryAction() { $bootmenuID = $this->_request->getParam('bootmenuID'); + $bootosmapper = new Application_Model_BootOsMapper(); +// $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); +// +// $bootoslist = $this->arrayDiff($bootosmapper->fetchAll(), $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID)); + if (!isset($_POST["addbootmenuentry"])){ - $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(); + $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll())); + } else { $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd($_POST); - + if ($addbootmenuentryForm->isValid($_POST)) { $bootmenuentry = new Application_Model_BootMenuEntries($_POST); @@ -130,18 +137,20 @@ class BootmenuController extends Zend_Controller_Action { $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); $bootmenuID = $this->_request->getParam('bootmenuID'); + $bootosmapper = new Application_Model_BootOsMapper(); 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); + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); + + $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll())); - $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(); - $editbootmenuentryForm->populate($bootmenuentry->toArray()); + $editbootmenuentryForm->populate($bootmenuentry->toArray()); } }else{ $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit($_POST); @@ -200,6 +209,17 @@ class BootmenuController extends Zend_Controller_Action $this->_redirect('/bootmenu'); } + private function arrayDiff($a, $b){ + foreach($a as $k1 => $i1){ + foreach($b as $k2 => $i2){ + if($i1->getID() == $i2->getBootosID()){ + unset($a[$k1]); + } + } + } + return $a; + } + } -- cgit v1.2.3-55-g7522