Project

General

Profile

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