<?php

if (isset($related_topic_list)) {
    ?>
<div class="panel panel-default">
<div class='panel-heading'>
<h3 class="panel-title">相关话题</h3>
</div>
<div class="panel-body">
<ul class="list-unstyled">
<?php 
    foreach ($related_topic_list as $v) {
        ?>
<li><a href="<?php 
        echo site_url('topic/show/' . $v['topic_id']);
        ?>
" class="text-muted"><?php 
        echo sb_substr($v['title'], 20);
        ?>
</a></li>
<?php 
    }
    ?>
</ul>
</div>
</div>
<?php 
}
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">最新贴子</h3>
    </div>
    <div class="panel-body">
    <ul class="list-unstyled">
    <?php 
if (isset($new_topics)) {
    foreach ($new_topics as $v) {
        ?>
        <li>
            <span><a href="<?php 
        echo url('topic_show', $v['topic_id']);
        ?>
" class="startbbs"><?php 
        echo sb_substr($v['title'], 14);
        ?>
</a><span class="pull-right gray"><?php 
        echo $this->myclass->friendly_date($v['updatetime']);
        ?>
</span></span>
        </li>
<?php 
    }
}
?>
    </ul>
    </div>
</div>
Exemple #3
0
 public function show($topic_id = 1, $page = 1)
 {
     $content = $this->topic_m->get_topic_by_topic_id($topic_id);
     if (!$content) {
         show_message('贴子不存在', site_url('/'));
     } elseif (!$this->auth->user_permit($content['node_id'])) {
         //权限
         show_message('您无权访问此节点中的贴子');
     } else {
         //$this->output->cache(1);
         $content = $this->topic_m->get_topic_by_topic_id($topic_id);
         //取出处理
         $content['content'] = stripslashes($content['content']);
         $data['content'] = $content;
         //if(!$content){
         //	$this->myclass->notice('alert("贴子不存在");window.location.href="'.site_url('/').'";');
         //	exit;
         //}
         //更新浏览数
         $this->db->where('topic_id', $content['topic_id'])->update('topics', array('views' => $content['views'] + 1));
         //评论分页
         $limit = 10;
         $config['uri_segment'] = 4;
         $config['use_page_numbers'] = TRUE;
         $config['base_url'] = site_url('topic/show/' . $topic_id);
         $config['total_rows'] = @$content['comments'];
         $config['per_page'] = $limit;
         $config['prev_link'] = '&larr;';
         $config['first_link'] = '首页';
         $config['last_link'] = '尾页';
         $config['prev_tag_open'] = '<li class=\'prev\'>';
         $config['prev_tag_close'] = '</li';
         $config['cur_tag_open'] = '<li class=\'active\'><span>';
         $config['cur_tag_close'] = '</span></li>';
         $config['num_tag_open'] = '<li>';
         $config['num_tag_close'] = '</li>';
         $config['next_link'] = '&rarr;';
         $config['next_tag_open'] = '<li class=\'next\'>';
         $config['next_tag_close'] = '</li>';
         $config['last_link'] = '尾页';
         $config['last_tag_open'] = '<li class=\'last\'>';
         $config['last_tag_close'] = '</li>';
         $config['num_links'] = 10;
         $this->load->library('pagination');
         $this->pagination->initialize($config);
         $start = ($page - 1) * $limit;
         $data['page'] = $page;
         $data['pagination'] = $this->pagination->create_links();
         //获取评论
         $this->load->model('comment_m');
         $data['comment'] = $this->comment_m->get_comment($start, $limit, $topic_id, $this->config->item('comment_order'));
         //获取当前分类
         $data['cate'] = $this->db->get_where('nodes', array('node_id' => $content['node_id']))->row_array();
         //上下主题
         $data['content']['previous'] = $this->topic_m->get_near_id($topic_id, $data['cate']['node_id'], 0);
         $data['content']['next'] = $this->topic_m->get_near_id($topic_id, $data['cate']['node_id'], 1);
         $data['content']['previous'] = $data['content']['previous']['topic_id'];
         $data['content']['next'] = $data['content']['next']['topic_id'];
         // 判断是不是已被收藏
         $data['in_favorites'] = '';
         $uid = $this->session->userdata('uid');
         if ($uid) {
             $user_fav = $this->db->get_where('favorites', array('uid' => $uid))->row_array();
             if ($user_fav && $user_fav['content']) {
                 if (strpos(' ,' . $user_fav['content'] . ',', ',' . $topic_id . ',')) {
                     $data['in_favorites'] = '1';
                 }
             }
         }
         //关键字tag
         if ($content['keywords']) {
             $data['tags'] = explode(',', $content['keywords']);
             $data['content']['keywords'] = $content['keywords'];
         } else {
             $data['content']['keywords'] = $content['title'];
         }
         //描述
         $data['content']['description'] = sb_substr(cleanhtml($content['content']), 200);
         //自定义tag_url
         $data['tag_url'] = array_keys($this->router->routes, 'tag/show/$1');
         if (is_array(@$data['tags'])) {
             foreach ($data['tags'] as $k => $v) {
                 $data['tag_list'][$k]['tag_title'] = $v;
                 $data['tag_list'][$k]['tag_url'] = str_replace('(:any)', urlencode($v), $data['tag_url'][0]);
             }
         }
         //相关贴子
         if (isset($data['tags'])) {
             $this->load->model('tag_m');
             $data['related_topic_list'] = $this->tag_m->get_related_topics_by_tag($data['tags'], 10);
         }
         //set top
         if (@$_GET['act'] == 'set_top') {
             if ($this->auth->is_admin() || $this->auth->is_master($content['node_id'])) {
                 $this->topic_m->set_top($content['topic_id'], $content['is_top']);
                 redirect('topic/show/' . $content['topic_id']);
             } else {
                 show_message('你无权置顶贴子');
             }
         }
         //开启storage config
         $this->load->config('qiniu');
         //获取分类
         $this->load->model('cate_m');
         $data['catelist'] = $this->cate_m->get_all_cates();
         $data['csrf_name'] = $this->security->get_csrf_token_name();
         $data['csrf_token'] = $this->security->get_csrf_hash();
         $this->load->view('topic_show', $data);
     }
 }