From 31e67a334d2f533b2b85d40469e3b5281275f381 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Fri, 10 Jan 2014 22:24:51 +0100 Subject: [PATCH] Reduce complexity of PMA_getHtmlForTrackingReport(). Signed-off-by: Hugues Peccatte --- libraries/tbl_tracking.lib.php | 173 ++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 48 deletions(-) diff --git a/libraries/tbl_tracking.lib.php b/libraries/tbl_tracking.lib.php index 2bc42ce60f..6467ea630a 100644 --- a/libraries/tbl_tracking.lib.php +++ b/libraries/tbl_tracking.lib.php @@ -357,37 +357,8 @@ function PMA_getHtmlForTrackingReport($url_query, $data, $url_params, . htmlspecialchars($data['tracking']) . '
'; $html .= '
'; - $html .= '
'; - - $str1 = ''; - $str2 = ''; - $str3 = ''; - $str4 = ''; - $str5 = '' - . ''; - - $html .= sprintf( - __('Show %1$s with dates from %2$s to %3$s by user %4$s %5$s'), - $str1, $str2, $str3, $str4, $str5 + list($str1, $str2, $str3, $str4, $str5) = PMA_getHtmlForElementsOfTrackingReport( + $selection_schema, $selection_data, $selection_both ); // Prepare delete link content here @@ -409,7 +380,94 @@ function PMA_getHtmlForTrackingReport($url_query, $data, $url_params, $msg->display(); } - if ($selection_schema || $selection_both && count($data['ddlog']) > 0) { + $html .= PMA_getHtmlForTrackingReportExportForm1( + $data, $url_params, $selection_schema, $selection_data, $selection_both, + $filter_ts_to, $filter_ts_from, $filter_users, $str1, $str2, $str3, + $str4, $str5, $drop_image_or_text + ); + + $html .= PMA_getHtmlForTrackingReportExportForm2( + $url_params, $str1, $str2, $str3, $str4, $str5 + ); + + $html .= "



\n"; + + return $html; +} + +/** + * Generate HTML element for report form + * + * @param boolean $selection_schema selection schema + * @param boolean $selection_data selection data + * @param boolean $selection_both selection both + * + * @return array + */ +function PMA_getHtmlForElementsOfTrackingReport( + $selection_schema, $selection_data, $selection_both +) { + $str1 = ''; + $str2 = ''; + $str3 = ''; + $str4 = ''; + $str5 = '' + . ''; + return array($str1, $str2, $str3, $str4, $str5); +} + +/** + * Generate HTML for export form + * + * @param array $data data + * @param array $url_params url params + * @param boolean $selection_schema selection schema + * @param boolean $selection_data selection data + * @param boolean $selection_both selection both + * @param int $filter_ts_to filter time stamp from + * @param int $filter_ts_from filter time stamp tp + * @param array $filter_users filter users + * @param string $str1 HTML for logtype select + * @param string $str2 HTML for "from date" + * @param string $str3 HTML for "to date" + * @param string $str4 HTML for user + * @param string $str5 HTML for "list report" + * @param string $drop_image_or_text HTML for image or text + * + * @return string HTML for form + */ +function PMA_getHtmlForTrackingReportExportForm1( + $data, $url_params, $selection_schema, $selection_data, $selection_both, + $filter_ts_to, $filter_ts_from, $filter_users, $str1, $str2, $str3, + $str4, $str5, $drop_image_or_text +) { + $html = ''; + + $html .= sprintf( + __('Show %1$s with dates from %2$s to %3$s by user %4$s %5$s'), + $str1, $str2, $str3, $str4, $str5 + ); + + if ($selection_schema || $selection_both && count($data['ddlog']) > 0) { list($temp, $ddlog_count) = PMA_getHtmlForDataDefinitionStatements( $data, $filter_users, $filter_ts_from, $filter_ts_to, $url_params, $drop_image_or_text @@ -428,7 +486,25 @@ function PMA_getHtmlForTrackingReport($url_query, $data, $url_params, ); } $html .= '
'; - $html .= '
'true', 'version' => $_REQUEST['version'] @@ -439,20 +515,8 @@ function PMA_getHtmlForTrackingReport($url_query, $data, $url_params, __('Show %1$s with dates from %2$s to %3$s by user %4$s %5$s'), $str1, $str2, $str3, $str4, $str5 ); - - $str_export1 = ''; - - $str_export2 = '' - . ''; $html .= '
'; + $html .= '
'; $html .= ''; + + $str_export1 = ''; + + $str_export2 = '' + . ''; + $html .= "
" . sprintf(__('Export as %s'), $str_export1) . $str_export2 . "
"; $html .= '
'; - $html .= "



\n"; - return $html; } + /** * Function to get html for data manipulation statements *