/**
  * 查询指定标签的详细信息
  * @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');
 }
Example #2
0
 public function getPostCount($info = array())
 {
     $info['post_status'] = "publish";
     $PostsLogic = new PostsLogic();
     $post_count = $PostsLogic->countAll("single", $info);
     return $post_count;
 }
Example #3
0
 /**
  * 文章feed
  * @param string $type 文章类型
  * @internal param $null 显示数量由 feed_num决定* 显示数量由 feed_num决定
  */
 public function listPost($type = 'single')
 {
     $PostsList = new PostsLogic();
     $post_list = $PostsList->getList(get_opinion('feed_num'), $type, 'post_date desc', true);
     $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
     // 站点标题的链接
     foreach ($post_list as $list) {
         $RSS->addItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . get_post_url($list), $list['post_content'], $list['post_date']);
     }
     $RSS->display();
 }
 /**
  * 页面feed
  * @param null
  * 显示数量由 feed_num决定
  */
 public function listsPage()
 {
     $PostsList = new PostsLogic();
     $post_list = $PostsList->getList(get_opinion('feed_num'), 'page', 'post_id desc', true);
     $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
     // 站点标题的链接
     foreach ($post_list as $list) {
         $RSS->AddItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . getPageURLByID($list['post_id']), $list['post_content'], $list['post_date']);
     }
     $RSS->Display();
 }
 /**
  * 兼容旧式CMS深目录结构的二级cat结构
  * @param $info
  */
 public function channel($info)
 {
     //TODO 兼容旧式CMS深目录结构的二级cat结构
     $Cat = new CatsLogic();
     $cat = $Cat->detail($info);
     $children = $Cat->getChildren($cat['cat_id']);
     $Cat = new CatsLogic();
     $Posts = new PostsLogic();
     $cat = $Cat->detail($info);
     $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了");
     //优雅的404
     $posts_id = $Cat->getPostsId($cat['cat_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 = $Posts->getList($limit, 'single', 'post_id desc', true, array(), $posts_id);
     }
     $this->assign('children', $children);
     $this->assign('title', $cat['cat_name']);
     // 赋值数据集
     $this->assign('res404', $res404);
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id']));
     $this->display('Archive/channel-list');
 }
 /**
  * 未知类型单页显示 支持年月日限定
  * @param $method 魔术方法名称 即文章类型
  * @param $args
  */
 public function _empty($method, $args)
 {
     //TODO 通用模板机制
     $Posts = new PostsLogic();
     $info = I('get.info');
     $post_detail = $Posts->detail($info, true);
     $Posts->viewInc($post_detail['post_id']);
     $this->assign('post', $post_detail);
     // 赋值数据集
     if (File::file_exists(T('Home@Post/' . $post_detail['post_template']))) {
         $this->display($post_detail['post_template']);
     } else {
         //TODO   这里怎么处理却决于你自己了。
         $this->error404('缺少对应的模版而不能显示');
         //  $this->display('single');
     }
     // $this->display($post_res['post_type']);
 }
Example #7
0
 /**
  * 兼容旧式CMS深目录结构的二级cat结构
  * @param $info
  */
 public function channel($info)
 {
     //TODO 兼容旧式CMS深目录结构的二级cat结构
     $CatsLogic = new CatsLogic();
     $cat = $CatsLogic->detail($info);
     $children = $CatsLogic->getChildren($cat['cat_id']);
     if (empty($children['cat_children'])) {
         $children = $CatsLogic->getChildren($children['cat_father']);
     }
     $CatsLogic = new CatsLogic();
     $Posts = new PostsLogic();
     $cat = $CatsLogic->detail($info);
     $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了");
     //优雅的404
     $posts_id = $CatsLogic->getPostsIdWithChildren($cat['cat_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 = $Posts->getList($limit, 'single', 'post_date desc', true, array(), $posts_id);
     }
     $this->assign('children', $children);
     $this->assign('title', $cat['cat_name']);
     // 赋值数据集
     $this->assign('res404', $res404);
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id']));
     if (File::file_exists(T('Home@Archive/channel-list'))) {
         $this->display('Archive/channel-list');
     } else {
         //TODO   这里怎么处理却决于你自己了。
         //            $this->error404('缺少对应的模版而不能显示');
         $this->display('Archive/single-list');
     }
 }
 /**
  * 清空回收站
  */
 public function emptyRecycleHandle()
 {
     $PostsLogic = new PostsLogic();
     if ($PostsLogic->emptyPostHandleByStatus('preDel')) {
         $this->success('清空回收站成功');
     } else {
         $this->error('清空回收站失败');
     }
 }
 /**
  * @param $tag
  * @param $content
  * @usage <recentlist type="文章类型" num="数量"  order="排序" relation="是否关联"  length="字长度" li_attr='li属性' ul_attr="ul属性"></recentlist>
  * @return string
  */
 public function _recentlist($tag, $content)
 {
     $PostsLogic = new PostsLogic();
     $num = isset($tag['num']) ? (int) $tag['num'] : 5;
     $post_type = isset($tag['type']) ? $tag['type'] : 'single';
     $order = isset($tag['order']) ? $tag['order'] : 'post_date desc';
     $relation = isset($tag['relation']) ? $tag['relation'] : false;
     $li_attr = isset($tag['li_attr']) ? $tag['li_attr'] : '';
     $ul_attr = isset($tag['ul_attr']) ? $tag['ul_attr'] : '';
     $length = isset($tag['length']) ? (int) $tag['length'] : 20;
     $info['post_type'] = $post_type;
     $post_list = $PostsLogic->getList($num, $post_type, $order, $relation, $info);
     $parseStr = '<ul ' . $ul_attr . '>';
     foreach ($post_list as $value) {
         $parseStr .= '<li ' . $li_attr . '>
         <a href="' . getSingleURLByID($value['post_id']) . '" title="' . $value['post_title'] . '">
             ' . mb_substr($value['post_title'], 0, $length, "UTF-8") . ' </a></li>';
     }
     $parseStr .= '</ul>';
     if (!empty($parseStr)) {
         return $parseStr;
     }
 }
 /**
  * 标签文章
  * @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);
     }
 }
Example #11
0
 public function count()
 {
     $year = I('request.year', date('Y'));
     $month_start = I('request.month_start', date('m'));
     $month_end = I('request.month_end', date('m'));
     if ($month_start == $month_end) {
         $condition['post_date'] = array('like', I('request.year', '%') . '-' . I('request.month', '%') . '-' . I('request.day', '%') . '%');
     } else {
         if ($month_start == '%%') {
             $condition['post_date'] = array('between', "{$year}-0-0,{$year}-{$month_end}-31");
         } else {
             if ($month_end == '%%') {
                 $condition['post_date'] = array('between', "{$year}-{$month_start}-0,{$year}-12-31");
             } else {
                 $condition['post_date'] = array('between', "{$year}-{$month_start}-0,{$year}-{$month_end}-31");
             }
         }
     }
     $UserLogic = new UserLogic();
     $PostsLogic = new PostsLogic();
     $user_list = $UserLogic->getList(false);
     foreach ($user_list as $key => $user) {
         $condition['user_id'] = $user['user_id'];
         $user_list[$key]['post_count'] = $PostsLogic->countAll('single', $condition);
         $user_list[$key]['date'] = substr($condition['post_date'][1], 0, 7);
     }
     $this->assign("user_list", $user_list);
     $this->assign("year", $year);
     $this->assign("month_start", $month_start);
     $this->assign("month_end", $month_end);
     $this->display('count');
 }
 /**
  *  未知类型归档  支持年月日参数传递 和用户id
  * @param $method 未知类型
  * @param array $args 参数
  */
 public function _empty($method, $args)
 {
     $title_prefix = (I('get.year', '') ? I('get.year', '') . '年' : '') . (I('get.month', '') ? I('get.month', '') . '月' : '') . (I('get.day', '') ? I('get.day', '') . '日' : '');
     //TODO 通用类型
     $post_type = $method;
     $map['post_date'] = array('like', I('get.year', '%') . '-' . I('get.month', '%') . '-' . I('get.day', '%') . '%');
     if (I('get.uid') != '') {
         $map['user_id'] = I('get.uid');
     }
     $PostsLogic = new PostsLogic();
     $count = $PostsLogic->countAll($post_type, $map);
     // 查询满足要求的总记录数
     $count == 0 ? $res404 = 0 : ($res404 = 1);
     if ($count != 0) {
         $Page = new GreenPage($count, C('PAGER'));
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $posts_list = $PostsLogic->getList($limit, $post_type, 'post_id desc', true, $map);
     }
     $this->assign('title', $title_prefix . '所有' . $post_type);
     $this->assign('res404', $res404);
     // 赋值数据集
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     if (File::file_exists(T('Home@Archive/' . $post_type . '-list'))) {
         $this->display($post_type);
     } else {
         //TODO   这里怎么处理却决于你自己了。
         $this->error404('缺少对应的模版而不能显示');
         //  $this->display('single-list');
     }
 }
 /**
  * @param $id
  */
 public function posts($id = -1)
 {
     $this->action = '编辑文章';
     $this->action_name = 'posts';
     $this->post_id = $post_id = $_GET['id'] ? (int) $_GET['id'] : false;
     $Posts = new PostsLogic();
     if (IS_POST) {
         $post_data = $_POST;
         $post_data['post_modified'] = date("Y-m-d H:m:s", time());
         $post_data['post_type'] = $_POST['post_type'] ? $_POST['post_type'] : 'single';
         M("post_cat")->where(array("post_id" => $post_data['post_id']))->delete();
         M("post_tag")->where(array("post_id" => $post_data['post_id']))->delete();
         if (!empty($_POST['cats'])) {
             foreach ($_POST['cats'] as $cat_id) {
                 M("Post_cat")->add(array("cat_id" => $cat_id, "post_id" => $post_data['post_id']));
             }
         }
         if (!empty($_POST['tags'])) {
             foreach ($_POST['tags'] as $tag_id) {
                 M("Post_tag")->add(array("tag_id" => $tag_id, "post_id" => $post_data['post_id']));
             }
         }
         if ($post_data['post_type'] == 'single') {
             $url = U('Admin/Posts/index');
         } elseif ($post_data['post_type'] == 'page') {
             $url = U('Admin/Posts/page');
         } else {
             $url = U('Admin/Posts/index');
         }
         if ($Posts->save($post_data)) {
             $this->jsonReturn(1, "已经更新", $url);
         } else {
             $this->jsonReturn(0, "更新失败", $url);
         }
     } else {
         //投稿员只能看到自己的
         if (!$this->noVerify()) {
             $where['user_id'] = get_current_user_id();
         }
         $where["post_id"] = $post_id;
         $post = D('Posts')->relation(true)->where($where)->find();
         if (empty($post)) {
             $this->error("不存在该记录");
         }
         $PostEvent = new PostsEvent();
         $tpl_type_list = $PostEvent->get_tpl_type_list();
         $this->assign('tpl_type', gen_opinion_list($tpl_type_list, $post['post_template']));
         //投稿员只能看到自己的
         if (!$this->noVerify()) {
             $user_id = (int) $_SESSION[C('USER_AUTH_KEY')];
             $user = D('User', 'Logic')->detail($user_id);
             $role_id = $user["user_role"]["role_id"];
             $role = D('Role')->where(array('id' => $role_id))->find();
             $where['cat_id'] = array('in', json_decode($role["cataccess"]));
             $cats = D('Cats', 'Logic')->where($where)->select();
             foreach ($cats as $key => $value) {
                 $cats[$key]['cat_slug'] = $cats[$key]['cat_name'];
             }
         } else {
             $cats = D('Cats', 'Logic')->category();
             $tags = D('Tags', 'Logic')->select();
         }
         $this->assign("cats", $cats);
         $this->assign("tags", $tags);
         $this->assign("info", $post);
         $this->assign("handle", U('Admin/Posts/posts', array('id' => $id), true, false));
         $this->assign("publish", "更新");
         $this->display('add');
     }
 }
 /**
  * 编辑菜单
  * @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();
 }
Example #15
0
 public function countAll()
 {
     $where = array();
     //投稿员只能看到自己的
     if (!$this->noVerify()) {
         $where['user_id'] = get_current_user_id();
     }
     $PostsLogic = new PostsLogic();
     $res = array();
     $post_status = C('post_status');
     foreach ($post_status as $key => $value) {
         $where['post_status'] = $key;
         $count = $PostsLogic->countAll('single', $where);
         // 查询满足要求的总记录数
         $res['single'][$key] = $count;
     }
     $where['post_status'] = 'publish';
     $count = $PostsLogic->countAll('single', $where);
     // 查询满足要求的总记录数
     $res['page']['publish'] = $count;
     $this->jsonReturn(1, $res);
 }
 /**
  * 轮播说明
  * post_img->幻灯图片 url
  * post_top->顺序
  * post_template->分组
  * post_name->链接URL
  * post_content->文字
  * */
 public function slider()
 {
     $PostsList = new PostsLogic();
     $slider = $PostsList->getList(0, 'slider', 'post_top', false);
     $this->assign('slider', $slider);
     $this->display();
 }