1
|
<?php
|
2
|
/*
|
3
|
* pkg.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
* you may not use this file except in compliance with the License.
|
11
|
* You may obtain a copy of the License at
|
12
|
*
|
13
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14
|
*
|
15
|
* Unless required by applicable law or agreed to in writing, software
|
16
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
* See the License for the specific language governing permissions and
|
19
|
* limitations under the License.
|
20
|
*/
|
21
|
|
22
|
##|+PRIV
|
23
|
##|*IDENT=page-package-settings
|
24
|
##|*NAME=Package: Settings
|
25
|
##|*DESCR=Allow access to the 'Package: Settings' page.
|
26
|
##|*MATCH=pkg.php*
|
27
|
##|-PRIV
|
28
|
|
29
|
require_once("guiconfig.inc");
|
30
|
require_once("pkg-utils.inc");
|
31
|
|
32
|
function domTT_title($title_msg) {
|
33
|
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');\"";
|
34
|
}
|
35
|
|
36
|
$xml = $_REQUEST['xml'];
|
37
|
|
38
|
if ($xml == "") {
|
39
|
$pgtitle = array(gettext("Package"), gettext("Editor"));
|
40
|
$pglinks = array("", "@self");
|
41
|
include("head.inc");
|
42
|
print_info_box(gettext("No valid package defined."), 'danger', false);
|
43
|
include("foot.inc");
|
44
|
exit;
|
45
|
} else {
|
46
|
$pkg_xml_prefix = "/usr/local/pkg/";
|
47
|
$pkg_full_path = "{$pkg_xml_prefix}/{$xml}";
|
48
|
$pkg_realpath = realpath($pkg_full_path);
|
49
|
if (empty($pkg_realpath)) {
|
50
|
$path_error = sprintf(gettext("Package path %s not found."), htmlspecialchars($pkg_full_path));
|
51
|
} else if (substr_compare($pkg_realpath, $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) {
|
52
|
$path_error = sprintf(gettext("Invalid path %s specified."), htmlspecialchars($pkg_full_path));
|
53
|
}
|
54
|
|
55
|
if (!empty($path_error)) {
|
56
|
include("head.inc");
|
57
|
print_info_box($path_error . "<br />" . gettext("Try reinstalling the package."), 'danger', false);
|
58
|
include("foot.inc");
|
59
|
die;
|
60
|
}
|
61
|
|
62
|
if (file_exists($pkg_full_path)) {
|
63
|
$pkg = parse_xml_config_pkg($pkg_full_path, "packagegui");
|
64
|
} else {
|
65
|
include("head.inc");
|
66
|
print_info_box(sprintf(gettext("File not found %s."), htmlspecialchars($xml)), 'danger', false);
|
67
|
include("foot.inc");
|
68
|
exit;
|
69
|
}
|
70
|
}
|
71
|
|
72
|
if ($pkg['donotsave'] != "") {
|
73
|
header("Location: pkg_edit.php?xml=" . $xml);
|
74
|
exit;
|
75
|
}
|
76
|
|
77
|
if ($pkg['include_file'] != "") {
|
78
|
require_once($pkg['include_file']);
|
79
|
}
|
80
|
|
81
|
if ($_REQUEST['startdisplayingat']) {
|
82
|
$startdisplayingat = $_REQUEST['startdisplayingat'];
|
83
|
}
|
84
|
|
85
|
if ($_REQUEST['display_maximum_rows']) {
|
86
|
if ($_REQUEST['display_maximum_rows']) {
|
87
|
$display_maximum_rows = $_REQUEST['display_maximum_rows'];
|
88
|
}
|
89
|
}
|
90
|
|
91
|
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
92
|
|
93
|
if ($_REQUEST['act'] == "update") {
|
94
|
|
95
|
if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
|
96
|
// get current values
|
97
|
$current_values=$config['installedpackages'][$pkg['name']]['config'];
|
98
|
// get updated ids
|
99
|
parse_str($_REQUEST['ids'], $update_list);
|
100
|
// sort ids to know what to change
|
101
|
// useful to do not lose data when using sorting and paging
|
102
|
$sort_list=$update_list['ids'];
|
103
|
sort($sort_list);
|
104
|
// apply updates
|
105
|
foreach ($update_list['ids'] as $key=> $value) {
|
106
|
$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
|
107
|
}
|
108
|
// save current config
|
109
|
write_config(gettext("Package configuration changes saved from package settings page."));
|
110
|
// sync package
|
111
|
eval ("{$pkg['custom_php_resync_config_command']}");
|
112
|
}
|
113
|
// function called via jquery, no need to continue after save changes.
|
114
|
exit;
|
115
|
}
|
116
|
if ($_REQUEST['act'] == "del") {
|
117
|
// loop through our fieldnames and automatically setup the fieldnames
|
118
|
// in the environment. ie: a fieldname of username with a value of
|
119
|
// testuser would automatically eval $username = "testuser";
|
120
|
foreach ($evaledvar as $ip) {
|
121
|
if ($pkg['adddeleteeditpagefields']['columnitem']) {
|
122
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
123
|
${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
|
124
|
}
|
125
|
}
|
126
|
}
|
127
|
|
128
|
$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
129
|
|
130
|
if ($a_pkg[$_REQUEST['id']]) {
|
131
|
unset($a_pkg[$_REQUEST['id']]);
|
132
|
write_config(gettext("Package configuration item deleted from package settings page."));
|
133
|
if ($pkg['custom_delete_php_command'] != "") {
|
134
|
if ($pkg['custom_php_command_before_form'] != "") {
|
135
|
eval($pkg['custom_php_command_before_form']);
|
136
|
}
|
137
|
eval($pkg['custom_delete_php_command']);
|
138
|
}
|
139
|
header("Location: pkg.php?xml=" . $xml);
|
140
|
exit;
|
141
|
}
|
142
|
}
|
143
|
|
144
|
ob_start();
|
145
|
|
146
|
$iflist = get_configured_interface_with_descr(true);
|
147
|
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
148
|
|
149
|
if ($pkg['custom_php_global_functions'] != "") {
|
150
|
eval($pkg['custom_php_global_functions']);
|
151
|
}
|
152
|
|
153
|
if ($pkg['custom_php_command_before_form'] != "") {
|
154
|
eval($pkg['custom_php_command_before_form']);
|
155
|
}
|
156
|
|
157
|
// Breadcrumb
|
158
|
if ($pkg['title'] != "") {
|
159
|
/*if (!$only_edit) { // Is any package still making use of this?? Is this something that is still wanted, considering the breadcrumb policy https://redmine.pfsense.org/issues/5527
|
160
|
$pkg['title'] = $pkg['title'] . '/Edit'; // If this needs to live on, then it has to be moved to run AFTER "foreach ($pkg['tabs']['tab'] as $tab)"-loop. This due to $pgtitle[] = $tab['text'];
|
161
|
}*/
|
162
|
if (strpos($pkg['title'], '/')) {
|
163
|
$title = explode('/', $pkg['title']);
|
164
|
|
165
|
foreach ($title as $subtitle) {
|
166
|
$pgtitle[] = gettext($subtitle);
|
167
|
$pglinks[] = "@self";
|
168
|
}
|
169
|
} else {
|
170
|
$pgtitle = array(gettext("Package"), gettext($pkg['title']));
|
171
|
$pglinks = array("", "@self");
|
172
|
}
|
173
|
} else {
|
174
|
$pgtitle = array(gettext("Package"), gettext("Editor"));
|
175
|
$pglinks = array("", "@self");
|
176
|
}
|
177
|
|
178
|
if ($pkg['tabs'] != "") {
|
179
|
$tab_array = array();
|
180
|
foreach ($pkg['tabs']['tab'] as $tab) {
|
181
|
if ($tab['tab_level']) {
|
182
|
$tab_level = $tab['tab_level'];
|
183
|
} else {
|
184
|
$tab_level = 1;
|
185
|
}
|
186
|
if (isset($tab['active'])) {
|
187
|
$active = true;
|
188
|
$pgtitle[] = $tab['text'];
|
189
|
$pglinks[] = "@self";
|
190
|
} else {
|
191
|
$active = false;
|
192
|
}
|
193
|
$urltmp = "";
|
194
|
if ($tab['url'] != "") {
|
195
|
$urltmp = $tab['url'];
|
196
|
}
|
197
|
if ($tab['xml'] != "") {
|
198
|
$urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
199
|
}
|
200
|
|
201
|
$addresswithport = getenv("HTTP_HOST");
|
202
|
$colonpos = strpos($addresswithport, ":");
|
203
|
if ($colonpos !== False) {
|
204
|
//my url is actually just the IP address of the pfsense box
|
205
|
$myurl = substr($addresswithport, 0, $colonpos);
|
206
|
} else {
|
207
|
$myurl = $addresswithport;
|
208
|
}
|
209
|
// eval url so that above $myurl item can be processed if need be.
|
210
|
$url = str_replace('$myurl', $myurl, $urltmp);
|
211
|
|
212
|
$tab_array[$tab_level][] = array(
|
213
|
$tab['text'],
|
214
|
$active,
|
215
|
$url
|
216
|
);
|
217
|
}
|
218
|
|
219
|
ksort($tab_array);
|
220
|
}
|
221
|
|
222
|
include("head.inc");
|
223
|
if (isset($tab_array)) {
|
224
|
foreach ($tab_array as $tabid => $tab) {
|
225
|
display_top_tabs($tab);
|
226
|
}
|
227
|
}
|
228
|
|
229
|
?>
|
230
|
|
231
|
<script type="text/javascript">
|
232
|
//<![CDATA[
|
233
|
events.push(function() {
|
234
|
|
235
|
function setFilter(filtertext) {
|
236
|
$('#pkg_filter').val(filtertext);
|
237
|
document.pkgform.submit();
|
238
|
}
|
239
|
|
240
|
<?php
|
241
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
242
|
?>
|
243
|
$('#mainarea table tbody').sortable({
|
244
|
items: 'tr.sortable',
|
245
|
cursor: 'move',
|
246
|
distance: 10,
|
247
|
opacity: 0.8,
|
248
|
helper: function(e, ui) {
|
249
|
ui.children().each(function() {
|
250
|
$(this).width($(this).width());
|
251
|
});
|
252
|
return ui;
|
253
|
},
|
254
|
});
|
255
|
<?php
|
256
|
}
|
257
|
?>
|
258
|
});
|
259
|
|
260
|
function save_changes_to_xml(xml) {
|
261
|
var ids = $('#mainarea table tbody').sortable('serialize', {key:"ids[]"});
|
262
|
var strloading="<?=gettext('Saving changes...')?>";
|
263
|
if (confirm("<?=gettext("Confirmation Required to save changes.")?>")) {
|
264
|
$.ajax({
|
265
|
type: 'get',
|
266
|
cache: false,
|
267
|
url: "<?=$_SERVER['SCRIPT_NAME']?>",
|
268
|
data: {xml:'<?=$xml?>', act:'update', ids: ids},
|
269
|
beforeSend: function() {
|
270
|
$('#savemsg').empty().html(strloading);
|
271
|
},
|
272
|
error: function(data) {
|
273
|
$('#savemsg').empty().html('Error:' + data);
|
274
|
},
|
275
|
success: function(data) {
|
276
|
$('#savemsg').empty().html(data);
|
277
|
}
|
278
|
});
|
279
|
}
|
280
|
}
|
281
|
|
282
|
//]]>
|
283
|
</script>
|
284
|
|
285
|
<?php
|
286
|
if ($_REQUEST['savemsg'] != "") {
|
287
|
$savemsg = htmlspecialchars($_REQUEST['savemsg']);
|
288
|
}
|
289
|
|
290
|
if ($savemsg) {
|
291
|
print_info_box($savemsg, 'success');
|
292
|
}
|
293
|
?>
|
294
|
|
295
|
<form action="pkg.php" name="pkgform" method="get">
|
296
|
<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
|
297
|
<div id="mainarea" class="panel panel-default">
|
298
|
<table id="mainarea" class="table table-striped table-hover table-condensed">
|
299
|
<thead>
|
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' class='text-center'>";
|
322
|
echo gettext("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' class='text-center'>";
|
333
|
if ($field['sortablefields']) {
|
334
|
echo gettext("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";
|
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 ' ' . gettext("Filter text: ") . '<input id="pkg_filter" name="pkg_filter" value="' . htmlspecialchars($_REQUEST['pkg_filter']) . '" />';
|
347
|
echo ' <button type="submit" value="Filter" class="btn btn-primary btn-xs">';
|
348
|
echo '<i class="fa fa-filter icon-embed-btn"></i>';
|
349
|
echo gettext("Filter");
|
350
|
echo "</button>";
|
351
|
}
|
352
|
echo "</td></tr><tr><td><font size='-3'> </font></td></tr>";
|
353
|
}
|
354
|
}
|
355
|
}
|
356
|
?>
|
357
|
<tr>
|
358
|
|
359
|
<?php
|
360
|
if ($display_maximum_rows) {
|
361
|
$totalpages = ceil(round((count($evaledvar) / $display_maximum_rows), 9));
|
362
|
$page = 1;
|
363
|
$tmpcount = 0;
|
364
|
$tmppp = 0;
|
365
|
if (is_array($evaledvar)) {
|
366
|
foreach ($evaledvar as $ipa) {
|
367
|
if ($tmpcount == $display_maximum_rows) {
|
368
|
$page++;
|
369
|
$tmpcount = 0;
|
370
|
}
|
371
|
if ($tmppp == $startdisplayingat) {
|
372
|
break;
|
373
|
}
|
374
|
$tmpcount++;
|
375
|
$tmppp++;
|
376
|
}
|
377
|
}
|
378
|
echo "<tr><th colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
|
379
|
echo "<table width='100%' summary=''>";
|
380
|
echo "<tr>";
|
381
|
echo "<td class='text-left'>" . sprintf(gettext('Displaying page %1$s of %2$s'), $page, $totalpages) . "</b></td>";
|
382
|
echo "<td class='text-right'>" . gettext("Rows per page: ") . "<select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
|
383
|
for ($x = 0; $x < 250; $x++) {
|
384
|
if ($x == $display_maximum_rows) {
|
385
|
$SELECTED = "selected";
|
386
|
} else {
|
387
|
$SELECTED = "";
|
388
|
}
|
389
|
echo "<option value='$x' $SELECTED>$x</option>\n";
|
390
|
$x = $x + 4;
|
391
|
}
|
392
|
echo "</select></td></tr>";
|
393
|
echo "</table>";
|
394
|
echo "</th></tr>";
|
395
|
}
|
396
|
|
397
|
$cols = 0;
|
398
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
399
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
400
|
echo "<th class=\"listhdrr\">" . $column['fielddescr'] . "</th>";
|
401
|
$cols++;
|
402
|
}
|
403
|
}
|
404
|
?>
|
405
|
</tr>
|
406
|
</thead>
|
407
|
<tbody>
|
408
|
<?php
|
409
|
$i = 0;
|
410
|
$pagination_counter = 0;
|
411
|
if ($evaledvar && is_array($evaledvar)) {
|
412
|
foreach ($evaledvar as $ip) {
|
413
|
if ($startdisplayingat) {
|
414
|
if ($i < $startdisplayingat) {
|
415
|
$i++;
|
416
|
continue;
|
417
|
}
|
418
|
}
|
419
|
if ($_REQUEST['pkg_filter']) {
|
420
|
// Handle filtered items
|
421
|
if ($pkg['fields']['field'] && !$filter_regex) {
|
422
|
// First find the sorting type field if it exists
|
423
|
foreach ($pkg['fields']['field'] as $field) {
|
424
|
if ($field['type'] == "sorting") {
|
425
|
if ($field['sortablefields']['item']) {
|
426
|
foreach ($field['sortablefields']['item'] as $sf) {
|
427
|
if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
|
428
|
$filter_fieldname = $sf['fieldname'];
|
429
|
#Use a default regex on sortable fields when none is declared
|
430
|
if ($sf['regex']) {
|
431
|
$filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
|
432
|
} else {
|
433
|
$filter_regex = "/{$_REQUEST['pkg_filter']}/i";
|
434
|
}
|
435
|
}
|
436
|
}
|
437
|
}
|
438
|
}
|
439
|
}
|
440
|
}
|
441
|
// Do we have something to filter on?
|
442
|
unset($filter_matches);
|
443
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
444
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
445
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
446
|
if ($column['fieldname'] == $filter_fieldname) {
|
447
|
if ($filter_regex) {
|
448
|
//echo "$filter_regex - $fieldname<p/>";
|
449
|
preg_match($filter_regex, $fieldname, $filter_matches);
|
450
|
break;
|
451
|
}
|
452
|
}
|
453
|
}
|
454
|
}
|
455
|
if (!$filter_matches) {
|
456
|
$i++;
|
457
|
continue;
|
458
|
}
|
459
|
}
|
460
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
461
|
echo "<tr style=\"vertical-align: top\" class=\"sortable\" id=\"id_{$i}\">\n";
|
462
|
} else {
|
463
|
echo "<tr style=\"vertical-align: top\">\n";
|
464
|
}
|
465
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
466
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
467
|
if ($column['fieldname'] == "description") {
|
468
|
$class = "listbg";
|
469
|
} else {
|
470
|
$class = "listlr";
|
471
|
}
|
472
|
?>
|
473
|
<td class="<?=$class?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>';">
|
474
|
<?php
|
475
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
476
|
#Check if columnitem has a type field declared
|
477
|
if ($column['type'] == "checkbox") {
|
478
|
if ($fieldname == "") {
|
479
|
echo gettext("No");
|
480
|
} else {
|
481
|
echo gettext("Yes");
|
482
|
}
|
483
|
} else if ($column['type'] == "interface") {
|
484
|
echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
|
485
|
} else {
|
486
|
$display_text = "";
|
487
|
#Check if columnitem has an encoding field declared
|
488
|
if ($column['encoding'] == "base64") {
|
489
|
$display_text = $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
|
490
|
#Check if there is a custom info to show when $fieldname is not empty
|
491
|
} else if ($column['listmodeon'] && $fieldname != "") {
|
492
|
$display_text = $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
|
493
|
#Check if there is a custom info to show when $fieldname is empty
|
494
|
} else if ($column['listmodeoff'] && $fieldname == "") {
|
495
|
$display_text = $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
|
496
|
} else {
|
497
|
$display_text = $column['prefix'] . $fieldname ." ". $column['suffix'];
|
498
|
}
|
499
|
if (!isset($column['allow_html'])) {
|
500
|
$display_text = htmlspecialchars($display_text);
|
501
|
}
|
502
|
echo $display_text;
|
503
|
}
|
504
|
?>
|
505
|
</td>
|
506
|
<?php
|
507
|
} // foreach columnitem
|
508
|
} // if columnitem
|
509
|
?>
|
510
|
<td style="vertical-align: middle" class="list text-nowrap">
|
511
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
512
|
<tr>
|
513
|
<?php
|
514
|
#Show custom description to edit button if defined
|
515
|
$edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:gettext("Edit this item"));
|
516
|
?>
|
517
|
<td><a class="fa fa-pencil" href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>" title="<?=$edit_msg?>"></a></td>
|
518
|
<?php
|
519
|
#Show custom description to delete button if defined
|
520
|
$delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:gettext("Delete this item"));
|
521
|
?>
|
522
|
<td> <a class="fa fa-trash" href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i?>" title="<?=$delete_msg?>"></a></td>
|
523
|
</tr>
|
524
|
</tbody>
|
525
|
</table>
|
526
|
</td>
|
527
|
<?php
|
528
|
echo "</tr>\n"; // Pairs with an echo tr some way above
|
529
|
// Handle pagination and display_maximum_rows
|
530
|
if ($display_maximum_rows) {
|
531
|
if ($pagination_counter == ($display_maximum_rows-1) or
|
532
|
$i == (count($evaledvar)-1)) {
|
533
|
$colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
|
534
|
$final_footer = "";
|
535
|
$final_footer .= "<tr><td colspan='$colcount'>";
|
536
|
$final_footer .= "<table width='100%' summary=''><tr>";
|
537
|
$final_footer .= "<td class='text-left'>";
|
538
|
$startingat = $startdisplayingat - $display_maximum_rows;
|
539
|
if ($startingat > -1) {
|
540
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat={$startingat}&display_maximum_rows={$display_maximum_rows}'>";
|
541
|
} else if ($startdisplayingat > 1) {
|
542
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=0&display_maximum_rows={$display_maximum_rows}'>";
|
543
|
}
|
544
|
$final_footer .= "<font size='2'><< " . gettext("Previous page") . "</font></a>";
|
545
|
if ($tmppp + $display_maximum_rows > count($evaledvar)) {
|
546
|
$endingrecord = count($evaledvar);
|
547
|
} else {
|
548
|
$endingrecord = $tmppp + $display_maximum_rows;
|
549
|
}
|
550
|
$final_footer .= "</td><td class='text-center'>";
|
551
|
$tmppp++;
|
552
|
$final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
|
553
|
$final_footer .= "</font></td><td class='text-right'> ";
|
554
|
if (($i+1) < count($evaledvar)) {
|
555
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&display_maximum_rows={$display_maximum_rows}'>";
|
556
|
}
|
557
|
$final_footer .= "<font size='2'>" . gettext("Next page") . " >></font></a>";
|
558
|
$final_footer .= "</td></tr></table></td></tr>";
|
559
|
$i = count($evaledvar);
|
560
|
break;
|
561
|
}
|
562
|
}
|
563
|
$i++;
|
564
|
$pagination_counter++;
|
565
|
} // foreach evaledvar
|
566
|
} // if evaledvar
|
567
|
?>
|
568
|
<tr>
|
569
|
<td colspan="<?=$cols?>"></td>
|
570
|
<td>
|
571
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
572
|
<tr>
|
573
|
<?php
|
574
|
#Show custom description to add button if defined
|
575
|
$add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:gettext("Add a new item"));
|
576
|
?>
|
577
|
<td><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>" class="btn btn-sm btn-success" title="<?=$add_msg?>"><i class="fa fa-plus icon-embed-btn"></i><?=gettext('Add')?></a></td>
|
578
|
<?php
|
579
|
#Show description button and info if defined
|
580
|
if ($pkg['adddeleteeditpagefields']['description']) {
|
581
|
?>
|
582
|
<td>
|
583
|
<i class="fa fa-info-circle"><?=$pkg['adddeleteeditpagefields']['description']?></i>
|
584
|
</td>
|
585
|
<?php
|
586
|
}
|
587
|
?>
|
588
|
</tr>
|
589
|
</table>
|
590
|
</td>
|
591
|
</tr>
|
592
|
<?=$final_footer?>
|
593
|
</table>
|
594
|
</div>
|
595
|
<button class="btn btn-primary" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')"><i class="fa fa-save icon-embed-btn"></i><?=gettext("Save")?></button>
|
596
|
|
597
|
</form>
|
598
|
<?php
|
599
|
echo "<!-- filter_fieldname: {$filter_fieldname} -->";
|
600
|
echo "<!-- filter_regex: {$filter_regex} -->";
|
601
|
|
602
|
include("foot.inc"); ?>
|