diff --git a/Documentation.html b/Documentation.html index 13bdc90f2..bbf6d2ace 100644 --- a/Documentation.html +++ b/Documentation.html @@ -2576,6 +2576,18 @@ setfacl -d -m "g:www-data:rwx" tmp field (i.e. 'text/plain', 'image/jpeg' etc.) +

Additionally you should also provide additional function to provide + information about the transformation to the user. This function should + have same name as transformation function just with appended + _info suffix. This function accepts no parameters and returns + array with information about the transformation. Currently following keys + can be used: +

+

+
info
+
Long description of the transformation.
+
+

FAQ - Frequently Asked Questions

diff --git a/libraries/messages.inc.php b/libraries/messages.inc.php index d071f75ff..cc5bac995 100644 --- a/libraries/messages.inc.php +++ b/libraries/messages.inc.php @@ -129,17 +129,4 @@ $strShowStatusThreads_cachedDescr = __('The number of threads in the thread cach $strShowStatusThreads_connectedDescr = __('The number of currently open connections.'); $strShowStatusThreads_createdDescr = __('The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. (Normally this doesn\'t give a notable performance improvement if you have a good thread implementation.)'); $strShowStatusThreads_runningDescr = __('The number of threads that are not sleeping.'); - -$strTransformation_application_octetstream__download = __('Displays a link to download the binary data of the field. You can use the first option to specify the filename, or use the second option as the name of a field which contains the filename. If you use the second option, you need to set the first option to the empty string.'); -$strTransformation_application_octetstream__hex = __('Displays hexadecimal representation of data. Optional first parameter specifies how often space will be added (defaults to 2 nibbles).'); -$strTransformation_image_jpeg__inline = __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.'); -$strTransformation_image_jpeg__link = __('Displays a link to download this image.'); -$strTransformation_image_png__inline = __('See image/jpeg: inline'); -$strTransformation_text_plain__dateformat = __('Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp field as formatted date. The first option is the offset (in hours) which will be added to the timestamp (Default: 0). Use second option to specify a different date/time format string. Third option determines whether you want to see local date or UTC one (use "local" or "utc" strings) for that. According to that, date format has different value - for "local" see the documentation for PHP\'s strftime() function and for "utc" it is done using gmdate() function.'); -$strTransformation_text_plain__external = __('LINUX ONLY: Launches an external application and feeds it the field data via standard input. Returns the standard output of the application. The default is Tidy, to pretty-print HTML code. For security reasons, you have to manually edit the file libraries/transformations/text_plain__external.inc.php and list the tools you want to make available. The first option is then the number of the program you want to use and the second option is the parameters for the program. The third option, if set to 1, will convert the output using htmlspecialchars() (Default 1). The fourth option, if set to 1, will prevent wrapping and ensure that the output appears all on one line (Default 1).'); -$strTransformation_text_plain__formatted = __('Displays the contents of the field as-is, without running it through htmlspecialchars(). That is, the field is assumed to contain valid HTML.'); -$strTransformation_text_plain__imagelink = __('Displays an image and a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second and third options are the width and the height in pixels.'); -$strTransformation_text_plain__link = __('Displays a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second option is a title for the link.'); -$strTransformation_text_plain__sql = __('Formats text as SQL query with syntax highlighting.'); -$strTransformation_text_plain__substr = __('Displays a part of a string. The first option is the number of characters to skip from the beginning of the string (Default 0). The second option is the number of characters to return (Default: until end of string). The third option is the string to append and/or prepend when truncation occurs (Default: "...").'); ?> diff --git a/libraries/transformations/TEMPLATE b/libraries/transformations/TEMPLATE index f3000adb6..eabb1948d 100644 --- a/libraries/transformations/TEMPLATE +++ b/libraries/transformations/TEMPLATE @@ -12,6 +12,12 @@ * extension. For further information regarding naming conventions see the /Documentation.html file. */ +function PMA_transformation_[ENTER_FILENAME_HERE]_info() { + return array( + 'info' => __('Description of the transformation.'), + ); +} + function PMA_transformation_[ENTER_FILENAME_HERE]($buffer, $options = array(), $meta = '') { // possibly use a global transform and feed it with special options: // include('./libraries/transformations/global.inc.php'); diff --git a/libraries/transformations/application_octetstream__download.inc.php b/libraries/transformations/application_octetstream__download.inc.php index 202563234..369126ddc 100644 --- a/libraries/transformations/application_octetstream__download.inc.php +++ b/libraries/transformations/application_octetstream__download.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_application_octetstream__download_info() { + return array( + 'info' => __('Displays a link to download the binary data of the field. You can use the first option to specify the filename, or use the second option as the name of a field which contains the filename. If you use the second option, you need to set the first option to the empty string.'), + ); +} + /** * */ diff --git a/libraries/transformations/application_octetstream__hex.inc.php b/libraries/transformations/application_octetstream__hex.inc.php index a9b485f3d..712235498 100644 --- a/libraries/transformations/application_octetstream__hex.inc.php +++ b/libraries/transformations/application_octetstream__hex.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_application_octetstream__hex_info() { + return array( + 'info' => __('Displays hexadecimal representation of data. Optional first parameter specifies how often space will be added (defaults to 2 nibbles).'), + ); +} + /** * */ diff --git a/libraries/transformations/image_jpeg__inline.inc.php b/libraries/transformations/image_jpeg__inline.inc.php index d97dcb9aa..682e4a0bb 100644 --- a/libraries/transformations/image_jpeg__inline.inc.php +++ b/libraries/transformations/image_jpeg__inline.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_image_jpeg__inline_info() { + return array( + 'info' => __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.'), + ); +} + /** * */ diff --git a/libraries/transformations/image_jpeg__link.inc.php b/libraries/transformations/image_jpeg__link.inc.php index 43fd9c8ec..5223e506b 100644 --- a/libraries/transformations/image_jpeg__link.inc.php +++ b/libraries/transformations/image_jpeg__link.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_image_jpeg__link_info() { + return array( + 'info' => __('Displays a link to download this image.'), + ); +} + /** * */ diff --git a/libraries/transformations/image_png__inline.inc.php b/libraries/transformations/image_png__inline.inc.php index 1801878ef..f631aa4a1 100644 --- a/libraries/transformations/image_png__inline.inc.php +++ b/libraries/transformations/image_png__inline.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_image_png__inline_info() { + return array( + 'info' => __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__dateformat.inc.php b/libraries/transformations/text_plain__dateformat.inc.php index c1386fa80..3f11fa902 100644 --- a/libraries/transformations/text_plain__dateformat.inc.php +++ b/libraries/transformations/text_plain__dateformat.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__dateformat_info() { + return array( + 'info' => __('Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp field as formatted date. The first option is the offset (in hours) which will be added to the timestamp (Default: 0). Use second option to specify a different date/time format string. Third option determines whether you want to see local date or UTC one (use "local" or "utc" strings) for that. According to that, date format has different value - for "local" see the documentation for PHP\'s strftime() function and for "utc" it is done using gmdate() function.'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__external.inc.php b/libraries/transformations/text_plain__external.inc.php index 69100dea5..981faecff 100644 --- a/libraries/transformations/text_plain__external.inc.php +++ b/libraries/transformations/text_plain__external.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__external_info() { + return array( + 'info' => __('LINUX ONLY: Launches an external application and feeds it the field data via standard input. Returns the standard output of the application. The default is Tidy, to pretty-print HTML code. For security reasons, you have to manually edit the file libraries/transformations/text_plain__external.inc.php and list the tools you want to make available. The first option is then the number of the program you want to use and the second option is the parameters for the program. The third option, if set to 1, will convert the output using htmlspecialchars() (Default 1). The fourth option, if set to 1, will prevent wrapping and ensure that the output appears all on one line (Default 1).'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__formatted.inc.php b/libraries/transformations/text_plain__formatted.inc.php index 65e145841..7a1e8f87f 100644 --- a/libraries/transformations/text_plain__formatted.inc.php +++ b/libraries/transformations/text_plain__formatted.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__formatted_info() { + return array( + 'info' => __('Displays the contents of the field as-is, without running it through htmlspecialchars(). That is, the field is assumed to contain valid HTML.'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__imagelink.inc.php b/libraries/transformations/text_plain__imagelink.inc.php index 8540d7671..d743a16b5 100644 --- a/libraries/transformations/text_plain__imagelink.inc.php +++ b/libraries/transformations/text_plain__imagelink.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__imagelink_info() { + return array( + 'info' => __('Displays an image and a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second and third options are the width and the height in pixels.'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__link.inc.php b/libraries/transformations/text_plain__link.inc.php index 9295de4e4..f9e2bf180 100644 --- a/libraries/transformations/text_plain__link.inc.php +++ b/libraries/transformations/text_plain__link.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__link_info() { + return array( + 'info' => __('Displays a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second option is a title for the link.'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__longToIpv4.inc.php b/libraries/transformations/text_plain__longToIpv4.inc.php index 7f9d6b887..bcfc12a4a 100644 --- a/libraries/transformations/text_plain__longToIpv4.inc.php +++ b/libraries/transformations/text_plain__longToIpv4.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__longToIpv4_info() { + return array( + 'info' => __('Converts an (IPv4) Internet network address into a string in Internet standard dotted format.'), + ); +} + /** * returns IPv4 address * diff --git a/libraries/transformations/text_plain__sql.inc.php b/libraries/transformations/text_plain__sql.inc.php index 7bc38d41c..5d5bfb1e5 100644 --- a/libraries/transformations/text_plain__sql.inc.php +++ b/libraries/transformations/text_plain__sql.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__sql_info() { + return array( + 'info' => __('Formats text as SQL query with syntax highlighting.'), + ); +} + /** * */ diff --git a/libraries/transformations/text_plain__substr.inc.php b/libraries/transformations/text_plain__substr.inc.php index 6b9520e6c..9982dcba4 100644 --- a/libraries/transformations/text_plain__substr.inc.php +++ b/libraries/transformations/text_plain__substr.inc.php @@ -5,6 +5,12 @@ * @version $Id$ */ +function PMA_transformation_text_plain__substr_info() { + return array( + 'info' => __('Displays a part of a string. The first option is the number of characters to skip from the beginning of the string (Default 0). The second option is the number of characters to return (Default: until end of string). The third option is the string to append and/or prepend when truncation occurs (Default: "...").'), + ); +} + /** * */ diff --git a/transformation_overview.php b/transformation_overview.php index fa7a0b0b2..12ca39513 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -53,11 +53,19 @@ foreach ($types['mimetype'] as $key => $mimetype) { $odd_row = true; foreach ($types['transformation'] as $key => $transform) { $func = strtolower(str_ireplace('.inc.php', '', $types['transformation_file'][$key])); - $desc = 'strTransformation_' . $func; + require './libraries/transformations/' . $types['transformation_file'][$key]; + $funcname = 'PMA_transformation_' . $func . '_info'; + $desc = '' . sprintf(__('No description is available for this transformation.
Please ask the author what %s does.'), 'PMA_transformation_' . $func . '()') . '
'; + if (function_exists($funcname)) { + $desc_arr = $funcname(); + if (isset($desc_arr['info'])) { + $desc = $desc_arr['info']; + } + } ?> - ' . sprintf(__('No description is available for this transformation.
Please ask the author what %s does.'), 'PMA_transformation_' . $func . '()') . ''); ?> +