Heim > php教程 > php手册 > 修改过的Page.class.php,支持select跳转

修改过的Page.class.php,支持select跳转

WBOY
Freigeben: 2016-06-07 11:43:03
Original
914 Leute haben es durchsucht

感觉THinkPHP原版的不太好使,Page.class.php,自己修改了下可以自定义需要那些组件
感觉THinkPHP原版的不太好使,Page.class.php,自己修改了下可以自定义需要那些组件 ,话说配图是必须的
修改过的Page.class.php,支持select跳转
自己的网站也是必须带的:http://sssui.com
不要在意这些细节
下面是代码 <?php <br /> // +----------------------------------------------------------------------<br> // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]<br> // +----------------------------------------------------------------------<br> // | Copyright (c) 2009 http://thinkphp.cn All rights reserved.<br> // +----------------------------------------------------------------------<br> // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )<br> // +----------------------------------------------------------------------<br> // | Author: liu21st <liu21st><br> // |         lanfengye <zibin_5257><br> // +----------------------------------------------------------------------<br> <br> class Page {<br>     <br>     // 分页栏每页显示的页数<br>     public $rollPage = 5;<br>     // 页数跳转时要带的参数<br>     public $parameter  ;<br>     // 分页URL地址<br>     public $url     =   '';<br>     // 默认列表每页显示行数<br>     public $listRows = 20;<br>     // 起始行数<br>     public $firstRow    ;<br>     // 分页总页面数<br>     protected $totalPages  ;<br>     // 总行数<br>     protected $totalRows  ;<br>     // 当前页数<br>     protected $nowPage    ;<br>     // 分页的栏的总页数<br>     protected $coolPages   ;<br>     // 分页显示定制<br>     protected $config  =    array(<br>         'header'=>'条记录',<br>         'prev'=>'上一页',<br>         'next'=>'下一页',<br>         'first'=>'第一页',<br>         'last'=>'最后一页',<br>         'widget'=>array(<br>             'UpDown'  =>true,<br>             'PreNext'  =>false,<br>             'FirstEnd'  =>true,<br>             'PageLink'  =>true,<br>             'JumpPage'  =>true,<br>         ),<br>         'theme'=>' %totalRow% %header% %nowPage%/%totalPage% 页 %first% %prePage% %upPage% %linkPage% %downPage% %nextPage% %end% %jumppage%'<br>     );<br>     // 默认分页变量名<br>     protected $varPage;<br> <br>     /**<br>      * 架构函数<br>      * @access public<br>      * @param array $totalRows  总的记录数<br>      * @param array $listRows  每页显示记录数<br>      * @param array $parameter  分页跳转的参数<br>      */<br>     public function __construct($totalRows,$listRows='',$parameter='',$url='') {<br>         $this->totalRows    =   $totalRows;<br>         $this->parameter    =   $parameter;<br>         $this->varPage      =   C('VAR_PAGE') ? C('VAR_PAGE') : 'p' ;<br>         if(!empty($listRows)) {<br>             $this->listRows =   intval($listRows);<br>         }<br>         $this->totalPages   =   ceil($this->totalRows/$this->listRows);     //总页数<br>         $this->coolPages    =   ceil($this->totalPages/$this->rollPage);<br>         $this->nowPage      =   !empty($_GET[$this->varPage])?intval($_GET[$this->varPage]):1;<br>         if(!empty($this->totalPages) && $this->nowPage>$this->totalPages) {<br>             $this->nowPage  =   $this->totalPages;<br>         }<br>         $this->firstRow     =   $this->listRows*($this->nowPage-1);<br>     }<br> <br>     public function setConfig($name,$value) {<br>         if(isset($this->config[$name])) {<br>             $this->config[$name]    =   $value;<br>         }<br>     }<br> <br>     /**<br>      * 分页显示输出<br>      * @access public<br>      */<br>     public function show() {<br>         if(0 == $this->totalRows) return '';<br>         $p              =   $this->varPage;<br>         $nowCoolPage    =   ceil($this->nowPage/$this->rollPage);<br>         // 分析分页参数<br>         if($this->url){<br>             $depr       =   C('URL_PATHINFO_DEPR');<br>             $url        =   rtrim(U('/'.$this->url,'',false),$depr).$depr.'__PAGE__';<br>         }else{<br>             if($this->parameter && is_string($this->parameter)) {<br>                 parse_str($this->parameter,$parameter);<br>             }elseif(empty($this->parameter)){<br>                 unset($_GET[C('VAR_URL_PARAMS')]);<br>                 if(empty($_GET)) {<br>                     $parameter  =   array();<br>                 }else{<br>                     $parameter  =   $_GET;<br>                 }<br>             }<br>             $parameter[$p]  =   '__PAGE__';<br>             $url            =   U('',$parameter);<br>         }<br>         //上下翻页字符串<br>         if($this->config['widget']['UpDown']){<br>             $upRow          =   $this->nowPage-1;<br>             $downRow        =   $this->nowPage+1;<br>             if ($upRow>0){<br>                 $upPage     =   "<a>".$this->config['prev']."</a>";<br>             }else{<br>                 $upPage     =   '';<br>             }<br> <br>             if ($downRow totalPages){<br>                 $downPage   =   "<a>".$this->config['next']."</a>";<br>             }else{<br>                 $downPage   =   '';<br>             }<br>         }<br>         //  >><br>         if($this->config['widget']['PreNext']){<br>             if($nowCoolPage == 1){<br>                 $prePage    =   '';<br>             }else{<br>                 $preRow     =   $this->nowPage-$this->rollPage;<br>                 $prePage    =   "<a>上".$this->rollPage."页</a>";<br>             }<br>             if($nowCoolPage == $this->coolPages){<br>                 $nextPage   =   '';<br>             }else{<br>                 $theEndRow  =   $this->totalPages;<br>                 $nextPage   =   "<a>下".$this->rollPage."页</a>";<br>             }<br>         }<br>         if($this->config['widget']['FirstEnd']){<br>             if($this->nowPage == 1){<br>                 $theFirst   =   '';<br>             }else{<br>                 $theFirst   =   "<a>".$this->config['first']."</a>";<br>             }<br>             if($this->nowPage == $this->totalPages){<br>                 if($this->config['widget']['FirstEnd']) $theEnd     =   '';<br>             }else{<br>                 $theEndRow  =   $this->totalPages;<br>                 $theEnd     =   "<a>".$this->config['last']."</a>";<br>             }<br>         }<br>         <br>         // 1 2 3 4 5<br> <br>         if($this->config['widget']['PageLink']){<br>             $linkPage = "";<br>             for($i=1;$irollPage;$i++){<br>                 $page       =   ($nowCoolPage-1)*$this->rollPage+$i;<br>                 if($page!=$this->nowPage){<br>                     if($pagetotalPages){<br>                         $linkPage .= " <a> ".$page." </a>";<br>                     }else{<br>                         break;<br>                     }<br>                 }else{<br>                     if($this->totalPages != 1){<br>                         $linkPage .= " <span>".$page."</span>";<br>                     }<br>                 }<br>             }<br>         }<br>         if($this->config['widget']['JumpPage']){<br>             $jumppage='<select>';<br>             for ($j=1; $j totalPages ; $j++) {<br>                 $select= ($this->nowPage==$j) ? 'selected' : '';<br>                 $jumppage.='<option>'.$j.'</option>';<br>             }<br>             $jumppage.='</select>';<br>         }<br>         $pageStr     =   str_replace(<br>             array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%','%jumppage%'),<br>             array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd,$jumppage),$this->config['theme']);<br>         return $pageStr;<br>     }<br> <br> }</zibin_5257></liu21st>

AD:真正免费,域名+虚机+企业邮箱=0元

Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage