zoukankan      html  css  js  c++  java
  • 分页

     protected function getPagesByLists($page, $base_url = null, $current_page=1)
        {
    
            $ret=[];
            $is_search_page = false;
            // $is_search_page = true;
            for($i=1;$i<=$page;++$i)
            {
                switch ($i)
                {
                    case 1 :
                        if(strpos($_SERVER["QUERY_STRING"],'&')!==false)
                        {
    //                        $sub_str=substr($_SERVER["QUERY_STRING"],strpos($_SERVER["QUERY_STRING"],'&')+1);
                            $sub_str=$_SERVER["QUERY_STRING"];
                            $return_url=U($base_url,array_merge(['page'=>$current_page-1,'um'=>I("get.um")])).'?'.$sub_str;
                            $ret[] = ['url'=> $current_page==1?'#':$return_url,'name'=>'<','is_current'=>0, 'is_disabled' => $current_page==1?1:0];
                        }else{
                            $ret[] = ['url'=> $current_page==1?'#':U($base_url,array_merge(I("get."),['page'=>$current_page-1,'um'=>I("get.um")])),'name'=>'<','is_current'=>0, 'is_disabled' => $current_page==1?1:0];
                        }
    
                    default :
                        if(abs($current_page-$i) < 3)
                        {
                            if(strpos($_SERVER["QUERY_STRING"],'&')!==false)
                            {
    //                            $sub_str=substr($_SERVER["QUERY_STRING"],strpos($_SERVER["QUERY_STRING"],'&')+1);
                                $sub_str=$_SERVER["QUERY_STRING"];
                                $return_url=U($base_url,array_merge(['page'=> $i,'um'=>I("get.um")])).'?'.$sub_str;
                                $ret[] = ['url'=>$return_url,'name'=>$i,'is_current'=>$current_page==$i?1:0,'is_disabled'=>0];
                            }else{
                                $ret[] = ['url'=>U($base_url,array_merge(I("get."),['page'=> $i,'um'=>I("get.um")])),'name'=>$i,'is_current'=>$current_page==$i?1:0,'is_disabled'=>0];
                            }
    
                        }else{
                            $is_search_page = true;
                        }
                        break;
                }
    
            }
            if($page>0)
            {
                if(strpos($_SERVER["QUERY_STRING"],'&')!==false)
                {
    //                $sub_str=substr($_SERVER["QUERY_STRING"],strpos($_SERVER["QUERY_STRING"],'&')+1);
                    $sub_str=$_SERVER["QUERY_STRING"];
                    $return_url= U($base_url,array_merge(['page'=> $current_page>=$page?$page:$current_page+1,'um'=>I("get.um")])).'?'.$sub_str;
                    $ret[] = ['url'=>$return_url,'name'=>'>','is_current'=>0];
                }else{
                    $ret[] = ['url'=> U($base_url,array_merge(I("get."),['page'=> $current_page>=$page?$page:$current_page+1,'um'=>I("get.um")])) ,'name'=>'>','is_current'=>0];
                }
    
            }
            if($is_search_page){
                $get_params = I("get.");
                if(isset($get_params['page'])){
                    unset($get_params['page']);
                }
    
                $ret[] = ['is_search_page'=>'1','url'=> U($base_url,array_merge($get_params,['um'=>I("get.um")]),true)];
    
            }
    
            return json_encode($ret);
        }
    

      

  • 相关阅读:
    MO 中的imagelayer
    GDAL之OGR入门(转载)
    OGR体系结构
    C++与C# 以及指针
    如何用C#编程实现动态生成Word文档并填充数据?
    C++的类与C#的类[zt]
    arcmap vba 实现“卫星立体测图”高度字段值的计算,今天的一点小成就
    lib 和 dll from baidu
    ping and netstat
    Visual Basic6.0 中的类模块和标准模块
  • 原文地址:https://www.cnblogs.com/stj123/p/12303873.html
Copyright © 2011-2022 走看看