From e0b32c7aaad348635044a2bda2e9d5712b198e6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 24 May 2010 12:04:20 +0200 Subject: [PATCH] Convert transformation descriptions to gettext. --- Documentation.html | 12 ++++++++++++ libraries/messages.inc.php | 13 ------------- libraries/transformations/TEMPLATE | 6 ++++++ .../application_octetstream__download.inc.php | 6 ++++++ .../transformations/application_octetstream__hex.inc.php | 6 ++++++ libraries/transformations/image_jpeg__inline.inc.php | 6 ++++++ libraries/transformations/image_jpeg__link.inc.php | 6 ++++++ libraries/transformations/image_png__inline.inc.php | 6 ++++++ libraries/transformations/text_plain__dateformat.inc.php | 6 ++++++ libraries/transformations/text_plain__external.inc.php | 6 ++++++ libraries/transformations/text_plain__formatted.inc.php | 6 ++++++ libraries/transformations/text_plain__imagelink.inc.php | 6 ++++++ libraries/transformations/text_plain__link.inc.php | 6 ++++++ libraries/transformations/text_plain__longToIpv4.inc.php | 6 ++++++ libraries/transformations/text_plain__sql.inc.php | 6 ++++++ libraries/transformations/text_plain__substr.inc.php | 6 ++++++ transformation_overview.php | 12 ++++++++++-- 17 files changed, 106 insertions(+), 15 deletions(-) diff --git a/Documentation.html b/Documentation.html index 13bdc90f21..bbf6d2ace9 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 d071f75ff7..cc5bac9953 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 f3000adb6c..eabb1948de 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 2025632344..369126ddcc 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 a9b485f3d7..7122354984 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 d97dcb9aa4..682e4a0bbb 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 43fd9c8ecd..5223e506be 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 1801878ef4..f631aa4a19 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 c1386fa800..3f11fa9025 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 69100dea52..981faecff0 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 65e145841b..7a1e8f87ff 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 8540d76719..d743a16b5d 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 9295de4e43..f9e2bf1808 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 7f9d6b887d..bcfc12a4a2 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 7bc38d41cd..5d5bfb1e5a 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 6b9520e6c8..9982dcba48 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 fa7a0b0b28..12ca395131 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 . '()') . ''); ?> +