From 3754538e2cf0fbc17945485f0d4af9d3ec1dde0b Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Mon, 2 Jul 2012 19:37:06 +0300 Subject: [PATCH 1/3] Add neutral string for transformations in pma_column_info --- libraries/transformations.lib.php | 65 +++++++++++++++++++++++++++++-- transformation_wrapper.php | 8 ++-- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index ead6204c38..79a9c67e4c 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -178,12 +178,55 @@ function PMA_getMIME($db, $table, $strict = false) . PMA_backquote($cfgRelation['column_info']) . ' WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\' AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\' - AND ( `mimetype` != \'\'' . (!$strict ? ' + AND ( `mimetype` != \'\'' . (! $strict ? ' OR `transformation` != \'\' OR `transformation_options` != \'\'' : '') . ')'; - return PMA_DBI_fetch_result( + $result = PMA_DBI_fetch_result( $com_qry, 'column_name', null, $GLOBALS['controllink'] ); + + foreach ($result as $column => $values) { + // replacements in mimetype and transformation + $values = str_replace("jpeg", "JPEG", $values); + $values = str_replace("png", "PNG", $values); + $values = str_replace("octet-stream", "Octetstream", $values); + + // convert mimetype to new format (f.e. Text_Plain, etc) + $delimiter_space = '- '; + $delimiter = "_"; + $values['mimetype'] = str_replace( + $delimiter_space, + $delimiter, + ucwords( + str_replace( + $delimiter, + $delimiter_space, + $values['mimetype'] + ) + ) + ); + + // convert transformation to new format (class name) + // f.e. Text_Plain_Substring.class.php + $values = str_replace("__", "_", $values); + $values = str_replace(".inc.php", ".class.php", $values); + + $values['transformation'] = str_replace( + $delimiter_space, + $delimiter, + ucwords( + str_replace( + $delimiter, + $delimiter_space, + $values['transformation'] + ) + ) + ); + + $result[$column] = $values; + } + + return $result; } // end of the 'PMA_getMIME()' function /** @@ -211,7 +254,21 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, return false; } - $test_qry = ' + // convert mimetype to old format (f.e. text_plain) + $mimetype = strtolower($mimetype); + // old format has octet-stream instead of octetstream for mimetype + if (strstr($mimetype, "octetstream")) { + $mimetype = "application_octet-stream"; + } + + // convert transformation to old format (f.e. text_plain__substring.inc.php) + $transformation = strtolower($transformation); + $transformation = str_replace(".class.php", ".inc.php", $transformation); + $last_pos = strrpos($transformation, "_"); + $transformation = substr($transformation , 0, $last_pos) . "_" + . substr($transformation, $last_pos); + + $test_qry = ' SELECT `mimetype`, `comment` FROM ' . PMA_backquote($cfgRelation['db']) . '.' @@ -219,7 +276,7 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\' AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\' AND `column_name` = \'' . PMA_sqlAddSlashes($key) . '\''; - $test_rs = PMA_queryAsControlUser($test_qry, true, PMA_DBI_QUERY_STORE); + $test_rs = PMA_queryAsControlUser($test_qry, true, PMA_DBI_QUERY_STORE); if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { $row = @PMA_DBI_fetch_assoc($test_rs); diff --git a/transformation_wrapper.php b/transformation_wrapper.php index ab1625c234..cbaa80973e 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -53,18 +53,18 @@ if (isset($where_clause)) { null, PMA_DBI_QUERY_STORE ); - $row = PMA_DBI_fetch_assoc($result); + $row = PMA_DBI_fetch_assoc($result); } else { $result = PMA_DBI_query( 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE ); - $row = PMA_DBI_fetch_assoc($result); + $row = PMA_DBI_fetch_assoc($result); } // No row returned -if (!$row) { +if (! $row) { exit; } // end if (no record returned) @@ -89,7 +89,7 @@ $response = PMA_Response::getInstance(); $response->getHeader()->sendHttpHeaders(); // [MIME] -if (isset($ct) && !empty($ct)) { +if (isset($ct) && ! empty($ct)) { $mime_type = $ct; } else { $mime_type = (isset($mime_map[$transform_key]['mimetype']) From defb4d6d39c0c3f5776fbfa6b256633c84129537 Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Mon, 2 Jul 2012 22:53:50 +0300 Subject: [PATCH 2/3] fix missing include in PMA_Tracker class --- libraries/Tracker.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php index 94800feed6..0276d1e684 100644 --- a/libraries/Tracker.class.php +++ b/libraries/Tracker.class.php @@ -258,7 +258,7 @@ class PMA_Tracker static public function createVersion($dbname, $tablename, $version, $tracking_set = '', $is_view = false ) { - global $sql_backquotes; + global $sql_backquotes, $export_type; $common_functions = PMA_CommonFunctions::getInstance(); @@ -267,6 +267,7 @@ class PMA_Tracker } // get Export SQL instance + require_once "libraries/plugin_interface.lib.php"; $export_sql_plugin = PMA_getPlugin( "export", "sql", From f5989eb628613f5e7403bddd152fb3ec87884579 Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Mon, 2 Jul 2012 23:01:03 +0300 Subject: [PATCH 3/3] fix error from merge conflict in transformations --- libraries/transformations.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index c65beadeff..a653570d93 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -163,7 +163,6 @@ function PMA_getTransformationDescription($file, $html_formatted = true) */ function PMA_getMIME($db, $table, $strict = false) { - $common_functions = PMA_CommonFunctions::getInstance(); $cfgRelation = PMA_getRelationsParam(); @@ -183,7 +182,7 @@ function PMA_getMIME($db, $table, $strict = false) AND ( `mimetype` != \'\'' . (!$strict ? ' OR `transformation` != \'\' OR `transformation_options` != \'\'' : '') . ')'; - return PMA_DBI_fetch_result( + $result = PMA_DBI_fetch_result( $com_qry, 'column_name', null, $GLOBALS['controllink'] );