public function action_index() { $data = array(); $category = new Model_Category('tree'); $category->checkTree(TRUE); $data['categories'] = $category->getTree(); if ($this->isPressed('btnSubmitAdd')) { $categoryName = Arr::get($_POST, 'categoryName', ''); $parentId = Arr::get($_POST, 'parentId', 0); $res = $category->catInsert($parentId, array('name' => $categoryName)); if ($res) { Request::initial()->redirect('admin/category'); } $data['errors'] = $category->getErrors(); } if ($this->isPressed('btnSubmitChange')) { $categoryName = Arr::get($_POST, 'categoryName', ''); $parentId = Arr::get($_POST, 'parentId', 0); if ($category->changeName($parentId, $categoryName)) { Request::initial()->redirect('admin/category'); } $data['errors'] = $category->getErrors(); } if ($this->isPressed('btnSubmitDel')) { $catDeleteId = Arr::get($_POST, 'catDeleteId', 0); $category->catDelete($catDeleteId); Request::initial()->redirect('admin/category'); } $this->tpl->content = View::factory('admin/categoryeditview', $data); }
public function action_index() { $data = array(); if (!is_readable(APPPATH . 'config/database.php')) { Request::initial()->redirect('install'); } $cat = new Model_Category(); $materials = new Model_Material(); $cat->checkTree(); $tree = $cat->getTree(); $data['tree'] = $cat->getITree($tree); $data['teachers'] = $materials->getTeachersGropupByNode(); $this->tpl->content = View::factory('main', $data); }