| 115 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Project: SmartyPaginate: Pagination for the Smarty Template Engine
|
|
|
5 |
* File: function.paginate_prev.php
|
|
|
6 |
* Author: Monte Ohrt <monte at newdigitalgroup dot com>
|
|
|
7 |
*
|
|
|
8 |
* This library is free software; you can redistribute it and/or
|
|
|
9 |
* modify it under the terms of the GNU Lesser General Public
|
|
|
10 |
* License as published by the Free Software Foundation; either
|
|
|
11 |
* version 2.1 of the License, or (at your option) any later version.
|
|
|
12 |
*
|
|
|
13 |
* This library is distributed in the hope that it will be useful,
|
|
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
16 |
* Lesser General Public License for more details.
|
|
|
17 |
*
|
|
|
18 |
* You should have received a copy of the GNU Lesser General Public
|
|
|
19 |
* License along with this library; if not, write to the Free Software
|
|
|
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
21 |
*
|
|
|
22 |
* @link http://www.phpinsider.com/php/code/SmartyPaginate/
|
|
|
23 |
* @copyright 2001-2005 New Digital Group, Inc.
|
|
|
24 |
* @author Monte Ohrt <monte at newdigitalgroup dot com>
|
|
|
25 |
* @package SmartyPaginate
|
|
|
26 |
* @version 1.6-dev
|
|
|
27 |
*/
|
|
|
28 |
|
|
|
29 |
function smarty_function_paginate_prev($params, &$smarty) {
|
|
|
30 |
|
|
|
31 |
$_id = 'default';
|
|
|
32 |
$_attrs = array();
|
|
|
33 |
|
|
|
34 |
if (!class_exists('SmartyPaginate')) {
|
|
|
35 |
$smarty->trigger_error("paginate_prev: missing SmartyPaginate class");
|
|
|
36 |
return;
|
|
|
37 |
}
|
|
|
38 |
if (!isset($_SESSION['SmartyPaginate'])) {
|
|
|
39 |
$smarty->trigger_error("paginate_prev: SmartyPaginate is not initialized, use connect() first");
|
|
|
40 |
return;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
foreach($params as $_key => $_val) {
|
|
|
44 |
switch($_key) {
|
|
|
45 |
case 'id':
|
|
|
46 |
if (!SmartyPaginate::isConnected($_val)) {
|
|
|
47 |
$smarty->trigger_error("paginate_prev: unknown id '$_val'");
|
|
|
48 |
return;
|
|
|
49 |
}
|
|
|
50 |
$_id = $_val;
|
|
|
51 |
break;
|
|
|
52 |
default:
|
|
|
53 |
$_attrs[] = $_key . '="' . $_val . '"';
|
|
|
54 |
break;
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
if (SmartyPaginate::getTotal($_id) === false) {
|
|
|
59 |
$smarty->trigger_error("paginate_prev: total was not set");
|
|
|
60 |
return;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
$_url = SmartyPaginate::getURL($_id);
|
|
|
64 |
|
|
|
65 |
$_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
|
|
|
66 |
|
|
|
67 |
if(($_item = SmartyPaginate::_getPrevPageItem($_id)) !== false) {
|
|
|
68 |
$_show = true;
|
|
|
69 |
$_text = isset($params['text']) ? $params['text'] : SmartyPaginate::getPrevText($_id);
|
|
|
70 |
$_url .= (strpos($_url, '?') === false) ? '?' : '&';
|
|
|
71 |
$_url .= SmartyPaginate::getUrlVar($_id) . '=' . $_item;
|
|
|
72 |
} else {
|
|
|
73 |
$_show = false;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
return $_show ? '<a href="' . str_replace('&','&', $_url) . '"' . $_attrs . '>' . $_text . '</a>' : '';
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
?>
|