国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

【phpcms-v9】前臺{pc}專題標簽調用類分析

2024-09-10 07:15:46
字體:
來源:轉載
供稿:網友
  1. <?php   
  2. /**  
  3.  * special_tag.class.php 專題標簽調用類  
  4.  * @author   
  5.  *  
  6.  */   
  7. class special_tag {   
  8.     private $db$c;   
  9.        
  10.     public function __construct() {   
  11.         $this->db = pc_base::load_model('special_model');//專題表:special   
  12.         $this->c = pc_base::load_model('special_content_model');//專題文章表:spscial_content   
  13.     }   
  14.        
  15.     /**  
  16.      * lists調用方法  
  17.      * @param array $data 標簽配置傳遞過來的配置數組,根據配置生成sql  
  18.      */   
  19.     public function lists($data) {   
  20.         $siteid = $data['siteid'] ? intval($data['siteid']) : get_siteid();//當前站點id   
  21.         $where .= "`siteid`='".$siteid."'";//pc標簽的siteid屬性:當前站點專題   
  22.         if ($data['elite']) $where .= " AND `elite`='1'";//pc標簽的elite屬性:推薦專題   
  23.         if ($data['thumb']) $where .= " AND `thumb`!=''"//pc標簽的thumb屬性:有縮略圖的專題   
  24.         if ($data['disable']) {   
  25.             $where .= " AND `disabled`='".$data['disable']."'";//是否啟用:0-啟用 1-禁用   
  26.         }else{   
  27.             $where .= " AND `disabled`='0'";//默認顯示,正常顯示的專題。   
  28.         }   
  29.         //專題的排序方式:0-按照id升序   1-按id降序      2-按listorder升序,id降序   3-按listorder降序,id降序   
  30.         $listorder = array('`id` ASC''`id` DESC''`listorder` ASC, `id` DESC''`listorder` DESC, `id` DESC');   
  31.         //查詢專題表   
  32.         return $this->db->select($where'*'$data['limit'], $listorder[$data['listorder']]);   
  33.     }   
  34.        
  35.     /**  
  36.      * 標簽中計算分頁的方法,解析標簽時會通過此方法計算分頁信息  
  37.      * @param array $data 標簽配置數組,根據數組計算出分頁  
  38.      */   
  39.     public function count($data) {   
  40.         $where = '1';   
  41.         if($data['action'] == 'lists') {   
  42.             $where = '1';   
  43.             if ($data['siteid']) $where .= " AND `siteid`='".$data['siteid']."'";//站點id   
  44.             if ($data['elite']) $where .= " AND `elite`='1'";//推薦專題   
  45.             if ($data['thumb']) $where .= " AND `thumb`!=''"//縮略圖   
  46.             //相當于 select count(id) as totle from gt_special $where   
  47.             $r = $this->db->get_one($where'COUNT(id) AS total');//專題總數   
  48.         } elseif ($data['action'] == 'content_list') {//如果要調用專題文章列表   
  49.             if ($data['specialid']) $where .= " AND `specialid`='".$data['specialid']."'";//專題id   
  50.             if ($data['typeid']) $where .= " AND `typeid`='".$data['typeid']."'";//類別id   
  51.             if ($data['thumb']) $where .= " AND `thumb`!=''";//縮略圖   
  52.             $r = $this->c->get_one($where'COUNT(id) AS total');//查詢到的專題文章總數   
  53.         } elseif ($data['action'] == 'hits') {//如果要調用點擊量信息   
  54.             $hitsid = 'special-c';   
  55.             if ($data['specialid']) $hitsid .= $data['specialid'].'-';   
  56.             else $hitsid .= '%-';   
  57.             $hitsid = $hitsid .= '%';   
  58.             $hits_db = pc_base::load_model('hits_model');   
  59.             $sql = "hitsid LIKE '$hitsid'";   
  60.             $r = $hits_db->get_one($sql'COUNT(*) AS total');//點擊排行文章總數   
  61.         }   
  62.         return $r['total'];   
  63.     }   
  64.        
  65.     /**  
  66.      * 點擊排行調用方法  
  67.      * @param array $data 標簽配置數組  
  68.      */   
  69.     public function hits($data) {   
  70.         $hitsid = 'special-c-';//hits表中hitsid字段的組成   
  71.         if ($data['specialid']) $hitsid .= $data['specialid'].'-';//如果專題id存在,則查詢當前專題下的專題文章   
  72.         else $hitsid .= '%-';//如果專題id不存在,則查詢所有的專題文章   
  73.         $hitsid = $hitsid .= '%';   
  74.         $this->hits_db = pc_base::load_model('hits_model');//hits表   
  75.         $sql = "hitsid LIKE '$hitsid'";//拼接sql   
  76.         //排序方式:0-按總訪問量降序排列      1-按昨日訪問量降序排列    2-按今日訪問量降序排列   3-按本周訪問量降序排列   4-按本月訪問量降序排列   
  77.         $listorders = array('views DESC''yesterdayviews DESC''dayviews DESC''weekviews DESC''monthviews DESC');   
  78.         //查詢點擊量表   
  79.         $result = $this->hits_db->select($sql'*'$data['limit'], $listorders[$data['listorder']]);   
  80.         foreach ($result as $key => $r) {   
  81.             $ids = explode('-'$r['hitsid']);//hits表中hitsid字段拆分,如:special-c-1-1   
  82.             $id = $ids[3];//當前專題文章的id   
  83.             //查詢專題文章主表   
  84.             $re = $this->c->get_one(array('id'=>$id));//從專題文章表special_content中獲取當前專題文章的內容   
  85.             $result[$key]['title'] = $re['title'];//專題文章的標題   
  86.             $result[$key]['url'] = $re['url'];//專題文章的url   
  87.         }   
  88.         return $result;   
  89.     }   
  90.        
  91.     /**  
  92.      * 內容列表調用方法  
  93.      * @param array $data 標簽配置數組  
  94.      */   
  95.     public function content_list($data) {   
  96.         $where = '1';   
  97.         if ($data['specialid']) $where .= " AND `specialid`='".$data['specialid']."'";//專題id   
  98.         if ($data['typeid']) $where .= " AND `typeid`='".$data['typeid']."'";//專題類別id   
  99.         if ($data['thumb']) $where .= " AND `thumb`!=''";//縮略圖   
  100.         //排序方式:0-id升序   1-id降序   2-listorder升序   3-listorder降序   
  101.         $listorder = array('`id` ASC''`id` DESC''`listorder` ASC''`listorder` DESC');   
  102.         //查詢專題文章主表   
  103.         $result = $this->c->select($where'*'$data['limit'], $listorder[$data['listorder']]);   
  104.         if (is_array($result)) {   
  105.             foreach($result as $k => $r) {   
  106.                 if ($r['curl']) {//是否為信息導入:導入原文章的欄目id和文章id   
  107.                     $content_arr = explode('|'$r['curl']);   
  108.                     $r['url'] = go($content_arr['1'], $content_arr['0']);//參數1:欄目id   參數2:文章id   
  109.                 }   
  110.                 $res[$k] = $r;//專題文章主表中的記錄   
  111.             }   
  112.         } else {   
  113.             $res = array();   
  114.         }   
  115.         return $res//返回專題文章表中查詢到的記錄   
  116.     }   
  117.        
  118.     /**  
  119.      * 獲取專題分類方法  
  120.      * @param intval $specialid 專題ID  
  121.      * @param string $value 默認選中值  
  122.      * @param intval $id onchange影響HTML的ID  
  123.      *   
  124.      */   
  125.     public function get_type($specialid = 0, $value = ''$id = '') {   
  126.         $type_db = pc_base::load_model('type_model');//類別表   
  127.         $data = $arr = array();   
  128.         //查詢類別表   
  129.         $data = $type_db->select(array('module'=>'special''parentid'=>$specialid));   
  130.         //表單類   
  131.         pc_base::load_sys_class('form''', 0);   
  132.         foreach($data as $r) {   
  133.             $arr[$r['typeid']] = $r['name'];//類別名稱   
  134.         }   
  135.         $html = $id ? ' id="typeid" onchange="$(/'#'.$id.'/').val(this.value);"' : 'name="typeid", id="typeid"';   
  136.         return form::select($arr$value$html, L('please_select'));//請選擇所屬類別   
  137.     }   
  138.        
  139.     /**  
  140.      * 標簽生成方法  
  141.      */   
  142.     public function pc_tag() {   
  143.         //獲取站點   
  144.         $sites = pc_base::load_app_class('sites','admin');   
  145.         $sitelist = $sites->pc_tag_list();   
  146.            
  147.         $result = getcache('special''commons');   
  148.         if(is_array($result)) {   
  149.             $specials = array(L('please_select'));   
  150.             foreach($result as $r) {   
  151.                 if($r['siteid']!=get_siteid()) continue;   
  152.                 $specials[$r['id']] = $r['title'];   
  153.             }   
  154.         }   
  155.         return array(   
  156.             'action'=>array('lists'=>L('special_list''''special'), 'content_list'=>L('content_list''''special'), 'hits'=>L('hits_order','','special')),   
  157.             'lists'=>array(   
  158.                 'siteid'=>array('name'=>L('site_id','','comment'), 'htmltype'=>'input_select''data'=>$sitelist),   
  159.                 'elite'=>array('name'=>L('iselite''''special'), 'htmltype'=>'radio''defaultvalue'=>'0''data'=>array(L('no'), L('yes'))),   
  160.                 'thumb'=>array('name'=>L('get_thumb''''special'), 'htmltype'=>'radio','defaultvalue'=>'0','data'=>array(L('no'), L('yes'))),   
  161.                 'listorder'=>array('name'=>L('order_type''''special'), 'htmltype'=>'select''defaultvalue'=>'3''data'=>array(L('id_asc''''special'), L('id_desc''','special'), L('order_asc','','special'), L('order_desc''','special'))),   
  162.             ),   
  163.             'content_list'=>array(   
  164.                 'specialid'=>array('name'=>L('special_id','','special'),'htmltype'=>'input_select''data'=>$specials'ajax'=>array('name'=>L('for_type','','special'), 'action'=>'get_type''id'=>'typeid')),   
  165.                 'thumb'=>array('name'=>L('content_thumb','','special'),'htmltype'=>'radio','defaultvalue'=>'0','data'=>array(L('no'), L('yes'))),   
  166.                 'listorder'=>array('name'=>L('order_type''''special'), 'htmltype'=>'select''defaultvalue'=>'3''data'=>array(L('id_asc''''special'), L('id_desc''','special'), L('order_asc','','special'), L('order_desc''','special'))),   //開源軟件:Vevb.com 
  167.             ),   
  168.             'hits' => array(   
  169.                 'specialid' => array('name'=>L('special_id','','special'), 'htmltype'=>'input_select''data'=>$specials),   
  170.                 'listorder' => array('name' => L('order_type''''special'), 'htmltype' => 'select''data'=>array(L('total','','special'), L('yesterday''','special'), L('today','','special'), L('week','','special'), L('month','','special'))),   
  171.             ),   
  172.         );   
  173.     }   
  174. }   
  175. ?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 遂平县| 布拖县| 肥乡县| 黔西县| 卓尼县| 忻州市| 微山县| 津市市| 瑞昌市| 苍梧县| 泽库县| 绥江县| 江孜县| 新龙县| 弥渡县| 江源县| 长宁县| 额济纳旗| 晋宁县| 光泽县| 易门县| 泽普县| 饶阳县| 嘉兴市| 紫金县| 堆龙德庆县| 常山县| 海盐县| 禄丰县| 云阳县| 彭州市| 赤水市| 内丘县| 长宁县| 根河市| 夏邑县| 上蔡县| 赤水市| 蒙阴县| 凤山市| 德令哈市|