Subversion Repositories Applications.papyrus

Rev

Rev 848 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 848 Rev 1713
1
<?php
1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
 
3
 
4
/**
4
/**
5
 * Contains the Pager_Common class
5
 * Contains the Pager_Common class
6
 *
6
 *
7
 * PHP versions 4 and 5
7
 * PHP versions 4 and 5
8
 *
8
 *
9
 * LICENSE: Redistribution and use in source and binary forms, with or without
9
 * LICENSE: Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
10
 * modification, are permitted provided that the following conditions are met:
11
 * 1. Redistributions of source code must retain the above copyright
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. The name of the author may not be used to endorse or promote products
16
 * 3. The name of the author may not be used to endorse or promote products
17
 *    derived from this software without specific prior written permission.
17
 *    derived from this software without specific prior written permission.
18
 *
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
23
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 *
29
 *
30
 * @category   HTML
30
 * @category   HTML
31
 * @package    Pager
31
 * @package    Pager
32
 * @author     Lorenzo Alberton <l dot alberton at quipo dot it>
32
 * @author     Lorenzo Alberton <l dot alberton at quipo dot it>
33
 * @author     Richard Heyes <richard@phpguru.org>
33
 * @author     Richard Heyes <richard@phpguru.org>
34
 * @copyright  2003-2006 Lorenzo Alberton, Richard Heyes
34
 * @copyright  2003-2006 Lorenzo Alberton, Richard Heyes
35
 * @license    http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
35
 * @license    http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
36
 * @version    CVS: $Id$
36
 * @version    CVS: $Id$
37
 * @link       http://pear.php.net/package/Pager
37
 * @link       http://pear.php.net/package/Pager
38
 */
38
 */
39
 
39
 
40
/**
40
/**
41
 * Two constants used to guess the path- and file-name of the page
41
 * Two constants used to guess the path- and file-name of the page
42
 * when the user doesn't set any other value
42
 * when the user doesn't set any other value
43
 */
43
 */
44
if (substr($_SERVER['PHP_SELF'], -1) == '/') {
44
if (substr($_SERVER['PHP_SELF'], -1) == '/') {
-
 
45
    $http = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
45
    define('CURRENT_FILENAME', '');
46
    define('CURRENT_FILENAME', '');
46
    define('CURRENT_PATHNAME', 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\', '/', $_SERVER['PHP_SELF']));
47
    define('CURRENT_PATHNAME', $http.$_SERVER['HTTP_HOST'].str_replace('\\', '/', $_SERVER['PHP_SELF']));
47
} else {
48
} else {
48
    define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['PHP_SELF'])));
49
    define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['PHP_SELF'])));
49
    define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])));
50
    define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])));
50
}
51
}
51
/**
52
/**
52
 * Error codes
53
 * Error codes
53
 */
54
 */
54
define('PAGER_OK',                         0);
55
define('PAGER_OK',                         0);
55
define('ERROR_PAGER',                     -1);
56
define('ERROR_PAGER',                     -1);
56
define('ERROR_PAGER_INVALID',             -2);
57
define('ERROR_PAGER_INVALID',             -2);
57
define('ERROR_PAGER_INVALID_PLACEHOLDER', -3);
58
define('ERROR_PAGER_INVALID_PLACEHOLDER', -3);
58
define('ERROR_PAGER_INVALID_USAGE',       -4);
59
define('ERROR_PAGER_INVALID_USAGE',       -4);
59
define('ERROR_PAGER_NOT_IMPLEMENTED',     -5);
60
define('ERROR_PAGER_NOT_IMPLEMENTED',     -5);
60
 
61
 
61
/**
62
/**
62
 * Pager_Common - Common base class for [Sliding|Jumping] Window Pager
63
 * Pager_Common - Common base class for [Sliding|Jumping] Window Pager
63
 * Extend this class to write a custom paging class
64
 * Extend this class to write a custom paging class
64
 *
65
 *
65
 * @category   HTML
66
 * @category   HTML
66
 * @package    Pager
67
 * @package    Pager
67
 * @author     Lorenzo Alberton <l dot alberton at quipo dot it>
68
 * @author     Lorenzo Alberton <l dot alberton at quipo dot it>
68
 * @author     Richard Heyes <richard@phpguru.org>
69
 * @author     Richard Heyes <richard@phpguru.org>
69
 * @copyright  2003-2005 Lorenzo Alberton, Richard Heyes
70
 * @copyright  2003-2005 Lorenzo Alberton, Richard Heyes
70
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
71
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
71
 * @link       http://pear.php.net/package/Pager
72
 * @link       http://pear.php.net/package/Pager
72
 */
73
 */
73
class Pager_Common
74
class Pager_Common
74
{
75
{
75
    // {{{ class vars
76
    // {{{ class vars
76
 
77
 
77
    /**
78
    /**
78
     * @var integer number of items
79
     * @var integer number of items
79
     * @access private
80
     * @access private
80
     */
81
     */
81
    var $_totalItems;
82
    var $_totalItems;
82
 
83
 
83
    /**
84
    /**
84
     * @var integer number of items per page
85
     * @var integer number of items per page
85
     * @access private
86
     * @access private
86
     */
87
     */
87
    var $_perPage     = 10;
88
    var $_perPage     = 10;
88
 
89
 
89
    /**
90
    /**
90
     * @var integer number of page links for each window
91
     * @var integer number of page links for each window
91
     * @access private
92
     * @access private
92
     */
93
     */
93
    var $_delta       = 10;
94
    var $_delta       = 10;
94
 
95
 
95
    /**
96
    /**
96
     * @var integer current page number
97
     * @var integer current page number
97
     * @access private
98
     * @access private
98
     */
99
     */
99
    var $_currentPage = 1;
100
    var $_currentPage = 1;
100
 
101
 
101
    /**
102
    /**
102
     * @var integer total pages number
103
     * @var integer total pages number
103
     * @access private
104
     * @access private
104
     */
105
     */
105
    var $_totalPages  = 1;
106
    var $_totalPages  = 1;
106
 
107
 
107
    /**
108
    /**
108
     * @var string CSS class for links
109
     * @var string CSS class for links
109
     * @access private
110
     * @access private
110
     */
111
     */
111
    var $_linkClass   = '';
112
    var $_linkClass   = '';
112
 
113
 
113
    /**
114
    /**
114
     * @var string wrapper for CSS class name
115
     * @var string wrapper for CSS class name
115
     * @access private
116
     * @access private
116
     */
117
     */
117
    var $_classString = '';
118
    var $_classString = '';
118
 
119
 
119
    /**
120
    /**
120
     * @var string path name
121
     * @var string path name
121
     * @access private
122
     * @access private
122
     */
123
     */
123
    var $_path        = CURRENT_PATHNAME;
124
    var $_path        = CURRENT_PATHNAME;
124
 
125
 
125
    /**
126
    /**
126
     * @var string file name
127
     * @var string file name
127
     * @access private
128
     * @access private
128
     */
129
     */
129
    var $_fileName    = CURRENT_FILENAME;
130
    var $_fileName    = CURRENT_FILENAME;
130
    
131
    
131
    /**
132
    /**
132
     * @var boolean If false, don't override the fileName option. Use at your own risk.
133
     * @var boolean If false, don't override the fileName option. Use at your own risk.
133
     * @access private
134
     * @access private
134
     */
135
     */
135
    var $_fixFileName = true;
136
    var $_fixFileName = true;
136
 
137
 
137
    /**
138
    /**
138
     * @var boolean you have to use FALSE with mod_rewrite
139
     * @var boolean you have to use FALSE with mod_rewrite
139
     * @access private
140
     * @access private
140
     */
141
     */
141
    var $_append      = true;
142
    var $_append      = true;
142
 
143
 
143
    /**
144
    /**
144
     * @var string specifies which HTTP method to use
145
     * @var string specifies which HTTP method to use
145
     * @access private
146
     * @access private
146
     */
147
     */
147
    var $_httpMethod  = 'GET';
148
    var $_httpMethod  = 'GET';
148
    
149
    
149
    /**
150
    /**
150
     * @var string specifies which HTML form to use
151
     * @var string specifies which HTML form to use
151
     * @access private
152
     * @access private
152
     */
153
     */
153
    var $_formID  = '';
154
    var $_formID  = '';
154
 
155
 
155
    /**
156
    /**
156
     * @var boolean whether or not to import submitted data
157
     * @var boolean whether or not to import submitted data
157
     * @access private
158
     * @access private
158
     */
159
     */
159
    var $_importQuery = true;
160
    var $_importQuery = true;
160
 
161
 
161
    /**
162
    /**
162
     * @var string name of the querystring var for pageID
163
     * @var string name of the querystring var for pageID
163
     * @access private
164
     * @access private
164
     */
165
     */
165
    var $_urlVar      = 'pageID';
166
    var $_urlVar      = 'pageID';
166
 
167
 
167
    /**
168
    /**
168
     * @var array data to pass through the link
169
     * @var array data to pass through the link
169
     * @access private
170
     * @access private
170
     */
171
     */
171
    var $_linkData    = array();
172
    var $_linkData    = array();
172
 
173
 
173
    /**
174
    /**
174
     * @var array additional URL vars
175
     * @var array additional URL vars
175
     * @access private
176
     * @access private
176
     */
177
     */
177
    var $_extraVars   = array();
178
    var $_extraVars   = array();
178
    
179
    
179
    /**
180
    /**
180
     * @var array URL vars to ignore
181
     * @var array URL vars to ignore
181
     * @access private
182
     * @access private
182
     */
183
     */
183
    var $_excludeVars = array();
184
    var $_excludeVars = array();
184
 
185
 
185
    /**
186
    /**
186
     * @var boolean TRUE => expanded mode (for Pager_Sliding)
187
     * @var boolean TRUE => expanded mode (for Pager_Sliding)
187
     * @access private
188
     * @access private
188
     */
189
     */
189
    var $_expanded    = true;
190
    var $_expanded    = true;
190
    
191
    
191
    /**
192
    /**
192
     * @var boolean TRUE => show accesskey attribute on <a> tags
193
     * @var boolean TRUE => show accesskey attribute on <a> tags
193
     * @access private
194
     * @access private
194
     */
195
     */
195
    var $_accesskey   = false;
196
    var $_accesskey   = false;
196
 
197
 
197
    /**
198
    /**
198
     * @var string extra attributes for the <a> tag
199
     * @var string extra attributes for the <a> tag
199
     * @access private
200
     * @access private
200
     */
201
     */
201
    var $_attributes  = '';
202
    var $_attributes  = '';
-
 
203
    
-
 
204
    /**
-
 
205
     * @var string onclick
-
 
206
     * @access private
-
 
207
     */
-
 
208
    var $_onclick = '';
202
 
209
 
203
    /**
210
    /**
204
     * @var string alt text for "first page" (use "%d" placeholder for page number)
211
     * @var string alt text for "first page" (use "%d" placeholder for page number)
205
     * @access private
212
     * @access private
206
     */
213
     */
207
    var $_altFirst     = 'first page';
214
    var $_altFirst     = 'first page';
208
 
215
 
209
    /**
216
    /**
210
     * @var string alt text for "previous page"
217
     * @var string alt text for "previous page"
211
     * @access private
218
     * @access private
212
     */
219
     */
213
    var $_altPrev     = 'previous page';
220
    var $_altPrev     = 'previous page';
214
 
221
 
215
    /**
222
    /**
216
     * @var string alt text for "next page"
223
     * @var string alt text for "next page"
217
     * @access private
224
     * @access private
218
     */
225
     */
219
    var $_altNext     = 'next page';
226
    var $_altNext     = 'next page';
220
 
227
 
221
    /**
228
    /**
222
     * @var string alt text for "last page" (use "%d" placeholder for page number)
229
     * @var string alt text for "last page" (use "%d" placeholder for page number)
223
     * @access private
230
     * @access private
224
     */
231
     */
225
    var $_altLast     = 'last page';
232
    var $_altLast     = 'last page';
226
 
233
 
227
    /**
234
    /**
228
     * @var string alt text for "page"
235
     * @var string alt text for "page"
229
     * @access private
236
     * @access private
230
     */
237
     */
231
    var $_altPage     = 'page';
238
    var $_altPage     = 'page';
232
 
239
 
233
    /**
240
    /**
234
     * @var string image/text to use as "prev" link
241
     * @var string image/text to use as "prev" link
235
     * @access private
242
     * @access private
236
     */
243
     */
237
    var $_prevImg     = '&lt;&lt; Back';
244
    var $_prevImg     = '&lt;&lt; Back';
238
 
245
 
239
    /**
246
    /**
240
     * @var string image/text to use as "next" link
247
     * @var string image/text to use as "next" link
241
     * @access private
248
     * @access private
242
     */
249
     */
243
    var $_nextImg     = 'Next &gt;&gt;';
250
    var $_nextImg     = 'Next &gt;&gt;';
244
 
251
 
245
    /**
252
    /**
246
     * @var string link separator
253
     * @var string link separator
247
     * @access private
254
     * @access private
248
     */
255
     */
249
    var $_separator   = '';
256
    var $_separator   = '';
250
 
257
 
251
    /**
258
    /**
252
     * @var integer number of spaces before separator
259
     * @var integer number of spaces before separator
253
     * @access private
260
     * @access private
254
     */
261
     */
255
    var $_spacesBeforeSeparator = 0;
262
    var $_spacesBeforeSeparator = 0;
256
 
263
 
257
    /**
264
    /**
258
     * @var integer number of spaces after separator
265
     * @var integer number of spaces after separator
259
     * @access private
266
     * @access private
260
     */
267
     */
261
    var $_spacesAfterSeparator  = 1;
268
    var $_spacesAfterSeparator  = 1;
262
 
269
 
263
    /**
270
    /**
264
     * @var string CSS class name for current page link
271
     * @var string CSS class name for current page link
265
     * @access private
272
     * @access private
266
     */
273
     */
267
    var $_curPageLinkClassName  = '';
274
    var $_curPageLinkClassName  = '';
268
 
275
 
269
    /**
276
    /**
270
     * @var string Text before current page link
277
     * @var string Text before current page link
271
     * @access private
278
     * @access private
272
     */
279
     */
273
    var $_curPageSpanPre        = '';
280
    var $_curPageSpanPre        = '';
274
 
281
 
275
    /**
282
    /**
276
     * @var string Text after current page link
283
     * @var string Text after current page link
277
     * @access private
284
     * @access private
278
     */
285
     */
279
    var $_curPageSpanPost       = '';
286
    var $_curPageSpanPost       = '';
280
 
287
 
281
    /**
288
    /**
282
     * @var string Text before first page link
289
     * @var string Text before first page link
283
     * @access private
290
     * @access private
284
     */
291
     */
285
    var $_firstPagePre  = '[';
292
    var $_firstPagePre  = '[';
286
 
293
 
287
    /**
294
    /**
288
     * @var string Text to be used for first page link
295
     * @var string Text to be used for first page link
289
     * @access private
296
     * @access private
290
     */
297
     */
291
    var $_firstPageText = '';
298
    var $_firstPageText = '';
292
 
299
 
293
    /**
300
    /**
294
     * @var string Text after first page link
301
     * @var string Text after first page link
295
     * @access private
302
     * @access private
296
     */
303
     */
297
    var $_firstPagePost = ']';
304
    var $_firstPagePost = ']';
298
 
305
 
299
    /**
306
    /**
300
     * @var string Text before last page link
307
     * @var string Text before last page link
301
     * @access private
308
     * @access private
302
     */
309
     */
303
    var $_lastPagePre   = '[';
310
    var $_lastPagePre   = '[';
304
 
311
 
305
    /**
312
    /**
306
     * @var string Text to be used for last page link
313
     * @var string Text to be used for last page link
307
     * @access private
314
     * @access private
308
     */
315
     */
309
    var $_lastPageText  = '';
316
    var $_lastPageText  = '';
310
 
317
 
311
    /**
318
    /**
312
     * @var string Text after last page link
319
     * @var string Text after last page link
313
     * @access private
320
     * @access private
314
     */
321
     */
315
    var $_lastPagePost  = ']';
322
    var $_lastPagePost  = ']';
316
 
323
 
317
    /**
324
    /**
318
     * @var string Will contain the HTML code for the spaces
325
     * @var string Will contain the HTML code for the spaces
319
     * @access private
326
     * @access private
320
     */
327
     */
321
    var $_spacesBefore  = '';
328
    var $_spacesBefore  = '';
322
 
329
 
323
    /**
330
    /**
324
     * @var string Will contain the HTML code for the spaces
331
     * @var string Will contain the HTML code for the spaces
325
     * @access private
332
     * @access private
326
     */
333
     */
327
    var $_spacesAfter   = '';
334
    var $_spacesAfter   = '';
328
 
335
 
329
    /**
336
    /**
330
     * @var string $_firstLinkTitle
337
     * @var string $_firstLinkTitle
331
     * @access private
338
     * @access private
332
     */
339
     */
333
    var $_firstLinkTitle = 'first page';
340
    var $_firstLinkTitle = 'first page';
334
 
341
 
335
    /**
342
    /**
336
     * @var string $_nextLinkTitle
343
     * @var string $_nextLinkTitle
337
     * @access private
344
     * @access private
338
     */
345
     */
339
    var $_nextLinkTitle = 'next page';
346
    var $_nextLinkTitle = 'next page';
340
 
347
 
341
    /**
348
    /**
342
     * @var string $_prevLinkTitle
349
     * @var string $_prevLinkTitle
343
     * @access private
350
     * @access private
344
     */
351
     */
345
    var $_prevLinkTitle = 'previous page';
352
    var $_prevLinkTitle = 'previous page';
346
 
353
 
347
    /**
354
    /**
348
     * @var string $_lastLinkTitle
355
     * @var string $_lastLinkTitle
349
     * @access private
356
     * @access private
350
     */
357
     */
351
    var $_lastLinkTitle = 'last page';
358
    var $_lastLinkTitle = 'last page';
352
 
359
 
353
    /**
360
    /**
354
     * @var string Text to be used for the 'show all' option in the select box
361
     * @var string Text to be used for the 'show all' option in the select box
355
     * @access private
362
     * @access private
356
     */
363
     */
357
    var $_showAllText   = '';
364
    var $_showAllText   = '';
358
 
365
 
359
    /**
366
    /**
360
     * @var array data to be paged
367
     * @var array data to be paged
361
     * @access private
368
     * @access private
362
     */
369
     */
363
    var $_itemData      = null;
370
    var $_itemData      = null;
364
 
371
 
365
    /**
372
    /**
366
     * @var boolean If TRUE and there's only one page, links aren't shown
373
     * @var boolean If TRUE and there's only one page, links aren't shown
367
     * @access private
374
     * @access private
368
     */
375
     */
369
    var $_clearIfVoid   = true;
376
    var $_clearIfVoid   = true;
370
 
377
 
371
    /**
378
    /**
372
     * @var boolean Use session for storing the number of items per page
379
     * @var boolean Use session for storing the number of items per page
373
     * @access private
380
     * @access private
374
     */
381
     */
375
    var $_useSessions   = false;
382
    var $_useSessions   = false;
376
 
383
 
377
    /**
384
    /**
378
     * @var boolean Close the session when finished reading/writing data
385
     * @var boolean Close the session when finished reading/writing data
379
     * @access private
386
     * @access private
380
     */
387
     */
381
    var $_closeSession  = false;
388
    var $_closeSession  = false;
382
 
389
 
383
    /**
390
    /**
384
     * @var string name of the session var for number of items per page
391
     * @var string name of the session var for number of items per page
385
     * @access private
392
     * @access private
386
     */
393
     */
387
    var $_sessionVar    = 'setPerPage';
394
    var $_sessionVar    = 'setPerPage';
388
 
395
 
389
    /**
396
    /**
390
     * Pear error mode (when raiseError is called)
397
     * Pear error mode (when raiseError is called)
391
     * (see PEAR doc)
398
     * (see PEAR doc)
392
     *
399
     *
393
     * @var int $_pearErrorMode
400
     * @var int $_pearErrorMode
394
     * @access private
401
     * @access private
395
     */
402
     */
396
    var $_pearErrorMode = null;
403
    var $_pearErrorMode = null;
397
 
404
 
398
    // }}}
405
    // }}}
399
    // {{{ public vars
406
    // {{{ public vars
400
 
407
 
401
    /**
408
    /**
402
     * @var string Complete set of links
409
     * @var string Complete set of links
403
     * @access public
410
     * @access public
404
     */
411
     */
405
    var $links = '';
412
    var $links = '';
406
 
413
 
407
    /**
414
    /**
408
     * @var string Complete set of link tags
415
     * @var string Complete set of link tags
409
     * @access public
416
     * @access public
410
     */
417
     */
411
    var $linkTags = '';
418
    var $linkTags = '';
412
 
419
 
413
    /**
420
    /**
414
     * @var array Array with a key => value pair representing
421
     * @var array Array with a key => value pair representing
415
     *            page# => bool value (true if key==currentPageNumber).
422
     *            page# => bool value (true if key==currentPageNumber).
416
     *            can be used for extreme customization.
423
     *            can be used for extreme customization.
417
     * @access public
424
     * @access public
418
     */
425
     */
419
    var $range = array();
426
    var $range = array();
420
    
427
    
421
    /**
428
    /**
422
     * @var array list of available options (safety check)
429
     * @var array list of available options (safety check)
423
     * @access private
430
     * @access private
424
     */
431
     */
425
    var $_allowed_options = array(
432
    var $_allowed_options = array(
426
        'totalItems',
433
        'totalItems',
427
        'perPage',
434
        'perPage',
428
        'delta',
435
        'delta',
429
        'linkClass',
436
        'linkClass',
430
        'path',
437
        'path',
431
        'fileName',
438
        'fileName',
432
        'fixFileName',
439
        'fixFileName',
433
        'append',
440
        'append',
434
        'httpMethod',
441
        'httpMethod',
435
        'formID',
442
        'formID',
436
        'importQuery',
443
        'importQuery',
437
        'urlVar',
444
        'urlVar',
438
        'altFirst',
445
        'altFirst',
439
        'altPrev',
446
        'altPrev',
440
        'altNext',
447
        'altNext',
441
        'altLast',
448
        'altLast',
442
        'altPage',
449
        'altPage',
443
        'prevImg',
450
        'prevImg',
444
        'nextImg',
451
        'nextImg',
445
        'expanded',
452
        'expanded',
446
        'accesskey',
453
        'accesskey',
447
        'attributes',
454
        'attributes',
-
 
455
        'onclick',
448
        'separator',
456
        'separator',
449
        'spacesBeforeSeparator',
457
        'spacesBeforeSeparator',
450
        'spacesAfterSeparator',
458
        'spacesAfterSeparator',
451
        'curPageLinkClassName',
459
        'curPageLinkClassName',
452
        'curPageSpanPre',
460
        'curPageSpanPre',
453
        'curPageSpanPost',
461
        'curPageSpanPost',
454
        'firstPagePre',
462
        'firstPagePre',
455
        'firstPageText',
463
        'firstPageText',
456
        'firstPagePost',
464
        'firstPagePost',
457
        'lastPagePre',
465
        'lastPagePre',
458
        'lastPageText',
466
        'lastPageText',
459
        'lastPagePost',
467
        'lastPagePost',
460
        'firstLinkTitle',
468
        'firstLinkTitle',
461
        'nextLinkTitle',
469
        'nextLinkTitle',
462
        'prevLinkTitle',
470
        'prevLinkTitle',
463
        'lastLinkTitle',
471
        'lastLinkTitle',
464
        'showAllText',
472
        'showAllText',
465
        'itemData',
473
        'itemData',
466
        'clearIfVoid',
474
        'clearIfVoid',
467
        'useSessions',
475
        'useSessions',
468
        'closeSession',
476
        'closeSession',
469
        'sessionVar',
477
        'sessionVar',
470
        'pearErrorMode',
478
        'pearErrorMode',
471
        'extraVars',
479
        'extraVars',
472
        'excludeVars',
480
        'excludeVars',
473
        'currentPage',
481
        'currentPage',
474
    );
482
    );
475
 
483
 
476
    // }}}
484
    // }}}
477
    // {{{ build()
485
    // {{{ build()
478
    
486
 
479
    /**
487
    /**
480
     * Generate or refresh the links and paged data after a call to setOptions()
488
     * Generate or refresh the links and paged data after a call to setOptions()
481
     *
489
     *
482
     * @access public
490
     * @access public
483
     */
491
     */
484
    function build()
492
    function build()
485
    {
493
    {
-
 
494
        //reset
-
 
495
        $this->_pageData = array();
-
 
496
        $this->links = '';
-
 
497
 
486
        $msg = '<b>PEAR::Pager Error:</b>'
498
        $this->_generatePageData();
-
 
499
        $this->_setFirstLastText();
-
 
500
 
-
 
501
        if ($this->_totalPages > (2 * $this->_delta + 1)) {
487
              .' function "build()" not implemented.';
502
            $this->links .= $this->_printFirstPage();
-
 
503
        }
-
 
504
 
-
 
505
        $this->links .= $this->_getBackLink();
-
 
506
        $this->links .= $this->_getPageLinks();
-
 
507
        $this->links .= $this->_getNextLink();
-
 
508
 
-
 
509
        $this->linkTags .= $this->_getFirstLinkTag();
-
 
510
        $this->linkTags .= $this->_getPrevLinkTag();
-
 
511
        $this->linkTags .= $this->_getNextLinkTag();
-
 
512
        $this->linkTags .= $this->_getLastLinkTag();
-
 
513
 
-
 
514
        if ($this->_totalPages > (2 * $this->_delta + 1)) {
488
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
515
            $this->links .= $this->_printLastPage();
-
 
516
        }
489
    }
517
    }
490
 
518
 
491
    // }}}
519
    // }}}
492
    // {{{ getPageData()
520
    // {{{ getPageData()
493
 
521
 
494
    /**
522
    /**
495
     * Returns an array of current pages data
523
     * Returns an array of current pages data
496
     *
524
     *
497
     * @param $pageID Desired page ID (optional)
525
     * @param $pageID Desired page ID (optional)
498
     * @return array Page data
526
     * @return array Page data
499
     * @access public
527
     * @access public
500
     */
528
     */
501
    function getPageData($pageID = null)
529
    function getPageData($pageID = null)
502
    {
530
    {
503
        $pageID = empty($pageID) ? $this->_currentPage : $pageID;
531
        $pageID = empty($pageID) ? $this->_currentPage : $pageID;
504
 
532
 
505
        if (!isset($this->_pageData)) {
533
        if (!isset($this->_pageData)) {
506
            $this->_generatePageData();
534
            $this->_generatePageData();
507
        }
535
        }
508
        if (!empty($this->_pageData[$pageID])) {
536
        if (!empty($this->_pageData[$pageID])) {
509
            return $this->_pageData[$pageID];
537
            return $this->_pageData[$pageID];
510
        }
538
        }
511
        return array();
539
        return array();
512
    }
540
    }
513
 
541
 
514
    // }}}
542
    // }}}
515
    // {{{ getPageIdByOffset()
543
    // {{{ getPageIdByOffset()
516
 
544
 
517
    /**
545
    /**
518
     * Returns pageID for given offset
546
     * Returns pageID for given offset
519
     *
547
     *
520
     * @param $index Offset to get pageID for
548
     * @param $index Offset to get pageID for
521
     * @return int PageID for given offset
549
     * @return int PageID for given offset
522
     */
550
     */
523
    function getPageIdByOffset($index)
551
    function getPageIdByOffset($index)
524
    {
552
    {
525
        $msg = '<b>PEAR::Pager Error:</b>'
553
        $msg = '<b>PEAR::Pager Error:</b>'
526
              .' function "getPageIdByOffset()" not implemented.';
554
              .' function "getPageIdByOffset()" not implemented.';
527
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
555
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
528
    }
556
    }
529
 
557
 
530
    // }}}
558
    // }}}
531
    // {{{ getOffsetByPageId()
559
    // {{{ getOffsetByPageId()
532
 
560
 
533
    /**
561
    /**
534
     * Returns offsets for given pageID. Eg, if you
562
     * Returns offsets for given pageID. Eg, if you
535
     * pass it pageID one and your perPage limit is 10
563
     * pass it pageID one and your perPage limit is 10
536
     * it will return (1, 10). PageID of 2 would
564
     * it will return (1, 10). PageID of 2 would
537
     * give you (11, 20).
565
     * give you (11, 20).
538
     *
566
     *
539
     * @param integer PageID to get offsets for
567
     * @param integer PageID to get offsets for
540
     * @return array  First and last offsets
568
     * @return array  First and last offsets
541
     * @access public
569
     * @access public
542
     */
570
     */
543
    function getOffsetByPageId($pageid = null)
571
    function getOffsetByPageId($pageid = null)
544
    {
572
    {
545
        $pageid = isset($pageid) ? $pageid : $this->_currentPage;
573
        $pageid = isset($pageid) ? $pageid : $this->_currentPage;
546
        if (!isset($this->_pageData)) {
574
        if (!isset($this->_pageData)) {
547
            $this->_generatePageData();
575
            $this->_generatePageData();
548
        }
576
        }
549
 
577
 
550
        if (isset($this->_pageData[$pageid]) || is_null($this->_itemData)) {
578
        if (isset($this->_pageData[$pageid]) || is_null($this->_itemData)) {
551
            return array(
579
            return array(
552
                        max(($this->_perPage * ($pageid - 1)) + 1, 1),
580
                        max(($this->_perPage * ($pageid - 1)) + 1, 1),
553
                        min($this->_totalItems, $this->_perPage * $pageid)
581
                        min($this->_totalItems, $this->_perPage * $pageid)
554
                   );
582
                   );
555
        } else {
583
        } else {
556
            return array(0, 0);
584
            return array(0, 0);
557
        }
585
        }
558
    }
586
    }
559
 
587
 
560
    // }}}
588
    // }}}
561
    // {{{ getPageRangeByPageId()
589
    // {{{ getPageRangeByPageId()
562
 
590
 
563
    /**
591
    /**
564
     * @param integer PageID to get offsets for
592
     * @param integer PageID to get offsets for
565
     * @return array  First and last offsets
593
     * @return array  First and last offsets
566
     */
594
     */
567
    function getPageRangeByPageId($pageID)
595
    function getPageRangeByPageId($pageID)
568
    {
596
    {
569
        $msg = '<b>PEAR::Pager Error:</b>'
597
        $msg = '<b>PEAR::Pager Error:</b>'
570
              .' function "getPageRangeByPageId()" not implemented.';
598
              .' function "getPageRangeByPageId()" not implemented.';
571
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
599
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
572
    }
600
    }
573
 
601
 
574
    // }}}
602
    // }}}
575
    // {{{ getLinks()
603
    // {{{ getLinks()
576
 
604
 
577
    /**
605
    /**
578
     * Returns back/next/first/last and page links,
606
     * Returns back/next/first/last and page links,
579
     * both as ordered and associative array.
607
     * both as ordered and associative array.
580
     *
608
     *
581
     * NB: in original PEAR::Pager this method accepted two parameters,
609
     * NB: in original PEAR::Pager this method accepted two parameters,
582
     * $back_html and $next_html. Now the only parameter accepted is
610
     * $back_html and $next_html. Now the only parameter accepted is
583
     * an integer ($pageID), since the html text for prev/next links can
611
     * an integer ($pageID), since the html text for prev/next links can
584
     * be set in the factory. If a second parameter is provided, then
612
     * be set in the factory. If a second parameter is provided, then
585
     * the method act as it previously did. This hack was done to mantain
613
     * the method act as it previously did. This hack was done to mantain
586
     * backward compatibility only.
614
     * backward compatibility only.
587
     *
615
     *
588
     * @param integer $pageID Optional pageID. If specified, links
616
     * @param integer $pageID Optional pageID. If specified, links
589
     *                for that page are provided instead of current one.  [ADDED IN NEW PAGER VERSION]
617
     *                for that page are provided instead of current one.  [ADDED IN NEW PAGER VERSION]
590
     * @param  string $next_html HTML to put inside the next link [deprecated: use the factory instead]
618
     * @param  string $next_html HTML to put inside the next link [deprecated: use the factory instead]
591
     * @return array back/next/first/last and page links
619
     * @return array back/next/first/last and page links
592
     */
620
     */
593
    function getLinks($pageID=null, $next_html='')
621
    function getLinks($pageID=null, $next_html='')
594
    {
622
    {
595
        $msg = '<b>PEAR::Pager Error:</b>'
623
        $msg = '<b>PEAR::Pager Error:</b>'
596
              .' function "getLinks()" not implemented.';
624
              .' function "getLinks()" not implemented.';
597
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
625
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
598
    }
626
    }
599
 
627
 
600
    // }}}
628
    // }}}
601
    // {{{ getCurrentPageID()
629
    // {{{ getCurrentPageID()
602
 
630
 
603
    /**
631
    /**
604
     * Returns ID of current page
632
     * Returns ID of current page
605
     *
633
     *
606
     * @return integer ID of current page
634
     * @return integer ID of current page
607
     */
635
     */
608
    function getCurrentPageID()
636
    function getCurrentPageID()
609
    {
637
    {
610
        return $this->_currentPage;
638
        return $this->_currentPage;
611
    }
639
    }
612
 
640
 
613
    // }}}
641
    // }}}
614
    // {{{ getNextPageID()
642
    // {{{ getNextPageID()
615
 
643
 
616
    /**
644
    /**
617
     * Returns next page ID. If current page is last page
645
     * Returns next page ID. If current page is last page
618
	 * this function returns FALSE
646
	 * this function returns FALSE
619
	 *
647
	 *
620
	 * @return mixed Next page ID
648
	 * @return mixed Next page ID
621
     */
649
     */
622
	function getNextPageID()
650
	function getNextPageID()
623
	{
651
	{
624
		return ($this->getCurrentPageID() == $this->numPages() ? false : $this->getCurrentPageID() + 1);
652
		return ($this->getCurrentPageID() == $this->numPages() ? false : $this->getCurrentPageID() + 1);
625
	}
653
	}
626
 
654
 
627
	// }}}
655
	// }}}
628
    // {{{ getPreviousPageID()
656
    // {{{ getPreviousPageID()
629
 
657
 
630
    /**
658
    /**
631
     * Returns previous page ID. If current page is first page
659
     * Returns previous page ID. If current page is first page
632
	 * this function returns FALSE
660
	 * this function returns FALSE
633
	 *
661
	 *
634
	 * @return mixed Previous pages' ID
662
	 * @return mixed Previous pages' ID
635
     */
663
     */
636
	function getPreviousPageID()
664
	function getPreviousPageID()
637
	{
665
	{
638
		return $this->isFirstPage() ? false : $this->getCurrentPageID() - 1;
666
		return $this->isFirstPage() ? false : $this->getCurrentPageID() - 1;
639
	}
667
	}
640
 
668
 
641
    // }}}
669
    // }}}
642
    // {{{ numItems()
670
    // {{{ numItems()
643
 
671
 
644
    /**
672
    /**
645
     * Returns number of items
673
     * Returns number of items
646
     *
674
     *
647
     * @return int Number of items
675
     * @return int Number of items
648
     */
676
     */
649
    function numItems()
677
    function numItems()
650
    {
678
    {
651
        return $this->_totalItems;
679
        return $this->_totalItems;
652
    }
680
    }
653
 
681
 
654
    // }}}
682
    // }}}
655
    // {{{ numPages()
683
    // {{{ numPages()
656
 
684
 
657
    /**
685
    /**
658
     * Returns number of pages
686
     * Returns number of pages
659
     *
687
     *
660
     * @return int Number of pages
688
     * @return int Number of pages
661
     */
689
     */
662
    function numPages()
690
    function numPages()
663
    {
691
    {
664
        return (int)$this->_totalPages;
692
        return (int)$this->_totalPages;
665
    }
693
    }
666
 
694
 
667
    // }}}
695
    // }}}
668
    // {{{ isFirstPage()
696
    // {{{ isFirstPage()
669
 
697
 
670
    /**
698
    /**
671
     * Returns whether current page is first page
699
     * Returns whether current page is first page
672
     *
700
     *
673
     * @return bool First page or not
701
     * @return bool First page or not
674
     */
702
     */
675
    function isFirstPage()
703
    function isFirstPage()
676
    {
704
    {
677
        return ($this->_currentPage < 2);
705
        return ($this->_currentPage < 2);
678
    }
706
    }
679
 
707
 
680
    // }}}
708
    // }}}
681
    // {{{ isLastPage()
709
    // {{{ isLastPage()
682
 
710
 
683
    /**
711
    /**
684
     * Returns whether current page is last page
712
     * Returns whether current page is last page
685
     *
713
     *
686
     * @return bool Last page or not
714
     * @return bool Last page or not
687
     */
715
     */
688
    function isLastPage()
716
    function isLastPage()
689
    {
717
    {
690
        return ($this->_currentPage == $this->_totalPages);
718
        return ($this->_currentPage == $this->_totalPages);
691
    }
719
    }
692
 
720
 
693
    // }}}
721
    // }}}
694
    // {{{ isLastPageComplete()
722
    // {{{ isLastPageComplete()
695
 
723
 
696
    /**
724
    /**
697
     * Returns whether last page is complete
725
     * Returns whether last page is complete
698
     *
726
     *
699
     * @return bool Last age complete or not
727
     * @return bool Last age complete or not
700
     */
728
     */
701
    function isLastPageComplete()
729
    function isLastPageComplete()
702
    {
730
    {
703
        return !($this->_totalItems % $this->_perPage);
731
        return !($this->_totalItems % $this->_perPage);
704
    }
732
    }
705
 
733
 
706
    // }}}
734
    // }}}
707
    // {{{ _generatePageData()
735
    // {{{ _generatePageData()
708
 
736
 
709
    /**
737
    /**
710
     * Calculates all page data
738
     * Calculates all page data
711
     * @access private
739
     * @access private
712
     */
740
     */
713
    function _generatePageData()
741
    function _generatePageData()
714
    {
742
    {
715
        // Been supplied an array of data?
743
        // Been supplied an array of data?
716
        if (!is_null($this->_itemData)) {
744
        if (!is_null($this->_itemData)) {
717
            $this->_totalItems = count($this->_itemData);
745
            $this->_totalItems = count($this->_itemData);
718
        }
746
        }
719
        $this->_totalPages = ceil((float)$this->_totalItems / (float)$this->_perPage);
747
        $this->_totalPages = ceil((float)$this->_totalItems / (float)$this->_perPage);
720
        $i = 1;
748
        $i = 1;
721
        if (!empty($this->_itemData)) {
749
        if (!empty($this->_itemData)) {
722
            foreach ($this->_itemData as $key => $value) {
750
            foreach ($this->_itemData as $key => $value) {
723
                $this->_pageData[$i][$key] = $value;
751
                $this->_pageData[$i][$key] = $value;
724
                if (count($this->_pageData[$i]) >= $this->_perPage) {
752
                if (count($this->_pageData[$i]) >= $this->_perPage) {
725
                    $i++;
753
                    $i++;
726
                }
754
                }
727
            }
755
            }
728
        } else {
756
        } else {
729
            $this->_pageData = array();
757
            $this->_pageData = array();
730
        }
758
        }
731
 
759
 
732
        //prevent URL modification
760
        //prevent URL modification
733
        $this->_currentPage = min($this->_currentPage, $this->_totalPages);
761
        $this->_currentPage = min($this->_currentPage, $this->_totalPages);
734
    }
762
    }
735
 
763
 
736
    // }}}
764
    // }}}
737
    // {{{ _renderLink()
765
    // {{{ _renderLink()
738
 
766
 
739
    /**
767
    /**
740
     * Renders a link using the appropriate method
768
     * Renders a link using the appropriate method
741
     *
769
     *
742
     * @param altText Alternative text for this link (title property)
770
     * @param altText Alternative text for this link (title property)
743
     * @param linkText Text contained by this link
771
     * @param linkText Text contained by this link
744
     * @return string The link in string form
772
     * @return string The link in string form
745
     * @access private
773
     * @access private
746
     */
774
     */
747
    function _renderLink($altText, $linkText)
775
    function _renderLink($altText, $linkText)
748
    {
776
    {
749
        if ($this->_httpMethod == 'GET') {
777
        if ($this->_httpMethod == 'GET') {
750
            if ($this->_append) {
778
            if ($this->_append) {
751
                $href = '?' . $this->_http_build_query_wrapper($this->_linkData);
779
                $href = '?' . $this->_http_build_query_wrapper($this->_linkData);
752
            } else {
780
            } else {
753
                $href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
781
                $href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
754
            }
782
            }
-
 
783
            $onclick = '';
-
 
784
            if (array_key_exists($this->_urlVar, $this->_linkData)) {
-
 
785
                $onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick);
-
 
786
            }
755
            return sprintf('<a href="%s"%s%s%s title="%s">%s</a>',
787
            return sprintf('<a href="%s"%s%s%s%s title="%s">%s</a>',
756
                           htmlentities($this->_url . $href),
788
                           htmlentities($this->_url . $href),
757
                           empty($this->_classString) ? '' : ' '.$this->_classString,
789
                           empty($this->_classString) ? '' : ' '.$this->_classString,
758
                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
790
                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
759
                           empty($this->_accesskey)   ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
791
                           empty($this->_accesskey)   ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
-
 
792
                           empty($onclick)            ? '' : ' onclick="'.$onclick.'"',
760
                           $altText,
793
                           $altText,
761
                           $linkText
794
                           $linkText
762
            );
795
            );
763
        } elseif ($this->_httpMethod == 'POST') {
796
        } elseif ($this->_httpMethod == 'POST') {
764
            return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
797
            return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
765
                           $this->_generateFormOnClick($this->_url, $this->_linkData),
798
                           $this->_generateFormOnClick($this->_url, $this->_linkData),
766
                           empty($this->_classString) ? '' : ' '.$this->_classString,
799
                           empty($this->_classString) ? '' : ' '.$this->_classString,
767
                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
800
                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
768
                           empty($this->_accesskey)   ? '' : ' accesskey=\''.$this->_linkData[$this->_urlVar].'\'',
801
                           empty($this->_accesskey)   ? '' : ' accesskey=\''.$this->_linkData[$this->_urlVar].'\'',
769
                           $altText,
802
                           $altText,
770
                           $linkText
803
                           $linkText
771
            );
804
            );
772
        }
805
        }
773
        return '';
806
        return '';
774
    }
807
    }
775
 
808
 
776
    // }}}
809
    // }}}
777
    // {{{ _generateFormOnClick()
810
    // {{{ _generateFormOnClick()
778
 
811
 
779
    /**
812
    /**
780
     * Mimics http_build_query() behavior in the way the data
813
     * Mimics http_build_query() behavior in the way the data
781
     * in $data will appear when it makes it back to the server.
814
     * in $data will appear when it makes it back to the server.
782
     *  For example:
815
     *  For example:
783
     * $arr =  array('array' => array(array('hello', 'world'),
816
     * $arr =  array('array' => array(array('hello', 'world'),
784
     *                                'things' => array('stuff', 'junk'));
817
     *                                'things' => array('stuff', 'junk'));
785
     * http_build_query($arr)
818
     * http_build_query($arr)
786
     * and _generateFormOnClick('foo.php', $arr)
819
     * and _generateFormOnClick('foo.php', $arr)
787
     * will yield
820
     * will yield
788
     * $_REQUEST['array'][0][0] === 'hello'
821
     * $_REQUEST['array'][0][0] === 'hello'
789
     * $_REQUEST['array'][0][1] === 'world'
822
     * $_REQUEST['array'][0][1] === 'world'
790
     * $_REQUEST['array']['things'][0] === 'stuff'
823
     * $_REQUEST['array']['things'][0] === 'stuff'
791
     * $_REQUEST['array']['things'][1] === 'junk'
824
     * $_REQUEST['array']['things'][1] === 'junk'
792
     *
825
     *
793
     * However, instead of  generating a query string, it generates
826
     * However, instead of  generating a query string, it generates
794
     * Javascript to create and submit a form.
827
     * Javascript to create and submit a form.
795
     *
828
     *
796
     * @param string $formAction where the form should be submitted
829
     * @param string $formAction where the form should be submitted
797
     * @param array  $data the associative array of names and values
830
     * @param array  $data the associative array of names and values
798
     * @return string A string of javascript that generates a form and submits it
831
     * @return string A string of javascript that generates a form and submits it
799
     * @access private
832
     * @access private
800
     */
833
     */
801
    function _generateFormOnClick($formAction, $data)
834
    function _generateFormOnClick($formAction, $data)
802
    {
835
    {
803
        // Check we have an array to work with
836
        // Check we have an array to work with
804
        if (!is_array($data)) {
837
        if (!is_array($data)) {
805
            trigger_error(
838
            trigger_error(
806
                '_generateForm() Parameter 1 expected to be Array or Object. Incorrect value given.',
839
                '_generateForm() Parameter 1 expected to be Array or Object. Incorrect value given.',
807
                E_USER_WARNING
840
                E_USER_WARNING
808
            );
841
            );
809
            return false;
842
            return false;
810
        }
843
        }
811
 
844
 
812
        if (!empty($this->_formID)) {
845
        if (!empty($this->_formID)) {
813
            $str = 'var form = document.getElementById("'.$this->_formID.'"); var input = ""; ';
846
            $str = 'var form = document.getElementById("'.$this->_formID.'"); var input = ""; ';
814
        } else {
847
        } else {
815
            $str = 'var form = document.createElement("form"); var input = ""; ';
848
            $str = 'var form = document.createElement("form"); var input = ""; ';
816
        }
849
        }
817
        
850
        
818
        // We /shouldn't/ need to escape the URL ...
851
        // We /shouldn't/ need to escape the URL ...
819
        $str .= sprintf('form.action = "%s"; ', htmlentities($formAction));
852
        $str .= sprintf('form.action = "%s"; ', htmlentities($formAction));
820
        $str .= sprintf('form.method = "%s"; ', $this->_httpMethod);
853
        $str .= sprintf('form.method = "%s"; ', $this->_httpMethod);
821
        foreach ($data as $key => $val) {
854
        foreach ($data as $key => $val) {
822
            $str .= $this->_generateFormOnClickHelper($val, $key);
855
            $str .= $this->_generateFormOnClickHelper($val, $key);
823
        }
856
        }
824
 
857
 
825
        if (empty($this->_formID)) {
858
        if (empty($this->_formID)) {
826
            $str .= 'document.getElementsByTagName("body")[0].appendChild(form);';
859
            $str .= 'document.getElementsByTagName("body")[0].appendChild(form);';
827
        }
860
        }
828
        
861
        
829
        $str .= 'form.submit(); return false;';
862
        $str .= 'form.submit(); return false;';
830
        return $str;
863
        return $str;
831
    }
864
    }
832
 
865
 
833
    // }}}
866
    // }}}
834
    // {{{ _generateFormOnClickHelper
867
    // {{{ _generateFormOnClickHelper
835
 
868
 
836
    /**
869
    /**
837
     * This is used by _generateFormOnClick(). 
870
     * This is used by _generateFormOnClick(). 
838
     * Recursively processes the arrays, objects, and literal values.
871
     * Recursively processes the arrays, objects, and literal values.
839
     *
872
     *
840
     * @param data Data that should be rendered
873
     * @param data Data that should be rendered
841
     * @param prev The name so far
874
     * @param prev The name so far
842
     * @return string A string of Javascript that creates form inputs
875
     * @return string A string of Javascript that creates form inputs
843
     *                representing the data
876
     *                representing the data
844
     * @access private
877
     * @access private
845
     */
878
     */
846
    function _generateFormOnClickHelper($data, $prev = '')
879
    function _generateFormOnClickHelper($data, $prev = '')
847
    {
880
    {
848
        $str = '';
881
        $str = '';
849
        if (is_array($data) || is_object($data)) {
882
        if (is_array($data) || is_object($data)) {
850
            // foreach key/visible member
883
            // foreach key/visible member
851
            foreach ((array)$data as $key => $val) {
884
            foreach ((array)$data as $key => $val) {
852
                // append [$key] to prev
885
                // append [$key] to prev
853
                $tempKey = sprintf('%s[%s]', $prev, $key);
886
                $tempKey = sprintf('%s[%s]', $prev, $key);
854
                $str .= $this->_generateFormOnClickHelper($val, $tempKey);
887
                $str .= $this->_generateFormOnClickHelper($val, $tempKey);
855
            }
888
            }
856
        } else {  // must be a literal value
889
        } else {  // must be a literal value
857
            // escape newlines and carriage returns
890
            // escape newlines and carriage returns
858
            $search  = array("\n", "\r");
891
            $search  = array("\n", "\r");
859
            $replace = array('\n', '\n');
892
            $replace = array('\n', '\n');
860
            $escapedData = str_replace($search, $replace, $data);
893
            $escapedData = str_replace($search, $replace, $data);
861
            // am I forgetting any dangerous whitespace?
894
            // am I forgetting any dangerous whitespace?
862
            // would a regex be faster?
895
            // would a regex be faster?
863
            // if it's already encoded, don't encode it again
896
            // if it's already encoded, don't encode it again
864
            if (!$this->_isEncoded($escapedData)) {
897
            if (!$this->_isEncoded($escapedData)) {
865
                $escapedData = urlencode($escapedData);
898
                $escapedData = urlencode($escapedData);
866
            }
899
            }
867
            $escapedData = htmlentities($escapedData, ENT_QUOTES, 'UTF-8');
900
            $escapedData = htmlentities($escapedData, ENT_QUOTES, 'UTF-8');
868
 
901
 
869
            $str .= 'input = document.createElement("input"); ';
902
            $str .= 'input = document.createElement("input"); ';
870
            $str .= 'input.type = "hidden"; ';
903
            $str .= 'input.type = "hidden"; ';
871
            $str .= sprintf('input.name = "%s"; ', $prev);
904
            $str .= sprintf('input.name = "%s"; ', $prev);
872
            $str .= sprintf('input.value = "%s"; ', $escapedData);
905
            $str .= sprintf('input.value = "%s"; ', $escapedData);
873
            $str .= 'form.appendChild(input); ';
906
            $str .= 'form.appendChild(input); ';
874
        }
907
        }
875
        return $str;
908
        return $str;
876
    }
909
    }
877
 
910
 
878
    // }}}
911
    // }}}
879
    // {{{ _getLinksData()
912
    // {{{ _getLinksData()
880
 
913
 
881
    /**
914
    /**
882
     * Returns the correct link for the back/pages/next links
915
     * Returns the correct link for the back/pages/next links
883
     *
916
     *
884
     * @return array Data
917
     * @return array Data
885
     * @access private
918
     * @access private
886
     */
919
     */
887
    function _getLinksData()
920
    function _getLinksData()
888
    {
921
    {
889
        $qs = array();
922
        $qs = array();
890
        if ($this->_importQuery) {
923
        if ($this->_importQuery) {
891
            if ($this->_httpMethod == 'POST') {
924
            if ($this->_httpMethod == 'POST') {
892
                $qs = $_POST;
925
                $qs = $_POST;
893
            } elseif ($this->_httpMethod == 'GET') {
926
            } elseif ($this->_httpMethod == 'GET') {
894
                $qs = $_GET;
927
                $qs = $_GET;
895
            }
928
            }
896
        }
929
        }
897
        if (count($this->_extraVars)){
-
 
898
            $this->_recursive_urldecode($this->_extraVars);
-
 
899
        }
-
 
900
        $qs = array_merge($qs, $this->_extraVars);
-
 
901
        foreach ($this->_excludeVars as $exclude) {
930
        foreach ($this->_excludeVars as $exclude) {
902
            if (array_key_exists($exclude, $qs)) {
931
            if (array_key_exists($exclude, $qs)) {
903
                unset($qs[$exclude]);
932
                unset($qs[$exclude]);
904
            }
933
            }
905
        }
934
        }
-
 
935
        if (count($this->_extraVars)){
-
 
936
            $this->_recursive_urldecode($this->_extraVars);
-
 
937
            $qs = array_merge($qs, $this->_extraVars);
-
 
938
        }
906
        if (count($qs) && get_magic_quotes_gpc()){
939
        if (count($qs) && get_magic_quotes_gpc()){
907
            $this->_recursive_stripslashes($qs);
940
            $this->_recursive_stripslashes($qs);
908
        }
941
        }
909
        return $qs;
942
        return $qs;
910
    }
943
    }
911
 
944
 
912
    // }}}
945
    // }}}
913
    // {{{ _recursive_stripslashes()
946
    // {{{ _recursive_stripslashes()
914
    
947
    
915
    /**
948
    /**
916
     * Helper method
949
     * Helper method
917
     * @param mixed $var
950
     * @param mixed $var
918
     * @access private
951
     * @access private
919
     */
952
     */
920
    function _recursive_stripslashes(&$var)
953
    function _recursive_stripslashes(&$var)
921
    {
954
    {
922
        if (is_array($var)) {
955
        if (is_array($var)) {
923
            foreach (array_keys($var) as $k) {
956
            foreach (array_keys($var) as $k) {
924
                $this->_recursive_stripslashes($var[$k]);
957
                $this->_recursive_stripslashes($var[$k]);
925
            }
958
            }
926
        } else {
959
        } else {
927
            $var = stripslashes($var);
960
            $var = stripslashes($var);
928
        }
961
        }
929
    }
962
    }
930
 
963
 
931
    // }}}
964
    // }}}
932
    // {{{ _recursive_urldecode()
965
    // {{{ _recursive_urldecode()
933
 
966
 
934
    /**
967
    /**
935
     * Helper method
968
     * Helper method
936
     * @param mixed $var
969
     * @param mixed $var
937
     * @access private
970
     * @access private
938
     */
971
     */
939
    function _recursive_urldecode(&$var)
972
    function _recursive_urldecode(&$var)
940
    {
973
    {
941
        if (is_array($var)) {
974
        if (is_array($var)) {
942
            foreach (array_keys($var) as $k) {
975
            foreach (array_keys($var) as $k) {
943
                $this->_recursive_urldecode($var[$k]);
976
                $this->_recursive_urldecode($var[$k]);
944
            }
977
            }
945
        } else {
978
        } else {
946
            $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES));
979
            $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES));
947
            $var = strtr($var, $trans_tbl);
980
            $var = strtr($var, $trans_tbl);
948
        }
981
        }
949
    }
982
    }
950
 
983
 
951
    // }}}
984
    // }}}
952
    // {{{ _getBackLink()
985
    // {{{ _getBackLink()
953
 
986
 
954
    /**
987
    /**
955
     * Returns back link
988
     * Returns back link
956
     *
989
     *
957
     * @param $url  URL to use in the link  [deprecated: use the factory instead]
990
     * @param $url  URL to use in the link  [deprecated: use the factory instead]
958
     * @param $link HTML to use as the link [deprecated: use the factory instead]
991
     * @param $link HTML to use as the link [deprecated: use the factory instead]
959
     * @return string The link
992
     * @return string The link
960
     * @access private
993
     * @access private
961
     */
994
     */
962
    function _getBackLink($url='', $link='')
995
    function _getBackLink($url='', $link='')
963
    {
996
    {
964
        //legacy settings... the preferred way to set an option
997
        //legacy settings... the preferred way to set an option
965
        //now is passing it to the factory
998
        //now is passing it to the factory
966
        if (!empty($url)) {
999
        if (!empty($url)) {
967
            $this->_path = $url;
1000
            $this->_path = $url;
968
        }
1001
        }
969
        if (!empty($link)) {
1002
        if (!empty($link)) {
970
            $this->_prevImg = $link;
1003
            $this->_prevImg = $link;
971
        }
1004
        }
972
        $back = '';
1005
        $back = '';
973
        if ($this->_currentPage > 1) {
1006
        if ($this->_currentPage > 1) {
974
            $this->_linkData[$this->_urlVar] = $this->getPreviousPageID();
1007
            $this->_linkData[$this->_urlVar] = $this->getPreviousPageID();
975
            $back = $this->_renderLink($this->_altPrev, $this->_prevImg)
1008
            $back = $this->_renderLink($this->_altPrev, $this->_prevImg)
976
                  . $this->_spacesBefore . $this->_spacesAfter;
1009
                  . $this->_spacesBefore . $this->_spacesAfter;
977
        }
1010
        }
978
        return $back;
1011
        return $back;
979
    }
1012
    }
980
 
1013
 
981
    // }}}
1014
    // }}}
982
    // {{{ _getPageLinks()
1015
    // {{{ _getPageLinks()
983
 
1016
 
984
    /**
1017
    /**
985
     * Returns pages link
1018
     * Returns pages link
986
     *
1019
     *
987
     * @param $url  URL to use in the link [deprecated: use the factory instead]
1020
     * @param $url  URL to use in the link [deprecated: use the factory instead]
988
     * @return string Links
1021
     * @return string Links
989
     * @access private
1022
     * @access private
990
     */
1023
     */
991
    function _getPageLinks($url='')
1024
    function _getPageLinks($url='')
992
    {
1025
    {
993
        $msg = '<b>PEAR::Pager Error:</b>'
1026
        $msg = '<b>PEAR::Pager Error:</b>'
994
              .' function "_getPageLinks()" not implemented.';
1027
              .' function "_getPageLinks()" not implemented.';
995
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
1028
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
996
    }
1029
    }
997
 
1030
 
998
    // }}}
1031
    // }}}
999
    // {{{ _getNextLink()
1032
    // {{{ _getNextLink()
1000
 
1033
 
1001
    /**
1034
    /**
1002
     * Returns next link
1035
     * Returns next link
1003
     *
1036
     *
1004
     * @param $url  URL to use in the link  [deprecated: use the factory instead]
1037
     * @param $url  URL to use in the link  [deprecated: use the factory instead]
1005
     * @param $link HTML to use as the link [deprecated: use the factory instead]
1038
     * @param $link HTML to use as the link [deprecated: use the factory instead]
1006
     * @return string The link
1039
     * @return string The link
1007
     * @access private
1040
     * @access private
1008
     */
1041
     */
1009
    function _getNextLink($url='', $link='')
1042
    function _getNextLink($url='', $link='')
1010
    {
1043
    {
1011
        //legacy settings... the preferred way to set an option
1044
        //legacy settings... the preferred way to set an option
1012
        //now is passing it to the factory
1045
        //now is passing it to the factory
1013
        if (!empty($url)) {
1046
        if (!empty($url)) {
1014
            $this->_path = $url;
1047
            $this->_path = $url;
1015
        }
1048
        }
1016
        if (!empty($link)) {
1049
        if (!empty($link)) {
1017
            $this->_nextImg = $link;
1050
            $this->_nextImg = $link;
1018
        }
1051
        }
1019
        $next = '';
1052
        $next = '';
1020
        if ($this->_currentPage < $this->_totalPages) {
1053
        if ($this->_currentPage < $this->_totalPages) {
1021
            $this->_linkData[$this->_urlVar] = $this->getNextPageID();
1054
            $this->_linkData[$this->_urlVar] = $this->getNextPageID();
1022
            $next = $this->_spacesAfter
1055
            $next = $this->_spacesAfter
1023
                  . $this->_renderLink($this->_altNext, $this->_nextImg)
1056
                  . $this->_renderLink($this->_altNext, $this->_nextImg)
1024
                  . $this->_spacesBefore . $this->_spacesAfter;
1057
                  . $this->_spacesBefore . $this->_spacesAfter;
1025
        }
1058
        }
1026
        return $next;
1059
        return $next;
1027
    }
1060
    }
1028
 
1061
 
1029
    // }}}
1062
    // }}}
1030
    // {{{ _getFirstLinkTag()
1063
    // {{{ _getFirstLinkTag()
1031
 
1064
 
1032
    /**
1065
    /**
1033
     * @return string
1066
     * @return string
1034
     * @access private
1067
     * @access private
1035
     */
1068
     */
1036
    function _getFirstLinkTag()
1069
    function _getFirstLinkTag()
1037
    {
1070
    {
1038
        if ($this->isFirstPage() || ($this->_httpMethod != 'GET')) {
1071
        if ($this->isFirstPage() || ($this->_httpMethod != 'GET')) {
1039
            return '';
1072
            return '';
1040
        }
1073
        }
1041
        return sprintf('<link rel="first" href="%s" title="%s" />'."\n",
1074
        return sprintf('<link rel="first" href="%s" title="%s" />'."\n",
1042
            $this->_getLinkTagUrl(1),
1075
            $this->_getLinkTagUrl(1),
1043
            $this->_firstLinkTitle
1076
            $this->_firstLinkTitle
1044
        );
1077
        );
1045
    }
1078
    }
1046
 
1079
 
1047
    // }}}
1080
    // }}}
1048
    // {{{ _getPrevLinkTag()
1081
    // {{{ _getPrevLinkTag()
1049
 
1082
 
1050
    /**
1083
    /**
1051
     * Returns previous link tag
1084
     * Returns previous link tag
1052
     *
1085
     *
1053
     * @return string the link tag
1086
     * @return string the link tag
1054
     * @access private
1087
     * @access private
1055
     */
1088
     */
1056
    function _getPrevLinkTag()
1089
    function _getPrevLinkTag()
1057
    {
1090
    {
1058
        if ($this->isFirstPage() || ($this->_httpMethod != 'GET')) {
1091
        if ($this->isFirstPage() || ($this->_httpMethod != 'GET')) {
1059
            return '';
1092
            return '';
1060
        }
1093
        }
1061
        return sprintf('<link rel="previous" href="%s" title="%s" />'."\n",
1094
        return sprintf('<link rel="previous" href="%s" title="%s" />'."\n",
1062
            $this->_getLinkTagUrl($this->getPreviousPageID()),
1095
            $this->_getLinkTagUrl($this->getPreviousPageID()),
1063
            $this->_prevLinkTitle
1096
            $this->_prevLinkTitle
1064
        );
1097
        );
1065
    }
1098
    }
1066
 
1099
 
1067
    // }}}
1100
    // }}}
1068
    // {{{ _getNextLinkTag()
1101
    // {{{ _getNextLinkTag()
1069
 
1102
 
1070
    /**
1103
    /**
1071
     * Returns next link tag
1104
     * Returns next link tag
1072
     *
1105
     *
1073
     * @return string the link tag
1106
     * @return string the link tag
1074
     * @access private
1107
     * @access private
1075
     */
1108
     */
1076
    function _getNextLinkTag()
1109
    function _getNextLinkTag()
1077
    {
1110
    {
1078
        if ($this->isLastPage() || ($this->_httpMethod != 'GET')) {
1111
        if ($this->isLastPage() || ($this->_httpMethod != 'GET')) {
1079
            return '';
1112
            return '';
1080
        }
1113
        }
1081
        return sprintf('<link rel="next" href="%s" title="%s" />'."\n",
1114
        return sprintf('<link rel="next" href="%s" title="%s" />'."\n",
1082
            $this->_getLinkTagUrl($this->getNextPageID()),
1115
            $this->_getLinkTagUrl($this->getNextPageID()),
1083
            $this->_nextLinkTitle
1116
            $this->_nextLinkTitle
1084
        );
1117
        );
1085
    }
1118
    }
1086
 
1119
 
1087
    // }}}
1120
    // }}}
1088
    // {{{ _getLastLinkTag()
1121
    // {{{ _getLastLinkTag()
1089
 
1122
 
1090
    /**
1123
    /**
1091
     * @return string the link tag
1124
     * @return string the link tag
1092
     * @access private
1125
     * @access private
1093
     */
1126
     */
1094
    function _getLastLinkTag()
1127
    function _getLastLinkTag()
1095
    {
1128
    {
1096
        if ($this->isLastPage() || ($this->_httpMethod != 'GET')) {
1129
        if ($this->isLastPage() || ($this->_httpMethod != 'GET')) {
1097
            return '';
1130
            return '';
1098
        }
1131
        }
1099
        return sprintf('<link rel="last" href="%s" title="%s" />'."\n",
1132
        return sprintf('<link rel="last" href="%s" title="%s" />'."\n",
1100
            $this->_getLinkTagUrl($this->_totalPages),
1133
            $this->_getLinkTagUrl($this->_totalPages),
1101
            $this->_lastLinkTitle
1134
            $this->_lastLinkTitle
1102
        );
1135
        );
1103
    }
1136
    }
1104
 
1137
 
1105
    // }}}
1138
    // }}}
1106
    // {{{ _getLinkTagUrl()
1139
    // {{{ _getLinkTagUrl()
1107
 
1140
 
1108
    /**
1141
    /**
1109
     * Helper method
1142
     * Helper method
1110
     * @return string the link tag url
1143
     * @return string the link tag url
1111
     * @access private
1144
     * @access private
1112
     */
1145
     */
1113
    function _getLinkTagUrl($pageID)
1146
    function _getLinkTagUrl($pageID)
1114
    {
1147
    {
1115
        $this->_linkData[$this->_urlVar] = $pageID;
1148
        $this->_linkData[$this->_urlVar] = $pageID;
1116
        if ($this->_append) {
1149
        if ($this->_append) {
1117
            $href = '?' . $this->_http_build_query_wrapper($this->_linkData);
1150
            $href = '?' . $this->_http_build_query_wrapper($this->_linkData);
1118
        } else {
1151
        } else {
1119
            $href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
1152
            $href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
1120
        }
1153
        }
1121
        return htmlentities($this->_url . $href);
1154
        return htmlentities($this->_url . $href);
1122
    }
1155
    }
1123
    
1156
    
1124
    // }}}
1157
    // }}}
1125
    // {{{ getPerPageSelectBox()
1158
    // {{{ getPerPageSelectBox()
1126
 
1159
 
1127
    /**
1160
    /**
1128
     * Returns a string with a XHTML SELECT menu,
1161
     * Returns a string with a XHTML SELECT menu,
1129
     * useful for letting the user choose how many items per page should be
1162
     * useful for letting the user choose how many items per page should be
1130
     * displayed. If parameter useSessions is TRUE, this value is stored in
1163
     * displayed. If parameter useSessions is TRUE, this value is stored in
1131
     * a session var. The string isn't echoed right now so you can use it
1164
     * a session var. The string isn't echoed right now so you can use it
1132
     * with template engines.
1165
     * with template engines.
1133
     *
1166
     *
1134
     * @param integer $start
1167
     * @param integer $start
1135
     * @param integer $end
1168
     * @param integer $end
1136
     * @param integer $step
1169
     * @param integer $step
1137
     * @param boolean $showAllData If true, perPage is set equal to totalItems.
1170
     * @param boolean $showAllData If true, perPage is set equal to totalItems.
1138
     * @param array   (or string $optionText for BC reasons)
1171
     * @param array   (or string $optionText for BC reasons)
1139
     *                - 'optionText': text to show in each option.
1172
     *                - 'optionText': text to show in each option.
1140
     *                  Use '%d' where you want to see the number of pages selected.
1173
     *                  Use '%d' where you want to see the number of pages selected.
1141
     *                - 'attributes': (html attributes) Tag attributes or
1174
     *                - 'attributes': (html attributes) Tag attributes or
1142
     *                  HTML attributes (id="foo" pairs), will be inserted in the
1175
     *                  HTML attributes (id="foo" pairs), will be inserted in the
1143
     *                  <select> tag
1176
     *                  <select> tag
1144
     * @return string xhtml select box
1177
     * @return string xhtml select box
1145
     * @access public
1178
     * @access public
1146
     */
1179
     */
1147
    function getPerPageSelectBox($start=5, $end=30, $step=5, $showAllData=false, $extraParams=array())
1180
    function getPerPageSelectBox($start=5, $end=30, $step=5, $showAllData=false, $extraParams=array())
1148
    {
1181
    {
1149
        require_once 'Pager/HtmlWidgets.php';
1182
        require_once 'Pager/HtmlWidgets.php';
1150
        $widget =& new Pager_HtmlWidgets($this);
1183
        $widget =& new Pager_HtmlWidgets($this);
1151
        return $widget->getPerPageSelectBox($start, $end, $step, $showAllData, $extraParams);
1184
        return $widget->getPerPageSelectBox($start, $end, $step, $showAllData, $extraParams);
1152
    }
1185
    }
1153
 
1186
 
1154
    // }}}
1187
    // }}}
1155
    // {{{ getPageSelectBox()
1188
    // {{{ getPageSelectBox()
1156
 
1189
 
1157
    /**
1190
    /**
1158
     * Returns a string with a XHTML SELECT menu with the page numbers,
1191
     * Returns a string with a XHTML SELECT menu with the page numbers,
1159
     * useful as an alternative to the links
1192
     * useful as an alternative to the links
1160
     *
1193
     *
1161
     * @param array   - 'optionText': text to show in each option.
1194
     * @param array   - 'optionText': text to show in each option.
1162
     *                  Use '%d' where you want to see the number of pages selected.
1195
     *                  Use '%d' where you want to see the number of pages selected.
1163
     *                - 'autoSubmit': if TRUE, add some js code to submit the
1196
     *                - 'autoSubmit': if TRUE, add some js code to submit the
1164
     *                  form on the onChange event
1197
     *                  form on the onChange event
1165
     * @param string   $extraAttributes (html attributes) Tag attributes or
1198
     * @param string   $extraAttributes (html attributes) Tag attributes or
1166
     *                  HTML attributes (id="foo" pairs), will be inserted in the
1199
     *                  HTML attributes (id="foo" pairs), will be inserted in the
1167
     *                  <select> tag
1200
     *                  <select> tag
1168
     * @return string xhtml select box
1201
     * @return string xhtml select box
1169
     * @access public
1202
     * @access public
1170
     */
1203
     */
1171
    function getPageSelectBox($params = array(), $extraAttributes = '')
1204
    function getPageSelectBox($params = array(), $extraAttributes = '')
1172
    {
1205
    {
1173
        require_once 'Pager/HtmlWidgets.php';
1206
        require_once 'Pager/HtmlWidgets.php';
1174
        $widget =& new Pager_HtmlWidgets($this);
1207
        $widget =& new Pager_HtmlWidgets($this);
1175
        return $widget->getPageSelectBox($params, $extraAttributes);
1208
        return $widget->getPageSelectBox($params, $extraAttributes);
1176
    }
1209
    }
1177
 
1210
 
1178
    // }}}
1211
    // }}}
1179
    // {{{ _printFirstPage()
1212
    // {{{ _printFirstPage()
1180
 
1213
 
1181
    /**
1214
    /**
1182
     * Print [1]
1215
     * Print [1]
1183
     *
1216
     *
1184
     * @return string String with link to 1st page,
1217
     * @return string String with link to 1st page,
1185
     *                or empty string if this is the 1st page.
1218
     *                or empty string if this is the 1st page.
1186
     * @access private
1219
     * @access private
1187
     */
1220
     */
1188
    function _printFirstPage()
1221
    function _printFirstPage()
1189
    {
1222
    {
1190
        if ($this->isFirstPage()) {
1223
        if ($this->isFirstPage()) {
1191
            return '';
1224
            return '';
1192
        }
1225
        }
1193
        $this->_linkData[$this->_urlVar] = 1;
1226
        $this->_linkData[$this->_urlVar] = 1;
1194
        return $this->_renderLink(
1227
        return $this->_renderLink(
1195
                str_replace('%d', 1, $this->_altFirst),
1228
                str_replace('%d', 1, $this->_altFirst),
1196
                $this->_firstPagePre . $this->_firstPageText . $this->_firstPagePost
1229
                $this->_firstPagePre . $this->_firstPageText . $this->_firstPagePost
1197
        ) . $this->_spacesBefore . $this->_spacesAfter;
1230
        ) . $this->_spacesBefore . $this->_spacesAfter;
1198
    }
1231
    }
1199
 
1232
 
1200
    // }}}
1233
    // }}}
1201
    // {{{ _printLastPage()
1234
    // {{{ _printLastPage()
1202
 
1235
 
1203
    /**
1236
    /**
1204
     * Print [numPages()]
1237
     * Print [numPages()]
1205
     *
1238
     *
1206
     * @return string String with link to last page,
1239
     * @return string String with link to last page,
1207
     *                or empty string if this is the 1st page.
1240
     *                or empty string if this is the 1st page.
1208
     * @access private
1241
     * @access private
1209
     */
1242
     */
1210
    function _printLastPage()
1243
    function _printLastPage()
1211
    {
1244
    {
1212
        if ($this->isLastPage()) {
1245
        if ($this->isLastPage()) {
1213
            return '';
1246
            return '';
1214
        }
1247
        }
1215
        $this->_linkData[$this->_urlVar] = $this->_totalPages;
1248
        $this->_linkData[$this->_urlVar] = $this->_totalPages;
1216
        return $this->_renderLink(
1249
        return $this->_renderLink(
1217
                str_replace('%d', $this->_totalPages, $this->_altLast),
1250
                str_replace('%d', $this->_totalPages, $this->_altLast),
1218
                $this->_lastPagePre . $this->_lastPageText . $this->_lastPagePost
1251
                $this->_lastPagePre . $this->_lastPageText . $this->_lastPagePost
1219
        );
1252
        );
1220
    }
1253
    }
1221
 
1254
 
1222
    // }}}
1255
    // }}}
1223
    // {{{ _setFirstLastText()
1256
    // {{{ _setFirstLastText()
1224
 
1257
 
1225
    /**
1258
    /**
1226
     * sets the private _firstPageText, _lastPageText variables
1259
     * sets the private _firstPageText, _lastPageText variables
1227
     * based on whether they were set in the options
1260
     * based on whether they were set in the options
1228
     *
1261
     *
1229
     * @access private
1262
     * @access private
1230
     */
1263
     */
1231
    function _setFirstLastText()
1264
    function _setFirstLastText()
1232
    {
1265
    {
1233
        if ($this->_firstPageText == '') {
1266
        if ($this->_firstPageText == '') {
1234
            $this->_firstPageText = '1';
1267
            $this->_firstPageText = '1';
1235
        }
1268
        }
1236
        if ($this->_lastPageText == '') {
1269
        if ($this->_lastPageText == '') {
1237
            $this->_lastPageText = $this->_totalPages;
1270
            $this->_lastPageText = $this->_totalPages;
1238
        }
1271
        }
1239
    }
1272
    }
1240
 
1273
 
1241
    // }}}
1274
    // }}}
1242
    // {{{ _http_build_query_wrapper()
1275
    // {{{ _http_build_query_wrapper()
1243
    
1276
    
1244
    /**
1277
    /**
1245
     * This is a slightly modified version of the http_build_query() function;
1278
     * This is a slightly modified version of the http_build_query() function;
1246
     * it heavily borrows code from PHP_Compat's http_build_query().
1279
     * it heavily borrows code from PHP_Compat's http_build_query().
1247
     * The main change is the usage of htmlentities instead of urlencode,
1280
     * The main change is the usage of htmlentities instead of urlencode,
1248
     * since it's too aggressive
1281
     * since it's too aggressive
1249
     *
1282
     *
1250
     * @author Stephan Schmidt <schst@php.net>
1283
     * @author Stephan Schmidt <schst@php.net>
1251
     * @author Aidan Lister <aidan@php.net>
1284
     * @author Aidan Lister <aidan@php.net>
1252
     * @author Lorenzo Alberton <l dot alberton at quipo dot it>
1285
     * @author Lorenzo Alberton <l dot alberton at quipo dot it>
1253
     * @param array $data
1286
     * @param array $data
1254
     * @return string
1287
     * @return string
1255
     * @access private
1288
     * @access private
1256
     */
1289
     */
1257
    function _http_build_query_wrapper($data)
1290
    function _http_build_query_wrapper($data)
1258
    {
1291
    {
1259
        $data = (array)$data;
1292
        $data = (array)$data;
1260
        if (empty($data)) {
1293
        if (empty($data)) {
1261
            return '';
1294
            return '';
1262
        }
1295
        }
1263
        $separator = ini_get('arg_separator.output');
1296
        $separator = ini_get('arg_separator.output');
1264
        if ($separator == '&amp;') {
1297
        if ($separator == '&amp;') {
1265
            $separator = '&'; //the string is escaped by htmlentities anyway...
1298
            $separator = '&'; //the string is escaped by htmlentities anyway...
1266
        }
1299
        }
1267
        $tmp = array ();
1300
        $tmp = array ();
1268
        foreach ($data as $key => $val) {
1301
        foreach ($data as $key => $val) {
1269
            if (is_scalar($val)) {
1302
            if (is_scalar($val)) {
1270
                //array_push($tmp, $key.'='.$val);
1303
                //array_push($tmp, $key.'='.$val);
1271
                $val = urlencode($val);
1304
                $val = urlencode($val);
1272
                array_push($tmp, $key .'='. str_replace('%2F', '/', $val));
1305
                array_push($tmp, $key .'='. str_replace('%2F', '/', $val));
1273
                continue;
1306
                continue;
1274
            }
1307
            }
1275
            // If the value is an array, recursively parse it
1308
            // If the value is an array, recursively parse it
1276
            if (is_array($val)) {
1309
            if (is_array($val)) {
1277
                array_push($tmp, $this->__http_build_query($val, htmlentities($key)));
1310
                array_push($tmp, $this->__http_build_query($val, htmlentities($key)));
1278
                continue;
1311
                continue;
1279
            }
1312
            }
1280
        }
1313
        }
1281
        return implode($separator, $tmp);
1314
        return implode($separator, $tmp);
1282
    }
1315
    }
1283
 
1316
 
1284
    // }}}
1317
    // }}}
1285
    // {{{ __http_build_query()
1318
    // {{{ __http_build_query()
1286
 
1319
 
1287
    /**
1320
    /**
1288
     * Helper function
1321
     * Helper function
1289
     * @author Stephan Schmidt <schst@php.net>
1322
     * @author Stephan Schmidt <schst@php.net>
1290
     * @author Aidan Lister <aidan@php.net>
1323
     * @author Aidan Lister <aidan@php.net>
1291
     * @access private
1324
     * @access private
1292
     */
1325
     */
1293
    function __http_build_query($array, $name)
1326
    function __http_build_query($array, $name)
1294
    {
1327
    {
1295
        $tmp = array ();
1328
        $tmp = array ();
-
 
1329
        $separator = ini_get('arg_separator.output');
-
 
1330
        if ($separator == '&amp;') {
-
 
1331
            $separator = '&'; //the string is escaped by htmlentities anyway...
-
 
1332
        }
1296
        foreach ($array as $key => $value) {
1333
        foreach ($array as $key => $value) {
1297
            if (is_array($value)) {
1334
            if (is_array($value)) {
1298
                //array_push($tmp, $this->__http_build_query($value, sprintf('%s[%s]', $name, $key)));
1335
                //array_push($tmp, $this->__http_build_query($value, sprintf('%s[%s]', $name, $key)));
1299
                array_push($tmp, $this->__http_build_query($value, $name.'%5B'.$key.'%5D'));
1336
                array_push($tmp, $this->__http_build_query($value, $name.'%5B'.$key.'%5D'));
1300
            } elseif (is_scalar($value)) {
1337
            } elseif (is_scalar($value)) {
1301
                //array_push($tmp, sprintf('%s[%s]=%s', $name, htmlentities($key), htmlentities($value)));
1338
                //array_push($tmp, sprintf('%s[%s]=%s', $name, htmlentities($key), htmlentities($value)));
1302
                array_push($tmp, $name.'%5B'.htmlentities($key).'%5D='.htmlentities($value));
1339
                array_push($tmp, $name.'%5B'.htmlentities($key).'%5D='.htmlentities($value));
1303
            } elseif (is_object($value)) {
1340
            } elseif (is_object($value)) {
1304
                //array_push($tmp, $this->__http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
1341
                //array_push($tmp, $this->__http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
1305
                array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D'));
1342
                array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D'));
1306
            }
1343
            }
1307
        }
1344
        }
1308
        return implode(ini_get('arg_separator.output'), $tmp);
1345
        return implode($separator, $tmp);
1309
    }
1346
    }
1310
 
1347
 
1311
    // }}}
1348
    // }}}
1312
    // {{{ _isEncoded()
1349
    // {{{ _isEncoded()
1313
 
1350
 
1314
    /**
1351
    /**
1315
     * Helper function
1352
     * Helper function
1316
     * Check if a string is an encoded multibyte string
1353
     * Check if a string is an encoded multibyte string
1317
     * @param string $string
1354
     * @param string $string
1318
     * @return boolean
1355
     * @return boolean
1319
     * @access private
1356
     * @access private
1320
     */
1357
     */
1321
    
1358
    
1322
    function _isEncoded($string)
1359
    function _isEncoded($string)
1323
    {
1360
    {
1324
        $hexchar = '&#[\dA-Fx]{2,};';
1361
        $hexchar = '&#[\dA-Fx]{2,};';
1325
        return preg_match("/^(\s|($hexchar))*$/Uims", $string) ? true : false;
1362
        return preg_match("/^(\s|($hexchar))*$/Uims", $string) ? true : false;
1326
    }
1363
    }
1327
 
1364
 
1328
    // }}}
1365
    // }}}
1329
    // {{{ raiseError()
1366
    // {{{ raiseError()
1330
 
1367
 
1331
    /**
1368
    /**
1332
     * conditionally includes PEAR base class and raise an error
1369
     * conditionally includes PEAR base class and raise an error
1333
     *
1370
     *
1334
     * @param string $msg  Error message
1371
     * @param string $msg  Error message
1335
     * @param int    $code Error code
1372
     * @param int    $code Error code
1336
     * @access private
1373
     * @access private
1337
     */
1374
     */
1338
    function raiseError($msg, $code)
1375
    function raiseError($msg, $code)
1339
    {
1376
    {
1340
        include_once 'PEAR.php';
1377
        include_once 'PEAR.php';
1341
        if (empty($this->_pearErrorMode)) {
1378
        if (empty($this->_pearErrorMode)) {
1342
            $this->_pearErrorMode = PEAR_ERROR_RETURN;
1379
            $this->_pearErrorMode = PEAR_ERROR_RETURN;
1343
        }
1380
        }
1344
        return PEAR::raiseError($msg, $code, $this->_pearErrorMode);
1381
        return PEAR::raiseError($msg, $code, $this->_pearErrorMode);
1345
    }
1382
    }
1346
 
1383
 
1347
    // }}}
1384
    // }}}
1348
    // {{{ setOptions()
1385
    // {{{ setOptions()
1349
 
1386
 
1350
    /**
1387
    /**
1351
     * Set and sanitize options
1388
     * Set and sanitize options
1352
     *
1389
     *
1353
     * @param mixed $options    An associative array of option names and
1390
     * @param mixed $options    An associative array of option names and
1354
     *                          their values.
1391
     *                          their values.
1355
     * @return integer error code (PAGER_OK on success)
1392
     * @return integer error code (PAGER_OK on success)
1356
     * @access public
1393
     * @access public
1357
     */
1394
     */
1358
    function setOptions($options)
1395
    function setOptions($options)
1359
    {
1396
    {
1360
        foreach ($options as $key => $value) {
1397
        foreach ($options as $key => $value) {
1361
            if (in_array($key, $this->_allowed_options) && (!is_null($value))) {
1398
            if (in_array($key, $this->_allowed_options) && (!is_null($value))) {
1362
                $this->{'_' . $key} = $value;
1399
                $this->{'_' . $key} = $value;
1363
            }
1400
            }
1364
        }
1401
        }
1365
 
1402
 
1366
        //autodetect http method
1403
        //autodetect http method
1367
        if (!isset($options['httpMethod'])
1404
        if (!isset($options['httpMethod'])
1368
            && !isset($_GET[$this->_urlVar])
1405
            && !isset($_GET[$this->_urlVar])
1369
            && isset($_POST[$this->_urlVar])
1406
            && isset($_POST[$this->_urlVar])
1370
        ) {
1407
        ) {
1371
            $this->_httpMethod = 'POST';
1408
            $this->_httpMethod = 'POST';
1372
        } else {
1409
        } else {
1373
            $this->_httpMethod = strtoupper($this->_httpMethod);
1410
            $this->_httpMethod = strtoupper($this->_httpMethod);
1374
        }
1411
        }
1375
 
1412
 
1376
        $this->_fileName = ltrim($this->_fileName, '/');  //strip leading slash
1413
        $this->_fileName = ltrim($this->_fileName, '/');  //strip leading slash
1377
        $this->_path     = rtrim($this->_path, '/');      //strip trailing slash
1414
        $this->_path     = rtrim($this->_path, '/');      //strip trailing slash
1378
 
1415
 
1379
        if ($this->_append) {
1416
        if ($this->_append) {
1380
            if ($this->_fixFileName) {
1417
            if ($this->_fixFileName) {
1381
                $this->_fileName = CURRENT_FILENAME; //avoid possible user error;
1418
                $this->_fileName = CURRENT_FILENAME; //avoid possible user error;
1382
            }
1419
            }
1383
            $this->_url = $this->_path.'/'.$this->_fileName;
1420
            $this->_url = $this->_path.'/'.$this->_fileName;
1384
        } else {
1421
        } else {
1385
            $this->_url = $this->_path;
1422
            $this->_url = $this->_path;
1386
            if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
1423
            if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
1387
                $this->_url .= '/';
1424
                $this->_url .= '/';
1388
            }
1425
            }
1389
            if (!strstr($this->_fileName, '%d')) {
1426
            if (strpos($this->_fileName, '%d') === false) {
1390
                trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
1427
                trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
1391
            }
1428
            }
1392
        }
1429
        }
1393
 
1430
 
1394
        $this->_classString = '';
1431
        $this->_classString = '';
1395
        if (strlen($this->_linkClass)) {
1432
        if (strlen($this->_linkClass)) {
1396
            $this->_classString = 'class="'.$this->_linkClass.'"';
1433
            $this->_classString = 'class="'.$this->_linkClass.'"';
1397
        }
1434
        }
1398
 
1435
 
1399
        if (strlen($this->_curPageLinkClassName)) {
1436
        if (strlen($this->_curPageLinkClassName)) {
1400
            $this->_curPageSpanPre  = '<span class="'.$this->_curPageLinkClassName.'">';
1437
            $this->_curPageSpanPre  = '<span class="'.$this->_curPageLinkClassName.'">';
1401
            $this->_curPageSpanPost = '</span>';
1438
            $this->_curPageSpanPost = '</span>';
1402
        }
1439
        }
1403
 
1440
 
1404
        $this->_perPage = max($this->_perPage, 1); //avoid possible user errors
1441
        $this->_perPage = max($this->_perPage, 1); //avoid possible user errors
1405
 
1442
 
1406
        if ($this->_useSessions && !isset($_SESSION)) {
1443
        if ($this->_useSessions && !isset($_SESSION)) {
1407
            session_start();
1444
            session_start();
1408
        }
1445
        }
1409
        if (!empty($_REQUEST[$this->_sessionVar])) {
1446
        if (!empty($_REQUEST[$this->_sessionVar])) {
1410
            $this->_perPage = max(1, (int)$_REQUEST[$this->_sessionVar]);
1447
            $this->_perPage = max(1, (int)$_REQUEST[$this->_sessionVar]);
1411
            if ($this->_useSessions) {
1448
            if ($this->_useSessions) {
1412
                $_SESSION[$this->_sessionVar] = $this->_perPage;
1449
                $_SESSION[$this->_sessionVar] = $this->_perPage;
1413
            }
1450
            }
1414
        }
1451
        }
1415
 
1452
 
1416
        if (!empty($_SESSION[$this->_sessionVar])) {
1453
        if (!empty($_SESSION[$this->_sessionVar])) {
1417
             $this->_perPage = $_SESSION[$this->_sessionVar];
1454
             $this->_perPage = $_SESSION[$this->_sessionVar];
1418
        }
1455
        }
1419
 
1456
 
1420
        if ($this->_closeSession) {
1457
        if ($this->_closeSession) {
1421
            session_write_close();
1458
            session_write_close();
1422
        }
1459
        }
1423
 
1460
 
1424
        $this->_spacesBefore = str_repeat('&nbsp;', $this->_spacesBeforeSeparator);
1461
        $this->_spacesBefore = str_repeat('&nbsp;', $this->_spacesBeforeSeparator);
1425
        $this->_spacesAfter  = str_repeat('&nbsp;', $this->_spacesAfterSeparator);
1462
        $this->_spacesAfter  = str_repeat('&nbsp;', $this->_spacesAfterSeparator);
1426
 
1463
 
1427
        if (isset($_REQUEST[$this->_urlVar]) && empty($options['currentPage'])) {
1464
        if (isset($_REQUEST[$this->_urlVar]) && empty($options['currentPage'])) {
1428
            $this->_currentPage = (int)$_REQUEST[$this->_urlVar];
1465
            $this->_currentPage = (int)$_REQUEST[$this->_urlVar];
1429
        }
1466
        }
1430
        $this->_currentPage = max($this->_currentPage, 1);
1467
        $this->_currentPage = max($this->_currentPage, 1);
1431
        $this->_linkData = $this->_getLinksData();
1468
        $this->_linkData = $this->_getLinksData();
1432
 
1469
 
1433
        return PAGER_OK;
1470
        return PAGER_OK;
1434
    }
1471
    }
1435
 
1472
 
1436
    // }}}
1473
    // }}}
1437
    // {{{ getOption()
1474
    // {{{ getOption()
1438
    
1475
    
1439
    /**
1476
    /**
1440
     * Return the current value of a given option
1477
     * Return the current value of a given option
1441
     *
1478
     *
1442
     * @param string option name
1479
     * @param string option name
1443
     * @return mixed option value
1480
     * @return mixed option value
1444
     */
1481
     */
1445
    function getOption($name)
1482
    function getOption($name)
1446
    {
1483
    {
1447
        if (!in_array($name, $this->_allowed_options)) {
1484
        if (!in_array($name, $this->_allowed_options)) {
1448
            $msg = '<b>PEAR::Pager Error:</b>'
1485
            $msg = '<b>PEAR::Pager Error:</b>'
1449
                  .' invalid option: '.$name;
1486
                  .' invalid option: '.$name;
1450
            return $this->raiseError($msg, ERROR_PAGER_INVALID);
1487
            return $this->raiseError($msg, ERROR_PAGER_INVALID);
1451
        }
1488
        }
1452
        return $this->{'_' . $name};
1489
        return $this->{'_' . $name};
1453
    }
1490
    }
1454
 
1491
 
1455
    // }}}
1492
    // }}}
1456
    // {{{ getOptions()
1493
    // {{{ getOptions()
1457
 
1494
 
1458
    /**
1495
    /**
1459
     * Return an array with all the current pager options
1496
     * Return an array with all the current pager options
1460
     *
1497
     *
1461
     * @return array list of all the pager options
1498
     * @return array list of all the pager options
1462
     */
1499
     */
1463
    function getOptions()
1500
    function getOptions()
1464
    {
1501
    {
1465
        $options = array();
1502
        $options = array();
1466
        foreach ($this->_allowed_options as $option) {
1503
        foreach ($this->_allowed_options as $option) {
1467
            $options[$option] = $this->{'_' . $option};
1504
            $options[$option] = $this->{'_' . $option};
1468
        }
1505
        }
1469
        return $options;
1506
        return $options;
1470
    }
1507
    }
1471
 
1508
 
1472
    // }}}
1509
    // }}}
1473
    // {{{ errorMessage()
1510
    // {{{ errorMessage()
1474
 
1511
 
1475
    /**
1512
    /**
1476
     * Return a textual error message for a PAGER error code
1513
     * Return a textual error message for a PAGER error code
1477
     *
1514
     *
1478
     * @param   int     $code error code
1515
     * @param   int     $code error code
1479
     * @return  string  error message
1516
     * @return  string  error message
1480
     * @access public
1517
     * @access public
1481
     */
1518
     */
1482
    function errorMessage($code)
1519
    function errorMessage($code)
1483
    {
1520
    {
1484
        static $errorMessages;
1521
        static $errorMessages;
1485
        if (!isset($errorMessages)) {
1522
        if (!isset($errorMessages)) {
1486
            $errorMessages = array(
1523
            $errorMessages = array(
1487
                ERROR_PAGER                     => 'unknown error',
1524
                ERROR_PAGER                     => 'unknown error',
1488
                ERROR_PAGER_INVALID             => 'invalid',
1525
                ERROR_PAGER_INVALID             => 'invalid',
1489
                ERROR_PAGER_INVALID_PLACEHOLDER => 'invalid format - use "%d" as placeholder.',
1526
                ERROR_PAGER_INVALID_PLACEHOLDER => 'invalid format - use "%d" as placeholder.',
1490
                ERROR_PAGER_INVALID_USAGE       => 'if $options[\'append\'] is set to false, '
1527
                ERROR_PAGER_INVALID_USAGE       => 'if $options[\'append\'] is set to false, '
1491
                                                  .' $options[\'fileName\'] MUST contain the "%d" placeholder.',
1528
                                                  .' $options[\'fileName\'] MUST contain the "%d" placeholder.',
1492
                ERROR_PAGER_NOT_IMPLEMENTED     => 'not implemented'
1529
                ERROR_PAGER_NOT_IMPLEMENTED     => 'not implemented'
1493
            );
1530
            );
1494
        }
1531
        }
1495
 
1532
 
1496
        return '<b>PEAR::Pager error:</b> '. (isset($errorMessages[$code]) ?
1533
        return '<b>PEAR::Pager error:</b> '. (isset($errorMessages[$code]) ?
1497
            $errorMessages[$code] : $errorMessages[ERROR_PAGER]);
1534
            $errorMessages[$code] : $errorMessages[ERROR_PAGER]);
1498
    }
1535
    }
1499
 
1536
 
1500
    // }}}
1537
    // }}}
1501
}
1538
}
1502
?>
1539
?>