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