Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-04-02 13:23:13 +02:00
commit d3cb706ff8
13 changed files with 60 additions and 82 deletions

View File

@ -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.</p>
<p> There is a basic file called '<em>global.inc.php</em>'. This function can be included by
any other transform function and provides some basic functions.</p>
<p> There is a file called '<em>transformations.lib.php</em>' that provides some basic functions
which can be included by any other transform function.</p>
<p> There are 5 possible file names:</p>

View File

@ -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;
}
?>

View File

@ -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:
*
* -- <mime_type>_<mime_subtype>__<transformation_name>.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.

View File

@ -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 {

View File

@ -1,60 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* GLOBAL Plugin function.
* ---------------
*
* THIS FILE PROVIDES BASIC FUNCTIONS TO USE IN OTHER PLUGINS!
*
* The basic filename usage for any plugin, residing in the libraries/transformations directory is:
*
* -- <mime_type>_<mime_subtype>__<transformation_name>.inc.php
*
* The function name has to be the like above filename:
*
* -- function PMA_transformation_<mime_type>_<mime_subtype>__<transformation_name>.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;
}
?>

View File

@ -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' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=jpeg&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0" /></a>');
} else {

View File

@ -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' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);

View File

@ -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' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=png&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0" /></a>');
} else {

View File

@ -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])) {

View File

@ -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.

View File

@ -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' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" target="_blank"><img src="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" border="0" width="' . (isset($options[1]) ? $options[1] : 100) . '" height="' . (isset($options[2]) ? $options[2] : 50) . '" />' . $buffer . '</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;

View File

@ -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' => '<a href="' . (isset($options[0]) ? $options[0] : '') . '%1$s" title="' . (isset($options[1]) ? $options[1] : '%1$s') . '">' . (isset($options[1]) ? $options[1] : '%1$s') . '</a>');
$transform_options = array ('string' => '<a href="' . PMA_linkURL((isset($options[0]) ? $options[0] : '') . $buffer) . '" title="' . (isset($options[1]) ? $options[1] : '') . '">' . (isset($options[1]) ? $options[1] : $buffer) . '</a>');

View File

@ -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] == '') {