本地

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);
                         $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'=>'&lt;','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'=>'&lt;','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);
                            $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);
                 $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'=>'&gt;','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'=>'&gt;','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);
    }

 

上一篇:反射:InvokeMethod 活动调用多种方法的方法配置要点


下一篇:已知U=22V,f=50Hz,初相位30度,求交流电的四种表达方式