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