From: Roland Häder Date: Mon, 22 Dec 2008 12:56:50 +0000 (+0000) Subject: Extension notes and verbose SQL table rewritten to templates. Resolved #13 X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c5502e4040f7946d4d6e42434efc3dc03c7b73d1;p=mailer.git Extension notes and verbose SQL table rewritten to templates. Resolved #13 --- diff --git a/.gitattributes b/.gitattributes index a5f1534345..c0c87f725c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -955,7 +955,10 @@ templates/de/html/admin/admin_edit_user.tpl -text templates/de/html/admin/admin_email_archiv.tpl -text templates/de/html/admin/admin_email_archiv_row.tpl -text templates/de/html/admin/admin_email_nav_row.tpl -text +templates/de/html/admin/admin_ext_notes.tpl -text templates/de/html/admin/admin_ext_reg_form.tpl -text +templates/de/html/admin/admin_ext_sql_row.tpl -text +templates/de/html/admin/admin_ext_sql_table.tpl -text templates/de/html/admin/admin_extensions.tpl -text templates/de/html/admin/admin_extensions_404.tpl -text templates/de/html/admin/admin_extensions_delete.tpl -text diff --git a/inc/databases.php b/inc/databases.php index b1de13831d..50d4e691e9 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -115,7 +115,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "692"); +define('CURR_SVN_REVISION', "693"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/extensions.php b/inc/extensions.php index 5abc6756d5..a59e17b086 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -152,20 +152,8 @@ function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run = false, $logout = tr // Load extension in update mode LOAD_EXTENSION($ext_name, "update", $ver, $dry_run, $SQLs); - // Do we have an update? - if (((GET_EXT_VERSION("sql_patches") != "") && (getConfig('verbose_sql') == "Y")) || (!EXT_IS_ACTIVE("sql_patches"))) { - if (!empty($UPDATE_NOTES)) { - // Update notes found - $NOTES .= ("
v".$ver.":
".$UPDATE_NOTES."
"); - $UPDATE_NOTES = ""; - } elseif (($ver == "0.0") || ($ver == "0.0.0")) { - // Initial release - $NOTES .= ("
v".$ver.":
".INITIAL_RELEASE."
"); - } else { - // No update notes found! - $NOTES .= ("
v".$ver.":
".NO_UPDATE_NOTES."
"); - } - } // END - if + // Add update notes to our output + $NOTES .= ADD_EXTENSION_NOTES($ver, $UPDATE_NOTES); } // END - foreach // Does this extension depends on an outstanding update of another update? @@ -424,6 +412,9 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) { // Init arrays $SQLs = array(); $INC_POOL = array(); + // Init notes + $NOTES = ""; + // Only admins are allowed to update extensions if ((!IS_ADMIN()) || (empty($ext_name))) return false; @@ -440,7 +431,6 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) { if ((($EXT_VERSION != $ext_ver) || ($dry_run)) && (is_array($history))) { // Search for starting point $start = array_search($ext_ver, $history); - $NOTES = ""; // And load SQL queries in order of version history for ($idx = ($start + 1); $idx < sizeof($history); $idx++) { @@ -469,18 +459,7 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) { } // END - if // Add notes - if (getConfig('verbose_sql') == "Y") { - if (!empty($UPDATE_NOTES)) { - // Update notes found - $NOTES .= ("
v".$cacheArray['update_ver'][$ext_name].":
".$UPDATE_NOTES."
"); - $UPDATE_NOTES = ""; - } elseif ($cacheArray['update_ver'][$ext_name] == "0.0") { - // Initial release - $NOTES .= ("
v".$cacheArray['update_ver'][$ext_name].":
".INITIAL_RELEASE."
"); - } else { - $NOTES .= ("
v".$cacheArray['update_ver'][$ext_name].":
".NO_UPDATE_NOTES."
"); - } - } // END - if + $NOTES .= ADD_EXTENSION_NOTES($cacheArray['update_ver'][$ext_name], $UPDATE_NOTES); } // END - for // In real-mode execute any existing includes @@ -526,48 +505,47 @@ function EXTENSION_VERBOSE_TABLE ($queries = array(), $title = ADMIN_SQLS_EXECUT } // END - if // Init variables - $S = false; $SW = 2; $i = 1; + $SW = 2; $i = 1; $OUT = ""; // Do we have queries? if ((is_array($SQLs)) && (GET_EXT_VERSION("sql_patches") >= "0.0.7") && (getConfig('verbose_sql') == "Y")) { - $OUT = "
- - - -\n"; foreach ($SQLs as $idx => $sql) { + // Trim out spaces $sql = trim($sql); + + // Output command if set if (!empty($sql)) { - $S = true; - $OUT .= " - - -\n"; - if ($switch) $SW = 3 - $SW; + // Prepare output for template + $content = array( + 'sw' => $SW, + 'i' => $i, + 'sql' => $sql + ); + + // Load row template + $OUT .= LOAD_TEMPLATE("admin_ext_sql_row", true, $content); + + // Switch color and count up + $SW = 3 - $SW; $i++; - } - } - } + } // END - if + } // END - foreach - if ((!$S) && (GET_EXT_VERSION("sql_patches") >= "0.0.7") && (getConfig('verbose_sql') == "Y")) { - // No addional SQL commands to run - $OUT .= " - -\n"; - } + // Prepare content for template + $content = array( + 'width' => $width, + 'dashed' => $dashed, + 'title' => $title, + 'out' => $OUT + ); - if (!empty($OUT)) { - // Add missing close-table tag - $OUT .= "
- ".$title.": -
".$i.". - ".$sql." -
- ".ADMIN_NO_ADDIONAL_SQLS." -
-
\n"; - } + // Load main template + $OUT = LOAD_TEMPLATE("admin_ext_sql_table", true, $content); + } elseif ((GET_EXT_VERSION("sql_patches") >= "0.0.7") && (getConfig('verbose_sql') == "Y")) { + // No addional SQL commands to run + $OUT = LOAD_TEMPLATE("admin_settings_saved", true, ADMIN_NO_ADDITIONAL_SQLS); + } // END - if // Return output return $OUT; @@ -826,5 +804,43 @@ function DETERMINE_TASK_ID_BY_SUBJECT ($subject) { return $task_id; } +// Add updates notes for given version +function ADD_EXTENSION_NOTES ($ver, &$UPDATE_NOTES) { + // Init notes/content + $out = ""; $content = array(); + + // Is do we have verbose output enabled? + if ((getConfig('verbose_sql') == "Y") || (!EXT_IS_ACTIVE("sql_patches"))) { + + // Update notes found? + if (!empty($UPDATE_NOTES)) { + // Update notes found + $content = array( + 'ver' => $ver, + 'notes' => $UPDATE_NOTES + ); + $UPDATE_NOTES = ""; + } elseif (($ver == "0.0") || ($ver == "0.0.0")) { + // Initial release + $content = array( + 'ver' => $ver, + 'notes' => INITIAL_RELEASE + ); + } else { + // No update notes found! + $content = array( + 'ver' => $ver, + 'notes' => NO_UPDATE_NOTES + ); + } + + // Load template + $out = LOAD_TEMPLATE("admin_ext_notes", true, $content); + } // END - if + + // Return the output + return $out; +} + // ?> diff --git a/templates/de/html/admin/admin_ext_notes.tpl b/templates/de/html/admin/admin_ext_notes.tpl new file mode 100644 index 0000000000..ca76eba979 --- /dev/null +++ b/templates/de/html/admin/admin_ext_notes.tpl @@ -0,0 +1,4 @@ +
+ v$content[ver]:
+ $content[notes] +
diff --git a/templates/de/html/admin/admin_ext_sql_row.tpl b/templates/de/html/admin/admin_ext_sql_row.tpl new file mode 100644 index 0000000000..5536c6a7ac --- /dev/null +++ b/templates/de/html/admin/admin_ext_sql_row.tpl @@ -0,0 +1,6 @@ + + $content[i]. + + $content[sql] + + diff --git a/templates/de/html/admin/admin_ext_sql_table.tpl b/templates/de/html/admin/admin_ext_sql_table.tpl new file mode 100644 index 0000000000..9634e11aec --- /dev/null +++ b/templates/de/html/admin/admin_ext_sql_table.tpl @@ -0,0 +1,10 @@ +
+ + + + +$content[out] +
+ $content[title]: +
+
diff --git a/templates/de/html/admin/admin_extensions_text.tpl b/templates/de/html/admin/admin_extensions_text.tpl index db42929e31..a80a751559 100644 --- a/templates/de/html/admin/admin_extensions_text.tpl +++ b/templates/de/html/admin/admin_extensions_text.tpl @@ -1,13 +1,13 @@ - - - - - - - - - - -
 
$content -
 
+ + + + + + + + + + +
 
+ $content +