Эх сурвалжийг харах

Enhance - Display text on app_defaults (#2645)

enable display_type on domains (and therefore app_defaults)
capture the output of app_defaults
format if statements to project preference
use more generic label display for results reducing number of translations required
change upgrade.php to use the more consistent $display_type
Mafoo 8 жил өмнө
parent
commit
ba6d3fc685

+ 19 - 39
core/upgrade/app_languages.php

@@ -600,25 +600,25 @@ $text['label-database']['ru-ru'] = "База данных";
 $text['label-database']['sv-se'] = "Databas";
 $text['label-database']['sv-se'] = "Databas";
 $text['label-database']['uk-ua'] = "База даних";
 $text['label-database']['uk-ua'] = "База даних";
 
 
-$text['header-upgrade_schema_results']['en-us'] = "Schema Results";
-$text['header-upgrade_schema_results']['ar-eg'] = "";
-$text['header-upgrade_schema_results']['de-at'] = "Schema Ergebnisse";
-$text['header-upgrade_schema_results']['de-ch'] = "";
-$text['header-upgrade_schema_results']['de-de'] = "Schema Ergebnisse";
-$text['header-upgrade_schema_results']['es-cl'] = "Resultados de Esquema";
-$text['header-upgrade_schema_results']['es-mx'] = "";
-$text['header-upgrade_schema_results']['fr-ca'] = "";
-$text['header-upgrade_schema_results']['fr-fr'] = "Résultats de Schéma";
-$text['header-upgrade_schema_results']['he-il'] = "";
-$text['header-upgrade_schema_results']['it-it'] = "Risultato Schema";
-$text['header-upgrade_schema_results']['nl-nl'] = "";
-$text['header-upgrade_schema_results']['pl-pl'] = "Wyniki schematu";
-$text['header-upgrade_schema_results']['pt-br'] = "Resultados do esquema";
-$text['header-upgrade_schema_results']['pt-pt'] = "Resultados de Esquema";
-$text['header-upgrade_schema_results']['ro-ro'] = "";
-$text['header-upgrade_schema_results']['ru-ru'] = "Результирующая структура БД";
-$text['header-upgrade_schema_results']['sv-se'] = "Schema Resultat";
-$text['header-upgrade_schema_results']['uk-ua'] = "Результати схем";
+$text['label-results']['en-us'] = "Results";
+$text['label-results']['ar-eg'] = "النتائج";
+$text['label-results']['de-at'] = "Ergebnisse";
+$text['label-results']['de-ch'] = "Ergebnisse";
+$text['label-results']['de-de'] = "Ergebnisse";
+$text['label-results']['es-cl'] = "Resultados";
+$text['label-results']['es-mx'] = "Resultados";
+$text['label-results']['fr-ca'] = "Résultats";
+$text['label-results']['fr-fr'] = "Résultats";
+$text['label-results']['he-il'] = "תוצאות";
+$text['label-results']['it-it'] = "Risultato";
+$text['label-results']['nl-nl'] = "resultaten";
+$text['label-results']['pl-pl'] = "Wyniki";
+$text['label-results']['pt-br'] = "Resultados";
+$text['label-results']['pt-pt'] = "Resultados";
+$text['label-results']['ro-ro'] = "Rezultate";
+$text['label-results']['ru-ru'] = "Результаты";
+$text['label-results']['sv-se'] = "Resultat";
+$text['label-results']['uk-ua'] = "результати";
 
 
 $text['header-upgrade']['en-us'] = "Upgrade";
 $text['header-upgrade']['en-us'] = "Upgrade";
 $text['header-upgrade']['ar-eg'] = "";
 $text['header-upgrade']['ar-eg'] = "";
@@ -640,26 +640,6 @@ $text['header-upgrade']['ru-ru'] = "Обновление";
 $text['header-upgrade']['sv-se'] = "Uppgradera";
 $text['header-upgrade']['sv-se'] = "Uppgradera";
 $text['header-upgrade']['uk-ua'] = "Оновлення";
 $text['header-upgrade']['uk-ua'] = "Оновлення";
 
 
-$text['header-source_update_results']['en-us'] = "Results";
-$text['header-source_update_results']['ar-eg'] = "";
-$text['header-source_update_results']['de-at'] = "Ergebnisse";
-$text['header-source_update_results']['de-ch'] = "";
-$text['header-source_update_results']['de-de'] = "Ergebnisse";
-$text['header-source_update_results']['es-cl'] = "Respuesta";
-$text['header-source_update_results']['es-mx'] = "";
-$text['header-source_update_results']['fr-ca'] = "";
-$text['header-source_update_results']['fr-fr'] = "Résultats";
-$text['header-source_update_results']['he-il'] = "";
-$text['header-source_update_results']['it-it'] = "Risultati";
-$text['header-source_update_results']['nl-nl'] = "";
-$text['header-source_update_results']['pl-pl'] = "Rezultat";
-$text['header-source_update_results']['pt-br'] = "Resposta";
-$text['header-source_update_results']['pt-pt'] = "Response";
-$text['header-source_update_results']['ro-ro'] = "";
-$text['header-source_update_results']['ru-ru'] = "Результаты";
-$text['header-source_update_results']['sv-se'] = "Resultat";
-$text['header-source_update_results']['uk-ua'] = "Результати";
-
 $text['header-database_type']['en-us'] = "Database Type";
 $text['header-database_type']['en-us'] = "Database Type";
 $text['header-database_type']['ar-eg'] = "";
 $text['header-database_type']['ar-eg'] = "";
 $text['header-database_type']['de-at'] = "Datenbank Typ";
 $text['header-database_type']['de-at'] = "Datenbank Typ";

+ 18 - 8
core/upgrade/index.php

@@ -63,7 +63,7 @@
 			exec("git pull 2>&1", $response_source_update);
 			exec("git pull 2>&1", $response_source_update);
 			$update_failed = true;
 			$update_failed = true;
 			if (sizeof($response_source_update) > 0) {
 			if (sizeof($response_source_update) > 0) {
-				$_SESSION["response"]["source"] = $response_source_update;
+				$_SESSION["response"]["upgrade_source"] = $response_source_update;
 				foreach ($response_source_update as $response_line) {
 				foreach ($response_source_update as $response_line) {
 					if (substr_count($response_line, "Updating ") > 0 || substr_count($response_line, "Already up-to-date.") > 0) {
 					if (substr_count($response_line, "Updating ") > 0 || substr_count($response_line, "Already up-to-date.") > 0) {
 						$update_failed = false;
 						$update_failed = false;
@@ -76,10 +76,12 @@
 				}
 				}
 			}
 			}
 			chdir($cwd);
 			chdir($cwd);
-			if ($update_failed)
+			if ($update_failed) {
 				messages::add($text['message-upgrade_source_failed'], 'negative', $message_timeout);
 				messages::add($text['message-upgrade_source_failed'], 'negative', $message_timeout);
-			else
+			}
+			else {
 				messages::add($text['message-upgrade_source'], null, $message_timeout);
 				messages::add($text['message-upgrade_source'], null, $message_timeout);
+			}
 		}
 		}
 
 
 		// load an array of the database schema and compare it with the active database
 		// load an array of the database schema and compare it with the active database
@@ -95,7 +97,14 @@
 		if ($do["apps"] && permission_exists("upgrade_apps")) {
 		if ($do["apps"] && permission_exists("upgrade_apps")) {
 			require_once "resources/classes/domains.php";
 			require_once "resources/classes/domains.php";
 			$domain = new domains;
 			$domain = new domains;
+			ob_start();
+			$domain->display_type = 'text';
 			$domain->upgrade();
 			$domain->upgrade();
+			$_SESSION["response"]["upgrade_apps"] = ob_get_flush();
+			if (strlen($_SESSION["response"]["upgrade_apps"]) == 0) {
+				$_SESSION["response"]["upgrade_apps"] = "No items updated or added";
+			}
+			$_SESSION["response"]["upgrade_apps"] = explode("\n", $_SESSION["response"]["upgrade_apps"]);
 			messages::add($text['message-upgrade_apps'], null, $message_timeout);
 			messages::add($text['message-upgrade_apps'], null, $message_timeout);
 		}
 		}
 
 
@@ -245,14 +254,15 @@
 
 
 	echo "<br /><br />";
 	echo "<br /><br />";
 	foreach($_SESSION["response"] as $part => $response){
 	foreach($_SESSION["response"] as $part => $response){
-		echo "<b>".$text["header-${part}_update_results"]."</b>";
+		echo "<b>". $text["label-results"]." - ".$text["label-${part}"]."</b>";
 		echo "<br /><br />";
 		echo "<br /><br />";
-		if(is_array($_SESSION["response"][$part])) {
+		if (is_array($response)) {
 			echo "<pre>";
 			echo "<pre>";
-			echo implode("\n", $_SESSION["response"][$part]);
+			echo implode("\n", $response);
 			echo "</pre>";
 			echo "</pre>";
-		}else {
-			echo $_SESSION["response"][$part];
+		}
+		else {
+			echo $response;
 		}
 		}
 		echo "<br /><br />";
 		echo "<br /><br />";
 	}
 	}

+ 7 - 6
core/upgrade/upgrade.php

@@ -32,7 +32,7 @@
 		set_include_path($document_root);
 		set_include_path($document_root);
 		require_once "resources/require.php";
 		require_once "resources/require.php";
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
-		$format = 'text'; //html, text
+		$display_type = 'text'; //html, text
 	}
 	}
 	else {
 	else {
 		include "root.php";
 		include "root.php";
@@ -45,7 +45,7 @@
 			echo "access denied";
 			echo "access denied";
 			exit;
 			exit;
 		}
 		}
-		$format = 'html';
+		$display_type = 'html';
 	}
 	}
 
 
 //add multi-lingual support
 //add multi-lingual support
@@ -54,7 +54,7 @@
 	$text = $language->get();
 	$text = $language->get();
 
 
 //show the title
 //show the title
-	if ($format == 'text') {
+	if ($display_type == 'text') {
 		echo "\n";
 		echo "\n";
 		echo $text['label-upgrade']."\n";
 		echo $text['label-upgrade']."\n";
 		echo "-----------------------------------------\n";
 		echo "-----------------------------------------\n";
@@ -70,10 +70,11 @@
 //run all app_defaults.php files
 //run all app_defaults.php files
 	require_once "resources/classes/domains.php";
 	require_once "resources/classes/domains.php";
 	$domain = new domains;
 	$domain = new domains;
+	$domain->display_type = $display_type;
 	$domain->upgrade();
 	$domain->upgrade();
 
 
 //show the content
 //show the content
-	if ($format == 'html') {
+	if ($display_type == 'html') {
 		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";
@@ -93,12 +94,12 @@
 		echo "<br />\n";
 		echo "<br />\n";
 		echo "<br />\n";
 		echo "<br />\n";
 	}
 	}
-	elseif ($format == 'text') {
+	elseif ($display_type == 'text') {
 		echo "\n";
 		echo "\n";
 	}
 	}
 
 
 //include the footer
 //include the footer
-	if ($format == "html") {
+	if ($display_type == "html") {
 		require_once "resources/footer.php";
 		require_once "resources/footer.php";
 	}
 	}
 
 

+ 2 - 0
resources/classes/domains.php

@@ -30,6 +30,7 @@ if (!class_exists('domains')) {
 
 
 		//define variables
 		//define variables
 		public $db;
 		public $db;
+		public $display_type;
 
 
 		//class constructor
 		//class constructor
 		public function __construct() {
 		public function __construct() {
@@ -344,6 +345,7 @@ if (!class_exists('domains')) {
 
 
 					//get the list of installed apps from the core and mod directories and execute the php code in app_defaults.php
 					//get the list of installed apps from the core and mod directories and execute the php code in app_defaults.php
 						$default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");
 						$default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");
+						$display_type = $this->display_type;
 						foreach ($default_list as &$default_path) {
 						foreach ($default_list as &$default_path) {
 							include($default_path);
 							include($default_path);
 						}
 						}