Ejemplo n.º 1
0
 /**
  * 获得栏目url
  * @param $category 栏目字段
  * @return string
  */
 static function getCategoryUrl($category)
 {
     //静态根目录
     $html_path = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
     switch ($category['cattype']) {
         case 3:
             //外部链接
             return $category['cat_redirecturl'];
         case 4:
             $model = ContentViewModel::getInstance($category['mid']);
             $content = $model->join('category')->where(C("DB_PREFIX") . 'category.cid=' . $category['cid'])->find();
             if ($category['cat_url_type'] == 1) {
                 //栏目生成静态
                 return Url::getContentHtml($content);
             } else {
                 return U('Index/Index/content', array('mid' => $content['mid'], 'cid' => $content['cid'], 'aid' => $content['aid']));
             }
         case 2:
         case 1:
         default:
             //普通栏目
             if ($category['cat_url_type'] == 1) {
                 //栏目生成静态
                 return __ROOT__ . '/' . $html_path . $category['catdir'];
             } else {
                 return U('Index/Index/category', array('mid' => $category['mid'], 'cid' => $category['cid']));
             }
     }
 }
Ejemplo n.º 2
0
 public function category()
 {
     $mid = Q('mid', 0, 'intval');
     $cid = Q('cid', 0, 'intval');
     $cache = cache('category');
     if (!$mid || !$cid || !isset($cache[$cid])) {
         _404();
     }
     $cachetime = C('CACHE_CATEGORY') >= 1 ? C('CACHE_CATEGORY') : null;
     if (!$this->isCache()) {
         $category = $cache[$cid];
         //外部链接,直接跳转
         if ($category['cattype'] == 3) {
             go($category['cat_redirecturl']);
         } else {
             $Model = ContentViewModel::getInstance($category['mid']);
             $catid = getCategory($category['cid']);
             $category['content_num'] = $Model->join()->where("cid IN(" . implode(',', $catid) . ")")->count();
             $category['comment_num'] = intval(M('comment')->where("cid IN(" . implode(',', $catid) . ")")->count());
             $this->assign("hdcms", $category);
             $this->display($category['template'], $cachetime);
         }
     } else {
         $this->display(null, $cachetime);
     }
 }
Ejemplo n.º 3
0
 public function index()
 {
     $ContentModel = ContentViewModel::getInstance($this->_mid);
     $where = "uid=" . $_SESSION['uid'];
     $page = new Page($ContentModel->join('category')->where($where)->count(), 15);
     $data = $ContentModel->join('category')->where($where)->limit($page->limit())->order(array("arc_sort" => "ASC", 'aid' => "DESC"))->all();
     $this->assign('data', $data);
     $this->display();
 }
Ejemplo n.º 4
0
 public function search()
 {
     $word = Q('word');
     if (!$word) {
         $this->error("搜索内容不能为空");
     } else {
         $cid = Q('cid', 0, 'intval');
         $mid = $cid ? $modelCache[$categoryCache[$cid]['mid']] : 1;
         $pre = C('DB_PREFIX');
         $seachType = Q('type', 'title');
         $modelCache = cache('model');
         $categoryCache = cache('category');
         $contentModel = ContentViewModel::getInstance($mid);
         $table = $modelCache[$mid]['table_name'];
         if ($seachType == 'tag') {
             $db = M();
             $countSql = "SELECT count(*) AS c FROM \n\t\t\t\t\t\t(SELECT distinct(aid) FROM {$pre}tag AS t INNER JOIN {$pre}content_tag AS ct ON t.tid=ct.tid WHERE tag='{$word}' AND mid=1 GROUP BY aid) AS c";
             $count = $db->query($countSql);
             $page = new Page($count[0]['c'], 15);
             $DataSql = "SELECT * FROM {$pre}category as cat JOIN {$pre}{$table} AS c  ON cat.cid = c.cid JOIN {$pre}content_tag AS ct  ON c.aid=ct.aid INNER \n\t\t\t\t\t\t\t\t\t\tJOIN {$pre}tag AS t ON t.tid=ct.tid WHERE t.tag='{$word}' LIMIT " . $page->limit(true);
             $data = $db->query($DataSql);
         } else {
             $where = array();
             if ($cid) {
                 $where[] = $pre . "category.cid=" . $cid;
             }
             if (!empty($_GET['search_begin_time']) && !empty($_GET['search_end_time'])) {
                 $where[] = "addtime>=" . strtotime($_GET['search_begin_time']) . " AND addtime<=" . $_GET['search_end_time'];
             }
             switch ($seachType) {
                 case 'title':
                     $where[] = "title like '%{$word}%'";
                     $count = $contentModel->join('category')->where($where)->count();
                     $page = new Page($count, 15);
                     $data = $contentModel->join('category')->where($where)->all();
                     break;
                 case 'description':
                     $where[] = "description like '%{$word}%'";
                     $count = $contentModel->join('category')->where($where)->count();
                     $page = new Page($count, 15);
                     $data = $contentModel->join('category')->where($where)->all();
                     break;
                 case 'username':
                     $where[] = "username like '%{$word}%'";
                     $count = $contentModel->join('category,user')->where($where)->count();
                     $page = new Page($count, 15);
                     $data = $contentModel->join('category,user')->where($where)->all();
                     break;
             }
         }
         $this->assign('searchCategory', $categoryCache);
         $this->assign('page', $page);
         $this->assign('data', $data);
         $this->display();
     }
 }
Ejemplo n.º 5
0
 public function __init()
 {
     $this->_model = cache("model", false);
     $this->_category = cache("category", false);
     $this->_mid = Q('mid', 1, 'intval');
     if (!isset($this->_model[$this->_mid])) {
         $this->error("模型不存在!");
     }
     $this->_db = ContentViewModel::getInstance($this->_mid);
 }
Ejemplo n.º 6
0
 public function content()
 {
     if (empty($this->_mid)) {
         $this->error('mid参数错误');
     }
     $ContentModel = ContentViewModel::getInstance($this->_mid);
     //文章状态
     $state = Q('get.state', 1, 'intval');
     $where = array();
     $where[] = $ContentModel->tableFull . ".content_state={$state}";
     //按时间搜索
     $search_begin_time = Q('post.search_begin_time', null, 'strtotime');
     if ($search_begin_time) {
         $where[] = "addtime>={$search_begin_time}";
     }
     //按flag搜索
     if ($flag = Q('flag')) {
         $where[] = "find_in_set('{$flag}',flag)";
     }
     //按字段类型
     if (isset($_POST['search_type']) && !empty($_POST['search_type']) && !empty($_POST['search_keyword'])) {
         $search_keyword = $_POST['search_keyword'];
         switch (strtolower($_POST['search_type'])) {
             case 1:
                 //标题
                 $where[] = "title LIKE '%{$search_keyword}%'";
                 break;
             case 2:
                 $where[] = "description LIKE '%{$search_keyword}%'";
                 //简介
                 break;
             case 3:
                 //用户名
                 $where[] = "username ='******'";
                 break;
             case 4:
                 //用户uid
                 $where[] = $ContentModel->tableFull . ".uid ={$search_keyword}";
                 break;
         }
     }
     $search_end_time = Q('post.search_end_time', null, 'strtotime');
     if ($search_end_time) {
         $where[] = "addtime<={$search_end_time}";
     }
     $where[] = C('DB_PREFIX') . "category.cid=" . $this->_cid;
     $page = new Page($ContentModel->join('user,category')->where($where)->count(), 15);
     $data = $ContentModel->join('user,category')->where($where)->limit($page->limit())->order(array("arc_sort" => "ASC", 'aid' => "DESC"))->all();
     $this->assign('data', $data);
     $flagCache = cache($this->_mid, false, FLAG_CACHE_PATH);
     $this->assign('flag', $flagCache);
     $this->assign('page', $page->show());
     $this->display();
 }
Ejemplo n.º 7
0
 public function content()
 {
     $ContentModel = ContentViewModel::getInstance($this->mid);
     $where[] = "category.mid=" . $this->mid;
     $where[] = 'user.uid=' . $_SESSION['user']['uid'];
     $page = new Page($ContentModel->where($where)->count(), 10);
     $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all();
     $this->assign('data', $data);
     $this->assign('model', $this->model[$this->mid]);
     $this->assign('page', $page->show());
     $this->display();
 }
 public function audit()
 {
     $Model = ContentViewModel::getInstance($this->mid);
     //1 审核  0 取消审核
     $status = Q("status", 1, "intval");
     //文章id
     $aids = Q("post.aid");
     foreach ($aids as $aid) {
         $Model->save(array("aid" => $aid, "content_status" => $status));
     }
     $this->success('操作成功!', U('content', array('mid' => $this->mid)));
 }
 public function content()
 {
     $Model = ContentViewModel::getInstance($this->mid);
     $count = $Model->where('content_status=0')->count();
     $page = new Page($count, 15);
     $data = $Model->where('content_status=0')->limit($page->limit())->order('updatetime DESC')->all();
     $this->assign('data', $data);
     $this->assign('mid', $this->mid);
     $this->assign('model', $this->model);
     $this->assign('page', $page->show());
     $this->display();
 }
Ejemplo n.º 10
0
 /**
  * 审核或取消审核
  */
 public function audit()
 {
     $Model = ContentViewModel::getInstance($this->_mid);
     //1 审核  0 取消审核
     $content_state = Q("content_state", 1, "intval");
     //文章id
     $aids = Q("post.aid");
     foreach ($aids as $aid) {
         $Model->save(array("aid" => $aid, "content_state" => $content_state));
     }
     $this->success('操作成功!');
 }
Ejemplo n.º 11
0
 public function index()
 {
     $user = M('user')->find($this->uid);
     $this->assign('user', $user);
     //记录访客信息
     $this->assign('guest', $this->RecordGuest());
     //文章
     $ContentModel = ContentViewModel::getInstance(1);
     $where[] = 'user.uid=' . $this->uid;
     $page = new Page($ContentModel->where($where)->count(), 10);
     $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all();
     $this->assign('data', $data);
     $this->assign('page', $page->show());
     $this->display();
 }
Ejemplo n.º 12
0
 public function find($aid)
 {
     $ContentModel = ContentViewModel::getInstance($this->_mid);
     $data = $ContentModel->where($ContentModel->tableFull . '.aid=' . $aid)->find();
     if (!$data) {
         $this->error = '文章不存在';
         return false;
     }
     $ContentOutModel = new ContentOutModel($this->_mid);
     $data = $ContentOutModel->get($data);
     if ($data == false) {
         $this->error = $ContentOutModel->error;
     } else {
         return $data;
     }
 }
Ejemplo n.º 13
0
 public function category($cid, $page = 1)
 {
     $categoryCache = S('category');
     if (!isset($categoryCache[$cid])) {
         return false;
     }
     $cat = $categoryCache[$cid];
     $GLOBALS['totalPage'] = 0;
     if ($cat['cat_url_type'] == 2 || $cat['cattype'] == 3) {
         return true;
     }
     //单文章
     if ($cat['cattype'] == 4) {
         $Model = ContentViewModel::getInstance($cat['mid']);
         $result = $Model->where("category.cid={$cat['cid']}")->find();
         if ($result) {
             return $this->content($result);
         }
     } else {
         //模板文件
         switch ($cat['cattype']) {
             case 1:
                 //普通栏目
                 $template = 'Template/' . C("WEB_STYLE") . '/' . $cat['list_tpl'];
                 break;
             case 2:
                 //封面栏目
                 $template = 'Template/' . C("WEB_STYLE") . '/' . $cat['index_tpl'];
                 break;
         }
         //普通栏目与封面栏目
         $htmlDir = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
         $_REQUEST['page'] = $_GET['page'] = $page;
         $_REQUEST['mid'] = $cat['mid'];
         $_REQUEST['cid'] = $cat['cid'];
         $Model = ContentViewModel::getInstance($cat['mid']);
         $cat['content_num'] = $Model->where("category.cid ={$cat['cid']}")->count();
         $htmlFile = $htmlDir . str_replace(array('{catdir}', '{cid}', '{page}'), array($cat['catdir'], $cat['cid'], $page), $cat['cat_html_url']);
         $this->assign("hdcms", $cat);
         $this->createHtml(basename($htmlFile), dirname($htmlFile) . '/', $template);
         //第1页时复制index.html
         if ($page == 1) {
             copy($htmlFile, $htmlDir . $cat['catdir'] . '/index.html');
         }
         return true;
     }
 }
Ejemplo n.º 14
0
 public function category()
 {
     $mid = Q('mid', 0, 'intval');
     $cid = Q('cid', 0, 'intval');
     if (!$mid || !$cid) {
         $this->error('参数错误');
     }
     $categoryCache = cache('category');
     if (!isset($categoryCache[$cid])) {
         $this->error('栏目不存在', __ROOT__);
     }
     if ($cid) {
         $category = $categoryCache[$cid];
         //外部链接,直接跳转
         if ($category['cattype'] == 3) {
             go($category['cat_redirecturl']);
         } else {
             $Model = ContentViewModel::getInstance($mid);
             $where = C('DB_PREFIX') . 'category.cid=' . $cid . " OR pid=" . $cid;
             $category['content_num'] = $Model->join('category')->where($where)->count();
             $childCategory = Data::channelList($categoryCache, $cid);
             $catWhere = array('cid' => array());
             if (!empty($childCategory)) {
                 foreach ($childCategory as $cat) {
                     $catWhere['cid'][] = $cat['cid'];
                 }
             }
             $catWhere['cid'][] = $cid;
             $category['comment_num'] = intval(M('comment')->where($catWhere)->sum());
             //栏目模板
             switch ($category['cattype']) {
                 case 1:
                     //普通栏目
                     $tpl = $category['list_tpl'];
                     break;
                 case 2:
                     //封面栏目
                     $tpl = $category['index_tpl'];
                     break;
             }
             $tpl = 'template/' . C("WEB_STYLE") . '/' . $tpl;
             $this->assign("hdcms", $category);
             $this->display($tpl);
         }
     }
 }
Ejemplo n.º 15
0
 public function index()
 {
     if ($wd = Q('post.wd')) {
         go(U('index', array('wd' => $wd)));
     }
     $data = array();
     if (!($search_history = cookie('search_history'))) {
         $search_history = array();
     }
     if ($wd = Q('get.wd')) {
         $ContentModel = ContentViewModel::getInstance($this->mid);
         $where[] = "category.mid=" . $this->mid;
         $where[] = " title like '%{$wd}%'";
         //搜索时间
         if ($time = Q('get.time')) {
             switch ($time) {
                 case 'day':
                     $where[] = 'addtime>' . time() - 3600 * 24;
                     break;
                 case 'week':
                     $where[] = 'addtime>' . time() - 3600 * 24 * 7;
                     break;
                 case 'month':
                     $where[] = 'addtime>' . time() - 3600 * 24 * 7 * 30;
                     break;
                 case 'year':
                     $where[] = 'addtime>' . time() - 3600 * 24 * 7 * 30 * 12;
                     break;
             }
         }
         $page = new Page($ContentModel->where($where)->count(), 10);
         $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all();
         array_unshift($search_history, $wd);
         $search_history = array_unique($search_history);
         $search_history = array_slice($search_history, 0, 8);
         cookie('search_history', $search_history);
     }
     $this->assign('data', $data);
     $this->assign('search_history', $search_history);
     $this->assign('model', S('model'));
     //模型
     $this->assign('search_word', cookie('search_word'));
     $this->display();
 }
Ejemplo n.º 16
0
 public function add()
 {
     $ContentModel = ContentViewModel::getInstance($this->mid);
     $content = $ContentModel->where($ContentModel->table . '.aid=' . $this->aid)->find();
     $data['mid'] = $this->mid;
     $data['cid'] = $this->cid;
     $data['aid'] = $this->aid;
     $data['user_id'] = $_SESSION['user']['uid'];
     $data['title'] = $content['title'];
     $url = U('Index/Index/content', array('mid' => $this->mid, 'cid' => $this->cid, 'aid' => $this->aid));
     if ($this->db->where(array('mid' => array('EQ', $this->mid), 'aid' => array('EQ', $this->aid)))->find()) {
         $this->error('文章已经收藏', $url);
     }
     if ($this->db->add($data)) {
         $this->success('收藏成功');
     } else {
         $this->error('收藏失败。。。');
     }
 }
Ejemplo n.º 17
0
 public function find($aid)
 {
     $ContentModel = ContentViewModel::getInstance($this->_mid);
     $data = $ContentModel->where($ContentModel->tableFull . '.aid=' . $aid)->find();
     if (!$data) {
         $this->error = '文章不存在';
         return false;
     }
     $ContentOutModel = new ContentOutModel($this->_mid);
     $data = $ContentOutModel->get($data);
     if ($data == false) {
         $this->error = $ContentOutModel->error;
     } else {
         $data['time'] = date("Y/m/d", $data['addtime']);
         $data['caturl'] = Url::getCategoryUrl($data);
         //模板文件
         $template = empty($data['template']) ? $data['arc_tpl'] : $data['template'];
         $data['template'] = 'template/' . C('web_style') . '/' . $template;
         //是否为静态
         $data['iscontenthtml'] = $data['url_type'] == 1 || $data['url_type'] == 3 && $data['arc_url_type'] == 1;
         //静态文件
         $htmlDir = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
         $time = getdate($data['addtime']);
         if (!empty($data['html_path'])) {
             //单独设置
             $data['htmlfile'] = $htmlDir . $data['html_path'];
         } else {
             //使用栏目定义
             $data['htmlfile'] = $htmlDir . str_replace(array('{catdir}', '{y}', '{m}', '{d}', '{cid}', '{aid}', '{timestamp}'), array($data['catdir'], $time['year'], $time['mon'], $time['mday'], $data['cid'], $data['aid'], $data['addtime']), $data['arc_html_url']);
         }
         //用户头像数据
         if (empty($data['icon'])) {
             $data['icon'] = __ROOT__ . '/data/image/user/250.png';
         } else {
             $data['icon'] = __ROOT__ . '/' . $data['icon'];
         }
         return $data;
     }
 }
Ejemplo n.º 18
0
 public function category($cid, $page = 1)
 {
     $categoryCache = cache('category');
     $cat = $categoryCache[$cid];
     $GLOBALS['totalPage'] = 0;
     if ($cat['cat_url_type'] == 2 || $cat['cattype'] == 3) {
         return true;
     }
     //单文章
     if ($cat['cattype'] == 4) {
         $Model = ContentViewModel::getInstance($cat['mid']);
         $result = $Model->join()->where("cid={$cat['cid']}")->find();
         if ($result) {
             $Content = new Content($cat['mid']);
             $data = $Content->find($result['aid']);
             return $this->content($data);
         }
     } else {
         //普通栏目与封面栏目
         $htmlDir = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
         $_REQUEST['page'] = $_GET['page'] = $page;
         $_REQUEST['mid'] = $cat['mid'];
         $_REQUEST['cid'] = $cat['cid'];
         $Model = ContentViewModel::getInstance($cat['mid']);
         $catid = getCategory($cat['cid']);
         $cat['content_num'] = $Model->join()->where("cid IN(" . implode(',', $catid) . ")")->count();
         $cat['comment_num'] = intval(M('comment')->where("cid IN(" . implode(',', $catid) . ")")->count());
         $htmlFile = $htmlDir . str_replace(array('{catdir}', '{cid}', '{page}'), array($cat['catdir'], $cat['cid'], $page), $cat['cat_html_url']);
         $info = explode('.', $htmlFile);
         $this->assign("hdcms", $cat);
         $this->createHtml(basename($info[0]), dirname($htmlFile) . '/', $cat['template']);
         //第1页时复制index.html
         if ($page == 1) {
             copy($htmlFile, dirname($htmlFile) . '/index.html');
         }
         return true;
     }
 }
Ejemplo n.º 19
0
 public function BatchContent()
 {
     $createCategory = F('createContentFile');
     if (empty($createCategory)) {
         $this->success('所有文章生成完毕...', U('create_content'), 0);
     }
     $modelCache = cache('model');
     $categorycache = cache('category');
     $oldCategory = $createCategory;
     $htmlDir = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
     require 'hd/Hdcms/Index/Control/IndexControl.class.php';
     $Control = new IndexControl();
     foreach ($oldCategory as $id => $category) {
         $options = $category['options'];
         $contentModel = ContentViewModel::getInstance($category['mid']);
         $limit = $options['currentNum'] . ',' . $options['step_row'];
         $contentData = $contentModel->join('category')->where($options['where'])->limit($limit)->all();
         if (empty($contentData)) {
             unset($createCategory[$id]);
             F('createContentFile', $createCategory);
             $this->success("{$category['catname']}生成完毕...", __METH__, 0);
         }
         foreach ($contentData as $content) {
             $_REQUEST['cid'] = $category['cid'];
             $_REQUEST['mid'] = $category['mid'];
             $_REQUEST['aid'] = $content['aid'];
             $time = getdate($content['addtime']);
             $htmlFile = $htmlDir . str_replace(array('{catdir}', '{y}', '{m}', '{d}', '{aid}'), array($category['catdir'], $time['year'], $time['mon'], $time['mday'], $content['aid']), $category['arc_html_url']);
             ob_start();
             $Control->content();
             $content = ob_get_clean();
             if (!is_dir(dirname($htmlFile))) {
                 if (!Dir::create(dirname($htmlFile))) {
                     $this->error('创建目录失败');
                 }
             }
             if (file_put_contents($htmlFile, $content) === false) {
                 $this->error("{$htmlFile}创建失败");
             }
         }
         $options['currentNum'] = $options['currentNum'] + $options['step_row'] - 1;
         if ($options['currentNum'] >= $options['total_row']) {
             unset($createCategory[$id]);
             F('createContentFile', $createCategory);
             $this->success("[{$category['catname']}] 生成完毕...", __METH__, 0);
         } else {
             $createCategory[$id]['options'] = $options;
             F('createContentFile', $createCategory);
             $createCategory[$id]['options'] = $options;
             $message = "[{$category['catname']}]\n                                已经更新{$options['currentNum']}条\n                                (<font color='red'>" . floor($options['currentNum'] / $options['total_row'] * 100) . "%</font>)";
             $this->success($message, __METH__, 0);
         }
     }
 }
Ejemplo n.º 20
0
 public function content()
 {
     $ContentModel = ContentViewModel::getInstance($this->mid);
     //文章状态
     $content_status = Q('content_status', 0, 'intval');
     $where = array();
     $where['content_status'] = array('EQ', $content_status);
     //按时间搜索
     $search_begin_time = Q('search_begin_time', 0, 'strtotime');
     if ($search_begin_time) {
         $where['addtime'] = array('EGT', $search_begin_time);
     }
     $search_end_time = Q('search_end_time', null, 'strtotime');
     if ($search_end_time) {
         $where['addtime'] = array('ELT', $search_end_time);
     }
     //按flag搜索
     if ($flag = Q('flag')) {
         $where[] = "find_in_set('{$flag}',flag) AND ";
     }
     //按字段类型
     if (!empty($_POST['search_type']) && !empty($_POST['search_keyword'])) {
         $search_keyword = $_POST['search_keyword'];
         switch (strtolower($_POST['search_type'])) {
             case 1:
                 //标题
                 $where['title'] = array('like', "'%{$search_keyword}%'");
                 break;
             case 2:
                 //简介
                 $where['description'] = array('like', "'%{$search_keyword}%'");
                 break;
             case 3:
                 //用户名
                 $where['username'] = array('EQ', $search_keyword);
                 break;
             case 4:
                 //用户uid
                 $where[] = "user.uid ={$search_keyword}";
                 break;
         }
     }
     $where[] = "category.cid=" . $this->cid;
     $page = new Page($ContentModel->where($where)->count(), 15);
     $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all();
     $this->assign('flag', S('flag' . $this->mid));
     $this->assign('data', $data);
     $this->assign('page', $page->show());
     $this->display();
 }
Ejemplo n.º 21
0
 private function createHtml($aid)
 {
     $content = ContentViewModel::getInstance($this->mid)->getOne($aid);
     $html = new Html();
     //内容静态
     $html->content($content);
     //生成栏目
     $category = Data::parentChannel($this->category, $content['cid']);
     //生成当前栏目
     $html->relation_category($content['cid']);
     foreach ($category as $cat) {
         $html->relation_category($cat['cid']);
     }
     //生成首页
     $html->index();
     return true;
 }
Ejemplo n.º 22
0
 public function BatchContent()
 {
     $createCategory = S('createContentFile');
     if (empty($createCategory)) {
         $this->success('所有文章生成完毕...', U('createContent'), 0);
     }
     $html = new Html();
     $oldCategory = $createCategory;
     foreach ($oldCategory as $id => $category) {
         $options = $category['options'];
         $contentModel = ContentViewModel::getInstance($category['mid']);
         $limit = $options['currentNum'] . ',' . $options['step_row'];
         $contentData = $contentModel->where($options['where'])->limit($limit)->all();
         if (empty($contentData)) {
             unset($createCategory[$id]);
             S('createContentFile', $createCategory);
             $this->success("[{$category['catname']}]文章生成完毕...", __ACTION__, 0);
         }
         foreach ($contentData as $content) {
             $html->content($contentModel->getOne($content['aid']));
         }
         $options['currentNum'] = $options['currentNum'] + $options['step_row'] - 1;
         if ($options['currentNum'] >= $options['total_row']) {
             unset($createCategory[$id]);
             S('createContentFile', $createCategory);
             $this->success("[{$category['catname']}] 生成完毕...", __ACTION__, 0);
         } else {
             $createCategory[$id]['options'] = $options;
             S('createContentFile', $createCategory);
             $createCategory[$id]['options'] = $options;
             $message = "[{$category['catname']}]\n                                已经更新{$options['currentNum']}条\n                                (<font color='red'>" . floor($options['currentNum'] / $options['total_row'] * 100) . "%</font>)";
             $this->success($message, __ACTION__, 0);
         }
     }
 }
Ejemplo n.º 23
0
 public function BatchContent()
 {
     $this->RedirectInfo = F('RedirectInfo');
     $createCategory = F('createContentFile');
     if (empty($createCategory)) {
         if ($this->RedirectInfo) {
             $redirect = array_shift($this->RedirectInfo);
             F('RedirectInfo', $this->RedirectInfo);
             $this->success($redirect['title'], $redirect['url'], 0);
         } else {
             $this->success('所有文章生成完毕...', U('create_content'), 0);
         }
     }
     $html = new Html();
     $modelCache = cache('model');
     $categorycache = cache('category');
     $oldCategory = $createCategory;
     foreach ($oldCategory as $id => $category) {
         $options = $category['options'];
         $contentModel = ContentViewModel::getInstance($category['mid']);
         $limit = $options['currentNum'] . ',' . $options['step_row'];
         $contentData = $contentModel->join('category')->where($options['where'])->limit($limit)->all();
         if (empty($contentData)) {
             unset($createCategory[$id]);
             F('createContentFile', $createCategory);
             $this->success("[{$category['catname']}]文章生成完毕...", __METH__, 0);
         }
         $Content = new Content($category['mid']);
         foreach ($contentData as $content) {
             $html->content($Content->find($content['aid']));
         }
         $options['currentNum'] = $options['currentNum'] + $options['step_row'] - 1;
         if ($options['currentNum'] >= $options['total_row']) {
             unset($createCategory[$id]);
             F('createContentFile', $createCategory);
             $this->success("[{$category['catname']}] 生成完毕...", __METH__, 0);
         } else {
             $createCategory[$id]['options'] = $options;
             F('createContentFile', $createCategory);
             $createCategory[$id]['options'] = $options;
             $message = "[{$category['catname']}]\n                                已经更新{$options['currentNum']}条\n                                (<font color='red'>" . floor($options['currentNum'] / $options['total_row'] * 100) . "%</font>)";
             $this->success($message, __METH__, 0);
         }
     }
 }
Ejemplo n.º 24
0
							猜你喜欢
						</header>
						        <?php 
$mid = '';
$cid = '';
$subtable = '';
$order = '';
$flag = '';
$noflag = '1';
$aid = '';
$type = 'new';
$sub_channel = 1;
$mid = $mid ? $mid : Q('mid', 1, 'intval');
$cid = !empty($cid) ? $cid : Q('cid', 0, 'intval');
//导入模型类
$db = ContentViewModel::getInstance($mid);
//主表(有表前缀)
$table = $db->tableFull;
//获取副表字段
if (empty($subtable)) {
    $db->join('category,user');
}
//---------------------------排序类型-------------------------------
switch ($type) {
    case 'hot':
        //查看次数最多
        $db->order('click DESC');
        break;
    case 'rand':
        //随机排序
        $db->order('rand()');
Ejemplo n.º 25
0
 public function getClick()
 {
     $ContentModel = ContentViewModel::getInstance($this->mid);
     $ContentModel->inc('click', 'aid=' . $this->aid, 1);
     $click = $ContentModel->where(array($ContentModel->table . '.aid' => $this->aid))->getField('click');
     echo "document.write({$click});";
     exit;
 }