diff --git a/ChangeLog b/ChangeLog index 2ce78fe94..cda6ad575 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,56 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-02-24 Garvin Hicking + Submitted multiple patches from the patch tracker: + + * JS rowmarker now works in vertical display mode + Files: libraries/functions.js, display_tbl.lib.php3 + + * Display nav_bar even when only one row is returned, to enable display in + vertical/horizontal mode (especially for rotated headers) + Files: libraries/display_tbl.lib.php3 + + * Measures basic query time [#571934] + Files: sql.php3, display_tbl.lib.php3 + + * New display mode with 90 degree rotated table headers [#544361]. Works + either as CSS or as 'faked' PHP-transformation. + Files: libraries/common.lib.php3, libraries/display_tbl.lib.php3 + + * Update and display column comments in Add/Edit Fieldmode and CREATE table + mode. Display comments in table structure (optional) with underlined + CSS-mouseovers. Display comments in browser mode (optional), both in + vertical and horizontal display mode. Keep column comments in synch, when + DROPping/ALTERing and moving/copying tables. + Files: tbl_addfield.php3, tbl_alter.php3, tbl_create.php3, + tbl_properties.inc.php3, tbl_properties_structure.php3, db_details_links, + tbl_relation.php3,tbl_move_copy.php3, tbl_properties_links.php3, + tbl_rename.php3, sql.php3, db_details_structure.php3, db_details_links.php3, + libraries/relation.lib.php3 + + * Display and enter DB/table comments for navigation, stored in pma comments table. + May be displayed as Alias-Tooltips in left frame. [#650064] + Files: db_details_structure.php3, left.php3, relation.lib.php3 + + * Display column comments in table/database dumps, as inline SQL-Comments + Files: tbl_dump.php3, tbl_properties_export.php3, build_dump.lib.php3 + + * Display MIME types to transform any table cell. You can only choose from a + list of pre-defined MIME-types. The list gets built by a function searching + a directory for valid transforms. For further information see README-file and soon + documentation. ;) + Files: tbl_properties.inc.php3, transformations.lib.php3, relation.lib.php3, + create_tables.sql, tbl_addfield.php3, tbl_alter.php3, tbl_create.php3, + tbl_move_copy.php3, transformation_wrapper.php3, + libraries/display_tbl.lib.php3, libraries/transformations/* + TODO: Add predefined functions! + + * IN PROGRESS: Display a (javascript) based query window as a new frame below the left + frame with query history [#526008] + Files: queryframe.php3, querywindow.php3, header.inc.php3, + tbl_query_box.php3, common.lib.php3 + 2003-02-24 Olivier L. Müller * libraries/common.lib.php3: if $cfg['PmaAbsoluteUri'] is empty and port == 80 or port == 443, do not add ":80" or ":443" anymore to the diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index c3f231fea..0e16af25f 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -527,6 +527,12 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { $comments_map = array(); } + if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfg']['BrowseMIME']) { + require('./libraries/transformations.lib.php3'); + $GLOBALS['mime_map'] = PMA_getMIME($db, $table); + } + + if ($is_display['sort_lnk'] == '1') { $is_join = eregi('(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN', $sql_query, $select_stt); } else { @@ -990,6 +996,40 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { // available or not $pointer = (function_exists('is_null') ? $i : $meta->name); + // garvin: Wrap MIME-transformations. [MIME] + $default_function = 'htmlspecialchars'; // default_function + $transform_function = $default_function; + $transform_options = array(); + + if ($GLOBALS['cfg']['BrowseMIME']) { + + if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation'])) { + // garvin: for security, never allow to break out from transformations directory + $include_file = eregi_replace('^[\./]*(.*)', '\1', $GLOBALS['mime_map'][$meta->name]['transformation']); + + $transformfunction_name = str_replace('.inc.php3', '', $GLOBALS['mime_map'][$meta->name]['transformation']); + + include('./libraries/transformations/' . $include_file); + + if (defined('PMA_TRANSFORMATION_' . strtoupper($transformfunction_name)) && function_exists('PMA_transformation_' . $transformfunction_name)) { + + $transform_function = 'PMA_transformation_' . $transformfunction_name; + $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : '')); + + } + + } + + } + + $transform_options['wrapper_link'] = '?' + . $url_query + . '&primary_key=' . $uva_condition + . '&sql_query=' . urlencode($sql_query) + . '&goto=' . urlencode($lnk_goto) + . '&transform_key=' . urlencode($meta->name); + + // n u m e r i c if ($meta->numeric == 1) { @@ -1045,9 +1085,9 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { . PMA_generate_common_url($db, $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$pointer]) . '"' . $title . '>' - . $row[$pointer] . ''; + . ($transform_function != $default_function ? $transform_function($row[$pointer], $transform_options) : $transform_function($row[$pointer])) . ''; } else { - $vertical_display['data'][$row_no][$i] .= $row[$pointer]; + $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$pointer], $transform_options) : $transform_function($row[$pointer])); } $vertical_display['data'][$row_no][$i] .= '' . "\n"; } else { @@ -1062,28 +1102,36 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { // even if $cfg['ShowBlob'] is false -> get the true type // of the fields. $field_flags = PMA_mysql_field_flags($dt_result, $i); + if (eregi('BINARY', $field_flags)) { - $vertical_display['data'][$row_no][$i] = ' [BLOB'; + $blobtext = '[BLOB'; if (isset($row[$pointer])) { $blob_size = PMA_formatByteDown(strlen($row[$pointer]), 3, 1); - $vertical_display['data'][$row_no][$i] .= ' - '. $blob_size [0] . ' ' . $blob_size[1]; + $blobtext .= ' - '. $blob_size [0] . ' ' . $blob_size[1]; unset($blob_size); } - $vertical_display['data'][$row_no][$i] .= ']' . "\n"; + + $blobtext .= ']'; + $blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options) : $default_function($blobtext)); + + $vertical_display['data'][$row_no][$i] = ' ' . $blobtext . ''; } else { //if (!isset($row[$meta->name]) if (!isset($row[$pointer]) || (function_exists('is_null') && is_null($row[$pointer]))) { $vertical_display['data'][$row_no][$i] = ' NULL' . "\n"; } else if ($row[$pointer] != '') { + // garvin: if a transform function for blob is set, none of these replacements will be made if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) { $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays all space characters, 4 space // characters for tabulations and / - $row[$pointer] = htmlspecialchars($row[$pointer]); + + $row[$pointer] = ($default_function != $transform_function ? $transform_function('BLOB', $transform_options) : $default_function($row[$pointer])); $row[$pointer] = str_replace("\011", '    ', str_replace(' ', '  ', $row[$pointer])); $row[$pointer] = ereg_replace("((\015\012)|(\015)|(\012))", '
', $row[$pointer]); + $vertical_display['data'][$row_no][$i] = ' ' . $row[$pointer] . '' . "\n"; } else { $vertical_display['data'][$row_no][$i] = '  ' . "\n"; @@ -1112,15 +1160,16 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { $row[$pointer] = str_replace("\x0a", '\n', $row[$pointer]); $row[$pointer] = str_replace("\x0d", '\r', $row[$pointer]); $row[$pointer] = str_replace("\x1a", '\Z', $row[$pointer]); - $row[$pointer] = htmlspecialchars($row[$pointer]); + $row[$pointer] = ($default_function != $transform_function ? $transform_function('BLOB', $transform_options) : $default_function($row[$pointer])); } // loic1: displays all space characters, 4 space // characters for tabulations and / else { - $row[$pointer] = htmlspecialchars($row[$pointer]); + $row[$pointer] = ($default_function != $transform_function ? $transform_function('BLOB', $transform_options) : $default_function($row[$pointer])); $row[$pointer] = str_replace("\011", '    ', str_replace(' ', '  ', $row[$pointer])); $row[$pointer] = ereg_replace("((\015\012)|(\015)|(\012))", '
', $row[$pointer]); } + // loic1: do not wrap if date field type $nowrap = (eregi('DATE|TIME', $meta->type) ? ' nowrap="nowrap"' : ''); $vertical_display['data'][$row_no][$i] = ' '; diff --git a/libraries/transformations.lib.php3 b/libraries/transformations.lib.php3 new file mode 100644 index 000000000..10a4453f3 --- /dev/null +++ b/libraries/transformations.lib.php3 @@ -0,0 +1,182 @@ + $string); + } + } + + return $transform_options; + } + + /** + * Gets all available MIME-types + * + * @return array array[mimetype], array[transformation] + * + * @access public + * + * @author Garvin Hicking + */ + function PMA_getAvailableMIMEtypes() { + $handle = opendir('./libraries/transformations'); + + $stack = array(); + $filestack = array(); + + while (($file = readdir($handle)) != false) { + $filestack[$file] = $file; + } + + closedir($handle); + + if (is_array($filestack)) { + @ksort($filestack); + @reset($filestack); + while(list($key, $file) = each($filestack)) { + + if (eregi('^.*__.*\.inc\.php3$', trim($file))) { + // File contains transformation functions. + $base = explode("__", str_replace(".inc.php3", "", $file)); + + $mimetype = str_replace("_", "/", $base[0]); + $stack['mimetype'][$mimetype] = $mimetype; + + $stack['transformation'][] = $mimetype . ': ' . $base[1]; + $stack['transformation_file'][] = $file; + + } else if (eregi('^.*\.inc\.php3$', trim($file))) { + // File is a plain mimetype, no functions. + $base = str_replace(".inc.php3", "", $file); + + if ($base != 'global') { + $mimetype = str_replace("_", "/", $base); + $stack['mimetype'][$mimetype] = $mimetype; + $stack['empty_mimetype'][$mimetype] = $mimetype; + } + } + + } + } + + return $stack; + } + + /** + * Gets the mimetypes for all rows of a table + * + * @param string the name of the db to check for + * @param string the name of the table to check for + * @param string whether to include only results having a mimetype set + * + * @return array [field_name][field_key] = field_value + * + * @global array the list of relations settings + * + * @access public + * + * @author Mike Beck / Garvin Hicking + */ + function PMA_getMIME($db, $table, $strict = false) { + global $cfgRelation; + + $com_qry = 'SELECT column_name, mimetype, transformation, transformation_options FROM ' . PMA_backquote($cfgRelation['column_comments']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND (mimetype != \'\'' . (!$strict ? ' OR transformation != \'\' OR transformation_options != \'\'' : '') . ')'; + $com_rs = PMA_query_as_cu($com_qry); + + while ($row = @PMA_mysql_fetch_array($com_rs)) { + $col = $row['column_name']; + $mime[$col]['mimetype'] = $row['mimetype']; + $mime[$col]['transformation'] = $row['transformation']; + $mime[$col]['transformation_options'] = $row['transformation_options']; + } // end while + + if (isset($mime) && is_array($mime)) { + return $mime; + } else { + return FALSE; + } + } // end of the 'PMA_getMIME()' function + + /** + * Set a single mimetype to a certain value. + * + * @param string the name of the db + * @param string the name of the table + * @param string the name of the column + * @param string the mimetype of the column + * @param string the transformation of the column + * @param string the transformation options of the column + * @param string (optional) force delete, will erase any existing comments for this column + * + * @return boolean true, if comment-query was made. + * + * @global array the list of relations settings + * + * @access public + */ + function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false) { + global $cfgRelation; + + $test_qry = 'SELECT mimetype, ' . PMA_backquote('comment') . ' FROM ' . PMA_backquote($cfgRelation['column_comments']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND column_name = \'' . PMA_handleSlashes($key) . '\''; + $test_rs = PMA_query_as_cu($test_qry); + + if ($test_rs && mysql_num_rows($test_rs) > 0) { + $row = @PMA_mysql_fetch_array($test_rs); + + if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) { + $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_comments']) + . ' SET mimetype = \'' . PMA_handleSlashes($mimetype) . '\',' + . ' transformation = \'' . PMA_handleSlashes($transformation) . '\',' + . ' transformation_options = \'' . PMA_handleSlashes($transformation_options) . '\'' + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND column_name = \'' . PMA_handleSlashes($key) . '\''; + } else { + $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND column_name = \'' . PMA_handleSlashes($key) . '\''; + } + } else if (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) { + $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments']) + . ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) ' + . ' VALUES(' + . '\'' . PMA_sqlAddslashes($db) . '\',' + . '\'' . PMA_sqlAddslashes($table) . '\',' + . '\'' . PMA_handleSlashes($key) . '\',' + . '\'' . PMA_handleSlashes($mimetype) . '\',' + . '\'' . PMA_handleSlashes($transformation) . '\',' + . '\'' . PMA_handleSlashes($transformation_options) . '\')'; + } + + if (isset($upd_query)){ + $upd_rs = PMA_query_as_cu($upd_query); + unset($upd_query); + return true; + } else { + return false; + } + } // end of 'PMA_setMIME()' function +} // $__PMA_TRANSFORMATION_LIB__ +?> diff --git a/libraries/transformations/README b/libraries/transformations/README new file mode 100644 index 000000000..6c3a6a1ce --- /dev/null +++ b/libraries/transformations/README @@ -0,0 +1,187 @@ +TRANSFORMATION USAGE (Garvin Hicking, ) +==================== + +1. What are transformations? +---------------------------- + +You can apply different transformations to the contents of each field. The transformation will take the content +of each field and transform it with certain rules defined in the selected transformation. + +Say you have a field 'filename' which contains a filename. Normale you would see in phpMyAdmin only this filename. +Using transformations you can transform that filename into a html link, so you can click inside of the phpMyAdmin +structure on the field's link and will see the file displayed in a new browser window. Using transformation +options you can also specify strings to append/prepend to a string or the format you want the output stored in. + +For a general overview of all available transformations and their options, you can consult your + +http:///libraries/transformations/overview.php + + +2. How to use transformations +----------------------------- + +Go to your tbl_properties.inc.php3 page (like reached through clicking on the 'properties' link for a table). +There you will see three new fields at the end of the line. They are called 'MIME-type', 'Browser transformation' +and 'Transformation options'. + + +* The field 'MIME-type' is a dropdown field. You have the options to leave that field empty or to use +'auto' [this feature is not yet available]. Please note that transformations are inactive as long as no +mimetype is selected. + + +* The field 'Browser transformation' is a dropdown field. You can choose from a hopefully growing amount +of pre-defined transformations. See below for information how to build your own transformation. + +There are global transformations and mimetype-bound transformations. Global transformations can be used +for any mimetype. They will take the mimetype, if neccessary, into regard. Mimetype-bound transformations +usually only operate on a certain mimetype. There are transformations which operate on the main mimetype +(like 'image'), which will most likely take the subtype into regard, and those who only operate on a +specific subtype (like 'image/jpeg'). + +You can use transformations on mimetypes for which the function was not defined for. There is no security +check for you selected the right transformation, so take care of what the output will be like. + +* The field 'Transformation options' is a free-type textfield. You have to enter transform-function specific +options here. Usually the transforms can operate with default options, but it is generally a good idea +to look up the overview to see which options are neccessary. + +Much like the ENUM/SET-Fields, you have to split up several options using the format 'a','b','c',... +(NOTE THE MISSING BLANKS). This is because internally the options will be parsed as an array, leaving +the first value the first element in the array, and so forth. + +If you want to specify a MIME charset you can define it in the transformation_options. You have to +put that outside of the pre-defined options of the specific mime-transform, as the last value of +the set. Use the format "'; charset=XXX'". If you use a transform, for which you can specify 2 +options and you want to append a charset, enter "'first parameter','second parameter','charset=us-ascii'". +You can, however use the defaults for the parameters: "'','','charset=us-ascii'". + +3. Basic file structure +------------------------ + +All mimetypes and their transformations are defined through single files in the directory +'libraries/transformations/'. + +They are stored in files to ease up customization and easy adding of new transformations. + +Because the user cannot enter own mimetypes, it is kept sure that transformations always work. It makes +no sense to apply a transformation to a mimetype, the transform-function doesn't know to handle. + +One can, however, use empty mime-types and global transformations which should work for many mimetypes. +You can also use transforms on a different mimetype they where built for, but pay attention to option +usage as well as what the transformation does to your field. + +All transformation functions are kept in the directory 'libraries/transformations'. + +There is a basic file called 'global.inc.php3'. This function can be included by any other transform +function and provides some basic functions. + +There are X possible file names: + +3.1 + A mimetype+subtype transform: + + ___.inc.php3 + + Please not that mimetype and subtype are seperated via '_', which shall not be contained in their names. + The transform function/filename may contain only characters which cause no problems in the file system as well + as the PHP function naming convention. + + The transform function will the be called 'PMA_transform____()'. + + Example: + + text_html__formatted.inc.php3 + PMA_transform_text_html__formatted() + +3.2 + A mimetype (w/o subtype) transform: + + __.inc.php3 + + Please note that there are no single '_' characters. + The transform function/filename may contain only characters which cause no problems in the file system as well + as the PHP function naming convention. + + The transform function will the be called 'PMA_transform___()'. + + Example: + + text__formatted.inc.php3 + PMA_transform_text__formatted() + +3.3 + A mimetype+subtype without specific transform function + + _.inc.php3 + + Please note that there are no '__' characters in the filename. Do not use special characters in the filename + causing problems with the file system. + + No transformation function is defined in the file itself. + + Example: + + text_plain.inc.php3 + (No function) + +3.4 + A mimetype (w/o subtype) without specific transform function + + .inc.php3 + + Please note that there are no '_' characters in the filename. Do not use special characters in the filename + causing problems with the file system. + + No transformation function is defined in the file itself. + + Example: + + text.inc.php3 + (No function) + +3.5 + A global transform function with no specific mimetype + + global__.inc.php3 + + The transform function will the be called 'PMA_transform_global__()'. + + Example: + + global__formatted + PMA_transform_global__formatted() + + +So generally use '_' to split up mimetype and subtype, and '__' to provide a transform function. + +All filenames containing no '__' in themselves are not shown as valid transform functions in the dropdown. + +Please see the TEMPLATE file for adding your own transform function. See the TEMPLATE_MIMETYPE for adding +a mimetype without a transform function. Also note the introduction of a function description in the language +files. For each function a $strTransformation_ has to exist. + +You can use the template generator (see 5) to generate new functions and entries in the language file. + + +4. FAQ +------- + +4.1 + Q: I can't enter my own mimetype! WTF is this feature then useful for? + + A: Slow down :). Defining mimetypes is of no use, if you can't put transformations on them. + Otherwise you could just put a comment on the field. Because entering your own mimetype will + cause serious syntax checking issues and validation, this introduces a high-risk false-user-input + situation. Instead you have to initialize mimetypes using functions or empty mimetype definitions. + + Plus, you have a whole overview of available mimetypes. Who knows all those mimetypes by heart so + he/she can enter it at will? + + +5. Template Generator +---------------------- + +To create a new transform function please see template_generator.sh. + +To create a new, empty mimetype please see template_generator_mimetype.sh. \ No newline at end of file diff --git a/libraries/transformations/TEMPLATE b/libraries/transformations/TEMPLATE new file mode 100644 index 000000000..992556592 --- /dev/null +++ b/libraries/transformations/TEMPLATE @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/libraries/transformations/generator.sh b/libraries/transformations/generator.sh new file mode 100644 index 000000000..11e5fdcfd --- /dev/null +++ b/libraries/transformations/generator.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# $Id$ +# +# Shell script that adds a new function file using a template. Should not be called directly +# but instead by template_Generator.sh and template_generator_mimetype.sh +# +# +# $1: Template +# $2: Filename +# $3: (optional) Description + +if [ $# == 0 ] +then + echo "Please call template_generator.sh or template_generator_mimetype.sh instead" + echo "" + exit 65 +fi + +functionupper="`echo $2 | tr [:lower:] [:upper:]`" +functionlower="`echo $2 | tr [:upper:] [:lower:]`" + +cat $1 | sed "s/\[ENTER_FILENAME_HERE\]/$functionupper/" | sed "s/\[enter_filename_here\]/$functionlower/" >> $2.inc.php3 + +if [ $3 ] +then + echo "" + echo "DEBUG/TODO: Call" + echo "../../lang/add_message.sh '\$strTransformation_${functionlower}' '$3'" + echo "later!" + echo "" +fi + +echo "Created $2.inc.php3" +echo "" \ No newline at end of file diff --git a/libraries/transformations/global.inc.php3 b/libraries/transformations/global.inc.php3 new file mode 100644 index 000000000..47ccd1d1b --- /dev/null +++ b/libraries/transformations/global.inc.php3 @@ -0,0 +1,50 @@ +___.inc.php3 + * + * The function name has to be the like above filename: + * + * -- function PMA_transformation____.inc.php3 + * + * Please use short and expressive names. For now, special characters which aren't allowed in + * filenames or functions should not be used. + * + * Please provide a comment for your function, what it does and what parameters are available. + * + */ + +if (!defined('PMA_TRANSFORMATION_LIB_GLOBAL')){ + define('PMA_TRANSFORMATION_LIB_GLOBAL', 1); + + function PMA_transformation_global_plain($buffer, $options = array()) { + return htmlspecialchars($buffer); + } + + function PMA_transformation_global_html($buffer, $options = array()) { + return $buffer; + } + + function PMA_transformation_global_html_replace($buffer, $options = array()) { + if (!isset($options['string'])) { + $options['string'] = ''; + } + + if (isset($options['regex']) && isset($options['regex_replace'])) { + $buffer = eregi_replace($options['regex'], $options['regex_replace'], $buffer); + } + + // Replace occurences of [__BUFFER__] with actual text + $return = str_replace("[__BUFFER__]", $buffer, $options['string']); + return $return; + } +} diff --git a/libraries/transformations/image_jpeg__inline.inc.php3 b/libraries/transformations/image_jpeg__inline.inc.php3 new file mode 100644 index 000000000..49deecc49 --- /dev/null +++ b/libraries/transformations/image_jpeg__inline.inc.php3 @@ -0,0 +1,16 @@ + '[__BUFFER__]'); + $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); + + return $buffer; + } +} diff --git a/libraries/transformations/image_jpeg__link.inc.php3 b/libraries/transformations/image_jpeg__link.inc.php3 new file mode 100644 index 000000000..a7a39fee9 --- /dev/null +++ b/libraries/transformations/image_jpeg__link.inc.php3 @@ -0,0 +1,16 @@ + '[BLOB]'); + $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); + + return $buffer; + } +} diff --git a/libraries/transformations/image_jpeg__plain.inc.php3 b/libraries/transformations/image_jpeg__plain.inc.php3 new file mode 100644 index 000000000..701cd220d --- /dev/null +++ b/libraries/transformations/image_jpeg__plain.inc.php3 @@ -0,0 +1,16 @@ + ''); + $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); + + return $buffer; + } +} diff --git a/libraries/transformations/overview.php3 b/libraries/transformations/overview.php3 new file mode 100644 index 000000000..0c37ba10b --- /dev/null +++ b/libraries/transformations/overview.php3 @@ -0,0 +1,82 @@ + + +

+' . $mimetype . '
'; + } else { + echo $mimetype . '
'; + } + +} +?> +
+() + +
+
+
+

+ + + + + + + + + + + + + + diff --git a/libraries/transformations/template_generator.sh b/libraries/transformations/template_generator.sh new file mode 100644 index 000000000..c6c92078e --- /dev/null +++ b/libraries/transformations/template_generator.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# $Id$ +# +# Shell script that adds a new mimetype with transform function. +# +# The filename should contain either 'mimetype_subtype' or 'mimetype'. +# The suffix '.inc.php3' is appended automatically! +# +# The 'description' parameter will add a new entry in the language file. Watch out for +# special escaping. +# +# Example: template_generator.sh 'filename' 'description' +# +if [ $# == 0 ] +then + echo "Usage: template_generator.sh 'filename' 'description'" + echo "" + exit 65 +fi + +./generator.sh 'TEMPLATE' '$1' +echo " " +echo "New TRANSFORM FUNCTION $1.inc.php3 added." diff --git a/libraries/transformations/template_generator_mimetype.sh b/libraries/transformations/template_generator_mimetype.sh new file mode 100644 index 000000000..4961f802c --- /dev/null +++ b/libraries/transformations/template_generator_mimetype.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# $Id$ +# +# Shell script that adds a new mimetype without transform function. +# +# The filename should contain either 'mimetype_subtype' or 'mimetype'. +# The suffix '.inc.php3' is appended automatically! +# +# Example: template_generator_mimetype.sh 'filename' +# +if [ $# == 0 ] +then + echo "Usage: template_generator_mimetype.sh 'filename'" + echo "" + exit 65 +fi + +./generator.sh 'TEMPLATE_MIMETYPE' '$1' +echo " " +echo "New MIMETYPE $1.inc.php3 added." diff --git a/libraries/transformations/text_plain__formatted.inc.php3 b/libraries/transformations/text_plain__formatted.inc.php3 new file mode 100644 index 000000000..4959d9b34 --- /dev/null +++ b/libraries/transformations/text_plain__formatted.inc.php3 @@ -0,0 +1,11 @@ + '' . (isset($options[1]) ? $options[1] : '%1$s') . ''); + $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); + + return $buffer; + + return htmlspecialchars($buffer); + } +} diff --git a/scripts/create_tables.sql b/scripts/create_tables.sql index 93705f285..ebd38ea6c 100644 --- a/scripts/create_tables.sql +++ b/scripts/create_tables.sql @@ -70,6 +70,10 @@ CREATE TABLE `PMA_column_comments` ( table_name varchar(64) NOT NULL default '', column_name varchar(64) NOT NULL default '', `comment` varchar(255) NOT NULL default '', + mimetype varchar(255) NOT NULL default '', + transformation varchar(255) NOT NULL default '', + transformation_options varchar(255) NOT NULL default '', + PRIMARY KEY (id), UNIQUE KEY db_name (db_name, table_name, column_name) ) TYPE=MyISAM COMMENT='Comments for Columns'; diff --git a/tbl_addfield.php3 b/tbl_addfield.php3 index e52ccb650..6adbeab32 100755 --- a/tbl_addfield.php3 +++ b/tbl_addfield.php3 @@ -194,6 +194,7 @@ if (isset($submit)) { // garvin: If comments were sent, enable relation stuff require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); $cfgRelation = PMA_getRelationsParam(); @@ -205,6 +206,29 @@ if (isset($submit)) { } } + // garvin: Update comment table for mime types [MIME] + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } + } + + // garvin: If comments were sent, enable relation stuff + require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); + + $cfgRelation = PMA_getRelationsParam(); + + // garvin: Update comment table for mime types [MIME] + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } + } + + // Go back to the structure sub-page $sql_query = $sql_query_cpy; unset($sql_query_cpy); diff --git a/tbl_alter.php3 b/tbl_alter.php3 index 8ba31fade..f6fa63f18 100755 --- a/tbl_alter.php3 +++ b/tbl_alter.php3 @@ -90,6 +90,7 @@ if (isset($submit)) { // garvin: If comments were sent, enable relation stuff require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); $cfgRelation = PMA_getRelationsParam(); @@ -101,6 +102,14 @@ if (isset($submit)) { } } + // garvin: Update comment table for mime types [MIME] + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } + } + include('./tbl_properties_structure.php3'); exit(); } diff --git a/tbl_create.php3 b/tbl_create.php3 index 9d15bc506..762c1962e 100755 --- a/tbl_create.php3 +++ b/tbl_create.php3 @@ -195,6 +195,7 @@ if (isset($submit)) { // garvin: If comments were sent, enable relation stuff require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); $cfgRelation = PMA_getRelationsParam(); @@ -206,6 +207,14 @@ if (isset($submit)) { } } + // garvin: Update comment table for mime types [MIME] + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } + } + include('./' . $cfg['DefaultTabTable']); exit(); } // end do create table diff --git a/tbl_properties.inc.php3 b/tbl_properties.inc.php3 index 2d7b59bc3..2f6448be3 100755 --- a/tbl_properties.inc.php3 +++ b/tbl_properties.inc.php3 @@ -50,6 +50,25 @@ if ($cfgRelation['commwork']) { echo ''; } +$comments_map = array(); +$mime_map = array(); +$available_mime = array(); + +if ($cfgRelation['commwork']) { + $comments_map = PMA_getComments($db, $table); + echo ''; + + if ($cfg['BrowseMIME']) { + $mime_map = PMA_getMIME($db, $table); + $available_mime = PMA_getAvailableMIMEtypes(); + + echo ''; + echo ''; + echo ''; + } +} + + // lem9: We could remove this 'if' and let the key information be shown and // editable. However, for this to work, tbl_alter must be modified to use the // key fields, as tbl_addfield does. @@ -241,6 +260,47 @@ for ($i = 0 ; $i < $num_fields; $i++) { + + + + + + + + + + + + + + + + + +
' . sprintf($strMIME_nodescription, 'PMA_transformation_' . $func . '()') . ''); ?>
' . $strComments . '' . $strComments . '' . $strMIME_MIMEtype . '' . $strMIME_transformation . '' . $strMIME_transformation_options . '*** + + + + + +
***  + +
+ ', '') . "\n"; ?> +

diff --git a/tbl_properties_structure.php3 b/tbl_properties_structure.php3 index b5a914c7e..13bd628fb 100755 --- a/tbl_properties_structure.php3 +++ b/tbl_properties_structure.php3 @@ -73,6 +73,7 @@ $fields_cnt = mysql_num_rows($fields_rs); MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']); + } + $strAttribute = ' '; if ($binary) { $strAttribute = 'BINARY'; diff --git a/transformation_wrapper.php3 b/transformation_wrapper.php3 new file mode 100644 index 000000000..092ac5765 --- /dev/null +++ b/transformation_wrapper.php3 @@ -0,0 +1,169 @@ +