Exemple #1
0
 /**
  * 列表
  */
 public function listc()
 {
     // 接收参数
     $kw = $this->input->get('kw', TRUE);
     $cid = (int) $this->input->get('cid');
     $order = dr_get_order_string(isset($_GET['order']) && strpos($_GET['order'], "undefined") !== 0 ? $this->input->get('order', TRUE) : 'inputtime desc', 'inputtime desc');
     // 相关文档
     $cdata = $this->_get_data($cid);
     if (!$cdata) {
         $this->member_msg(dr_lang('mod-30', $cid));
     }
     if ($cdata['uid'] != $this->uid) {
         $this->member_msg(lang('mod-05'));
     }
     // 组合条件
     $this->link->where('cid', $cid);
     if ($kw) {
         $this->link->like('subject', $kw);
     }
     $this->link->order_by($order);
     if ($this->input->get('action') == 'search') {
         // ajax请求
         $page = max((int) $this->input->get('page'), 1);
         $data = $this->link->limit($this->pagesize, $this->pagesize * ($page - 1))->get($this->table)->result_array();
         if (!$data) {
             exit('null');
         }
         $this->template->assign(array('list' => $data));
         $this->template->display(is_file(APPPATH . 'templates/member/' . MEMBER_TEMPLATE . '/mform_cdata_' . $this->form['table'] . '.html') ? 'mform_cdata_' . $this->form['table'] . '.html' : 'mform_cdata.html');
     } else {
         // 首次请求
         $this->template->assign(array('list' => $this->link->limit($this->pagesize)->get($this->table)->result_array(), 'datatpl' => is_file(APPPATH . 'templates/member/' . MEMBER_TEMPLATE . '/mform_cdata_' . $this->form['table'] . '.html') ? 'mform_cdata_' . $this->form['table'] . '.html' : 'mform_cdata.html', 'searchurl' => 'index.php?s=' . APP_DIR . '&c=' . $this->router->class . '&m=listc&action=search&cid=' . $cid . '&kw=' . $kw . '&order=' . $order, 'meta_name' => $cdata['title']));
         $this->template->display(is_file(APPPATH . 'templates/member/' . MEMBER_TEMPLATE . '/mform_listc_' . $this->form['table'] . '.html') ? 'mform_index_' . $this->form['table'] . '.html' : 'mform_listc.html');
     }
 }
 /**
  * 管理
  */
 public function index()
 {
     // 作者判断
     if ($this->content['uid'] != $this->uid) {
         $this->member_msg(lang('mod-05'));
     }
     if (IS_POST) {
         // 判断id是否为空
         $ids = $this->input->post('ids', TRUE);
         if (!$ids) {
             exit(dr_json(0, lang('019')));
         }
         if ($this->input->post('action') == 'update') {
             $_data = $this->input->post('data');
             foreach ($ids as $id) {
                 $this->link->where('id', $id)->update(SITE_ID . '_' . APP_DIR . '_extend', $_data[$id]);
             }
             exit(dr_json(1, lang('000')));
         }
     }
     $this->link->where('uid', $this->uid)->where('cid', (int) $this->content['id']);
     // 搜索关键字
     $kw = $this->input->get('kw', TRUE);
     if ($kw) {
         $this->link->like('name', $kw);
     }
     // 搜索类型
     $type = (int) $this->input->get('type');
     if ($type) {
         $this->link->where('mytype', $type);
     }
     // 排序
     $order = dr_get_order_string(isset($_GET['order']) && strpos($_GET['order'], "undefined") !== 0 ? $this->input->get('order', TRUE) : 'displayorder desc', 'displayorder desc');
     $this->link->order_by($order . ',id desc');
     if ($this->input->get('action') == 'search') {
         // ajax搜索数据
         $page = max((int) $this->input->get('page'), 1);
         $data = $this->link->limit($this->pagesize, $this->pagesize * ($page - 1))->get(SITE_ID . '_' . APP_DIR . '_extend')->result_array();
         if (!$data) {
             exit('null');
         }
         $this->template->assign(array('kw' => $kw, 'list' => $data));
         $this->template->display('content_extend_data.html');
     } else {
         $url = 'index.php?s=' . APP_DIR . '&c=extend&m=index&cid=' . $this->content['id'] . "&action=search&kw={$kw}&order={$order}&type={$type}";
         $this->template->assign(array('kw' => $kw, 'list' => $this->link->limit($this->pagesize)->get(SITE_ID . '_' . APP_DIR . '_extend')->result_array(), 'total' => $this->total[1], 'order' => $order, 'extend' => $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'extend'), 'moreurl' => $url, 'searchurl' => $url, 'meta_name' => lang('mod-01')));
         $this->template->display('content_extend_index.html');
     }
 }
 /**
  * 数据分页显示
  *
  * @param	array	$param	条件参数
  * @param	intval	$page	页数
  * @param	intval	$total	总数据
  * @return	array
  */
 public function feed_limit_page($param, $page, $total)
 {
     if (!$total || IS_POST) {
         $select = $this->db->select('count(*) as total');
         $this->_feed_where($select, $param);
         $data = $select->get('sns_feed')->row_array();
         unset($select);
         $total = (int) $data['total'];
         if (!$total) {
             return array(array(), array('total' => 0));
         }
         $page = 1;
     }
     $select = $this->db->limit(SITE_ADMIN_PAGESIZE, SITE_ADMIN_PAGESIZE * ($page - 1));
     list($_param, $_search) = $this->_feed_where($select, $param);
     $order = dr_get_order_string(isset($_GET['order']) && strpos($_GET['order'], "undefined") !== 0 ? $this->input->get('order', TRUE) : 'inputtime desc', 'inputtime desc');
     $data = $select->order_by($order)->get('sns_feed')->result_array();
     $_param['total'] = $total;
     $_param['order'] = $order;
     return array($data, $_param, $_search);
 }
 /**
  * 管理
  */
 public function index()
 {
     if (IS_POST) {
         // 判断id是否为空
         $ids = $this->input->post('ids', TRUE);
         if (!$ids) {
             exit(dr_json(0, lang('019')));
         }
         if ($this->input->post('action') == 'update') {
             // 虚拟币检查
             if ($this->member_rule['update_score'] + $this->member['score'] < 0) {
                 exit(dr_json(0, dr_lang('mod-08', abs($this->member_rule['update_score']), $this->member['score'])));
             }
             // 积分检查
             $this->member_model->update_score(0, $this->uid, (int) $this->member_rule['update_experience'], '', "lang,m-150");
             // 虚拟币
             $this->member_model->update_score(1, $this->uid, (int) $this->member_rule['update_score'], '', "lang,m-150");
             // 更新文档时间
             $this->content_model->updatetime($ids);
             exit(dr_json(1, lang('mod-12')));
         } else {
             $i = (int) $this->input->post('flag');
             if (!isset($this->flag[$i])) {
                 exit(dr_json(0, lang('mod-14')));
             }
             $count = count($ids);
             $value = abs($this->flag[$i][$this->markrule] * $count);
             // 虚拟币检查
             if ($this->member['score'] - $value < 0) {
                 exit(dr_json(0, dr_lang('mod-11', $value, $this->member['score'])));
             }
             $total = $this->content_model->flag($ids, $i);
             if ($total) {
                 // 虚拟币
                 $value = abs($this->flag[$i][$this->markrule] * $total);
                 $this->member_model->update_score(1, $this->uid, -$value, '', "lang,m-181," . $total);
                 exit(dr_json(1, lang('000')));
             }
             exit(dr_json(0, lang('mod-13')));
         }
     }
     $kw = $this->input->get('kw', TRUE);
     $catid = (int) $this->input->get('catid');
     $order = dr_get_order_string(isset($_GET['order']) && strpos($_GET['order'], "undefined") !== 0 ? $this->input->get('order', TRUE) : 'updatetime desc', 'updatetime desc');
     $this->link->where('uid', $this->uid)->where_in('catid', $this->catid)->where('status', 9);
     // 模块表单嵌入
     $form = array();
     $data = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'form');
     if ($data) {
         foreach ($data as $t) {
             if (!$t['permission'][$this->markrule]['disabled']) {
                 $form[] = array('url' => dr_url(APP_DIR . '/form_' . $t['table'] . '/listc'), 'name' => $t['name'], 'field' => $t['table'] . '_total');
             }
         }
     }
     // 搜索关键字
     if ($kw) {
         $this->link->like('title', $kw);
     }
     // 搜索栏目
     if ($catid) {
         $this->link->where_in('catid', explode(',', $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category', $catid, 'childids')));
     }
     // 排序
     $this->link->order_by($order);
     if ($this->input->get('action') == 'search') {
         // ajax搜索数据
         $page = max((int) $this->input->get('page'), 1);
         $data = $this->link->limit($this->pagesize, $this->pagesize * ($page - 1))->get($this->content_model->prefix)->result_array();
         if (!$data) {
             exit('null');
         }
         $this->template->assign(array('kw' => $kw, 'form' => $form, 'list' => $data));
         $this->template->display('content_data.html');
     } else {
         $url = 'index.php?s=' . APP_DIR . '&c=home&m=index&action=search&catid=' . $catid . '&order=' . $order . '&kw=' . $kw;
         $this->template->assign(array('kw' => $kw, 'form' => $form, 'list' => $this->link->limit($this->pagesize)->get($this->content_model->prefix)->result_array(), 'order' => $order, 'extend' => $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'extend'), 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), $catid, 'id=\'dr_catid\' name=\'catid\'', ' -- ', 1, 1), 'moreurl' => $url, 'flagdata' => $this->flag, 'meta_name' => lang('mod-01'), 'searchurl' => $url));
         $this->template->display('content_index.html');
     }
 }
 public function limit_page($param, $page, $total)
 {
     if (!$total) {
         $select = $this->db->select('count(*) as total');
         $_param = $this->_where($select, $param);
         if ($_param) {
             $select->order_by('id');
         }
         $data = $select->get($this->tablename)->row_array();
         unset($select);
         $total = (int) $data['total'];
         if (!$total) {
             return array(array(), array('total' => 0));
         }
     }
     $select = $this->db->limit(SITE_ADMIN_PAGESIZE, SITE_ADMIN_PAGESIZE * ($page - 1));
     $_param = $this->_where($select, $param);
     $order = dr_get_order_string(isset($_GET['order']) && strpos($_GET['order'], "undefined") !== 0 ? $this->input->get('order', TRUE) : 'updatetime desc', 'updatetime desc');
     $data = $select->order_by($order)->get($this->tablename)->result_array();
     $_param['total'] = $total;
     $_param['order'] = $order;
     return array($data, $_param);
 }
 /**
  * 数据分页显示
  *
  * @param	array	$param	条件参数
  * @param	intval	$page	页数
  * @param	intval	$total	总数据
  * @return	array	
  */
 public function limit_page($param, $page, $total)
 {
     if (!$total) {
         $select = $this->db->select('count(*) as total');
         $this->_where($select, $param);
         $data = $select->get(isset($param['flag']) ? 'space_flag' : 'space')->row_array();
         unset($select);
         $total = (int) $data['total'];
         if (!$total) {
             return array(array(), array('total' => 0));
         }
     }
     $select = $this->db;
     $this->_where($select, $param);
     if (isset($param['flag'])) {
         $flag = $this->db->where('flag', (int) $param['flag'])->get('space_flag')->result_array();
         if ($flag) {
             $in = array();
             foreach ($flag as $t) {
                 $in[] = $t['uid'];
             }
             $select->where_in('space.uid', $in);
             unset($in);
         }
         unset($flag);
     }
     if (isset($_GET['order']) && strpos($_GET['order'], "undefined") !== 0) {
         $order = dr_get_order_string($this->input->get('order', TRUE), 'updatetime desc');
         list($field, $a) = explode(' ', $order);
         if (in_array($field, array('username', 'groupid'))) {
             $torder = 'member.' . $order;
         } else {
             $torder = 'space.' . $order;
         }
         unset($field, $a);
     } else {
         $order = 'regtime DESC';
         $torder = 'space.' . $order;
     }
     $data = $select->select('space.*,member.`username`,member.`groupid`')->from('space')->join('member', 'space.uid = member.uid', 'left')->limit(SITE_ADMIN_PAGESIZE, SITE_ADMIN_PAGESIZE * ($page - 1))->order_by($torder)->get()->result_array();
     $param['total'] = $total;
     $param['order'] = $order;
     return array($data, $param);
 }