Project

General

Profile

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