From 33b969a3b7dea1a28680e1506a76920fffe855eb Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 27 Apr 2015 08:43:46 -0400 Subject: [PATCH] Refactor duplicate code Signed-off-by: Marc Delisle --- libraries/structure.lib.php | 45 ++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php index 9a27836722..d290a14b93 100644 --- a/libraries/structure.lib.php +++ b/libraries/structure.lib.php @@ -634,38 +634,25 @@ function PMA_getHtmlForShowStats($tbl_url_query, $formatted_size, } /** - * Get HTML to show database structure creation, last update and last checkx time + * Get HTML to show either a database structure creation, last update or + * last check time * - * @param string $create_time create time - * @param string $update_time last update time - * @param string $check_time last check time + * @param string $one_time one of the times to show + * @param string $config_param the related configuration parameter + * @param string $class the class to generate * * @return string $html_output */ -function PMA_getHtmlForStructureTimes($create_time, $update_time, $check_time) +function PMA_getHtmlForStructureTime($one_time, $config_param, $class) { $html_output = ''; - if ($GLOBALS['cfg']['ShowDbStructureCreation']) { - $html_output .= '' - . ($create_time - ? PMA_Util::localisedDate(strtotime($create_time)) + if ($GLOBALS['cfg'][$config_param]) { + $html_output .= '' + . ($one_time + ? PMA_Util::localisedDate(strtotime($one_time)) : '-' ) . ''; } // end if - if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) { - $html_output .= '' - . ($update_time - ? PMA_Util::localisedDate(strtotime($update_time)) - : '-' ) - . ''; - } // end if - if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) { - $html_output .= '' - . ($check_time - ? PMA_Util::localisedDate(strtotime($check_time)) - : '-' ) - . ''; - } return $html_output; } @@ -766,9 +753,15 @@ function PMA_getHtmlForNotNullEngineViewTable($table_is_view, $current_table, ); } - $html_output .= PMA_getHtmlForStructureTimes( - $create_time, $update_time, $check_time - ); + $html_output .= PMA_getHtmlForStructureTime( + $create_time, 'ShowDbStructureCreation', 'tbl_creation' + ) + . PMA_getHtmlForStructureTime( + $update_time, 'ShowDbStructureLastUpdate', 'tbl_last_update' + ) + . PMA_getHtmlForStructureTime( + $check_time, 'ShowDbStructureLastCheck', 'tbl_last_check' + ); return array($html_output, $approx_rows); }