Project

General

Profile

Download (19.4 KB) Statistics
| Branch: | Tag: | Revision:
1 a7f908db Scott Ullrich
<?php
2
/*
3 f8ac4407 Phil Davis
	pkg.php
4 1d333258 Scott Ullrich
/*
5 f5dbca0d Stephen Beaver
/* ====================================================================
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 a7f908db Scott Ullrich
56 6b07c15a Matthew Grooms
##|+PRIV
57
##|*IDENT=page-package-settings
58 5230f468 jim-p
##|*NAME=Package: Settings
59 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Package: Settings' page.
60
##|*MATCH=pkg.php*
61
##|-PRIV
62
63 e4bf1c19 Colin Smith
require_once("guiconfig.inc");
64
require_once("pkg-utils.inc");
65 a7f908db Scott Ullrich
66
function gentitle_pkg($pgname) {
67 e3c4b6b7 Scott Ullrich
	global $config;
68
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
69 a7f908db Scott Ullrich
}
70
71 2c2fed92 Stephen Beaver
function domTT_title($title_msg) {
72
	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');\"";
73
}
74
75 98bcf1f8 Scott Ullrich
$xml = $_REQUEST['xml'];
76 a7f908db Scott Ullrich
77 f8ac4407 Phil Davis
if ($xml == "") {
78 f5dbca0d Stephen Beaver
	include("head.inc");
79
	print_info_box_np(gettext("ERROR: No valid package defined."));
80
	include("foot.inc");
81 b000f96f Scott Ullrich
	exit;
82 a7f908db Scott Ullrich
} else {
83 44bcf766 jim-p
	$pkg_xml_prefix = "/usr/local/pkg/";
84
	$pkg_full_path = "{$pkg_xml_prefix}/{$xml}";
85
	if (substr_compare(realpath($pkg_full_path), $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) {
86
		print_info_box_np(gettext("ERROR: Invalid path specified."));
87
		die;
88
	}
89
	if (file_exists($pkg_full_path)) {
90
		$pkg = parse_xml_config_pkg($pkg_full_path, "packagegui");
91 f8ac4407 Phil Davis
	} else {
92 f5dbca0d Stephen Beaver
		include("head.inc");
93
		print_info_box_np(gettext("File not found ") . htmlspecialchars($xml));
94
		include("foot.inc");
95 98bcf1f8 Scott Ullrich
		exit;
96
	}
97 a7f908db Scott Ullrich
}
98
99 f5dbca0d Stephen Beaver
if ($pkg['donotsave'] != "") {
100 6f3d2063 Renato Botelho
	header("Location: pkg_edit.php?xml=" . $xml);
101 b000f96f Scott Ullrich
	exit;
102 3eaeb703 Scott Ullrich
}
103
104 7c172009 Scott Ullrich
if ($pkg['include_file'] != "") {
105
	require_once($pkg['include_file']);
106
}
107
108 f8ac4407 Phil Davis
if ($_REQUEST['startdisplayingat']) {
109 32c477c5 Scott Ullrich
	$startdisplayingat = $_REQUEST['startdisplayingat'];
110 f8ac4407 Phil Davis
}
111 32c477c5 Scott Ullrich
112 f8ac4407 Phil Davis
if ($_REQUEST['display_maximum_rows']) {
113
	if ($_REQUEST['display_maximum_rows']) {
114 3ca50a15 Scott Ullrich
		$display_maximum_rows = $_REQUEST['display_maximum_rows'];
115 f8ac4407 Phil Davis
	}
116
}
117 3ca50a15 Scott Ullrich
118 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
119 e3c4b6b7 Scott Ullrich
120 05a42cce Marcello Coutinho
if ($_GET['act'] == "update") {
121 f8ac4407 Phil Davis
122
	if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
123
		#get current values
124
		$current_values=$config['installedpackages'][$pkg['name']]['config'];
125
		#get updated ids
126
		parse_str($_REQUEST['ids'], $update_list);
127
		#sort ids to know what to change
128
		#useful to do not lose data when using sorting and paging
129
		$sort_list=$update_list['ids'];
130
		sort($sort_list);
131
		#apply updates
132
		foreach ($update_list['ids'] as $key=> $value) {
133
			$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
134
		}
135
		#save current config
136
		write_config();
137
		#sync package
138
		eval ("{$pkg['custom_php_resync_config_command']}");
139
	}
140
	#function called via jquery, no need to continue after save changes.
141
	exit;
142 05a42cce Marcello Coutinho
}
143 e3c4b6b7 Scott Ullrich
if ($_GET['act'] == "del") {
144 f8ac4407 Phil Davis
	// loop through our fieldnames and automatically setup the fieldnames
145 f5dbca0d Stephen Beaver
	// in the environment.	ie: a fieldname of username with a value of
146 f8ac4407 Phil Davis
	// testuser would automatically eval $username = "testuser";
147
	foreach ($evaledvar as $ip) {
148
		if ($pkg['adddeleteeditpagefields']['columnitem']) {
149
			foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
150
				${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
151
			}
152 ef2029df Scott Ullrich
		}
153 f8ac4407 Phil Davis
	}
154 e3c4b6b7 Scott Ullrich
155 f8ac4407 Phil Davis
	$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
156 e3c4b6b7 Scott Ullrich
157 f8ac4407 Phil Davis
	if ($a_pkg[$_GET['id']]) {
158
		unset($a_pkg[$_GET['id']]);
159
		write_config();
160 f5dbca0d Stephen Beaver
		if ($pkg['custom_delete_php_command'] != "") {
161
			if ($pkg['custom_php_command_before_form'] != "") {
162 f8ac4407 Phil Davis
				eval($pkg['custom_php_command_before_form']);
163 8060d89a Scott Ullrich
			}
164 f8ac4407 Phil Davis
			eval($pkg['custom_delete_php_command']);
165
		}
166
		header("Location:  pkg.php?xml=" . $xml);
167
		exit;
168
	}
169 e3c4b6b7 Scott Ullrich
}
170
171 4b5976b5 Scott Ullrich
ob_start();
172
173 d3ab36dc Ermal Lu?i
$iflist = get_configured_interface_with_descr(false, true);
174 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
175 a7f908db Scott Ullrich
176 f5dbca0d Stephen Beaver
if ($pkg['custom_php_global_functions'] != "") {
177 ef2029df Scott Ullrich
	eval($pkg['custom_php_global_functions']);
178 f8ac4407 Phil Davis
}
179 194b4e0a Colin Smith
180 f5dbca0d Stephen Beaver
if ($pkg['custom_php_command_before_form'] != "") {
181 194b4e0a Colin Smith
	eval($pkg['custom_php_command_before_form']);
182 f8ac4407 Phil Davis
}
183 f9a91638 Scott Ullrich
184 8cfdeb2e BBcan177
// Breadcrumb
185
if ($pkg['title'] != "") {
186
	if (!$only_edit) {
187
 		$pkg['title'] = $pkg['title'] . '/Edit';
188
	}
189
	if (strpos($pkg['title'], '/')) {
190
		$title = explode('/', $pkg['title']);
191
192
		foreach ($title as $subtitle) {
193
			$pgtitle[] = gettext($subtitle);
194
		}
195
	} else {
196
		$pgtitle = array(gettext("Package"), gettext($pkg['title']));
197
	}
198
} else {
199
	$pgtitle = array(gettext("Package"), gettext("Editor"));
200
}
201
202 83ddedcd Scott Ullrich
include("head.inc");
203
204 a7f908db Scott Ullrich
?>
205
206 44507df4 Colin Fleming
<script type="text/javascript">
207
//<![CDATA[
208 0f649c97 Phil Davis
events.push(function() {
209 2ef13b6c Stephen Beaver
210 44507df4 Colin Fleming
	function setFilter(filtertext) {
211
		jQuery('#pkg_filter').val(filtertext);
212
		document.pkgform.submit();
213 f8ac4407 Phil Davis
	}
214 44507df4 Colin Fleming
215 2ef13b6c Stephen Beaver
<?php
216
	if ($pkg['adddeleteeditpagefields']['movable']) {
217
?>
218
		$('#mainarea table tbody').sortable({
219
		items: 'tr.sortable',
220
			cursor: 'move',
221
			distance: 10,
222
			opacity: 0.8,
223
			helper: function(e, ui) {
224
				ui.children().each(function() {
225
					jQuery(this).width(jQuery(this).width());
226 44507df4 Colin Fleming
				});
227 2ef13b6c Stephen Beaver
			return ui;
228
			},
229
		});
230
<?php
231
	}
232
?>
233
});
234 b51d272c Stephen Beaver
235 15281e44 Stephen Beaver
function save_changes_to_xml(xml) {
236
	var ids = $('#mainarea table tbody').sortable('serialize', {key:"ids[]"});
237
	var strloading="<?=gettext('Saving changes...')?>";
238
	if (confirm("<?=gettext("Do you really want to save changes?")?>")) {
239
		$.ajax({
240
			type: 'get',
241
			cache: false,
242
			url: "<?=$_SERVER['SCRIPT_NAME']?>",
243
			data: {xml:'<?=$xml?>', act:'update', ids: ids},
244
			beforeSend: function() {
245
				$('#savemsg').empty().html(strloading);
246
			},
247
			error: function(data) {
248
				$('#savemsg').empty().html('Error:' + data);
249
			},
250
			success: function(data) {
251
				$('#savemsg').empty().html(data);
252
			}
253
		});
254 2ef13b6c Stephen Beaver
	}
255
}
256
257 44507df4 Colin Fleming
//]]>
258
</script>
259 f5dbca0d Stephen Beaver
260
<?php
261 0f649c97 Phil Davis
if ($_GET['savemsg'] != "") {
262 f5dbca0d Stephen Beaver
	$savemsg = htmlspecialchars($_GET['savemsg']);
263 0f649c97 Phil Davis
}
264 f5dbca0d Stephen Beaver
265 0f649c97 Phil Davis
if ($savemsg) {
266 f5dbca0d Stephen Beaver
	print_info_box($savemsg, 'success');
267 0f649c97 Phil Davis
}
268 f5dbca0d Stephen Beaver
?>
269
270 5aa9a4f2 Scott Ullrich
<form action="pkg.php" name="pkgform" method="get">
271 f5dbca0d Stephen Beaver
	<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
272 7c061036 Scott Ullrich
<?php
273 f5dbca0d Stephen Beaver
	if ($pkg['tabs'] != "") {
274 f8ac4407 Phil Davis
		$tab_array = array();
275
		foreach ($pkg['tabs']['tab'] as $tab) {
276
			if ($tab['tab_level']) {
277
				$tab_level = $tab['tab_level'];
278
			} else {
279
				$tab_level = 1;
280
			}
281
			if (isset($tab['active'])) {
282
				$active = true;
283
			} else {
284
				$active = false;
285
			}
286
			if (isset($tab['no_drop_down'])) {
287
				$no_drop_down = true;
288
			}
289
			$urltmp = "";
290 f5dbca0d Stephen Beaver
			if ($tab['url'] != "") {
291 f8ac4407 Phil Davis
				$urltmp = $tab['url'];
292
			}
293 f5dbca0d Stephen Beaver
			if ($tab['xml'] != "") {
294 f8ac4407 Phil Davis
				$urltmp = "pkg_edit.php?xml=" . $tab['xml'];
295
			}
296
297
			$addresswithport = getenv("HTTP_HOST");
298
			$colonpos = strpos($addresswithport, ":");
299
			if ($colonpos !== False) {
300
				//my url is actually just the IP address of the pfsense box
301
				$myurl = substr($addresswithport, 0, $colonpos);
302
			} else {
303
				$myurl = $addresswithport;
304
			}
305
			// eval url so that above $myurl item can be processed if need be.
306
			$url = str_replace('$myurl', $myurl, $urltmp);
307
308
			$tab_array[$tab_level][] = array(
309
				$tab['text'],
310
				$active,
311
				$url
312
			);
313
		}
314
315
		ksort($tab_array);
316
		foreach ($tab_array as $tab) {
317
			display_top_tabs($tab, $no_drop_down);
318
		}
319
	}
320 7c061036 Scott Ullrich
?>
321 c24bb3fc Stephen Beaver
		<div id="mainarea" class="panel panel-default">
322 b51d272c Stephen Beaver
			<table id="mainarea" class="table table-striped table-hover table-condensed">
323 c24bb3fc Stephen Beaver
				<thead>
324 32c477c5 Scott Ullrich
<?php
325 f8ac4407 Phil Davis
	/* Handle filtering bar A-Z */
326
	$include_filtering_inputbox = false;
327
	$colspan = 0;
328 f5dbca0d Stephen Beaver
	if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
329 f8ac4407 Phil Davis
		foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
330
			$colspan++;
331
		}
332
	}
333
	if ($pkg['fields']['field']) {
334
		// First find the sorting type field if it exists
335
		foreach ($pkg['fields']['field'] as $field) {
336
			if ($field['type'] == "sorting") {
337
				if (isset($field['include_filtering_inputbox'])) {
338
					$include_filtering_inputbox = true;
339
				}
340
				if ($display_maximum_rows < 1) {
341
					if ($field['display_maximum_rows']) {
342
						$display_maximum_rows = $field['display_maximum_rows'];
343
					}
344
				}
345 f5dbca0d Stephen Beaver
				echo "<tr><td colspan='$colspan' align='center'>";
346 f8ac4407 Phil Davis
				echo "Filter by: ";
347
				$isfirst = true;
348
				for ($char = 65; $char < 91; $char++) {
349
					if (!$isfirst) {
350
						echo " | ";
351
					}
352
					echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
353
					$isfirst = false;
354
				}
355
				echo "</td></tr>";
356 f5dbca0d Stephen Beaver
				echo "<tr><td colspan='$colspan' align='center'>";
357 f8ac4407 Phil Davis
				if ($field['sortablefields']) {
358
					echo "Filter field: <select name='pkg_filter_type'>";
359
					foreach ($field['sortablefields']['item'] as $si) {
360
						if ($si['name'] == $_REQUEST['pkg_filter_type']) {
361 c4b60a9a Colin Fleming
							$SELECTED = "selected";
362 f8ac4407 Phil Davis
						} else {
363
							$SELECTED = "";
364 32c477c5 Scott Ullrich
						}
365 f8ac4407 Phil Davis
						echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
366 32c477c5 Scott Ullrich
					}
367 f8ac4407 Phil Davis
					echo "</select>";
368 32c477c5 Scott Ullrich
				}
369 f8ac4407 Phil Davis
				if ($include_filtering_inputbox) {
370 f5dbca0d Stephen Beaver
					echo "&nbsp;&nbsp;Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /><input type='submit' value='Filter' />";
371 f8ac4407 Phil Davis
				}
372
				echo "</td></tr><tr><td><font size='-3'>&nbsp;</font></td></tr>";
373
			}
374
		}
375
	}
376 32c477c5 Scott Ullrich
?>
377
				<tr>
378 c24bb3fc Stephen Beaver
379 32c477c5 Scott Ullrich
<?php
380 f8ac4407 Phil Davis
	if ($display_maximum_rows) {
381 6c07db48 Phil Davis
		$totalpages = ceil(round((count($evaledvar) / $display_maximum_rows), 9));
382 f8ac4407 Phil Davis
		$page = 1;
383
		$tmpcount = 0;
384
		$tmppp = 0;
385
		if (is_array($evaledvar)) {
386
			foreach ($evaledvar as $ipa) {
387
				if ($tmpcount == $display_maximum_rows) {
388
					$page++;
389 37da0c50 Scott Ullrich
					$tmpcount = 0;
390
				}
391 f8ac4407 Phil Davis
				if ($tmppp == $startdisplayingat) {
392
					break;
393 32c477c5 Scott Ullrich
				}
394 f8ac4407 Phil Davis
				$tmpcount++;
395
				$tmppp++;
396
			}
397
		}
398 c24bb3fc Stephen Beaver
		echo "<tr><th colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
399 f8ac4407 Phil Davis
		echo "<table width='100%' summary=''>";
400
		echo "<tr>";
401
		echo "<td align='left'>Displaying page $page of $totalpages</b></td>";
402
		echo "<td align='right'>Rows per page: <select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
403 6c07db48 Phil Davis
		for ($x = 0; $x < 250; $x++) {
404 f8ac4407 Phil Davis
			if ($x == $display_maximum_rows) {
405 c4b60a9a Colin Fleming
				$SELECTED = "selected";
406 f8ac4407 Phil Davis
			} else {
407
				$SELECTED = "";
408
			}
409
			echo "<option value='$x' $SELECTED>$x</option>\n";
410
			$x = $x + 4;
411
		}
412
		echo "</select></td></tr>";
413
		echo "</table>";
414 c24bb3fc Stephen Beaver
		echo "</th></tr>";
415 f8ac4407 Phil Davis
	}
416 2ef13b6c Stephen Beaver
417 f8ac4407 Phil Davis
	$cols = 0;
418 f5dbca0d Stephen Beaver
	if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
419 f8ac4407 Phil Davis
		foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
420 c24bb3fc Stephen Beaver
			echo "<th class=\"listhdrr\">" . $column['fielddescr'] . "</th>";
421 f8ac4407 Phil Davis
			$cols++;
422
		}
423
	}
424
?>
425
				</tr>
426 c24bb3fc Stephen Beaver
				</thead>
427
				<tbody>
428 f8ac4407 Phil Davis
<?php
429
	$i = 0;
430 6c07db48 Phil Davis
	$pagination_counter = 0;
431 f8ac4407 Phil Davis
	if ($evaledvar) {
432
		foreach ($evaledvar as $ip) {
433
			if ($startdisplayingat) {
434
				if ($i < $startdisplayingat) {
435
					$i++;
436
					continue;
437 32c477c5 Scott Ullrich
				}
438 f8ac4407 Phil Davis
			}
439
			if ($_REQUEST['pkg_filter']) {
440
				// Handle filtered items
441
				if ($pkg['fields']['field'] && !$filter_regex) {
442
					// First find the sorting type field if it exists
443
					foreach ($pkg['fields']['field'] as $field) {
444
						if ($field['type'] == "sorting") {
445
							if ($field['sortablefields']['item']) {
446
								foreach ($field['sortablefields']['item'] as $sf) {
447
									if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
448
										$filter_fieldname = $sf['fieldname'];
449
										#Use a default regex on sortable fields when none is declared
450
										if ($sf['regex']) {
451
											$filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
452
										} else {
453
											$filter_regex = "/{$_REQUEST['pkg_filter']}/i";
454 32c477c5 Scott Ullrich
										}
455
									}
456
								}
457
							}
458
						}
459
					}
460 f8ac4407 Phil Davis
				}
461
				// Do we have something to filter on?
462
				unset($filter_matches);
463 f5dbca0d Stephen Beaver
				if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
464 f8ac4407 Phil Davis
					foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
465
						$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
466
						if ($column['fieldname'] == $filter_fieldname) {
467
							if ($filter_regex) {
468
								//echo "$filter_regex - $fieldname<p/>";
469
								preg_match($filter_regex, $fieldname, $filter_matches);
470
								break;
471 32c477c5 Scott Ullrich
							}
472
						}
473
					}
474
				}
475 f8ac4407 Phil Davis
				if (!$filter_matches) {
476
					$i++;
477
					continue;
478
				}
479
			}
480
			if ($pkg['adddeleteeditpagefields']['movable']) {
481
				echo "<tr valign=\"top\" class=\"sortable\" id=\"id_{$i}\">\n";
482
			} else {
483
				echo "<tr valign=\"top\">\n";
484
			}
485 f5dbca0d Stephen Beaver
			if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
486 f8ac4407 Phil Davis
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
487
					if ($column['fieldname'] == "description") {
488
						$class = "listbg";
489
					} else {
490
						$class = "listlr";
491
					}
492 32c477c5 Scott Ullrich
?>
493 f5dbca0d Stephen Beaver
					<td class="<?=$class?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i?>';">
494 32c477c5 Scott Ullrich
<?php
495 f8ac4407 Phil Davis
					$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
496
					#Check if columnitem has a type field declared
497
					if ($column['type'] == "checkbox") {
498
						if ($fieldname == "") {
499
							echo gettext("No");
500
						} else {
501
							echo gettext("Yes");
502
						}
503
					} else if ($column['type'] == "interface") {
504 6c07db48 Phil Davis
						echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
505 f8ac4407 Phil Davis
					} else {
506
						#Check if columnitem has an encoding field declared
507
						if ($column['encoding'] == "base64") {
508 6c07db48 Phil Davis
							echo $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
509 f8ac4407 Phil Davis
						#Check if there is a custom info to show when $fieldname is not empty
510
						} else if ($column['listmodeon'] && $fieldname != "") {
511
							echo $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
512
						#Check if there is a custom info to show when $fieldname is empty
513
						} else if ($column['listmodeoff'] && $fieldname == "") {
514
							echo $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
515
						} else {
516
							echo $column['prefix'] . $fieldname ." ". $column['suffix'];
517
						}
518 32c477c5 Scott Ullrich
					}
519
?>
520 f8ac4407 Phil Davis
					</td>
521 32c477c5 Scott Ullrich
<?php
522 f8ac4407 Phil Davis
				} // foreach columnitem
523
			} // if columnitem
524
?>
525
					<td valign="middle" class="list nowrap">
526
						<table border="0" cellspacing="0" cellpadding="1" summary="icons">
527
							<tr>
528
<?php
529
			#Show custom description to edit button if defined
530
			$edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:"Edit this item");
531
?>
532 995df6c3 Stephen Beaver
								<td><a class="btn btn-xs btn-info" href="pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i?>"><?=$edit_msg?></a></td>
533 f8ac4407 Phil Davis
<?php
534
			#Show custom description to delete button if defined
535
			$delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:"Delete this item");
536
?>
537 c24bb3fc Stephen Beaver
								<td>&nbsp;<a class="btn btn-xs btn-danger" href="pkg.php?xml=<?=$xml?>&amp;act=del&amp;id=<?=$i?>"><?=gettext("Delete")?></a></td>
538 f8ac4407 Phil Davis
							</tr>
539 c24bb3fc Stephen Beaver
						</tbody>
540
					</table>
541 b51d272c Stephen Beaver
				</td>
542 f8ac4407 Phil Davis
<?php
543 f5dbca0d Stephen Beaver
			echo "</tr>\n"; // Pairs with an echo tr some way above
544 f8ac4407 Phil Davis
			// Handle pagination and display_maximum_rows
545
			if ($display_maximum_rows) {
546
				if ($pagination_counter == ($display_maximum_rows-1) or
547 f5dbca0d Stephen Beaver
					$i == (count($evaledvar)-1)) {
548 f8ac4407 Phil Davis
					$colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
549
					$final_footer = "";
550
					$final_footer .= "<tr><td colspan='$colcount'>";
551 6c07db48 Phil Davis
					$final_footer .= "<table width='100%' summary=''><tr>";
552
					$final_footer .= "<td align='left'>";
553 f8ac4407 Phil Davis
					$startingat = $startdisplayingat - $display_maximum_rows;
554
					if ($startingat > -1) {
555 6c07db48 Phil Davis
						$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat={$startingat}&amp;display_maximum_rows={$display_maximum_rows}'>";
556 f8ac4407 Phil Davis
					} else if ($startdisplayingat > 1) {
557 6c07db48 Phil Davis
						$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=0&amp;display_maximum_rows={$display_maximum_rows}'>";
558 32c477c5 Scott Ullrich
					}
559 6c07db48 Phil Davis
					$final_footer .= "<font size='2'><< Previous page</font></a>";
560 f8ac4407 Phil Davis
					if ($tmppp + $display_maximum_rows > count($evaledvar)) {
561
						$endingrecord = count($evaledvar);
562
					} else {
563
						$endingrecord = $tmppp + $display_maximum_rows;
564
					}
565 6c07db48 Phil Davis
					$final_footer .= "</td><td align='center'>";
566 f8ac4407 Phil Davis
					$tmppp++;
567 6c07db48 Phil Davis
					$final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
568
					$final_footer .= "</font></td><td align='right'>&nbsp;";
569 f8ac4407 Phil Davis
					if (($i+1) < count($evaledvar)) {
570 6c07db48 Phil Davis
						$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&amp;display_maximum_rows={$display_maximum_rows}'>";
571 f8ac4407 Phil Davis
					}
572 6c07db48 Phil Davis
					$final_footer .= "<font size='2'>Next page >></font></a>";
573
					$final_footer .= "</td></tr></table></td></tr>";
574 f8ac4407 Phil Davis
					$i = count($evaledvar);
575
					break;
576 549912e3 Scott Ullrich
				}
577 f8ac4407 Phil Davis
			}
578
			$i++;
579
			$pagination_counter++;
580
		} // foreach evaledvar
581
	} // if evaledvar
582 32c477c5 Scott Ullrich
?>
583
				<tr>
584
					<td colspan="<?=$cols?>"></td>
585
					<td>
586 44507df4 Colin Fleming
						<table border="0" cellspacing="0" cellpadding="1" summary="icons">
587 32c477c5 Scott Ullrich
							<tr>
588 f8ac4407 Phil Davis
<?php
589
	#Show custom description to add button if defined
590
	$add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:"Add a new item");
591
?>
592 c24bb3fc Stephen Beaver
								<td><a href="pkg_edit.php?xml=<?=$xml?>&amp;id=<?=$i?>" class="btn btn-sm btn-success"><?=gettext('Add')?></a></td>
593 f8ac4407 Phil Davis
<?php
594
	#Show description button and info if defined
595
	if ($pkg['adddeleteeditpagefields']['description']) {
596
?>
597 995df6c3 Stephen Beaver
								<td>
598 7ea65674 Jared Dillard
									<i class="fa fa-info-circle"><?=$pkg['adddeleteeditpagefields']['description']?></i>
599 995df6c3 Stephen Beaver
								</td>
600 f8ac4407 Phil Davis
<?php
601
	}
602
?>
603 32c477c5 Scott Ullrich
							</tr>
604
						</table>
605
					</td>
606
				</tr>
607 37da0c50 Scott Ullrich
				<?=$final_footer?>
608 f8ac4407 Phil Davis
<?php
609
	#Show save button only when movable is defined
610
	if ($pkg['adddeleteeditpagefields']['movable']) {
611
?>
612 c24bb3fc Stephen Beaver
613
614
615 f8ac4407 Phil Davis
<?php
616
	}
617
?>
618
			</table>
619 c24bb3fc Stephen Beaver
			</div>
620
		<input class="btn btn-primary" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')" />
621 3d335c4d Scott Ullrich
622 a7f908db Scott Ullrich
</form>
623 b000f96f Scott Ullrich
<?php
624 f5dbca0d Stephen Beaver
echo "<!-- filter_fieldname: {$filter_fieldname} -->";
625
echo "<!-- filter_regex: {$filter_regex} -->";
626 b000f96f Scott Ullrich
627 f5dbca0d Stephen Beaver
include("foot.inc"); ?>