Mutlilinguified Modules

This commit is contained in:
Nate Jones
2013-05-29 21:46:48 +00:00
parent 71998eff7b
commit 3fa4cbb720
4 changed files with 132 additions and 60 deletions

View File

@@ -0,0 +1,47 @@
<?php
//Modules
$text['title-modules']['en-us'] = 'Modules';
$text['title-module_add']['en-us'] = 'Module Add';
$text['title-module_edit']['en-us'] = 'Module Edit';
$text['header-modules']['en-us'] = 'Module List';
$text['header-module_add']['en-us'] = 'Module Add';
$text['header-module_edit']['en-us'] = 'Module Edit';
$text['description-modules']['en-us'] = 'Modules extend the features of the system. Use this page to enable or disable modules.';
$text['label-label']['en-us'] = 'Label';
$text['label-module_name']['en-us'] = 'Module Name';
$text['label-description']['en-us'] = 'Description';
$text['label-module_category']['en-us'] = 'Module Category';
$text['label-status']['en-us'] = 'Status';
$text['label-action']['en-us'] = 'Action';
$text['label-enabled']['en-us'] = 'Enabled';
$text['label-default_enabled']['en-us'] = 'Default Enabled';
$text['label-stopped']['en-us'] = 'Stopped';
$text['label-running']['en-us'] = 'Running';
$text['label-start']['en-us'] = 'Start';
$text['label-stop']['en-us'] = 'Stop';
$text['label-unload_module']['en-us'] = 'Unload Module';
$text['label-load_module']['en-us'] = 'Load Module';
$text['label-message']['en-us'] = 'Message';
$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['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

@@ -33,7 +33,16 @@ else {
echo "access denied";
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "includes/header.php";
$page["title"] = $text['title-modules'];
require_once "includes/paging.php";
$order_by = $_GET["order_by"];
@@ -46,7 +55,7 @@ if (strlen($_GET["a"]) > 0) {
if ($fp) {
$cmd = "api unload $module_name";
$response = trim(event_socket_request($fp, $cmd));
$msg = '<strong>Unload Module:</strong><pre>'.$response.'</pre>';
$msg = "<strong>".$text['label-unload_module'].":</strong> <pre>".$response."</pre>";
}
}
if ($_GET["a"] == "start") {
@@ -54,7 +63,7 @@ if (strlen($_GET["a"]) > 0) {
if ($fp) {
$cmd = "api load $module_name";
$response = trim(event_socket_request($fp, $cmd));
$msg = '<strong>Load Module:</strong><pre>'.$response.'</pre>';
$msg = "<strong>".$text['label-load_module'].":</strong> <pre>".$response."</pre>";
}
}
}
@@ -76,7 +85,7 @@ if (strlen($_GET["a"]) > 0) {
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
echo "<th align='left'>Message</th>\n";
echo "<th align='left'>".$text['label-message']."</th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='row_style1'>$msg</td>\n";
@@ -93,13 +102,10 @@ if (strlen($_GET["a"]) > 0) {
echo " <br>";
echo "<table width='100%' border='0'><tr>\n";
echo "<td align='left' width='50%' nowrap><b>Module List</b></td>\n";
echo "<td align='left' width='50%' align='right'>&nbsp;</td>\n";
echo "<td align='left' nowrap><b>".$text['header-modules']."</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left'>\n";
echo "Modules extend the features of the system. Use this page to enable or disable modules. ";
echo "</td>\n";
echo "<td align='left'>".$text['description-modules']."</td>\n";
echo "</tr>\n";
echo "</table>\n";
@@ -111,16 +117,13 @@ if (strlen($_GET["a"]) > 0) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
$tmp_module_header = "\n";
$tmp_module_header .= "<tr>\n";
//$tmp_module_header .= "<th>Module Category</th>\n";
$tmp_module_header .= "<th>Label</th>\n";
//$tmp_module_header .= "<th>Module Name</th>\n";
$tmp_module_header .= "<th>Description</th>\n";
$tmp_module_header .= "<th>Status</th>\n";
$tmp_module_header .= "<th>Action</th>\n";
$tmp_module_header .= "<th>Enabled</th>\n";
//$tmp_module_header .= "<th>Default Enabled</th>\n";
$tmp_module_header .= "<th>".$text['label-label']."</th>\n";
$tmp_module_header .= "<th>".$text['label-description']."</th>\n";
$tmp_module_header .= "<th>".$text['label-status']."</th>\n";
$tmp_module_header .= "<th>".$text['label-action']."</th>\n";
$tmp_module_header .= "<th>".$text['label-enabled']."</th>\n";
$tmp_module_header .= "<td align='right' width='42'>\n";
$tmp_module_header .= " <a href='modules_edit.php' alt='add'>$v_link_label_add</a>\n";
$tmp_module_header .= " <a href='modules_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
$tmp_module_header .= "</td>\n";
$tmp_module_header .= "<tr>\n";
@@ -154,31 +157,35 @@ if (strlen($_GET["a"]) > 0) {
}
echo "<tr >\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row["module_category"]."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row["module_label"]."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row["module_name"]."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row["module_description"]."&nbsp;</td>\n";
if ($mod->active($row["module_name"])) {
echo " <td valign='top' class='".$row_style[$c]."'>Running</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='modules.php?a=stop&m=".$row["module_name"]."' alt='stop'>Stop</a></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-running']."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='modules.php?a=stop&m=".$row["module_name"]."' alt='".$text['label-stop']."'>".$text['label-stop']."</a></td>\n";
}
else {
if ($row['module_enabled']=="true") {
echo " <td valign='top' class='".$row_style[$c]."'><b>Stopped</b></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><b>".$text['label-stopped']."</b></td>\n";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>Stopped $notice</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-stopped']." ".$notice."</td>\n";
}
echo " <td valign='top' class='".$row_style[$c]."'><a href='modules.php?a=start&m=".$row["module_name"]."' alt='start'>Start</a></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='modules.php?a=start&m=".$row["module_name"]."' alt='".$text['label-start']."'>".$text['label-start']."</a></td>\n";
}
echo " <td valign='top' class='".$row_style[$c]."'>".$row["module_enabled"]."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row["module_default_enabled"]."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if ($row["module_enabled"] == "true") {
echo $text['option-true'];
}
else if ($row["module_enabled"] == "false") {
echo $text['option-false'];
}
echo "</td>\n";
echo " <td valign='top' align='right'>\n";
if (permission_exists('modules_edit')) {
echo " <a href='modules_edit.php?id=".$row["module_uuid"]."' alt='edit'>$v_link_label_edit</a>\n";
echo " <a href='modules_edit.php?id=".$row["module_uuid"]."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
}
if (permission_exists('modules_delete')) {
echo " <a href='modules_delete.php?id=".$row["module_uuid"]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
echo " <a href='modules_delete.php?id=".$row["module_uuid"]."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
@@ -197,7 +204,7 @@ if (strlen($_GET["a"]) > 0) {
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n";
if (permission_exists('modules_add')) {
echo " <a href='modules_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='modules_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
}
echo " </td>\n";
echo " </tr>\n";

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"];
}
@@ -49,7 +55,7 @@ if (strlen($id)>0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=modules.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']];
}
//determin the action add or update
if (isset($_REQUEST["id"])) {
$action = "update";
@@ -61,12 +67,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//check for all required data
if (strlen($module_label) == 0) { $msg .= "Please provide: Label<br>\n"; }
if (strlen($module_name) == 0) { $msg .= "Please provide: Module Name<br>\n"; }
//if (strlen($module_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
if (strlen($module_category) == 0) { $msg .= "Please provide: Module Category<br>\n"; }
if (strlen($module_enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
if (strlen($module_default_enabled) == 0) { $msg .= "Please provide: Default Enabled<br>\n"; }
if (strlen($module_label) == 0) { $msg .= $text['message-required'].$text['label-label']."<br>\n"; }
if (strlen($module_name) == 0) { $msg .= $text['message-required'].$text['label-module_name']."<br>\n"; }
//if (strlen($module_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (strlen($module_category) == 0) { $msg .= $text['message-required'].$text['label-module_category']."<br>\n"; }
if (strlen($module_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
if (strlen($module_default_enabled) == 0) { $msg .= $text['message-required'].$text['label-default_enabled']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
require_once "includes/persistformvar.php";
@@ -112,7 +118,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=modules.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;
@@ -135,7 +141,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=modules.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;
@@ -165,6 +171,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//show the header
require_once "includes/header.php";
if ($action == "add") {
$page["title"] = $text['title-module_add'];
}
if ($action == "update") {
$page["title"] = $text['title-module_edit'];
}
//show the content
echo "<div align='center'>";
@@ -180,17 +192,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
if ($action == "add") {
echo "<td align='left' width='30%' nowrap><b>Module Add</b></td>\n";
echo "<td align='left' width='30%' nowrap><b>".$text['header-module_add']."</b></td>\n";
}
if ($action == "update") {
echo "<td align='left' width='30%' nowrap><b>Module Update</b></td>\n";
echo "<td align='left' width='30%' nowrap><b>".$text['header-module_edit']."</b></td>\n";
}
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='modules.php'\" value='Back'></td>\n";
echo "<td width='70%' align='right'><input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='modules.php'\" value='".$text['button-back']."'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Label:\n";
echo " ".$text['label-label'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='module_label' maxlength='255' value=\"$module_label\">\n";
@@ -201,7 +213,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Module Name:\n";
echo " ".$text['label-module_name'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='module_name' maxlength='255' value=\"$module_name\">\n";
@@ -212,7 +224,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 " <input class='formfld' type='text' name='module_description' maxlength='255' value=\"$module_description\">\n";
@@ -223,7 +235,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Module Category:\n";
echo " ".$text['label-module_category'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
$table_name = 'v_modules';$field_name = 'module_category';$sql_where_optional = "";$field_current_value = $module_category;
@@ -235,22 +247,22 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
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='module_enabled'>\n";
echo " <option value=''></option>\n";
if ($module_enabled == "true") {
echo " <option value='true' SELECTED >true</option>\n";
if ($module_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 ($module_enabled == "false") {
echo " <option value='false' SELECTED >false</option>\n";
if ($module_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";
@@ -260,22 +272,22 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Default Enabled:\n";
echo " ".$text['label-default_enabled'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='module_default_enabled'>\n";
echo " <option value=''></option>\n";
if ($module_default_enabled == "true") {
echo " <option value='true' SELECTED >true</option>\n";
if ($module_default_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 ($module_default_enabled == "false") {
echo " <option value='false' SELECTED >false</option>\n";
if ($module_default_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";
@@ -287,7 +299,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if ($action == "update") {
echo " <input type='hidden' name='module_uuid' value='$module_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>";
echo "</table>";