<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $menuBar = array('cancel' => $_SESSION['referer_link'], 'save' => null); $this->content .= $this->makeToolbar($menuBar, 24); $menuBar = array(); $tree = new NestedTreeAdmin($ushop->db_name . 'product_categories', null, 'category', $this->registry); if ($this->registry->params['id']) { $row = $this->getResult('*', $ushop->db_name . 'products', null, array('where' => 'product_id = ' . $this->registry->params['id']), false); $tmpl = file_get_contents(__SITE_PATH . '/components/ushop/html/formHtml.html'); $errors = array(); $form = new HTML_QuickForm('edit_product', 'post', $_SERVER['REQUEST_URI']); // Remove name attribute for xhtml strict compliance. $form->removeAttribute('name'); //$form->addElement('html', '<div id="panelSet">'); // Details. $form->addElement('html', '<div id="details" class="morphtabs_panel"><div class="panel_content">'); //$form->addElement('header','details','Details'); $form->addElement('checkbox', 'enabled', 'Enable:'); $form->addElement('checkbox', 'discontinued', 'Discontinue:'); $form->addElement('text', 'name', 'Product Name:', array('size' => 20, 'maxlength' => 60, 'class' => 'inputbox')); $errors[] = 'name'; $form->addElement('text', 'sku', 'SKU:', array('size' => 20, 'maxlength' => 60, 'class' => 'inputbox')); $errors[] = 'sku'; $items_opts[0] = 'Select One'; foreach ($items = $tree->getTree() as $item) { $items_opts[$item['category_id']] = str_repeat(str_repeat(' ', 4), $item['depth']) . $item['category']; } $s = $form->createElement('select', 'category_id', 'Category:', null, array('id' => 'category'));
$access_level_opts[$level->status_id] = $status; } $s = $form->createElement('select', 'status_id', 'Access Level:', null, array('size' => '3', 'id' => 'access_level')); $s->loadArray($access_level_opts); $form->addElement($s); $form->addElement('html', '</fieldset>'); $form->addRule('item', 'Please enter a title', 'required'); // group rules $form->addRule('type_id', 'Please Select a menu type', 'nonzero'); $form->addRule('status_id', 'Please Select a access level', 'nonzero'); if ($form->validate()) { $menuBar = array(); // Apply form element filters. $form->freeze(); $values = $form->process(array(&$this, 'formValues'), false); $tree = new NestedTreeAdmin($this->registry->core . 'menu_items', null, 'item'); $ip = end($tree->getTopLevelTree()); $category_id = $tree->insert($ip['item_id'], $values, 'after child'); $menuBar['back'] = '/menu/overview'; // Always check that result is not an error if ($category_id) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu was successfully added.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>'; } } else { $renderer = new UthandoForm(__SITE_PATH . '/templates/' . $this->get('admin_config.site.template')); $renderer->setFormTemplate('form'); $renderer->setHeaderTemplate('header');
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $menuBar = array('cancel' => $_SESSION['referer_link'], 'save' => null); $this->content .= $this->makeToolbar($menuBar, 24); $menuBar = array(); $tree = new NestedTreeAdmin($ushop->db_name . 'product_categories', null, 'category'); $form = new HTML_QuickForm('add_category', 'post', $_SERVER['REQUEST_URI']); // Remove name attribute for xhtml strict compliance. $form->removeAttribute('name'); $form->addElement('html', '<fieldset>'); $form->addElement('header', 'new_category', 'New Category'); $form->addElement('text', 'category', 'Category:', array('size' => 20, 'maxlength' => 20, 'class' => 'inputbox')); $items_opts[0] = 'Top'; foreach ($items = $tree->getTree() as $item) { $items_opts[$item['category_id']] = str_repeat(str_repeat(' ', 4), $item['depth']) . $item['category']; } $s = $form->createElement('select', 'item_position', 'Position:', null, array('size' => '10', 'id' => 'item_position')); $s->loadArray($items_opts); $form->addElement($s); // Creates a radio buttons group $radio[] = $form->createElement('radio', null, null, 'at top', 'new child'); if (count($items) > 0) { $radio[] = $form->createElement('radio', null, null, 'after this item', 'after child'); } $form->addGroup($radio, 'insert_type', 'Insert as new sub item'); $form->addElement('html', '</fieldset>'); $form->addRule('category', 'Please enter a category', 'required'); if ($form->validate()) {
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { if (isset($this->registry->params['id']) && isset($this->registry->params['item']) && $this->upid <= 2) { if (isset($this->registry->params['itemAction']) == 'delete') { // start tree class $tree = new NestedTreeAdmin($this->registry->core . 'menu_items', $this->registry->params['item'], 'item'); // Update menu item table. $item = $tree->getCategory(); if ($item) { $result = $this->getResult('item_id', $this->registry->core . 'menu_items', null, array('where' => 'url_id=' . $item['url_id'])); if ($result) { $num_rows = count($result); } else { $pass = false; } // if just one url depends on this item then delete it. if ($num_rows == 1) { $result = $this->remove($this->registry->core . 'menu_urls', 'url_id=' . $item['url_id']); $pass = $result ? true : false; } } if ($num_rows) { $result = $tree->remove($this->registry->params['item']); $pass = $result ? true : false; } if ($pass) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu item was successfully deleted.</h2>';
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $menuBar = array(); if ($this->registry->params['comfirm'] == 'delete') { $tree = new NestedTreeAdmin($ushop->db_name . 'product_categories', $this->registry->params['id'], 'category'); $res = $tree->remove($this->registry->params['id']); if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Category was successfully deleted.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Category could not be deleted due to an error.</h2>'; } // done! $menuBar = array('back' => $_SESSION['referer_link']); } else { $menuBar = array('cancel' => $_SESSION['referer_link'], 'delete' => '/ushop/products/action-delete_category/id-' . $this->registry->params['id'] . '/comfirm-delete'); $params['TYPE'] = 'warning'; $params['MESSAGE'] = 'Are you sure you want to delete this category'; } if (isset($params)) { $params['CONTENT'] = $this->makeMessageBar($menuBar, 24); $this->content .= $this->message($params); } } else { header("Location:" . $this->get('config.server.web_url')); exit; }