Fixes #5666 - Default options for transformations
Signed-off-by: Raghuram <raghuram.vadapalli@research.iiit.ac.in>
This commit is contained in:
parent
8270a1c1e1
commit
44028973ee
@ -3234,6 +3234,58 @@ MySQL settings
|
||||
FUNC\_SPATIAL, FUNC\_UUID) and for ``first_timestamp``, which is used
|
||||
for first timestamp column in table.
|
||||
|
||||
Default options for Transformations
|
||||
-----------------------------------
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']
|
||||
|
||||
:type: array
|
||||
:default: An array with below listed key-values
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['Substring']
|
||||
|
||||
:type: array
|
||||
:default: array(0, 'all', '…')
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['Bool2Text']
|
||||
|
||||
:type: array
|
||||
:default: array('T', 'F')
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['External']
|
||||
|
||||
:type: array
|
||||
:default: array(0, '-f /dev/null -i -wrap -q', 1, 1)
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['PreApPend']
|
||||
|
||||
:type: array
|
||||
:default: array('', '')
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['Hex']
|
||||
|
||||
:type: array
|
||||
:default: array('2')
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['DateFormat']
|
||||
|
||||
:type: array
|
||||
:default: array(0, '', 'local')
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['Inline']
|
||||
|
||||
:type: array
|
||||
:default: array('100', 100)
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['TextImageLink']
|
||||
|
||||
:type: array
|
||||
:default: array('', 100, 50)
|
||||
|
||||
.. config:option:: $cfg['DefaultTransformations']['TextLink']
|
||||
|
||||
:type: array
|
||||
:default: array('', '', '')
|
||||
|
||||
Developer
|
||||
---------
|
||||
|
||||
@ -79,7 +79,8 @@ They are called 'MIME-type', 'Browser transformation' and
|
||||
which you can specify 2 options and you want to append a character
|
||||
set, enter "'first parameter','second parameter','charset=us-ascii'".
|
||||
You can, however use the defaults for the parameters: "'','','charset
|
||||
=us-ascii'".
|
||||
=us-ascii'". The default options can be configured using
|
||||
:config:option:`$cfg['DefaultTransformations']`
|
||||
|
||||
.. _transformationsfiles:
|
||||
|
||||
|
||||
@ -42,7 +42,8 @@ abstract class Bool2TextTransformationsPlugin extends TransformationsPlugin
|
||||
*/
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
$options = $this->getOptions($options, array('T', 'F'));
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Bool2Text']);
|
||||
|
||||
if ($buffer == '0') {
|
||||
return $options[1]; // return false label
|
||||
|
||||
@ -51,17 +51,11 @@ abstract class DateFormatTransformationsPlugin extends TransformationsPlugin
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['DateFormat']);
|
||||
|
||||
// further operations on $buffer using the $options[] array.
|
||||
if (empty($options[0])) {
|
||||
$options[0] = 0;
|
||||
}
|
||||
|
||||
if (empty($options[2])) {
|
||||
$options[2] = 'local';
|
||||
} else {
|
||||
$options[2] = mb_strtolower($options[2]);
|
||||
}
|
||||
$options[2] = mb_strtolower($options[2]);
|
||||
|
||||
if (empty($options[1])) {
|
||||
if ($options[2] == 'local') {
|
||||
|
||||
@ -96,9 +96,10 @@ abstract class ExternalTransformationsPlugin extends TransformationsPlugin
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions(
|
||||
$options,
|
||||
array(0, '-f /dev/null -i -wrap -q', 1, 1)
|
||||
$cfg['DefaultTransformations']['External']
|
||||
);
|
||||
|
||||
if (isset($allowed_programs[$options[0]])) {
|
||||
|
||||
@ -43,7 +43,8 @@ abstract class HexTransformationsPlugin extends TransformationsPlugin
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
$options = $this->getOptions($options, array('2'));
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Hex']);
|
||||
$options[0] = intval($options[0]);
|
||||
|
||||
if ($options[0] < 1) {
|
||||
|
||||
@ -45,13 +45,16 @@ abstract class InlineTransformationsPlugin extends TransformationsPlugin
|
||||
*/
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Inline']);
|
||||
|
||||
if (PMA_IS_GD2) {
|
||||
return '<a href="transformation_wrapper.php'
|
||||
. $options['wrapper_link']
|
||||
. '" rel="noopener noreferrer" target="_blank"><img src="transformation_wrapper.php'
|
||||
. $options['wrapper_link'] . '&resize=jpeg&newWidth='
|
||||
. (isset($options[0]) ? intval($options[0]) : '100') . '&newHeight='
|
||||
. (isset($options[1]) ? intval($options[1]) : 100)
|
||||
. intval($options[0]) . '&newHeight='
|
||||
. intval($options[1])
|
||||
. '" alt="[' . htmlspecialchars($buffer) . ']" border="0" /></a>';
|
||||
} else {
|
||||
return '<img src="transformation_wrapper.php'
|
||||
|
||||
@ -43,7 +43,8 @@ abstract class PreApPendTransformationsPlugin extends TransformationsPlugin
|
||||
*/
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
$options = $this->getOptions($options, array('', ''));
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['PreApPend']);
|
||||
|
||||
//just prepend and/or append the options to the original text
|
||||
return htmlspecialchars($options[0]) . htmlspecialchars($buffer)
|
||||
|
||||
@ -47,7 +47,8 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin
|
||||
// possibly use a global transform and feed it with special options
|
||||
|
||||
// further operations on $buffer using the $options[] array.
|
||||
$options = $this->getOptions($options, array(0, 'all', '…'));
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Substring']);
|
||||
|
||||
if ($options[1] != 'all') {
|
||||
$newtext = mb_substr(
|
||||
|
||||
@ -47,15 +47,17 @@ abstract class TextImageLinkTransformationsPlugin extends TransformationsPlugin
|
||||
*/
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
$url = (isset($options[0]) ? $options[0] : '') . $buffer;
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['TextImageLink']);
|
||||
$url = $options[0] . $buffer;
|
||||
/* Do not allow javascript links */
|
||||
if (! Sanitize::checkLink($url, true, true)) {
|
||||
return htmlspecialchars($url);
|
||||
}
|
||||
return '<a href="' . htmlspecialchars($url)
|
||||
. '" rel="noopener noreferrer" target="_blank"><img src="' . htmlspecialchars($url)
|
||||
. '" border="0" width="' . (isset($options[1]) ? intval($options[1]) : 100)
|
||||
. '" height="' . (isset($options[2]) ? intval($options[2]) : 50) . '" />'
|
||||
. '" border="0" width="' . intval($options[1])
|
||||
. '" height="' . intval($options[2]) . '" />'
|
||||
. htmlspecialchars($buffer) . '</a>';
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,8 @@ abstract class TextLinkTransformationsPlugin extends TransformationsPlugin
|
||||
*/
|
||||
public function applyTransformation($buffer, $options = array(), $meta = '')
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['TextLink']);
|
||||
$url = (isset($options[0]) ? $options[0] : '') . ((isset($options[2]) && $options[2]) ? '' : $buffer);
|
||||
/* Do not allow javascript links */
|
||||
if (! Sanitize::checkLink($url, true, true)) {
|
||||
|
||||
@ -3105,3 +3105,79 @@ $cfg['MysqlMinVersion'] = array(
|
||||
* @global array $cfg['DisableShortcutKeys']
|
||||
*/
|
||||
$cfg['DisableShortcutKeys'] = false;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Default options for transformations
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize default transformations array
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']
|
||||
*/
|
||||
$cfg['DefaultTransformations'] = array();
|
||||
|
||||
/**
|
||||
* Default transformations for Substring
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['Substring']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['Substring'] = array(0, 'all', '…');
|
||||
|
||||
/**
|
||||
* Default transformations for Bool2Text
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['Bool2Text']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['Bool2Text'] = array('T', 'F');
|
||||
|
||||
/**
|
||||
* Default transformations for External
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['External']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['External'] = array(0, '-f /dev/null -i -wrap -q', 1, 1);
|
||||
|
||||
/**
|
||||
* Default transformations for PreApPend
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['PreApPend']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['PreApPend'] = array('', '');
|
||||
|
||||
/**
|
||||
* Default transformations for Hex
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['Hex']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['Hex'] = array('2');
|
||||
|
||||
/**
|
||||
* Default transformations for DateFormat
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['DateFormat']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['DateFormat'] = array(0, '', 'local');
|
||||
|
||||
/**
|
||||
* Default transformations for Inline
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['Inline']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['Inline'] = array('100', 100);
|
||||
$cfg['DefaultTransformations']['Inline']['wrapper_link'] = null;
|
||||
|
||||
/**
|
||||
* Default transformations for TextImageLink
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['TextImageLink']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['TextImageLink'] = array(null, 100, 50);
|
||||
|
||||
/**
|
||||
* Default transformations for TextLink
|
||||
*
|
||||
* @global array $cfg['DefaultTransformations']['TextLink']
|
||||
*/
|
||||
$cfg['DefaultTransformations']['TextLink'] = array(null, null, null);
|
||||
|
||||
@ -118,6 +118,25 @@ $strConfigShowColumnComments_name = __('Show column comments');
|
||||
$strConfigShowColumnComments_desc
|
||||
= __('Whether column comments should be shown in table structure view');
|
||||
$strConfigHideStructureActions_name = __('Hide table structure actions');
|
||||
$strConfigDefaultTransformations_Hex_name = __('Default transformations for Hex');
|
||||
$strConfigDefaultTransformations_Hex_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_Substring_name = __('Default transformations for Substring');
|
||||
$strConfigDefaultTransformations_Substring_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_Bool2Text_name = __('Default transformations for Bool2Text');
|
||||
$strConfigDefaultTransformations_Bool2Text_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_External_name = __('Default transformations for External');
|
||||
$strConfigDefaultTransformations_External_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_PreApPend_name = __('Default transformations for PreApPend');
|
||||
$strConfigDefaultTransformations_PreApPend_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_DateFormat_name = __('Default transformations for DateFormat');
|
||||
$strConfigDefaultTransformations_DateFormat_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_Inline_name = __('Default transformations for Inline');
|
||||
$strConfigDefaultTransformations_Inline_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_TextImageLink_name = __('Default transformations for TextImageLink');
|
||||
$strConfigDefaultTransformations_TextImageLink_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
$strConfigDefaultTransformations_TextLink_name = __('Default transformations for TextLink');
|
||||
$strConfigDefaultTransformations_TextLink_desc = __('Values for options list for default transformations. These will be overwritten if tranformation is filled in at table structure page.');
|
||||
|
||||
$strConfigDisplayServersList_desc
|
||||
= __('Show server listing as a list instead of a drop down.');
|
||||
$strConfigDisplayServersList_name = __('Display servers as a list');
|
||||
|
||||
@ -120,7 +120,19 @@ $forms['Main_panel']['DbStructure'] = array(
|
||||
'ShowDbStructureLastCheck');
|
||||
$forms['Main_panel']['TableStructure'] = array(
|
||||
'HideStructureActions',
|
||||
'ShowColumnComments');
|
||||
'ShowColumnComments',
|
||||
':group:' . __('Default transformations'),
|
||||
'DefaultTransformations/Hex',
|
||||
'DefaultTransformations/Substring',
|
||||
'DefaultTransformations/Bool2Text',
|
||||
'DefaultTransformations/External',
|
||||
'DefaultTransformations/PreApPend',
|
||||
'DefaultTransformations/DateFormat',
|
||||
'DefaultTransformations/Inline',
|
||||
'DefaultTransformations/TextImageLink',
|
||||
'DefaultTransformations/TextLink',
|
||||
':group:end'
|
||||
);
|
||||
$forms['Main_panel']['Browse'] = array(
|
||||
'TableNavigationLinksMode',
|
||||
'ActionLinksMode',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user