Multilinguified Variables.

This commit is contained in:
Nate Jones
2013-05-29 22:27:04 +00:00
parent ac8f9d8a34
commit bd4404cb14
5 changed files with 139 additions and 60 deletions

View File

@@ -0,0 +1,48 @@
<?php
//Variables
$text['title-variables']['en-us'] = 'System Variables';
$text['title-variable_add']['en-us'] = 'Variable Add';
$text['title-variable_edit']['en-us'] = 'Variable Edit';
$text['title-variables_advanced']['en-us'] = 'System Variables: Advanced';
$text['header-variables']['en-us'] = 'System Variables';
$text['header-variable_add']['en-us'] = 'Variable Add';
$text['header-variable_edit']['en-us'] = 'Variable Edit';
$text['header-variables_advanced']['en-us'] = 'System Variables: Advanced';
$text['description-variables']['en-us'] = 'Define preprocessor variables here.';
$text['description-variables_advanced']['en-us'] = 'Define preprocessor variables here. Can be accessed in the xml configation with $${var_name}.';
$text['label-name']['en-us'] = 'Name';
$text['label-value']['en-us'] = 'Value';
$text['label-category']['en-us'] = 'Category';
$text['label-enabled']['en-us'] = 'Enabled';
$text['label-order']['en-us'] = 'Order';
$text['label-description']['en-us'] = 'Description';
$text['label-codec_information']['en-us'] = 'Codec Information';
$text['description-name']['en-us'] = 'Enter the variable name.';
$text['description-value']['en-us'] = 'Enter the variable value.';
$text['description-category']['en-us'] = 'Select the category.';
$text['option-true']['en-us'] = 'True';
$text['option-false']['en-us'] = 'False';
$text['button-add']['en-us'] = 'Add';
$text['button-edit']['en-us'] = 'Edit';
$text['button-delete']['en-us'] = 'Delete';
$text['button-back']['en-us'] = 'Back';
$text['button-save']['en-us'] = 'Save';
$text['button-restore']['en-us'] = 'Restore Default';
$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
$text['message-add']['en-us'] = 'Add Completed';
$text['message-update']['en-us'] = 'Update Completed';
$text['message-delete']['en-us'] = 'Delete Completed';
$text['message-required']['en-us'] = 'Please provide: ';
?>

View File

@@ -34,6 +34,12 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
if (count($_GET)>0) {
$id = $_GET["id"];
}
@@ -53,7 +59,7 @@ if (count($_GET)>0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=vars.php\">\n";
echo "<div align='center'>\n";
echo "Delete Complete\n";
echo $text['message-delete']."\n";
echo "</div>\n";
require_once "includes/footer.php";
return;

View File

@@ -34,6 +34,12 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//set the action as an add or an update
if (isset($_REQUEST["id"])) {
$action = "update";
@@ -65,12 +71,11 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//check for all required data
if (strlen($var_name) == 0) { $msg .= "Please provide: Name<br>\n"; }
//if (strlen($var_value) == 0) { $msg .= "Please provide: Value<br>\n"; }
//if (strlen($var_cat) == 0) { $msg .= "Please provide: Category<br>\n"; }
if (strlen($var_enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
if (strlen($var_order) == 0) { $msg .= "Please provide: Order<br>\n"; }
//if (strlen($var_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
if (strlen($var_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
//if (strlen($var_value) == 0) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
//if (strlen($var_cat) == 0) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
if (strlen($var_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
if (strlen($var_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
require_once "includes/persistformvar.php";
@@ -121,7 +126,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=vars.php\">\n";
echo "<div align='center'>\n";
echo "Add Complete\n";
echo $text['message-add']."\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
@@ -149,7 +154,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=vars.php\">\n";
echo "<div align='center'>\n";
echo "Update Complete\n";
echo $text['message-update']."\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
@@ -179,6 +184,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//include header
require_once "includes/header.php";
if ($action == "add") {
$page["title"] = $text['title-variable_add'];
}
if ($action == "update") {
$page["title"] = $text['title-variable_edit'];
}
//show contents
echo "<div align='center'>";
@@ -193,67 +204,66 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
if ($action == "add") {
echo "<td width='30%' align='left'nowrap><b>Variable Add</b></td>\n";
echo "<td width='30%' align='left'nowrap><b>".$text['header-variable_add']."</b></td>\n";
}
if ($action == "update") {
echo "<td width='30%' align='left' nowrap><b>Variable Edit</b></td>\n";
echo "<td width='30%' align='left' nowrap><b>".$text['header-variable_edit']."</b></td>\n";
}
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='vars.php'\" value='Back'></td>\n";
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='vars.php'\" value='".$text['button-back']."'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Name:\n";
echo " ".$text['label-name'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='var_name' maxlength='255' value=\"$var_name\">\n";
echo "<br />\n";
echo "Enter the variable name here. \n";
echo $text['description-name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Value:\n";
echo " ".$text['label-value'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='var_value' maxlength='255' value=\"$var_value\">\n";
echo "<br />\n";
echo "Enter the variable value here. \n";
echo $text['description-value']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " Category:\n";
echo " ".$text['label-category'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
$table_name = 'v_vars';$field_name = 'var_cat';$sql_where_optional = "";$field_current_value = $var_cat;
echo html_select_other($db, $table_name, $field_name, $sql_where_optional, $field_current_value);
//echo " <input class='formfld' type='text' name='var_cat' maxlength='255' value=\"$var_cat\">\n";
echo "<br />\n";
echo "Enter the category here.\n";
echo $text['description-category']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Enabled:\n";
echo " ".$text['label-enabled'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='var_enabled'>\n";
echo " <option value=''></option>\n";
if ($var_enabled == "true") {
echo " <option value='true' SELECTED >true</option>\n";
if ($var_enabled == "true") {
echo " <option value='true' SELECTED >".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>true</option>\n";
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($var_enabled == "false") {
echo " <option value='false' SELECTED >false</option>\n";
if ($var_enabled == "false") {
echo " <option value='false' SELECTED >".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>false</option>\n";
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
@@ -263,11 +273,10 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Order:\n";
echo " ".$text['label-order'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='var_order' class='formfld'>\n";
//echo " <option></option>\n";
if (strlen(htmlspecialchars($var_order ))> 0) {
echo " <option selected='yes' value='".htmlspecialchars($var_order )."'>".htmlspecialchars($var_order )."</option>\n";
}
@@ -293,7 +302,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " Description:\n";
echo " ".$text['label-description'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <textarea class='formfld' name='var_description' rows='17'>$var_description</textarea>\n";
@@ -306,7 +315,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if ($action == "update") {
echo " <input type='hidden' name='var_uuid' value='$var_uuid'>\n";
}
echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
@@ -315,7 +324,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo "<br />\n";
echo "<b>Codec Information:</b><br />\n";
echo "<b>".$text['label-codec_information']."</b><br><br>\n";
echo "Module must be compiled and loaded. &nbsp; &nbsp; codecname[@8000h|16000h|32000h[@XXi]]<br />\n";
echo "<br />\n";
echo "XX is the frame size must be multples allowed for the codec<br />\n";

View File

@@ -34,8 +34,15 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//include the header
require_once "includes/header.php";
$page["title"] = $text['title-variables'];
//set http values as php variables
$order_by = $_GET["order_by"];
@@ -50,8 +57,8 @@ else {
echo "<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'><b>Variables</b><br>\n";
echo " Define preprocessor variables here. \n";
echo " <td align='left'><b>".$text['header-variables']."</b><br>\n";
echo " ".$text['description-variables']."\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
@@ -78,15 +85,13 @@ else {
$tmp_var_header = '';
$tmp_var_header .= "<tr>\n";
$tmp_var_header .= th_order_by('var_name', 'Name', $order_by, $order);
$tmp_var_header .= th_order_by('var_value', 'Value', $order_by, $order);
//$tmp_var_header .= th_order_by('var_cat', 'Category', $order_by, $order);
//$tmp_var_header .= th_order_by('var_order', 'Order', $order_by, $order);
$tmp_var_header .= th_order_by('var_enabled', 'Enabled', $order_by, $order);
$tmp_var_header .= "<th>Description</th>\n";
$tmp_var_header .= th_order_by('var_name', $text['label-name'], $order_by, $order);
$tmp_var_header .= th_order_by('var_value', $text['label-value'], $order_by, $order);
$tmp_var_header .= th_order_by('var_enabled', $text['label-enabled'], $order_by, $order);
$tmp_var_header .= "<th>".$text['label-description']."</th>\n";
$tmp_var_header .= "<td align='right' width='42'>\n";
if (permission_exists('variables_add')) {
$tmp_var_header .= " <a href='var_edit.php' alt='add'>$v_link_label_add</a>\n";
$tmp_var_header .= " <a href='var_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
}
$tmp_var_header .= "</td>\n";
$tmp_var_header .= "<tr>\n";
@@ -107,7 +112,7 @@ else {
echo " <td width='33.3%' align='center' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='right'>\n";
if (permission_exists('variables_add')) {
echo " <a href='var_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='var_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
}
echo " </td>\n";
echo " </tr>\n";
@@ -125,18 +130,23 @@ else {
echo "<tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".substr($row['var_name'],0,32)."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".substr($var_value,0,30)."&nbsp;</td>\n";
//echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$row['var_cat']."</td>\n";
//echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$row['var_order']."</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$row['var_enabled']."</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>";
if ($row['var_enabled'] == "true") {
echo $text['option-true'];
}
else if ($row['var_enabled'] == "false") {
echo $text['option-false'];
}
echo "</td>\n";
$var_description = str_replace("\n", "<br />", trim(substr(base64_decode($row['var_description']),0,40)));
$var_description = str_replace(" ", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $var_description);
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$var_description."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";
if (permission_exists('variables_edit')) {
echo " <a href='var_edit.php?id=".$row['var_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
echo " <a href='var_edit.php?id=".$row['var_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
}
if (permission_exists('variables_delete')) {
echo " <a href='var_delete.php?id=".$row['var_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
echo " <a href='var_delete.php?id=".$row['var_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
@@ -155,7 +165,7 @@ else {
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n";
if (permission_exists('variables_add')) {
echo " <a href='var_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='var_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
}
echo " </td>\n";
echo " </tr>\n";

View File

@@ -34,8 +34,15 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//include the header
require_once "includes/header.php";
$page["title"] = $text['title-variables_advanced'];
//restore the default vars.xml
if ($_GET['a'] == "default" && permission_exists('variables_edit')) {
@@ -43,7 +50,7 @@ if ($_GET['a'] == "default" && permission_exists('variables_edit')) {
$fd = fopen($_SESSION['switch']['conf']['dir'].".orig/vars.xml", "r");
$v_content = fread($fd, filesize($_SESSION['switch']['conf']['dir'].".orig/vars.xml"));
fclose($fd);
//write the default config fget
$fd = fopen($_SESSION['switch']['conf']['dir']."/vars.xml", "w");
fwrite($fd, $v_content);
@@ -66,16 +73,16 @@ if ($_GET['a'] == "default" && permission_exists('variables_edit')) {
fclose($fd);
//edit area
echo " <script language=\"javascript\" type=\"text/javascript\" src=\"/edit_area/edit_area_full.js\"></script>\n";
echo " <script language=\"javascript\" type=\"text/javascript\" src=\"/includes/edit_area/edit_area_full.js\"></script>\n";
echo " <script language=\"Javascript\" type=\"text/javascript\">\n";
echo " // initialisation //load,\n";
echo " editAreaLoader.init({\n";
echo " id: \"code\" // id of the textarea to transform //, |, help\n";
echo " ,start_highlight: true\n";
echo " ,font_size: \"8\"\n";
echo " ,font_size: \"9\"\n";
echo " ,allow_toggle: false\n";
echo " ,language: \"en\"\n";
echo " ,syntax: \"html\"\n";
echo " ,syntax: \"xml\"\n";
echo " ,toolbar: \"search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help\" //new_document,\n";
echo " ,plugins: \"charmap\"\n";
echo " ,charmap_default: \"arrows\"\n";
@@ -88,21 +95,20 @@ if ($_GET['a'] == "default" && permission_exists('variables_edit')) {
<div align='center'>
<table width="90%" border="0" cellpadding="0" cellspacing="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<form action="vars.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width='100%'><span class="vexpl"><span class="red"><strong>Variables<br>
</strong></span>
Define preprocessor variables here. Can be accessed in the xml configation with $${var_name}.
<br />
<br />
<td width='100%'><span class="vexpl"><span class="red"><strong><?=$text['header-variables_advanced']?></strong></span>
<br /><br />
<?=$text['description-variables_advanced']?>
<br /><br />
</td>
<td width='10%' align='right' valign='top'>
<td align='right' valign='top'>
<?php if (permission_exists('variables_edit')) { ?>
<input type="submit" class='btn' value="save" />
<input type="submit" class='btn' value="<?=$text['button-save']?>" />
<?php } ?>
</td>
</tr>
@@ -128,7 +134,7 @@ if ($_GET['a'] == "default" && permission_exists('variables_edit')) {
<input type="hidden" name="a" value="save" />
<?php
if (permission_exists('variables_edit')) {
echo "<input type='button' class='btn' value='Restore Default' onclick=\"document.location.href='vars.php?a=default&f=vars.xml';\" />";
echo "<input type='button' class='btn' value='".$text['button-restore']."' onclick=\"document.location.href='vars.php?a=default&f=vars.xml';\" />";
}
?>
</td>