diff --git a/Documentation.html b/Documentation.html index 922b17229a..781cfb1251 100644 --- a/Documentation.html +++ b/Documentation.html @@ -2528,8 +2528,8 @@ setfacl -d -m "g:www-data:rwx" tmp for, but pay attention to option usage as well as what the transformation does to your column.

-

There is a basic file called 'global.inc.php'. This function can be included by - any other transform function and provides some basic functions.

+

There is a file called 'transformations.lib.php' that provides some basic functions + which can be included by any other transform function.

There are 5 possible file names:

diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index 4351c25482..72e96905ee 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -3,6 +3,14 @@ /** * Set of functions used with the relation and pdf feature * + * This file also provides basic functions to use in other plungins! + * These are declared in the 'GLOBAL Plugin functions' section + * + * 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. + * * @package PhpMyAdmin */ @@ -252,4 +260,45 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, return false; } } // end of 'PMA_setMIME()' function + + +/** + * GLOBAL Plugin functions + */ + + +/** + * Replaces "[__BUFFER__]" occurences found in $options['string'] with the text + * in $buffer, after performing a regular expression search and replace on + * $buffer using $options['regex'] and $options['regex_replace']. + * + * @param string $buffer text that will be replaced in $options['string'], + * after being formatted + * @param array $options the options required to format $buffer + * = array ( + * 'string' => 'string', // text containing "[__BUFFER__]" + * 'regex' => 'mixed', // the pattern to search for + * 'regex_replace' => 'mixed', // string or array of strings to replace with + * ); + * + * @return string containing the text with all the replacements + */ +function PMA_transformation_global_html_replace($buffer, $options = array()) +{ + if ( ! isset($options['string']) ) { + $options['string'] = ''; + } + + if ( + isset($options['regex']) + && + isset($options['regex_replace']) + ) { + $buffer = preg_replace('@' . str_replace('@', '\@', $options['regex']) . '@si', $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/TEMPLATE b/libraries/transformations/TEMPLATE index fb4506e4de..463aded524 100644 --- a/libraries/transformations/TEMPLATE +++ b/libraries/transformations/TEMPLATE @@ -7,6 +7,10 @@ * * For instructions, read the /Documentation.html file. * + * The basic filename usage for any plugin, residing in the libraries/transformations directory is: + * + * -- ___.inc.php + * * The string [ENTER_FILENAME_HERE] shall be substituted with the filename without the '.inc.php' * extension. For further information regarding naming conventions see the /Documentation.html file. */ @@ -20,8 +24,7 @@ function PMA_transformation_[ENTER_FILENAME_HERE]_info() 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'); + // possibly use a global transform and feed it with special options // further operations on $buffer using the $options[] array. diff --git a/libraries/transformations/application_octetstream__hex.inc.php b/libraries/transformations/application_octetstream__hex.inc.php index c0cb6b2345..6204286e79 100644 --- a/libraries/transformations/application_octetstream__hex.inc.php +++ b/libraries/transformations/application_octetstream__hex.inc.php @@ -16,8 +16,7 @@ function PMA_transformation_application_octetstream__hex_info() */ function PMA_transformation_application_octetstream__hex($buffer, $options = array(), $meta = '') { - // possibly use a global transform and feed it with special options: - // include './libraries/transformations/global.inc.php'; + // possibly use a global transform and feed it with special options if (!isset($options[0])) { $options[0] = 2; } else { diff --git a/libraries/transformations/global.inc.php b/libraries/transformations/global.inc.php deleted file mode 100644 index 373c3cc539..0000000000 --- a/libraries/transformations/global.inc.php +++ /dev/null @@ -1,60 +0,0 @@ -___.inc.php - * - * The function name has to be the like above filename: - * - * -- function PMA_transformation____.inc.php - * - * 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. - * - * @package PhpMyAdmin-Transformation - */ - -/** - * Replaces "[__BUFFER__]" occurences found in $options['string'] with the text - * in $buffer, after performing a regular expression search and replace on - * $buffer using $options['regex'] and $options['regex_replace']. - * - * @param string $buffer text that will be replaced in $options['string'], - * after being formatted - * @param array $options the options required to format $buffer - * = array ( - * 'string' => 'string', // text containing "[__BUFFER__]" - * 'regex' => 'mixed', // the pattern to search for - * 'regex_replace' => 'mixed', // string or array of strings to replace with - * ); - * - * @return string containing the text with all the replacements - */ -function PMA_transformation_global_html_replace($buffer, $options = array()) -{ - if ( ! isset($options['string']) ) { - $options['string'] = ''; - } - - if ( - isset($options['regex']) - && - isset($options['regex_replace']) - ) { - $buffer = preg_replace('@' . str_replace('@', '\@', $options['regex']) . '@si', $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.php b/libraries/transformations/image_jpeg__inline.inc.php index 4bbf465e14..f36c8d926b 100644 --- a/libraries/transformations/image_jpeg__inline.inc.php +++ b/libraries/transformations/image_jpeg__inline.inc.php @@ -16,8 +16,6 @@ function PMA_transformation_image_jpeg__inline_info() */ function PMA_transformation_image_jpeg__inline($buffer, $options = array(), $meta = '') { - include_once './libraries/transformations/global.inc.php'; - if (PMA_IS_GD2) { $transform_options = array ('string' => '[__BUFFER__]'); } else { diff --git a/libraries/transformations/image_jpeg__link.inc.php b/libraries/transformations/image_jpeg__link.inc.php index 39b38f6d5e..4da16614d1 100644 --- a/libraries/transformations/image_jpeg__link.inc.php +++ b/libraries/transformations/image_jpeg__link.inc.php @@ -16,8 +16,6 @@ function PMA_transformation_image_jpeg__link_info() */ function PMA_transformation_image_jpeg__link($buffer, $options = array(), $meta = '') { - include_once './libraries/transformations/global.inc.php'; - $transform_options = array ('string' => '[BLOB]'); $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); diff --git a/libraries/transformations/image_png__inline.inc.php b/libraries/transformations/image_png__inline.inc.php index f96c9a0cee..99676ab7d9 100644 --- a/libraries/transformations/image_png__inline.inc.php +++ b/libraries/transformations/image_png__inline.inc.php @@ -16,8 +16,6 @@ function PMA_transformation_image_png__inline_info() */ function PMA_transformation_image_png__inline($buffer, $options = array(), $meta = '') { - include_once './libraries/transformations/global.inc.php'; - if (PMA_IS_GD2) { $transform_options = array ('string' => '[__BUFFER__]'); } else { diff --git a/libraries/transformations/text_plain__dateformat.inc.php b/libraries/transformations/text_plain__dateformat.inc.php index dcdcb8c3a4..26afb1c9b6 100644 --- a/libraries/transformations/text_plain__dateformat.inc.php +++ b/libraries/transformations/text_plain__dateformat.inc.php @@ -16,8 +16,7 @@ function PMA_transformation_text_plain__dateformat_info() */ function PMA_transformation_text_plain__dateformat($buffer, $options = array(), $meta = '') { - // possibly use a global transform and feed it with special options: - // include './libraries/transformations/global.inc.php'; + // possibly use a global transform and feed it with special options // further operations on $buffer using the $options[] array. if (empty($options[0])) { diff --git a/libraries/transformations/text_plain__external.inc.php b/libraries/transformations/text_plain__external.inc.php index eb71ef2efa..20d3368cca 100644 --- a/libraries/transformations/text_plain__external.inc.php +++ b/libraries/transformations/text_plain__external.inc.php @@ -29,8 +29,7 @@ function PMA_transformation_text_plain__external_nowrap($options = array()) function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') { - // possibly use a global transform and feed it with special options: - // include './libraries/transformations/global.inc.php'; + // possibly use a global transform and feed it with special options // further operations on $buffer using the $options[] array. diff --git a/libraries/transformations/text_plain__imagelink.inc.php b/libraries/transformations/text_plain__imagelink.inc.php index c02ff35dd3..ca705d5235 100644 --- a/libraries/transformations/text_plain__imagelink.inc.php +++ b/libraries/transformations/text_plain__imagelink.inc.php @@ -16,8 +16,6 @@ function PMA_transformation_text_plain__imagelink_info() */ function PMA_transformation_text_plain__imagelink($buffer, $options = array(), $meta = '') { - include_once './libraries/transformations/global.inc.php'; - $transform_options = array ('string' => '' . $buffer . ''); $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); return $buffer; diff --git a/libraries/transformations/text_plain__link.inc.php b/libraries/transformations/text_plain__link.inc.php index c08d34e6f3..06285f5271 100644 --- a/libraries/transformations/text_plain__link.inc.php +++ b/libraries/transformations/text_plain__link.inc.php @@ -16,8 +16,6 @@ function PMA_transformation_text_plain__link_info() */ function PMA_transformation_text_plain__link($buffer, $options = array(), $meta = '') { - include_once './libraries/transformations/global.inc.php'; - // $transform_options = array ('string' => '' . (isset($options[1]) ? $options[1] : '%1$s') . ''); $transform_options = array ('string' => '' . (isset($options[1]) ? $options[1] : $buffer) . ''); diff --git a/libraries/transformations/text_plain__substr.inc.php b/libraries/transformations/text_plain__substr.inc.php index c220b0602d..d20a3e1409 100644 --- a/libraries/transformations/text_plain__substr.inc.php +++ b/libraries/transformations/text_plain__substr.inc.php @@ -16,8 +16,7 @@ function PMA_transformation_text_plain__substr_info() */ function PMA_transformation_text_plain__substr($buffer, $options = array(), $meta = '') { - // possibly use a global transform and feed it with special options: - // include './libraries/transformations/global.inc.php'; + // possibly use a global transform and feed it with special options // further operations on $buffer using the $options[] array. if (!isset($options[0]) || $options[0] == '') {