Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-06-01 13:58:21 +02:00
commit 8fa57d23ff
40 changed files with 579 additions and 588 deletions

View File

@ -8,7 +8,6 @@
use PMA\libraries\Response;
require_once 'libraries/common.inc.php';
require_once 'libraries/transformations.lib.php';
require_once 'libraries/browse_foreigners.lib.php';
/**

View File

@ -5,8 +5,10 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\URL;
use PMA\libraries\Response;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
/**
* Gets the variables sent or posted to this script, then displays headers
@ -37,8 +39,6 @@ $header->enablePrintView();
*/
$cfgRelation = PMA_getRelationsParam();
require_once 'libraries/transformations.lib.php';
/**
* Check parameters
*/
@ -186,7 +186,7 @@ foreach ($tables as $table) {
}
echo '</td>' , "\n";
if ($cfgRelation['mimework']) {
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = Transformations::getMIME($db, $table, true);
echo ' <td>';
if (isset($mime_map[$column_name])) {

View File

@ -407,9 +407,6 @@ do {
if ($do_relation || $do_comments || $do_mime) {
$cfgRelation = PMA_getRelationsParam();
}
if ($do_mime) {
include_once 'libraries/transformations.lib.php';
}
// Include dates in export?
$do_dates = isset($GLOBALS[$what . '_dates']);

View File

@ -9,10 +9,9 @@ namespace PMA\libraries;
use PhpMyAdmin\SqlParser\Utils\Query;
use PMA\libraries\plugins\transformations\Text_Plain_Link;
use PMA\libraries\URL;
use PMA\libraries\Sanitize;
require_once './libraries/transformations.lib.php';
use PMA\libraries\Transformations;
use PMA\libraries\URL;
/**
* Handle all the functionalities related to displaying results
@ -2915,7 +2914,7 @@ class DisplayResults
) {
$mimeMap = array_merge(
$mimeMap,
PMA_getMIME($this->__get('db'), $meta->orgtable, false, true)
Transformations::getMIME($this->__get('db'), $meta->orgtable, false, true)
);
$added[$orgFullTableName] = true;
}
@ -3060,14 +3059,14 @@ class DisplayResults
if (file_exists($include_file)) {
include_once $include_file;
$class_name = PMA_getTransformationClassName($include_file);
$class_name = Transformations::getClassName($include_file);
// todo add $plugin_manager
$plugin_manager = null;
$transformation_plugin = new $class_name(
$plugin_manager
);
$transform_options = PMA_Transformation_getOptions(
$transform_options = Transformations::getOptions(
isset(
$mime_map[$orgFullColName]
['transformation_options']
@ -3100,7 +3099,7 @@ class DisplayResults
$transformation_plugin = new $this->transformation_info
[$dbLower][$tblLower][$nameLower][1](null);
$transform_options = PMA_Transformation_getOptions(
$transform_options = Transformations::getOptions(
isset($mime_map[$orgFullColName]['transformation_options'])
? $mime_map[$orgFullColName]['transformation_options']
: ''

View File

@ -0,0 +1,460 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Set of functions used with the relation and pdf feature
*
* This file also provides basic functions to use in other plugins!
* 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
*/
namespace PMA\libraries;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\Util;
/**
* Transformations class
*
* @package PhpMyAdmin
*/
class Transformations
{
/**
* Returns array of options from string with options separated by comma,
* removes quotes
*
* <code>
* getOptions("'option ,, quoted',abd,'2,3',");
* // array {
* // 'option ,, quoted',
* // 'abc',
* // '2,3',
* // '',
* // }
* </code>
*
* @param string $option_string comma separated options
*
* @return array options
*/
public static function getOptions($option_string)
{
$result = array();
if (strlen($option_string) === 0
|| ! $transform_options = preg_split('/,/', $option_string)
) {
return $result;
}
while (($option = array_shift($transform_options)) !== null) {
$trimmed = trim($option);
if (strlen($trimmed) > 1
&& $trimmed[0] == "'"
&& $trimmed[strlen($trimmed) - 1] == "'"
) {
// '...'
$option = mb_substr($trimmed, 1, -1);
} elseif (isset($trimmed[0]) && $trimmed[0] == "'") {
// '...,
$trimmed = ltrim($option);
while (($option = array_shift($transform_options)) !== null) {
// ...,
$trimmed .= ',' . $option;
$rtrimmed = rtrim($trimmed);
if ($rtrimmed[strlen($rtrimmed) - 1] == "'") {
// ,...'
break;
}
}
$option = mb_substr($rtrimmed, 1, -1);
}
$result[] = stripslashes($option);
}
return $result;
}
/**
* Gets all available MIME-types
*
* @access public
* @staticvar array mimetypes
* @return array array[mimetype], array[transformation]
*/
public static function getAvailableMIMEtypes()
{
static $stack = null;
if (null !== $stack) {
return $stack;
}
$stack = array();
$sub_dirs = array(
'input/' => 'input_',
'output/' => '',
'' => ''
);
foreach ($sub_dirs as $sd => $prefix) {
$handle = opendir('libraries/plugins/transformations/' . $sd);
if (! $handle) {
$stack[$prefix . 'transformation'] = array();
$stack[$prefix . 'transformation_file'] = array();
continue;
}
$filestack = array();
while ($file = readdir($handle)) {
// Ignore hidden files
if ($file[0] == '.') {
continue;
}
// Ignore old plugins (.class in filename)
if (strpos($file, '.class') !== false) {
continue;
}
$filestack[] = $file;
}
closedir($handle);
sort($filestack);
foreach ($filestack as $file) {
if (preg_match('|^[^.].*_.*_.*\.php$|', $file)) {
// File contains transformation functions.
$parts = explode('_', str_replace('.php', '', $file));
$mimetype = $parts[0] . "/" . $parts[1];
$stack['mimetype'][$mimetype] = $mimetype;
$stack[$prefix . 'transformation'][] = $mimetype . ': ' . $parts[2];
$stack[$prefix . 'transformation_file'][] = $sd . $file;
if ($sd === '') {
$stack['input_transformation'][] = $mimetype . ': ' . $parts[2];
$stack['input_transformation_file'][] = $sd . $file;
}
} elseif (preg_match('|^[^.].*\.php$|', $file)) {
// File is a plain mimetype, no functions.
$base = str_replace('.php', '', $file);
if ($base != 'global') {
$mimetype = str_replace('_', '/', $base);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['empty_mimetype'][$mimetype] = $mimetype;
}
}
}
}
return $stack;
}
/**
* Returns the class name of the transformation
*
* @param string $filename transformation file name
*
* @return string the class name of transformation
*/
public static function getClassName($filename)
{
// get the transformation class name
$class_name = explode(".php", $filename);
$class_name = 'PMA\\' . str_replace('/', '\\', $class_name[0]);
return $class_name;
}
/**
* Returns the description of the transformation
*
* @param string $file transformation file
*
* @return String the description of the transformation
*/
public static function getDescription($file)
{
$include_file = 'libraries/plugins/transformations/' . $file;
/* @var $class_name PMA\libraries\plugins\TransformationsInterface */
$class_name = self::getClassName($include_file);
// include and instantiate the class
include_once $include_file;
return $class_name::getInfo();
}
/**
* Returns the name of the transformation
*
* @param string $file transformation file
*
* @return String the name of the transformation
*/
public static function getName($file)
{
$include_file = 'libraries/plugins/transformations/' . $file;
/* @var $class_name PMA\libraries\plugins\TransformationsInterface */
$class_name = self::getClassName($include_file);
// include and instantiate the class
include_once $include_file;
return $class_name::getName();
}
/**
* Gets the mimetypes for all columns of a table
*
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
* @param boolean $strict whether to include only results having a mimetype set
* @param boolean $fullName whether to use full column names as the key
*
* @access public
*
* @return array [field_name][field_key] = field_value
*/
public static function getMIME($db, $table, $strict = false, $fullName = false)
{
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['commwork']) {
return false;
}
$com_qry = '';
if ($fullName) {
$com_qry .= "SELECT CONCAT("
. "`db_name`, '.', `table_name`, '.', `column_name`"
. ") AS column_name, ";
} else {
$com_qry = "SELECT `column_name`, ";
}
$com_qry .= '`mimetype`,
`transformation`,
`transformation_options`,
`input_transformation`,
`input_transformation_options`
FROM ' . Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
AND ( `mimetype` != \'\'' . (!$strict ? '
OR `transformation` != \'\'
OR `transformation_options` != \'\'
OR `input_transformation` != \'\'
OR `input_transformation_options` != \'\'' : '') . ')';
$result = $GLOBALS['dbi']->fetchResult(
$com_qry, 'column_name', null, $GLOBALS['controllink']
);
foreach ($result as $column => $values) {
// replacements in mimetype and transformation
$values = str_replace("jpeg", "JPEG", $values);
$values = str_replace("png", "PNG", $values);
// convert mimetype to new format (f.e. Text_Plain, etc)
$delimiter_space = '- ';
$delimiter = "_";
$values['mimetype'] = str_replace(
$delimiter_space,
$delimiter,
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$values['mimetype']
)
)
);
// For transformation of form
// output/image_jpeg__inline.inc.php
// extract dir part.
$dir = explode('/', $values['transformation']);
$subdir = '';
if (count($dir) === 2) {
$subdir = $dir[0] . '/';
$values['transformation'] = $dir[1];
}
$values['transformation'] = str_replace(
$delimiter_space,
$delimiter,
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$values['transformation']
)
)
);
$values['transformation'] = $subdir . $values['transformation'];
$result[$column] = $values;
}
return $result;
} // end of the 'getMIME()' function
/**
* Set a single mimetype to a certain value.
*
* @param string $db the name of the db
* @param string $table the name of the table
* @param string $key the name of the column
* @param string $mimetype the mimetype of the column
* @param string $transformation the transformation of the column
* @param string $transformationOpts the transformation options of the column
* @param string $inputTransform the input transformation of the column
* @param string $inputTransformOpts the input transformation options of the column
* @param boolean $forcedelete force delete, will erase any existing
* comments for this column
*
* @access public
*
* @return boolean true, if comment-query was made.
*/
public static function setMIME($db, $table, $key, $mimetype, $transformation,
$transformationOpts, $inputTransform, $inputTransformOpts, $forcedelete = false
) {
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['commwork']) {
return false;
}
// lowercase mimetype & transformation
$mimetype = mb_strtolower($mimetype);
$transformation = mb_strtolower($transformation);
$test_qry = '
SELECT `mimetype`,
`comment`
FROM ' . Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key) . '\'';
$test_rs = PMA_queryAsControlUser(
$test_qry, true, DatabaseInterface::QUERY_STORE
);
if ($test_rs && $GLOBALS['dbi']->numRows($test_rs) > 0) {
$row = @$GLOBALS['dbi']->fetchAssoc($test_rs);
$GLOBALS['dbi']->freeResult($test_rs);
if (! $forcedelete
&& (strlen($mimetype) > 0
|| strlen($transformation) > 0
|| strlen($transformationOpts) > 0
|| strlen($row['comment']) > 0)
) {
$upd_query = 'UPDATE '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['column_info'])
. ' SET '
. '`mimetype` = \''
. $GLOBALS['dbi']->escapeString($mimetype) . '\', '
. '`transformation` = \''
. $GLOBALS['dbi']->escapeString($transformation) . '\', '
. '`transformation_options` = \''
. $GLOBALS['dbi']->escapeString($transformationOpts) . '\', '
. '`input_transformation` = \''
. $GLOBALS['dbi']->escapeString($inputTransform) . '\', '
. '`input_transformation_options` = \''
. $GLOBALS['dbi']->escapeString($inputTransformOpts) . '\'';
} else {
$upd_query = 'DELETE FROM '
. Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['column_info']);
}
$upd_query .= '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key)
. '\'';
} elseif (strlen($mimetype) > 0
|| strlen($transformation) > 0
|| strlen($transformationOpts) > 0
) {
$upd_query = 'INSERT INTO '
. Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, '
. 'transformation, transformation_options, '
. 'input_transformation, input_transformation_options) '
. ' VALUES('
. '\'' . $GLOBALS['dbi']->escapeString($db) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($table) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($key) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($mimetype) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($transformation) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($transformationOpts) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($inputTransform) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($inputTransformOpts) . '\')';
}
if (isset($upd_query)) {
return PMA_queryAsControlUser($upd_query);
} else {
return false;
}
} // end of 'setMIME()' function
/**
* GLOBAL Plugin functions
*/
/**
* Delete related transformation details
* after deleting database. table or column
*
* @param string $db Database name
* @param string $table Table name
* @param string $column Column name
*
* @return boolean State of the query execution
*/
public static function clear($db, $table = '', $column = '')
{
$cfgRelation = PMA_getRelationsParam();
if (! isset($cfgRelation['column_info'])) {
return false;
}
$delete_sql = 'DELETE FROM '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['column_info'])
. ' WHERE ';
if (($column != '') && ($table != '')) {
$delete_sql .= '`db_name` = \'' . $db . '\' AND '
. '`table_name` = \'' . $table . '\' AND '
. '`column_name` = \'' . $column . '\' ';
} else if ($table != '') {
$delete_sql .= '`db_name` = \'' . $db . '\' AND '
. '`table_name` = \'' . $table . '\' ';
} else {
$delete_sql .= '`db_name` = \'' . $db . '\' ';
}
return $GLOBALS['dbi']->tryQuery($delete_sql);
}
}

View File

@ -19,10 +19,10 @@ use PhpMyAdmin\SqlParser;
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
use PhpMyAdmin\SqlParser\Utils\Table as SqlTable;
use PMA\libraries\Table;
use PMA\libraries\Transformations;
use PMA\libraries\controllers\TableController;
use PMA\libraries\URL;
require_once 'libraries/transformations.lib.php';
require_once 'libraries/util.lib.php';
require_once 'libraries/config/messages.inc.php';
require_once 'libraries/config/user_preferences.forms.php';
@ -1037,7 +1037,7 @@ class TableStructureController extends TableController
if (isset($_REQUEST['field_name'][$fieldindex])
&& strlen($_REQUEST['field_name'][$fieldindex]) > 0
) {
PMA_setMIME(
Transformations::setMIME(
$this->db, $this->table,
$_REQUEST['field_name'][$fieldindex],
$mimetype,
@ -1163,10 +1163,9 @@ class TableStructureController extends TableController
$mime_map = array();
if ($GLOBALS['cfg']['ShowPropertyComments']) {
include_once 'libraries/transformations.lib.php';
$comments_map = PMA_getComments($this->db, $this->table);
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mime_map = PMA_getMIME($this->db, $this->table, true);
$mime_map = Transformations::getMIME($this->db, $this->table, true);
}
}
include_once 'libraries/central_columns.lib.php';

View File

@ -8,8 +8,9 @@
use PMA\libraries\Message;
use PMA\libraries\plugins\TransformationsPlugin;
use PMA\libraries\Response;
use PMA\libraries\URL;
use PMA\libraries\Sanitize;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
/**
* Retrieve form parameters for insert/edit form
@ -2182,14 +2183,13 @@ function PMA_transformEditedValues($db, $table,
'where_clause' => $_REQUEST['where_clause'],
'transform_key' => $column_name
);
$transform_options = PMA_Transformation_getOptions(
$transform_options = Transformations::getOptions(
isset($transformation[$type . '_options'])
? $transformation[$type . '_options']
: ''
);
$transform_options['wrapper_link']
= URL::getCommon($_url_params);
$class_name = PMA_getTransformationClassName($include_file);
$transform_options['wrapper_link'] = URL::getCommon($_url_params);
$class_name = Transformations::getClassName($include_file);
/** @var TransformationsPlugin $transformation_plugin */
$transformation_plugin = new $class_name();
@ -2887,9 +2887,9 @@ function PMA_getHtmlForInsertEditFormColumn($table_columns, $column_number,
$include_file = 'libraries/plugins/transformations/' . $file;
if (is_file($include_file)) {
include_once $include_file;
$class_name = PMA_getTransformationClassName($include_file);
$class_name = Transformations::getClassName($include_file);
$transformation_plugin = new $class_name();
$transformation_options = PMA_Transformation_getOptions(
$transformation_options = Transformations::getOptions(
$column_mime['input_transformation_options']
);
$_url_params = array(
@ -2977,7 +2977,7 @@ function PMA_getHtmlForInsertEditRow($url_params, $table_columns,
//store the default value for CharEditing
$default_char_editing = $GLOBALS['cfg']['CharEditing'];
$mime_map = PMA_getMIME($db, $table);
$mime_map = Transformations::getMIME($db, $table);
$where_clause = '';
if (isset($where_clause_array[$row_id])) {
$where_clause = $where_clause_array[$row_id];

View File

@ -12,7 +12,6 @@ if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/transformations.lib.php';
require_once 'libraries/sql.lib.php';
require_once 'libraries/mult_submits.lib.php';

View File

@ -8,6 +8,7 @@
* @package PhpMyAdmin
*/
use PMA\libraries\Table;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
/**
@ -295,11 +296,11 @@ function PMA_buildOrExecuteQueryForMulti(
$result = $GLOBALS['dbi']->query($a_query);
if ($query_type == 'drop_db') {
PMA_clearTransformations($selected[$i]);
Transformations::clear($selected[$i]);
} elseif ($query_type == 'drop_tbl') {
PMA_clearTransformations($db, $selected[$i]);
Transformations::clear($db, $selected[$i]);
} else if ($query_type == 'drop_fld') {
PMA_clearTransformations($db, $table, $selected[$i]);
Transformations::clear($db, $table, $selected[$i]);
}
} // end if
} // end for
@ -575,4 +576,3 @@ function PMA_getQueryFromSelected($what, $table, $selected, $views)
return array($full_query, $reload, $full_query_views);
}

View File

@ -6,8 +6,9 @@
* @package PhpMyAdmin
*/
use PMA\libraries\Message;
use PMA\libraries\Util;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
use PMA\libraries\Util;
/**
* build the html for columns of $colTypeCategory category
@ -78,8 +79,8 @@ function PMA_getHtmlForCreateNewColumn(
$available_mime = array();
$mime_map = array();
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mime_map = PMA_getMIME($db, $table);
$available_mime = PMA_getAvailableMIMEtypes();
$mime_map = Transformations::getMIME($db, $table);
$available_mime = Transformations::getAvailableMIMEtypes();
}
$comments_map = PMA_getComments($db, $table);
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {

View File

@ -8,15 +8,16 @@
*/
namespace PMA\libraries\plugins\export;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\properties\plugins\ExportPluginProperties;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\Util;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\options\items\RadioPropertyItem;
use PMA\libraries\properties\options\items\TextPropertyItem;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
/**
* Handles the export for the HTML-Word format
@ -409,7 +410,7 @@ class ExportHtmlword extends ExportPlugin
$schema_insert .= '<td class="print"><strong>'
. htmlspecialchars('MIME')
. '</strong></td>';
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = Transformations::getMIME($db, $table, true);
}
$schema_insert .= '</tr>';

View File

@ -8,15 +8,16 @@
*/
namespace PMA\libraries\plugins\export;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\properties\plugins\ExportPluginProperties;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\Util;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\options\items\RadioPropertyItem;
use PMA\libraries\properties\options\items\TextPropertyItem;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
/**
* Handles the export for the Latex format
@ -533,7 +534,7 @@ class ExportLatex extends ExportPlugin
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = Transformations::getMIME($db, $table, true);
}
// Table caption for first page and label

View File

@ -8,16 +8,17 @@
*/
namespace PMA\libraries\plugins\export;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\properties\plugins\ExportPluginProperties;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\Util;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\options\items\RadioPropertyItem;
use PMA\libraries\properties\options\items\TextPropertyItem;
use PMA\libraries\OpenDocument;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
$GLOBALS['odt_buffer'] = '';
@ -503,7 +504,7 @@ class ExportOdt extends ExportPlugin
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . __('MIME type') . '</text:p>'
. '</table:table-cell>';
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = Transformations::getMIME($db, $table, true);
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';

View File

@ -24,8 +24,6 @@ if (! class_exists('TCPDF')) {
return;
}
require_once 'libraries/transformations.lib.php';
/**
* Handles the export for the PDF class
*

View File

@ -8,25 +8,26 @@
*/
namespace PMA\libraries\plugins\export;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\plugins\ExportPluginProperties;
use PMA\libraries\properties\options\items\MessageOnlyPropertyItem;
use PMA\libraries\properties\options\items\NumberPropertyItem;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\properties\options\groups\OptionsPropertySubgroup;
use PMA\libraries\Charsets;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\Util;
use PMA\libraries\properties\options\items\RadioPropertyItem;
use PMA\libraries\properties\options\items\SelectPropertyItem;
use PhpMyAdmin\SqlParser\Components\CreateDefinition;
use PhpMyAdmin\SqlParser\Context;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\SelectStatement;
use PhpMyAdmin\SqlParser\Token;
use PMA\libraries\Charsets;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\properties\plugins\ExportPluginProperties;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\properties\options\groups\OptionsPropertySubgroup;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\options\items\MessageOnlyPropertyItem;
use PMA\libraries\properties\options\items\NumberPropertyItem;
use PMA\libraries\properties\options\items\RadioPropertyItem;
use PMA\libraries\properties\options\items\SelectPropertyItem;
use PMA\libraries\properties\options\items\TextPropertyItem;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
/**
* Handles the export for the SQL class
@ -1843,7 +1844,7 @@ class ExportSql extends ExportPlugin
);
if ($do_mime && $cfgRelation['mimework']) {
if (!($mime_map = PMA_getMIME($db, $table, true))) {
if (!($mime_map = Transformations::getMIME($db, $table, true))) {
unset($mime_map);
}
}

View File

@ -8,15 +8,16 @@
*/
namespace PMA\libraries\plugins\export;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\properties\plugins\ExportPluginProperties;
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\plugins\ExportPlugin;
use PMA\libraries\Util;
use PMA\libraries\properties\options\items\BoolPropertyItem;
use PMA\libraries\properties\options\items\RadioPropertyItem;
use PMA\libraries\properties\options\items\TextPropertyItem;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
/**
* Handles the export for the Texy! text class
@ -385,7 +386,7 @@ class ExportTexytext extends ExportPlugin
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . htmlspecialchars('MIME');
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = Transformations::getMIME($db, $table, true);
}
$text_output .= "\n|------\n";

View File

@ -10,6 +10,7 @@ namespace PMA\libraries\plugins\export\helpers;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\PDF as PdfLib;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
use TCPDF_STATIC;
@ -518,7 +519,7 @@ class Pdf extends PdfLib
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = Transformations::getMIME($db, $table, true);
}
$columns = $GLOBALS['dbi']->getColumns($db, $table);

View File

@ -25,8 +25,6 @@ if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
require_once 'libraries/transformations.lib.php';
/**
* Extends the "TCPDF" class and helps
* in developing the structure of PDF Schema Export

View File

@ -7,9 +7,10 @@
*/
namespace PMA\libraries\plugins\schema\pdf;
use PMA\libraries\plugins\schema\ExportRelationSchema;
use PMA\libraries\Util;
use PMA\libraries\PDF as PDF_lib;
use PMA\libraries\plugins\schema\ExportRelationSchema;
use PMA\libraries\Transformations;
use PMA\libraries\Util;
/**
* Skip the plugin if TCPDF is not available.
@ -26,8 +27,6 @@ if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
require_once 'libraries/transformations.lib.php';
/**
* Pdf Relation Schema Class
*
@ -550,7 +549,7 @@ class PdfRelationSchema extends ExportRelationSchema
$cfgRelation = PMA_getRelationsParam();
$comments = PMA_getComments($this->db, $table);
if ($cfgRelation['mimework']) {
$mime_map = PMA_getMIME($this->db, $table, true);
$mime_map = Transformations::getMIME($this->db, $table, true);
}
/**

View File

@ -14,9 +14,6 @@ if (!defined('PHPMYADMIN')) {
exit;
}
/* For PMA_Transformation_globalHtmlReplace */
require_once 'libraries/transformations.lib.php';
/**
* Provides common methods for all of the link transformations plugins.
*

View File

@ -14,9 +14,6 @@ if (!defined('PHPMYADMIN')) {
exit;
}
/* For PMA_Transformation_globalHtmlReplace */
require_once 'libraries/transformations.lib.php';
/**
* Provides common methods for all of the inline transformations plugins.
*

View File

@ -5,12 +5,14 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Bookmark;
use PMA\libraries\DisplayResults;
use PMA\libraries\Message;
use PMA\libraries\Table;
use PMA\libraries\Response;
use PMA\libraries\Table;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
use PMA\libraries\Bookmark;
/**
* Parses and analyzes the given SQL query.
@ -1297,14 +1299,13 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
*/
function PMA_deleteTransformationInfo($db, $table, $analyzed_sql_results)
{
include_once 'libraries/transformations.lib.php';
$statement = $analyzed_sql_results['statement'];
if ($statement instanceof PhpMyAdmin\SqlParser\Statements\AlterStatement) {
if (!empty($statement->altered[0])
&& $statement->altered[0]->options->has('DROP')
) {
if (!empty($statement->altered[0]->field->column)) {
PMA_clearTransformations(
Transformations::clear(
$db,
$table,
$statement->altered[0]->field->column
@ -1312,7 +1313,7 @@ function PMA_deleteTransformationInfo($db, $table, $analyzed_sql_results)
}
}
} elseif ($statement instanceof PhpMyAdmin\SqlParser\Statements\DropStatement) {
PMA_clearTransformations($db, $table);
Transformations::clear($db, $table);
}
}

View File

@ -8,6 +8,7 @@
*/
use PMA\libraries\Response;
use PMA\libraries\Table;
use PMA\libraries\Transformations;
use PMA\Util;
if (!defined('PHPMYADMIN')) {
@ -83,7 +84,6 @@ if (isset($selected) && is_array($selected)) {
$is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
$comments_map = PMA_getComments($db, $table);
@ -97,8 +97,8 @@ if (isset($fields_meta)) {
$available_mime = array();
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mime_map = PMA_getMIME($db, $table);
$available_mime = PMA_getAvailableMIMEtypes();
$mime_map = Transformations::getMIME($db, $table);
$available_mime = Transformations::getAvailableMIMEtypes();
}
// workaround for field_fulltext, because its submitted indices contain

View File

@ -1,452 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Set of functions used with the relation and pdf feature
*
* This file also provides basic functions to use in other plugins!
* 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
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Returns array of options from string with options separated by comma,
* removes quotes
*
* <code>
* PMA_Transformation_getOptions("'option ,, quoted',abd,'2,3',");
* // array {
* // 'option ,, quoted',
* // 'abc',
* // '2,3',
* // '',
* // }
* </code>
*
* @param string $option_string comma separated options
*
* @return array options
*/
function PMA_Transformation_getOptions($option_string)
{
$result = array();
if (strlen($option_string) === 0
|| ! $transform_options = preg_split('/,/', $option_string)
) {
return $result;
}
while (($option = array_shift($transform_options)) !== null) {
$trimmed = trim($option);
if (strlen($trimmed) > 1
&& $trimmed[0] == "'"
&& $trimmed[strlen($trimmed) - 1] == "'"
) {
// '...'
$option = mb_substr($trimmed, 1, -1);
} elseif (isset($trimmed[0]) && $trimmed[0] == "'") {
// '...,
$trimmed = ltrim($option);
while (($option = array_shift($transform_options)) !== null) {
// ...,
$trimmed .= ',' . $option;
$rtrimmed = rtrim($trimmed);
if ($rtrimmed[strlen($rtrimmed) - 1] == "'") {
// ,...'
break;
}
}
$option = mb_substr($rtrimmed, 1, -1);
}
$result[] = stripslashes($option);
}
return $result;
}
/**
* Gets all available MIME-types
*
* @access public
* @staticvar array mimetypes
* @return array array[mimetype], array[transformation]
*/
function PMA_getAvailableMIMEtypes()
{
static $stack = null;
if (null !== $stack) {
return $stack;
}
$stack = array();
$sub_dirs = array(
'input/' => 'input_',
'output/' => '',
'' => ''
);
foreach ($sub_dirs as $sd => $prefix) {
$handle = opendir('libraries/plugins/transformations/' . $sd);
if (! $handle) {
$stack[$prefix . 'transformation'] = array();
$stack[$prefix . 'transformation_file'] = array();
continue;
}
$filestack = array();
while ($file = readdir($handle)) {
// Ignore hidden files
if ($file[0] == '.') {
continue;
}
// Ignore old plugins (.class in filename)
if (strpos($file, '.class') !== false) {
continue;
}
$filestack[] = $file;
}
closedir($handle);
sort($filestack);
foreach ($filestack as $file) {
if (preg_match('|^[^.].*_.*_.*\.php$|', $file)) {
// File contains transformation functions.
$parts = explode('_', str_replace('.php', '', $file));
$mimetype = $parts[0] . "/" . $parts[1];
$stack['mimetype'][$mimetype] = $mimetype;
$stack[$prefix . 'transformation'][] = $mimetype . ': ' . $parts[2];
$stack[$prefix . 'transformation_file'][] = $sd . $file;
if ($sd === '') {
$stack['input_transformation'][] = $mimetype . ': ' . $parts[2];
$stack['input_transformation_file'][] = $sd . $file;
}
} elseif (preg_match('|^[^.].*\.php$|', $file)) {
// File is a plain mimetype, no functions.
$base = str_replace('.php', '', $file);
if ($base != 'global') {
$mimetype = str_replace('_', '/', $base);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['empty_mimetype'][$mimetype] = $mimetype;
}
}
}
}
return $stack;
}
/**
* Returns the class name of the transformation
*
* @param string $filename transformation file name
*
* @return string the class name of transformation
*/
function PMA_getTransformationClassName($filename)
{
// get the transformation class name
$class_name = explode(".php", $filename);
$class_name = 'PMA\\' . str_replace('/', '\\', $class_name[0]);
return $class_name;
}
/**
* Returns the description of the transformation
*
* @param string $file transformation file
*
* @return String the description of the transformation
*/
function PMA_getTransformationDescription($file)
{
$include_file = 'libraries/plugins/transformations/' . $file;
/* @var $class_name PMA\libraries\plugins\TransformationsInterface */
$class_name = PMA_getTransformationClassName($include_file);
// include and instantiate the class
include_once $include_file;
return $class_name::getInfo();
}
/**
* Returns the name of the transformation
*
* @param string $file transformation file
*
* @return String the name of the transformation
*/
function PMA_getTransformationName($file)
{
$include_file = 'libraries/plugins/transformations/' . $file;
/* @var $class_name PMA\libraries\plugins\TransformationsInterface */
$class_name = PMA_getTransformationClassName($include_file);
// include and instantiate the class
include_once $include_file;
return $class_name::getName();
}
/**
* Gets the mimetypes for all columns of a table
*
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
* @param boolean $strict whether to include only results having a mimetype set
* @param boolean $fullName whether to use full column names as the key
*
* @access public
*
* @return array [field_name][field_key] = field_value
*/
function PMA_getMIME($db, $table, $strict = false, $fullName = false)
{
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['commwork']) {
return false;
}
$com_qry = '';
if ($fullName) {
$com_qry .= "SELECT CONCAT("
. "`db_name`, '.', `table_name`, '.', `column_name`"
. ") AS column_name, ";
} else {
$com_qry = "SELECT `column_name`, ";
}
$com_qry .= '`mimetype`,
`transformation`,
`transformation_options`,
`input_transformation`,
`input_transformation_options`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
AND ( `mimetype` != \'\'' . (!$strict ? '
OR `transformation` != \'\'
OR `transformation_options` != \'\'
OR `input_transformation` != \'\'
OR `input_transformation_options` != \'\'' : '') . ')';
$result = $GLOBALS['dbi']->fetchResult(
$com_qry, 'column_name', null, $GLOBALS['controllink']
);
foreach ($result as $column => $values) {
// replacements in mimetype and transformation
$values = str_replace("jpeg", "JPEG", $values);
$values = str_replace("png", "PNG", $values);
// convert mimetype to new format (f.e. Text_Plain, etc)
$delimiter_space = '- ';
$delimiter = "_";
$values['mimetype'] = str_replace(
$delimiter_space,
$delimiter,
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$values['mimetype']
)
)
);
// For transformation of form
// output/image_jpeg__inline.inc.php
// extract dir part.
$dir = explode('/', $values['transformation']);
$subdir = '';
if (count($dir) === 2) {
$subdir = $dir[0] . '/';
$values['transformation'] = $dir[1];
}
$values['transformation'] = str_replace(
$delimiter_space,
$delimiter,
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$values['transformation']
)
)
);
$values['transformation'] = $subdir . $values['transformation'];
$result[$column] = $values;
}
return $result;
} // end of the 'PMA_getMIME()' function
/**
* Set a single mimetype to a certain value.
*
* @param string $db the name of the db
* @param string $table the name of the table
* @param string $key the name of the column
* @param string $mimetype the mimetype of the column
* @param string $transformation the transformation of the column
* @param string $transformationOpts the transformation options of the column
* @param string $inputTransform the input transformation of the column
* @param string $inputTransformOpts the input transformation options of the column
* @param boolean $forcedelete force delete, will erase any existing
* comments for this column
*
* @access public
*
* @return boolean true, if comment-query was made.
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
$transformationOpts, $inputTransform, $inputTransformOpts, $forcedelete = false
) {
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['commwork']) {
return false;
}
// lowercase mimetype & transformation
$mimetype = mb_strtolower($mimetype);
$transformation = mb_strtolower($transformation);
$test_qry = '
SELECT `mimetype`,
`comment`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key) . '\'';
$test_rs = PMA_queryAsControlUser(
$test_qry, true, PMA\libraries\DatabaseInterface::QUERY_STORE
);
if ($test_rs && $GLOBALS['dbi']->numRows($test_rs) > 0) {
$row = @$GLOBALS['dbi']->fetchAssoc($test_rs);
$GLOBALS['dbi']->freeResult($test_rs);
if (! $forcedelete
&& (strlen($mimetype) > 0
|| strlen($transformation) > 0
|| strlen($transformationOpts) > 0
|| strlen($row['comment']) > 0)
) {
$upd_query = 'UPDATE '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' SET '
. '`mimetype` = \''
. $GLOBALS['dbi']->escapeString($mimetype) . '\', '
. '`transformation` = \''
. $GLOBALS['dbi']->escapeString($transformation) . '\', '
. '`transformation_options` = \''
. $GLOBALS['dbi']->escapeString($transformationOpts) . '\', '
. '`input_transformation` = \''
. $GLOBALS['dbi']->escapeString($inputTransform) . '\', '
. '`input_transformation_options` = \''
. $GLOBALS['dbi']->escapeString($inputTransformOpts) . '\'';
} else {
$upd_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['column_info']);
}
$upd_query .= '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key)
. '\'';
} elseif (strlen($mimetype) > 0
|| strlen($transformation) > 0
|| strlen($transformationOpts) > 0
) {
$upd_query = 'INSERT INTO '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, '
. 'transformation, transformation_options, '
. 'input_transformation, input_transformation_options) '
. ' VALUES('
. '\'' . $GLOBALS['dbi']->escapeString($db) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($table) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($key) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($mimetype) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($transformation) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($transformationOpts) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($inputTransform) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($inputTransformOpts) . '\')';
}
if (isset($upd_query)) {
return PMA_queryAsControlUser($upd_query);
} else {
return false;
}
} // end of 'PMA_setMIME()' function
/**
* GLOBAL Plugin functions
*/
/**
* Delete related transformation details
* after deleting database. table or column
*
* @param string $db Database name
* @param string $table Table name
* @param string $column Column name
*
* @return boolean State of the query execution
*/
function PMA_clearTransformations($db, $table = '', $column = '')
{
$cfgRelation = PMA_getRelationsParam();
if (! isset($cfgRelation['column_info'])) {
return false;
}
$delete_sql = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' WHERE ';
if (($column != '') && ($table != '')) {
$delete_sql .= '`db_name` = \'' . $db . '\' AND '
. '`table_name` = \'' . $table . '\' AND '
. '`column_name` = \'' . $column . '\' ';
} else if ($table != '') {
$delete_sql .= '`db_name` = \'' . $db . '\' AND '
. '`table_name` = \'' . $table . '\' ';
} else {
$delete_sql .= '`db_name` = \'' . $db . '\' ';
}
return $GLOBALS['dbi']->tryQuery($delete_sql);
}

View File

@ -12,7 +12,6 @@ use PMA\libraries\Response;
*
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/transformations.lib.php';
require_once 'libraries/normalization.lib.php';
if (isset($_REQUEST['getColumns'])) {

View File

@ -5,8 +5,10 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\URL;
use PMA\libraries\Response;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
/**
* Get some core libraries
@ -65,9 +67,6 @@ if (isset($_REQUEST['do_save_data'])) {
list($result, $sql_query) = PMA_tryColumnCreationQuery($db, $table, $err_url);
if ($result === true) {
// If comments were sent, enable relation stuff
include_once 'libraries/transformations.lib.php';
// Update comment table for mime types [MIME]
if (isset($_REQUEST['field_mimetype'])
&& is_array($_REQUEST['field_mimetype'])
@ -77,7 +76,7 @@ if (isset($_REQUEST['do_save_data'])) {
if (isset($_REQUEST['field_name'][$fieldindex])
&& strlen($_REQUEST['field_name'][$fieldindex]) > 0
) {
PMA_setMIME(
Transformations::setMIME(
$db, $table,
$_REQUEST['field_name'][$fieldindex],
$mimetype,

View File

@ -28,7 +28,6 @@ require_once 'libraries/db_table_exists.inc.php';
* functions implementation for this script
*/
require_once 'libraries/insert_edit.lib.php';
require_once 'libraries/transformations.lib.php';
/**
* Determine whether Insert or Edit and set global variables

View File

@ -5,8 +5,10 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\URL;
use PMA\libraries\Response;
use PMA\libraries\Transformations;
use PMA\libraries\URL;
/**
* Get some core libraries
@ -66,8 +68,6 @@ if (isset($_REQUEST['do_save_data'])) {
$result = $GLOBALS['dbi']->tryQuery($sql_query);
if ($result) {
// If comments were sent, enable relation stuff
include_once 'libraries/transformations.lib.php';
// Update comment table for mime types [MIME]
if (isset($_REQUEST['field_mimetype'])
&& is_array($_REQUEST['field_mimetype'])
@ -77,7 +77,7 @@ if (isset($_REQUEST['do_save_data'])) {
if (isset($_REQUEST['field_name'][$fieldindex])
&& strlen($_REQUEST['field_name'][$fieldindex]) > 0
) {
PMA_setMIME(
Transformations::setMIME(
$db, $table,
$_REQUEST['field_name'][$fieldindex], $mimetype,
$_REQUEST['field_transformation'][$fieldindex],

View File

@ -14,6 +14,7 @@
use PMA\libraries\plugins\IOTransformationsPlugin;
use PMA\libraries\Response;
use PMA\libraries\Table;
use PMA\libraries\Transformations;
/**
* Gets some core libraries
@ -24,7 +25,6 @@ require_once 'libraries/common.inc.php';
* functions implementation for this script
*/
require_once 'libraries/insert_edit.lib.php';
require_once 'libraries/transformations.lib.php';
// Check parameters
PMA\libraries\Util::checkParameters(array('db', 'table', 'goto'));
@ -127,7 +127,7 @@ $gis_from_wkb_functions = array(
);
//if some posted fields need to be transformed.
$mime_map = PMA_getMIME($GLOBALS['db'], $GLOBALS['table']);
$mime_map = Transformations::getMIME($GLOBALS['db'], $GLOBALS['table']);
if ($mime_map === false) {
$mime_map = array();
}
@ -219,10 +219,10 @@ foreach ($loop_array as $rownumber => $where_clause) {
. $mime_map[$column_name]['input_transformation'];
if (is_file($filename)) {
include_once $filename;
$classname = PMA_getTransformationClassName($filename);
$classname = Transformations::getClassName($filename);
/** @var IOTransformationsPlugin $transformation_plugin */
$transformation_plugin = new $classname();
$transformation_options = PMA_Transformation_getOptions(
$transformation_options = Transformations::getOptions(
$mime_map[$column_name]['input_transformation_options']
);
$current_value = $transformation_plugin->applyTransformation(

View File

@ -1,3 +1,4 @@
<?php use PMA\libraries\Transformations; ?>
<select id="field_<?= $columnNumber; ?>_<?= ($ci - $ci_offset); ?>"
size="1"
name="field_<?= $type;?>[<?= $columnNumber;?>]">
@ -9,11 +10,11 @@
&& isset($mime_map[$columnMeta['Field']][$type])
&& preg_match('@' . preg_quote($available_mime[$type . '_file'][$mimekey], '@') . '3?@i',
$mime_map[$columnMeta['Field']][$type]) ? 'selected ' : '';
$tooltip = PMA_getTransformationDescription(
$tooltip = Transformations::getDescription(
$available_mime[$type . '_file'][$mimekey]
);
$parts = explode(":", $transform);
$name = PMA_getTransformationName(
$name = Transformations::getName(
$available_mime[$type . '_file'][$mimekey]
) . ' (' . strtolower($parts[0]) . ":" . $parts[1] . ')';
?>

View File

@ -7,11 +7,11 @@
*/
use PMA\libraries\Theme;
use PMA\libraries\Transformations;
/*
* Include to test.
*/
require_once 'libraries/transformations.lib.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/relation.lib.php';
@ -20,9 +20,8 @@ require_once 'libraries/relation.lib.php';
*
* @package PhpMyAdmin-test
*/
class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
class TransformationsTest extends PHPUnit_Framework_TestCase
{
/**
* Set up global environment.
*
@ -63,7 +62,7 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
{
$this->assertEquals(
$expected,
PMA_Transformation_getOptions($input)
Transformations::getOptions($input)
);
}
@ -168,7 +167,7 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
'Text_Plain_Substring.php',
),
),
PMA_getAvailableMIMEtypes()
Transformations::getAvailableMIMEtypes()
);
}
@ -203,16 +202,16 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
'input_transformation_options' => '',
),
),
PMA_getMIME('pma_test', 'table1')
Transformations::getMIME('pma_test', 'table1')
);
}
/**
* Test for PMA_clearTransformations
* Test for Transformations::clear
*
* @return void
*/
public function testClearTransformations()
public function testClear()
{
// Mock dbi
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
@ -224,7 +223,7 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
$GLOBALS['dbi'] = $dbi;
// Case 1 : no configuration storage
$actual = PMA_clearTransformations('db');
$actual = Transformations::clear('db');
$this->assertEquals(
false,
$actual
@ -235,21 +234,21 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
$_SESSION['relation'][$GLOBALS['server']]['db'] = "pmadb";
// Case 2 : database delete
$actual = PMA_clearTransformations('db');
$actual = Transformations::clear('db');
$this->assertEquals(
true,
$actual
);
// Case 3 : table delete
$actual = PMA_clearTransformations('db', 'table');
$actual = Transformations::clear('db', 'table');
$this->assertEquals(
true,
$actual
);
// Case 4 : column delete
$actual = PMA_clearTransformations('db', 'table', 'col');
$actual = Transformations::clear('db', 'table', 'col');
$this->assertEquals(
true,
$actual

View File

@ -10,7 +10,6 @@ use PMA\libraries\plugins\export\ExportHtmlword;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/transformations.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -10,7 +10,6 @@ use PMA\libraries\plugins\export\ExportLatex;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/transformations.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -12,7 +12,6 @@ require_once 'libraries/plugins/export/ExportOdt.php';
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/transformations.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -11,7 +11,6 @@ use PMA\libraries\Table;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/transformations.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -10,7 +10,6 @@ use PMA\libraries\plugins\export\ExportTexytext;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/transformations.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -12,7 +12,6 @@ use PMA\libraries\plugins\schema\pdf\PdfRelationSchema;
require_once 'libraries/relation.lib.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/transformations.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -18,7 +18,6 @@ use PMA\libraries\TypesMySQL;
require_once 'libraries/insert_edit.lib.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/transformations.lib.php';
/**
* Tests for libraries/insert_edit.lib.php

View File

@ -5,19 +5,20 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Response;
use PMA\libraries\Transformations;
/**
* Gets some core libraries and displays a top message if required
*/
require_once './libraries/common.inc.php';
require_once './libraries/transformations.lib.php';
$response = Response::getInstance();
$header = $response->getHeader();
$header->disableMenuAndConsole();
$types = PMA_getAvailableMIMEtypes();
$types = Transformations::getAvailableMIMEtypes();
?>
<h2><?php echo __('Available MIME types'); ?></h2>
@ -57,7 +58,7 @@ $th = array(
<tbody>
<?php
foreach ($types[$ttype] as $key => $transform) {
$desc = PMA_getTransformationDescription($types[$ttype . '_file'][$key]);
$desc = Transformations::getDescription($types[$ttype . '_file'][$key]);
?>
<tr>
<td><?php echo htmlspecialchars($transform); ?></td>

View File

@ -5,7 +5,9 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Response;
use PMA\libraries\Transformations;
/**
*
@ -16,7 +18,7 @@ define('IS_TRANSFORMATION_WRAPPER', true);
* Gets a core script and starts output buffering work
*/
require_once './libraries/common.inc.php';
require_once './libraries/transformations.lib.php'; // Transformations
$cfgRelation = PMA_getRelationsParam();
/**
@ -82,8 +84,8 @@ if (! $row) {
$default_ct = 'application/octet-stream';
if ($cfgRelation['commwork'] && $cfgRelation['mimework']) {
$mime_map = PMA_getMime($db, $table);
$mime_options = PMA_Transformation_getOptions(
$mime_map = Transformations::getMIME($db, $table);
$mime_options = Transformations::getOptions(
isset($mime_map[$transform_key]['transformation_options'])
? $mime_map[$transform_key]['transformation_options'] : ''
);