Ejemplo n.º 1
0
 /**
  * UserCompetenceAct::actIndex()
  * 列出符合条件的数据并分页显示
  * @param string $condition 查询条件
  * @param integer $curpage 页码
  * @param integer $pagenum 每页个数
  * @return array 
  */
 public function actIndex()
 {
     $data = array();
     $condition = '';
     //接收参数生成条件
     $curpage = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1;
     $type = isset($_GET['type']) ? trim($_GET['type']) : '';
     $key = isset($_GET['key']) ? post_check(trim($_GET['key'])) : '';
     $condition .= "1";
     if ($type && $key) {
         if (!in_array($type, array('competence'))) {
             redirect_to("index.php?mod=userCompetence&act=index");
         }
         $condition .= ' AND ' . $type . " = '" . $key . "'";
     }
     //获取符合条件的数据并分页
     $pagenum = 20;
     $total = UserCompetenceModel::modListCount($condition);
     $res = UserCompetenceModel::modList($condition, $curpage, $pagenum);
     $page = new Page($total, $pagenum, '', 'CN');
     $pageStr = "";
     if ($res) {
         if ($total > $pagenum) {
             $pageStr = $page->fpage(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
         } else {
             $pageStr = $page->fpage(array(0, 1, 2, 3));
         }
     } else {
         $pageStr = '暂无数据';
     }
     //封装数据返回
     $data['key'] = $key;
     $data['type'] = $type;
     $data['lists'] = $res;
     $data['pages'] = $pageStr;
     self::$errCode = UserCompetenceModel::$errCode;
     self::$errMsg = UserCompetenceModel::$errMsg;
     if (self::$errCode != 0) {
         show_message($this->smarty, self::$errMsg, "");
         return false;
     }
     return $data;
 }