/** * 查询指定标签的详细信息 * @param $info detail 查询的 id 或者slug */ public function detail($info) { $TagsLogic = new TagsLogic(); $PostsLogic = new PostsLogic(); $tag = $TagsLogic->detail($info); $this->if404($tag, "非常抱歉,没有这个标签,可能它已经躲起来了"); $posts_id = $TagsLogic->getPostsId($tag['tag_id']); $count = sizeof($posts_id); $count == 0 ? $res404 = 0 : ($res404 = 1); if (!empty($posts_id)) { $Page = new GreenPage($count, get_opinion('PAGER')); $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $posts_list = $PostsLogic->getList($limit, 'single', 'post_id desc', true, array(), $posts_id); } $this->assign('title', $tag['tag_name']); // 赋值数据集 $this->assign('res404', $res404); $this->assign('postslist', $posts_list); // 赋值数据集 $this->assign('pager', $pager_bar); // 赋值分页输出 $this->assign('breadcrumbs', get_breadcrumbs('tags', $tag['tag_id'])); $this->display('Archive/single-list'); }
/** * */ public function menuAdd() { $CatsLogic = new CatsLogic(); $TagsLogic = new TagsLogic(); $PostsLogic = new PostsLogic(); $cat_list = $CatsLogic->category(); $tag_list = $TagsLogic->field('tag_id,tag_name')->select(); $post_list = $PostsLogic->field('post_id,post_title')->select(); $cat_list = array_column_5($cat_list, 'cat_slug', 'cat_id'); $tag_list = array_column_5($tag_list, 'tag_name', 'tag_id'); $post_list = array_column_5($post_list, 'post_title', 'post_id'); $action = '添加菜单'; $action_url = U('Admin/Custom/menuAdd'); $form_url = U('Admin/Custom/menuAddHandle'); $Menu = new Category('Menu', array('menu_id', 'menu_pid', 'menu_name', 'menu_construct')); $menu_list = $Menu->getList(); // 获取分类结构 $url_function = C('url_function'); $this->assign('url_function', gen_opinion_list($url_function)); $url_open = C('url_open'); $this->assign('url_open', gen_opinion_list($url_open)); $this->assign('cat_list', gen_opinion_list($cat_list)); $this->assign('tag_list', gen_opinion_list($tag_list)); $this->assign('post_list', gen_opinion_list($post_list)); $this->assign('menu', $menu_list); $this->assign('action', $action); $this->assign('action_url', $action_url); $this->assign('form_url', $form_url); $this->display(); }
/** * 所有标签 * @usage {:W('Widget/tag')} */ public function tag() { $TagList = new TagsLogic(); $tag_res = $TagList->getList(50, false); $this->assign('tagClouds', $tag_res); $this->display('Widget:tag'); }
/** * 所有标签 * @usage {:W('Widget/tag')} */ public function tag() { if (S("Widget_tag") == null) { $TagList = new TagsLogic(); $tag_res = $TagList->getList(50, false, true); $this->assign('tagClouds', $tag_res); $tag = $this->fetch('Widget:tag'); S("Widget_tag", $tag, DEFAULT_EXPIRES_TIME); echo $tag; } else { echo S("Widget_tag"); } }
/** * 删除标签 * @param $id */ public function delTag($id = -1) { $TagsLogic = new TagsLogic(); if ($TagsLogic->relation(true)->delete($id)) { $this->success('标签删除成功', U('Admin/Posts/tag')); } else { $this->success('标签删除失败:没有找到指定标签,可能它已经被删除', U('Admin/Posts/tag')); } }
/** * 标签文章 * @param int $id 指定标签的文章 */ public function tag($id) { $Tag = new TagsLogic(); $Posts = new PostsLogic(); $tag = $Tag->detail($id); $posts_id = $Tag->getPostsId($tag['cat_id']); $count = sizeof($posts_id); if (!empty($posts_id)) { $Page = new GreenPage($count, get_opinion('PAGER')); $limit = $Page->firstRow . ',' . $Page->listRows; $res = $Posts->getList($limit, 'single', 'post_date desc', true, array(), $posts_id); foreach ($res as $key => $value) { $res[$key]['post_content'] = strip_tags($res[$key]['post_content']); $res[$key]['post_url'] = U('Api/Index/post', array('id' => $res[$key]['post_id']), false, true); $res[$key]["post_img"] = get_post_img($value); } $res_array["posts"] = $res; $this->jsonReturn(1, $res_array); } else { $res_array["detail"] = "没有文章"; $this->jsonReturn(0, $res_array); } }
/** * */ public function tag() { $page = I('get.page', C('PAGER')); $TagsLogic = new TagsLogic(); $count = $TagsLogic->count(); // 查询满足要求的总记录数 if ($count != 0) { $Page = new GreenPage($count, $page); // 实例化分页类 传入总记录数 $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $tags = $TagsLogic->selectWithPostsCount($limit); } $this->assign('tags', $tags); $this->assign('pager', $pager_bar); $this->display(); }
/** * 编辑菜单 * @param $id */ public function menuEdit($id) { $menu_item = D('Menu')->where(array('menu_id' => $id))->find(); if (!$menu_item) { $this->error('不存在这个菜单项'); } $this->assign('info', $menu_item); $CatsLogic = new CatsLogic(); $TagsLogic = new TagsLogic(); $PostsLogic = new PostsLogic(); /** * 文章分类标签 start */ $cat_list = $CatsLogic->category(); $tag_list = $TagsLogic->field('tag_id,tag_name')->select(); $post_list = $PostsLogic->field('post_id,post_title')->select(); $cat_list = array_column_5($cat_list, 'cat_slug', 'cat_id'); $tag_list = array_column_5($tag_list, 'tag_name', 'tag_id'); $post_list = array_column_5($post_list, 'post_title', 'post_id'); $this->assign('cat_list', gen_opinion_list($cat_list)); $this->assign('tag_list', gen_opinion_list($tag_list)); $this->assign('post_list', gen_opinion_list($post_list)); /** * 文章分类标签 end */ $action = '编辑菜单'; $action_url = U('Admin/Custom/menuEdit', array('id' => $id)); $form_url = U('Admin/Custom/menuEditHandle', array('id' => $id)); $Menu = new Category('Menu', array('menu_id', 'menu_pid', 'menu_name', 'menu_construct')); $menu_list = $Menu->getList(); // 获取分类结构 $url_function = get_opinion('url_function'); $this->assign('url_function', gen_opinion_list($url_function, $menu_item["menu_function"])); $url_open = get_opinion('url_open'); $this->assign('url_open', gen_opinion_list($url_open, $menu_item["menu_action"])); //父级节点 $menu_list2 = array_column_5($menu_list, 'menu_construct', 'menu_id'); $this->assign('menu_list2', gen_opinion_list($menu_list2, $menu_item['menu_pid'])); //显示排序 $menu_list3 = array_column_5($menu_list, 'menu_construct', 'menu_sort'); $this->assign('menu_list3', gen_opinion_list($menu_list3, $menu_item['menu_sort'])); $this->assign('menu', $menu_list); $this->assign('action', $action); $this->assign('action_url', $action_url); $this->assign('form_url', $form_url); $this->display(); }
/** * 删除标签 * @param $id */ public function delTag($id = -1) { $TagsLogic = new TagsLogic(); $PostsLogic = new PostsLogic(); $process_method = I('post.process_method'); if ($process_method == 'totag' && I('post.newtag') == $id) { $this->error("移动后的标签不能和当前分类相同"); } if ($TagsLogic->delete($id)) { if (D('Post_tag')->where(array("tag_id" => $id))->find()) { $pt_list = D('Post_tag')->where(array("tag_id" => $id))->select(); foreach ($pt_list as $pt) { if ($process_method == 'del') { $PostsLogic->preDel($pt['post_id']); } if ($process_method == 'totag') { $data['tag_id'] = I('post.newtag'); D('Post_tag')->where(array("pt_id" => $pt['pt_id']))->data($data)->save(); } } } } else { $this->error('标签删除失败:没有找到指定标签,可能它已经被删除', U('Admin/Posts/tag')); } $this->success('标签删除成功', U('Admin/Posts/tag')); }