페이지 매김 클래스 - 꼬리 페이지 번호 탐색

WBOY
풀어 주다: 2016-07-25 09:01:02
원래의
1378명이 탐색했습니다.
페이지 매김 클래스 - 꼬리 페이지 번호 탐색
  1. /**
  2. * 댓글의 테일 페이징 탐색 생성
  3. * @author Li Jun
  4. *
  5. */
  6. class cmtTail{
  7. private $currentPage;
  8. private $totalPage;
  9. /**
  10. * 페이지 번호 탐색 생성 - 전체 제어 기능
  11. * @param string $currentPage 현재 페이지 번호
  12. * @param string $totalPage 총 페이지 수
  13. * @throws Exception 페이지 번호가 더 작은 경우 1보다 큰 경우 예외가 발생합니다
  14. * @return string
  15. */
  16. function __do($currentPage, $totalPage) {
  17. $this->currentPage=$currentPage;
  18. $this->totalPage=$totalPage;
  19. if($this->totalPage<=10){//총 ​​페이지 수가 10페이지 이하입니다
  20. if($this->currentPage==1){//The 현재 페이지가 첫 번째 페이지입니다
  21. $str='이전 페이지'.$this->currentTag();
  22. for ($i = 2; $i <= $this->totalPage; $i ) {
  23. $ str=$str.$this->commonTag($i);
  24. }
  25. $str=$str.$this->next();
  26. }elseif ( $this->currentPage ==$this->totalPage){//마지막 페이지로 이동했습니다
  27. $str=$this->up();
  28. for ($i = 1; $i <= $this ->totalPage-1; $i ) {
  29. $str=$str.$this->commonTag($i);
  30. }
  31. $str=$str.$ this->currentTag ();
  32. $str=$str.$this->next();
  33. }else{
  34. $str=$this->up();
  35. for($i= 1; $i<$this->currentPage; $i ){
  36. $str=$str.$this->commonTag($i);
  37. }
  38. $str =$str.$ this->currentTag();//현재 페이지 태그 생성
  39. for ($i = $this->currentPage 1; $i <= $this->totalPage; $i ) {
  40. $ str=$str.$this->commonTag($i);
  41. }
  42. $str=$str.$this->next();
  43. }
  44. }elseif ($this ->totalPage>10){//페이지 번호가 10보다 큽니다.
  45. if($this->currentPage==1){/8 2
  46. $str=' 이전 페이지'.$this-> currentTag();
  47. for ($i = 2; $i <= 8; $i ) {
  48. $str=$str.$this->commonTag( $i);
  49. }
  50. $str=$str.'...';//줄임표 추가
  51. $str=$str.$this->commonTag($this->totalPage- 1);
  52. $str= $str.$this->commonTag($this->totalPage);
  53. }elseif($this->currentPage==$this->totalPage) {/ /마지막 페이지입니다
  54. $str=$this->up();
  55. $str=$str.$this->commonTag(1);
  56. $str=$str.' ...';//줄임표 추가
  57. for ($i = $this->totalPage-6; $i < $this->totalPage; $i ) {
  58. $str=$str. $this->commonTag($i );
  59. }
  60. $str=$str.$this->currentTag();
  61. $str=$str.$this->next() ;
  62. }else {
  63. if ($this->currentPage<6) {
  64. $str=$this->up();
  65. for ($i = 1; $i < ; $this->currentPage; $ i ) {
  66. $str=$str.$this->commonTag($i);
  67. }
  68. $str=$str.$this-> currentTag();
  69. for ( $i = $this->currentPage 1; $i <= 7; $i ) {
  70. $str=$str.$this->commonTag($i) ;
  71. }
  72. $ str=$str.'...';//줄임표 추가
  73. $str=$str.$this->commonTag($this->totalPage);
  74. $str=$str.$this ->next();
  75. }else {
  76. if ($this->currentPage>=$this->totalPage-4) {
  77. $str =$this->up() ;
  78. $str=$str.$this->commonTag(1);
  79. $str=$str.'...';//줄임표 추가
  80. for ($i = $this- >totalPage-6; $i < $this->currentPage; $i ) {
  81. $str=$str.$this->commonTag($i);
  82. }
  83. $str =$str.$this->currentTag();
  84. for ($i = $this->currentPage 1; $i <= $this->totalPage; $i ) {
  85. $str =$str.$this->commonTag($i);
  86. }
  87. $str=$str.$this->next();
  88. } elseif ($this->currentPage< $this->totalPage-4){//1 5 1
  89. $str=$this->up();
  90. $str=$str.$this ->commonTag(1);
  91. $str=$str.'...';//줄임표 추가
  92. $str=$str.$this->commonTag($this->currentPage- 2);
  93. $str= $str.$this->commonTag($this->currentPage-1);
  94. $str=$str.$this->currentTag();
  95. $str=$str.$this- >commonTag($this->currentPage 1);
  96. $str=$str.$this->commonTag($this->currentPage 2);
  97. $str=$str.'.. .';//줄임표 추가
  98. $str=$str.$this->commonTag($this->totalPage);
  99. $str=$str.$ this->next();
  100. }
  101. };
  102. }
  103. }elseif ($this->totalPage<=0){
  104. throw new Exception("페이지는 이보다 작을 수 없습니다. 1");
  105. }
  106. return $str;
  107. }
  108. /**
  109. * 일반 태그
  110. * @param int $param 페이지 번호
  111. * @return 문자열
  112. */
  113. function commonTag($param) {
  114. return ''.$param.'';
  115. }
  116. /**
  117. * 현재 페이지 레이블 생성
  118. * @param int $param 페이지 번호
  119. * @return 문자열
  120. */
  121. function currentTag() {
  122. return ''.$this->currentPage .'';
  123. }
  124. /**
  125. * 다음 페이지 태그 생성
  126. * @param int $param 다음 페이지 번호
  127. * @return 문자열
  128. */
  129. function next() {
  130. if ($this->currentPage==$this-> totalPage) {
  131. return '下一页';
  132. }
  133. return '下一页';
  134. }
  135. /**
  136. * 이전 페이지 태그 생성
  137. * @param int $param 이전 페이지 페이지 번호
  138. * @return string
  139. */
  140. function up() {
  141. if ($this->currentPage==1){
  142. return '上一页';
  143. }else{
  144. return '上一页';
  145. }
  146. }
  147. /**
  148. * cmtTail 인스턴스화,
  149. * 기능: Comment의 테일 페이징 탐색 생성
  150. * @param string $currentPage 현재 페이지 번호
  151. * @param string $totalPage 총 페이지 수
  152. * @return 문자열은 html 태그 문자열을 반환합니다
  153. */
  154. 정적 함수 GO($currentPage, $totalPage) {
  155. $p=new cmtTail();
  156. return $p-> __do($currentPage, $totalPage);
  157. }
  158. }
复代码


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!