分页
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); }
你所浪费的今天是那些死去的人所奢望的明天,你所厌恶的现在是未来的你所回不去的曾经。