Merge pull request #77 from alexukf/plugins-and-OOP
Transformations bugs
This commit is contained in:
commit
837d76baf6
@ -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",
|
||||
|
||||
@ -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,9 +182,52 @@ 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']
|
||||
);
|
||||
|
||||
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
|
||||
|
||||
/**
|
||||
@ -215,7 +257,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 ' . $common_functions->backquote($cfgRelation['db']) . '.'
|
||||
|
||||
@ -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_CommonFunctions::getInstance()->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'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user