1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
pkg.php
|
5
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
6
|
Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
/*
|
31
|
pfSense_MODULE: pkgs
|
32
|
*/
|
33
|
|
34
|
##|+PRIV
|
35
|
##|*IDENT=page-package-settings
|
36
|
##|*NAME=Package: Settings page
|
37
|
##|*DESCR=Allow access to the 'Package: Settings' page.
|
38
|
##|*MATCH=pkg.php*
|
39
|
##|-PRIV
|
40
|
|
41
|
require_once("guiconfig.inc");
|
42
|
require_once("pkg-utils.inc");
|
43
|
|
44
|
function gentitle_pkg($pgname) {
|
45
|
global $config;
|
46
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
47
|
}
|
48
|
|
49
|
function domTT_title($title_msg) {
|
50
|
print "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '".gettext($title_msg)."', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\"";
|
51
|
}
|
52
|
|
53
|
$xml = $_REQUEST['xml'];
|
54
|
|
55
|
if ($xml == "") {
|
56
|
print_info_box_np(gettext("ERROR: No package defined."));
|
57
|
exit;
|
58
|
} else {
|
59
|
if (file_exists("/usr/local/pkg/" . $xml)) {
|
60
|
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
|
61
|
} else {
|
62
|
echo "File not found " . htmlspecialchars($xml);
|
63
|
exit;
|
64
|
}
|
65
|
}
|
66
|
|
67
|
if ($pkg['donotsave'] <> "") {
|
68
|
header("Location: pkg_edit.php?xml=" . $xml);
|
69
|
exit;
|
70
|
}
|
71
|
|
72
|
if ($pkg['include_file'] != "") {
|
73
|
require_once($pkg['include_file']);
|
74
|
}
|
75
|
|
76
|
if ($_REQUEST['startdisplayingat']) {
|
77
|
$startdisplayingat = $_REQUEST['startdisplayingat'];
|
78
|
}
|
79
|
|
80
|
if ($_REQUEST['display_maximum_rows']) {
|
81
|
if ($_REQUEST['display_maximum_rows']) {
|
82
|
$display_maximum_rows = $_REQUEST['display_maximum_rows'];
|
83
|
}
|
84
|
}
|
85
|
|
86
|
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
87
|
|
88
|
if ($_GET['act'] == "update") {
|
89
|
|
90
|
if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
|
91
|
#get current values
|
92
|
$current_values=$config['installedpackages'][$pkg['name']]['config'];
|
93
|
#get updated ids
|
94
|
parse_str($_REQUEST['ids'], $update_list);
|
95
|
#sort ids to know what to change
|
96
|
#useful to do not lose data when using sorting and paging
|
97
|
$sort_list=$update_list['ids'];
|
98
|
sort($sort_list);
|
99
|
#apply updates
|
100
|
foreach ($update_list['ids'] as $key=> $value) {
|
101
|
$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
|
102
|
}
|
103
|
#save current config
|
104
|
write_config();
|
105
|
#sync package
|
106
|
eval ("{$pkg['custom_php_resync_config_command']}");
|
107
|
}
|
108
|
#function called via jquery, no need to continue after save changes.
|
109
|
exit;
|
110
|
}
|
111
|
if ($_GET['act'] == "del") {
|
112
|
// loop through our fieldnames and automatically setup the fieldnames
|
113
|
// in the environment. ie: a fieldname of username with a value of
|
114
|
// testuser would automatically eval $username = "testuser";
|
115
|
foreach ($evaledvar as $ip) {
|
116
|
if ($pkg['adddeleteeditpagefields']['columnitem']) {
|
117
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
118
|
${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
|
119
|
}
|
120
|
}
|
121
|
}
|
122
|
|
123
|
$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
124
|
|
125
|
if ($a_pkg[$_GET['id']]) {
|
126
|
unset($a_pkg[$_GET['id']]);
|
127
|
write_config();
|
128
|
if ($pkg['custom_delete_php_command'] <> "") {
|
129
|
if ($pkg['custom_php_command_before_form'] <> "") {
|
130
|
eval($pkg['custom_php_command_before_form']);
|
131
|
}
|
132
|
eval($pkg['custom_delete_php_command']);
|
133
|
}
|
134
|
header("Location: pkg.php?xml=" . $xml);
|
135
|
exit;
|
136
|
}
|
137
|
}
|
138
|
|
139
|
ob_start();
|
140
|
|
141
|
$iflist = get_configured_interface_with_descr(false, true);
|
142
|
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
143
|
|
144
|
if ($pkg['custom_php_global_functions'] <> "") {
|
145
|
eval($pkg['custom_php_global_functions']);
|
146
|
}
|
147
|
|
148
|
if ($pkg['custom_php_command_before_form'] <> "") {
|
149
|
eval($pkg['custom_php_command_before_form']);
|
150
|
}
|
151
|
|
152
|
$pgtitle = array($pkg['title']);
|
153
|
include("head.inc");
|
154
|
|
155
|
?>
|
156
|
|
157
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
158
|
<?php include("fbegin.inc"); ?>
|
159
|
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
|
160
|
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
|
161
|
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
|
162
|
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
|
163
|
<script type="text/javascript">
|
164
|
//<![CDATA[
|
165
|
function setFilter(filtertext) {
|
166
|
jQuery('#pkg_filter').val(filtertext);
|
167
|
document.pkgform.submit();
|
168
|
}
|
169
|
|
170
|
<?php
|
171
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
172
|
?>
|
173
|
jQuery(document).ready(function() {
|
174
|
jQuery('#mainarea table tbody').sortable({
|
175
|
items: 'tr.sortable',
|
176
|
cursor: 'move',
|
177
|
distance: 10,
|
178
|
opacity: 0.8,
|
179
|
helper: function(e, ui) {
|
180
|
ui.children().each(function() {
|
181
|
jQuery(this).width(jQuery(this).width());
|
182
|
});
|
183
|
return ui;
|
184
|
},
|
185
|
});
|
186
|
});
|
187
|
function save_changes_to_xml(xml) {
|
188
|
var ids=jQuery('#mainarea table tbody').sortable('serialize', {key:"ids[]"});
|
189
|
var strloading="<img src='/themes/<?= $g['theme']; ?>/images/misc/loader.gif' alt='loader' /> " + "<?=gettext('Saving changes...');?>";
|
190
|
if (confirm("<?=gettext("Do you really want to save changes?");?>")) {
|
191
|
jQuery.ajax({
|
192
|
type: 'get',
|
193
|
cache: false,
|
194
|
url: "<?=$_SERVER['SCRIPT_NAME'];?>",
|
195
|
data: {xml:'<?=$xml?>', act:'update', ids: ids},
|
196
|
beforeSend: function() {
|
197
|
jQuery('#savemsg').empty().html(strloading);
|
198
|
},
|
199
|
error: function(data) {
|
200
|
jQuery('#savemsg').empty().html('Error:' + data);
|
201
|
},
|
202
|
success: function(data) {
|
203
|
jQuery('#savemsg').empty().html(data);
|
204
|
}
|
205
|
});
|
206
|
}
|
207
|
}
|
208
|
<?php
|
209
|
}
|
210
|
?>
|
211
|
//]]>
|
212
|
</script>
|
213
|
<form action="pkg.php" name="pkgform" method="get">
|
214
|
<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
|
215
|
<?php if ($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
|
216
|
<div id="savemsg"></div>
|
217
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
218
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package settings">
|
219
|
<?php
|
220
|
if ($pkg['tabs'] <> "") {
|
221
|
$tab_array = array();
|
222
|
foreach ($pkg['tabs']['tab'] as $tab) {
|
223
|
if ($tab['tab_level']) {
|
224
|
$tab_level = $tab['tab_level'];
|
225
|
} else {
|
226
|
$tab_level = 1;
|
227
|
}
|
228
|
if (isset($tab['active'])) {
|
229
|
$active = true;
|
230
|
} else {
|
231
|
$active = false;
|
232
|
}
|
233
|
if (isset($tab['no_drop_down'])) {
|
234
|
$no_drop_down = true;
|
235
|
}
|
236
|
$urltmp = "";
|
237
|
if ($tab['url'] <> "") {
|
238
|
$urltmp = $tab['url'];
|
239
|
}
|
240
|
if ($tab['xml'] <> "") {
|
241
|
$urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
242
|
}
|
243
|
|
244
|
$addresswithport = getenv("HTTP_HOST");
|
245
|
$colonpos = strpos($addresswithport, ":");
|
246
|
if ($colonpos !== False) {
|
247
|
//my url is actually just the IP address of the pfsense box
|
248
|
$myurl = substr($addresswithport, 0, $colonpos);
|
249
|
} else {
|
250
|
$myurl = $addresswithport;
|
251
|
}
|
252
|
// eval url so that above $myurl item can be processed if need be.
|
253
|
$url = str_replace('$myurl', $myurl, $urltmp);
|
254
|
|
255
|
$tab_array[$tab_level][] = array(
|
256
|
$tab['text'],
|
257
|
$active,
|
258
|
$url
|
259
|
);
|
260
|
}
|
261
|
|
262
|
ksort($tab_array);
|
263
|
foreach ($tab_array as $tab) {
|
264
|
echo '<tr><td>';
|
265
|
display_top_tabs($tab, $no_drop_down);
|
266
|
echo '</td></tr>';
|
267
|
}
|
268
|
}
|
269
|
?>
|
270
|
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
271
|
<tr>
|
272
|
<td class="tabcont">
|
273
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
|
274
|
<?php
|
275
|
/* Handle filtering bar A-Z */
|
276
|
$include_filtering_inputbox = false;
|
277
|
$colspan = 0;
|
278
|
if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
|
279
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
280
|
$colspan++;
|
281
|
}
|
282
|
}
|
283
|
if ($pkg['fields']['field']) {
|
284
|
// First find the sorting type field if it exists
|
285
|
foreach ($pkg['fields']['field'] as $field) {
|
286
|
if ($field['type'] == "sorting") {
|
287
|
if (isset($field['include_filtering_inputbox'])) {
|
288
|
$include_filtering_inputbox = true;
|
289
|
}
|
290
|
if ($display_maximum_rows < 1) {
|
291
|
if ($field['display_maximum_rows']) {
|
292
|
$display_maximum_rows = $field['display_maximum_rows'];
|
293
|
}
|
294
|
}
|
295
|
echo "<tr><td class='listhdrr' colspan='$colspan' align='center'>";
|
296
|
echo "Filter by: ";
|
297
|
$isfirst = true;
|
298
|
for ($char = 65; $char < 91; $char++) {
|
299
|
if (!$isfirst) {
|
300
|
echo " | ";
|
301
|
}
|
302
|
echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
|
303
|
$isfirst = false;
|
304
|
}
|
305
|
echo "</td></tr>";
|
306
|
echo "<tr><td class='listhdrr' colspan='$colspan' align='center'>";
|
307
|
if ($field['sortablefields']) {
|
308
|
echo "Filter field: <select name='pkg_filter_type'>";
|
309
|
foreach ($field['sortablefields']['item'] as $si) {
|
310
|
if ($si['name'] == $_REQUEST['pkg_filter_type']) {
|
311
|
$SELECTED = "selected=\"selected\"";
|
312
|
} else {
|
313
|
$SELECTED = "";
|
314
|
}
|
315
|
echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
|
316
|
}
|
317
|
echo "</select>";
|
318
|
}
|
319
|
if ($include_filtering_inputbox) {
|
320
|
echo " Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /> <input type='submit' value='Filter' />";
|
321
|
}
|
322
|
echo "</td></tr><tr><td><font size='-3'> </font></td></tr>";
|
323
|
}
|
324
|
}
|
325
|
}
|
326
|
?>
|
327
|
<tr>
|
328
|
<?php
|
329
|
if ($display_maximum_rows) {
|
330
|
$totalpages = ceil(round((count($evaledvar) / $display_maximum_rows), 9));
|
331
|
$page = 1;
|
332
|
$tmpcount = 0;
|
333
|
$tmppp = 0;
|
334
|
if (is_array($evaledvar)) {
|
335
|
foreach ($evaledvar as $ipa) {
|
336
|
if ($tmpcount == $display_maximum_rows) {
|
337
|
$page++;
|
338
|
$tmpcount = 0;
|
339
|
}
|
340
|
if ($tmppp == $startdisplayingat) {
|
341
|
break;
|
342
|
}
|
343
|
$tmpcount++;
|
344
|
$tmppp++;
|
345
|
}
|
346
|
}
|
347
|
echo "<tr><td colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
|
348
|
echo "<table width='100%' summary=''>";
|
349
|
echo "<tr>";
|
350
|
echo "<td align='left'>Displaying page $page of $totalpages</b></td>";
|
351
|
echo "<td align='right'>Rows per page: <select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
|
352
|
for ($x = 0; $x < 250; $x++) {
|
353
|
if ($x == $display_maximum_rows) {
|
354
|
$SELECTED = "selected=\"selected\"";
|
355
|
} else {
|
356
|
$SELECTED = "";
|
357
|
}
|
358
|
echo "<option value='$x' $SELECTED>$x</option>\n";
|
359
|
$x = $x + 4;
|
360
|
}
|
361
|
echo "</select></td></tr>";
|
362
|
echo "</table>";
|
363
|
echo "</td></tr>";
|
364
|
}
|
365
|
$cols = 0;
|
366
|
if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
|
367
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
368
|
echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
|
369
|
$cols++;
|
370
|
}
|
371
|
}
|
372
|
?>
|
373
|
</tr>
|
374
|
<?php
|
375
|
$i = 0;
|
376
|
$pagination_counter = 0;
|
377
|
if ($evaledvar) {
|
378
|
foreach ($evaledvar as $ip) {
|
379
|
if ($startdisplayingat) {
|
380
|
if ($i < $startdisplayingat) {
|
381
|
$i++;
|
382
|
continue;
|
383
|
}
|
384
|
}
|
385
|
if ($_REQUEST['pkg_filter']) {
|
386
|
// Handle filtered items
|
387
|
if ($pkg['fields']['field'] && !$filter_regex) {
|
388
|
// First find the sorting type field if it exists
|
389
|
foreach ($pkg['fields']['field'] as $field) {
|
390
|
if ($field['type'] == "sorting") {
|
391
|
if ($field['sortablefields']['item']) {
|
392
|
foreach ($field['sortablefields']['item'] as $sf) {
|
393
|
if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
|
394
|
$filter_fieldname = $sf['fieldname'];
|
395
|
#Use a default regex on sortable fields when none is declared
|
396
|
if ($sf['regex']) {
|
397
|
$filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
|
398
|
} else {
|
399
|
$filter_regex = "/{$_REQUEST['pkg_filter']}/i";
|
400
|
}
|
401
|
}
|
402
|
}
|
403
|
}
|
404
|
}
|
405
|
}
|
406
|
}
|
407
|
// Do we have something to filter on?
|
408
|
unset($filter_matches);
|
409
|
if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
|
410
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
411
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
412
|
if ($column['fieldname'] == $filter_fieldname) {
|
413
|
if ($filter_regex) {
|
414
|
//echo "$filter_regex - $fieldname<p/>";
|
415
|
preg_match($filter_regex, $fieldname, $filter_matches);
|
416
|
break;
|
417
|
}
|
418
|
}
|
419
|
}
|
420
|
}
|
421
|
if (!$filter_matches) {
|
422
|
$i++;
|
423
|
continue;
|
424
|
}
|
425
|
}
|
426
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
427
|
echo "<tr valign=\"top\" class=\"sortable\" id=\"id_{$i}\">\n";
|
428
|
} else {
|
429
|
echo "<tr valign=\"top\">\n";
|
430
|
}
|
431
|
if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
|
432
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
433
|
if ($column['fieldname'] == "description") {
|
434
|
$class = "listbg";
|
435
|
} else {
|
436
|
$class = "listlr";
|
437
|
}
|
438
|
?>
|
439
|
<td class="<?=$class;?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
|
440
|
<?php
|
441
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
442
|
#Check if columnitem has a type field declared
|
443
|
if ($column['type'] == "checkbox") {
|
444
|
if ($fieldname == "") {
|
445
|
echo gettext("No");
|
446
|
} else {
|
447
|
echo gettext("Yes");
|
448
|
}
|
449
|
} else if ($column['type'] == "interface") {
|
450
|
echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
|
451
|
} else {
|
452
|
#Check if columnitem has an encoding field declared
|
453
|
if ($column['encoding'] == "base64") {
|
454
|
echo $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
|
455
|
#Check if there is a custom info to show when $fieldname is not empty
|
456
|
} else if ($column['listmodeon'] && $fieldname != "") {
|
457
|
echo $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
|
458
|
#Check if there is a custom info to show when $fieldname is empty
|
459
|
} else if ($column['listmodeoff'] && $fieldname == "") {
|
460
|
echo $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
|
461
|
} else {
|
462
|
echo $column['prefix'] . $fieldname ." ". $column['suffix'];
|
463
|
}
|
464
|
}
|
465
|
?>
|
466
|
</td>
|
467
|
<?php
|
468
|
} // foreach columnitem
|
469
|
} // if columnitem
|
470
|
?>
|
471
|
<td valign="middle" class="list nowrap">
|
472
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
473
|
<tr>
|
474
|
<?php
|
475
|
#Show custom description to edit button if defined
|
476
|
$edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:"Edit this item");
|
477
|
?>
|
478
|
<td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" <?=domTT_title($edit_msg)?> alt="edit" /></a></td>
|
479
|
<?php
|
480
|
#Show custom description to delete button if defined
|
481
|
$delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:"Delete this item");
|
482
|
?>
|
483
|
<td valign="middle"><a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this item?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" <?=domTT_title($delete_msg)?> alt="delete" /></a></td>
|
484
|
</tr>
|
485
|
</table>
|
486
|
</td>
|
487
|
<?php
|
488
|
echo "</tr>\n"; // Pairs with an echo tr some way above
|
489
|
// Handle pagination and display_maximum_rows
|
490
|
if ($display_maximum_rows) {
|
491
|
if ($pagination_counter == ($display_maximum_rows-1) or
|
492
|
$i == (count($evaledvar)-1)) {
|
493
|
$colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
|
494
|
$final_footer = "";
|
495
|
$final_footer .= "<tr><td colspan='$colcount'>";
|
496
|
$final_footer .= "<table width='100%' summary=''><tr>";
|
497
|
$final_footer .= "<td align='left'>";
|
498
|
$startingat = $startdisplayingat - $display_maximum_rows;
|
499
|
if ($startingat > -1) {
|
500
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat={$startingat}&display_maximum_rows={$display_maximum_rows}'>";
|
501
|
} else if ($startdisplayingat > 1) {
|
502
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=0&display_maximum_rows={$display_maximum_rows}'>";
|
503
|
}
|
504
|
$final_footer .= "<font size='2'><< Previous page</font></a>";
|
505
|
if ($tmppp + $display_maximum_rows > count($evaledvar)) {
|
506
|
$endingrecord = count($evaledvar);
|
507
|
} else {
|
508
|
$endingrecord = $tmppp + $display_maximum_rows;
|
509
|
}
|
510
|
$final_footer .= "</td><td align='center'>";
|
511
|
$tmppp++;
|
512
|
$final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
|
513
|
$final_footer .= "</font></td><td align='right'> ";
|
514
|
if (($i+1) < count($evaledvar)) {
|
515
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&display_maximum_rows={$display_maximum_rows}'>";
|
516
|
}
|
517
|
$final_footer .= "<font size='2'>Next page >></font></a>";
|
518
|
$final_footer .= "</td></tr></table></td></tr>";
|
519
|
$i = count($evaledvar);
|
520
|
break;
|
521
|
}
|
522
|
}
|
523
|
$i++;
|
524
|
$pagination_counter++;
|
525
|
} // foreach evaledvar
|
526
|
} // if evaledvar
|
527
|
?>
|
528
|
<tr>
|
529
|
<td colspan="<?=$cols?>"></td>
|
530
|
<td>
|
531
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
532
|
<tr>
|
533
|
<?php
|
534
|
#Show custom description to add button if defined
|
535
|
$add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:"Add a new item");
|
536
|
?>
|
537
|
<td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" <?=domTT_title($add_msg)?> alt="add" /></a></td>
|
538
|
<?php
|
539
|
#Show description button and info if defined
|
540
|
if ($pkg['adddeleteeditpagefields']['description']) {
|
541
|
?>
|
542
|
<td valign="middle"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" width="17" height="17" border="0" <?=domTT_title($pkg['adddeleteeditpagefields']['description'])?> alt="info" /></td>
|
543
|
<?php
|
544
|
}
|
545
|
?>
|
546
|
</tr>
|
547
|
</table>
|
548
|
</td>
|
549
|
</tr>
|
550
|
<?=$final_footer?>
|
551
|
<?php
|
552
|
#Show save button only when movable is defined
|
553
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
554
|
?>
|
555
|
<tr>
|
556
|
<td><input class="formbtn" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')" /></td>
|
557
|
</tr>
|
558
|
<?php
|
559
|
}
|
560
|
?>
|
561
|
</table>
|
562
|
</td>
|
563
|
</tr>
|
564
|
</table></div></td></tr>
|
565
|
</table>
|
566
|
|
567
|
</form>
|
568
|
<?php include("fend.inc"); ?>
|
569
|
|
570
|
<?php
|
571
|
echo "<!-- filter_fieldname: {$filter_fieldname} -->";
|
572
|
echo "<!-- filter_regex: {$filter_regex} -->";
|
573
|
?>
|
574
|
|
575
|
</body>
|
576
|
</html>
|