Explorar o código

Multilinguified Upgrade Schema

Nate Jones %!s(int64=12) %!d(string=hai) anos
pai
achega
09c31689c0

+ 25 - 0
core/upgrade/app_languages.php

@@ -0,0 +1,25 @@
+<?php
+
+	// Upgrade Schema
+
+		$text['title-upgrade_schema']['en-us'] = 'Upgrade Schema';
+
+		$text['header-database_type']['en-us'] = 'Database Type';
+		$text['header-message']['en-us'] = 'Message';
+
+		$text['label-sql_changes']['en-us'] = 'SQL Changes';
+		$text['label-table']['en-us'] = 'Table';
+		$text['label-exists']['en-us'] = 'Exists';
+		$text['label-details']['en-us'] = 'Details';
+		$text['label-name']['en-us'] = 'Name';
+		$text['label-type']['en-us'] = 'Type';
+		$text['label-upgrade']['en-us'] = 'Upgrade';
+		$text['label-database']['en-us'] = 'Database';
+		$text['label-schema']['en-us'] = 'Schema';
+		$text['label-no_change']['en-us'] = 'No Change';
+
+		$text['option-true']['en-us'] = 'True';
+		$text['option-false']['en-us'] = 'False';
+
+		$text['message-upgrade']['en-us'] = 'Upgrade Completed';
+?>

+ 17 - 4
core/upgrade/upgrade.php

@@ -33,6 +33,12 @@
 		require_once "includes/require.php";
 		require_once "includes/require.php";
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$display_type = 'text'; //html, text
 		$display_type = 'text'; //html, text
+
+		//add multi-lingual support
+			require_once "app_languages.php";
+			foreach($text as $key => $value) {
+				$text[$key] = $value[$_SESSION['domain']['language']['code']];
+			}
 	}
 	}
 	else {
 	else {
 		include "root.php";
 		include "root.php";
@@ -45,6 +51,13 @@
 			echo "access denied";
 			echo "access denied";
 			exit;
 			exit;
 		}
 		}
+
+		//add multi-lingual support
+			require_once "app_languages.php";
+			foreach($text as $key => $value) {
+				$text[$key] = $value[$_SESSION['domain']['language']['code']];
+			}
+
 	}
 	}
 
 
 //set the default
 //set the default
@@ -59,10 +72,10 @@
 
 
 if ($display_type == 'text') {
 if ($display_type == 'text') {
 	echo "\n";
 	echo "\n";
-	echo "Upgrade\n";
+	echo $text['label-upgrade']."\n";
 	echo "-----------------------------------------\n";
 	echo "-----------------------------------------\n";
 	echo "\n";
 	echo "\n";
-	echo "Database\n";
+	echo $text['label-database']."\n";
 }
 }
 
 
 //upgrade the database schema
 //upgrade the database schema
@@ -73,10 +86,10 @@ if ($display_type == 'text') {
 		echo "<div align='center'>\n";
 		echo "<div align='center'>\n";
 		echo "<table width='40%'>\n";
 		echo "<table width='40%'>\n";
 		echo "<tr>\n";
 		echo "<tr>\n";
-		echo "<th align='left'>Message</th>\n";
+		echo "<th align='left'>".$text['header-message']."</th>\n";
 		echo "</tr>\n";
 		echo "</tr>\n";
 		echo "<tr>\n";
 		echo "<tr>\n";
-		echo "<td class='row_style1'><strong>Upgrade Completed</strong></td>\n";
+		echo "<td class='row_style1'><strong>".$text['message-upgrade']."</strong></td>\n";
 		echo "</tr>\n";
 		echo "</tr>\n";
 		echo "</table>\n";
 		echo "</table>\n";
 		echo "</div>\n";
 		echo "</div>\n";

+ 15 - 0
core/upgrade/upgrade_schema.php

@@ -33,6 +33,12 @@
 		require_once "includes/require.php";
 		require_once "includes/require.php";
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$display_type = 'text'; //html, text
 		$display_type = 'text'; //html, text
+
+		//add multi-lingual support
+			require_once "app_languages.php";
+			foreach($text as $key => $value) {
+				$text[$key] = $value[$_SESSION['domain']['language']['code']];
+			}
 	}
 	}
 	else {
 	else {
 		include "root.php";
 		include "root.php";
@@ -45,7 +51,16 @@
 			echo "access denied";
 			echo "access denied";
 			exit;
 			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";
 		require_once "includes/header.php";
+		$page["title"] = $text['title-upgrade_schema'];
+
 		$display_type = 'html'; //html, text
 		$display_type = 'html'; //html, text
 	}
 	}
 
 

+ 17 - 16
includes/lib_schema.php

@@ -269,6 +269,7 @@ function db_insert_into ($apps, $db_type, $table) {
 }
 }
 
 
 function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
+	global $text; // pulls in language variable array
 	global $display_type;
 	global $display_type;
 
 
 	//PHP PDO check if table or column exists
 	//PHP PDO check if table or column exists
@@ -514,7 +515,7 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 	//display results as html
 	//display results as html
 		if ($display_results && $display_type == "html") {
 		if ($display_results && $display_type == "html") {
 			//show the database type
 			//show the database type
-				echo "<strong>Database Type: ".$db_type. "</strong><br /><br />";
+				echo "<strong>".$text['header-database_type'].": ".$db_type. "</strong><br /><br />";
 			//start the table
 			//start the table
 				echo "<table width='100%' border='0' cellpadding='20' cellspacing='0'>\n";
 				echo "<table width='100%' border='0' cellpadding='20' cellspacing='0'>\n";
 			//show the changes
 			//show the changes
@@ -522,7 +523,7 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 					echo "<tr>\n";
 					echo "<tr>\n";
 					echo "<td class='row_style1' colspan='3'>\n";
 					echo "<td class='row_style1' colspan='3'>\n";
 					echo "<br />\n";
 					echo "<br />\n";
-					echo "<strong>SQL Changes:</strong><br />\n";
+					echo "<strong>".$text['label-sql_changes'].":</strong><br />\n";
 					echo "<pre>\n";
 					echo "<pre>\n";
 					echo $sql_update;
 					echo $sql_update;
 					echo "</pre>\n";
 					echo "</pre>\n";
@@ -532,9 +533,9 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 				}
 				}
 			//list all tables
 			//list all tables
 				echo "<tr>\n";
 				echo "<tr>\n";
-				echo "<th>Table</th>\n";
-				echo "<th>Exists</th>\n";
-				echo "<th>Details</th>\n";
+				echo "<th>".$text['label-table']."</th>\n";
+				echo "<th>".$text['label-exists']."</th>\n";
+				echo "<th>".$text['label-details']."</th>\n";
 				echo "<tr>\n";
 				echo "<tr>\n";
 			//build the html while looping through the app db array
 			//build the html while looping through the app db array
 				$sql = '';
 				$sql = '';
@@ -550,17 +551,17 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 
 
 						//check if the table exists
 						//check if the table exists
 							if ($row['exists'] == "true") {
 							if ($row['exists'] == "true") {
-								echo "<td valign='top' class='row_style1'><strong>table</strong><br />$table_name</td>\n";
-								echo "<td valign='top' class='vncell' style=''>true</td>\n";
+								echo "<td valign='top' class='row_style1'>".$table_name."</td>\n";
+								echo "<td valign='top' class='vncell' style='padding-top: 3px;'>".$text['option-true']."</td>\n";
 
 
 								if (count($row['fields']) > 0) {
 								if (count($row['fields']) > 0) {
 									echo "<td class='row_style1'>\n";
 									echo "<td class='row_style1'>\n";
 									//show the list of columns
 									//show the list of columns
 										echo "<table border='0' cellpadding='10' cellspacing='0'>\n";
 										echo "<table border='0' cellpadding='10' cellspacing='0'>\n";
 										echo "<tr>\n";
 										echo "<tr>\n";
-										echo "<th>name</th>\n";
-										echo "<th>type</th>\n";
-										echo "<th>exists</th>\n";
+										echo "<th>".$text['label-name']."</th>\n";
+										echo "<th>".$text['label-type']."</th>\n";
+										echo "<th>".$text['label-exists']."</th>\n";
 										echo "</tr>\n";
 										echo "</tr>\n";
 										foreach ($row['fields'] as $field) {
 										foreach ($row['fields'] as $field) {
 											if ($field['deprecated'] == "true") {
 											if ($field['deprecated'] == "true") {
@@ -583,11 +584,11 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 												echo "<td class='row_style1' width='200'>".$field_name."</td>\n";
 												echo "<td class='row_style1' width='200'>".$field_name."</td>\n";
 												echo "<td class='row_style1'>".$field_type."</td>\n";
 												echo "<td class='row_style1'>".$field_type."</td>\n";
 												if ($field['exists'] == "true") {
 												if ($field['exists'] == "true") {
-													echo "<td class='row_style0' style=''>true</td>\n";
+													echo "<td class='row_style0' style=''>".$text['option-true']."</td>\n";
 													echo "<td>&nbsp;</td>\n";
 													echo "<td>&nbsp;</td>\n";
 												}
 												}
 												else {
 												else {
-													echo "<td class='row_style1' style='background-color:#444444;color:#CCCCCC;'>false</td>\n";
+													echo "<td class='row_style1' style='background-color:#444444;color:#CCCCCC;'>".$text['option-false']."</td>\n";
 													echo "<td>&nbsp;</td>\n";
 													echo "<td>&nbsp;</td>\n";
 												}
 												}
 												echo "</tr>\n";
 												echo "</tr>\n";
@@ -599,8 +600,8 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 								}
 								}
 							}
 							}
 							else {
 							else {
-								echo "<td valign='top' class='row_style1'><strong>table</strong><br />$table_name</td>\n";
-								echo "<td valign='top' class='row_style1' style='background-color:#444444;color:#CCCCCC;'><strong>exists</strong><br />false</td>\n";
+								echo "<td valign='top' class='row_style1'>$table_name</td>\n";
+								echo "<td valign='top' class='row_style1' style='background-color:#444444;color:#CCCCCC;'><strong>".$text['label-exists']."</strong><br />".$text['option-false']."</td>\n";
 								echo "<td valign='top' class='row_style1'>&nbsp;</td>\n";
 								echo "<td valign='top' class='row_style1'>&nbsp;</td>\n";
 							}
 							}
 							echo "</tr>\n";
 							echo "</tr>\n";
@@ -615,11 +616,11 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
 		//loop line by line through all the lines of sql code
 		//loop line by line through all the lines of sql code
 			$x = 0;
 			$x = 0;
 			if (strlen($sql_update) == 0 && $display_type == "text") {
 			if (strlen($sql_update) == 0 && $display_type == "text") {
-				echo "	Schema:			no change\n";
+				echo "	".$text['label-schema'].":			".$text['label-no_change']."\n";
 			}
 			}
 			else {
 			else {
 				if ($display_type == "text") {
 				if ($display_type == "text") {
-					echo "	Schema:\n";
+					echo "	".$text['label-schema'].":\n";
 				}
 				}
 				//$db->beginTransaction();
 				//$db->beginTransaction();
 				$update_array = explode(";", $sql_update);
 				$update_array = explode(";", $sql_update);