1
2
/**
3
* filename: ext_page.class.php
4
* @package:phpbean
5
* @author :feifengxlq
6
* @copyright :Copyright 2006 feifengxlq
7
* @license:version 2.0
8
* @create:2006-5-31
9
* @modify:2006-6-1
10
* @modify:feifengxlq 2006-11-4
11
* description:超强分页类,四种分页模式,默认采用类似baidu,google的分页风格。
12
* 2.0增加功能:支持自定义风格,自定义样式,同时支持PHP4和PHP5,
13
* to see detail,please visit [url=http://www.phpobject.net/blog/read.php]http://www.phpobject.net/blog/read.php[/url]?
14
* example:
15
* 模式四种分页模式:
16
require_once('../libs/classes/page.class.php');
17
$page=new page(array('total'=>1000,'perpage'=>20));
18
echo 'mode:1
'.$page->show();
19
echo '
mode:2
'.$page->show(2);
20
echo '
mode:3
'.$page->show(3);
21
echo '
mode:4
'.$page->show(4);
22
开启AJAX:
23
$ajaxpage=new page(array('total'=>1000,'perpage'=>20,'ajax'=>'ajax_page','page_name'=>'test'));
24
echo 'mode:1
'.$ajaxpage->show();
25
采用继承自定义分页显示模式:
26
demo:http://www.phpobject.net/blog
27
*/
28
class page
29
{
30
/**
31
* config ,public
32
*/
33
var $page_name="PB_page";//page标签,用来控制url页。比如说xxx.php?PB_page=2中的PB_page
34
var $next_page='>';//下一页
35
var $pre_page='';//上一页
36
var $first_page='First';//首页
37
var $last_page='Last';//尾页
38
var $pre_bar='';//上一分页条
39
var $next_bar='>>';//下一分页条
40
var $format_left='[';
41
var $format_right=']';
42
var $is_ajax=false;//是否支持AJAX分页模式
43
44
/**
45
* private
46
*
47
*/
48
var $pagebarnum=10;//控制记录条的个数。
49
var $totalpage=0;//总页数
50
var $ajax_action_name='';//AJAX动作名
51
var $nowindex=1;//当前页
52
var $url="";//url地址头
53
var $offset=0;
54
55
/**
56
* constructor构造函数
57
*
58
* @param array $array['total'],$array['perpage'],$array['nowindex'],$array['url'],$array['ajax']
59
*/
60
function page($array)
61
{
62
if(is_array($array)){
63
if(!array_key_exists('total',$array))$this->error(__FUNCTION__,'need a param of total');
64
$total=intval($array['total']);
65
$perpage=(array_key_exists('perpage',$array))?intval($array['perpage']):10;
66
$nowindex=(array_key_exists('nowindex',$array))?intval($array['nowindex']):'';
67
$url=(array_key_exists('url',$array))?$array['url']:'';
68
}else{
69
$total=$array;
70
$perpage=10;
71
$nowindex='';
72
$url='';
73
}
74
if((!is_int($total))||($total0))$this->error(__FUNCTION__,$total.' is not a positive integer!');
75
if((!is_int($perpage))||($perpage0))$this->error(__FUNCTION__,$perpage.' is not a positive integer!');
76
if(!empty($array['page_name']))$this->set('page_name',$array['page_name']);//设置pagename
77
$this->_set_nowindex($nowindex);//设置当前页
78
$this->_set_url($url);//设置链接地址
79
$this->totalpage=ceil($total/$perpage);
80
$this->offset=($this->nowindex-1)*$this->perpage;
81
if(!empty($array['ajax']))$this->open_ajax($array['ajax']);//打开AJAX模式
82
}
83
/**
84
* 设定类中指定变量名的值,如果改变量不属于这个类,将throw一个exception
85
*
86
* @param string $var
87
* @param string $value
88
*/
89
function set($var,$value)
90
{
91
if(in_array($var,get_object_vars($this)))
92
$this->$var=$value;
93
else {
94
$this->error(__FUNCTION__,$var." does not belong to PB_Page!");
95
}
96
97
}
98
/**
99
* 打开倒AJAX模式
100
*
101
* @param string $action 默认ajax触发的动作。
102
*/
103
function open_ajax($action)
104
{
105
$this->is_ajax=true;
106
$this->ajax_action_name=$action;
107
}
108
/**
109
* 获取显示"下一页"的代码
110
*
111
* @param string $style
112
* @return string
113
*/
114
function next_page($style='')
115
{
116
if($this->nowindex$this->totalpage){
117
return $this->_get_link($this->_get_url($this->nowindex+1),$this->next_page,$style);
118
}
119
return ''.$style.'">'.$this->next_page.'';
120
}
121
122
/**
123
* 获取显示“上一页”的代码
124
*
125
* @param string $style
126
* @return string
127
*/
128
function pre_page($style='')
129
{
130
if($this->nowindex>1){
131
return $this->_get_link($this->_get_url($this->nowindex-1),$this->pre_page,$style);
132
}
133
return ''.$style.'">'.$this->pre_page.'';
134
}
135
136
/**
137
* 获取显示“首页”的代码
138
*
139
* @return string
140
*/
141
function first_page($style='')
142
{
143
if($this->nowindex==1){
144
return ''.$style.'">'.$this->first_page.'';
145
}
146
return $this->_get_link($this->_get_url(1),$this->first_page,$style);
147
}
148
149
/**
150
* 获取显示“尾页”的代码
151
*
152
* @return string
153
*/
154
function last_page($style='')
155
{
156
if($this->nowindex==$this->totalpage){
157
return ''.$style.'">'.$this->last_page.'';
158
}
159
return $this->_get_link($this->_get_url($this->totalpage),$this->last_page,$style);
160
}
161
162
function nowbar($style='',$nowindex_style='')
163
{
164
$plus=ceil($this->pagebarnum/2);
165
if($this->pagebarnum-$plus+$this->nowindex>$this->totalpage)$plus=($this->pagebarnum-$this->totalpage+$this->nowindex);
166

2

3

4

5


7

8

9

10

11

12

13

14

15

16

17

18

'.$page->show();
19

mode:2
'.$page->show(2);
20

mode:3
'.$page->show(3);
21

mode:4
'.$page->show(4);
22

23

24

'.$ajaxpage->show();
25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58


59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사
R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
어 ass 신 크리드 그림자 : 조개 수수께끼 솔루션
2 몇 주 전ByDDD
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

드림위버 CS6
시각적 웹 개발 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음
