/** * Add an option, which is a link. * The call will attempt to work out whether the option should be marked as * active, and will sometimes get it wrong. * @param string $label A Label for the new menu option * @param string $target The URL to target for this option. * @param string $title Some tooltip help for the title tag. * @param string $active Whether this option should be marked as Active. * @param int $sortkey An (optional) value to allow option ordering. * @param external open this link in a new window/tab. * @return mixed A reference to the MenuOption that was added, or false if none were added. */ function &AddOption($label, $target, $title = "", $active = false, $sortkey = null, $external = false) { if (!isset($sortkey)) { $sortkey = isset($this->last_sortkey) ? $this->last_sortkey + 100 : 1000; } $this->last_sortkey = $sortkey; if (version_compare(phpversion(), '5.0') < 0) { $new_option = new MenuOption($label, $target, $title, $this->main_class, $sortkey); } else { $new_option = new MenuOption($label, $target, $title, $this->main_class, $sortkey); } if (($old_option = $this->_OptionExists($label)) === false) { $this->options[] =& $new_option; } else { dbg_error_log("MenuSet", ":AddOption: Replacing existing option # {$old_option} ({$label})"); $this->options[$old_option] =& $new_option; // Overwrite the existing option } if (is_bool($active) && $active == false && $_SERVER['REQUEST_URI'] == $target) { // If $active is not set, then we look for an exact match to the current URL $new_option->Active($this->active_class); } else { if (is_bool($active) && $active) { // When active is specified as a boolean, the recognition has been done externally $new_option->Active($this->active_class); } else { if (is_string($active) && preg_match($active, $_SERVER['REQUEST_URI'])) { // If $active is a string, then we match the current URL to that as a Perl regex $new_option->Active($this->active_class); } } } if ($external == true) { $new_option->Set('target', '_blank'); } return $new_option; }
$originalOption->Id = $id; $originalOption->selectById(); } if (isset($_POST['update'])) { $updatedOption = new MenuOption($db); $updatedOption->Id = $_POST['id']; $updatedOption->MenuItem = $_POST['menuitem']; $updatedOption->MenuItemPrice = $_POST['menuitemprice']; if ($updatedOption->update() == true) { header("location:menu.php"); } else { echo "<script>alert('There was an error updating this item');window.location = 'menu.php' </script>"; } } if (isset($_POST['delete'])) { $updatedOption = new MenuOption($db); $updatedOption->Id = $_POST['id']; if ($updatedOption->delete() == true) { header("location:menu.php"); } else { echo "<script>alert('There was an error deleting this item');window.location = 'menu.php' </script>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</div> </div> <div class="form-group"> <label>Comment <input class="form-control" type="text" id="comment" name="comment" value="<?php echo $originalOption->Comment; ?> "/> </label> </div> <div class="form-group"> <label>Menu Item </label> <select class="form-control" name="menuitemid" id="menuitemid"> <?php $menuItem = new MenuOption($db); $stmt = $menuItem->selectAll(); while ($row_menuItem = $stmt->fetch(PDO::FETCH_ASSOC)) { extract($row_menuItem); if ($originalOption->MenuOption_Id == $Id) { echo "<option value='{$Id}' selected='selected'>{$MenuItem}</option>"; } else { echo "<option value='{$Id}'>{$MenuItem}</option>"; } } ?> </select> </div> </div>
<?php error_reporting(0); include "../config/database.class.php"; include "../objects/menuoption.class.php"; $database = new Database(); $db = $database->getConnection(); if (isset($_POST['add'])) { $updatedOption = new MenuOption($db); $updatedOption->MenuItem = $_POST['menuitem']; $updatedOption->MenuItemPrice = $_POST['menuitemprice']; if ($updatedOption->insert() == true) { header("location:menu.php"); } else { echo "<script>alert('There was an error adding this item');window.location = 'menu.php' </script>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <script src="../js/jquery-2.1.3.min.js"></script> <script src="../js/jquery.validate.js"></script> <link href="../css/bootstrap.min.css" rel="stylesheet">