/** * Добавление/обновление категории * @return void */ public function editAction() { if ($this->_authorize('category', 'edit')) { $form = new Form_Category_Edit(); if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { // Выполняем update (insert/update данных о категории) $objCategories = new Categories(); $categoryId = $form->categoryId->getValue(); if (!empty($categoryId)) { $objCategory = $objCategories->getCategoryById($categoryId); } else { $objCategory = $objCategories->createRow(); } $categoryName = $form->categoryName->getValue(); // trim и htmlEnteties делают фильтры zend_form $objCategory->setName($categoryName); $categoryDescr = $form->categoryDescr->getValue(); $objCategory->setDescription($categoryDescr); $objCategory->save(); $this->_forward('index', 'category'); } } else { $categoryId = (int) $this->getRequest()->getParam('categoryId'); if ($categoryId != '') { // выбираем из базы данные о редактируемой категории $categories = new Categories(); $objCategory = $categories->getCategoryById($categoryId); if ($objCategory) { $this->view->objCategory = $objCategory; $form->populate(array('categoryName' => $objCategory->cat_name, 'categoryDescr' => $objCategory->cat_descr, 'categoryId' => $objCategory->cat_id)); } } } // print_r( $form->getErrors()); // @todo: НЕ выводит сообщения об ошибках в форму $this->view->objCategoryEditForm = $form; } }
<?php //renders a category tree from level clicked. require_once '../classes/domains/Categories.php'; require_once '../classes/domains/Post.php'; $user = "******"; $categoryId = isset($_GET["cid"]) ? $_GET['cid'] : null; $categories = array(); $postsArray = array(); $postErr = array(); if (!is_null($categoryId)) { $categories = Categories::getCategoryById($categoryId); $currentActiveString = $categories[0]->category; Categories::getHierarchy($categories); fetchPosts($categories, $postsArray, $postErr); } ?> <!DOCTYPE html> <html lang="en"> <head> <?php require_once 'views/header.php'; ?> <script type="text/javascript"> <?php require_once 'views/header.php'; echo "\ncategories=" . json_encode($categories) . ";\n"; echo "posts=" . json_encode($postsArray) . ";\n"; echo "postErr=" . json_encode($postErr) . ";\n"; ?> </script>
<?php require_once '../classes/domains/Categories.php'; require_once '../classes/domains/Post.php'; $postId = isset($_GET["pid"]) ? $_GET['pid'] : null; if (!is_null($postId)) { $postArray = Post::getPostById($postId); $post = $postArray[0]; } else { $post = new Post(0, '', ''); //redirect back to where they came from. } $currentCategory = Categories::getCategoryById($post->categoryId); $currentActiveString = $currentCategory[0]->category; $showBottomLink = false; ?> <!DOCTYPE html> <html lang="en"> <head> <?php require_once 'views/header.php'; ?> <link href="../assets/css/styles/tomorrow-night-eighties.css" rel="stylesheet"> <style> fieldset.fieldset-override { padding: 20px 20px 20px 20px; background-color: #FFFFFF; border: 1px solid #DDDDDD; border-radius: 4px 4px 4px 4px; margin: 15px 0;