當前位置: 首頁>>代碼示例>>PHP>>正文


PHP helper::pagebar方法代碼示例

本文整理匯總了PHP中helper::pagebar方法的典型用法代碼示例。如果您正苦於以下問題:PHP helper::pagebar方法的具體用法?PHP helper::pagebar怎麽用?PHP helper::pagebar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在helper的用法示例。


在下文中一共展示了helper::pagebar方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_area

 /**
  * 根據位置ID獲取(專題,推薦)
  * 如果是廣告,則輸出廣告代碼,如果是專題或者推薦信息則輸出列表
  *
  * @param  $ 參數數組
  * @param  $area_id 位置ID
  * @param  $pagesize 分頁大小
  * @param  $p 當前分頁
  * @param  $count 是否統計分頁
  * @param  $where 查詢條件
  * @param  $order 專題內文檔排序方式,默認為排序升序
  */
 function get_area($params)
 {
     $area_id = isset($params['area_id']) ? $params['area_id'] : 0;
     $pagesize = isset($params['pagesize']) ? $params['pagesize'] : PAGESIZE_F;
     $p = isset($params['p']) ? $params['p'] : 1;
     $count = isset($params['count']) ? $params['count'] : 0;
     $where = isset($params['where']) ? $params['where'] : '';
     $rewrite = isset($params['rewrite']) ? $params['rewrite'] : 2;
     $order = isset($params['order']) ? $params['order'] : '';
     if (!is_numeric($area_id)) {
         return array();
     }
     if ($area_id == 0) {
         // 如果位置ID=0,則取列表
         $recommend_list = array();
         $sql = "select * from " . TB_PREFIX . "recommend_area ";
         if ($where != '') {
             $sql .= " where {$where}";
         }
         $suffix = " order by area_order asc,area_id desc";
         // 拚接分頁數據
         $suffix .= " limit " . ($p - 1) * $pagesize . ",{$pagesize}";
         $result = $this->dbm->query($sql, $suffix, $count);
         //print_r($result);
         //生成surl
         $count = count($result['list']);
         for ($i = 0; $i < $count; $i++) {
             $result['list'][$i]['surl'] = $this->url->encode('special_content', array('host' => SITE_PATH, 'id' => $result['list'][$i]['area_id']));
         }
         $total = $result['total'];
         // 分頁碼HTML
         if ($rewrite == 0 || $rewrite == 1) {
             // 前台使用動態地址或者偽靜態地址
             if ($this->url != null) {
                 $result['pagebar'] = helper::pagebar(array('total' => $total, 'pagesize' => $pagesize, 'rewrite' => $rewrite, 'rule' => array('node' => $node, 'obj' => $this->url, 'params' => array('host' => '/', 'cate_id' => $cate_id, 'cname_py' => $this->categories[$cate_id]['cname_py'], 'p' => $p))));
             } else {
                 $result['pagebar'] = array('pagecode' => '');
             }
         } else {
             $result['pagebar'] = helper::pagebar(array('total' => $total, 'pagesize' => $pagesize, 'rewrite' => $rewrite));
         }
         return $result;
     } else {
         // 如果位置ID大於0,則取某個位置的數據
         $sql = "select * from " . TB_PREFIX . "recommend_area where area_id='{$area_id}' limit 1";
         $rs = $this->dbm->query($sql);
         $recommend = array();
         if (count($rs['list']) == 1) {
             $recommend = $rs['list'][0];
             //print_r($recommend);
             if ($recommend['area_type'] == 0) {
                 // 廣告
                 $tmp_a = unserialize($recommend['area_html']);
                 $order = 1;
                 //print_r($tmp_a);
                 if (is_array($tmp_a['list'])) {
                     foreach ($tmp_a['list'] as $v) {
                         if (!isset($v['order'])) {
                             $order = 0;
                             break;
                         }
                     }
                     if ($order == 1) {
                         $tmp_arr = helper::array_sort($tmp_a['list'], 'order', 'asc');
                         $tmp = array();
                         foreach ($tmp_arr as $v) {
                             array_push($tmp, $v);
                         }
                         $tmp_a['list'] = $tmp;
                     }
                 }
                 $recommend = $tmp_a;
             } else {
                 // 專題,推薦
                 if ($order == '') {
                     $order = ' order by field(info_id,' . $recommend['id_list'] . ')';
                 }
                 //$list = $this -> get_list(array('where' => 'info_id in (' . $recommend['id_list'] . ')', 'pagesize' => $pagesize, 'order' => $order,'extern'=>$extern));
                 //$recommend['list'] = $list['list'];
             }
         }
         return $recommend;
     }
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:96,代碼來源:common.class.php

示例2: join_query

 /**
  * 聯表查詢(2張表)
  * 
  * @param  $params 
  * @param  $ -> $table_name     表名 必填
  * @param  $ -> $fields         字段 field1,field2,...
  * @param  $ -> $where          更新的條件語句
  * @param  $ -> $suffix         order by , limit 語句
  * @param  $ -> $count          計算總量 0=不計算 1=計算
  * @param  $ -> $pagesize       分頁大小
  * 示範 params=array('table1'=>'cate','table2'=>'info','joinon'=>'cate_id#last_cate_id','fields'=>'a.field,b.felde'......)
  */
 public function join_query($params)
 {
     // 初始化
     $table1 = isset($params['table1']) ? $params['table1'] : '';
     $table2 = isset($params['table2']) ? $params['table2'] : '';
     // 關聯字段 cate_id#last_cate_id 以#分隔
     $joinon = isset($params['joinon']) ? $params['joinon'] : '';
     $joinon = explode("#", $joinon);
     $fields = isset($params['fields']) ? $params['fields'] : '*';
     $where = isset($params['where']) ? $params['where'] : '';
     $suffix = isset($params['suffix']) ? $params['suffix'] : '';
     $count = isset($params['count']) ? $params['count'] : 0;
     $total = isset($params['total']) ? $params['total'] : 0;
     $left_index = isset($params['left_index']) ? $params['left_index'] : '';
     $right_index = isset($params['right_index']) ? $params['right_index'] : '';
     $pagesize = isset($params['pagesize']) ? $params['pagesize'] : 10;
     if (strlen($where) > 0) {
         $where = "where {$where}";
     }
     $sql = "select {$fields} from {$table1} as a " . $left_index . " left join {$table2} as b " . $right_index . " on a." . $joinon[0] . "=b." . $joinon[1] . " {$where}";
     $result = $this->query($sql, $suffix, $count);
     $result['pagebar'] = helper::pagebar(array('total' => $total > 0 ? $total : $result['total'], 'pagesize' => $pagesize, 'rewrite' => 2));
     return $result;
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:36,代碼來源:database.class.php

示例3: get_list_tag


//.........這裏部分代碼省略.........
                 $result = $this->dbm->query($sql, $suffix, $count);
                 for ($i = 0; $i < count($result['list']); $i++) {
                     unset($result['list'][$i]['uid']);
                     unset($result['list'][$i]['uname']);
                 }
                 // 寫入緩存
                 $result = helper::file_cache($cache_file, $result, CACHE_TIME, $data_path);
             }
         } else {
             $result = $this->dbm->query($sql, $suffix, $count);
         }
     }
     if ($count == 1) {
         $total = $result['total'];
     } else {
         $result['total'] = $total;
     }
     $result['keyword'] = $keyword;
     if (defined('INFO_IMG') && file_exists(INFO_IMG)) {
         $default_img = INFO_IMG;
     }
     // 重寫返回數組
     for ($i = 0; $i < count($result['list']); $i++) {
         $result['list'][$i]['cate'] = $this->categories[$result['list'][$i]['last_cate_id']];
         if ($show_extern == '1') {
             // 取擴展表
             $extern = $this->get_extern_by_cate_id($result['list'][$i]['cate']['cate_id']);
             if ($extern['extern_name'] != '') {
                 $result['list'][$i]['extern'] = $this->get_extern($extern['extern_name'], $result['list'][$i]['info_id']);
             }
             // 取擴展字段結束
         }
         // 取資源列表
         if ($resource == 1) {
             $result['list'][$i]['resource'] = $this->get_resource($result['list'][$i]['info_id']);
             $result['list'][$i]['resource_total'] = count($result['list'][$i]['resource']);
         }
         // 縮略圖
         if (isset($result['list'][$i]['info_img'])) {
             if ($result['list'][$i]['info_img'] == '') {
                 $result['list'][$i]['info_img'] = $default_img;
             }
             $result['list'][$i]['thumb'] = $this->thumb_url($result['list'][$i]['info_img']);
         }
         // URL
         $surl_domain = $this->bind_domain($result['list'][$i]['last_cate_id']);
         $result['list'][$i]['surl'] = ($surl_domain == '' ? $this->url_recheck() : $surl_domain) . $this->url->encode('content_info', array('host' => SITE_PATH, 'id' => $result['list'][$i]['info_id']));
         if ($result['list'][$i]['info_url'] != '') {
             $result['list'][$i]['surl'] = $result['list'][$i]['info_url'];
         }
         // 資訊標題
         // 標題加粗
         $result['list'][$i]['info_style_title'] = $result['list'][$i]['info_title'];
         if ($result['list'][$i]['fbold'] == 1) {
             $result['list'][$i]['info_style_title'] = "<b>" . $result['list'][$i]['info_title'] . "</b>";
         }
         // 標題加亮
         if (!empty($result['list'][$i]['fcolor'])) {
             $result['list'][$i]['info_style_title'] = "<font color='" . $result['list'][$i]['fcolor'] . "'>" . $result['list'][$i]['info_style_title'] . "</font>";
         }
         // 資訊簡介
         if ($result['list'][$i]['info_desc'] == '') {
             $result['list'][$i]['info_desc'] = helper::utf8_substr(preg_replace('~(<style[^>]*>[\\w\\W]*?</style>)|(<[^>]*>)|(\\r)|(\\n)|(\\t)~', '', $result['list'][$i]['info_body']), 0, 220);
         }
         //精確標簽輸出
         //查詢關係表中的關鍵字ID
         if ($show_tags == 1) {
             $sql = "select keyword_id from " . TB_PREFIX . "keyword_relation where info_id= '{$result['list'][$i]['info_id']}'";
             $r = $this->dbm->query($sql);
             $ids = array();
             foreach ($r['list'] as $k => $v) {
                 array_push($ids, $v['keyword_id']);
             }
             $sql = "select * from " . TB_PREFIX . "keyword where keyword_id in (" . implode(',', $ids) . ")";
             $ret = $this->dbm->query($sql);
             $result['tags_html'] = '';
             if (count($ret['list']) > 0) {
                 $result['list'][$i]['tags'] = array();
                 $result['list'][$i]['tags_html'] = '';
                 foreach ($ret['list'] as $k => $v) {
                     $result['list'][$i]['tags'][] = $v['keyword'];
                     $result['list'][$i]['tags_html'] .= '<a href="' . $this->url->encode('tag_index', array('host' => SITE_PATH, 'extid' => $this->categories[$result['list'][$i]['last_cate_id']]['extern_id'], 'id' => $v['keyword_id'])) . '" target="_blank">' . $v['keyword'] . '</a>&nbsp;&nbsp;';
                 }
             }
         }
     }
     // 分頁碼HTML
     if ($rewrite == 0 || $rewrite == 1) {
         // 前台使用動態地址或者偽靜態地址
         if ($this->url != null && $params['count'] == 1) {
             $cpy = '';
             $result['pagebar'] = helper::pagebar(array('total' => $total, 'pagesize' => $pagesize, 'rewrite' => $rewrite, 'rule' => array('node' => $node, 'obj' => $this->url, 'params' => array('host' => SITE_PATH, 'id' => $keyword_id, 'p' => $p))));
         } else {
             $result['pagebar'] = array('pagecode' => '');
         }
     } else {
         $result['pagebar'] = helper::pagebar(array('total' => $total, 'pagesize' => $pagesize, 'rewrite' => $rewrite));
     }
     return $result;
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:101,代碼來源:common.class.php


注:本文中的helper::pagebar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。