Пример #1
0
 /**
 	分页代码
 	@param string $_url   URL格式模板,如index.php?pid=%d&rn=%d,需要注意的是pid必须在rn的前面
 	@param string $_per   记录总数
 	@param string $_pid   当前页
 	@param string $_rn    每页显示
 	@param string $_inner 分页内容模板
 	@return string
 */
 public function pagelist($_url = '', $_per = '', $_pid = 0, $_rn = 0, $_inner = null)
 {
     if ($this->ispagelist = 0) {
         //如果不分页,则不显示分页代码
         return '';
     }
     if ($this->mPagelist != '') {
         return $this->mPagelist;
     }
     if ($_per == 0) {
         return '';
     }
     if ($_pid == 0) {
         $_pid = $this->pid;
     }
     //第x页 即当前页
     if ($_rn == 0) {
         $_rn = $this->rn;
     }
     //每页显示
     $this->mPagelist = kc_pagelist($_url, $_per, $_pid, $_rn, $_inner);
     return $this->mPagelist;
 }
Пример #2
0
 /**
 
 	列表分页
 
 	@param string $inner   INNERHTML
 	@param array  $ass     assign 内容
 	@param array  $attrib  属性数组,目前没有可用属性
 */
 public function tag_pagelist($inner, $ass, $attrib)
 {
     global $king;
     $type = kc_val($ass, 'type');
     $modelid = kc_val($ass, 'modelid');
     //列表分页
     if ($type == 'list' && $modelid > 0) {
         //只有在列表页和modelid大于6的时候才调用
         $info = $this->infoList($ass['listid']);
         $site = $this->infoSite($info['siteid']);
         $pagelist = kc_pagelist($this->pathList($info, 0, 'PID'), $ass['ncount'], $ass['pid'], $ass['nlistnumber'], $inner);
         return $pagelist;
     }
     //内容分页
     if ($type == 'page' && $modelid > 0) {
         $info = $this->infoList($ass['listid']);
         if ($info['npagenumber'] == 1) {
             return;
         }
         $count = $ass['count'];
         $pagelist = kc_pagelist($ass['path'], $count, $ass['pid'], $info['npagenumber'], $inner);
         return $pagelist;
     }
     //搜索
     if ($type == 'search' && $modelid > 0) {
         $model = $this->infoModel($modelid);
         $where = 'nshow=1' . kc_val($ass, 'search');
         //关联字段
         if (isset($model['field']['isrelate'])) {
             $relate = $model['field']['isrelate'];
             if (is_array($relate)) {
                 foreach ($relate as $key => $val) {
                     if (isset($attrib[$key])) {
                         $where .= " and k{$val}='" . $king->db->escape($attrib[$key]) . "'";
                     }
                 }
             }
         }
         //限定listid等等
         $field_id = $model['field']['id'];
         foreach ($field_id as $val) {
             if (isset($attrib[$val])) {
                 if (kc_validate($attrib[$val], 2)) {
                     $where .= " and {$val}=" . $king->db->escape($attrib[$val]) . "";
                 } elseif (kc_validate($attrib[$val], 3)) {
                     $where .= " and {$val} in (" . $king->db->escape($attrib[$val]) . ")";
                 }
             }
         }
         //siteid属性 分析如果有指定siteid,则先获得listid列表进行限定
         $siteid = isset($attrib['siteid']) ? $attrib['siteid'] : '';
         if (kc_validate($siteid, 2) || kc_validate($siteid, 3)) {
             $lists = array();
             if ($sites = $king->db->getRows("select listid from %s_list where " . (kc_validate($siteid, 2) ? "siteid={$siteid}" : "siteid in ({$siteid})"))) {
                 foreach ($sites as $rs) {
                     $lists[] = $rs['listid'];
                 }
             }
             if (count($lists) === 1) {
                 $where .= " and listid={$lists[0]}";
             } elseif (count($lists) > 1) {
                 $where .= " and listid in (" . implode(',', $lists) . ")";
             }
         }
         //SQL扩展属性where,这个功能是标签解析不稳定的隐患功能。
         if (isset($attrib['where'])) {
             $where .= " and " . $attrib['where'];
         }
         $count = $king->db->getRows_number('%s__' . $model['modeltable'], $where);
         $pid = kc_val($ass, 'pid');
         $rn = kc_val($ass, 'rn');
         $get = is_array($_GET) ? $_GET : array();
         $array = array();
         foreach ($get as $key => $val) {
             if ($key == 'pid' || $key == 'rn') {
                 $array[] = "{$key}=" . strtoupper($key);
             } else {
                 $array[] = "{$key}=" . urlencode($val);
             }
         }
         $url = implode('&', $array);
         if (!array_key_exists('pid', $array)) {
             $url .= '&pid=PID';
         }
         if (!array_key_exists('rn', $array)) {
             $url .= '&rn=RN';
         }
         $pagelist = kc_pagelist('search.php?' . $url, $count, $pid, $rn, $inner);
         return $pagelist;
     }
 }