public function content()
 {
     $id = $_GET['id'];
     $article = sp_sql_content($id, '');
     if (empty($article)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $termid = $article['term_id'];
     $term_obj = M("Terms");
     $term = $term_obj->where("term_id='{$termid}'")->find();
     $str_like_list = D('like')->getLikeByUUID($id, true);
     $article_id = $article['object_id'];
     $dbContent = D("content");
     $dbContent->saveByUUID($id, array("post_hits" => array("exp", "post_hits+1")));
     $article_date = $article['post_modified'];
     $join = "" . C('DB_PREFIX') . 'content as b on a.object_id =b.id';
     $join2 = "" . C('DB_PREFIX') . 'users as c on b.post_author = c.id';
     $rs = M("TermRelationships");
     $next = $rs->alias("a")->join($join)->join($join2)->where(array("post_modified" => array("egt", $article_date), "tid" => array('neq', $id), "status" => 1, 'a.term_id' => $termid))->order("post_modified asc")->find();
     $prev = $rs->alias("a")->join($join)->join($join2)->where(array("post_modified" => array("elt", $article_date), "tid" => array('neq', $id), "status" => 1, 'a.term_id' => $termid))->order("post_modified desc")->find();
     $this->assign("next", $next);
     $this->assign("prev", $prev);
     $smeta = json_decode($article['smeta'], true);
     $content_data = sp_content_page($article['post_content']);
     $article['post_content'] = $content_data['content'];
     switch ($article['term_id']) {
         case 2:
             $article['content_type'] = '论文';
             break;
         case 3:
             $article['content_type'] = '项目';
             break;
         case 4:
             $article['content_type'] = '获奖';
             break;
         case 5:
             $article['content_type'] = '专利';
             break;
     }
     $this->assign("page", $content_data['page']);
     $this->assign("article", $article);
     $this->assign("smeta", $smeta);
     $this->assign("term", $term);
     $this->assign("article_id", $article_id);
     $this->assign("str_like_list", $str_like_list);
     $tplname = $term["one_tpl"];
     $tplname = sp_get_apphome_tpl($tplname, "article");
     $this->display(":{$tplname}");
 }
 public function index()
 {
     $term = sp_get_term($_GET['id']);
     if (empty($term)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $tplname = $term["list_tpl"];
     $tplname = sp_get_apphome_tpl($tplname, "list");
     $this->assign($term);
     $this->assign('cat_id', intval($_GET['id']));
     $this->display(":{$tplname}");
 }
 public function list_content()
 {
     $tplname = $term["list_tpl"];
     $tplname = sp_get_apphome_tpl($tplname, "list_content");
     if (empty($tplname)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $dbContent = M('content');
     $dbTR = M('term_relationships');
     $obj = $dbTR->where('status=1')->select();
     foreach ($obj as $item) {
         $obj_id[] = $item['object_id'];
     }
     $map['post_status'] = 1;
     //判断文章是否审核通过;
     $map['id'] = array('in', $obj_id);
     //判断文章是否被删除;
     $list = $dbContent->where($map)->order('post_date desc')->select();
     for ($i = 0; $i < count($list); $i++) {
         $user = M('users')->where('id=' . $list[$i]['post_author'])->find();
         $list[$i]['author'] = $user['user_name'];
         $list[$i]['like_list'] = D('like')->getLikeByUUID($list[$i]['id'], true);
         switch ($list[$i]['table_name']) {
             case 'content_paper':
                 $list[$i]['content_type'] = '论文';
                 break;
             case 'content_project':
                 $list[$i]['content_type'] = '项目';
                 break;
             case 'content_award':
                 $list[$i]['content_type'] = '获奖';
                 break;
             case 'content_patent':
                 $list[$i]['content_type'] = '专利';
                 break;
         }
     }
     $this->assign('lists_post', $list);
     $this->assign($term);
     $this->display(":{$tplname}");
 }
 public function index()
 {
     $term = sp_get_term($_GET['id']);
     if (empty($term)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     if ($term['parent'] != 0) {
         $parentid = $term['parent'];
         $termschildren = $this->terms_model->where(array('parent' => $parentid))->select();
         //获得二级栏目
     } else {
         $termschildren = $this->terms_model->where(array('parent' => $term['term_id']))->select();
         //获得二级栏目
     }
     //kjdump($term);
     switch ($term['catype']) {
         case '1':
             $postdata = $this->getcaseslist($term['term_id']);
             break;
             //文章
         //文章
         case '0':
             $postdata = $this->getarticlelist($term['term_id']);
             break;
             //案例
         //案例
         default:
             $this->display(":404");
             break;
     }
     //kjdump($postdata );
     $tplname = $term["list_tpl"];
     //$tplname=sp_get_apphome_tpl($tplname, "list");
     $this->assign('term', $term);
     $this->assign('parentid', $parentid);
     //$this->assign('cat_id', intval($_GET['id']));
     $this->assign('termschildren', $termschildren);
     $this->assign('postdata', $postdata);
     $this->display(":{$tplname}");
 }
 public function index()
 {
     $id = $_GET['id'];
     $content = sp_sql_page($id);
     if (empty($content)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $this->assign($content);
     $smeta = json_decode($content['smeta'], true);
     $tplname = isset($smeta['template']) ? $smeta['template'] : "";
     $tplname = sp_get_apphome_tpl($tplname, "page");
     $this->display(":{$tplname}");
 }
 public function index()
 {
     $terms_db = M('Terms');
     $term = sp_get_term($_GET['id']);
     if (empty($term)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $tlist = $terms_db->where(array('parent' => $_GET['id']))->select();
     $tplname = $term["list_tpl"];
     $tplname = sp_get_apphome_tpl($tplname, "list");
     $this->assign($term);
     $this->assign('tlist', $tlist);
     $this->assign('cat_id', intval($_GET['id']));
     $this->display(":{$tplname}");
 }
 public function index()
 {
     $id = intval($_GET['id']);
     $article = sp_sql_post($id, '');
     if (empty($article)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $termid = $article['term_id'];
     $term_obj = M("Terms");
     $term = $term_obj->where("term_id='{$termid}'")->find();
     $article_id = $article['object_id'];
     $should_change_post_hits = sp_check_user_action("posts{$article_id}", 1, true);
     if ($should_change_post_hits) {
         $posts_model = M("Posts");
         $posts_model->save(array("id" => $article_id, "post_hits" => array("exp", "post_hits+1")));
     }
     $article_date = $article['post_modified'];
     $join = "" . C('DB_PREFIX') . 'posts as b on a.object_id =b.id';
     $join2 = "" . C('DB_PREFIX') . 'users as c on b.post_author = c.id';
     $rs = M("TermRelationships");
     $next = $rs->alias("a")->join($join)->join($join2)->where(array("post_modified" => array("egt", $article_date), "tid" => array('neq', $id), "status" => 1, 'term_id' => $termid))->order("post_modified asc")->find();
     $prev = $rs->alias("a")->join($join)->join($join2)->where(array("post_modified" => array("elt", $article_date), "tid" => array('neq', $id), "status" => 1, 'term_id' => $termid))->order("post_modified desc")->find();
     $this->assign("next", $next);
     $this->assign("prev", $prev);
     $smeta = json_decode($article['smeta'], true);
     $content_data = sp_content_page($article['post_content']);
     $article['post_content'] = $content_data['content'];
     $this->assign("page", $content_data['page']);
     $this->assign($article);
     $this->assign("smeta", $smeta);
     $this->assign("term", $term);
     $this->assign("article_id", $article_id);
     $tplname = $term["one_tpl"];
     $tplname = sp_get_apphome_tpl($tplname, "article");
     $this->display(":{$tplname}");
 }
 public function index()
 {
     $term = sp_get_term($_GET['id']);
     if (empty($term)) {
         header('HTTP/1.1 404 Not Found');
         header('Status:404 Not Found');
         if (sp_template_file_exists(MODULE_NAME . "/404")) {
             $this->display(":404");
         }
         return;
     }
     $tplname = $term["list_tpl"];
     $tplname = sp_get_apphome_tpl($tplname, "list");
     $dbPosts = M('posts');
     $dieYear['max'] = $dbPosts->field(array('MAX(LEFT(post_diedate,4))' => 'max'))->find()['max'];
     $dieYear['min'] = $dbPosts->field(array('MIN(LEFT(post_diedate,4))' => 'min'))->find()['min'];
     $this->assign('dieYear', $dieYear);
     $this->assign($term);
     $this->assign('cat_id', intval($_GET['id']));
     $this->display(":{$tplname}");
 }