summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xusr/local/www/pkg.php14
-rwxr-xr-xusr/local/www/pkg_edit.php46
2 files changed, 40 insertions, 20 deletions
diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php
index 26da6b0..bc57e55 100755
--- a/usr/local/www/pkg.php
+++ b/usr/local/www/pkg.php
@@ -30,6 +30,10 @@
require_once("guiconfig.inc");
require_once("pkg-utils.inc");
+function gettext($text) {
+ return $text;
+}
+
function gentitle_pkg($pgname) {
global $config;
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
@@ -38,7 +42,7 @@ function gentitle_pkg($pgname) {
$xml = $_GET['xml'];
if($xml == "") {
- print_info_box_np("ERROR: No package defined.");
+ print_info_box_np(gettext("ERROR: No package defined."));
die;
} else {
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
@@ -161,9 +165,9 @@ if ($pkg['tabs'] <> "") {
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
if($column['type'] == "checkbox") {
if($fieldname == "") {
- echo "No";
+ echo gettext("No");
} else {
- echo "Yes";
+ echo gettext("Yes");
}
} else {
echo $column['prefix'] . $fieldname . $column['suffix'];
@@ -177,7 +181,7 @@ if ($pkg['tabs'] <> "") {
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<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"></a></td>
- <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this item?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ <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"></a></td>
</tr>
</table>
</td>
@@ -191,7 +195,7 @@ if ($pkg['tabs'] <> "") {
<td>
<table border="0" cellspacing="0" cellpadding="1">
<tr>
- <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ <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"></a></td>
</tr>
</table>
</td>
diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php
index cdedac4..b02428d 100755
--- a/usr/local/www/pkg_edit.php
+++ b/usr/local/www/pkg_edit.php
@@ -30,6 +30,10 @@
require_once("guiconfig.inc");
require_once("pkg-utils.inc");
+function gettext($text) {
+ return $text;
+}
+
function gentitle_pkg($pgname) {
global $pfSense_config;
return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname;
@@ -40,7 +44,7 @@ $xml = $_GET['xml'];
if($_POST['xml']) $xml = $_POST['xml'];
if($xml == "") {
- print_info_box_np("ERROR: No package defined.");
+ print_info_box_np(gettext("ERROR: No package defined."));
die;
} else {
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
@@ -50,12 +54,16 @@ if($pkg['include_file'] <> "") {
require_once($pkg['include_file']);
}
+if (!isset($pkg['adddeleteeditpagefields']))
+ $only_edit = true;
+else
+ $only_edit = false;
+
$package_name = $pkg['menu'][0]['name'];
$section = $pkg['menu'][0]['section'];
$config_path = $pkg['configpath'];
$name = $pkg['name'];
-//$title = $section . ": " . $package_name;
-$title = $pkg['title'];
+$title = $pkg['title'];
$pgtitle = $title;
$id = $_GET['id'];
@@ -120,7 +128,7 @@ if ($_POST) {
$reqfields = array();
$reqfieldsn = array();
foreach ($pkg['fields']['field'] as $field) {
- if (($field['type'] == 'input') && ($field['required'] == 'yes')) {
+ if (($field['type'] == 'input') && isset($field['required'])) {
$reqfields[] = $field['fieldname'];
$reqfieldsn[] = $field['fielddescr'];
}
@@ -214,10 +222,12 @@ if ($_POST) {
$get_from_post = true;
}
-if($pkg['title'] <> "")
- $title = $pkg['title'] . ': Edit';
+if($pkg['title'] <> "") {
+ $edit = ($only_edit ? '' : ': Edit');
+ $title = $pkg['title'] . $edit;
+}
else
- $title = "Package Editor";
+ $title = gettext("Package Editor");
$pgtitle = $title;
include("head.inc");
@@ -311,7 +321,7 @@ if ($pkg['tabs'] <> "") {
<tr><td><div id="mainarea"><table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<?php
$cols = 0;
- $savevalue = "Save";
+ $savevalue = gettext("Save");
if($pkg['savetext'] <> "") $savevalue = $pkg['savetext'];
foreach ($pkg['fields']['field'] as $pkga) { ?>
@@ -323,7 +333,7 @@ if ($pkg['tabs'] <> "") {
if(!$pkga['dontdisplayname']) {
unset($req);
- if ($pkga['required'] == 'yes')
+ if (isset($pkga['required']))
$req = 'req';
echo "<td width=\"22%\" class=\"vncell{$req}\">";
echo fixup_string($pkga['fielddescr']);
@@ -339,6 +349,8 @@ if ($pkg['tabs'] <> "") {
else {
if (isset($id) && $a_pkg[$id])
$value = $a_pkg[$id][$fieldname];
+ else
+ $value = $pkga['default_value'];
}
if($pkga['type'] == "input") {
@@ -370,7 +382,9 @@ if ($pkg['tabs'] <> "") {
} else if($pkga['type'] == "checkbox") {
$checkboxchecked = "";
if($value == "on") $checkboxchecked = " CHECKED";
- echo "<input type='checkbox' name='" . $pkga['fieldname'] . "'" . $checkboxchecked . ">\n";
+ if (isset($pkga['enablefields']) || isset($pkga['checkenablefields']))
+ $onclick = ' onclick="javascript:enablechange();"';
+ echo "<input type='checkbox' name='" . $pkga['fieldname'] . "'" . $checkboxchecked . $onclick . ">\n";
echo "<br>" . fixup_string($pkga['description']) . "\n";
} else if($pkga['type'] == "textarea") {
if($pkga['rows']) $rows = " rows='" . $pkga['rows'] . "' ";
@@ -499,7 +513,7 @@ if ($pkg['tabs'] <> "") {
$rowcounter++;
echo "<td>";
- echo "<input type=\"image\" src=\"./themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\">";
+ echo "<input type=\"image\" src=\"./themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"" . gettext("Delete") . "\">";
echo "</td>\n";
echo "</tr>\n";
}
@@ -566,12 +580,14 @@ if ($pkg['tabs'] <> "") {
<td width="78%">
<?php
if($pkg['note'] != "")
- print("<p><span class=\"red\"><strong>Note:</strong></span> {$pkg['note']}</p>");
-if (isset($id) && $a_pkg[$id])
+ print("<p><span class=\"red\"><strong>" . gettext("Note") . ":</strong></span> {$pkg['note']}</p>");
+//if (isset($id) && $a_pkg[$id]) // We'll always have a valid ID in our hands
print("<input name=\"id\" type=\"hidden\" value=\"$id\">");
?>
<input name="Submit" type="submit" class="formbtn" value="<?= $savevalue ?>">
- <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+<?php if (!$only_edit): ?>
+ <input class="formbtn" type="button" value="<?=gettext("Cancel");?>" onclick="history.back()">
+<?php endif; ?>
</td>
</tr>
</table>
@@ -723,4 +739,4 @@ function parse_package_templates() {
}
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud