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