本地
作者:互联网
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'=>'<','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); $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'=>'>','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); }
标签:um,get,url,ret,current,本地,page 来源: https://www.cnblogs.com/stj123/p/12372592.html