public function getCategories() { $arrCats = AROShopProductCategory::finder()->findMany('parent_category_id = ?', $this->id); foreach ($arrCats as $cat) { $cat->init($this); } return $arrCats; }
function printCats($f_arrCats, $f_iLevel = 1) { $szOptions = ''; foreach ($f_arrCats as $objCat) { $szOptions .= '<option value="' . $objCat->id . '"' . ($_GET['selected'] == (int) $objCat->id ? ' selected="1"' : '') . '>' . trim(str_repeat(' >', $f_iLevel) . ' ' . htmlspecialchars($objCat->title)) . '</option'; $arrSubCats = AROShopProductCategory::finder()->findMany('parent_category_id = ?', $objCat->id); $szOptions .= printCats($arrSubCats, $f_iLevel + 1); } return $szOptions; }
function printCats($f_arrCats) { echo '<table border="2" cellpadding="3" cellspacing="0" bordercolor="white" width="300"><tbody>'; foreach ($f_arrCats as $objCat) { echo '<tr' . (empty($_GET['sort']) ? '' : ' bgcolor="#cccccc"') . '><td>'; echo '<div>> <a href="edit_category.php?id=' . $GLOBALS['objShop']->id . '&cat=' . $objCat->id . '">' . htmlspecialchars($objCat->title) . ' (' . htmlspecialchars($objCat->url_id) . ')</a> (<a href="new_category.php?id=' . $GLOBALS['objShop']->id . '&selected=' . $objCat->id . '">+</a>) (<a href="?id=' . $GLOBALS['objShop']->id . '&del=' . $objCat->id . '">x</a>)</div>'; $arrSubCats = AROShopProductCategory::finder()->findMany('parent_category_id = ?', $objCat->id); if (0 < count($arrSubCats)) { echo '<div class="sub">'; printCats($arrSubCats); echo '</div>'; } echo '</td></tr>'; } echo '</tbody></table>'; }
<?php require_once 'cfg_admin.php'; logincheck(); $objShop = AROImplementation::loadImplementationByID($_GET['id']); $objCat = AROShopProductCategory::finder()->findOne('id = ? AND shop_implementation_id = ?', $_GET['cat'], $objShop->implementation_id)->init($objShop); if (isset($_POST['url_id'], $_POST['title'], $_POST['content_1'])) { $arrUpdate = array('url_id' => $_POST['url_id'], 'title' => $_POST['title'], 'content_1' => $_POST['content_1']); foreach (array('1', '2') as $n) { $szColName = 'image_' . $n; if (!empty($_FILES[$szColName]) && 0 == $_FILES[$szColName]['error']) { $szExt = substr(strrchr($_FILES[$szColName]['name'], '.'), 1); if (in_array($szExt, array('jpg', 'jpeg', 'gif', 'bmp', 'png'))) { if ($u = move_uploaded_file($_FILES[$szColName]['tmp_name'], PROJECT_PUBLIC_RESOURCES . '/product_category_' . $objCat->id . '_' . $n . '.' . $szExt)) { $arrUpdate[$szColName] = $szExt; } } } } $db->update('shop_product_categories', $arrUpdate, 'id = ' . $objCat->id); header('Location: categories.php?id=' . $objShop->id); exit; } ?> <form method="post" action="" enctype="multipart/form-data"> <p>ID:<br /><input type="text" name="url_id" value="<?php echo $objCat->url_id; ?> " /></p>