summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/BootmenuController.php64
-rw-r--r--application/models/BootMenuEntriesMapper.php6
-rw-r--r--application/models/DbTable/BootMenuEntries.php1
-rw-r--r--application/views/scripts/bootmenu/index.phtml61
-rw-r--r--pbs.sql5
5 files changed, 120 insertions, 17 deletions
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) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ }
+
+ $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
}
diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php
index 632d578..a2a497a 100644
--- a/application/models/BootMenuEntriesMapper.php
+++ b/application/models/BootMenuEntriesMapper.php
@@ -38,7 +38,7 @@ class Application_Model_BootMenuEntriesMapper
unset($data['bootmenuentriesID']);
$this->getDbTable()->insert($data);
} else {
- $this->getDbTable()->update($data, array('bootosID = ?' => $id));
+ $this->getDbTable()->update($data, array('bootmenuentriesID = ?' => $id));
}
}
@@ -60,7 +60,7 @@ class Application_Model_BootMenuEntriesMapper
$row = $result->current();
- $botmenuentries->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order);
+ $botmenuentries->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order);
}
public function fetchAll()
@@ -69,9 +69,7 @@ class Application_Model_BootMenuEntriesMapper
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_BootMenuEntries();
-
$entry->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order);
-
$entries[] = $entry;
}
return $entries;
diff --git a/application/models/DbTable/BootMenuEntries.php b/application/models/DbTable/BootMenuEntries.php
index 92fb068..b4ad677 100644
--- a/application/models/DbTable/BootMenuEntries.php
+++ b/application/models/DbTable/BootMenuEntries.php
@@ -4,6 +4,7 @@ class Application_Model_DbTable_BootMenuEntries extends Zend_Db_Table_Abstract
{
protected $_name = 'pbs_bootmenuentries';
+ protected $_primary = 'bootmenuID';
}
diff --git a/application/views/scripts/bootmenu/index.phtml b/application/views/scripts/bootmenu/index.phtml
index c4cdb99..d7acbac 100644
--- a/application/views/scripts/bootmenu/index.phtml
+++ b/application/views/scripts/bootmenu/index.phtml
@@ -1,4 +1,13 @@
<h1>BootMenu</h1>
+
+<style>
+table{font-family:verdana;font-size:12px;}
+td{border:1px solid #CCC;}
+td.nostyle{background-color:#FFFFFF;}
+tr.bootmenu{background-color:#D8D8D8;}
+tr.bootentry{background-color:#E0ECF8;}
+</style>
+
<table border=1>
<tr>
<th>ID</th>
@@ -8,37 +17,75 @@
<th>Changed</th>
</tr>
<?php foreach ($this->bootmenulist as $bootmenu): ?>
- <tr>
+ <tr class=bootmenu>
<td><?php echo $this->escape($bootmenu->getID()); ?></td>
<td><?php echo $this->escape($bootmenu->getTitle()); ?></td>
<td><?php echo $this->escape($bootmenu->getGroupID()); ?></td>
<td><?php echo $this->escape($bootmenu->getMembershipID()); ?></td>
<td><?php echo $this->escape(date('Y-m-d H:i:s', $bootmenu->getCreated())); ?></td>
- <td><a href="<?php echo $this->url(
+ <td class=nostyle><a href="<?php echo $this->url(
array(
'controller' => 'bootmenu',
'action' => 'editbootmenu',
'bootmenuID' => $bootmenu->getID()
),
'default',
- true, false) ?>">Edit BootMenu</a></td>
- <td><a href="<?php echo $this->url(
+ true, false) ?>">Edit Bootmenu</a></td>
+ <td class=nostyle><a href="<?php echo $this->url(
array(
'controller' => 'bootmenu',
'action' => 'deletebootmenu',
'bootmenuID' => $bootmenu->getID()
),
'default',
- true) ?>">Delete BootMenu</a></td>
- <td><a href="<?php echo $this->url(
+ true) ?>">Delete Bootmenu</a></td>
+ <td class=nostyle><a href="<?php echo $this->url(
array(
'controller' => 'bootmenu',
'action' => 'addbootmenuentry',
'bootmenuID' => $bootmenu->getID()
),
'default',
- true) ?>">Add BootMenuEntry</a></td>
+ true) ?>">Add Entry</a></td>
+ </tr>
+ <tr>
+ <th></th>
+ <th>ID</th>
+ <th>Title</th>
+ <th>BootmenuID</th>
+ <th>BootOSID</th>
+ <th>kcl</th>
+ <th>ConfigID</th>
+ <th>order</th>
</tr>
+ <?php foreach ($this->bootmenuentrylist[$bootmenu->getID()] as $bootmenuentry): ?>
+ <tr class=bootentry><td class=nostyle></td>
+ <td><?php echo $this->escape($bootmenuentry->getID()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getTitle()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getBootmenuID()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getBootosID()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getkcl()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getConfigID()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getOrder()); ?></td>
+ <td class=nostyle><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'bootmenu',
+ 'action' => 'editbootmenuentry',
+ 'bootmenuentryID' => $bootmenuentry->getID()
+ ),
+ 'default',
+ true, false) ?>">Edit Entry</a></td>
+ <td class=nostyle><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'bootmenu',
+ 'action' => 'removebootmenuentry',
+ 'bootmenuentryID' => $bootmenuentry->getID(),
+ 'bootmenuID' => $bootmenu->getID()
+ ),
+ 'default',
+ true) ?>">Remove Entry</a></td>
+ </tr>
+ <?php endforeach; ?>
<?php endforeach; ?>
</table>
<br/>
diff --git a/pbs.sql b/pbs.sql
index 6c60837..10dc0d5 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -163,9 +163,10 @@ CREATE TABLE IF NOT EXISTS `pbs_bootmenuentries` (
`bootmenuID` int(11) NOT NULL,
`title` varchar(30) NOT NULL,
`kcl` varchar(140),
- `configID` int(11) NOT NULL,
+ `configID` int(11),
`order` int(11) NOT NULL,
PRIMARY KEY (`bootmenuentriesID`),
+ UNIQUE KEY `bootmenuIDbootosID` (`bootmenuID`,`bootosID`),
KEY `bootosID` (`bootosID`),
KEY `bootmenuID` (`bootmenuID`),
KEY `configID` (`configID`)
@@ -174,7 +175,7 @@ CREATE TABLE IF NOT EXISTS `pbs_bootmenuentries` (
ALTER TABLE `pbs_bootmenuentries`
ADD CONSTRAINT `pbs_bootmenuentries_ibfk_1` FOREIGN KEY (`bootmenuID`) REFERENCES `pbs_bootmenu` (`bootmenuID`) ON DELETE CASCADE,
ADD CONSTRAINT `pbs_bootmenuentries_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE,
- ADD CONSTRAINT `pbs_bootmenuentries_ibfk_3` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE CASCADE;
+ ADD CONSTRAINT `pbs_bootmenuentries_ibfk_3` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`);
CREATE TABLE IF NOT EXISTS `pbs_bootiso` (
`bootisoID` int(11) NOT NULL AUTO_INCREMENT,