/** * add doc */ public function add() { $post = array(); if ($_POST) { $post =& $_POST; $site_next_flow = site::site_next_flow($this->current_flow); $submit_target = intval($this->input->post('submit_target')); $doc = Mydoc::instance(); //标签过滤 tool::filter_strip_tags($_POST, array('content')); /* 判断url是否重复*/ $permalink = $this->input->post('permalink'); if ($doc->url_exist($permalink)) { remind::set(Kohana::lang('o_site.url_exist')); } else { if ($doc->add($_POST)) { //判断添加成功去向 switch ($submit_target) { case 1: remind::set(Kohana::lang('o_global.add_success'), 'site/doc/add', 'success'); break; case 2: remind::set(Kohana::lang('o_global.add_success'), 'site/doc/add', 'success'); break; default: remind::set(Kohana::lang('o_global.update_success'), 'site/doc', 'success'); } } else { remind::set(Kohana::lang('o_global.access_denied')); } } } //分类树 $category_list = ''; $categories = Mydoc_category::instance()->doc_categories(0); if (!empty($categories)) { foreach ($categories as $category) { $icon = ''; for ($i = 1; $i <= $category['level_depth']; $i++) { $icon = $icon . '--'; } $select = ''; if (isset($post['category_id']) && $post['category_id'] == $category['id']) { $select = ' selected'; } $category_list .= '<option value="' . $category['id'] . '"' . $select . '>' . $icon . $category['category_name'] . '</option>'; } } $this->template->content = new View("site/doc_add"); $this->template->content->post = $post; $this->template->content->title = "site doc add"; $this->template->content->category_list = $category_list; }
/** * 设定菜单的排序 */ public function set_order() { //初始化返回数组 $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); $request_data = $this->input->get(); $id = isset($request_data['id']) ? $request_data['id'] : ''; $order = isset($request_data['order']) ? $request_data['order'] : ''; /* 验证是否可以操作 */ if (!role::verify('doc_category', site::id(), 0)) { $return_struct['msg'] = Kohana::lang('o_global.permission_enough'); exit(json_encode($return_struct)); } if (empty($id) || empty($order) && $order != 0) { $return_struct['msg'] = Kohana::lang('o_global.bad_request'); exit(json_encode($return_struct)); } if (!is_numeric($order) || $order < 0) { $return_struct['msg'] = Kohana::lang('o_global.position_rule'); exit(json_encode($return_struct)); } if (Mydoc_category::instance()->set_order($id, $order)) { $return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order)); } else { $return_struct['msg'] = Kohana::lang('o_global.position_error'); } exit(json_encode($return_struct)); }