Skip to content

Commit

Permalink
Enhance - Display text on app_defaults (fusionpbx#2645)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mafoo authored and markjcrane committed Jun 8, 2017
1 parent b7f4cba commit 2c97ce1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 53 deletions.
58 changes: 19 additions & 39 deletions core/upgrade/app_languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,25 +600,25 @@
$text['label-database']['sv-se'] = "Databas";
$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']['ar-eg'] = "";
Expand All @@ -640,26 +640,6 @@
$text['header-upgrade']['sv-se'] = "Uppgradera";
$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']['ar-eg'] = "";
$text['header-database_type']['de-at'] = "Datenbank Typ";
Expand Down
26 changes: 18 additions & 8 deletions core/upgrade/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
exec("git pull 2>&1", $response_source_update);
$update_failed = true;
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) {
if (substr_count($response_line, "Updating ") > 0 || substr_count($response_line, "Already up-to-date.") > 0) {
$update_failed = false;
Expand All @@ -76,10 +76,12 @@
}
}
chdir($cwd);
if ($update_failed)
if ($update_failed) {
messages::add($text['message-upgrade_source_failed'], 'negative', $message_timeout);
else
}
else {
messages::add($text['message-upgrade_source'], null, $message_timeout);
}
}

// load an array of the database schema and compare it with the active database
Expand All @@ -95,7 +97,14 @@
if ($do["apps"] && permission_exists("upgrade_apps")) {
require_once "resources/classes/domains.php";
$domain = new domains;
ob_start();
$domain->display_type = 'text';
$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);
}

Expand Down Expand Up @@ -245,14 +254,15 @@

echo "<br /><br />";
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 />";
if(is_array($_SESSION["response"][$part])) {
if (is_array($response)) {
echo "<pre>";
echo implode("\n", $_SESSION["response"][$part]);
echo implode("\n", $response);
echo "</pre>";
}else {
echo $_SESSION["response"][$part];
}
else {
echo $response;
}
echo "<br /><br />";
}
Expand Down
13 changes: 7 additions & 6 deletions core/upgrade/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
set_include_path($document_root);
require_once "resources/require.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$format = 'text'; //html, text
$display_type = 'text'; //html, text
}
else {
include "root.php";
Expand All @@ -45,7 +45,7 @@
echo "access denied";
exit;
}
$format = 'html';
$display_type = 'html';
}

//add multi-lingual support
Expand All @@ -54,7 +54,7 @@
$text = $language->get();

//show the title
if ($format == 'text') {
if ($display_type == 'text') {
echo "\n";
echo $text['label-upgrade']."\n";
echo "-----------------------------------------\n";
Expand All @@ -70,10 +70,11 @@
//run all app_defaults.php files
require_once "resources/classes/domains.php";
$domain = new domains;
$domain->display_type = $display_type;
$domain->upgrade();

//show the content
if ($format == 'html') {
if ($display_type == 'html') {
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
Expand All @@ -93,12 +94,12 @@
echo "<br />\n";
echo "<br />\n";
}
elseif ($format == 'text') {
elseif ($display_type == 'text') {
echo "\n";
}

//include the footer
if ($format == "html") {
if ($display_type == "html") {
require_once "resources/footer.php";
}

Expand Down
2 changes: 2 additions & 0 deletions resources/classes/domains.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class domains {

//define variables
public $db;
public $display_type;

//class constructor
public function __construct() {
Expand Down Expand Up @@ -344,6 +345,7 @@ public function upgrade() {

//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");
$display_type = $this->display_type;
foreach ($default_list as &$default_path) {
include($default_path);
}
Expand Down

0 comments on commit 2c97ce1

Please sign in to comment.