Project

General

Profile

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