Project

General

Profile

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