diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php
index 3f2b600bab..6a8e80fb03 100644
--- a/libraries/classes/CentralColumns.php
+++ b/libraries/classes/CentralColumns.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Charsets\Charset;
use PhpMyAdmin\Charsets\Collation;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
/**
@@ -934,14 +935,14 @@ class CentralColumns
'text_dir' => $text_dir,
'form_name' => 'tableslistcontainer',
]);
- $html_output .= Util::getButtonOrImage(
+ $html_output .= Generator::getButtonOrImage(
'edit_central_columns',
'mult_submit change_central_columns',
__('Edit'),
'b_edit',
'edit central columns'
);
- $html_output .= Util::getButtonOrImage(
+ $html_output .= Generator::getButtonOrImage(
'delete_central_columns',
'mult_submit',
__('Delete'),
diff --git a/libraries/classes/Config/FormDisplay.php b/libraries/classes/Config/FormDisplay.php
index 79ad04d4d4..0e69a89cd7 100644
--- a/libraries/classes/Config/FormDisplay.php
+++ b/libraries/classes/Config/FormDisplay.php
@@ -16,6 +16,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config\Forms\User\UserFormList;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Util;
@@ -785,7 +786,7 @@ class FormDisplay
if ($test == 'Import' || $test == 'Export') {
return '';
}
- return Util::getDocuLink(
+ return MySQLDocumentation::getDocumentationLink(
'config',
'cfg_' . $this->_getOptName($path)
);
diff --git a/libraries/classes/Config/FormDisplayTemplate.php b/libraries/classes/Config/FormDisplayTemplate.php
index b680d635a1..c31d7c91a0 100644
--- a/libraries/classes/Config/FormDisplayTemplate.php
+++ b/libraries/classes/Config/FormDisplayTemplate.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
@@ -229,7 +230,7 @@ class FormDisplayTemplate
} else {
// In this case we just use getImage() because it's available
foreach ($iconInit as $k => $v) {
- $icons[$k] = Util::getImage(
+ $icons[$k] = Generator::getImage(
$v[0],
$v[1]
);
diff --git a/libraries/classes/Console.php b/libraries/classes/Console.php
index 28fcde1af7..cc0190de91 100644
--- a/libraries/classes/Console.php
+++ b/libraries/classes/Console.php
@@ -139,7 +139,7 @@ class Console
$GLOBALS['cfg']['Server']['user']
);
- $image = Util::getImage('console', __('SQL Query Console'));
+ $image = Html\Generator::getImage('console', __('SQL Query Console'));
$_sql_history = $this->relation->getHistory(
$GLOBALS['cfg']['Server']['user']
);
diff --git a/libraries/classes/Controllers/Database/RoutinesController.php b/libraries/classes/Controllers/Database/RoutinesController.php
index e4e72e0ecc..020bcdebdf 100644
--- a/libraries/classes/Controllers/Database/RoutinesController.php
+++ b/libraries/classes/Controllers/Database/RoutinesController.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Database;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Rte\Routines;
use PhpMyAdmin\Util;
diff --git a/libraries/classes/Controllers/Database/StructureController.php b/libraries/classes/Controllers/Database/StructureController.php
index a7481c0cc1..f9c01434c5 100644
--- a/libraries/classes/Controllers/Database/StructureController.php
+++ b/libraries/classes/Controllers/Database/StructureController.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Display\CreateTable;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
use PhpMyAdmin\Relation;
@@ -97,17 +98,8 @@ class StructureController extends AbstractController
*/
private function getDatabaseInfo(string $subPart): void
{
- list(
- $tables,
- $numTables,
- $totalNumTables,
- ,
- $isShowStats,
- $dbIsSystemSchema,
- ,
- ,
- $position
- ) = Util::getDbInfo($this->db, $subPart);
+ [$tables, $numTables, $totalNumTables,, $isShowStats, $dbIsSystemSchema,,, $position]
+ = Util::getDbInfo($this->db, $subPart);
$this->tables = $tables;
$this->numTables = $numTables;
@@ -171,7 +163,7 @@ class StructureController extends AbstractController
if (isset($parameters['sort_order'])) {
$urlParams['sort_order'] = $parameters['sort_order'];
}
- $listNavigator = Util::getListNavigator(
+ $listNavigator = Generator::getListNavigator(
$this->totalNumTables,
$this->position,
$urlParams,
@@ -395,13 +387,20 @@ class StructureController extends AbstractController
];
// do not list the previous table's size info for a view
- list($current_table, $formatted_size, $unit, $formatted_overhead,
- $overhead_unit, $overhead_size, $table_is_view, $sum_size)
- = $this->getStuffForEngineTypeTable(
- $current_table,
- $sum_size,
- $overhead_size
- );
+ [
+ $current_table,
+ $formatted_size,
+ $unit,
+ $formatted_overhead,
+ $overhead_unit,
+ $overhead_size,
+ $table_is_view,
+ $sum_size,
+ ] = $this->getStuffForEngineTypeTable(
+ $current_table,
+ $sum_size,
+ $overhead_size
+ );
$curTable = $this->dbi
->getTable($this->db, $current_table['TABLE_NAME']);
@@ -544,12 +543,12 @@ class StructureController extends AbstractController
$structure_table_rows = [];
}
- list($approx_rows, $show_superscript) = $this->isRowCountApproximated(
+ [$approx_rows, $show_superscript] = $this->isRowCountApproximated(
$current_table,
$table_is_view
);
- list($do, $ignored) = $this->getReplicationStatus($truename);
+ [$do, $ignored] = $this->getReplicationStatus($truename);
$structure_table_rows[] = [
'table_name_hash' => md5($current_table['TABLE_NAME']),
@@ -739,7 +738,7 @@ class StructureController extends AbstractController
&& $current_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews']
) {
$approx_rows = true;
- $show_superscript = Util::showHint(
+ $show_superscript = Generator::showHint(
Sanitize::sanitizeMessage(
sprintf(
__(
@@ -928,9 +927,15 @@ class StructureController extends AbstractController
case 'ARCHIVE':
case 'Aria':
case 'Maria':
- list($current_table, $formatted_size, $unit, $formatted_overhead,
- $overhead_unit, $overhead_size, $sum_size)
- = $this->getValuesForAriaTable(
+ [
+ $current_table,
+ $formatted_size,
+ $unit,
+ $formatted_overhead,
+ $overhead_unit,
+ $overhead_size,
+ $sum_size,
+ ] = $this->getValuesForAriaTable(
$current_table,
$sum_size,
$overhead_size,
@@ -946,7 +951,7 @@ class StructureController extends AbstractController
// InnoDB table: Row count is not accurate but data and index sizes are.
// PBMS table in Drizzle: TABLE_ROWS is taken from table cache,
// so it may be unavailable
- list($current_table, $formatted_size, $unit, $sum_size)
+ [$current_table, $formatted_size, $unit, $sum_size]
= $this->getValuesForInnodbTable(
$current_table,
$sum_size
@@ -1033,7 +1038,7 @@ class StructureController extends AbstractController
$tblsize = $current_table['Data_length']
+ $current_table['Index_length'];
$sum_size += $tblsize;
- list($formatted_size, $unit) = Util::formatByteDown(
+ [$formatted_size, $unit] = Util::formatByteDown(
$tblsize,
3,
$tblsize > 0 ? 1 : 0
@@ -1041,7 +1046,7 @@ class StructureController extends AbstractController
if (isset($current_table['Data_free'])
&& $current_table['Data_free'] > 0
) {
- list($formatted_overhead, $overhead_unit)
+ [$formatted_overhead, $overhead_unit]
= Util::formatByteDown(
$current_table['Data_free'],
3,
@@ -1091,7 +1096,7 @@ class StructureController extends AbstractController
$tblsize = $current_table['Data_length']
+ $current_table['Index_length'];
$sum_size += $tblsize;
- list($formatted_size, $unit) = Util::formatByteDown(
+ [$formatted_size, $unit] = Util::formatByteDown(
$tblsize,
3,
($tblsize > 0 ? 1 : 0)
diff --git a/libraries/classes/Controllers/HomeController.php b/libraries/classes/Controllers/HomeController.php
index e8ed894e3c..0f8af98bcc 100644
--- a/libraries/classes/Controllers/HomeController.php
+++ b/libraries/classes/Controllers/HomeController.php
@@ -15,6 +15,7 @@ use PhpMyAdmin\CheckUserPrivileges;
use PhpMyAdmin\Config;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Display\GitRevision;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
@@ -84,7 +85,7 @@ class HomeController extends AbstractController
$languageManager = LanguageManager::getInstance();
if (! empty($message)) {
- $displayMessage = Util::getMessage($message);
+ $displayMessage = Generator::getMessage($message);
unset($message);
}
if (isset($_SESSION['partial_logout'])) {
@@ -114,7 +115,7 @@ class HomeController extends AbstractController
if (($cfg['Server']['auth_type'] != 'config') && $cfg['ShowChgPassword']) {
$changePassword = $this->template->render('list/item', [
- 'content' => Util::getImage('s_passwd') . ' ' . __(
+ 'content' => Generator::getImage('s_passwd') . ' ' . __(
'Change password'
),
'id' => 'li_change_password',
@@ -151,7 +152,7 @@ class HomeController extends AbstractController
}
$userPreferences = $this->template->render('list/item', [
- 'content' => Util::getImage('b_tblops') . ' ' . __(
+ 'content' => Generator::getImage('b_tblops') . ' ' . __(
'More settings'
),
'id' => 'li_user_preferences',
@@ -197,7 +198,7 @@ class HomeController extends AbstractController
$databaseServer = [
'host' => $hostInfo,
'type' => Util::getServerType(),
- 'connection' => Util::getServerSSL(),
+ 'connection' => Generator::getServerSSL(),
'version' => $this->dbi->getVersionString() . ' - ' . $this->dbi->getVersionComment(),
'protocol' => $this->dbi->getProtoInfo(),
'user' => $this->dbi->fetchValue('SELECT USER();'),
diff --git a/libraries/classes/Controllers/Server/BinlogController.php b/libraries/classes/Controllers/Server/BinlogController.php
index 03474733e5..3f5a8ef1d1 100644
--- a/libraries/classes/Controllers/Server/BinlogController.php
+++ b/libraries/classes/Controllers/Server/BinlogController.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin\Controllers\Server;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
@@ -112,7 +113,7 @@ class BinlogController extends AbstractController
'url_params' => $urlParams,
'binary_logs' => $this->binaryLogs,
'log' => $params['log'],
- 'sql_message' => Util::getMessage(Message::success(), $sqlQuery),
+ 'sql_message' => Generator::getMessage(Message::success(), $sqlQuery),
'values' => $values,
'has_previous' => $position > 0,
'has_next' => $numRows >= $cfg['MaxRows'],
diff --git a/libraries/classes/Controllers/Server/DatabasesController.php b/libraries/classes/Controllers/Server/DatabasesController.php
index 475f876e55..c35d303bd1 100644
--- a/libraries/classes/Controllers/Server/DatabasesController.php
+++ b/libraries/classes/Controllers/Server/DatabasesController.php
@@ -14,6 +14,7 @@ use PhpMyAdmin\Charsets\Collation;
use PhpMyAdmin\CheckUserPrivileges;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
@@ -192,7 +193,7 @@ class DatabasesController extends AbstractController
*/
$sqlQuery = 'CREATE DATABASE ' . Util::backquote($params['new_db']);
if (! empty($params['db_collation'])) {
- list($databaseCharset) = explode('_', $params['db_collation']);
+ [$databaseCharset] = explode('_', $params['db_collation']);
$charsets = Charsets::getCharsets(
$this->dbi,
$cfg['Server']['DisableIS']
@@ -233,7 +234,7 @@ class DatabasesController extends AbstractController
$json = [
'message' => $message,
- 'sql_query' => Util::getMessage(null, $sqlQuery, 'success'),
+ 'sql_query' => Generator::getMessage(null, $sqlQuery, 'success'),
'url_query' => $scriptName . Url::getCommon(
['db' => $params['new_db']],
strpos($scriptName, '?') === false ? '?' : '&'
diff --git a/libraries/classes/Controllers/Server/Status/ProcessesController.php b/libraries/classes/Controllers/Server/Status/ProcessesController.php
index 8a788fe19c..33d91aa02f 100644
--- a/libraries/classes/Controllers/Server/Status/ProcessesController.php
+++ b/libraries/classes/Controllers/Server/Status/ProcessesController.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server\Status;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Util;
@@ -237,7 +238,7 @@ class ProcessesController extends AbstractController
'time' => $process['Time'],
'state' => ! empty($process['State']) ? $process['State'] : '---',
'progress' => ! empty($process['Progress']) ? $process['Progress'] : '---',
- 'info' => ! empty($process['Info']) ? Util::formatSql(
+ 'info' => ! empty($process['Info']) ? Generator::formatSql(
$process['Info'],
! $showFullSql
) : '---',
diff --git a/libraries/classes/Controllers/Server/Status/VariablesController.php b/libraries/classes/Controllers/Server/Status/VariablesController.php
index f7ecffe696..f20ca286e2 100644
--- a/libraries/classes/Controllers/Server/Status/VariablesController.php
+++ b/libraries/classes/Controllers/Server/Status/VariablesController.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server\Status;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Util;
/**
@@ -79,7 +80,7 @@ class VariablesController extends AbstractController
// Fields containing % are calculated,
// they can not be described in MySQL documentation
if (mb_strpos($name, '%') === false) {
- $variables[$name]['doc'] = Util::linkToVarDocumentation(
+ $variables[$name]['doc'] = Generator::linkToVarDocumentation(
$name,
$this->dbi->isMariaDB()
);
diff --git a/libraries/classes/Controllers/Server/VariablesController.php b/libraries/classes/Controllers/Server/VariablesController.php
index 89cd9f3d70..038bcfba62 100644
--- a/libraries/classes/Controllers/Server/VariablesController.php
+++ b/libraries/classes/Controllers/Server/VariablesController.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;
use PhpMyAdmin\Controllers\AbstractController;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Util;
use Williamdes\MariaDBMySQLKBS\KBException;
use Williamdes\MariaDBMySQLKBS\Search as KBSearch;
@@ -54,15 +55,17 @@ class VariablesController extends AbstractController
foreach ($serverVars as $name => $value) {
$hasSessionValue = isset($serverVarsSession[$name])
&& $serverVarsSession[$name] !== $value;
- $docLink = Util::linkToVarDocumentation(
+ $docLink = Generator::linkToVarDocumentation(
$name,
$this->dbi->isMariaDB(),
str_replace('_', ' ', $name)
);
- list($formattedValue, $isEscaped) = $this->formatVariable($name, $value);
+ [$formattedValue, $isEscaped] = $this->formatVariable($name, $value);
if ($hasSessionValue) {
- list($sessionFormattedValue, ) = $this->formatVariable(
+ [
+ $sessionFormattedValue,
+ ] = $this->formatVariable(
$name,
$serverVarsSession[$name]
);
@@ -187,7 +190,7 @@ class VariablesController extends AbstractController
. '";',
'NUM'
);
- list($formattedValue, $isHtmlFormatted) = $this->formatVariable(
+ [$formattedValue, $isHtmlFormatted] = $this->formatVariable(
$params['varName'],
$varValue[1]
);
diff --git a/libraries/classes/Controllers/Table/IndexesController.php b/libraries/classes/Controllers/Table/IndexesController.php
index 263bed964d..8afb823765 100644
--- a/libraries/classes/Controllers/Table/IndexesController.php
+++ b/libraries/classes/Controllers/Table/IndexesController.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
@@ -158,7 +159,7 @@ class IndexesController extends AbstractController
$message->addParam($this->table);
$this->response->addJSON(
'message',
- Util::getMessage($message, $sql_query, 'success')
+ Generator::getMessage($message, $sql_query, 'success')
);
$this->response->addJSON(
'index_table',
diff --git a/libraries/classes/Controllers/Table/RelationController.php b/libraries/classes/Controllers/Table/RelationController.php
index 5c384bfe57..146706f44f 100644
--- a/libraries/classes/Controllers/Table/RelationController.php
+++ b/libraries/classes/Controllers/Table/RelationController.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Index;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
@@ -230,7 +231,7 @@ class RelationController extends AbstractController
)
) {
$this->response->addHTML(
- Util::getMessage(
+ Generator::getMessage(
__('Display column was successfully updated.'),
'',
'success'
@@ -256,7 +257,7 @@ class RelationController extends AbstractController
// foreign db is not the same)
if (isset($_POST['destination_foreign_db'], $_POST['destination_foreign_table'])
&& isset($_POST['destination_foreign_column'])) {
- list($html, $preview_sql_data, $display_query, $seen_error)
+ [$html, $preview_sql_data, $display_query, $seen_error]
= $this->upd_query->updateForeignKeys(
$_POST['destination_foreign_db'],
$multi_edit_columns_name,
@@ -279,7 +280,7 @@ class RelationController extends AbstractController
if (! empty($display_query) && ! $seen_error) {
$GLOBALS['display_query'] = $display_query;
$this->response->addHTML(
- Util::getMessage(
+ Generator::getMessage(
__('Your SQL query has been executed successfully.'),
null,
'success'
@@ -309,7 +310,7 @@ class RelationController extends AbstractController
)
) {
$this->response->addHTML(
- Util::getMessage(
+ Generator::getMessage(
__('Internal relationships were successfully updated.'),
'',
'success'
diff --git a/libraries/classes/Controllers/Table/SearchController.php b/libraries/classes/Controllers/Table/SearchController.php
index 5f571082e2..d6e9f6fda7 100644
--- a/libraries/classes/Controllers/Table/SearchController.php
+++ b/libraries/classes/Controllers/Table/SearchController.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
use PhpMyAdmin\Sql;
@@ -375,7 +376,7 @@ class SearchController extends AbstractController
//Displays form for point data and scatter plot
$titles = [
- 'Browse' => Util::getIcon(
+ 'Browse' => Generator::getIcon(
'b_browse',
__('Browse foreign values')
),
@@ -629,7 +630,7 @@ class SearchController extends AbstractController
$this->_connectionCharSet
);
$this->response->addHTML(
- Util::getMessage(
+ Generator::getMessage(
__('Your SQL query has been executed successfully.'),
null,
'success'
@@ -933,7 +934,7 @@ class SearchController extends AbstractController
$entered_value = (isset($_POST['criteriaValues'])
? $_POST['criteriaValues'] : '');
$titles = [
- 'Browse' => Util::getIcon(
+ 'Browse' => Generator::getIcon(
'b_browse',
__('Browse foreign values')
),
diff --git a/libraries/classes/Controllers/Table/StructureController.php b/libraries/classes/Controllers/Table/StructureController.php
index 011a5853c4..922a3dba4b 100644
--- a/libraries/classes/Controllers/Table/StructureController.php
+++ b/libraries/classes/Controllers/Table/StructureController.php
@@ -16,6 +16,7 @@ use PhpMyAdmin\Core;
use PhpMyAdmin\CreateAddField;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Engines\Innodb;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\ParseAnalyze;
@@ -252,16 +253,18 @@ class StructureController extends AbstractController
// handle confirmation of deleting multiple columns
$action = Url::getFromRoute('/table/structure');
$GLOBALS['selected'] = $_POST['selected_fld'];
- list(
- $what_ret, $query_type_ret, $is_unset_submit_mult,
- $mult_btn_ret, $centralColsError
- )
- = $this->getDataForSubmitMult(
- $submit_mult,
- $_POST['selected_fld'],
- $action,
- $containerBuilder
- );
+ [
+ $what_ret,
+ $query_type_ret,
+ $is_unset_submit_mult,
+ $mult_btn_ret,
+ $centralColsError,
+ ] = $this->getDataForSubmitMult(
+ $submit_mult,
+ $_POST['selected_fld'],
+ $action,
+ $containerBuilder
+ );
//update the existing variables
// todo: refactor mult_submits.inc.php such as
// below globals are not needed anymore
@@ -289,7 +292,7 @@ class StructureController extends AbstractController
$message = Message::success();
}
$this->response->addHTML(
- Util::getMessage($message, $sql_query)
+ Generator::getMessage($message, $sql_query)
);
}
} else {
@@ -777,7 +780,7 @@ class StructureController extends AbstractController
);
$message->addParam($this->table);
$this->response->addHTML(
- Util::getMessage($message, $sql_query, 'success')
+ Generator::getMessage($message, $sql_query, 'success')
);
} else {
$this->response->setRequestStatus(false);
@@ -852,10 +855,10 @@ class StructureController extends AbstractController
// Parse and analyze the query
$db = &$this->db;
- list(
+ [
$analyzed_sql_results,
$db,
- ) = ParseAnalyze::sqlQuery($sql_query, $db);
+ ] = ParseAnalyze::sqlQuery($sql_query, $db);
// @todo: possibly refactor
extract($analyzed_sql_results);
@@ -965,7 +968,7 @@ class StructureController extends AbstractController
// To allow replication, we first select the db to use
// and then run queries on this db.
if (! $this->dbi->selectDb($this->db)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
$this->dbi->getError(),
'USE ' . Util::backquote($this->db) . ';',
false,
@@ -1044,7 +1047,7 @@ class StructureController extends AbstractController
$message->addParam($this->table);
$this->response->addHTML(
- Util::getMessage($message, $sql_query, 'success')
+ Generator::getMessage($message, $sql_query, 'success')
);
} else {
// An error happened while inserting/updating a table definition
@@ -1265,20 +1268,20 @@ class StructureController extends AbstractController
$columns_list = [];
$titles = [
- 'Change' => Util::getIcon('b_edit', __('Change')),
- 'Drop' => Util::getIcon('b_drop', __('Drop')),
- 'NoDrop' => Util::getIcon('b_drop', __('Drop')),
- 'Primary' => Util::getIcon('b_primary', __('Primary')),
- 'Index' => Util::getIcon('b_index', __('Index')),
- 'Unique' => Util::getIcon('b_unique', __('Unique')),
- 'Spatial' => Util::getIcon('b_spatial', __('Spatial')),
- 'IdxFulltext' => Util::getIcon('b_ftext', __('Fulltext')),
- 'NoPrimary' => Util::getIcon('bd_primary', __('Primary')),
- 'NoIndex' => Util::getIcon('bd_index', __('Index')),
- 'NoUnique' => Util::getIcon('bd_unique', __('Unique')),
- 'NoSpatial' => Util::getIcon('bd_spatial', __('Spatial')),
- 'NoIdxFulltext' => Util::getIcon('bd_ftext', __('Fulltext')),
- 'DistinctValues' => Util::getIcon('b_browse', __('Distinct values')),
+ 'Change' => Generator::getIcon('b_edit', __('Change')),
+ 'Drop' => Generator::getIcon('b_drop', __('Drop')),
+ 'NoDrop' => Generator::getIcon('b_drop', __('Drop')),
+ 'Primary' => Generator::getIcon('b_primary', __('Primary')),
+ 'Index' => Generator::getIcon('b_index', __('Index')),
+ 'Unique' => Generator::getIcon('b_unique', __('Unique')),
+ 'Spatial' => Generator::getIcon('b_spatial', __('Spatial')),
+ 'IdxFulltext' => Generator::getIcon('b_ftext', __('Fulltext')),
+ 'NoPrimary' => Generator::getIcon('bd_primary', __('Primary')),
+ 'NoIndex' => Generator::getIcon('bd_index', __('Index')),
+ 'NoUnique' => Generator::getIcon('bd_unique', __('Unique')),
+ 'NoSpatial' => Generator::getIcon('bd_spatial', __('Spatial')),
+ 'NoIdxFulltext' => Generator::getIcon('bd_ftext', __('Fulltext')),
+ 'DistinctValues' => Generator::getIcon('b_browse', __('Distinct values')),
];
/**
@@ -1329,12 +1332,12 @@ class StructureController extends AbstractController
if ($primary_index && $primary_index->hasColumn($field['Field'])) {
$displayed_fields[$rownum]->icon .=
- Util::getImage('b_primary', __('Primary'));
+ Generator::getImage('b_primary', __('Primary'));
}
if (in_array($field['Field'], $columns_with_index)) {
$displayed_fields[$rownum]->icon .=
- Util::getImage('bd_primary', __('Index'));
+ Generator::getImage('bd_primary', __('Index'));
}
$collation = Charsets::findCollationByName(
@@ -1426,25 +1429,25 @@ class StructureController extends AbstractController
// this is to display for example 261.2 MiB instead of 268k KiB
$max_digits = 3;
$decimals = 1;
- list($data_size, $data_unit) = Util::formatByteDown(
+ [$data_size, $data_unit] = Util::formatByteDown(
$this->_showtable['Data_length'],
$max_digits,
$decimals
);
if ($mergetable === false) {
- list($index_size, $index_unit) = Util::formatByteDown(
+ [$index_size, $index_unit] = Util::formatByteDown(
$this->_showtable['Index_length'],
$max_digits,
$decimals
);
}
if (isset($this->_showtable['Data_free'])) {
- list($free_size, $free_unit) = Util::formatByteDown(
+ [$free_size, $free_unit] = Util::formatByteDown(
$this->_showtable['Data_free'],
$max_digits,
$decimals
);
- list($effect_size, $effect_unit) = Util::formatByteDown(
+ [$effect_size, $effect_unit] = Util::formatByteDown(
$this->_showtable['Data_length']
+ $this->_showtable['Index_length']
- $this->_showtable['Data_free'],
@@ -1452,20 +1455,20 @@ class StructureController extends AbstractController
$decimals
);
} else {
- list($effect_size, $effect_unit) = Util::formatByteDown(
+ [$effect_size, $effect_unit] = Util::formatByteDown(
$this->_showtable['Data_length']
+ $this->_showtable['Index_length'],
$max_digits,
$decimals
);
}
- list($tot_size, $tot_unit) = Util::formatByteDown(
+ [$tot_size, $tot_unit] = Util::formatByteDown(
$this->_showtable['Data_length'] + $this->_showtable['Index_length'],
$max_digits,
$decimals
);
if ($this->_table_info_num_rows > 0) {
- list($avg_size, $avg_unit) = Util::formatByteDown(
+ [$avg_size, $avg_unit] = Util::formatByteDown(
($this->_showtable['Data_length']
+ $this->_showtable['Index_length'])
/ $this->_showtable['Rows'],
diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php
index a0f3fe4d68..e169345bb1 100644
--- a/libraries/classes/Core.php
+++ b/libraries/classes/Core.php
@@ -813,10 +813,10 @@ class Core
$retval .= __('No change');
} elseif (is_array($query_data)) {
foreach ($query_data as $query) {
- $retval .= Util::formatSql($query);
+ $retval .= Html\Generator::formatSql($query);
}
} else {
- $retval .= Util::formatSql($query_data);
+ $retval .= Html\Generator::formatSql($query_data);
}
$retval .= '';
$response = Response::getInstance();
diff --git a/libraries/classes/CreateAddField.php b/libraries/classes/CreateAddField.php
index 02b0d5fe70..0396c787ff 100644
--- a/libraries/classes/CreateAddField.php
+++ b/libraries/classes/CreateAddField.php
@@ -8,6 +8,8 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Generator;
+
/**
* Set of functions for /table/create and /table/addfield
*
@@ -285,14 +287,14 @@ class CreateAddField
private function getColumnCreationStatements(bool $isCreateTable = true): string
{
$sqlStatement = "";
- list(
+ [
$fieldCount,
$fieldPrimary,
$fieldIndex,
$fieldUnique,
$fieldFullText,
- $fieldSpatial
- ) = $this->getIndexedColumns();
+ $fieldSpatial,
+ ] = $this->getIndexedColumns();
$definitions = $this->buildColumnCreationStatement(
$fieldCount,
$isCreateTable
@@ -533,7 +535,7 @@ class CreateAddField
// To allow replication, we first select the db to use and then run queries
// on this db.
if (! $this->dbi->selectDb($db)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
$this->dbi->getError(),
'USE ' . Util::backquote($db),
false,
diff --git a/libraries/classes/Database/Qbe.php b/libraries/classes/Database/Qbe.php
index baa2c36abd..5bcc305d91 100644
--- a/libraries/classes/Database/Qbe.php
+++ b/libraries/classes/Database/Qbe.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin\Database;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Relation;
use PhpMyAdmin\SavedSearches;
@@ -363,7 +364,7 @@ class Qbe
exit;
}
// The tables list gets from MySQL
- while (list($table) = $this->dbi->fetchRow($all_tables)) {
+ while ([$table] = $this->dbi->fetchRow($all_tables)) {
$columns = $this->dbi->getColumns($this->_db, $table);
if (empty($this->_criteriaTables[$table])
@@ -1310,7 +1311,7 @@ class Qbe
$unique_columns = $indexes['unique'];
$index_columns = $indexes['index'];
- list($candidate_columns, $needsort)
+ [$candidate_columns, $needsort]
= $this->_getLeftJoinColumnCandidatesBest(
$search_tables,
$where_clause_columns,
@@ -1805,7 +1806,7 @@ class Qbe
$html_output .= ''
. sprintf(
__('SQL query on database %s :'),
- Util::getDbLink($this->_db)
+ Generator::getDbLink($this->_db)
);
$html_output .= ' ';
$text_dir = 'ltr';
diff --git a/libraries/classes/Database/Search.php b/libraries/classes/Database/Search.php
index 68488043fe..09ed4c7c3d 100644
--- a/libraries/classes/Database/Search.php
+++ b/libraries/classes/Database/Search.php
@@ -9,6 +9,8 @@ declare(strict_types=1);
namespace PhpMyAdmin\Database;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\MySQLDocumentation;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Template;
use PhpMyAdmin\Util;
@@ -321,16 +323,16 @@ class Search
{
$choices = [
'1' => $this->searchTypes[1] . ' '
- . Util::showHint(
+ . Generator::showHint(
__('Words are separated by a space character (" ").')
),
'2' => $this->searchTypes[2] . ' '
- . Util::showHint(
+ . Generator::showHint(
__('Words are separated by a space character (" ").')
),
'3' => $this->searchTypes[3],
'4' => $this->searchTypes[4],
- '5' => $this->searchTypes[5] . ' ' . Util::showMySQLDocu('Regexp'),
+ '5' => $this->searchTypes[5] . ' ' . MySQLDocumentation::show('Regexp'),
];
return $this->template->render('database/search/main', [
'db' => $this->db,
diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php
index ad56948083..4ffca7a6f2 100644
--- a/libraries/classes/DatabaseInterface.php
+++ b/libraries/classes/DatabaseInterface.php
@@ -12,6 +12,8 @@ use mysqli_result;
use PhpMyAdmin\Database\DatabaseList;
use PhpMyAdmin\Dbi\DbiExtension;
use PhpMyAdmin\Dbi\DbiMysqli;
+use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\SqlParser\Context;
/**
@@ -159,7 +161,7 @@ class DatabaseInterface
bool $cache_affected_rows = true
) {
$res = $this->tryQuery($query, $link, $options, $cache_affected_rows)
- or Util::mysqlDie($this->getError($link), $query);
+ or Generator::mysqlDie($this->getError($link), $query);
return $res;
}
@@ -950,7 +952,7 @@ class DatabaseInterface
$mysql_error = $this->getError($link);
if (! count($databases) && $GLOBALS['errno']) {
- Util::mysqlDie($mysql_error, $sql);
+ Generator::mysqlDie($mysql_error, $sql);
}
// display only databases also in official database list
@@ -2337,12 +2339,12 @@ class DatabaseInterface
if ($type === 'super') {
$query = 'SELECT 1 FROM mysql.user LIMIT 1';
} elseif ($type === 'create') {
- list($user, $host) = $this->getCurrentUserAndHost();
+ [$user, $host] = $this->getCurrentUserAndHost();
$query = "SELECT 1 FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES` "
. "WHERE `PRIVILEGE_TYPE` = 'CREATE USER' AND "
. "'''" . $user . "''@''" . $host . "''' LIKE `GRANTEE` LIMIT 1";
} elseif ($type === 'grant') {
- list($user, $host) = $this->getCurrentUserAndHost();
+ [$user, $host] = $this->getCurrentUserAndHost();
$query = "SELECT 1 FROM ("
. "SELECT `GRANTEE`, `IS_GRANTABLE` FROM "
. "`INFORMATION_SCHEMA`.`COLUMN_PRIVILEGES` UNION "
@@ -2591,7 +2593,7 @@ class DatabaseInterface
*/
public function connect(int $mode, ?array $server = null, ?int $target = null)
{
- list($user, $password, $server) = $this->getConnectionParams($mode, $server);
+ [$user, $password, $server] = $this->getConnectionParams($mode, $server);
if ($target === null) {
$target = $mode;
@@ -3144,7 +3146,7 @@ class DatabaseInterface
}
if (! self::checkDbExtension('mysqli')) {
- $docUrl = Util::getDocuLink('faq', 'faqmysql');
+ $docUrl = MySQLDocumentation::getDocumentationLink('faq', 'faqmysql');
$docLink = sprintf(
__('See %sour documentation%s for more information.'),
'[a@' . $docUrl . '@documentation]',
diff --git a/libraries/classes/Display/ChangePassword.php b/libraries/classes/Display/ChangePassword.php
index 24cbe6c11b..88a6949c10 100644
--- a/libraries/classes/Display/ChangePassword.php
+++ b/libraries/classes/Display/ChangePassword.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Display;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Message;
use PhpMyAdmin\Relation;
use PhpMyAdmin\RelationCleanup;
@@ -151,7 +152,7 @@ class ChangePassword
. 'or an \'unencrypted connection that encrypts the '
. 'password using RSA \'; while connecting to the server.'
)
- . Util::showMySQLDocu(
+ . MySQLDocumentation::show(
'sha256-authentication-plugin'
)
)
diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php
index e84b01b322..3b601ee281 100644
--- a/libraries/classes/Display/Export.php
+++ b/libraries/classes/Display/Export.php
@@ -11,6 +11,7 @@ namespace PhpMyAdmin\Display;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Encoding;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
@@ -362,7 +363,7 @@ class Export
);
$msg->addParamHtml('');
$msg->addParam($trans);
- $docUrl = Util::getDocuLink('faq', 'faq6-27');
+ $docUrl = MySQLDocumentation::getDocumentationLink('faq', 'faq6-27');
$msg->addParamHtml(
''
);
diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php
index 5e5ba2dc5a..d5ce1a28ed 100644
--- a/libraries/classes/Display/Results.php
+++ b/libraries/classes/Display/Results.php
@@ -11,6 +11,7 @@ namespace PhpMyAdmin\Display;
use PhpMyAdmin\Config\SpecialSchemaLinks;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\Transformations\Output\Text_Octetstream_Sql;
@@ -878,10 +879,10 @@ class Results
$pageSelector = '';
$numberTotalPage = 1;
if (! $isShowingAll) {
- list(
+ [
$pageSelector,
- $numberTotalPage
- ) = $this->_getHtmlPageSelector();
+ $numberTotalPage,
+ ] = $this->_getHtmlPageSelector();
}
// Move to the next page or to the last one
@@ -1068,7 +1069,7 @@ class Results
// ($GLOBALS['cfg']['ShowBrowseComments']).
$comments_map = $this->_getTableCommentsArray($analyzed_sql_results);
- list($col_order, $col_visib) = $this->_getColumnParams(
+ [$col_order, $col_visib] = $this->_getColumnParams(
$analyzed_sql_results
);
@@ -1095,7 +1096,7 @@ class Results
$display_params = $this->__get('display_params');
if (($displayParts['sort_lnk'] == '1') && ! $is_limited_display) {
- list($order_link, $sorted_header_html)
+ [$order_link, $sorted_header_html]
= $this->_getOrderLinkAndSortedHeaderHtml(
$fields_meta[$i],
$sort_expression,
@@ -1193,7 +1194,7 @@ class Results
// 1. Set $colspan and generate html with full/partial
// text button or link
- list($colspan, $buttonHtml) = $this->_getFieldVisibilityParams(
+ [$colspan, $buttonHtml] = $this->_getFieldVisibilityParams(
$displayParts,
$fullOrPartialTextLink
);
@@ -1518,7 +1519,7 @@ class Results
return '';
}
- list($columnOrder, $columnVisibility) = $this->_getColumnParams(
+ [$columnOrder, $columnVisibility] = $this->_getColumnParams(
$analyzedSqlResults
);
@@ -1609,7 +1610,7 @@ class Results
. $tmp_txt . '" title="' . $tmp_txt . '">';
$tmp_url = Url::getFromRoute('/sql', $url_params_full_text);
- return Util::linkOrButton($tmp_url, $tmp_image);
+ return Generator::linkOrButton($tmp_url, $tmp_image);
}
/**
@@ -1687,7 +1688,7 @@ class Results
// Generates the orderby clause part of the query which is part
// of URL
- list($single_sort_order, $multi_sort_order, $order_img)
+ [$single_sort_order, $multi_sort_order, $order_img]
= $this->_getSingleAndMultiSortUrls(
$sort_expression,
$sort_expression_nodirection,
@@ -1854,7 +1855,7 @@ class Results
) . ' ';
}
if ($is_in_sort) {
- list($single_sort_order, $order_img)
+ [$single_sort_order, $order_img]
= $this->_getSortingUrlParams(
$sort_direction,
$single_sort_order,
@@ -1866,7 +1867,7 @@ class Results
}
if ($current_name == $name_to_use_in_sort && $is_in_sort) {
// We need to generate the arrow button and related html
- list($sort_order, $order_img) = $this->_getSortingUrlParams(
+ [$sort_order, $order_img] = $this->_getSortingUrlParams(
$sort_direction,
$sort_order,
$index
@@ -1992,40 +1993,40 @@ class Results
{
if (strtoupper(trim($sort_direction[$index])) == self::DESCENDING_SORT_DIR) {
$sort_order .= ' ASC';
- $order_img = ' ' . Util::getImage(
- 's_desc',
- __('Descending'),
- [
- 'class' => "soimg",
- 'title' => '',
- ]
- );
- $order_img .= ' ' . Util::getImage(
- 's_asc',
- __('Ascending'),
- [
- 'class' => "soimg hide",
- 'title' => '',
- ]
- );
+ $order_img = ' ' . Generator::getImage(
+ 's_desc',
+ __('Descending'),
+ [
+ 'class' => "soimg",
+ 'title' => '',
+ ]
+ );
+ $order_img .= ' ' . Generator::getImage(
+ 's_asc',
+ __('Ascending'),
+ [
+ 'class' => "soimg hide",
+ 'title' => '',
+ ]
+ );
} else {
$sort_order .= ' DESC';
- $order_img = ' ' . Util::getImage(
- 's_asc',
- __('Ascending'),
- [
- 'class' => "soimg",
- 'title' => '',
- ]
- );
- $order_img .= ' ' . Util::getImage(
- 's_desc',
- __('Descending'),
- [
- 'class' => "soimg hide",
- 'title' => '',
- ]
- );
+ $order_img = ' ' . Generator::getImage(
+ 's_asc',
+ __('Ascending'),
+ [
+ 'class' => "soimg",
+ 'title' => '',
+ ]
+ );
+ $order_img .= ' ' . Generator::getImage(
+ 's_desc',
+ __('Descending'),
+ [
+ 'class' => "soimg hide",
+ 'title' => '',
+ ]
+ );
}
return [
$sort_order,
@@ -2061,7 +2062,7 @@ class Results
$inner_link_content = $order_link_content . $order_img
. ' ';
- return Util::linkOrButton(
+ return Generator::linkOrButton(
$order_url,
$inner_link_content,
$order_link_params
@@ -2468,7 +2469,7 @@ class Results
}
// prepare to get the column order, if available
- list($col_order, $col_visib) = $this->_getColumnParams(
+ [$col_order, $col_visib] = $this->_getColumnParams(
$analyzed_sql_results
);
@@ -2525,7 +2526,7 @@ class Results
* with only one field and it's a BLOB; in this case,
* avoid to display the delete and edit links
*/
- list($where_clause, $clause_is_unique, $condition_array)
+ [$where_clause, $clause_is_unique, $condition_array]
= Util::getUniqueCondition(
$dt_result, // handle
$this->__get('fields_cnt'), // fields_cnt
@@ -2542,8 +2543,13 @@ class Results
// 1.2.1 Modify link(s) - update row case
if ($displayParts['edit_lnk'] == self::UPDATE_ROW) {
- list($edit_url, $copy_url, $edit_str, $copy_str,
- $edit_anchor_class)
+ [
+ $edit_url,
+ $copy_url,
+ $edit_str,
+ $copy_str,
+ $edit_anchor_class,
+ ]
= $this->_getModifiedLinks(
$where_clause,
$clause_is_unique,
@@ -2552,7 +2558,7 @@ class Results
} // end if (1.2.1)
// 1.2.2 Delete/Kill link(s)
- list($del_url, $del_str, $js_conf)
+ [$del_url, $del_str, $js_conf]
= $this->_getDeleteAndKillLinks(
$where_clause,
$clause_is_unique,
@@ -3349,7 +3355,7 @@ class Results
$del_url = Url::getFromRoute('/sql', $_url_params);
$js_conf = $kill;
- $del_str = Util::getIcon(
+ $del_str = Generator::getIcon(
'b_drop',
__('Kill')
);
@@ -3385,7 +3391,7 @@ class Results
&& $GLOBALS['cfg']['RowActionType'] == self::ACTION_LINK_CONTENT_ICONS
) {
$linkContent .= ''
- . Util::getImage(
+ . Generator::getImage(
$icon,
$display_text
)
@@ -3395,7 +3401,7 @@ class Results
) {
$linkContent .= '' . $display_text . ' ';
} else {
- $linkContent .= Util::getIcon(
+ $linkContent .= Generator::getIcon(
$icon,
$display_text
);
@@ -3670,11 +3676,11 @@ class Results
// Convert to WKT format
$wktval = Util::asWKT($column);
- list(
+ [
$is_field_truncated,
$displayedColumn,
// skip 3rd param
- ) = $this->_getPartialText($wktval);
+ ] = $this->_getPartialText($wktval);
$cell = $this->_getRowData(
$class,
@@ -3701,11 +3707,11 @@ class Results
$where_comparison = ' = ' . $column;
$wkbval = substr(bin2hex($column), 8);
- list(
+ [
$is_field_truncated,
$displayedColumn,
// skip 3rd param
- ) = $this->_getPartialText($wkbval);
+ ] = $this->_getPartialText($wkbval);
$cell = $this->_getRowData(
$class,
@@ -3832,11 +3838,11 @@ class Results
&& strpos($transformation_plugin->getName(), 'Link') !== false)
&& false === stripos($field_flags, self::BINARY_FIELD)
) {
- list(
+ [
$is_field_truncated,
$column,
- $original_length
- ) = $this->_getPartialText($column);
+ $original_length,
+ ] = $this->_getPartialText($column);
}
$formatted = false;
@@ -4134,7 +4140,7 @@ class Results
$sql = new Sql();
if ($is_innodb && $sql->isJustBrowsing($analyzed_sql_results, true)) {
$pre_count = '~';
- $after_count = Util::showHint(
+ $after_count = Generator::showHint(
Sanitize::sanitizeMessage(
__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].')
)
@@ -4149,16 +4155,16 @@ class Results
// 1.1 Gets the information about which functionalities should be
// displayed
- list(
+ [
$displayParts,
- $total
- ) = $this->_setDisplayPartsAndTotal($displayParts);
+ $total,
+ ] = $this->_setDisplayPartsAndTotal($displayParts);
// 1.2 Defines offsets for the next and previous pages
$pos_next = null;
$pos_prev = null;
if ($displayParts['nav_bar'] == '1') {
- list($pos_next, $pos_prev) = $this->_getOffsets();
+ [$pos_next, $pos_prev] = $this->_getOffsets();
} // end if
// 1.3 Extract sorting expressions.
@@ -4205,13 +4211,13 @@ class Results
$after_count
);
- $sqlQueryMessage = Util::getMessage(
+ $sqlQueryMessage = Generator::getMessage(
$message,
$this->__get('sql_query'),
'success'
);
} elseif ((! isset($printview) || ($printview != '1')) && ! $is_limited_display) {
- $sqlQueryMessage = Util::getMessage(
+ $sqlQueryMessage = Generator::getMessage(
__('Your SQL query has been executed successfully.'),
$this->__get('sql_query'),
'success'
@@ -4233,7 +4239,7 @@ class Results
// can the result be sorted?
if ($displayParts['sort_lnk'] == '1' && $analyzed_sql_results['statement'] !== null) {
// At this point, $sort_expression is an array
- list($unsorted_sql_query, $sort_by_key_html)
+ [$unsorted_sql_query, $sort_by_key_html]
= $this->_getUnsortedSqlAndSortByKeyDropDown(
$analyzed_sql_results,
$sort_expression
@@ -4388,7 +4394,7 @@ class Results
$sort_table = $this->__get('table');
$sort_column = $sort_expression_nodirection;
} else {
- list($sort_table, $sort_column)
+ [$sort_table, $sort_column]
= explode('.', $sort_expression_nodirection);
}
@@ -4546,7 +4552,7 @@ class Results
$message->addParam('[doc@cfg_MaxExactCount]');
$message->addParam('[/doc]');
- $message_view_warning = Util::showHint($message);
+ $message_view_warning = Generator::showHint($message);
} else {
$message_view_warning = false;
}
@@ -4686,7 +4692,7 @@ class Results
'form_name' => 'resultsForm_' . $this->__get('unique_id'),
]);
- $links_html .= Util::getButtonOrImage(
+ $links_html .= Generator::getButtonOrImage(
'submit_mult',
'mult_submit',
__('Edit'),
@@ -4694,7 +4700,7 @@ class Results
'edit'
);
- $links_html .= Util::getButtonOrImage(
+ $links_html .= Generator::getButtonOrImage(
'submit_mult',
'mult_submit',
__('Copy'),
@@ -4702,7 +4708,7 @@ class Results
'copy'
);
- $links_html .= Util::getButtonOrImage(
+ $links_html .= Generator::getButtonOrImage(
'submit_mult',
'mult_submit',
$delete_text,
@@ -4711,7 +4717,7 @@ class Results
);
if ($analyzed_sql_results['querytype'] == 'SELECT') {
- $links_html .= Util::getButtonOrImage(
+ $links_html .= Generator::getButtonOrImage(
'submit_mult',
'mult_submit',
__('Export'),
@@ -4742,7 +4748,7 @@ class Results
// $clause_is_unique is needed by getTable() to generate the proper param
// in the multi-edit and multi-delete form
- list($where_clause, $clause_is_unique, $condition_array)
+ [$where_clause, $clause_is_unique, $condition_array]
= Util::getUniqueCondition(
$dt_result, // handle
$this->__get('fields_cnt'), // fields_cnt
@@ -4782,9 +4788,9 @@ class Results
$results_operations_html = '';
if (empty($analyzed_sql_results['procedure'])) {
$results_operations_html .= ''
- . Util::linkOrButton(
+ . Generator::linkOrButton(
Url::getFromRoute('/view/create', $params),
- Util::getIcon(
+ Generator::getIcon(
'b_view_add',
__('Create view'),
true
@@ -4828,9 +4834,9 @@ class Results
*/
private function _getCopytoclipboardLinks()
{
- return Util::linkOrButton(
+ return Generator::linkOrButton(
'#',
- Util::getIcon(
+ Generator::getIcon(
'b_insrow',
__('Copy to clipboard'),
true
@@ -4848,9 +4854,9 @@ class Results
*/
private function _getPrintviewLinks()
{
- return Util::linkOrButton(
+ return Generator::linkOrButton(
'#',
- Util::getIcon(
+ Generator::getIcon(
'b_print',
__('Print'),
true
@@ -4956,25 +4962,25 @@ class Results
}
}
- $results_operations_html .= Util::linkOrButton(
- Url::getFromRoute('/table/export', $_url_params),
- Util::getIcon(
- 'b_tblexport',
- __('Export'),
- true
+ $results_operations_html .= Generator::linkOrButton(
+ Url::getFromRoute('/table/export', $_url_params),
+ Generator::getIcon(
+ 'b_tblexport',
+ __('Export'),
+ true
+ )
)
- )
. "\n";
// prepare chart
- $results_operations_html .= Util::linkOrButton(
- Url::getFromRoute('/table/chart', $_url_params),
- Util::getIcon(
- 'b_chart',
- __('Display chart'),
- true
+ $results_operations_html .= Generator::linkOrButton(
+ Url::getFromRoute('/table/chart', $_url_params),
+ Generator::getIcon(
+ 'b_chart',
+ __('Display chart'),
+ true
+ )
)
- )
. "\n";
// prepare GIS chart
@@ -4989,9 +4995,9 @@ class Results
if ($geometry_found) {
$results_operations_html
- .= Util::linkOrButton(
+ .= Generator::linkOrButton(
Url::getFromRoute('/table/gis_visualization', $_url_params),
- Util::getIcon(
+ Generator::getIcon(
'b_globe',
__('Visualize GIS data'),
true
@@ -5119,11 +5125,11 @@ class Results
} else {
$result = '0x' . bin2hex($content);
}
- list(
+ [
$is_truncated,
$result,
// skip 3rd param
- ) = $this->_getPartialText($result);
+ ] = $this->_getPartialText($result);
}
/* Create link to download */
@@ -5173,7 +5179,7 @@ class Results
);
if ($dispresult && $GLOBALS['dbi']->numRows($dispresult) > 0) {
- list($dispval) = $GLOBALS['dbi']->fetchRow($dispresult, 0);
+ [$dispval] = $GLOBALS['dbi']->fetchRow($dispresult, 0);
} else {
$dispval = __('Link not found!');
}
@@ -5340,7 +5346,7 @@ class Results
if (strpos($class, 'grid_edit') !== false) {
$tag_params['class'] = 'ajax';
}
- $result .= Util::linkOrButton(
+ $result .= Generator::linkOrButton(
Url::getFromRoute('/sql', $_url_params),
$displayedData,
$tag_params
@@ -5437,7 +5443,7 @@ class Results
if (! empty($edit_url)) {
$ret .= '
'
. ''
- . Util::linkOrButton($edit_url, $edit_str);
+ . Generator::linkOrButton($edit_url, $edit_str);
/*
* Where clause for selecting this row uniquely is provided as
* a hidden input. Used by jQuery scripts for handling grid editing
@@ -5482,7 +5488,7 @@ class Results
}
$ret .= 'text-center print_ignore">'
- . Util::linkOrButton($copy_url, $copy_str);
+ . Generator::linkOrButton($copy_url, $copy_str);
/*
* Where clause for selecting this row uniquely is provided as
@@ -5526,7 +5532,7 @@ class Results
}
$ajax = Response::getInstance()->isAjax() ? ' ajax' : '';
$ret .= 'text-center print_ignore">'
- . Util::linkOrButton(
+ . Generator::linkOrButton(
$del_url,
$del_str,
['class' => 'delete_row requireConfirm' . $ajax]
diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php
index 7b53a07191..c490322d0b 100644
--- a/libraries/classes/Footer.php
+++ b/libraries/classes/Footer.php
@@ -214,7 +214,7 @@ class Footer
$retval .= '';
if (Util::showIcons('TabsMode')) {
- $retval .= Util::getImage(
+ $retval .= Html\Generator::getImage(
'window-new',
__('Open new phpMyAdmin window')
);
diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php
index 6376ea74d3..acfc35e654 100644
--- a/libraries/classes/Header.php
+++ b/libraries/classes/Header.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\Navigation;
/**
@@ -506,7 +507,7 @@ class Header
if (isset($GLOBALS['buffer_message'])) {
$buffer_message = $GLOBALS['buffer_message'];
}
- $retval .= Util::getMessage($message);
+ $retval .= Generator::getMessage($message);
if (isset($buffer_message)) {
$GLOBALS['buffer_message'] = $buffer_message;
}
diff --git a/libraries/classes/Html/ActionLinksModes/ActionLinksModesInterface.php b/libraries/classes/Html/ActionLinksModes/ActionLinksModesInterface.php
new file mode 100644
index 0000000000..58549e483f
--- /dev/null
+++ b/libraries/classes/Html/ActionLinksModes/ActionLinksModesInterface.php
@@ -0,0 +1,36 @@
+' . "\n"
+ . Generator::getIcon($image, $text)
+ . '' . "\n";
+ }
+}
diff --git a/libraries/classes/Html/ActionLinksModes/Text.php b/libraries/classes/Html/ActionLinksModes/Text.php
new file mode 100644
index 0000000000..7b5ac23cdb
--- /dev/null
+++ b/libraries/classes/Html/ActionLinksModes/Text.php
@@ -0,0 +1,43 @@
+' . "\n";
+ }
+}
diff --git a/libraries/classes/Html/Forms/Fields/BrowseUploadFileBlock.php b/libraries/classes/Html/Forms/Fields/BrowseUploadFileBlock.php
new file mode 100644
index 0000000000..676dd0a731
--- /dev/null
+++ b/libraries/classes/Html/Forms/Fields/BrowseUploadFileBlock.php
@@ -0,0 +1,50 @@
+';
+ } else {
+ $block_html .= '';
+ }
+
+ $block_html .= __('Browse your computer:') . ' '
+ . '
'
+ . '
'
+ . ' '
+ . Util::getFormattedMaximumUploadSize($max_upload_size) . "\n"
+ // some browsers should respect this :)
+ . Forms\Fields\MaxFileSize::generate($max_upload_size) . "\n";
+
+ return $block_html;
+ }
+}
diff --git a/libraries/classes/Html/Forms/Fields/DropDown.php b/libraries/classes/Html/Forms/Fields/DropDown.php
new file mode 100644
index 0000000000..ae70b8f760
--- /dev/null
+++ b/libraries/classes/Html/Forms/Fields/DropDown.php
@@ -0,0 +1,80 @@
+ $one_choice_label) {
+ $resultOptions[$one_choice_value]['value'] = $one_choice_value;
+ $resultOptions[$one_choice_value]['selected'] = false;
+
+ if ($one_choice_value == $active_choice) {
+ $resultOptions[$one_choice_value]['selected'] = true;
+ $selected = true;
+ }
+ $resultOptions[$one_choice_value]['label'] = $one_choice_label;
+ }
+ return $template->render(
+ 'dropdown',
+ [
+ 'select_name' => $select_name,
+ 'id' => $id,
+ 'class' => $class,
+ 'placeholder' => $placeholder,
+ 'selected' => $selected,
+ 'result_options' => $resultOptions,
+ ]
+ );
+ }
+}
diff --git a/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php b/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php
new file mode 100644
index 0000000000..adfaa24b8e
--- /dev/null
+++ b/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php
@@ -0,0 +1,86 @@
+'
+ . sprintf(
+ __('Select from the web server upload directory %s :'),
+ htmlspecialchars(Util::userDir($uploaddir))
+ )
+ . '';
+
+ $extensions = '';
+ foreach ($import_list as $import_plugin) {
+ if (! empty($extensions)) {
+ $extensions .= '|';
+ }
+ $extensions .= $import_plugin->getProperties()
+ ->getExtension();
+ }
+
+ $matcher = '@\.(' . $extensions . ')(\.('
+ . $fileListing->supportedDecompressions() . '))?$@';
+
+ $active = (isset($GLOBALS['timeout_passed'], $GLOBALS['local_import_file']) && $GLOBALS['timeout_passed'])
+ ? $GLOBALS['local_import_file']
+ : '';
+
+ $files = $fileListing->getFileSelectOptions(
+ Util::userDir($uploaddir),
+ $matcher,
+ $active
+ );
+
+ if ($files === false) {
+ Message::error(
+ __('The directory you set for upload work cannot be reached.')
+ )
+ ->display();
+ } elseif (! empty($files)) {
+ $block_html .= "\n"
+ . ' ' . "\n"
+ . ' ' . "\n"
+ . $files
+ . ' ' . "\n";
+ } elseif (empty($files)) {
+ $block_html .= '' . __('There are no files to upload!') . ' ';
+ }
+
+ return $block_html;
+ }
+}
diff --git a/libraries/classes/Html/Forms/Fields/FKCheckbox.php b/libraries/classes/Html/Forms/Fields/FKCheckbox.php
new file mode 100644
index 0000000000..c15941ada5
--- /dev/null
+++ b/libraries/classes/Html/Forms/Fields/FKCheckbox.php
@@ -0,0 +1,45 @@
+render(
+ 'fk_checkbox',
+ [
+ 'checked' => Util::isForeignKeyCheck(),
+ ]
+ );
+ }
+}
diff --git a/libraries/classes/Html/Forms/Fields/FieldGenerator.php b/libraries/classes/Html/Forms/Fields/FieldGenerator.php
new file mode 100644
index 0000000000..bce9b67f25
--- /dev/null
+++ b/libraries/classes/Html/Forms/Fields/FieldGenerator.php
@@ -0,0 +1,19 @@
+';
+ }
+}
diff --git a/libraries/classes/Html/Forms/Fields/RadioList.php b/libraries/classes/Html/Forms/Fields/RadioList.php
new file mode 100644
index 0000000000..eb8c8381f2
--- /dev/null
+++ b/libraries/classes/Html/Forms/Fields/RadioList.php
@@ -0,0 +1,83 @@
+ $choice_label) {
+ if (! $id_prefix) {
+ $id_prefix = $html_field_name;
+ }
+ $html_field_id = $id_prefix . '_' . $choice_value;
+
+ if ($choice_value == $checked_choice) {
+ $checked = 1;
+ } else {
+ $checked = 0;
+ }
+ $radio_html .= $template->render(
+ 'radio_fields',
+ [
+ 'class' => $class,
+ 'html_field_name' => $html_field_name,
+ 'html_field_id' => $html_field_id,
+ 'choice_value' => $choice_value,
+ 'is_line_break' => $line_break,
+ 'choice_label' => $choice_label,
+ 'escape_label' => $escape_label,
+ 'checked' => $checked,
+ ]
+ );
+ }
+
+ return $radio_html;
+ }
+}
diff --git a/libraries/classes/Html/Generator.php b/libraries/classes/Html/Generator.php
new file mode 100644
index 0000000000..5e52e5f13d
--- /dev/null
+++ b/libraries/classes/Html/Generator.php
@@ -0,0 +1,1624 @@
+' . __('Copy') . ' ';
+ }
+
+ /**
+ * Get a link to variable documentation
+ *
+ * @param string $name The variable name
+ * @param boolean $useMariaDB Use only MariaDB documentation
+ * @param string $text (optional) The text for the link
+ *
+ * @return string link or empty string
+ */
+ public static function linkToVarDocumentation(
+ string $name,
+ bool $useMariaDB = false,
+ string $text = null
+ ): string {
+ $html = '';
+ try {
+ $type = KBSearch::MYSQL;
+ if ($useMariaDB) {
+ $type = KBSearch::MARIADB;
+ }
+ $docLink = KBSearch::getByName($name, $type);
+ $html = MySQLDocumentation::show(
+ $name,
+ false,
+ $docLink,
+ $text
+ );
+ } catch (KBException $e) {
+ unset($e);// phpstan workaround
+ }
+ return $html;
+ }
+
+ /**
+ * Returns HTML code for a tooltip
+ *
+ * @param string $message the message for the tooltip
+ *
+ * @return string
+ *
+ * @access public
+ */
+ public static function showHint($message): string
+ {
+ if ($GLOBALS['cfg']['ShowHint']) {
+ $classClause = ' class="pma_hint"';
+ } else {
+ $classClause = '';
+ }
+ return ''
+ . self::getImage('b_help')
+ . '' . $message . ' '
+ . ' ';
+ }
+
+ /**
+ * returns a tab for tabbed navigation.
+ * If the variables $link and $args ar left empty, an inactive tab is created
+ *
+ * @param array $tab array with all options
+ * @param array $url_params tab specific URL parameters
+ *
+ * @return string html code for one tab, a link if valid otherwise a span
+ *
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ * @access public
+ */
+ public static function getHtmlTab(array $tab, array $url_params = []): string
+ {
+ $template = new Template();
+ // default values
+ $defaults = [
+ 'text' => '',
+ 'class' => '',
+ 'active' => null,
+ 'link' => '',
+ 'sep' => '?',
+ 'attr' => '',
+ 'args' => '',
+ 'warning' => '',
+ 'fragment' => '',
+ 'id' => '',
+ ];
+
+ $tab = array_merge($defaults, $tab);
+
+ // determine additional style-class
+ if (empty($tab['class'])) {
+ if (! empty($tab['active'])
+ || Core::isValid($GLOBALS['active_page'], 'identical', $tab['link'])
+ ) {
+ $tab['class'] = 'active';
+ } elseif ($tab['active'] === null && empty($GLOBALS['active_page'])
+ && (basename($GLOBALS['PMA_PHP_SELF']) == $tab['link'])
+ ) {
+ $tab['class'] = 'active';
+ }
+ }
+
+ // build the link
+ if (! empty($tab['link'])) {
+ // If there are any tab specific URL parameters, merge those with
+ // the general URL parameters
+ if (! empty($tab['args']) && is_array($tab['args'])) {
+ $url_params = array_merge($url_params, $tab['args']);
+ }
+ if (strpos($tab['link'], '?') === false) {
+ $tab['link'] = htmlentities($tab['link']) . Url::getCommon($url_params);
+ } else {
+ $tab['link'] = htmlentities($tab['link']) . Url::getCommon($url_params, '&');
+ }
+ }
+
+ if (! empty($tab['fragment'])) {
+ $tab['link'] .= $tab['fragment'];
+ }
+
+ // display icon
+ if (isset($tab['icon'])) {
+ // avoid generating an alt tag, because it only illustrates
+ // the text that follows and if browser does not display
+ // images, the text is duplicated
+ $tab['text'] = self::getIcon(
+ $tab['icon'],
+ $tab['text'],
+ false,
+ true,
+ 'TabsMode'
+ );
+ } elseif (empty($tab['text'])) {
+ // check to not display an empty link-text
+ $tab['text'] = '?';
+ trigger_error(
+ 'empty linktext in function ' . __FUNCTION__ . '()',
+ E_USER_NOTICE
+ );
+ }
+
+ //Set the id for the tab, if set in the params
+ $tabId = (empty($tab['id']) ? null : $tab['id']);
+
+ $item = [];
+ if (! empty($tab['link'])) {
+ $item = [
+ 'content' => $tab['text'],
+ 'url' => [
+ 'href' => empty($tab['link']) ? null : $tab['link'],
+ 'id' => $tabId,
+ 'class' => 'tab' . htmlentities($tab['class']),
+ ],
+ ];
+ } else {
+ $item['content'] = '' . $tab['text'] . ' ';
+ }
+
+ $item['class'] = $tab['class'] === 'active' ? 'active' : '';
+
+ return $template->render('list/item', $item);
+ }
+
+ /**
+ * returns html-code for a tab navigation
+ *
+ * @param array $tabs one element per tab
+ * @param array $url_params additional URL parameters
+ * @param string $menu_id HTML id attribute for the menu container
+ * @param bool $resizable whether to add a "resizable" class
+ *
+ * @return string html-code for tab-navigation
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public static function getHtmlTabs(
+ array $tabs,
+ array $url_params,
+ $menu_id,
+ $resizable = false
+ ): string {
+ $class = '';
+ if ($resizable) {
+ $class = ' class="resizable-menu"';
+ }
+
+ $tab_navigation = '' . "\n";
+
+ return $tab_navigation;
+ }
+
+ /**
+ * Generate a button or image tag
+ *
+ * @param string $button_name name of button element
+ * @param string $button_class class of button or image element
+ * @param string $text text to display
+ * @param string $image image to display
+ * @param string $value value
+ *
+ * @return string html content
+ *
+ * @access public
+ */
+ public static function getButtonOrImage(
+ $button_name,
+ $button_class,
+ $text,
+ $image,
+ $value = ''
+ ): string {
+ return Factory::build($GLOBALS['cfg']['ActionLinksMode'])
+ ->generate($button_name, $button_class, $text, $image, $value);
+ }
+
+ /**
+ * returns html code for db link to default db page
+ *
+ * @param string $database database
+ *
+ * @return string html link to default db page
+ */
+ public static function getDbLink($database = ''): string
+ {
+ if ('' === (string) $database) {
+ if ('' === (string) $GLOBALS['db']) {
+ return '';
+ }
+ $database = $GLOBALS['db'];
+ } else {
+ $database = Util::unescapeMysqlWildcards($database);
+ }
+
+ $scriptName = Util::getScriptNameForOption(
+ $GLOBALS['cfg']['DefaultTabDatabase'],
+ 'database'
+ );
+ return '' . htmlspecialchars($database) . ' ';
+ }
+
+ /**
+ * Prepare a lightbulb hint explaining a known external bug
+ * that affects a functionality
+ *
+ * @param string $functionality localized message explaining the func.
+ * @param string $component 'mysql' (eventually, 'php')
+ * @param string $minimum_version of this component
+ * @param string $bugref bug reference for this component
+ *
+ * @return String
+ */
+ public static function getExternalBug(
+ $functionality,
+ $component,
+ $minimum_version,
+ $bugref
+ ): string {
+ $ext_but_html = '';
+ if (($component === 'mysql') && ($GLOBALS['dbi']->getVersion() < $minimum_version)) {
+ $ext_but_html .= self::showHint(
+ sprintf(
+ __('The %s functionality is affected by a known bug, see %s'),
+ $functionality,
+ Core::linkURL('https://bugs.mysql.com/') . $bugref
+ )
+ );
+ }
+ return $ext_but_html;
+ }
+
+ /**
+ * Generates a slider effect (jQjuery)
+ * Takes care of generating the initial and the link
+ * controlling the slider; you have to generate the
yourself
+ * after the sliding section.
+ *
+ * @param string $id the id of the on which to apply the effect
+ * @param string $message the message to show as a link
+ * @param string|null $overrideDefault override InitialSlidersState config
+ *
+ * @return string html div element
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public static function getDivForSliderEffect($id = '', $message = '', $overrideDefault = null): string
+ {
+ $template = new Template();
+ return $template->render(
+ 'div_for_slider_effect',
+ [
+ 'id' => $id,
+ 'initial_sliders_state' => ($overrideDefault != null) ? $overrideDefault
+ : $GLOBALS['cfg']['InitialSlidersState'],
+ 'message' => $message,
+ ]
+ );
+ }
+
+ /**
+ * Creates an AJAX sliding toggle button
+ * (or and equivalent form when AJAX is disabled)
+ *
+ * @param string $action The URL for the request to be executed
+ * @param string $select_name The name for the dropdown box
+ * @param array $options An array of options (see PhpMyAdmin\Rte\Footer)
+ * @param string $callback A JS snippet to execute when the request is
+ * successfully processed
+ *
+ * @return string HTML code for the toggle button
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public static function toggleButton($action, $select_name, array $options, $callback): string
+ {
+ $template = new Template();
+ // Do the logic first
+ $link = "$action&" . urlencode($select_name) . '=';
+ $link_on = $link . urlencode($options[1]['value']);
+ $link_off = $link . urlencode($options[0]['value']);
+
+ if ($options[1]['selected'] == true) {
+ $state = 'on';
+ } elseif ($options[0]['selected'] == true) {
+ $state = 'off';
+ } else {
+ $state = 'on';
+ }
+
+ return $template->render(
+ 'toggle_button',
+ [
+ 'pma_theme_image' => $GLOBALS['pmaThemeImage'],
+ 'text_dir' => $GLOBALS['text_dir'],
+ 'link_on' => $link_on,
+ 'link_off' => $link_off,
+ 'toggle_on' => $options[1]['label'],
+ 'toggle_off' => $options[0]['label'],
+ 'callback' => $callback,
+ 'state' => $state,
+ ]
+ );
+ }
+
+ /**
+ * Returns an HTML IMG tag for a particular icon from a theme,
+ * which may be an actual file or an icon from a sprite.
+ * This function takes into account the ActionLinksMode
+ * configuration setting and wraps the image tag in a span tag.
+ *
+ * @param string $icon name of icon file
+ * @param string $alternate alternate text
+ * @param boolean $force_text whether to force alternate text to be displayed
+ * @param boolean $menu_icon whether this icon is for the menu bar or not
+ * @param string $control_param which directive controls the display
+ *
+ * @return string an html snippet
+ */
+ public static function getIcon(
+ $icon,
+ $alternate = '',
+ $force_text = false,
+ $menu_icon = false,
+ $control_param = 'ActionLinksMode'
+ ): string {
+ $include_icon = $include_text = false;
+ if (Util::showIcons($control_param)) {
+ $include_icon = true;
+ }
+ if ($force_text
+ || Util::showText($control_param)
+ ) {
+ $include_text = true;
+ }
+ // Sometimes use a span (we rely on this in js/sql.js). But for menu bar
+ // we don't need a span
+ $button = $menu_icon ? '' : '
';
+ if ($include_icon) {
+ $button .= self::getImage($icon, $alternate);
+ }
+ if ($include_icon && $include_text) {
+ $button .= ' ';
+ }
+ if ($include_text) {
+ $button .= $alternate;
+ }
+ $button .= $menu_icon ? '' : ' ';
+
+ return $button;
+ }
+
+ /**
+ * Returns information about SSL status for current connection
+ *
+ * @return string
+ */
+ public static function getServerSSL(): string
+ {
+ $server = $GLOBALS['cfg']['Server'];
+ $class = 'caution';
+ if (! $server['ssl']) {
+ $message = __('SSL is not being used');
+ if (! empty($server['socket']) || $server['host'] === '127.0.0.1' || $server['host'] === 'localhost') {
+ $class = '';
+ }
+ } elseif (! $server['ssl_verify']) {
+ $message = __('SSL is used with disabled verification');
+ } elseif (empty($server['ssl_ca'])) {
+ $message = __('SSL is used without certification authority');
+ } else {
+ $class = '';
+ $message = __('SSL is used');
+ }
+ return '
' . $message . ' ' . MySQLDocumentation::showDocumentation(
+ 'setup',
+ 'ssl'
+ );
+ }
+
+ /**
+ * Returns default function for a particular column.
+ *
+ * @param array $field Data about the column for which
+ * to generate the dropdown
+ * @param bool $insert_mode Whether the operation is 'insert'
+ *
+ * @return string An HTML snippet of a dropdown list with function
+ * names appropriate for the requested column.
+ * @global mixed $data data of currently edited row
+ * (used to detect whether to choose defaults)
+ *
+ * @global array $cfg PMA configuration
+ */
+ public static function getDefaultFunctionForField(array $field, $insert_mode): string
+ {
+ /*
+ * @todo Except for $cfg, no longer use globals but pass as parameters
+ * from higher levels
+ */
+ global $cfg, $data;
+
+ $default_function = '';
+
+ // Can we get field class based values?
+ $current_class = $GLOBALS['dbi']->types->getTypeClass($field['True_Type']);
+ if (! empty($current_class) && isset($cfg['DefaultFunctions']['FUNC_' . $current_class])) {
+ $default_function = $cfg['DefaultFunctions']['FUNC_' . $current_class];
+ }
+
+ // what function defined as default?
+ // for the first timestamp we don't set the default function
+ // if there is a default value for the timestamp
+ // (not including CURRENT_TIMESTAMP)
+ // and the column does not have the
+ // ON UPDATE DEFAULT TIMESTAMP attribute.
+ if (($field['True_Type'] === 'timestamp')
+ && $field['first_timestamp']
+ && empty($field['Default'])
+ && empty($data)
+ && $field['Extra'] !== 'on update CURRENT_TIMESTAMP'
+ && $field['Null'] === 'NO'
+ ) {
+ $default_function = $cfg['DefaultFunctions']['first_timestamp'];
+ }
+
+ // For primary keys of type char(36) or varchar(36) UUID if the default
+ // function
+ // Only applies to insert mode, as it would silently trash data on updates.
+ if ($insert_mode
+ && $field['Key'] === 'PRI'
+ && ($field['Type'] === 'char(36)' || $field['Type'] === 'varchar(36)')
+ ) {
+ $default_function = $cfg['DefaultFunctions']['FUNC_UUID'];
+ }
+
+ return $default_function;
+ }
+
+ /**
+ * Creates a dropdown box with MySQL functions for a particular column.
+ *
+ * @param array $field Data about the column for which
+ * to generate the dropdown
+ * @param bool $insert_mode Whether the operation is 'insert'
+ * @param array $foreignData Foreign data
+ *
+ * @return string An HTML snippet of a dropdown list with function
+ * names appropriate for the requested column.
+ */
+ public static function getFunctionsForField(array $field, $insert_mode, array $foreignData): string
+ {
+ $default_function = self::getDefaultFunctionForField($field, $insert_mode);
+ $dropdown_built = [];
+
+ // Create the output
+ $retval = '
' . "\n";
+ // loop on the dropdown array and print all available options for that
+ // field.
+ $functions = $GLOBALS['dbi']->types->getFunctions($field['True_Type']);
+ foreach ($functions as $function) {
+ $retval .= '
' . "\n";
+ $dropdown_built[$function] = true;
+ }
+
+ // Create separator before all functions list
+ if (count($functions) > 0) {
+ $retval .= ' -------- '
+ . "\n";
+ }
+
+ // For compatibility's sake, do not let out all other functions. Instead
+ // print a separator (blank) and then show ALL functions which weren't
+ // shown yet.
+ $functions = $GLOBALS['dbi']->types->getAllFunctions();
+ foreach ($functions as $function) {
+ // Skip already included functions
+ if (isset($dropdown_built[$function])) {
+ continue;
+ }
+ $retval .= '
' . "\n";
+ } // end for
+
+ return $retval;
+ }
+
+ /**
+ * Renders a single link for the top of the navigation panel
+ *
+ * @param string $link The url for the link
+ * @param bool $showText Whether to show the text or to
+ * only use it for title attributes
+ * @param string $text The text to display and use for title attributes
+ * @param bool $showIcon Whether to show the icon
+ * @param string $icon The filename of the icon to show
+ * @param string $linkId Value to use for the ID attribute
+ * @param boolean $disableAjax Whether to disable ajax page loading for this link
+ * @param string $linkTarget The name of the target frame for the link
+ * @param array $classes HTML classes to apply
+ *
+ * @return string HTML code for one link
+ */
+ public static function getNavigationLink(
+ $link,
+ $showText,
+ $text,
+ $showIcon,
+ $icon,
+ $linkId = '',
+ $disableAjax = false,
+ $linkTarget = '',
+ array $classes = []
+ ): string {
+ $retval = '';
+ if ($showIcon) {
+ $retval .= self::getImage(
+ $icon,
+ $text
+ );
+ }
+ if ($showText) {
+ $retval .= $text;
+ }
+ $retval .= ' ';
+ if ($showText) {
+ $retval .= ' ';
+ }
+ return $retval;
+ }
+
+ /**
+ * Function to get html for the start row and number of rows panel
+ *
+ * @param string $sql_query sql query
+ *
+ * @return string html
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public static function getStartAndNumberOfRowsPanel($sql_query): string
+ {
+ $template = new Template();
+
+ if (isset($_REQUEST['session_max_rows'])) {
+ $rows = $_REQUEST['session_max_rows'];
+ } elseif (isset($_SESSION['tmpval']['max_rows'])
+ && $_SESSION['tmpval']['max_rows'] !== 'all'
+ ) {
+ $rows = $_SESSION['tmpval']['max_rows'];
+ } else {
+ $rows = $GLOBALS['cfg']['MaxRows'];
+ $_SESSION['tmpval']['max_rows'] = $rows;
+ }
+
+ if (isset($_REQUEST['pos'])) {
+ $pos = $_REQUEST['pos'];
+ } elseif (isset($_SESSION['tmpval']['pos'])) {
+ $pos = $_SESSION['tmpval']['pos'];
+ } else {
+ $number_of_line = (int) $_REQUEST['unlim_num_rows'];
+ $pos = ((ceil($number_of_line / $rows) - 1) * $rows);
+ $_SESSION['tmpval']['pos'] = $pos;
+ }
+
+ return $template->render(
+ 'start_and_number_of_rows_panel',
+ [
+ 'pos' => $pos,
+ 'unlim_num_rows' => (int) $_REQUEST['unlim_num_rows'],
+ 'rows' => $rows,
+ 'sql_query' => $sql_query,
+ ]
+ );
+ }
+
+ /**
+ * Execute an EXPLAIN query and formats results similar to MySQL command line
+ * utility.
+ *
+ * @param string $sqlQuery EXPLAIN query
+ *
+ * @return string query resuls
+ */
+ private static function _generateRowQueryOutput($sqlQuery): string
+ {
+ $ret = '';
+ $result = $GLOBALS['dbi']->query($sqlQuery);
+ if ($result) {
+ $devider = '+';
+ $columnNames = '|';
+ $fieldsMeta = $GLOBALS['dbi']->getFieldsMeta($result);
+ foreach ($fieldsMeta as $meta) {
+ $devider .= '---+';
+ $columnNames .= ' ' . $meta->name . ' |';
+ }
+ $devider .= "\n";
+
+ $ret .= $devider . $columnNames . "\n" . $devider;
+ while ($row = $GLOBALS['dbi']->fetchRow($result)) {
+ $values = '|';
+ foreach ($row as $value) {
+ if ($value === null) {
+ $value = 'NULL';
+ }
+ $values .= ' ' . $value . ' |';
+ }
+ $ret .= $values . "\n";
+ }
+ $ret .= $devider;
+ }
+ return $ret;
+ }
+
+ /**
+ * Prepare the message and the query
+ * usually the message is the result of the query executed
+ *
+ * @param Message|string $message the message to display
+ * @param string $sql_query the query to display
+ * @param string $type the type (level) of the message
+ *
+ * @return string
+ *
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ * @access public
+ */
+ public static function getMessage(
+ $message,
+ $sql_query = null,
+ $type = 'notice'
+ ): string {
+ global $cfg;
+ $template = new Template();
+ $retval = '';
+
+ if (null === $sql_query) {
+ if (! empty($GLOBALS['display_query'])) {
+ $sql_query = $GLOBALS['display_query'];
+ } elseif (! empty($GLOBALS['unparsed_sql'])) {
+ $sql_query = $GLOBALS['unparsed_sql'];
+ } elseif (! empty($GLOBALS['sql_query'])) {
+ $sql_query = $GLOBALS['sql_query'];
+ } else {
+ $sql_query = '';
+ }
+ }
+
+ $render_sql = $cfg['ShowSQL'] == true && ! empty($sql_query) && $sql_query !== ';';
+
+ if (isset($GLOBALS['using_bookmark_message'])) {
+ $retval .= $GLOBALS['using_bookmark_message']->getDisplay();
+ unset($GLOBALS['using_bookmark_message']);
+ }
+
+ if ($render_sql) {
+ $retval .= '' . "\n";
+ }
+
+ if ($message instanceof Message) {
+ if (isset($GLOBALS['special_message'])) {
+ $message->addText($GLOBALS['special_message']);
+ unset($GLOBALS['special_message']);
+ }
+ $retval .= $message->getDisplay();
+ } else {
+ $context = 'primary';
+ if ($type === 'error') {
+ $context = 'danger';
+ } elseif ($type === 'success') {
+ $context = 'success';
+ }
+ $retval .= '
';
+ $retval .= Sanitize::sanitizeMessage($message);
+ if (isset($GLOBALS['special_message'])) {
+ $retval .= Sanitize::sanitizeMessage($GLOBALS['special_message']);
+ unset($GLOBALS['special_message']);
+ }
+ $retval .= '
';
+ }
+
+ if ($render_sql) {
+ $query_too_big = false;
+
+ $queryLength = mb_strlen($sql_query);
+ if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
+ // when the query is large (for example an INSERT of binary
+ // data), the parser chokes; so avoid parsing the query
+ $query_too_big = true;
+ $query_base = mb_substr(
+ $sql_query,
+ 0,
+ $cfg['MaxCharactersInDisplayedSQL']
+ ) . '[...]';
+ } else {
+ $query_base = $sql_query;
+ }
+
+ // Html format the query to be displayed
+ // If we want to show some sql code it is easiest to create it here
+ /* SQL-Parser-Analyzer */
+
+ if (! empty($GLOBALS['show_as_php'])) {
+ $new_line = '\\n"
' . "\n" . ' . "';
+ $query_base = htmlspecialchars(addslashes($query_base));
+ $query_base = preg_replace(
+ '/((\015\012)|(\015)|(\012))/',
+ $new_line,
+ $query_base
+ );
+ $query_base = '
' . "\n"
+ . '$sql = "' . $query_base . '";' . "\n"
+ . ' ';
+ } elseif ($query_too_big) {
+ $query_base = '
' . "\n" .
+ htmlspecialchars($query_base) .
+ ' ';
+ } else {
+ $query_base = self::formatSql($query_base);
+ }
+
+ // Prepares links that may be displayed to edit/explain the query
+ // (don't go to default pages, we must go to the page
+ // where the query box is available)
+
+ // Basic url query part
+ $url_params = [];
+ if (! isset($GLOBALS['db'])) {
+ $GLOBALS['db'] = '';
+ }
+ if (strlen($GLOBALS['db']) > 0) {
+ $url_params['db'] = $GLOBALS['db'];
+ if (strlen($GLOBALS['table']) > 0) {
+ $url_params['table'] = $GLOBALS['table'];
+ $edit_link = Url::getFromRoute('/table/sql');
+ } else {
+ $edit_link = Url::getFromRoute('/database/sql');
+ }
+ } else {
+ $edit_link = Url::getFromRoute('/server/sql');
+ }
+
+ // Want to have the query explained
+ // but only explain a SELECT (that has not been explained)
+ /* SQL-Parser-Analyzer */
+ $explain_link = '';
+ $is_select = preg_match('@^SELECT[[:space:]]+@i', $sql_query);
+ if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) {
+ $explain_params = $url_params;
+ if ($is_select) {
+ $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
+ $explain_link = ' [ '
+ . self::linkOrButton(
+ Url::getFromRoute('/import', $explain_params),
+ __('Explain SQL')
+ ) . ' ]';
+ } elseif (preg_match(
+ '@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i',
+ $sql_query
+ )) {
+ $explain_params['sql_query']
+ = mb_substr($sql_query, 8);
+ $explain_link = ' [ '
+ . self::linkOrButton(
+ Url::getFromRoute('/import', $explain_params),
+ __('Skip Explain SQL')
+ ) . ']';
+ $url = 'https://mariadb.org/explain_analyzer/analyze/'
+ . '?client=phpMyAdmin&raw_explain='
+ . urlencode(self::_generateRowQueryOutput($sql_query));
+ $explain_link .= ' ['
+ . self::linkOrButton(
+ htmlspecialchars('url.php?url=' . urlencode($url)),
+ sprintf(__('Analyze Explain at %s'), 'mariadb.org'),
+ [],
+ '_blank'
+ ) . ' ]';
+ }
+ } //show explain
+
+ $url_params['sql_query'] = $sql_query;
+ $url_params['show_query'] = 1;
+
+ // even if the query is big and was truncated, offer the chance
+ // to edit it (unless it's enormous, see linkOrButton() )
+ if (! empty($cfg['SQLQuery']['Edit'])
+ && empty($GLOBALS['show_as_php'])
+ ) {
+ $edit_link .= Url::getCommon($url_params);
+ $edit_link = ' [ '
+ . self::linkOrButton($edit_link, __('Edit'))
+ . ' ]';
+ } else {
+ $edit_link = '';
+ }
+
+ // Also we would like to get the SQL formed in some nice
+ // php-code
+ if (! empty($cfg['SQLQuery']['ShowAsPHP']) && ! $query_too_big) {
+ if (! empty($GLOBALS['show_as_php'])) {
+ $php_link = ' [ '
+ . self::linkOrButton(
+ Url::getFromRoute('/import', $url_params),
+ __('Without PHP code')
+ )
+ . ' ]';
+
+ $php_link .= ' [ '
+ . self::linkOrButton(
+ Url::getFromRoute('/import', $url_params),
+ __('Submit query')
+ )
+ . ' ]';
+ } else {
+ $php_params = $url_params;
+ $php_params['show_as_php'] = 1;
+ $php_link = ' [ '
+ . self::linkOrButton(
+ Url::getFromRoute('/import', $php_params),
+ __('Create PHP code')
+ )
+ . ' ]';
+ }
+ } else {
+ $php_link = '';
+ } //show as php
+
+ // Refresh query
+ if (! empty($cfg['SQLQuery']['Refresh'])
+ && ! isset($GLOBALS['show_as_php']) // 'Submit query' does the same
+ && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)
+ ) {
+ $refresh_link = Url::getFromRoute('/import', $url_params);
+ $refresh_link = ' [ '
+ . self::linkOrButton($refresh_link, __('Refresh')) . ']';
+ } else {
+ $refresh_link = '';
+ } //refresh
+
+ $retval .= '
';
+ $retval .= $query_base;
+ $retval .= '
';
+
+ $retval .= '
';
+ $retval .= '';
+
+ /**
+ * TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
+ */
+ if (! empty($cfg['SQLQuery']['Edit'])
+ && ! $query_too_big
+ && empty($GLOBALS['show_as_php'])
+ ) {
+ $inline_edit_link = ' ['
+ . self::linkOrButton(
+ '#',
+ _pgettext('Inline edit query', 'Edit inline'),
+ ['class' => 'inline_edit_sql']
+ )
+ . ']';
+ } else {
+ $inline_edit_link = '';
+ }
+ $retval .= $inline_edit_link . $edit_link . $explain_link . $php_link
+ . $refresh_link;
+ $retval .= '
';
+
+ $retval .= '
';
+ }
+
+ return $retval;
+ }
+
+ /**
+ * Displays a link to the PHP documentation
+ *
+ * @param string $target anchor in documentation
+ *
+ * @return string the html link
+ *
+ * @access public
+ */
+ public static function showPHPDocumentation($target): string
+ {
+ return self::showDocumentationLink(Core::getPHPDocLink($target));
+ }
+
+ /**
+ * Displays a link to the documentation as an icon
+ *
+ * @param string $link documentation link
+ * @param string $target optional link target
+ * @param boolean $bbcode optional flag indicating whether to output bbcode
+ *
+ * @return string the html link
+ *
+ * @access public
+ */
+ public static function showDocumentationLink($link, $target = 'documentation', $bbcode = false): string
+ {
+ if ($bbcode) {
+ return "[a@$link@$target][dochelpicon][/a]";
+ }
+
+ return ''
+ . self::getImage('b_help', __('Documentation'))
+ . ' ';
+ }
+
+ /**
+ * Displays a MySQL error message in the main panel when $exit is true.
+ * Returns the error message otherwise.
+ *
+ * @param string|bool $server_msg Server's error message.
+ * @param string $sql_query The SQL query that failed.
+ * @param bool $is_modify_link Whether to show a "modify" link or not.
+ * @param string $back_url URL for the "back" link (full path is
+ * not required).
+ * @param bool $exit Whether execution should be stopped or
+ * the error message should be returned.
+ *
+ * @return string
+ *
+ * @global string $table The current table.
+ * @global string $db The current database.
+ *
+ * @access public
+ */
+ public static function mysqlDie(
+ $server_msg = '',
+ $sql_query = '',
+ $is_modify_link = true,
+ $back_url = '',
+ $exit = true
+ ): ?string {
+ global $table, $db;
+
+ /**
+ * Error message to be built.
+ * @var string $error_msg
+ */
+ $error_msg = '';
+
+ // Checking for any server errors.
+ if (empty($server_msg)) {
+ $server_msg = $GLOBALS['dbi']->getError();
+ }
+
+ // Finding the query that failed, if not specified.
+ if (empty($sql_query) && ! empty($GLOBALS['sql_query'])) {
+ $sql_query = $GLOBALS['sql_query'];
+ }
+ $sql_query = trim($sql_query);
+
+ /**
+ * The lexer used for analysis.
+ * @var Lexer $lexer
+ */
+ $lexer = new Lexer($sql_query);
+
+ /**
+ * The parser used for analysis.
+ * @var Parser $parser
+ */
+ $parser = new Parser($lexer->list);
+
+ /**
+ * The errors found by the lexer and the parser.
+ * @var array $errors
+ */
+ $errors = ParserError::get(
+ [
+ $lexer,
+ $parser,
+ ]
+ );
+
+ if (empty($sql_query)) {
+ $formatted_sql = '';
+ } elseif (count($errors)) {
+ $formatted_sql = htmlspecialchars($sql_query);
+ } else {
+ $formatted_sql = self::formatSql($sql_query, true);
+ }
+
+ $error_msg .= '' . __('Error') . ' ';
+
+ // For security reasons, if the MySQL refuses the connection, the query
+ // is hidden so no details are revealed.
+ if (! empty($sql_query) && ! mb_strstr($sql_query, 'connect')) {
+ // Static analysis errors.
+ if (! empty($errors)) {
+ $error_msg .= '
' . __('Static analysis:')
+ . '
';
+ $error_msg .= '
' . sprintf(
+ __('%d errors were found during analysis.'),
+ count($errors)
+ ) . '
';
+ $error_msg .= '
';
+ $error_msg .= implode(
+ ParserError::format(
+ $errors,
+ '%2$s (near "%4$s" at position %5$d) '
+ )
+ );
+ $error_msg .= ' ';
+ }
+
+ // Display the SQL query and link to MySQL documentation.
+ $error_msg .= '
' . __('SQL query:') . ' ' . self::showCopyToClipboard(
+ $sql_query
+ ) . "\n";
+ $formattedSqlToLower = mb_strtolower($formatted_sql);
+
+ // TODO: Show documentation for all statement types.
+ if (mb_strstr($formattedSqlToLower, 'select')) {
+ // please show me help to the error on select
+ $error_msg .= MySQLDocumentation::show('SELECT');
+ }
+
+ if ($is_modify_link) {
+ $_url_params = [
+ 'sql_query' => $sql_query,
+ 'show_query' => 1,
+ ];
+ if (strlen($table) > 0) {
+ $_url_params['db'] = $db;
+ $_url_params['table'] = $table;
+ $doedit_goto = '';
+ } elseif (strlen($db) > 0) {
+ $_url_params['db'] = $db;
+ $doedit_goto = ' ';
+ } else {
+ $doedit_goto = ' ';
+ }
+
+ $error_msg .= $doedit_goto
+ . self::getIcon('b_edit', __('Edit'))
+ . ' ';
+ }
+
+ $error_msg .= '
' . "\n"
+ . '
' . "\n"
+ . $formatted_sql . "\n"
+ . '
' . "\n";
+ }
+
+ // Display server's error.
+ if (! empty($server_msg)) {
+ $server_msg = preg_replace(
+ "@((\015\012)|(\015)|(\012)){3,}@",
+ "\n\n",
+ $server_msg
+ );
+
+ // Adds a link to MySQL documentation.
+ $error_msg .= '
' . "\n"
+ . ' ' . __('MySQL said: ') . ' '
+ . MySQLDocumentation::show('Error-messages-server')
+ . "\n"
+ . '
' . "\n";
+
+ // The error message will be displayed within a CODE segment.
+ // To preserve original formatting, but allow word-wrapping,
+ // a couple of replacements are done.
+ // All non-single blanks and TAB-characters are replaced with their
+ // HTML-counterpart
+ $server_msg = str_replace(
+ [
+ ' ',
+ "\t",
+ ],
+ [
+ ' ',
+ ' ',
+ ],
+ $server_msg
+ );
+
+ // Replace line breaks
+ $server_msg = nl2br($server_msg);
+
+ $error_msg .= '
' . $server_msg . '';
+ }
+
+ $error_msg .= '
';
+ $_SESSION['Import_message']['message'] = $error_msg;
+
+ if (! $exit) {
+ return $error_msg;
+ }
+
+ /**
+ * If this is an AJAX request, there is no "Back" link and
+ * `Response()` is used to send the response.
+ */
+ $response = Response::getInstance();
+ if ($response->isAjax()) {
+ $response->setRequestStatus(false);
+ $response->addJSON('message', $error_msg);
+ exit;
+ }
+
+ if (! empty($back_url)) {
+ if (mb_strstr($back_url, '?')) {
+ $back_url .= '&no_history=true';
+ } else {
+ $back_url .= '?no_history=true';
+ }
+
+ $_SESSION['Import_message']['go_back_url'] = $back_url;
+
+ $error_msg .= '' . "\n\n";
+ }
+
+ exit($error_msg);
+ }
+
+ /**
+ * Returns an HTML IMG tag for a particular image from a theme
+ *
+ * The image name should match CSS class defined in icons.css.php
+ *
+ * @param string $image The name of the file to get
+ * @param string $alternate Used to set 'alt' and 'title' attributes
+ * of the image
+ * @param array $attributes An associative array of other attributes
+ *
+ * @return string an html IMG tag
+ */
+ public static function getImage($image, $alternate = '', array $attributes = []): string
+ {
+ $alternate = htmlspecialchars($alternate);
+
+ if (isset($attributes['class'])) {
+ $attributes['class'] = "icon ic_$image " . $attributes['class'];
+ } else {
+ $attributes['class'] = "icon ic_$image";
+ }
+
+ // set all other attributes
+ $attr_str = '';
+ foreach ($attributes as $key => $value) {
+ if (! in_array($key, ['alt', 'title'])) {
+ $attr_str .= " $key=\"$value\"";
+ }
+ }
+
+ // override the alt attribute
+ $alt = $attributes['alt'] ?? $alternate;
+
+ // override the title attribute
+ $title = $attributes['title'] ?? $alternate;
+
+ // generate the IMG tag
+ $template = ' ';
+ return sprintf($template, $title, $alt, $attr_str);
+ }
+
+ /**
+ * Displays a link, or a link with code to trigger POST request.
+ *
+ * POST is used in following cases:
+ *
+ * - URL is too long
+ * - URL components are over Suhosin limits
+ * - There is SQL query in the parameters
+ *
+ * @param string $url the URL
+ * @param string $message the link message
+ * @param mixed $tag_params string: js confirmation; array: additional tag
+ * params (f.e. style="")
+ * @param string $target target
+ *
+ * @return string the results to be echoed or saved in an array
+ */
+ public static function linkOrButton(
+ $url,
+ $message,
+ $tag_params = [],
+ $target = ''
+ ): string {
+ $url_length = strlen($url);
+
+ if (! is_array($tag_params)) {
+ $tmp = $tag_params;
+ $tag_params = [];
+ if (! empty($tmp)) {
+ $tag_params['onclick'] = 'return Functions.confirmLink(this, \''
+ . Sanitize::escapeJsString($tmp) . '\')';
+ }
+ unset($tmp);
+ }
+ if (! empty($target)) {
+ $tag_params['target'] = $target;
+ if ($target === '_blank' && strncmp($url, 'url.php?', 8) == 0) {
+ $tag_params['rel'] = 'noopener noreferrer';
+ }
+ }
+
+ // Suhosin: Check that each query parameter is not above maximum
+ $in_suhosin_limits = true;
+ if ($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) {
+ $suhosin_get_MaxValueLength = ini_get('suhosin.get.max_value_length');
+ if ($suhosin_get_MaxValueLength) {
+ $query_parts = Util::splitURLQuery($url);
+ foreach ($query_parts as $query_pair) {
+ if (strpos($query_pair, '=') === false) {
+ continue;
+ }
+
+ [, $eachval] = explode('=', $query_pair);
+ if (strlen($eachval) > $suhosin_get_MaxValueLength) {
+ $in_suhosin_limits = false;
+ break;
+ }
+ }
+ }
+ }
+
+ $tag_params_strings = [];
+ if (($url_length > $GLOBALS['cfg']['LinkLengthLimit'])
+ || ! $in_suhosin_limits
+ // Has as sql_query without a signature
+ || (strpos($url, 'sql_query=') !== false && strpos($url, 'sql_signature=') === false)
+ || strpos($url, 'view[as]=') !== false
+ ) {
+ $parts = explode('?', $url, 2);
+ /*
+ * The data-post indicates that client should do POST
+ * this is handled in js/ajax.js
+ */
+ $tag_params_strings[] = 'data-post="' . (isset($parts[1]) ? $parts[1] : '') . '"';
+ $url = $parts[0];
+ if (array_key_exists('class', $tag_params)
+ && strpos($tag_params['class'], 'create_view') !== false
+ ) {
+ $url .= '?' . explode('&', $parts[1], 2)[0];
+ }
+ }
+
+ foreach ($tag_params as $par_name => $par_value) {
+ $tag_params_strings[] = $par_name . '="' . htmlspecialchars($par_value) . '"';
+ }
+
+ // no whitespace within an else Safari will make it part of the link
+ return ' '
+ . $message . ' ';
+ }
+
+ /**
+ * Prepare navigation for a list
+ *
+ * @param int $count number of elements in the list
+ * @param int $pos current position in the list
+ * @param array $_url_params url parameters
+ * @param string $script script name for form target
+ * @param string $frame target frame
+ * @param int $max_count maximum number of elements to display from
+ * the list
+ * @param string $name the name for the request parameter
+ * @param string[] $classes additional classes for the container
+ *
+ * @return string the html content
+ *
+ * @access public
+ *
+ * @todo use $pos from $_url_params
+ */
+ public static function getListNavigator(
+ $count,
+ $pos,
+ array $_url_params,
+ $script,
+ $frame,
+ $max_count,
+ $name = 'pos',
+ $classes = []
+ ): string {
+
+ // This is often coming from $cfg['MaxTableList'] and
+ // people sometimes set it to empty string
+ $max_count = intval($max_count);
+ if ($max_count <= 0) {
+ $max_count = 250;
+ }
+
+ $class = $frame === 'frame_navigation' ? ' class="ajax"' : '';
+
+ $list_navigator_html = '';
+
+ if ($max_count < $count) {
+ $classes[] = 'pageselector';
+ $list_navigator_html .= '';
+
+ if ($frame !== 'frame_navigation') {
+ $list_navigator_html .= __('Page number:');
+ }
+
+ // Move to the beginning or to the previous page
+ if ($pos > 0) {
+ $caption1 = '';
+ $caption2 = '';
+ if (Util::showIcons('TableNavigationLinksMode')) {
+ $caption1 .= '<< ';
+ $caption2 .= '< ';
+ }
+ if (Util::showText('TableNavigationLinksMode')) {
+ $caption1 .= _pgettext('First page', 'Begin');
+ $caption2 .= _pgettext('Previous page', 'Previous');
+ }
+ $title1 = ' title="' . _pgettext('First page', 'Begin') . '"';
+ $title2 = ' title="' . _pgettext('Previous page', 'Previous') . '"';
+
+ $_url_params[$name] = 0;
+ $list_navigator_html .= '
' . $caption1
+ . ' ';
+
+ $_url_params[$name] = $pos - $max_count;
+ $list_navigator_html .= '
'
+ . $caption2 . ' ';
+ }
+
+ $list_navigator_html .= '
';
+
+ if ($pos + $max_count < $count) {
+ $caption3 = '';
+ $caption4 = '';
+ if (Util::showText('TableNavigationLinksMode')) {
+ $caption3 .= _pgettext('Next page', 'Next');
+ $caption4 .= _pgettext('Last page', 'End');
+ }
+ if (Util::showIcons('TableNavigationLinksMode')) {
+ $caption3 .= ' >';
+ $caption4 .= ' >>';
+ }
+ $title3 = ' title="' . _pgettext('Next page', 'Next') . '"';
+ $title4 = ' title="' . _pgettext('Last page', 'End') . '"';
+
+ $_url_params[$name] = $pos + $max_count;
+ $list_navigator_html .= '
' . $caption3
+ . ' ';
+
+ $_url_params[$name] = floor($count / $max_count) * $max_count;
+ if ($_url_params[$name] == $count) {
+ $_url_params[$name] = $count - $max_count;
+ }
+
+ $list_navigator_html .= '
'
+ . $caption4 . ' ';
+ }
+ $list_navigator_html .= '
' . "\n";
+ }
+
+ return $list_navigator_html;
+ }
+
+ /**
+ * format sql strings
+ *
+ * @param string $sqlQuery raw SQL string
+ * @param boolean $truncate truncate the query if it is too long
+ *
+ * @return string the formatted sql
+ *
+ * @global array $cfg the configuration array
+ *
+ * @access public
+ */
+ public static function formatSql($sqlQuery, $truncate = false): string
+ {
+ global $cfg;
+
+ if ($truncate
+ && mb_strlen($sqlQuery) > $cfg['MaxCharactersInDisplayedSQL']
+ ) {
+ $sqlQuery = mb_substr(
+ $sqlQuery,
+ 0,
+ $cfg['MaxCharactersInDisplayedSQL']
+ ) . '[...]';
+ }
+ return '' . "\n"
+ . htmlspecialchars($sqlQuery) . "\n"
+ . ' ';
+ }
+
+ /**
+ * This function processes the datatypes supported by the DB,
+ * as specified in Types->getColumns() and returns an HTML snippet that
+ * creates a drop-down list.
+ *
+ * @param string $selected The value to mark as selected in HTML mode
+ *
+ * @return string
+ */
+ public static function getSupportedDatatypes($selected): string
+ {
+ // NOTE: the SELECT tag is not included in this snippet.
+ $retval = '';
+
+ foreach ($GLOBALS['dbi']->types->getColumns() as $key => $value) {
+ if (is_array($value)) {
+ $retval .= " ";
+ foreach ($value as $subvalue) {
+ if ($subvalue == $selected) {
+ $retval .= sprintf(
+ '%s ',
+ $GLOBALS['dbi']->types->getTypeDescription($subvalue),
+ $subvalue
+ );
+ } elseif ($subvalue === '-') {
+ $retval .= '';
+ $retval .= $subvalue;
+ $retval .= ' ';
+ } else {
+ $retval .= sprintf(
+ '%s ',
+ $GLOBALS['dbi']->types->getTypeDescription($subvalue),
+ $subvalue
+ );
+ }
+ }
+ $retval .= ' ';
+ } elseif ($selected == $value) {
+ $retval .= sprintf(
+ '
%s ',
+ $GLOBALS['dbi']->types->getTypeDescription($value),
+ $value
+ );
+ } else {
+ $retval .= sprintf(
+ '
%s ',
+ $GLOBALS['dbi']->types->getTypeDescription($value),
+ $value
+ );
+ }
+ }
+ return $retval;
+ }
+}
diff --git a/libraries/classes/Html/MySQLDocumentation.php b/libraries/classes/Html/MySQLDocumentation.php
new file mode 100644
index 0000000000..44dbb1cc14
--- /dev/null
+++ b/libraries/classes/Html/MySQLDocumentation.php
@@ -0,0 +1,101 @@
+';
+ $closeLink = '';
+
+ if ($bigIcon) {
+ $html = $openLink .
+ Generator::getImage('b_sqlhelp', __('Documentation'))
+ . $closeLink;
+ } elseif ($text !== null) {
+ $html = $openLink . $text . $closeLink;
+ } else {
+ $html = Generator::showDocumentationLink($url, 'mysql_doc');
+ }
+
+ return $html;
+ }
+
+ /**
+ * Displays a link to the phpMyAdmin documentation
+ *
+ * @param string $page Page in documentation
+ * @param string $anchor Optional anchor in page
+ * @param boolean $bbcode Optional flag indicating whether to output bbcode
+ *
+ * @return string the html link
+ *
+ * @access public
+ */
+ public static function showDocumentation($page, $anchor = '', $bbcode = false): string
+ {
+ return Generator::showDocumentationLink(self::getDocumentationLink($page, $anchor), 'documentation', $bbcode);
+ }
+
+ /**
+ * Returns link to documentation.
+ *
+ * @param string $page Page in documentation
+ * @param string $anchor Optional anchor in page
+ *
+ * @return string URL
+ */
+ public static function getDocumentationLink($page, $anchor = ''): string
+ {
+ /* Construct base URL */
+ $url = $page . '.html';
+ if (! empty($anchor)) {
+ $url .= '#' . $anchor;
+ }
+
+ /* Check if we have built local documentation, however
+ * provide consistent URL for testsuite
+ */
+ if (! defined('TESTSUITE') && @file_exists(ROOT_PATH . 'doc/html/index.html')) {
+ return 'doc/html/' . $url;
+ }
+
+ return Core::linkURL('https://docs.phpmyadmin.net/en/latest/' . $url);
+ }
+}
diff --git a/libraries/classes/Import.php b/libraries/classes/Import.php
index f153154945..dc058fae4d 100644
--- a/libraries/classes/Import.php
+++ b/libraries/classes/Import.php
@@ -1451,7 +1451,7 @@ class Import
$matched_rows_url = Url::getFromRoute('/sql', $_url_params);
return [
- 'sql_query' => Util::formatSql($analyzed_sql_results['query']),
+ 'sql_query' => Html\Generator::formatSql($analyzed_sql_results['query']),
'matched_rows' => $matched_rows,
'matched_rows_url' => $matched_rows_url,
];
diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php
index 5c69265303..62a454f37c 100644
--- a/libraries/classes/Index.php
+++ b/libraries/classes/Index.php
@@ -8,6 +8,9 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Html\MySQLDocumentation;
+
/**
* Index manipulation class
*
@@ -533,7 +536,7 @@ class Index
$types[$type] = $type;
}
- return Util::getDropdown(
+ return Html\Forms\Fields\DropDown::generate(
"index[Index_type]",
$types,
$this->_type,
@@ -689,7 +692,7 @@ class Index
if (! $print_mode) {
$r = '
';
$r .= '';
$r .= $no_indexes;
@@ -738,7 +741,7 @@ class Index
. ' ' . Util::getIcon('b_edit', __('Edit')) . ' '
+ . '">' . Generator::getIcon('b_edit', __('Edit')) . ''
. ' ' . "\n";
$this_params = $GLOBALS['url_params'];
if ($index->getName() == 'PRIMARY') {
@@ -762,9 +765,9 @@ class Index
$r .= '';
$r .= ' ';
- $r .= Util::linkOrButton(
+ $r .= Generator::linkOrButton(
Url::getFromRoute('/sql', $this_params),
- Util::getIcon('b_drop', __('Drop')),
+ Generator::getIcon('b_drop', __('Drop')),
['class' => 'drop_primary_key_index_anchor ajax']
);
$r .= ' ' . "\n";
diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php
index 0153c9a4d8..f50bbf65ae 100644
--- a/libraries/classes/InsertEdit.php
+++ b/libraries/classes/InsertEdit.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Plugins\TransformationsPlugin;
/**
@@ -188,7 +189,7 @@ class InsertEdit
if (! $rows[$key_id]) {
unset($rows[$key_id], $where_clause_array[$key_id]);
Response::getInstance()->addHTML(
- Util::getMessage(
+ Generator::getMessage(
__('MySQL returned an empty result set (i.e. zero rows).'),
$local_query
)
@@ -200,7 +201,7 @@ class InsertEdit
} else {// end if (no row returned)
$meta = $this->dbi->getFieldsMeta($result[$key_id]);
- list($unique_condition, $tmp_clause_is_unique)
+ [$unique_condition, $tmp_clause_is_unique]
= Util::getUniqueCondition(
$result[$key_id], // handle
count($meta), // fields_cnt
@@ -372,7 +373,7 @@ class InsertEdit
]
);
- list($column['pma_type'], $column['wrap'], $column['first_timestamp'])
+ [$column['pma_type'], $column['wrap'], $column['first_timestamp']]
= $this->getEnumSetAndTimestampColumns($column, $timestamp_seen);
return $column;
@@ -490,7 +491,7 @@ class InsertEdit
$insert_mode,
$readOnly,
array $foreignData
- ) {
+ ): string {
$html_output = '';
if (($GLOBALS['cfg']['ProtectBinary'] === 'blob'
&& $column['is_blob'] && ! $is_upload)
@@ -513,7 +514,7 @@ class InsertEdit
. ' ' . $onChangeClause
. ' tabindex="' . ($tabindex + $tabindex_for_function) . '"'
. ' id="field_' . $idindex . '_1">';
- $html_output .= Util::getFunctionsForField(
+ $html_output .= Generator::getFunctionsForField(
$column,
$insert_mode,
$foreignData
@@ -867,7 +868,7 @@ class InsertEdit
array $titles,
$readOnly
) {
- list($table, $db) = $paramTableDbArray;
+ [$table, $db] = $paramTableDbArray;
$html_output = '';
$html_output .= $backup_field . "\n";
@@ -1264,7 +1265,7 @@ class InsertEdit
$data,
$readOnly
) {
- list($column_set_values, $select_size) = $this->getColumnSetValueAndSelectSize(
+ [$column_set_values, $select_size] = $this->getColumnSetValueAndSelectSize(
$column,
$extracted_columnspec
);
@@ -1436,7 +1437,9 @@ class InsertEdit
. ' name="fields_upload' . $vkey . '[' . $column['Field_md5'] . ']"'
. ' class="textfield noDragDrop" id="field_' . $idindex . '_3" size="10"'
. ' ' . $onChangeClause . '> ';
- list($html_out,) = $this->getMaxUploadSize(
+ [
+ $html_out,
+ ] = $this->getMaxUploadSize(
$column,
$biggest_max_file_size
);
@@ -1741,9 +1744,9 @@ class InsertEdit
*/
private function getHtmlForGisDataTypes()
{
- $edit_str = Util::getIcon('b_edit', __('Edit/Insert'));
+ $edit_str = Generator::getIcon('b_edit', __('Edit/Insert'));
return ''
- . Util::linkOrButton(
+ . Generator::linkOrButton(
'#',
$edit_str,
[],
@@ -1921,21 +1924,21 @@ class InsertEdit
private function getSubmitAndResetButtonForActionsPanel($tabindex, $tabindex_for_value)
{
return ' '
- . Util::showHint(
- __(
- 'Use TAB key to move from value to value,'
- . ' or CTRL+arrows to move anywhere.'
+ . Generator::showHint(
+ __(
+ 'Use TAB key to move from value to value,'
+ . ' or CTRL+arrows to move anywhere.'
+ )
)
- )
- . ' '
- . ''
- . ' '
- . ''
- . ''
- . ' ';
+ . ''
+ . ''
+ . ' '
+ . ''
+ . ''
+ . ' ';
}
/**
@@ -2217,7 +2220,7 @@ class InsertEdit
$meta = $this->dbi->getFieldsMeta($res);
// must find a unique condition based on unique key,
// not a combination of all fields
- list($unique_condition, $clause_is_unique)
+ [$unique_condition, $clause_is_unique]
= Util::getUniqueCondition(
$res, // handle
count($meta), // fields_cnt
@@ -2441,7 +2444,7 @@ class InsertEdit
DatabaseInterface::QUERY_STORE
);
if ($dispresult && $this->dbi->numRows($dispresult) > 0) {
- list($dispval) = $this->dbi->fetchRow($dispresult);
+ [$dispval] = $this->dbi->fetchRow($dispresult);
} else {
$dispval = '';
}
@@ -2928,7 +2931,7 @@ class InsertEdit
// we are editing
$insert_mode = false;
$where_clause_array = $this->getWhereClauseArray($where_clause);
- list($where_clauses, $result, $rows, $found_unique_key)
+ [$where_clauses, $result, $rows, $found_unique_key]
= $this->analyzeWhereClauses(
$where_clause_array,
$table,
@@ -2938,7 +2941,7 @@ class InsertEdit
// we are inserting
$insert_mode = true;
$where_clause = null;
- list($result, $rows) = $this->loadFirstRow($table, $db);
+ [$result, $rows] = $this->loadFirstRow($table, $db);
$where_clauses = null;
$where_clause_array = [];
$found_unique_key = false;
@@ -3226,10 +3229,13 @@ class InsertEdit
$special_chars_encoded = '';
if (! empty($current_row)) {
// (we are editing)
- list(
- $real_null_value, $special_chars_encoded, $special_chars,
- $data, $backup_field
- )
+ [
+ $real_null_value,
+ $special_chars_encoded,
+ $special_chars,
+ $data,
+ $backup_field,
+ ]
= $this->getSpecialCharsAndBackupFieldForExistingRow(
$current_row,
$column,
@@ -3246,9 +3252,13 @@ class InsertEdit
if (isset($repopulate[$column['Field_md5']])) {
$tmp['Default'] = $repopulate[$column['Field_md5']];
}
- list($real_null_value, $data, $special_chars, $backup_field,
- $special_chars_encoded
- )
+ [
+ $real_null_value,
+ $data,
+ $special_chars,
+ $backup_field,
+ $special_chars_encoded,
+ ]
= $this->getSpecialCharsAndBackupFieldForInsertingMode(
$tmp,
$real_null_value
diff --git a/libraries/classes/LanguageManager.php b/libraries/classes/LanguageManager.php
index 55fe739aa7..9ef41b6e04 100644
--- a/libraries/classes/LanguageManager.php
+++ b/libraries/classes/LanguageManager.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Language;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
@@ -952,7 +953,7 @@ class LanguageManager
$language_title = __('Language')
. (__('Language') != 'Language' ? ' - Language ' : '');
if ($show_doc) {
- $language_title .= Util::showDocu('faq', 'faq7-2');
+ $language_title .= MySQLDocumentation::showDocumentation('faq', 'faq7-2');
}
$available_languages = $this->sortedLanguages();
diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php
index 7dc6e8bb48..a7fea42f1d 100644
--- a/libraries/classes/Menu.php
+++ b/libraries/classes/Menu.php
@@ -8,6 +8,8 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Generator;
+
/**
* Class for generating the top menu
*
@@ -113,7 +115,7 @@ class Menu
unset($tabs[$key]);
}
}
- return Util::getHtmlTabs($tabs, $url_params, 'topmenu', true);
+ return Generator::getHtmlTabs($tabs, $url_params, 'topmenu', true);
}
/**
@@ -190,7 +192,7 @@ class Menu
$retval .= "";
$retval .= "";
if (Util::showIcons('TabsMode')) {
- $retval .= Util::getImage(
+ $retval .= Generator::getImage(
's_host',
'',
['class' => 'item']
@@ -211,7 +213,7 @@ class Menu
if (strlen($this->_db) > 0) {
$retval .= $separator;
if (Util::showIcons('TabsMode')) {
- $retval .= Util::getImage(
+ $retval .= Generator::getImage(
's_db',
'',
['class' => 'item']
@@ -247,7 +249,7 @@ class Menu
$retval .= $separator;
if (Util::showIcons('TabsMode')) {
$icon = $tbl_is_view ? 'b_views' : 's_tbl';
- $retval .= Util::getImage(
+ $retval .= Generator::getImage(
$icon,
'',
['class' => 'item']
diff --git a/libraries/classes/Message.php b/libraries/classes/Message.php
index b6bf75b3f2..1350675990 100644
--- a/libraries/classes/Message.php
+++ b/libraries/classes/Message.php
@@ -817,7 +817,7 @@ class Message
} else {
$image = 's_notice';
}
- $message = self::notice(Util::getImage($image)) . " " . $message;
+ $message = self::notice(Html\Generator::getImage($image)) . " " . $message;
return $message;
}
}
diff --git a/libraries/classes/MultSubmits.php b/libraries/classes/MultSubmits.php
index 47bfb6cd9d..11162d6867 100644
--- a/libraries/classes/MultSubmits.php
+++ b/libraries/classes/MultSubmits.php
@@ -10,6 +10,8 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Forms\Fields\FKCheckbox;
+
/**
* Functions for multi submit forms
*
@@ -523,7 +525,7 @@ class MultSubmits
// Display option to disable foreign key checks while dropping tables
if ($what === 'drop_tbl' || $what === 'empty_tbl' || $what === 'row_delete') {
$html .= '
';
- $html .= Util::getFKCheckbox();
+ $html .= FKCheckbox::generate();
$html .= '
';
}
$html .= '
';
$retval .= '
';
- $retval .= Util::getNavigationLink(
+ $retval .= Generator::getNavigationLink(
'#',
$showText,
__('Collapse all'),
@@ -1457,7 +1458,7 @@ class NavigationTree
$syncImage = 's_link';
$title = __('Unlink from main panel');
}
- $retval .= Util::getNavigationLink(
+ $retval .= Generator::getNavigationLink(
'#',
$showText,
$title,
@@ -1484,7 +1485,7 @@ class NavigationTree
{
$retval = '';
if ($node === $this->tree) {
- $retval .= Util::getListNavigator(
+ $retval .= Generator::getListNavigator(
$this->tree->getPresence('databases', $this->searchClause),
$this->pos,
['server' => $GLOBALS['server']],
@@ -1518,7 +1519,7 @@ class NavigationTree
$node->realName,
$this->searchClause2
);
- $retval .= Util::getListNavigator(
+ $retval .= Generator::getListNavigator(
$num,
$pos,
$urlParams,
diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php
index cc8b24b904..c9f2ac44f6 100644
--- a/libraries/classes/Navigation/Nodes/Node.php
+++ b/libraries/classes/Navigation/Nodes/Node.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Util;
@@ -801,10 +802,10 @@ class Node
} elseif ($match) {
$this->visible = true;
- return Util::getImage('b_minus');
+ return Generator::getImage('b_minus');
}
- return Util::getImage('b_plus', __('Expand/Collapse'));
+ return Generator::getImage('b_plus', __('Expand/Collapse'));
}
/**
diff --git a/libraries/classes/Navigation/Nodes/NodeColumn.php b/libraries/classes/Navigation/Nodes/NodeColumn.php
index 9a009335cf..4ee90cbe98 100644
--- a/libraries/classes/Navigation/Nodes/NodeColumn.php
+++ b/libraries/classes/Navigation/Nodes/NodeColumn.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -31,7 +32,7 @@ class NodeColumn extends Node
$this->displayName = $this->getDisplayName($item);
parent::__construct($item['name'], $type, $isGroup);
- $this->icon = Util::getImage($this->getColumnIcon($item['key']), __('Column'));
+ $this->icon = Generator::getImage($this->getColumnIcon($item['key']), __('Column'));
$this->links = [
'text' => Url::getFromRoute('/table/structure', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeColumnContainer.php b/libraries/classes/Navigation/Nodes/NodeColumnContainer.php
index a6d4945b64..fd260af3a4 100644
--- a/libraries/classes/Navigation/Nodes/NodeColumnContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeColumnContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeColumnContainer extends Node
public function __construct()
{
parent::__construct(__('Columns'), Node::CONTAINER);
- $this->icon = Util::getImage('pause', __('Columns'));
+ $this->icon = Generator::getImage('pause', __('Columns'));
$this->links = [
'text' => Url::getFromRoute('/table/structure', [
'server' => $GLOBALS['server'],
@@ -46,7 +47,7 @@ class NodeColumnContainer extends Node
$newLabel
);
$new->isNew = true;
- $new->icon = Util::getImage('b_column_add', $newLabel);
+ $new->icon = Generator::getImage('b_column_add', $newLabel);
$new->links = [
'text' => Url::getFromRoute('/table/addfield', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeDatabase.php b/libraries/classes/Navigation/Nodes/NodeDatabase.php
index 9f1ae622bc..b3793a31d7 100644
--- a/libraries/classes/Navigation/Nodes/NodeDatabase.php
+++ b/libraries/classes/Navigation/Nodes/NodeDatabase.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -37,7 +38,7 @@ class NodeDatabase extends Node
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage(
+ $this->icon = Generator::getImage(
's_db',
__('Database operations')
);
@@ -682,7 +683,7 @@ class NodeDatabase extends Node
. '
'
- . Util::getImage(
+ . Generator::getImage(
'show',
__('Show hidden items')
)
diff --git a/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php b/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php
index 4b6d3f06dd..baee76215e 100644
--- a/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php
+++ b/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -52,7 +53,7 @@ abstract class NodeDatabaseChild extends Node
. ' '
- . Util::getImage('hide', __('Hide'))
+ . Generator::getImage('hide', __('Hide'))
. ' ';
}
diff --git a/libraries/classes/Navigation/Nodes/NodeDatabaseContainer.php b/libraries/classes/Navigation/Nodes/NodeDatabaseContainer.php
index c8b8d7e547..351131ecea 100644
--- a/libraries/classes/Navigation/Nodes/NodeDatabaseContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeDatabaseContainer.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
use PhpMyAdmin\CheckUserPrivileges;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -40,7 +41,7 @@ class NodeDatabaseContainer extends Node
_pgettext('Create new database', 'New')
);
$new->isNew = true;
- $new->icon = Util::getImage('b_newdb', '');
+ $new->icon = Generator::getImage('b_newdb', '');
$new->links = [
'text' => Url::getFromRoute('/server/databases', ['server' => $GLOBALS['server']]),
'icon' => Url::getFromRoute('/server/databases', ['server' => $GLOBALS['server']]),
diff --git a/libraries/classes/Navigation/Nodes/NodeEvent.php b/libraries/classes/Navigation/Nodes/NodeEvent.php
index 0a7da28d8f..20317e97f1 100644
--- a/libraries/classes/Navigation/Nodes/NodeEvent.php
+++ b/libraries/classes/Navigation/Nodes/NodeEvent.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,7 +30,7 @@ class NodeEvent extends NodeDatabaseChild
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage('b_events');
+ $this->icon = Generator::getImage('b_events');
$this->links = [
'text' => Url::getFromRoute('/database/events', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeEventContainer.php b/libraries/classes/Navigation/Nodes/NodeEventContainer.php
index ec88139e69..5762734d72 100644
--- a/libraries/classes/Navigation/Nodes/NodeEventContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeEventContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeEventContainer extends NodeDatabaseChildContainer
public function __construct()
{
parent::__construct(__('Events'), Node::CONTAINER);
- $this->icon = Util::getImage('b_events', '');
+ $this->icon = Generator::getImage('b_events', '');
$this->links = [
'text' => Url::getFromRoute('/database/events', [
'server' => $GLOBALS['server'],
@@ -41,7 +42,7 @@ class NodeEventContainer extends NodeDatabaseChildContainer
_pgettext('Create new event', 'New')
);
$new->isNew = true;
- $new->icon = Util::getImage('b_event_add', '');
+ $new->icon = Generator::getImage('b_event_add', '');
$new->links = [
'text' => Url::getFromRoute('/database/events', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeFunction.php b/libraries/classes/Navigation/Nodes/NodeFunction.php
index 91e5437978..04467668e5 100644
--- a/libraries/classes/Navigation/Nodes/NodeFunction.php
+++ b/libraries/classes/Navigation/Nodes/NodeFunction.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,7 +30,7 @@ class NodeFunction extends NodeDatabaseChild
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage('b_routines', __('Function'));
+ $this->icon = Generator::getImage('b_routines', __('Function'));
$this->links = [
'text' => Url::getFromRoute('/database/routines', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeFunctionContainer.php b/libraries/classes/Navigation/Nodes/NodeFunctionContainer.php
index b5046e9b87..2e954c0d74 100644
--- a/libraries/classes/Navigation/Nodes/NodeFunctionContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeFunctionContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeFunctionContainer extends NodeDatabaseChildContainer
public function __construct()
{
parent::__construct(__('Functions'), Node::CONTAINER);
- $this->icon = Util::getImage('b_routines', __('Functions'));
+ $this->icon = Generator::getImage('b_routines', __('Functions'));
$this->links = [
'text' => Url::getFromRoute('/database/routines', [
'server' => $GLOBALS['server'],
@@ -44,7 +45,7 @@ class NodeFunctionContainer extends NodeDatabaseChildContainer
$newLabel
);
$new->isNew = true;
- $new->icon = Util::getImage('b_routine_add', $newLabel);
+ $new->icon = Generator::getImage('b_routine_add', $newLabel);
$new->links = [
'text' => Url::getFromRoute('/database/routines', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeIndex.php b/libraries/classes/Navigation/Nodes/NodeIndex.php
index 5eb8faec7c..cf619094e9 100644
--- a/libraries/classes/Navigation/Nodes/NodeIndex.php
+++ b/libraries/classes/Navigation/Nodes/NodeIndex.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,7 +30,7 @@ class NodeIndex extends Node
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage('b_index', __('Index'));
+ $this->icon = Generator::getImage('b_index', __('Index'));
$this->links = [
'text' => Url::getFromRoute('/table/indexes', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeIndexContainer.php b/libraries/classes/Navigation/Nodes/NodeIndexContainer.php
index f3bc23d638..84ad3ed9e1 100644
--- a/libraries/classes/Navigation/Nodes/NodeIndexContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeIndexContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeIndexContainer extends Node
public function __construct()
{
parent::__construct(__('Indexes'), Node::CONTAINER);
- $this->icon = Util::getImage('b_index', __('Indexes'));
+ $this->icon = Generator::getImage('b_index', __('Indexes'));
$this->links = [
'text' => Url::getFromRoute('/table/structure', [
'server' => $GLOBALS['server'],
@@ -46,7 +47,7 @@ class NodeIndexContainer extends Node
$newLabel
);
$new->isNew = true;
- $new->icon = Util::getImage('b_index_add', $newLabel);
+ $new->icon = Generator::getImage('b_index_add', $newLabel);
$new->links = [
'text' => Url::getFromRoute('/table/indexes', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeProcedure.php b/libraries/classes/Navigation/Nodes/NodeProcedure.php
index 3bd8683e10..09b2dc2eca 100644
--- a/libraries/classes/Navigation/Nodes/NodeProcedure.php
+++ b/libraries/classes/Navigation/Nodes/NodeProcedure.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,7 +30,7 @@ class NodeProcedure extends NodeDatabaseChild
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage('b_routines', __('Procedure'));
+ $this->icon = Generator::getImage('b_routines', __('Procedure'));
$this->links = [
'text' => Url::getFromRoute('/database/routines', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeProcedureContainer.php b/libraries/classes/Navigation/Nodes/NodeProcedureContainer.php
index 7905a1bf57..f5f477efec 100644
--- a/libraries/classes/Navigation/Nodes/NodeProcedureContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeProcedureContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeProcedureContainer extends NodeDatabaseChildContainer
public function __construct()
{
parent::__construct(__('Procedures'), Node::CONTAINER);
- $this->icon = Util::getImage('b_routines', __('Procedures'));
+ $this->icon = Generator::getImage('b_routines', __('Procedures'));
$this->links = [
'text' => Url::getFromRoute('/database/routines', [
'server' => $GLOBALS['server'],
@@ -44,7 +45,7 @@ class NodeProcedureContainer extends NodeDatabaseChildContainer
$newLabel
);
$new->isNew = true;
- $new->icon = Util::getImage('b_routine_add', $newLabel);
+ $new->icon = Generator::getImage('b_routine_add', $newLabel);
$new->links = [
'text' => Url::getFromRoute('/database/routines', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeTable.php b/libraries/classes/Navigation/Nodes/NodeTable.php
index 5606fc9af1..58caa5af0f 100644
--- a/libraries/classes/Navigation/Nodes/NodeTable.php
+++ b/libraries/classes/Navigation/Nodes/NodeTable.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -293,19 +294,19 @@ class NodeTable extends NodeDatabaseChild
switch ($page) {
case Url::getFromRoute('/table/structure'):
- $this->icon[] = Util::getImage('b_props', __('Structure'));
+ $this->icon[] = Generator::getImage('b_props', __('Structure'));
break;
case Url::getFromRoute('/table/search'):
- $this->icon[] = Util::getImage('b_search', __('Search'));
+ $this->icon[] = Generator::getImage('b_search', __('Search'));
break;
case Url::getFromRoute('/table/change'):
- $this->icon[] = Util::getImage('b_insrow', __('Insert'));
+ $this->icon[] = Generator::getImage('b_insrow', __('Insert'));
break;
case Url::getFromRoute('/table/sql'):
- $this->icon[] = Util::getImage('b_sql', __('SQL'));
+ $this->icon[] = Generator::getImage('b_sql', __('SQL'));
break;
case Url::getFromRoute('/sql'):
- $this->icon[] = Util::getImage('b_browse', __('Browse'));
+ $this->icon[] = Generator::getImage('b_browse', __('Browse'));
break;
}
}
diff --git a/libraries/classes/Navigation/Nodes/NodeTableContainer.php b/libraries/classes/Navigation/Nodes/NodeTableContainer.php
index a4f4742240..3b0da72391 100644
--- a/libraries/classes/Navigation/Nodes/NodeTableContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeTableContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeTableContainer extends NodeDatabaseChildContainer
public function __construct()
{
parent::__construct(__('Tables'), Node::CONTAINER);
- $this->icon = Util::getImage('b_browse', __('Tables'));
+ $this->icon = Generator::getImage('b_browse', __('Tables'));
$this->links = [
'text' => Url::getFromRoute('/database/structure', [
'server' => $GLOBALS['server'],
@@ -47,7 +48,7 @@ class NodeTableContainer extends NodeDatabaseChildContainer
$newLabel
);
$new->isNew = true;
- $new->icon = Util::getImage('b_table_add', $newLabel);
+ $new->icon = Generator::getImage('b_table_add', $newLabel);
$new->links = [
'text' => Url::getFromRoute('/table/create', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeTrigger.php b/libraries/classes/Navigation/Nodes/NodeTrigger.php
index 99da37544a..561403cbbe 100644
--- a/libraries/classes/Navigation/Nodes/NodeTrigger.php
+++ b/libraries/classes/Navigation/Nodes/NodeTrigger.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,7 +30,7 @@ class NodeTrigger extends Node
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage('b_triggers');
+ $this->icon = Generator::getImage('b_triggers');
$this->links = [
'text' => Url::getFromRoute('/database/triggers', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeTriggerContainer.php b/libraries/classes/Navigation/Nodes/NodeTriggerContainer.php
index b3384a0a70..7d190a0a67 100644
--- a/libraries/classes/Navigation/Nodes/NodeTriggerContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeTriggerContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeTriggerContainer extends Node
public function __construct()
{
parent::__construct(__('Triggers'), Node::CONTAINER);
- $this->icon = Util::getImage('b_triggers');
+ $this->icon = Generator::getImage('b_triggers');
$this->links = [
'text' => Url::getFromRoute('/database/triggers', [
'server' => $GLOBALS['server'],
@@ -41,7 +42,7 @@ class NodeTriggerContainer extends Node
_pgettext('Create new trigger', 'New')
);
$new->isNew = true;
- $new->icon = Util::getImage('b_trigger_add', '');
+ $new->icon = Generator::getImage('b_trigger_add', '');
$new->links = [
'text' => Url::getFromRoute('/database/triggers', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Navigation/Nodes/NodeView.php b/libraries/classes/Navigation/Nodes/NodeView.php
index c91eec4c25..af64386d41 100644
--- a/libraries/classes/Navigation/Nodes/NodeView.php
+++ b/libraries/classes/Navigation/Nodes/NodeView.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,7 +30,7 @@ class NodeView extends NodeDatabaseChild
public function __construct($name, $type = Node::OBJECT, $isGroup = false)
{
parent::__construct($name, $type, $isGroup);
- $this->icon = Util::getImage('b_props', __('View'));
+ $this->icon = Generator::getImage('b_props', __('View'));
$this->links = [
'text' => Url::getFromRoute('/sql')
. '&server=' . $GLOBALS['server']
diff --git a/libraries/classes/Navigation/Nodes/NodeViewContainer.php b/libraries/classes/Navigation/Nodes/NodeViewContainer.php
index 89a6d19460..e5fd0c2ae2 100644
--- a/libraries/classes/Navigation/Nodes/NodeViewContainer.php
+++ b/libraries/classes/Navigation/Nodes/NodeViewContainer.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeFactory;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -25,7 +26,7 @@ class NodeViewContainer extends NodeDatabaseChildContainer
public function __construct()
{
parent::__construct(__('Views'), Node::CONTAINER);
- $this->icon = Util::getImage('b_views', __('Views'));
+ $this->icon = Generator::getImage('b_views', __('Views'));
$this->links = [
'text' => Url::getFromRoute('/database/structure', [
'server' => $GLOBALS['server'],
@@ -47,7 +48,7 @@ class NodeViewContainer extends NodeDatabaseChildContainer
$newLabel
);
$new->isNew = true;
- $new->icon = Util::getImage('b_view_add', $newLabel);
+ $new->icon = Generator::getImage('b_view_add', $newLabel);
$new->links = [
'text' => Url::getFromRoute('/view/create', [
'server' => $GLOBALS['server'],
diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php
index 1110a5e63a..17fe8dcdb6 100644
--- a/libraries/classes/Normalization.php
+++ b/libraries/classes/Normalization.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Charsets\Charset;
use PhpMyAdmin\Charsets\Collation;
+use PhpMyAdmin\Html\Generator;
/**
* Set of functions used for normalization
@@ -279,7 +280,7 @@ class Normalization
. "(or combination of columns) that uniquely identify all rows."
);
$subText = '
'
- . Util::getIcon(
+ . Generator::getIcon(
'b_index_add',
__(
'Add a primary key on existing column(s)'
@@ -920,7 +921,7 @@ class Normalization
'3nf' => __('Third step of normalization (1NF+2NF+3NF)'),
];
- $htmlOutput .= Util::getRadioFields(
+ $htmlOutput .= Html\Forms\Fields\RadioList::generate(
'normalizeTo',
$choices,
'1nf',
diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php
index 3a7867efb1..610c5636a4 100644
--- a/libraries/classes/Operations.php
+++ b/libraries/classes/Operations.php
@@ -11,6 +11,10 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Charsets\Charset;
use PhpMyAdmin\Charsets\Collation;
use PhpMyAdmin\Engines\Innodb;
+use PhpMyAdmin\Html\Forms\Fields\DropDown;
+use PhpMyAdmin\Html\Forms\Fields\RadioList;
+use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Plugins\Export\ExportSql;
/**
@@ -59,7 +63,7 @@ class Operations
. ' '
. '';
if (Util::showIcons('ActionLinksMode')) {
- $html_output .= Util::getImage('b_comment') . ' ';
+ $html_output .= Generator::getImage('b_comment') . ' ';
}
$html_output .= __('Database comment');
$html_output .= ' ';
@@ -103,7 +107,7 @@ class Operations
. '';
if (Util::showIcons('ActionLinksMode')) {
- $html_output .= Util::getImage('b_edit') . ' ';
+ $html_output .= Generator::getImage('b_edit') . ' ';
}
$html_output .= __('Rename database to')
. ' ';
@@ -128,7 +132,7 @@ class Operations
}
$html_output .= ''
- . __('Adjust privileges') . Util::showDocu('faq', 'faq6-39')
+ . __('Adjust privileges') . MySQLDocumentation::showDocumentation('faq', 'faq6-39')
. ' ';
$html_output .= ''
@@ -169,7 +173,7 @@ class Operations
. '';
$html_output .= '';
if (Util::showIcons('ActionLinksMode')) {
- $html_output .= Util::getImage('b_deltbl') . ' ';
+ $html_output .= Generator::getImage('b_deltbl') . ' ';
}
$html_output .= __('Remove database')
. ' ';
@@ -221,13 +225,13 @@ class Operations
. '';
if (Util::showIcons('ActionLinksMode')) {
- $html_output .= Util::getImage('b_edit') . ' ';
+ $html_output .= Generator::getImage('b_edit') . ' ';
}
$html_output .= __('Copy database to')
. ' '
. ' '
- . Util::getRadioFields(
+ . RadioList::generate(
'what',
$choices,
'data',
@@ -269,7 +273,7 @@ class Operations
. '" disabled>';
}
$html_output .= ''
- . __('Adjust privileges') . Util::showDocu('faq', 'faq6-39')
+ . __('Adjust privileges') . MySQLDocumentation::showDocumentation('faq', 'faq6-39')
. ' ';
$html_output .= ' ';
if (Util::showIcons('ActionLinksMode')) {
- $html_output .= Util::getImage('s_asci') . ' ';
+ $html_output .= Generator::getImage('s_asci') . ' ';
}
$html_output .= '' . __('Collation')
. ' ' . "\n"
@@ -925,7 +929,7 @@ class Operations
. '" disabled>';
}
$html_output .= ''
- . __('Adjust privileges') . Util::showDocu('faq', 'faq6-39')
+ . __('Adjust privileges') . MySQLDocumentation::showDocumentation('faq', 'faq6-39')
. ' ';
$html_output .= ' \n";
$retval .= "\n";
$retval .= "\n\n";
@@ -155,12 +157,15 @@ class Footer
$retval .= " \n";
$retval .= "
\n";
// show the toggle button
- $retval .= Util::toggleButton(
- Url::getFromRoute('/sql', [
- 'db' => $db,
- 'table' => $table,
- 'goto' => Url::getFromRoute('/database/events', ['db' => $db]),
- ]),
+ $retval .= Generator::toggleButton(
+ Url::getFromRoute(
+ '/sql',
+ [
+ 'db' => $db,
+ 'table' => $table,
+ 'goto' => Url::getFromRoute('/database/events', ['db' => $db]),
+ ]
+ ),
'sql_query',
$options,
'Functions.slidingMessage(data.sql_query);'
diff --git a/libraries/classes/Rte/Routines.php b/libraries/classes/Rte/Routines.php
index 3e34e012e8..fca54a26f5 100644
--- a/libraries/classes/Rte/Routines.php
+++ b/libraries/classes/Rte/Routines.php
@@ -12,6 +12,8 @@ use PhpMyAdmin\Charsets;
use PhpMyAdmin\Charsets\Charset;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\MySQLDocumentation;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\SqlParser\Parser;
@@ -301,7 +303,7 @@ class Routines
. '
'
. __('MySQL said: ') . $this->dbi->getError();
} else {
- list($newErrors, $message) = $this->create(
+ [$newErrors, $message] = $this->create(
$routine_query,
$create_routine,
$privilegesBackup
@@ -350,7 +352,7 @@ class Routines
$message->addHtml('');
}
- $output = Util::getMessage($message, $sql_query);
+ $output = Generator::getMessage($message, $sql_query);
$response = Response::getInstance();
if (! $response->isAjax()) {
return $errors;
@@ -1047,7 +1049,7 @@ class Routines
) {
$retval .= "
";
$retval .= " " . __('Adjust privileges');
- $retval .= Util::showDocu('faq', 'faq6-39');
+ $retval .= MySQLDocumentation::showDocumentation('faq', 'faq6-39');
$retval .= " ";
if ($GLOBALS['proc_priv']
&& $GLOBALS['is_reload_priv']
@@ -1439,7 +1441,7 @@ class Routines
$nbResultsetToDisplay = 0;
if ($outcome) {
// Pass the SQL queries through the "pretty printer"
- $output = Util::formatSql(implode("\n", $queries));
+ $output = Generator::formatSql(implode("\n", $queries));
// Display results
$output .= "";
@@ -1684,7 +1686,7 @@ class Routines
];
$retval .= "";
- $retval .= Util::getFunctionsForField($field, false, []);
+ $retval .= Generator::getFunctionsForField($field, false, []);
$retval .= " ";
}
$retval .= "\n";
diff --git a/libraries/classes/Rte/RteList.php b/libraries/classes/Rte/RteList.php
index 24862e8d61..8e5f691f3f 100644
--- a/libraries/classes/Rte/RteList.php
+++ b/libraries/classes/Rte/RteList.php
@@ -9,6 +9,8 @@ declare(strict_types=1);
namespace PhpMyAdmin\Rte;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\MySQLDocumentation;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Response;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
@@ -101,7 +103,7 @@ class RteList
$retval .= " \n";
$retval .= " " . $this->words->get('title') . "\n";
$retval .= " "
- . Util::showMySQLDocu($this->words->get('docu')) . "\n";
+ . MySQLDocumentation::show($this->words->get('docu')) . "\n";
$retval .= " \n";
$retval .= " \n";
$retval .= " " . $this->words->get('nothing') . "\n";
@@ -186,14 +188,14 @@ class RteList
'text_dir' => $GLOBALS['text_dir'],
'form_name' => 'rteListForm',
]);
- $retval .= Util::getButtonOrImage(
+ $retval .= Generator::getButtonOrImage(
'submit_mult',
'mult_submit',
__('Export'),
'b_export',
'export'
);
- $retval .= Util::getButtonOrImage(
+ $retval .= Generator::getButtonOrImage(
'submit_mult',
'mult_submit',
__('Drop'),
@@ -351,13 +353,16 @@ class RteList
}
$retval .= " \n";
$retval .= "
\n";
- $retval .= Util::linkOrButton(
- Url::getFromRoute('/sql', [
- 'db' => $db,
- 'table' => $table,
- 'sql_query' => $sql_drop,
- 'goto' => Url::getFromRoute('/database/routines', ['db' => $db]),
- ]),
+ $retval .= Generator::linkOrButton(
+ Url::getFromRoute(
+ '/sql',
+ [
+ 'db' => $db,
+ 'table' => $table,
+ 'sql_query' => $sql_drop,
+ 'goto' => Url::getFromRoute('/database/routines', ['db' => $db]),
+ ]
+ ),
$titles['Drop'],
['class' => 'ajax drop_anchor']
);
@@ -435,13 +440,16 @@ class RteList
$retval .= " \n";
$retval .= "
\n";
if (Util::currentUserHasPrivilege('TRIGGER', $db)) {
- $retval .= Util::linkOrButton(
- Url::getFromRoute('/sql', [
- 'db' => $db,
- 'table' => $table,
- 'sql_query' => $trigger['drop'],
- 'goto' => Url::getFromRoute('/database/triggers', ['db' => $db]),
- ]),
+ $retval .= Generator::linkOrButton(
+ Url::getFromRoute(
+ '/sql',
+ [
+ 'db' => $db,
+ 'table' => $table,
+ 'sql_query' => $trigger['drop'],
+ 'goto' => Url::getFromRoute('/database/triggers', ['db' => $db]),
+ ]
+ ),
$titles['Drop'],
['class' => 'ajax drop_anchor']
);
@@ -518,13 +526,16 @@ class RteList
$retval .= " \n";
$retval .= "
\n";
if (Util::currentUserHasPrivilege('EVENT', $db)) {
- $retval .= Util::linkOrButton(
- Url::getFromRoute('/sql', [
- 'db' => $db,
- 'table' => $table,
- 'sql_query' => $sql_drop,
- 'goto' => Url::getFromRoute('/database/events', ['db' => $db]),
- ]),
+ $retval .= Generator::linkOrButton(
+ Url::getFromRoute(
+ '/sql',
+ [
+ 'db' => $db,
+ 'table' => $table,
+ 'sql_query' => $sql_drop,
+ 'goto' => Url::getFromRoute('/database/events', ['db' => $db]),
+ ]
+ ),
$titles['Drop'],
['class' => 'ajax drop_anchor']
);
diff --git a/libraries/classes/Rte/Triggers.php b/libraries/classes/Rte/Triggers.php
index ff615b081e..c4e17efd9d 100644
--- a/libraries/classes/Rte/Triggers.php
+++ b/libraries/classes/Rte/Triggers.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Rte;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Url;
@@ -213,7 +214,7 @@ class Triggers
$message->addHtml('');
}
- $output = Util::getMessage($message, $sql_query);
+ $output = Generator::getMessage($message, $sql_query);
$response = Response::getInstance();
if ($response->isAjax()) {
if ($message->isSuccess()) {
diff --git a/libraries/classes/Sanitize.php b/libraries/classes/Sanitize.php
index a685df4205..520b35923d 100644
--- a/libraries/classes/Sanitize.php
+++ b/libraries/classes/Sanitize.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Util;
/**
@@ -124,7 +125,7 @@ class Sanitize
$page = 'setup';
}
}
- $link = Util::getDocuLink($page, $anchor);
+ $link = MySQLDocumentation::getDocumentationLink($page, $anchor);
return '';
}
@@ -170,7 +171,7 @@ class Sanitize
// used in common.inc.php:
'[conferr]' => '',
// used in libraries/Util.php
- '[dochelpicon]' => Util::getImage('b_help', __('Documentation')),
+ '[dochelpicon]' => Html\Generator::getImage('b_help', __('Documentation')),
];
$message = strtr($message, $replace_pairs);
diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php
index 9965597d61..97aa552152 100644
--- a/libraries/classes/Server/Privileges.php
+++ b/libraries/classes/Server/Privileges.php
@@ -11,6 +11,10 @@ namespace PhpMyAdmin\Server;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Display\ChangePassword;
+use PhpMyAdmin\Html\Forms;
+use PhpMyAdmin\Html\Forms\Fields\DropDown;
+use PhpMyAdmin\Html\MySQLDocumentation;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Relation;
use PhpMyAdmin\RelationCleanup;
@@ -802,7 +806,7 @@ class Privileges
];
}
- $html_output = Util::getDropdown(
+ $html_output = DropDown::generate(
'authentication_plugin',
$active_auth_plugins,
$orig_auth_plugin,
@@ -858,7 +862,7 @@ class Privileges
) {
global $pred_username, $pred_hostname, $username, $hostname, $new_username;
- list($usernameLength, $hostnameLength) = $this->getUsernameAndHostnameLength();
+ [$usernameLength, $hostnameLength] = $this->getUsernameAndHostnameLength();
if (isset($username) && strlen($username) === 0) {
$pred_username = 'any';
@@ -997,7 +1001,7 @@ class Privileges
$authentication_plugin = $row['plugin'];
}
} elseif ($mode == 'change') {
- list($username, $hostname) = $this->dbi->getCurrentUserAndHost();
+ [$username, $hostname] = $this->dbi->getCurrentUserAndHost();
$row = $this->dbi->fetchSingleRow(
'SELECT `plugin` FROM `mysql`.`user` WHERE '
@@ -1153,7 +1157,7 @@ class Privileges
// Update the plugin for the user
if (! $this->dbi->tryQuery($update_plugin_query)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
$this->dbi->getError(),
$update_plugin_query,
false,
@@ -1187,7 +1191,7 @@ class Privileges
}
if (! $this->dbi->tryQuery($local_query)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
$this->dbi->getError(),
$sql_query,
false,
@@ -1642,13 +1646,13 @@ class Privileges
switch ($linktype) {
case 'edit':
- $html .= Util::getIcon('b_usredit', __('Edit privileges'));
+ $html .= Generator::getIcon('b_usredit', __('Edit privileges'));
break;
case 'revoke':
- $html .= Util::getIcon('b_usrdrop', __('Revoke'));
+ $html .= Generator::getIcon('b_usrdrop', __('Revoke'));
break;
case 'export':
- $html .= Util::getIcon('b_tblexport', __('Export'));
+ $html .= Generator::getIcon('b_tblexport', __('Export'));
break;
}
$html .= ' ';
@@ -1748,7 +1752,7 @@ class Privileges
$extra_data = [];
if (strlen($sql_query) > 0) {
- $extra_data['sql_query'] = Util::getMessage(null, $sql_query);
+ $extra_data['sql_query'] = Generator::getMessage(null, $sql_query);
}
if (isset($_POST['change_copy'])) {
@@ -2237,7 +2241,7 @@ class Privileges
DatabaseInterface::QUERY_STORE
);
if ($initials) {
- while (list($tmp_initial) = $this->dbi->fetchRow($initials)) {
+ while ([$tmp_initial] = $this->dbi->fetchRow($initials)) {
$array_initials[$tmp_initial] = true;
}
}
@@ -2527,7 +2531,7 @@ class Privileges
}
foreach ($selected_usr as $each_user) {
- list($this_user, $this_host) = explode('', $each_user);
+ [$this_user, $this_host] = explode('', $each_user);
$queries[] = '# '
. sprintf(
__('Deleting %s'),
@@ -2672,7 +2676,7 @@ class Privileges
];
}
- list(
+ [
$create_user_real,
$create_user_show,
$real_sql_query,
@@ -2680,8 +2684,8 @@ class Privileges
$password_set_real,
$password_set_show,
$alter_real_sql_query,
- $alter_sql_query
- ) = $this->getSqlQueriesForDisplayAndAddUser(
+ $alter_sql_query,
+ ] = $this->getSqlQueriesForDisplayAndAddUser(
$username,
$hostname,
(isset($password) ? $password : '')
@@ -2705,7 +2709,7 @@ class Privileges
$sql_query = $create_user_show . $sql_query;
}
- list($sql_query, $message) = $this->addUserAndCreateDatabase(
+ [$sql_query, $message] = $this->addUserAndCreateDatabase(
$_error,
$real_sql_query,
$sql_query,
@@ -3087,7 +3091,7 @@ class Privileges
. 'from connecting if the host part of their account '
. 'allows a connection from any (%) host.'
)
- . Util::showMySQLDocu('problems-connecting')
+ . MySQLDocumentation::show('problems-connecting')
)->getDisplay();
break 2;
}
@@ -3148,7 +3152,7 @@ class Privileges
. 'the privileges have to be reloaded but currently, you '
. 'don\'t have the RELOAD privilege.'
)
- . Util::showMySQLDocu(
+ . MySQLDocumentation::show(
'privileges-provided',
false,
null,
diff --git a/libraries/classes/Server/UserGroups.php b/libraries/classes/Server/UserGroups.php
index 3a9c46d367..b47478d747 100644
--- a/libraries/classes/Server/UserGroups.php
+++ b/libraries/classes/Server/UserGroups.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Server;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -120,7 +121,7 @@ class UserGroups
''
)
. '">'
- . Util::getIcon('b_usrlist', __('View users'))
+ . Generator::getIcon('b_usrlist', __('View users'))
. '';
$html_output .= ' ';
$html_output .= ''
- . Util::getIcon('b_edit', __('Edit')) . ' ';
+ . Generator::getIcon('b_edit', __('Edit')) . '';
$html_output .= ' ';
$html_output .= ''
- . Util::getIcon('b_drop', __('Delete')) . ' ';
+ . Generator::getIcon('b_drop', __('Delete')) . '';
$html_output .= ' ';
$html_output .= '
';
@@ -158,7 +159,7 @@ class UserGroups
$html_output .= '
';
diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php
index ec0f0e105d..71a8f956bf 100644
--- a/libraries/classes/Sql.php
+++ b/libraries/classes/Sql.php
@@ -12,6 +12,8 @@ use PhpMyAdmin\Bookmark;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Display\Results as DisplayResults;
+use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\Operations;
@@ -87,7 +89,9 @@ class Sql
if ($db === null && isset($GLOBALS['db']) && strlen($GLOBALS['db'])) {
$db = $GLOBALS['db'];
}
- list($analyzed_sql_results,,) = ParseAnalyze::sqlQuery($sql_query, $db);
+ [
+ $analyzed_sql_results,,
+ ] = ParseAnalyze::sqlQuery($sql_query, $db);
return $analyzed_sql_results;
}
@@ -291,11 +295,11 @@ class Sql
if (! empty($profilingResults)) {
$urlQuery = isset($urlQuery) ? $urlQuery : Url::getCommon(['db' => $database]);
- list(
+ [
$detailedTable,
$chartJson,
- $profilingStats
- ) = $this->analyzeAndGetTableHtmlForProfilingResults($profilingResults);
+ $profilingStats,
+ ] = $this->analyzeAndGetTableHtmlForProfilingResults($profilingResults);
return $this->template->render('sql/profiling_chart', [
'url_query' => $urlQuery,
@@ -831,7 +835,7 @@ class Sql
);
$GLOBALS['using_bookmark_message']->addParam($table);
$GLOBALS['using_bookmark_message']->addHtml(
- Util::showDocu('faq', 'faq6-22')
+ MySQLDocumentation::showDocumentation('faq', 'faq6-22')
);
$sql_query = $bookmark->getQuery();
} else {
@@ -884,7 +888,7 @@ class Sql
$response->setRequestStatus(false);
$response->addJSON('message', $message);
} else {
- Util::mysqlDie($error, $full_sql_query, '', '');
+ Generator::mysqlDie($error, $full_sql_query, '', '');
}
exit;
}
@@ -1171,10 +1175,10 @@ class Sql
$GLOBALS['dbi']->query('SET PROFILING=1;');
}
- list(
+ [
$result,
- $GLOBALS['querytime']
- ) = $this->executeQueryAndMeasureTime($full_sql_query);
+ $GLOBALS['querytime'],
+ ] = $this->executeQueryAndMeasureTime($full_sql_query);
// Displays an error message if required and stop parsing the script
$error = $GLOBALS['dbi']->getError();
@@ -1417,7 +1421,7 @@ class Sql
}
$html_output = '';
- $html_message = Util::getMessage(
+ $html_message = Generator::getMessage(
$message,
$GLOBALS['sql_query'],
'success'
@@ -1696,7 +1700,7 @@ class Sql
): string {
$output = '';
if (isset($displayQuery) && ($showSql === true) && empty($sqlData)) {
- $output = Util::getMessage(
+ $output = Generator::getMessage(
$displayMessage,
$displayQuery,
'success'
@@ -1727,7 +1731,7 @@ class Sql
. ' Grid edit, checkbox, Edit, Copy and Delete features'
. ' are not available. %s'
),
- Util::showDocu(
+ MySQLDocumentation::showDocumentation(
'config',
'cfg_RowActionLinksWithoutUnique'
)
@@ -1741,7 +1745,7 @@ class Sql
. ' Grid edit, Edit, Copy and Delete features may result in'
. ' undesired behavior. %s'
),
- Util::showDocu(
+ MySQLDocumentation::showDocumentation(
'config',
'cfg_RowActionLinksWithoutUnique'
)
@@ -1932,7 +1936,7 @@ class Sql
$scripts->addFile('sql.js');
if (isset($message)) {
$message = Message::success($message);
- $tableMaintenanceHtml = Util::getMessage(
+ $tableMaintenanceHtml = Generator::getMessage(
$message,
$GLOBALS['sql_query'],
'success'
@@ -2081,11 +2085,11 @@ class Sql
) {
if ($analyzed_sql_results == null) {
// Parse and analyze the query
- list(
+ [
$analyzed_sql_results,
$db,
- $table_from_sql
- ) = ParseAnalyze::sqlQuery($sql_query, $db);
+ $table_from_sql,
+ ] = ParseAnalyze::sqlQuery($sql_query, $db);
// @todo: possibly refactor
extract($analyzed_sql_results);
@@ -2206,13 +2210,13 @@ class Sql
$GLOBALS['reload'] = $this->hasCurrentDbChanged($db);
$GLOBALS['dbi']->selectDb($db);
- list(
+ [
$result,
$num_rows,
$unlim_num_rows,
$profiling_results,
- $extra_data
- ) = $this->executeTheQuery(
+ $extra_data,
+ ] = $this->executeTheQuery(
$analyzed_sql_results,
$full_sql_query,
$is_gotofile,
diff --git a/libraries/classes/SqlQueryForm.php b/libraries/classes/SqlQueryForm.php
index 4b2a5b2032..a54dff6300 100644
--- a/libraries/classes/SqlQueryForm.php
+++ b/libraries/classes/SqlQueryForm.php
@@ -13,6 +13,8 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\MySQLDocumentation;
+
/**
* PhpMyAdmin\SqlQueryForm class
*
@@ -80,7 +82,7 @@ class SqlQueryForm
}
if ($display_tab === 'full' || $display_tab === 'sql') {
- list($legend, $query, $columns_list) = $this->init($query);
+ [$legend, $query, $columns_list] = $this->init($query);
}
$cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
@@ -190,7 +192,7 @@ class SqlQueryForm
);
}
}
- $legend .= ': ' . Util::showMySQLDocu('SELECT');
+ $legend .= ': ' . MySQLDocumentation::show('SELECT');
return [
$legend,
diff --git a/libraries/classes/StorageEngine.php b/libraries/classes/StorageEngine.php
index a95383c42e..49e4f99a4f 100644
--- a/libraries/classes/StorageEngine.php
+++ b/libraries/classes/StorageEngine.php
@@ -20,6 +20,7 @@ use PhpMyAdmin\Engines\Myisam;
use PhpMyAdmin\Engines\Ndbcluster;
use PhpMyAdmin\Engines\Pbxt;
use PhpMyAdmin\Engines\PerformanceSchema;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Util;
/**
@@ -253,7 +254,7 @@ class StorageEngine
. '
' . "\n";
if (! empty($details['desc'])) {
$ret .= ' '
- . Util::showHint($details['desc'])
+ . Generator::showHint($details['desc'])
. "\n";
}
$ret .= ' ' . "\n"
diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php
index 531721ab8a..1c076d1fc6 100644
--- a/libraries/classes/Table.php
+++ b/libraries/classes/Table.php
@@ -9,6 +9,8 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
@@ -1889,7 +1891,7 @@ class Table
'Failed to cleanup table UI preferences (see ' .
'$cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'
),
- Util::showDocu('config', 'cfg_Servers_MaxTableUiprefs')
+ MySQLDocumentation::showDocumentation('config', 'cfg_Servers_MaxTableUiprefs')
)
);
$message->addMessage(
@@ -2492,7 +2494,7 @@ class Table
if (! empty($tmp_error_drop)) {
$seen_error = true;
- $html_output .= Util::mysqlDie(
+ $html_output .= Generator::mysqlDie(
$tmp_error_drop,
$drop_query,
false,
@@ -2538,7 +2540,7 @@ class Table
$message->addParam(implode(', ', $master_field));
$html_output .= $message->getDisplay();
} else {
- $html_output .= Util::mysqlDie(
+ $html_output .= Generator::mysqlDie(
$tmp_error_create,
$create_query,
false,
@@ -2546,9 +2548,9 @@ class Table
false
);
}
- $html_output .= Util::showMySQLDocu(
- 'InnoDB_foreign_key_constraints'
- ) . "\n";
+ $html_output .= MySQLDocumentation::show(
+ 'InnoDB_foreign_key_constraints'
+ ) . "\n";
}
} else {
$preview_sql_data .= $create_query . "\n";
diff --git a/libraries/classes/Tracking.php b/libraries/classes/Tracking.php
index 9f868bcb86..879c210100 100644
--- a/libraries/classes/Tracking.php
+++ b/libraries/classes/Tracking.php
@@ -8,6 +8,8 @@ declare(strict_types=1);
namespace PhpMyAdmin;
+use PhpMyAdmin\Html\Generator;
+
/**
* PhpMyAdmin\Tracking class
*
@@ -246,7 +248,7 @@ class Tracking
. htmlspecialchars($data['tracking']) . '
';
$html .= '
';
- list($str1, $str2, $str3, $str4, $str5) = $this->getHtmlForElementsOfTrackingReport(
+ [$str1, $str2, $str3, $str4, $str5] = $this->getHtmlForElementsOfTrackingReport(
$selection_schema,
$selection_data,
$selection_both
@@ -255,7 +257,7 @@ class Tracking
// Prepare delete link content here
$drop_image_or_text = '';
if (Util::showIcons('ActionLinksMode')) {
- $drop_image_or_text .= Util::getImage(
+ $drop_image_or_text .= Generator::getImage(
'b_drop',
__('Delete tracking data row from report')
);
@@ -399,7 +401,7 @@ class Tracking
);
if ($selection_schema || $selection_both && count($data['ddlog']) > 0) {
- list($temp, $ddlog_count) = $this->getHtmlForDataDefinitionStatements(
+ [$temp, $ddlog_count] = $this->getHtmlForDataDefinitionStatements(
$data,
$filter_users,
$filter_ts_from,
@@ -517,7 +519,9 @@ class Tracking
$drop_image_or_text
) {
// no need for the secondth returned parameter
- list($html,) = $this->getHtmlForDataStatements(
+ [
+ $html,
+ ] = $this->getHtmlForDataStatements(
$data,
$filter_users,
$filter_ts_from,
@@ -553,7 +557,7 @@ class Tracking
array $url_params,
$drop_image_or_text
) {
- list($html, $line_number) = $this->getHtmlForDataStatements(
+ [$html, $line_number] = $this->getHtmlForDataStatements(
$data,
$filter_users,
$filter_ts_from,
@@ -609,7 +613,7 @@ class Tracking
&& (in_array('*', $filterUsers)
|| in_array($entry['username'], $filterUsers))
) {
- $entry['formated_statement'] = Util::formatSql($entry['statement'], true);
+ $entry['formated_statement'] = Generator::formatSql($entry['statement'], true);
$deleteParam = 'delete_' . $whichLog;
$entry['url_params'] = Url::getCommon($urlParams + [
'report' => 'true',
@@ -662,7 +666,7 @@ class Tracking
$drop_create_statements .= $data['ddlog'][1]['statement'];
}
// Print SQL code
- $html .= Util::getMessage(
+ $html .= Generator::getMessage(
sprintf(
__('Version %s snapshot (SQL code)'),
htmlspecialchars($_POST['version'])
@@ -1172,7 +1176,7 @@ class Tracking
&& $GLOBALS['dbi']->numRows($allTablesResult) > 0;
if ($headVersionExists) {
while ($oneResult = $GLOBALS['dbi']->fetchArray($allTablesResult)) {
- list($tableName, $versionNumber) = $oneResult;
+ [$tableName, $versionNumber] = $oneResult;
$tableQuery = ' SELECT * FROM ' .
Util::backquote($cfgRelation['db']) . '.' .
Util::backquote($cfgRelation['tracking']) .
@@ -1278,7 +1282,7 @@ class Tracking
'version' => $versionData['version'],
], $params));
- return Util::toggleButton(
+ return Generator::toggleButton(
$link,
'toggle_activation',
$options,
diff --git a/libraries/classes/Twig/UtilExtension.php b/libraries/classes/Twig/UtilExtension.php
index d0b7f9f7ca..3a81521473 100644
--- a/libraries/classes/Twig/UtilExtension.php
+++ b/libraries/classes/Twig/UtilExtension.php
@@ -33,7 +33,7 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'get_browse_upload_file_block',
- 'PhpMyAdmin\Util::getBrowseUploadFileBlock',
+ '\PhpMyAdmin\Html\Forms\Fields\BrowseUploadFileBlock::generate',
['is_safe' => ['html']]
),
new TwigFunction(
@@ -50,37 +50,37 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'format_sql',
- 'PhpMyAdmin\Util::formatSql',
+ '\PhpMyAdmin\Html\Generator::formatSql',
['is_safe' => ['html']]
),
new TwigFunction(
'get_button_or_image',
- 'PhpMyAdmin\Util::getButtonOrImage',
+ '\PhpMyAdmin\Html\Generator::getButtonOrImage',
['is_safe' => ['html']]
),
new TwigFunction(
'get_docu_link',
- 'PhpMyAdmin\Util::getDocuLink',
+ '\PhpMyAdmin\Html\MySQLDocumentation::getDocumentationLink',
['is_safe' => ['html']]
),
new TwigFunction(
'get_list_navigator',
- 'PhpMyAdmin\Util::getListNavigator',
+ '\PhpMyAdmin\Html\Generator::getListNavigator',
['is_safe' => ['html']]
),
new TwigFunction(
'show_docu',
- 'PhpMyAdmin\Util::showDocu',
+ '\PhpMyAdmin\Html\MySQLDocumentation::showDocumentation',
['is_safe' => ['html']]
),
new TwigFunction(
'get_dropdown',
- 'PhpMyAdmin\Util::getDropdown',
+ '\PhpMyAdmin\Html\Forms\Fields\DropDown::generate',
['is_safe' => ['html']]
),
new TwigFunction(
'get_fk_checkbox',
- 'PhpMyAdmin\Util::getFKCheckbox',
+ '\PhpMyAdmin\Html\Forms\Fields\FKCheckbox::generate',
['is_safe' => ['html']]
),
new TwigFunction(
@@ -93,27 +93,27 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'get_html_tab',
- 'PhpMyAdmin\Util::getHtmlTab',
+ '\PhpMyAdmin\Html\Generator::getHtmlTab',
['is_safe' => ['html']]
),
new TwigFunction(
'get_icon',
- 'PhpMyAdmin\Util::getIcon',
+ '\PhpMyAdmin\Html\Generator::getIcon',
['is_safe' => ['html']]
),
new TwigFunction(
'get_image',
- 'PhpMyAdmin\Util::getImage',
+ '\PhpMyAdmin\Html\Generator::getImage',
['is_safe' => ['html']]
),
new TwigFunction(
'get_radio_fields',
- 'PhpMyAdmin\Util::getRadioFields',
+ '\PhpMyAdmin\Html\Forms\Fields\RadioList::generate',
['is_safe' => ['html']]
),
new TwigFunction(
'get_select_upload_file_block',
- 'PhpMyAdmin\Util::getSelectUploadFileBlock',
+ '\PhpMyAdmin\Html\Forms\Fields\DropDownUploadFileBlock::generate',
['is_safe' => ['html']]
),
new TwigFunction(
@@ -146,7 +146,7 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'show_hint',
- 'PhpMyAdmin\Util::showHint',
+ '\PhpMyAdmin\Html\Generator::showHint',
['is_safe' => ['html']]
),
new TwigFunction(
@@ -155,7 +155,7 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'show_mysql_docu',
- 'PhpMyAdmin\Util::showMySQLDocu',
+ '\PhpMyAdmin\Html\MySQLDocumentation::show',
['is_safe' => ['html']]
),
new TwigFunction(
@@ -165,7 +165,7 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'show_php_docu',
- 'PhpMyAdmin\Util::showPHPDocu',
+ '\PhpMyAdmin\Html\Generator::showPHPDocumentation',
['is_safe' => ['html']]
),
new TwigFunction(
@@ -179,7 +179,7 @@ class UtilExtension extends AbstractExtension
),
new TwigFunction(
'generate_hidden_max_file_size',
- 'PhpMyAdmin\Util::generateHiddenMaxFileSize',
+ '\PhpMyAdmin\Html\Forms\Fields\MaxFileSize::generate',
['is_safe' => ['html']]
),
];
diff --git a/libraries/classes/UserPassword.php b/libraries/classes/UserPassword.php
index 09d070010d..c990adb22c 100644
--- a/libraries/classes/UserPassword.php
+++ b/libraries/classes/UserPassword.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Server\Privileges;
@@ -56,7 +57,7 @@ class UserPassword
$response->addJSON('message', $change_password_message['msg']);
$response->setRequestStatus(false);
} else {
- $sql_query = Util::getMessage(
+ $sql_query = Generator::getMessage(
$change_password_message['msg'],
$sql_query,
'success'
@@ -112,7 +113,7 @@ class UserPassword
$hashing_function = $this->changePassHashingFunction();
- list($username, $hostname) = $GLOBALS['dbi']->getCurrentUserAndHost();
+ [$username, $hostname] = $GLOBALS['dbi']->getCurrentUserAndHost();
$serverType = Util::getServerType();
$serverVersion = $GLOBALS['dbi']->getVersion();
@@ -249,7 +250,7 @@ class UserPassword
. $GLOBALS['dbi']->escapeString($password) . '\')');
}
if (! @$GLOBALS['dbi']->tryQuery($local_query)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
$GLOBALS['dbi']->getError(),
$sql_query,
false,
@@ -272,7 +273,7 @@ class UserPassword
private function changePassDisplayPage($message, $sql_query)
{
echo '
' , __('Change password') , ' ' , "\n\n";
- echo Util::getMessage(
+ echo Generator::getMessage(
$message,
$sql_query,
'success'
diff --git a/libraries/classes/UserPreferencesHeader.php b/libraries/classes/UserPreferencesHeader.php
index 924855a595..5d66da37e0 100644
--- a/libraries/classes/UserPreferencesHeader.php
+++ b/libraries/classes/UserPreferencesHeader.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Config\Forms\User\UserFormList;
+use PhpMyAdmin\Html\Generator;
use Throwable;
use Twig_Error_Loader;
use Twig_Error_Runtime;
@@ -54,21 +55,21 @@ class UserPreferencesHeader
global $route;
// build user preferences menu
- $content = Util::getHtmlTab(
- [
- 'link' => 'index.php?route=/preferences/manage',
- 'text' => __('Manage your settings'),
- 'active' => $route === '/preferences/manage',
- ]
- ) . "\n";
+ $content = Generator::getHtmlTab(
+ [
+ 'link' => 'index.php?route=/preferences/manage',
+ 'text' => __('Manage your settings'),
+ 'active' => $route === '/preferences/manage',
+ ]
+ ) . "\n";
/* Second authentication factor */
- $content .= Util::getHtmlTab(
- [
- 'link' => 'index.php?route=/preferences/twofactor',
- 'text' => __('Two-factor authentication'),
- 'active' => $route === '/preferences/twofactor',
- ]
- ) . "\n";
+ $content .= Generator::getHtmlTab(
+ [
+ 'link' => 'index.php?route=/preferences/twofactor',
+ 'text' => __('Two-factor authentication'),
+ 'active' => $route === '/preferences/twofactor',
+ ]
+ ) . "\n";
$content .= self::displayTabsWithIcon();
@@ -107,7 +108,7 @@ class UserPreferencesHeader
'icon' => $tabs_icons[$formset],
'active' => $route === '/preferences/forms' && $formset === $form_param,
];
- $content .= Util::getHtmlTab($tab, ['form' => $formset]) . "\n";
+ $content .= Generator::getHtmlTab($tab, ['form' => $formset]) . "\n";
}
return $content;
}
diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php
index 39353794be..ab16bf399c 100644
--- a/libraries/classes/Util.php
+++ b/libraries/classes/Util.php
@@ -9,16 +9,12 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use Closure;
-use PhpMyAdmin\Plugins\ImportPlugin;
+use PhpMyAdmin\Html\Generator;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\SqlParser\Context;
-use PhpMyAdmin\SqlParser\Lexer;
-use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Token;
-use PhpMyAdmin\SqlParser\Utils\Error as ParserError;
use phpseclib\Crypt\Random;
use stdClass;
-use Williamdes\MariaDBMySQLKBS\KBException;
-use Williamdes\MariaDBMySQLKBS\Search as KBSearch;
/**
* Misc functions used all over the scripts.
@@ -51,102 +47,6 @@ class Util
return in_array($GLOBALS['cfg'][$value], ['text', 'both']);
}
- /**
- * Returns an HTML IMG tag for a particular icon from a theme,
- * which may be an actual file or an icon from a sprite.
- * This function takes into account the ActionLinksMode
- * configuration setting and wraps the image tag in a span tag.
- *
- * @param string $icon name of icon file
- * @param string $alternate alternate text
- * @param boolean $force_text whether to force alternate text to be displayed
- * @param boolean $menu_icon whether this icon is for the menu bar or not
- * @param string $control_param which directive controls the display
- *
- * @return string an html snippet
- */
- public static function getIcon(
- $icon,
- $alternate = '',
- $force_text = false,
- $menu_icon = false,
- $control_param = 'ActionLinksMode'
- ) {
- $include_icon = $include_text = false;
- if (self::showIcons($control_param)) {
- $include_icon = true;
- }
- if ($force_text
- || self::showText($control_param)
- ) {
- $include_text = true;
- }
- // Sometimes use a span (we rely on this in js/sql.js). But for menu bar
- // we don't need a span
- $button = $menu_icon ? '' : '
';
- if ($include_icon) {
- $button .= self::getImage($icon, $alternate);
- }
- if ($include_icon && $include_text) {
- $button .= ' ';
- }
- if ($include_text) {
- $button .= $alternate;
- }
- $button .= $menu_icon ? '' : ' ';
-
- return $button;
- }
-
- /**
- * Returns an HTML IMG tag for a particular image from a theme
- *
- * The image name should match CSS class defined in icons.css.php
- *
- * @param string $image The name of the file to get
- * @param string $alternate Used to set 'alt' and 'title' attributes
- * of the image
- * @param array $attributes An associative array of other attributes
- *
- * @return string an html IMG tag
- */
- public static function getImage($image, $alternate = '', array $attributes = [])
- {
- $alternate = htmlspecialchars($alternate);
-
- if (isset($attributes['class'])) {
- $attributes['class'] = "icon ic_$image " . $attributes['class'];
- } else {
- $attributes['class'] = "icon ic_$image";
- }
-
- // set all other attributes
- $attr_str = '';
- foreach ($attributes as $key => $value) {
- if (! in_array($key, ['alt', 'title'])) {
- $attr_str .= " $key=\"$value\"";
- }
- }
-
- // override the alt attribute
- if (isset($attributes['alt'])) {
- $alt = $attributes['alt'];
- } else {
- $alt = $alternate;
- }
-
- // override the title attribute
- if (isset($attributes['title'])) {
- $title = $attributes['title'];
- } else {
- $title = $alternate;
- }
-
- // generate the IMG tag
- $template = '
';
- return sprintf($template, $title, $alt, $attr_str);
- }
-
/**
* Returns the formatted maximum size for an upload
*
@@ -160,26 +60,10 @@ class Util
{
// I have to reduce the second parameter (sensitiveness) from 6 to 4
// to avoid weird results like 512 kKib
- list($max_size, $max_unit) = self::formatByteDown($max_upload_size, 4);
+ [$max_size, $max_unit] = self::formatByteDown($max_upload_size, 4);
return '(' . sprintf(__('Max: %s%s'), $max_size, $max_unit) . ')';
}
- /**
- * Generates a hidden field which should indicate to the browser
- * the maximum size for upload
- *
- * @param integer $max_size the size
- *
- * @return string the INPUT field
- *
- * @access public
- */
- public static function generateHiddenMaxFileSize($max_size)
- {
- return '
';
- }
-
/**
* Add slashes before "_" and "%" characters for using them in MySQL
* database, table and field names.
@@ -251,75 +135,6 @@ class Util
return $quoted_string;
}
- /**
- * format sql strings
- *
- * @param string $sqlQuery raw SQL string
- * @param boolean $truncate truncate the query if it is too long
- *
- * @return string the formatted sql
- *
- * @global array $cfg the configuration array
- *
- * @access public
- * @todo move into PMA_Sql
- */
- public static function formatSql($sqlQuery, $truncate = false)
- {
- global $cfg;
-
- if ($truncate
- && mb_strlen($sqlQuery) > $cfg['MaxCharactersInDisplayedSQL']
- ) {
- $sqlQuery = mb_substr(
- $sqlQuery,
- 0,
- $cfg['MaxCharactersInDisplayedSQL']
- ) . '[...]';
- }
- return '
' . "\n"
- . htmlspecialchars($sqlQuery) . "\n"
- . ' ';
- } // end of the "formatSql()" function
-
- /**
- * Displays a button to copy content to clipboard
- *
- * @param string $text Text to copy to clipboard
- *
- * @return string the html link
- *
- * @access public
- */
- public static function showCopyToClipboard($text)
- {
- $open_link = '
' . __('Copy') . ' ';
- return $open_link;
- } // end of the 'showCopyToClipboard()' function
-
- /**
- * Displays a link to the documentation as an icon
- *
- * @param string $link documentation link
- * @param string $target optional link target
- * @param boolean $bbcode optional flag indicating whether to output bbcode
- *
- * @return string the html link
- *
- * @access public
- */
- public static function showDocLink($link, $target = 'documentation', $bbcode = false)
- {
- if ($bbcode) {
- return "[a@$link@$target][dochelpicon][/a]";
- }
-
- return '
'
- . self::getImage('b_help', __('Documentation'))
- . ' ';
- } // end of the 'showDocLink()' function
-
/**
* Get a URL link to the official MySQL documentation
*
@@ -359,362 +174,6 @@ class Util
return Core::linkURL($url);
}
- /**
- * Get a link to variable documentation
- *
- * @param string $name The variable name
- * @param boolean $useMariaDB Use only MariaDB documentation
- * @param string $text (optional) The text for the link
- * @return string link or empty string
- */
- public static function linkToVarDocumentation(
- string $name,
- bool $useMariaDB = false,
- string $text = null
- ): string {
- $html = '';
- try {
- $type = KBSearch::MYSQL;
- if ($useMariaDB) {
- $type = KBSearch::MARIADB;
- }
- $docLink = KBSearch::getByName($name, $type);
- $html = Util::showMySQLDocu(
- $name,
- false,
- $docLink,
- $text
- );
- } catch (KBException $e) {
- unset($e);// phpstan workaround
- }
- return $html;
- }
-
- /**
- * Displays a link to the official MySQL documentation
- *
- * @param string $link contains name of page/anchor that is being linked
- * @param bool $bigIcon whether to use big icon (like in left frame)
- * @param string|null $url href attribute
- * @param string|null $text text of link
- * @param string $anchor anchor to page part
- *
- * @return string the html link
- *
- * @access public
- */
- public static function showMySQLDocu(
- $link,
- bool $bigIcon = false,
- $url = null,
- $text = null,
- $anchor = ''
- ): string {
- if ($url === null) {
- $url = self::getMySQLDocuURL($link, $anchor);
- }
- $openLink = '
';
- $closeLink = ' ';
- $html = '';
-
- if ($bigIcon) {
- $html = $openLink .
- self::getImage('b_sqlhelp', __('Documentation'))
- . $closeLink;
- } elseif ($text !== null) {
- $html = $openLink . $text . $closeLink;
- } else {
- $html = self::showDocLink($url, 'mysql_doc');
- }
-
- return $html;
- } // end of the 'showMySQLDocu()' function
-
- /**
- * Returns link to documentation.
- *
- * @param string $page Page in documentation
- * @param string $anchor Optional anchor in page
- *
- * @return string URL
- */
- public static function getDocuLink($page, $anchor = '')
- {
- /* Construct base URL */
- $url = $page . '.html';
- if (! empty($anchor)) {
- $url .= '#' . $anchor;
- }
-
- /* Check if we have built local documentation, however
- * provide consistent URL for testsuite
- */
- if (! defined('TESTSUITE') && @file_exists(ROOT_PATH . 'doc/html/index.html')) {
- return 'doc/html/' . $url;
- }
-
- return Core::linkURL('https://docs.phpmyadmin.net/en/latest/' . $url);
- }
-
- /**
- * Displays a link to the phpMyAdmin documentation
- *
- * @param string $page Page in documentation
- * @param string $anchor Optional anchor in page
- * @param boolean $bbcode Optional flag indicating whether to output bbcode
- *
- * @return string the html link
- *
- * @access public
- */
- public static function showDocu($page, $anchor = '', $bbcode = false)
- {
- return self::showDocLink(self::getDocuLink($page, $anchor), 'documentation', $bbcode);
- } // end of the 'showDocu()' function
-
- /**
- * Displays a link to the PHP documentation
- *
- * @param string $target anchor in documentation
- *
- * @return string the html link
- *
- * @access public
- */
- public static function showPHPDocu($target)
- {
- $url = Core::getPHPDocLink($target);
-
- return self::showDocLink($url);
- } // end of the 'showPHPDocu()' function
-
- /**
- * Returns HTML code for a tooltip
- *
- * @param string $message the message for the tooltip
- *
- * @return string
- *
- * @access public
- */
- public static function showHint($message)
- {
- if ($GLOBALS['cfg']['ShowHint']) {
- $classClause = ' class="pma_hint"';
- } else {
- $classClause = '';
- }
- return '
'
- . self::getImage('b_help')
- . '' . $message . ' '
- . ' ';
- }
-
- /**
- * Displays a MySQL error message in the main panel when $exit is true.
- * Returns the error message otherwise.
- *
- * @param string|bool $server_msg Server's error message.
- * @param string $sql_query The SQL query that failed.
- * @param bool $is_modify_link Whether to show a "modify" link or not.
- * @param string $back_url URL for the "back" link (full path is
- * not required).
- * @param bool $exit Whether execution should be stopped or
- * the error message should be returned.
- *
- * @return string
- *
- * @global string $table The current table.
- * @global string $db The current database.
- *
- * @access public
- */
- public static function mysqlDie(
- $server_msg = '',
- $sql_query = '',
- $is_modify_link = true,
- $back_url = '',
- $exit = true
- ) {
- global $table, $db;
-
- /**
- * Error message to be built.
- * @var string $error_msg
- */
- $error_msg = '';
-
- // Checking for any server errors.
- if (empty($server_msg)) {
- $server_msg = $GLOBALS['dbi']->getError();
- }
-
- // Finding the query that failed, if not specified.
- if (empty($sql_query) && ! empty($GLOBALS['sql_query'])) {
- $sql_query = $GLOBALS['sql_query'];
- }
- $sql_query = trim($sql_query);
-
- /**
- * The lexer used for analysis.
- * @var Lexer $lexer
- */
- $lexer = new Lexer($sql_query);
-
- /**
- * The parser used for analysis.
- * @var Parser $parser
- */
- $parser = new Parser($lexer->list);
-
- /**
- * The errors found by the lexer and the parser.
- * @var array $errors
- */
- $errors = ParserError::get([$lexer, $parser]);
-
- if (empty($sql_query)) {
- $formatted_sql = '';
- } elseif (count($errors)) {
- $formatted_sql = htmlspecialchars($sql_query);
- } else {
- $formatted_sql = self::formatSql($sql_query, true);
- }
-
- $error_msg .= '
' . __('Error') . ' ';
-
- // For security reasons, if the MySQL refuses the connection, the query
- // is hidden so no details are revealed.
- if (! empty($sql_query) && ! mb_strstr($sql_query, 'connect')) {
- // Static analysis errors.
- if (! empty($errors)) {
- $error_msg .= '
' . __('Static analysis:')
- . '
';
- $error_msg .= '
' . sprintf(
- __('%d errors were found during analysis.'),
- count($errors)
- ) . '
';
- $error_msg .= '
';
- $error_msg .= implode(
- ParserError::format(
- $errors,
- '%2$s (near "%4$s" at position %5$d) '
- )
- );
- $error_msg .= ' ';
- }
-
- // Display the SQL query and link to MySQL documentation.
- $error_msg .= '
' . __('SQL query:') . ' ' . self::showCopyToClipboard($sql_query) . "\n";
- $formattedSqlToLower = mb_strtolower($formatted_sql);
-
- // TODO: Show documentation for all statement types.
- if (mb_strstr($formattedSqlToLower, 'select')) {
- // please show me help to the error on select
- $error_msg .= self::showMySQLDocu('SELECT');
- }
-
- if ($is_modify_link) {
- $_url_params = [
- 'sql_query' => $sql_query,
- 'show_query' => 1,
- ];
- if (strlen($table) > 0) {
- $_url_params['db'] = $db;
- $_url_params['table'] = $table;
- $doedit_goto = '';
- } elseif (strlen($db) > 0) {
- $_url_params['db'] = $db;
- $doedit_goto = ' ';
- } else {
- $doedit_goto = ' ';
- }
-
- $error_msg .= $doedit_goto
- . self::getIcon('b_edit', __('Edit'))
- . ' ';
- }
-
- $error_msg .= '
' . "\n"
- . '
' . "\n"
- . $formatted_sql . "\n"
- . '
' . "\n";
- }
-
- // Display server's error.
- if (! empty($server_msg)) {
- $server_msg = preg_replace(
- "@((\015\012)|(\015)|(\012)){3,}@",
- "\n\n",
- $server_msg
- );
-
- // Adds a link to MySQL documentation.
- $error_msg .= '
' . "\n"
- . ' ' . __('MySQL said: ') . ' '
- . self::showMySQLDocu('Error-messages-server')
- . "\n"
- . '
' . "\n";
-
- // The error message will be displayed within a CODE segment.
- // To preserve original formatting, but allow word-wrapping,
- // a couple of replacements are done.
- // All non-single blanks and TAB-characters are replaced with their
- // HTML-counterpart
- $server_msg = str_replace(
- [
- ' ',
- "\t",
- ],
- [
- ' ',
- ' ',
- ],
- $server_msg
- );
-
- // Replace line breaks
- $server_msg = nl2br($server_msg);
-
- $error_msg .= '
' . $server_msg . '';
- }
-
- $error_msg .= '
';
- $_SESSION['Import_message']['message'] = $error_msg;
-
- if (! $exit) {
- return $error_msg;
- }
-
- /**
- * If this is an AJAX request, there is no "Back" link and
- * `Response()` is used to send the response.
- */
- $response = Response::getInstance();
- if ($response->isAjax()) {
- $response->setRequestStatus(false);
- $response->addJSON('message', $error_msg);
- exit;
- }
-
- if (! empty($back_url)) {
- if (mb_strstr($back_url, '?')) {
- $back_url .= '&no_history=true';
- } else {
- $back_url .= '?no_history=true';
- }
-
- $_SESSION['Import_message']['go_back_url'] = $back_url;
-
- $error_msg .= '' . "\n\n";
- }
-
- exit($error_msg);
- }
-
/**
* Check the correct row count
*
@@ -934,319 +393,6 @@ class Util
return $a_name;
} // end of the 'backquoteCompat()' function
- /**
- * Prepare the message and the query
- * usually the message is the result of the query executed
- *
- * @param Message|string $message the message to display
- * @param string $sql_query the query to display
- * @param string $type the type (level) of the message
- *
- * @return string
- *
- * @access public
- */
- public static function getMessage(
- $message,
- $sql_query = null,
- $type = 'notice'
- ) {
- global $cfg;
- $template = new Template();
- $retval = '';
-
- if (null === $sql_query) {
- if (! empty($GLOBALS['display_query'])) {
- $sql_query = $GLOBALS['display_query'];
- } elseif (! empty($GLOBALS['unparsed_sql'])) {
- $sql_query = $GLOBALS['unparsed_sql'];
- } elseif (! empty($GLOBALS['sql_query'])) {
- $sql_query = $GLOBALS['sql_query'];
- } else {
- $sql_query = '';
- }
- }
-
- $render_sql = $cfg['ShowSQL'] == true && ! empty($sql_query) && $sql_query !== ';';
-
- if (isset($GLOBALS['using_bookmark_message'])) {
- $retval .= $GLOBALS['using_bookmark_message']->getDisplay();
- unset($GLOBALS['using_bookmark_message']);
- }
-
- if ($render_sql) {
- $retval .= '
' . "\n";
- }
-
- if ($message instanceof Message) {
- if (isset($GLOBALS['special_message'])) {
- $message->addText($GLOBALS['special_message']);
- unset($GLOBALS['special_message']);
- }
- $retval .= $message->getDisplay();
- } else {
- $context = 'primary';
- if ($type === 'error') {
- $context = 'danger';
- } elseif ($type === 'success') {
- $context = 'success';
- }
- $retval .= '
';
- $retval .= Sanitize::sanitizeMessage($message);
- if (isset($GLOBALS['special_message'])) {
- $retval .= Sanitize::sanitizeMessage($GLOBALS['special_message']);
- unset($GLOBALS['special_message']);
- }
- $retval .= '
';
- }
-
- if ($render_sql) {
- $query_too_big = false;
-
- $queryLength = mb_strlen($sql_query);
- if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
- // when the query is large (for example an INSERT of binary
- // data), the parser chokes; so avoid parsing the query
- $query_too_big = true;
- $query_base = mb_substr(
- $sql_query,
- 0,
- $cfg['MaxCharactersInDisplayedSQL']
- ) . '[...]';
- } else {
- $query_base = $sql_query;
- }
-
- // Html format the query to be displayed
- // If we want to show some sql code it is easiest to create it here
- /* SQL-Parser-Analyzer */
-
- if (! empty($GLOBALS['show_as_php'])) {
- $new_line = '\\n"
' . "\n" . ' . "';
- $query_base = htmlspecialchars(addslashes($query_base));
- $query_base = preg_replace(
- '/((\015\012)|(\015)|(\012))/',
- $new_line,
- $query_base
- );
- $query_base = '
' . "\n"
- . '$sql = "' . $query_base . '";' . "\n"
- . ' ';
- } elseif ($query_too_big) {
- $query_base = '
' . "\n" .
- htmlspecialchars($query_base) .
- ' ';
- } else {
- $query_base = self::formatSql($query_base);
- }
-
- // Prepares links that may be displayed to edit/explain the query
- // (don't go to default pages, we must go to the page
- // where the query box is available)
-
- // Basic url query part
- $url_params = [];
- if (! isset($GLOBALS['db'])) {
- $GLOBALS['db'] = '';
- }
- if (strlen($GLOBALS['db']) > 0) {
- $url_params['db'] = $GLOBALS['db'];
- if (strlen($GLOBALS['table']) > 0) {
- $url_params['table'] = $GLOBALS['table'];
- $edit_link = Url::getFromRoute('/table/sql');
- } else {
- $edit_link = Url::getFromRoute('/database/sql');
- }
- } else {
- $edit_link = Url::getFromRoute('/server/sql');
- }
-
- // Want to have the query explained
- // but only explain a SELECT (that has not been explained)
- /* SQL-Parser-Analyzer */
- $explain_link = '';
- $is_select = preg_match('@^SELECT[[:space:]]+@i', $sql_query);
- if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) {
- $explain_params = $url_params;
- if ($is_select) {
- $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
- $explain_link = ' [ '
- . self::linkOrButton(
- Url::getFromRoute('/import', $explain_params),
- __('Explain SQL')
- ) . ' ]';
- } elseif (preg_match(
- '@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i',
- $sql_query
- )) {
- $explain_params['sql_query']
- = mb_substr($sql_query, 8);
- $explain_link = ' [ '
- . self::linkOrButton(
- Url::getFromRoute('/import', $explain_params),
- __('Skip Explain SQL')
- ) . ']';
- $url = 'https://mariadb.org/explain_analyzer/analyze/'
- . '?client=phpMyAdmin&raw_explain='
- . urlencode(self::_generateRowQueryOutput($sql_query));
- $explain_link .= ' ['
- . self::linkOrButton(
- htmlspecialchars('url.php?url=' . urlencode($url)),
- sprintf(__('Analyze Explain at %s'), 'mariadb.org'),
- [],
- '_blank'
- ) . ' ]';
- }
- } //show explain
-
- $url_params['sql_query'] = $sql_query;
- $url_params['show_query'] = 1;
-
- // even if the query is big and was truncated, offer the chance
- // to edit it (unless it's enormous, see linkOrButton() )
- if (! empty($cfg['SQLQuery']['Edit'])
- && empty($GLOBALS['show_as_php'])
- ) {
- $edit_link .= Url::getCommon($url_params);
- $edit_link = ' [ '
- . self::linkOrButton($edit_link, __('Edit'))
- . ' ]';
- } else {
- $edit_link = '';
- }
-
- // Also we would like to get the SQL formed in some nice
- // php-code
- if (! empty($cfg['SQLQuery']['ShowAsPHP']) && ! $query_too_big) {
- if (! empty($GLOBALS['show_as_php'])) {
- $php_link = ' [ '
- . self::linkOrButton(
- Url::getFromRoute('/import', $url_params),
- __('Without PHP code')
- )
- . ' ]';
-
- $php_link .= ' [ '
- . self::linkOrButton(
- Url::getFromRoute('/import', $url_params),
- __('Submit query')
- )
- . ' ]';
- } else {
- $php_params = $url_params;
- $php_params['show_as_php'] = 1;
- $php_link = ' [ '
- . self::linkOrButton(
- Url::getFromRoute('/import', $php_params),
- __('Create PHP code')
- )
- . ' ]';
- }
- } else {
- $php_link = '';
- } //show as php
-
- // Refresh query
- if (! empty($cfg['SQLQuery']['Refresh'])
- && ! isset($GLOBALS['show_as_php']) // 'Submit query' does the same
- && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)
- ) {
- $refresh_link = Url::getFromRoute('/import', $url_params);
- $refresh_link = ' [ '
- . self::linkOrButton($refresh_link, __('Refresh')) . ']';
- } else {
- $refresh_link = '';
- } //refresh
-
- $retval .= '
';
- $retval .= $query_base;
- $retval .= '
';
-
- $retval .= '
';
- $retval .= '';
-
- /**
- * TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
- */
- if (! empty($cfg['SQLQuery']['Edit'])
- && ! $query_too_big
- && empty($GLOBALS['show_as_php'])
- ) {
- $inline_edit_link = ' ['
- . self::linkOrButton(
- '#',
- _pgettext('Inline edit query', 'Edit inline'),
- ['class' => 'inline_edit_sql']
- )
- . ']';
- } else {
- $inline_edit_link = '';
- }
- $retval .= $inline_edit_link . $edit_link . $explain_link . $php_link
- . $refresh_link;
- $retval .= '
';
-
- $retval .= '
';
- }
-
- return $retval;
- } // end of the 'getMessage()' function
-
- /**
- * Execute an EXPLAIN query and formats results similar to MySQL command line
- * utility.
- *
- * @param string $sqlQuery EXPLAIN query
- *
- * @return string query resuls
- */
- private static function _generateRowQueryOutput($sqlQuery)
- {
- $ret = '';
- $result = $GLOBALS['dbi']->query($sqlQuery);
- if ($result) {
- $devider = '+';
- $columnNames = '|';
- $fieldsMeta = $GLOBALS['dbi']->getFieldsMeta($result);
- foreach ($fieldsMeta as $meta) {
- $devider .= '---+';
- $columnNames .= ' ' . $meta->name . ' |';
- }
- $devider .= "\n";
-
- $ret .= $devider . $columnNames . "\n" . $devider;
- while ($row = $GLOBALS['dbi']->fetchRow($result)) {
- $values = '|';
- foreach ($row as $value) {
- if ($value === null) {
- $value = 'NULL';
- }
- $values .= ' ' . $value . ' |';
- }
- $ret .= $values . "\n";
- }
- $ret .= $devider;
- }
- return $ret;
- }
-
/**
* Verifies if current MySQL server supports profiling
*
@@ -1601,244 +747,6 @@ class Util
return $ret;
} // end of the 'localisedDate()' function
- /**
- * returns a tab for tabbed navigation.
- * If the variables $link and $args ar left empty, an inactive tab is created
- *
- * @param array $tab array with all options
- * @param array $url_params tab specific URL parameters
- *
- * @return string html code for one tab, a link if valid otherwise a span
- *
- * @access public
- */
- public static function getHtmlTab(array $tab, array $url_params = [])
- {
- $template = new Template();
- // default values
- $defaults = [
- 'text' => '',
- 'class' => '',
- 'active' => null,
- 'link' => '',
- 'sep' => '?',
- 'attr' => '',
- 'args' => '',
- 'warning' => '',
- 'fragment' => '',
- 'id' => '',
- ];
-
- $tab = array_merge($defaults, $tab);
-
- // determine additional style-class
- if (empty($tab['class'])) {
- if (! empty($tab['active'])
- || Core::isValid($GLOBALS['active_page'], 'identical', $tab['link'])
- ) {
- $tab['class'] = 'active';
- } elseif ($tab['active'] === null && empty($GLOBALS['active_page'])
- && (basename($GLOBALS['PMA_PHP_SELF']) == $tab['link'])
- ) {
- $tab['class'] = 'active';
- }
- }
-
- // build the link
- if (! empty($tab['link'])) {
- // If there are any tab specific URL parameters, merge those with
- // the general URL parameters
- if (! empty($tab['args']) && is_array($tab['args'])) {
- $url_params = array_merge($url_params, $tab['args']);
- }
- if (strpos($tab['link'], '?') === false) {
- $tab['link'] = htmlentities($tab['link']) . Url::getCommon($url_params);
- } else {
- $tab['link'] = htmlentities($tab['link']) . Url::getCommon($url_params, '&');
- }
- }
-
- if (! empty($tab['fragment'])) {
- $tab['link'] .= $tab['fragment'];
- }
-
- // display icon
- if (isset($tab['icon'])) {
- // avoid generating an alt tag, because it only illustrates
- // the text that follows and if browser does not display
- // images, the text is duplicated
- $tab['text'] = self::getIcon(
- $tab['icon'],
- $tab['text'],
- false,
- true,
- 'TabsMode'
- );
- } elseif (empty($tab['text'])) {
- // check to not display an empty link-text
- $tab['text'] = '?';
- trigger_error(
- 'empty linktext in function ' . __FUNCTION__ . '()',
- E_USER_NOTICE
- );
- }
-
- //Set the id for the tab, if set in the params
- $tabId = (empty($tab['id']) ? null : $tab['id']);
-
- $item = [];
- if (! empty($tab['link'])) {
- $item = [
- 'content' => $tab['text'],
- 'url' => [
- 'href' => empty($tab['link']) ? null : $tab['link'],
- 'id' => $tabId,
- 'class' => 'tab' . htmlentities($tab['class']),
- ],
- ];
- } else {
- $item['content'] = '
' . $tab['text'] . ' ';
- }
-
- $item['class'] = $tab['class'] == 'active' ? 'active' : '';
-
- return $template->render('list/item', $item);
- }
-
- /**
- * returns html-code for a tab navigation
- *
- * @param array $tabs one element per tab
- * @param array $url_params additional URL parameters
- * @param string $menu_id HTML id attribute for the menu container
- * @param bool $resizable whether to add a "resizable" class
- *
- * @return string html-code for tab-navigation
- */
- public static function getHtmlTabs(
- array $tabs,
- array $url_params,
- $menu_id,
- $resizable = false
- ) {
- $class = '';
- if ($resizable) {
- $class = ' class="resizable-menu"';
- }
-
- $tab_navigation = '' . "\n";
-
- return $tab_navigation;
- }
-
- /**
- * Displays a link, or a link with code to trigger POST request.
- *
- * POST is used in following cases:
- *
- * - URL is too long
- * - URL components are over Suhosin limits
- * - There is SQL query in the parameters
- *
- * @param string $url the URL
- * @param string $message the link message
- * @param mixed $tag_params string: js confirmation; array: additional tag
- * params (f.e. style="")
- * @param string $target target
- *
- * @return string the results to be echoed or saved in an array
- */
- public static function linkOrButton(
- $url,
- $message,
- $tag_params = [],
- $target = ''
- ) {
- $url_length = strlen($url);
-
- if (! is_array($tag_params)) {
- $tmp = $tag_params;
- $tag_params = [];
- if (! empty($tmp)) {
- $tag_params['onclick'] = 'return Functions.confirmLink(this, \''
- . Sanitize::escapeJsString($tmp) . '\')';
- }
- unset($tmp);
- }
- if (! empty($target)) {
- $tag_params['target'] = $target;
- if ($target === '_blank' && strncmp($url, 'url.php?', 8) == 0) {
- $tag_params['rel'] = 'noopener noreferrer';
- }
- }
-
- // Suhosin: Check that each query parameter is not above maximum
- $in_suhosin_limits = true;
- if ($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) {
- $suhosin_get_MaxValueLength = ini_get('suhosin.get.max_value_length');
- if ($suhosin_get_MaxValueLength) {
- $query_parts = self::splitURLQuery($url);
- foreach ($query_parts as $query_pair) {
- if (strpos($query_pair, '=') === false) {
- continue;
- }
-
- list(, $eachval) = explode('=', $query_pair);
- if (strlen($eachval) > $suhosin_get_MaxValueLength
- ) {
- $in_suhosin_limits = false;
- break;
- }
- }
- }
- }
-
- $tag_params_strings = [];
- if (($url_length > $GLOBALS['cfg']['LinkLengthLimit'])
- || ! $in_suhosin_limits
- // Has as sql_query without a signature
- || ( strpos($url, 'sql_query=') !== false && strpos($url, 'sql_signature=') === false)
- || strpos($url, 'view[as]=') !== false
- ) {
- $parts = explode('?', $url, 2);
- /*
- * The data-post indicates that client should do POST
- * this is handled in js/ajax.js
- */
- $tag_params_strings[] = 'data-post="' . (isset($parts[1]) ? $parts[1] : '') . '"';
- $url = $parts[0];
- if (array_key_exists('class', $tag_params)
- && strpos($tag_params['class'], 'create_view') !== false
- ) {
- $url .= '?' . explode('&', $parts[1], 2)[0];
- }
- }
-
- foreach ($tag_params as $par_name => $par_value) {
- $tag_params_strings[] = $par_name . '="' . htmlspecialchars($par_value) . '"';
- }
-
- // no whitespace within an
else Safari will make it part of the link
- return ' '
- . $message . ' ';
- } // end of the 'linkOrButton()' function
-
/**
* Splits a URL string by parameter
*
@@ -1930,7 +838,7 @@ class Util
$error_message .= $reported_script_name
. ': ' . __('Missing parameter:') . ' '
. $param
- . self::showDocu('faq', 'faqmissingparameters', true)
+ . MySQLDocumentation::showDocumentation('faq', 'faqmissingparameters', true)
. '[br]';
$found_error = true;
}
@@ -2135,7 +1043,7 @@ class Util
*/
public static function getCharsetQueryPart($collation, $override = false)
{
- list($charset) = explode('_', $collation);
+ [$charset] = explode('_', $collation);
$keyword = ' CHARSET=';
if ($override) {
@@ -2145,41 +1053,6 @@ class Util
. ($charset == $collation ? '' : ' COLLATE ' . $collation);
}
- /**
- * Generate a button or image tag
- *
- * @param string $button_name name of button element
- * @param string $button_class class of button or image element
- * @param string $text text to display
- * @param string $image image to display
- * @param string $value value
- *
- * @return string html content
- *
- * @access public
- */
- public static function getButtonOrImage(
- $button_name,
- $button_class,
- $text,
- $image,
- $value = ''
- ) {
- if ($value == '') {
- $value = $text;
- }
- if ($GLOBALS['cfg']['ActionLinksMode'] == 'text') {
- return '
' . "\n";
- }
- return '
' . "\n"
- . self::getIcon($image, $text)
- . ' ' . "\n";
- } // end function
-
/**
* Generate a pagination selector for browsing resultsets
*
@@ -2336,127 +1209,6 @@ class Util
return (int) floor($pos / $max_count) + 1;
}
- /**
- * Prepare navigation for a list
- *
- * @param int $count number of elements in the list
- * @param int $pos current position in the list
- * @param array $_url_params url parameters
- * @param string $script script name for form target
- * @param string $frame target frame
- * @param int $max_count maximum number of elements to display from
- * the list
- * @param string $name the name for the request parameter
- * @param string[] $classes additional classes for the container
- *
- * @return string the html content
- *
- * @access public
- *
- * @todo use $pos from $_url_params
- */
- public static function getListNavigator(
- $count,
- $pos,
- array $_url_params,
- $script,
- $frame,
- $max_count,
- $name = 'pos',
- $classes = []
- ) {
-
- // This is often coming from $cfg['MaxTableList'] and
- // people sometimes set it to empty string
- $max_count = intval($max_count);
- if ($max_count <= 0) {
- $max_count = 250;
- }
-
- $class = $frame == 'frame_navigation' ? ' class="ajax"' : '';
-
- $list_navigator_html = '';
-
- if ($max_count < $count) {
- $classes[] = 'pageselector';
- $list_navigator_html .= '
';
-
- if ($frame != 'frame_navigation') {
- $list_navigator_html .= __('Page number:');
- }
-
- // Move to the beginning or to the previous page
- if ($pos > 0) {
- $caption1 = '';
- $caption2 = '';
- if (self::showIcons('TableNavigationLinksMode')) {
- $caption1 .= '<< ';
- $caption2 .= '< ';
- }
- if (self::showText('TableNavigationLinksMode')) {
- $caption1 .= _pgettext('First page', 'Begin');
- $caption2 .= _pgettext('Previous page', 'Previous');
- }
- $title1 = ' title="' . _pgettext('First page', 'Begin') . '"';
- $title2 = ' title="' . _pgettext('Previous page', 'Previous') . '"';
-
- $_url_params[$name] = 0;
- $list_navigator_html .= '
' . $caption1
- . ' ';
-
- $_url_params[$name] = $pos - $max_count;
- $list_navigator_html .= '
'
- . $caption2 . ' ';
- }
-
- $list_navigator_html .= '
';
-
- if ($pos + $max_count < $count) {
- $caption3 = '';
- $caption4 = '';
- if (self::showText('TableNavigationLinksMode')) {
- $caption3 .= _pgettext('Next page', 'Next');
- $caption4 .= _pgettext('Last page', 'End');
- }
- if (self::showIcons('TableNavigationLinksMode')) {
- $caption3 .= ' >';
- $caption4 .= ' >>';
- }
- $title3 = ' title="' . _pgettext('Next page', 'Next') . '"';
- $title4 = ' title="' . _pgettext('Last page', 'End') . '"';
-
- $_url_params[$name] = $pos + $max_count;
- $list_navigator_html .= '
' . $caption3
- . ' ';
-
- $_url_params[$name] = floor($count / $max_count) * $max_count;
- if ($_url_params[$name] == $count) {
- $_url_params[$name] = $count - $max_count;
- }
-
- $list_navigator_html .= '
'
- . $caption4 . ' ';
- }
- $list_navigator_html .= '
' . "\n";
- }
-
- return $list_navigator_html;
- }
-
/**
* replaces %u in given path with current user name
*
@@ -2480,235 +1232,6 @@ class Util
return str_replace('%u', Core::securePath($GLOBALS['cfg']['Server']['user']), $dir);
}
- /**
- * returns html code for db link to default db page
- *
- * @param string $database database
- *
- * @return string html link to default db page
- */
- public static function getDbLink($database = '')
- {
- if (strlen((string) $database) === 0) {
- if (strlen((string) $GLOBALS['db']) === 0) {
- return '';
- }
- $database = $GLOBALS['db'];
- } else {
- $database = self::unescapeMysqlWildcards($database);
- }
-
- $scriptName = self::getScriptNameForOption(
- $GLOBALS['cfg']['DefaultTabDatabase'],
- 'database'
- );
- return '
' . htmlspecialchars($database) . ' ';
- }
-
- /**
- * Prepare a lightbulb hint explaining a known external bug
- * that affects a functionality
- *
- * @param string $functionality localized message explaining the func.
- * @param string $component 'mysql' (eventually, 'php')
- * @param string $minimum_version of this component
- * @param string $bugref bug reference for this component
- *
- * @return String
- */
- public static function getExternalBug(
- $functionality,
- $component,
- $minimum_version,
- $bugref
- ) {
- $ext_but_html = '';
- if (($component == 'mysql') && ($GLOBALS['dbi']->getVersion() < $minimum_version)) {
- $ext_but_html .= self::showHint(
- sprintf(
- __('The %s functionality is affected by a known bug, see %s'),
- $functionality,
- Core::linkURL('https://bugs.mysql.com/') . $bugref
- )
- );
- }
- return $ext_but_html;
- }
-
- /**
- * Generates a set of radio HTML fields
- *
- * @param string $html_field_name the radio HTML field
- * @param array $choices the choices values and labels
- * @param string $checked_choice the choice to check by default
- * @param boolean $line_break whether to add HTML line break after a choice
- * @param boolean $escape_label whether to use htmlspecialchars() on label
- * @param string $class enclose each choice with a div of this class
- * @param string $id_prefix prefix for the id attribute, name will be
- * used if this is not supplied
- *
- * @return string set of html radio fiels
- */
- public static function getRadioFields(
- $html_field_name,
- array $choices,
- $checked_choice = '',
- $line_break = true,
- $escape_label = true,
- $class = '',
- $id_prefix = ''
- ) {
- $template = new Template();
- $radio_html = '';
-
- foreach ($choices as $choice_value => $choice_label) {
- if (! $id_prefix) {
- $id_prefix = $html_field_name;
- }
- $html_field_id = $id_prefix . '_' . $choice_value;
-
- if ($choice_value == $checked_choice) {
- $checked = 1;
- } else {
- $checked = 0;
- }
- $radio_html .= $template->render('radio_fields', [
- 'class' => $class,
- 'html_field_name' => $html_field_name,
- 'html_field_id' => $html_field_id,
- 'choice_value' => $choice_value,
- 'is_line_break' => $line_break,
- 'choice_label' => $choice_label,
- 'escape_label' => $escape_label,
- 'checked' => $checked,
- ]);
- }
-
- return $radio_html;
- }
-
- /**
- * Generates and returns an HTML dropdown
- *
- * @param string $select_name name for the select element
- * @param array $choices choices values
- * @param string $active_choice the choice to select by default
- * @param string $id id of the select element; can be different in
- * case the dropdown is present more than once
- * on the page
- * @param string $class class for the select element
- * @param string $placeholder Placeholder for dropdown if nothing else
- * is selected
- *
- * @return string html content
- *
- * @todo support titles
- */
- public static function getDropdown(
- $select_name,
- array $choices,
- $active_choice,
- $id,
- $class = '',
- $placeholder = null
- ) {
- $template = new Template();
- $resultOptions = [];
- $selected = false;
-
- foreach ($choices as $one_choice_value => $one_choice_label) {
- $resultOptions[$one_choice_value]['value'] = $one_choice_value;
- $resultOptions[$one_choice_value]['selected'] = false;
-
- if ($one_choice_value == $active_choice) {
- $resultOptions[$one_choice_value]['selected'] = true;
- $selected = true;
- }
- $resultOptions[$one_choice_value]['label'] = $one_choice_label;
- }
- return $template->render('dropdown', [
- 'select_name' => $select_name,
- 'id' => $id,
- 'class' => $class,
- 'placeholder' => $placeholder,
- 'selected' => $selected,
- 'result_options' => $resultOptions,
- ]);
- }
-
- /**
- * Generates a slider effect (jQjuery)
- * Takes care of generating the initial
and the link
- * controlling the slider; you have to generate the
yourself
- * after the sliding section.
- *
- * @param string $id the id of the
on which to apply the effect
- * @param string $message the message to show as a link
- * @param string|null $overrideDefault override InitialSlidersState config
- *
- * @return string html div element
- *
- */
- public static function getDivForSliderEffect($id = '', $message = '', $overrideDefault = null)
- {
- $template = new Template();
- return $template->render('div_for_slider_effect', [
- 'id' => $id,
- 'initial_sliders_state' => ($overrideDefault != null) ? $overrideDefault : $GLOBALS['cfg']['InitialSlidersState'],
- 'message' => $message,
- ]);
- }
-
- /**
- * Creates an AJAX sliding toggle button
- * (or and equivalent form when AJAX is disabled)
- *
- * @param string $action The URL for the request to be executed
- * @param string $select_name The name for the dropdown box
- * @param array $options An array of options (see PhpMyAdmin\Rte\Footer)
- * @param string $callback A JS snippet to execute when the request is
- * successfully processed
- *
- * @return string HTML code for the toggle button
- */
- public static function toggleButton($action, $select_name, array $options, $callback)
- {
- $template = new Template();
- // Do the logic first
- $link = "$action&" . urlencode($select_name) . "=";
- $link_on = $link . urlencode($options[1]['value']);
- $link_off = $link . urlencode($options[0]['value']);
-
- if ($options[1]['selected'] == true) {
- $state = 'on';
- } elseif ($options[0]['selected'] == true) {
- $state = 'off';
- } else {
- $state = 'on';
- }
-
- return $template->render('toggle_button', [
- 'pma_theme_image' => $GLOBALS['pmaThemeImage'],
- 'text_dir' => $GLOBALS['text_dir'],
- 'link_on' => $link_on,
- 'link_off' => $link_off,
- 'toggle_on' => $options[1]['label'],
- 'toggle_off' => $options[0]['label'],
- 'callback' => $callback,
- 'state' => $state,
- ]);
- }
-
/**
* Clears cache content which needs to be refreshed on user change.
*
@@ -3015,19 +1538,6 @@ class Util
return ($GLOBALS['dbi']->getVariable('FOREIGN_KEY_CHECKS') == 'ON');
}
- /**
- * Get HTML for Foreign key check checkbox
- *
- * @return string HTML for checkbox
- */
- public static function getFKCheckbox()
- {
- $template = new Template();
- return $template->render('fk_checkbox', [
- 'checked' => self::isForeignKeyCheck(),
- ]);
- }
-
/**
* Handle foreign key check request
*
@@ -3311,129 +1821,6 @@ class Util
return strtr((string) strftime($string), $replace);
}
- /**
- * Prepare the form used to browse anywhere on the local server for a file to
- * import
- *
- * @param string $max_upload_size maximum upload size
- *
- * @return String
- */
- public static function getBrowseUploadFileBlock($max_upload_size)
- {
- $block_html = '';
-
- if ($GLOBALS['is_upload'] && ! empty($GLOBALS['cfg']['UploadDir'])) {
- $block_html .= '
';
- } else {
- $block_html .= '';
- }
-
- $block_html .= __("Browse your computer:") . ' '
- . '
'
- . '
'
- . ' '
- . self::getFormattedMaximumUploadSize($max_upload_size) . "\n"
- // some browsers should respect this :)
- . self::generateHiddenMaxFileSize($max_upload_size) . "\n";
-
- return $block_html;
- }
-
- /**
- * Prepare the form used to select a file to import from the server upload
- * directory
- *
- * @param ImportPlugin[] $import_list array of import plugins
- * @param string $uploaddir upload directory
- *
- * @return String
- */
- public static function getSelectUploadFileBlock($import_list, $uploaddir)
- {
- $fileListing = new FileListing();
-
- $block_html = '';
- $block_html .= ''
- . sprintf(
- __("Select from the web server upload directory %s :"),
- htmlspecialchars(self::userDir($uploaddir))
- )
- . ' ';
-
- $extensions = '';
- foreach ($import_list as $import_plugin) {
- if (! empty($extensions)) {
- $extensions .= '|';
- }
- $extensions .= $import_plugin->getProperties()->getExtension();
- }
-
- $matcher = '@\.(' . $extensions . ')(\.('
- . $fileListing->supportedDecompressions() . '))?$@';
-
- $active = (isset($GLOBALS['timeout_passed'], $GLOBALS['local_import_file']) && $GLOBALS['timeout_passed'])
- ? $GLOBALS['local_import_file']
- : '';
-
- $files = $fileListing->getFileSelectOptions(
- self::userDir($uploaddir),
- $matcher,
- $active
- );
-
- if ($files === false) {
- Message::error(
- __('The directory you set for upload work cannot be reached.')
- )->display();
- } elseif (! empty($files)) {
- $block_html .= "\n"
- . ' ' . "\n"
- . ' ' . "\n"
- . $files
- . ' ' . "\n";
- } elseif (empty($files)) {
- $block_html .= '' . __('There are no files to upload!') . ' ';
- }
-
- return $block_html;
- }
-
- /**
- * Build titles and icons for action links
- *
- * @return array the action titles
- */
- public static function buildActionTitles()
- {
- $titles = [];
-
- $titles['Browse'] = self::getIcon('b_browse', __('Browse'));
- $titles['NoBrowse'] = self::getIcon('bd_browse', __('Browse'));
- $titles['Search'] = self::getIcon('b_select', __('Search'));
- $titles['NoSearch'] = self::getIcon('bd_select', __('Search'));
- $titles['Insert'] = self::getIcon('b_insrow', __('Insert'));
- $titles['NoInsert'] = self::getIcon('bd_insrow', __('Insert'));
- $titles['Structure'] = self::getIcon('b_props', __('Structure'));
- $titles['Drop'] = self::getIcon('b_drop', __('Drop'));
- $titles['NoDrop'] = self::getIcon('bd_drop', __('Drop'));
- $titles['Empty'] = self::getIcon('b_empty', __('Empty'));
- $titles['NoEmpty'] = self::getIcon('bd_empty', __('Empty'));
- $titles['Edit'] = self::getIcon('b_edit', __('Edit'));
- $titles['NoEdit'] = self::getIcon('bd_edit', __('Edit'));
- $titles['Export'] = self::getIcon('b_export', __('Export'));
- $titles['NoExport'] = self::getIcon('bd_export', __('Export'));
- $titles['Execute'] = self::getIcon('b_nextpage', __('Execute'));
- $titles['NoExecute'] = self::getIcon('bd_nextpage', __('Execute'));
- // For Favorite/NoFavorite, we need icon only.
- $titles['Favorite'] = self::getIcon('b_favorite', '');
- $titles['NoFavorite'] = self::getIcon('b_no_favorite', '');
-
- return $titles;
- }
-
/**
* This function processes the datatypes supported by the DB,
* as specified in Types->getColumns() and either returns an array
@@ -3449,48 +1836,7 @@ class Util
public static function getSupportedDatatypes($html = false, $selected = '')
{
if ($html) {
- // NOTE: the SELECT tag in not included in this snippet.
- $retval = '';
-
- foreach ($GLOBALS['dbi']->types->getColumns() as $key => $value) {
- if (is_array($value)) {
- $retval .= "";
- foreach ($value as $subvalue) {
- if ($subvalue == $selected) {
- $retval .= sprintf(
- '%s ',
- $GLOBALS['dbi']->types->getTypeDescription($subvalue),
- $subvalue
- );
- } elseif ($subvalue === '-') {
- $retval .= '';
- $retval .= $subvalue;
- $retval .= ' ';
- } else {
- $retval .= sprintf(
- '%s ',
- $GLOBALS['dbi']->types->getTypeDescription($subvalue),
- $subvalue
- );
- }
- }
- $retval .= ' ';
- } else {
- if ($selected == $value) {
- $retval .= sprintf(
- '%s ',
- $GLOBALS['dbi']->types->getTypeDescription($value),
- $value
- );
- } else {
- $retval .= sprintf(
- '%s ',
- $GLOBALS['dbi']->types->getTypeDescription($value),
- $value
- );
- }
- }
- }
+ $retval = Generator::getSupportedDatatypes($selected);
} else {
$retval = [];
foreach ($GLOBALS['dbi']->types->getColumns() as $value) {
@@ -3809,123 +2155,6 @@ class Util
return $funcs;
}
- /**
- * Returns default function for a particular column.
- *
- * @param array $field Data about the column for which
- * to generate the dropdown
- * @param bool $insert_mode Whether the operation is 'insert'
- *
- * @global array $cfg PMA configuration
- * @global mixed $data data of currently edited row
- * (used to detect whether to choose defaults)
- *
- * @return string An HTML snippet of a dropdown list with function
- * names appropriate for the requested column.
- */
- public static function getDefaultFunctionForField(array $field, $insert_mode)
- {
- /*
- * @todo Except for $cfg, no longer use globals but pass as parameters
- * from higher levels
- */
- global $cfg, $data;
-
- $default_function = '';
-
- // Can we get field class based values?
- $current_class = $GLOBALS['dbi']->types->getTypeClass($field['True_Type']);
- if (! empty($current_class)) {
- if (isset($cfg['DefaultFunctions']['FUNC_' . $current_class])) {
- $default_function
- = $cfg['DefaultFunctions']['FUNC_' . $current_class];
- }
- }
-
- // what function defined as default?
- // for the first timestamp we don't set the default function
- // if there is a default value for the timestamp
- // (not including CURRENT_TIMESTAMP)
- // and the column does not have the
- // ON UPDATE DEFAULT TIMESTAMP attribute.
- if (($field['True_Type'] == 'timestamp')
- && $field['first_timestamp']
- && empty($field['Default'])
- && empty($data)
- && $field['Extra'] != 'on update CURRENT_TIMESTAMP'
- && $field['Null'] == 'NO'
- ) {
- $default_function = $cfg['DefaultFunctions']['first_timestamp'];
- }
-
- // For primary keys of type char(36) or varchar(36) UUID if the default
- // function
- // Only applies to insert mode, as it would silently trash data on updates.
- if ($insert_mode
- && $field['Key'] == 'PRI'
- && ($field['Type'] == 'char(36)' || $field['Type'] == 'varchar(36)')
- ) {
- $default_function = $cfg['DefaultFunctions']['FUNC_UUID'];
- }
-
- return $default_function;
- }
-
- /**
- * Creates a dropdown box with MySQL functions for a particular column.
- *
- * @param array $field Data about the column for which
- * to generate the dropdown
- * @param bool $insert_mode Whether the operation is 'insert'
- * @param array $foreignData Foreign data
- *
- * @return string An HTML snippet of a dropdown list with function
- * names appropriate for the requested column.
- */
- public static function getFunctionsForField(array $field, $insert_mode, array $foreignData)
- {
- $default_function = self::getDefaultFunctionForField($field, $insert_mode);
- $dropdown_built = [];
-
- // Create the output
- $retval = ' ' . "\n";
- // loop on the dropdown array and print all available options for that
- // field.
- $functions = $GLOBALS['dbi']->types->getFunctions($field['True_Type']);
- foreach ($functions as $function) {
- $retval .= '' . "\n";
- $dropdown_built[$function] = true;
- }
-
- // Create separator before all functions list
- if (count($functions) > 0) {
- $retval .= ' -------- '
- . "\n";
- }
-
- // For compatibility's sake, do not let out all other functions. Instead
- // print a separator (blank) and then show ALL functions which weren't
- // shown yet.
- $functions = $GLOBALS['dbi']->types->getAllFunctions();
- foreach ($functions as $function) {
- // Skip already included functions
- if (isset($dropdown_built[$function])) {
- continue;
- }
- $retval .= '' . "\n";
- } // end for
-
- return $retval;
- } // end getFunctionsForField()
-
/**
* Checks if the current user has a specific privilege and returns true if the
* user indeed has that privilege or false if they don't. This function must
@@ -3949,7 +2178,7 @@ class Util
{
// Get the username for the current user in the format
// required to use in the information schema database.
- list($user, $host) = $GLOBALS['dbi']->getCurrentUserAndHost();
+ [$user, $host] = $GLOBALS['dbi']->getCurrentUserAndHost();
if ($user === '') { // MySQL is started with --skip-grant-tables
return true;
@@ -4043,31 +2272,6 @@ class Util
return 'MySQL';
}
- /**
- * Returns information about SSL status for current connection
- *
- * @return string
- */
- public static function getServerSSL()
- {
- $server = $GLOBALS['cfg']['Server'];
- $class = 'caution';
- if (! $server['ssl']) {
- $message = __('SSL is not being used');
- if (! empty($server['socket']) || $server['host'] == '127.0.0.1' || $server['host'] == 'localhost') {
- $class = '';
- }
- } elseif (! $server['ssl_verify']) {
- $message = __('SSL is used with disabled verification');
- } elseif (empty($server['ssl_ca'])) {
- $message = __('SSL is used without certification authority');
- } else {
- $class = '';
- $message = __('SSL is used');
- }
- return '' . $message . ' ' . self::showDocu('setup', 'ssl');
- }
-
/**
* Parses ENUM/SET values
*
@@ -4270,63 +2474,6 @@ class Util
return 'none';
}
- /**
- * Renders a single link for the top of the navigation panel
- *
- * @param string $link The url for the link
- * @param bool $showText Whether to show the text or to
- * only use it for title attributes
- * @param string $text The text to display and use for title attributes
- * @param bool $showIcon Whether to show the icon
- * @param string $icon The filename of the icon to show
- * @param string $linkId Value to use for the ID attribute
- * @param boolean $disableAjax Whether to disable ajax page loading for this link
- * @param string $linkTarget The name of the target frame for the link
- * @param array $classes HTML classes to apply
- *
- * @return string HTML code for one link
- */
- public static function getNavigationLink(
- $link,
- $showText,
- $text,
- $showIcon,
- $icon,
- $linkId = '',
- $disableAjax = false,
- $linkTarget = '',
- array $classes = []
- ) {
- $retval = '';
- if ($showIcon) {
- $retval .= self::getImage(
- $icon,
- $text
- );
- }
- if ($showText) {
- $retval .= $text;
- }
- $retval .= ' ';
- if ($showText) {
- $retval .= ' ';
- }
- return $retval;
- }
-
/**
* Provide COLLATE clause, if required, to perform case sensitive comparisons
* for queries on information_schema.
@@ -4398,46 +2545,6 @@ class Util
];
}
- /**
- * Function to get html for the start row and number of rows panel
- *
- * @param string $sql_query sql query
- *
- * @return string html
- */
- public static function getStartAndNumberOfRowsPanel($sql_query)
- {
- $template = new Template();
-
- if (isset($_REQUEST['session_max_rows'])) {
- $rows = $_REQUEST['session_max_rows'];
- } elseif (isset($_SESSION['tmpval']['max_rows'])
- && $_SESSION['tmpval']['max_rows'] != 'all'
- ) {
- $rows = $_SESSION['tmpval']['max_rows'];
- } else {
- $rows = $GLOBALS['cfg']['MaxRows'];
- $_SESSION['tmpval']['max_rows'] = $rows;
- }
-
- if (isset($_REQUEST['pos'])) {
- $pos = $_REQUEST['pos'];
- } elseif (isset($_SESSION['tmpval']['pos'])) {
- $pos = $_SESSION['tmpval']['pos'];
- } else {
- $number_of_line = (int) $_REQUEST['unlim_num_rows'];
- $pos = ((ceil($number_of_line / $rows) - 1) * $rows);
- $_SESSION['tmpval']['pos'] = $pos;
- }
-
- return $template->render('start_and_number_of_rows_panel', [
- 'pos' => $pos,
- 'unlim_num_rows' => (int) $_REQUEST['unlim_num_rows'],
- 'rows' => $rows,
- 'sql_query' => $sql_query,
- ]);
- }
-
/**
* Returns whether the database server supports virtual columns
*
@@ -4865,22 +2972,22 @@ class Util
if ($requestedSortOrder == 'ASC') {
$futureSortOrder = 'DESC';
// current sort order is ASC
- $orderImg = ' ' . self::getImage(
- 's_asc',
- __('Ascending'),
- [
- 'class' => 'sort_arrow',
- 'title' => '',
- ]
- );
- $orderImg .= ' ' . self::getImage(
- 's_desc',
- __('Descending'),
- [
- 'class' => 'sort_arrow hide',
- 'title' => '',
- ]
- );
+ $orderImg = ' ' . Generator::getImage(
+ 's_asc',
+ __('Ascending'),
+ [
+ 'class' => 'sort_arrow',
+ 'title' => '',
+ ]
+ );
+ $orderImg .= ' ' . Generator::getImage(
+ 's_desc',
+ __('Descending'),
+ [
+ 'class' => 'sort_arrow hide',
+ 'title' => '',
+ ]
+ );
// but on mouse over, show the reverse order (DESC)
$orderLinkParams['onmouseover'] = "$('.sort_arrow').toggle();";
// on mouse out, show current sort order (ASC)
@@ -4888,22 +2995,22 @@ class Util
} else {
$futureSortOrder = 'ASC';
// current sort order is DESC
- $orderImg = ' ' . self::getImage(
- 's_asc',
- __('Ascending'),
- [
- 'class' => 'sort_arrow hide',
- 'title' => '',
- ]
- );
- $orderImg .= ' ' . self::getImage(
- 's_desc',
- __('Descending'),
- [
- 'class' => 'sort_arrow',
- 'title' => '',
- ]
- );
+ $orderImg = ' ' . Generator::getImage(
+ 's_asc',
+ __('Ascending'),
+ [
+ 'class' => 'sort_arrow hide',
+ 'title' => '',
+ ]
+ );
+ $orderImg .= ' ' . Generator::getImage(
+ 's_desc',
+ __('Descending'),
+ [
+ 'class' => 'sort_arrow',
+ 'title' => '',
+ ]
+ );
// but on mouse over, show the reverse order (ASC)
$orderLinkParams['onmouseover'] = "$('.sort_arrow').toggle();";
// on mouse out, show current sort order (DESC)
@@ -4926,7 +3033,7 @@ class Util
$url = Url::getFromRoute('/database/structure', $urlParams);
- return self::linkOrButton($url, $title . $orderImg, $orderLinkParams);
+ return Generator::linkOrButton($url, $title . $orderImg, $orderLinkParams);
}
/**
@@ -4940,4 +3047,37 @@ class Util
{
return ctype_digit((string) $input);
}
+
+ /**
+ * Build titles and icons for action links
+ *
+ * @return array the action titles
+ */
+ public static function buildActionTitles(): array
+ {
+ $titles = [];
+
+ $titles['Browse'] = Generator::getIcon('b_browse', __('Browse'));
+ $titles['NoBrowse'] = Generator::getIcon('bd_browse', __('Browse'));
+ $titles['Search'] = Generator::getIcon('b_select', __('Search'));
+ $titles['NoSearch'] = Generator::getIcon('bd_select', __('Search'));
+ $titles['Insert'] = Generator::getIcon('b_insrow', __('Insert'));
+ $titles['NoInsert'] = Generator::getIcon('bd_insrow', __('Insert'));
+ $titles['Structure'] = Generator::getIcon('b_props', __('Structure'));
+ $titles['Drop'] = Generator::getIcon('b_drop', __('Drop'));
+ $titles['NoDrop'] = Generator::getIcon('bd_drop', __('Drop'));
+ $titles['Empty'] = Generator::getIcon('b_empty', __('Empty'));
+ $titles['NoEmpty'] = Generator::getIcon('bd_empty', __('Empty'));
+ $titles['Edit'] = Generator::getIcon('b_edit', __('Edit'));
+ $titles['NoEdit'] = Generator::getIcon('bd_edit', __('Edit'));
+ $titles['Export'] = Generator::getIcon('b_export', __('Export'));
+ $titles['NoExport'] = Generator::getIcon('bd_export', __('Export'));
+ $titles['Execute'] = Generator::getIcon('b_nextpage', __('Execute'));
+ $titles['NoExecute'] = Generator::getIcon('bd_nextpage', __('Execute'));
+ // For Favorite/NoFavorite, we need icon only.
+ $titles['Favorite'] = Generator::getIcon('b_favorite', '');
+ $titles['NoFavorite'] = Generator::getIcon('b_no_favorite', '');
+
+ return $titles;
+ }
}
diff --git a/libraries/entry_points/database/operations.php b/libraries/entry_points/database/operations.php
index 3bfe0c566d..68eb5d395b 100644
--- a/libraries/entry_points/database/operations.php
+++ b/libraries/entry_points/database/operations.php
@@ -15,6 +15,7 @@ declare(strict_types=1);
use PhpMyAdmin\CheckUserPrivileges;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Display\CreateTable;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Operations;
use PhpMyAdmin\Plugins;
@@ -216,7 +217,7 @@ if (strlen($db) > 0
$response->addJSON('newname', $_POST['newname']);
$response->addJSON(
'sql_query',
- Util::getMessage(null, $sql_query)
+ Generator::getMessage(null, $sql_query)
);
$response->addJSON('db', $db);
exit;
@@ -244,7 +245,7 @@ $url_query .= Url::getCommon($url_params, '&');
// Gets the database structure
$sub_part = '_structure';
-list(
+[
$tables,
$num_tables,
$total_num_tables,
@@ -253,13 +254,13 @@ list(
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
- $pos
-) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
+ $pos,
+] = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
echo "\n";
if (isset($message)) {
- echo Util::getMessage($message, $sql_query);
+ echo Generator::getMessage($message, $sql_query);
unset($message);
}
diff --git a/libraries/entry_points/database/search.php b/libraries/entry_points/database/search.php
index 2b1165a594..3cb14da097 100644
--- a/libraries/entry_points/database/search.php
+++ b/libraries/entry_points/database/search.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
use PhpMyAdmin\Database\Search;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
@@ -41,7 +42,7 @@ require ROOT_PATH . 'libraries/db_common.inc.php';
// If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
if (! $GLOBALS['cfg']['UseDbSearch']) {
- Util::mysqlDie(
+ Generator::mysqlDie(
__('Access denied!'),
'',
false,
@@ -56,7 +57,7 @@ $db_search = new Search($dbi, $db, $template);
// Display top links if we are not in an Ajax request
if (! $response->isAjax()) {
- list(
+ [
$tables,
$num_tables,
$total_num_tables,
@@ -65,8 +66,8 @@ if (! $response->isAjax()) {
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
- $pos
- ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
+ $pos,
+ ] = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
}
// Main search form has been submitted, get results
diff --git a/libraries/entry_points/database/tracking.php b/libraries/entry_points/database/tracking.php
index 01e436f803..2ba09859e9 100644
--- a/libraries/entry_points/database/tracking.php
+++ b/libraries/entry_points/database/tracking.php
@@ -7,6 +7,7 @@
declare(strict_types=1);
use PhpMyAdmin\Display\CreateTable;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
@@ -46,7 +47,7 @@ $url_query .= Url::getCommon($url_params, '&');
// Get the database structure
$sub_part = '_structure';
-list(
+[
$tables,
$num_tables,
$total_num_tables,
@@ -55,8 +56,8 @@ list(
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
- $pos
-) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
+ $pos,
+] = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
if (isset($_POST['delete_tracking'], $_POST['table'])) {
Tracker::deleteTracking($db, $_POST['table']);
@@ -130,5 +131,5 @@ if (count($data['ddlog']) > 0) {
$log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
. $entry['statement'] . "\n";
}
- echo Util::getMessage(__('Database Log'), $log);
+ echo Generator::getMessage(__('Database Log'), $log);
}
diff --git a/libraries/entry_points/import.php b/libraries/entry_points/import.php
index badaa7a798..6e547fd89e 100644
--- a/libraries/entry_points/import.php
+++ b/libraries/entry_points/import.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\File;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Import;
use PhpMyAdmin\ParseAnalyze;
use PhpMyAdmin\Plugins;
@@ -666,11 +667,11 @@ if (isset($message)) {
// can choke on it so avoid parsing)
$sqlLength = mb_strlen($sql_query);
if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
- list(
+ [
$analyzed_sql_results,
$db,
- $table_from_sql
- ) = ParseAnalyze::sqlQuery($sql_query, $db);
+ $table_from_sql,
+ ] = ParseAnalyze::sqlQuery($sql_query, $db);
// @todo: possibly refactor
extract($analyzed_sql_results);
@@ -682,7 +683,7 @@ if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
// There was an error?
if (isset($my_die)) {
foreach ($my_die as $key => $die) {
- PhpMyAdmin\Util::mysqlDie(
+ Generator::mysqlDie(
$die['error'],
$die['sql'],
false,
@@ -704,11 +705,11 @@ if ($go_sql) {
foreach ($sql_queries as $sql_query) {
// parse sql query
- list(
+ [
$analyzed_sql_results,
$db,
- $table_from_sql
- ) = ParseAnalyze::sqlQuery($sql_query, $db);
+ $table_from_sql,
+ ] = ParseAnalyze::sqlQuery($sql_query, $db);
// @todo: possibly refactor
extract($analyzed_sql_results);
@@ -718,7 +719,7 @@ if ($go_sql) {
$cfg['AllowUserDropDatabase'],
$dbi->isSuperuser()
)) {
- PhpMyAdmin\Util::mysqlDie(
+ Generator::mysqlDie(
__('"DROP DATABASE" statements are disabled.'),
'',
false,
@@ -787,7 +788,7 @@ if ($go_sql) {
$response->addJSON('message', PhpMyAdmin\Message::success($msg));
$response->addJSON(
'sql_query',
- PhpMyAdmin\Util::getMessage($msg, $sql_query, 'success')
+ Generator::getMessage($msg, $sql_query, 'success')
);
} elseif ($result === false) {
$response->setRequestStatus(false);
diff --git a/libraries/entry_points/server/privileges.php b/libraries/entry_points/server/privileges.php
index 95e0d0fd83..dcf94f2660 100644
--- a/libraries/entry_points/server/privileges.php
+++ b/libraries/entry_points/server/privileges.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\Controllers\Database\PrivilegesController as DatabaseController;
use PhpMyAdmin\Controllers\Table\PrivilegesController as TableController;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Relation;
use PhpMyAdmin\RelationCleanup;
@@ -169,10 +170,15 @@ $_add_user_error = false;
* Get DB information: username, hostname, dbname,
* tablename, db_and_table, dbname_is_wildcard
*/
-list(
- $username, $hostname, $dbname, $tablename, $routinename,
- $db_and_table, $dbname_is_wildcard
-) = $serverPrivileges->getDataForDBInfo();
+[
+ $username,
+ $hostname,
+ $dbname,
+ $tablename,
+ $routinename,
+ $db_and_table,
+ $dbname_is_wildcard,
+] = $serverPrivileges->getDataForDBInfo();
/**
* Checks if the user is allowed to do what they try to...
@@ -221,13 +227,13 @@ if (isset($_POST['change_copy']) && $username == $_POST['old_username']
/**
* Changes / copies a user, part I
*/
-list($queries, $password) = $serverPrivileges->getDataForChangeOrCopyUser();
+[$queries, $password] = $serverPrivileges->getDataForChangeOrCopyUser();
/**
* Adds a user
* (Changes / copies a user, part II)
*/
-list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error)
+[$ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error]
= $serverPrivileges->addUser(
isset($dbname) ? $dbname : null,
isset($username) ? $username : null,
@@ -267,7 +273,7 @@ if (! empty($routinename)) {
if (! empty($_POST['update_privs'])) {
if (is_array($dbname)) {
foreach ($dbname as $key => $db_name) {
- list($sql_query[$key], $message) = $serverPrivileges->updatePrivileges(
+ [$sql_query[$key], $message] = $serverPrivileges->updatePrivileges(
(isset($username) ? $username : ''),
(isset($hostname) ? $hostname : ''),
(isset($tablename)
@@ -280,7 +286,7 @@ if (! empty($_POST['update_privs'])) {
$sql_query = implode("\n", $sql_query);
} else {
- list($sql_query, $message) = $serverPrivileges->updatePrivileges(
+ [$sql_query, $message] = $serverPrivileges->updatePrivileges(
(isset($username) ? $username : ''),
(isset($hostname) ? $hostname : ''),
(isset($tablename)
@@ -306,7 +312,7 @@ if (! empty($_POST['changeUserGroup']) && $cfgRelation['menuswork']
* Revokes Privileges
*/
if (isset($_POST['revokeall'])) {
- list ($message, $sql_query) = $serverPrivileges->getMessageAndSqlQueryForPrivilegesRevoke(
+ [$message, $sql_query] = $serverPrivileges->getMessageAndSqlQueryForPrivilegesRevoke(
(isset($dbname) ? $dbname : ''),
(isset($tablename)
? $tablename
@@ -337,7 +343,7 @@ if (isset($_POST['delete'])
) {
$queries = $serverPrivileges->getDataForDeleteUsers($queries);
if (empty($_POST['change_copy'])) {
- list($sql_query, $message) = $serverPrivileges->deleteUser($queries);
+ [$sql_query, $message] = $serverPrivileges->deleteUser($queries);
}
}
@@ -402,7 +408,7 @@ if (isset($_GET['viewing_mode']) && $_GET['viewing_mode'] == 'db') {
$sub_part = '_structure';
ob_start();
- list(
+ [
$tables,
$num_tables,
$total_num_tables,
@@ -411,13 +417,13 @@ if (isset($_GET['viewing_mode']) && $_GET['viewing_mode'] == 'db') {
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
- $pos
- ) = PhpMyAdmin\Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
+ $pos,
+ ] = PhpMyAdmin\Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
$content = ob_get_clean();
$response->addHTML($content . "\n");
} elseif (! empty($GLOBALS['message'])) {
- $response->addHTML(PhpMyAdmin\Util::getMessage($GLOBALS['message']));
+ $response->addHTML(Generator::getMessage($GLOBALS['message']));
unset($GLOBALS['message']);
}
@@ -435,7 +441,7 @@ $response->addHTML(
if (isset($_GET['export'])
|| (isset($_POST['submit_mult']) && $_POST['submit_mult'] == 'export')
) {
- list($title, $export) = $serverPrivileges->getListForExportUserDefinition(
+ [$title, $export] = $serverPrivileges->getListForExportUserDefinition(
isset($username) ? $username : null,
isset($hostname) ? $hostname : null
);
diff --git a/libraries/entry_points/sql.php b/libraries/entry_points/sql.php
index f66b35bc59..1f0fee0427 100644
--- a/libraries/entry_points/sql.php
+++ b/libraries/entry_points/sql.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
use PhpMyAdmin\CheckUserPrivileges;
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\ParseAnalyze;
use PhpMyAdmin\Response;
use PhpMyAdmin\Sql;
@@ -159,11 +160,11 @@ if (empty($sql_query) && strlen($table) > 0 && strlen($db) > 0) {
/**
* Parse and analyze the query
*/
-list(
+[
$analyzed_sql_results,
$db,
- $table_from_sql
-) = ParseAnalyze::sqlQuery($sql_query, $db);
+ $table_from_sql,
+] = ParseAnalyze::sqlQuery($sql_query, $db);
// @todo: possibly refactor
extract($analyzed_sql_results);
@@ -184,7 +185,7 @@ if ($sql->hasNoRightsToDropDatabase(
$cfg['AllowUserDropDatabase'],
$dbi->isSuperuser()
)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
__('"DROP DATABASE" statements are disabled.'),
'',
false,
diff --git a/libraries/entry_points/table/addfield.php b/libraries/entry_points/table/addfield.php
index f22cd99d82..51f49d663b 100644
--- a/libraries/entry_points/table/addfield.php
+++ b/libraries/entry_points/table/addfield.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
use PhpMyAdmin\Config;
use PhpMyAdmin\CreateAddField;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Transformations;
@@ -87,7 +88,7 @@ if (isset($_POST['do_save_data'])) {
$createAddField = new CreateAddField($dbi);
- list($result, $sql_query) = $createAddField->tryColumnCreationQuery($db, $table, $err_url);
+ [$result, $sql_query] = $createAddField->tryColumnCreationQuery($db, $table, $err_url);
if ($result === true) {
// Update comment table for mime types [MIME]
@@ -120,11 +121,11 @@ if (isset($_POST['do_save_data'])) {
$message->addParam($table);
$response->addJSON(
'message',
- Util::getMessage($message, $sql_query, 'success')
+ Generator::getMessage($message, $sql_query, 'success')
);
exit;
} else {
- $error_message_html = Util::mysqlDie(
+ $error_message_html = Generator::mysqlDie(
'',
'',
false,
diff --git a/libraries/entry_points/table/change.php b/libraries/entry_points/table/change.php
index a41ae93b7b..6fd7aba232 100644
--- a/libraries/entry_points/table/change.php
+++ b/libraries/entry_points/table/change.php
@@ -8,11 +8,12 @@ declare(strict_types=1);
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Forms\Fields\MaxFileSize;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\InsertEdit;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
use PhpMyAdmin\Url;
-use PhpMyAdmin\Util;
if (! defined('PHPMYADMIN')) {
exit;
@@ -44,10 +45,16 @@ $insertEdit = $containerBuilder->get('insert_edit');
/**
* Determine whether Insert or Edit and set global variables
*/
-list(
- $insert_mode, $where_clause, $where_clause_array, $where_clauses,
- $result, $rows, $found_unique_key, $after_insert
-) = $insertEdit->determineInsertOrEdit(
+[
+ $insert_mode,
+ $where_clause,
+ $where_clause_array,
+ $where_clauses,
+ $result,
+ $rows,
+ $found_unique_key,
+ $after_insert,
+] = $insertEdit->determineInsertOrEdit(
isset($where_clause) ? $where_clause : null,
$db,
$table
@@ -96,7 +103,7 @@ $scripts->addFile('gis_data_editor.js');
* $disp_message come from /table/replace
*/
if (! empty($disp_message)) {
- $response->addHTML(Util::getMessage($disp_message, null));
+ $response->addHTML(Generator::getMessage($disp_message, null));
}
$table_columns = $insertEdit->getTableColumns($db, $table);
@@ -166,7 +173,7 @@ $html_output .= $insertEdit->getHtmlForInsertEditFormHeader($has_blob_field, $is
$html_output .= Url::getHiddenInputs($_form_params);
-$titles['Browse'] = Util::getIcon('b_browse', __('Browse foreign values'));
+$titles['Browse'] = Generator::getIcon('b_browse', __('Browse foreign values'));
// user can toggle the display of Function column and column types
// (currently does not work for multi-edits)
@@ -251,7 +258,7 @@ $html_output .= $insertEdit->getActionsPanel(
if ($biggest_max_file_size > 0) {
$html_output .= ' '
- . Util::generateHiddenMaxFileSize(
+ . MaxFileSize::generate(
$biggest_max_file_size
) . "\n";
}
diff --git a/libraries/entry_points/table/create.php b/libraries/entry_points/table/create.php
index e260ccf18e..0cd8703c81 100644
--- a/libraries/entry_points/table/create.php
+++ b/libraries/entry_points/table/create.php
@@ -10,6 +10,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Core;
use PhpMyAdmin\CreateAddField;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Response;
use PhpMyAdmin\Transformations;
use PhpMyAdmin\Url;
@@ -45,7 +46,7 @@ $cfg = $config->settings;
/* Check if database name is empty */
if (strlen($db) === 0) {
- Util::mysqlDie(
+ Generator::mysqlDie(
__('The database name is empty!'),
'',
false,
@@ -57,7 +58,7 @@ if (strlen($db) === 0) {
* Selects the database to work with
*/
if (! $dbi->selectDb($db)) {
- Util::mysqlDie(
+ Generator::mysqlDie(
sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
'',
false,
@@ -67,7 +68,7 @@ if (! $dbi->selectDb($db)) {
if ($dbi->getColumns($db, $table)) {
// table exists already
- Util::mysqlDie(
+ Generator::mysqlDie(
sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
'',
false,
diff --git a/libraries/entry_points/table/export.php b/libraries/entry_points/table/export.php
index 7e836fd226..7367f5990c 100644
--- a/libraries/entry_points/table/export.php
+++ b/libraries/entry_points/table/export.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Display\Export;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
use PhpMyAdmin\Url;
@@ -90,7 +91,7 @@ if (! empty($sql_query)) {
);
}
- echo PhpMyAdmin\Util::getMessage(PhpMyAdmin\Message::success());
+ echo Generator::getMessage(PhpMyAdmin\Message::success());
}
if (! isset($sql_query)) {
diff --git a/libraries/entry_points/table/get_field.php b/libraries/entry_points/table/get_field.php
index 914d98e7e7..c56dfdf45d 100644
--- a/libraries/entry_points/table/get_field.php
+++ b/libraries/entry_points/table/get_field.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Mime;
use PhpMyAdmin\Response;
@@ -41,7 +42,7 @@ PhpMyAdmin\Util::checkParameters(
/* Select database */
if (! $dbi->selectDb($db)) {
- PhpMyAdmin\Util::mysqlDie(
+ Generator::mysqlDie(
sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
'',
false
@@ -50,7 +51,7 @@ if (! $dbi->selectDb($db)) {
/* Check if table exists */
if (! $dbi->getColumns($db, $table)) {
- PhpMyAdmin\Util::mysqlDie(__('Invalid table name'));
+ Generator::mysqlDie(__('Invalid table name'));
}
/* Grab data */
@@ -61,7 +62,7 @@ $result = $dbi->fetchValue($sql);
/* Check return code */
if ($result === false) {
- PhpMyAdmin\Util::mysqlDie(
+ Generator::mysqlDie(
__('MySQL returned an empty result set (i.e. zero rows).'),
$sql
);
diff --git a/libraries/entry_points/table/operations.php b/libraries/entry_points/table/operations.php
index fa98544176..a4fa70affc 100644
--- a/libraries/entry_points/table/operations.php
+++ b/libraries/entry_points/table/operations.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
use PhpMyAdmin\CheckUserPrivileges;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\Operations;
@@ -252,7 +253,7 @@ if (isset($_POST['submitoptions'])) {
* Reordering the table has been requested by the user
*/
if (isset($_POST['submitorderby']) && ! empty($_POST['order_field'])) {
- list($sql_query, $result) = $operations->getQueryAndResultForReorderingTable();
+ [$sql_query, $result] = $operations->getQueryAndResultForReorderingTable();
} // end if
/**
@@ -261,7 +262,7 @@ if (isset($_POST['submitorderby']) && ! empty($_POST['order_field'])) {
if (isset($_POST['submit_partition'])
&& ! empty($_POST['partition_operation'])
) {
- list($sql_query, $result) = $operations->getQueryAndResultForPartition();
+ [$sql_query, $result] = $operations->getQueryAndResultForPartition();
} // end if
if ($reread_info) {
@@ -303,7 +304,7 @@ if (isset($result) && empty($message_to_show)) {
if (! empty($sql_query)) {
$response->addJSON(
'sql_query',
- Util::getMessage(null, $sql_query)
+ Generator::getMessage(null, $sql_query)
);
}
exit;
@@ -324,7 +325,7 @@ if (isset($result) && empty($message_to_show)) {
if (! empty($sql_query)) {
$response->addJSON(
'sql_query',
- Util::getMessage(null, $sql_query)
+ Generator::getMessage(null, $sql_query)
);
}
exit;
@@ -338,7 +339,7 @@ if (isset($result) && empty($message_to_show)) {
);
} else {
$response->addHTML(
- Util::getMessage($_message, $sql_query)
+ Generator::getMessage($_message, $sql_query)
);
}
unset($_message);
diff --git a/libraries/entry_points/table/replace.php b/libraries/entry_points/table/replace.php
index 15c52e04c6..1fdbdb4c0f 100644
--- a/libraries/entry_points/table/replace.php
+++ b/libraries/entry_points/table/replace.php
@@ -15,6 +15,7 @@ declare(strict_types=1);
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\File;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\InsertEdit;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\IOTransformationsPlugin;
@@ -97,7 +98,7 @@ $err_url = $insertEdit->getErrorUrl($url_params);
/**
* Prepares the update/insert of a row
*/
-list($loop_array, $using_key, $is_insert, $is_insertignore)
+[$loop_array, $using_key, $is_insert, $is_insertignore]
= $insertEdit->getParamsForUpdateOrInsert();
$query = [];
@@ -310,7 +311,7 @@ foreach ($loop_array as $rownumber => $where_clause) {
);
if (! isset($multi_edit_virtual, $multi_edit_virtual[$key])) {
- list($query_values, $query_fields)
+ [$query_values, $query_fields]
= $insertEdit->getQueryValuesForInsertAndUpdateInMultipleEdit(
$multi_edit_columns_name,
$multi_edit_columns_null,
@@ -393,9 +394,14 @@ if (isset($_POST['preview_sql'])) {
* Executes the sql query and get the result, then move back to the calling
* page
*/
-list ($url_params, $total_affected_rows, $last_messages, $warning_messages,
- $error_messages, $return_to_sql_query)
- = $insertEdit->executeSqlQuery($url_params, $query);
+[
+ $url_params,
+ $total_affected_rows,
+ $last_messages,
+ $warning_messages,
+ $error_messages,
+ $return_to_sql_query,
+] = $insertEdit->executeSqlQuery($url_params, $query);
if ($is_insert && (count($value_sets) > 0 || $row_skipped)) {
$message = Message::getMessageForInsertedRows(
@@ -519,7 +525,7 @@ if ($response->isAjax() && ! isset($_POST['ajax_page_request'])) {
$_table = new Table($_POST['table'], $_POST['db']);
$extra_data['row_count'] = $_table->countRecords();
- $extra_data['sql_query'] = Util::getMessage(
+ $extra_data['sql_query'] = Generator::getMessage(
$message,
$GLOBALS['display_query']
);
diff --git a/libraries/entry_points/view/create.php b/libraries/entry_points/view/create.php
index f0d514584d..1c3a0c51bd 100644
--- a/libraries/entry_points/view/create.php
+++ b/libraries/entry_points/view/create.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
@@ -173,7 +174,7 @@ if (isset($_POST['createview']) || isset($_POST['alterview'])) {
} else {
$response->addJSON(
'message',
- Util::getMessage(
+ Generator::getMessage(
Message::success(),
$sql_query
)
diff --git a/libraries/entry_points/view/operations.php b/libraries/entry_points/view/operations.php
index 0e51b788e6..de6b3d71fb 100644
--- a/libraries/entry_points/view/operations.php
+++ b/libraries/entry_points/view/operations.php
@@ -7,6 +7,7 @@
declare(strict_types=1);
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
use PhpMyAdmin\Operations;
use PhpMyAdmin\Relation;
@@ -92,7 +93,7 @@ if (isset($result)) {
$_message->isError(true);
unset($warning_messages);
}
- echo Util::getMessage(
+ echo Generator::getMessage(
$_message,
$sql_query,
$_type
diff --git a/test/classes/CentralColumnsTest.php b/test/classes/CentralColumnsTest.php
index 321b498e5c..6df3456dec 100644
--- a/test/classes/CentralColumnsTest.php
+++ b/test/classes/CentralColumnsTest.php
@@ -11,6 +11,7 @@ namespace PhpMyAdmin\Tests;
use PhpMyAdmin\CentralColumns;
use PhpMyAdmin\Config;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Types;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -693,14 +694,14 @@ class CentralColumnsTest extends TestCase
$this->assertStringContainsString(__('Click to sort.'), $result);
$this->assertStringContainsString(Url::getHiddenInputs($db), $result);
$this->assertStringContainsString(Url::getHiddenInputs($db), $result);
- $editSelectedButton = Util::getButtonOrImage(
+ $editSelectedButton = Generator::getButtonOrImage(
'edit_central_columns',
'mult_submit change_central_columns',
__('Edit'),
'b_edit',
'edit central columns'
);
- $deleteSelectedButton = Util::getButtonOrImage(
+ $deleteSelectedButton = Generator::getButtonOrImage(
'delete_central_columns',
'mult_submit',
__('Delete'),
diff --git a/test/classes/Controllers/Server/EnginesControllerTest.php b/test/classes/Controllers/Server/EnginesControllerTest.php
index 96dc5b59db..487d3e5af0 100644
--- a/test/classes/Controllers/Server/EnginesControllerTest.php
+++ b/test/classes/Controllers/Server/EnginesControllerTest.php
@@ -11,11 +11,10 @@ namespace PhpMyAdmin\Tests\Controllers\Server;
use PhpMyAdmin\Config;
use PhpMyAdmin\Controllers\Server\EnginesController;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Response;
use PhpMyAdmin\StorageEngine;
use PhpMyAdmin\Template;
-use PhpMyAdmin\Url;
-use PhpMyAdmin\Util;
use PHPStan\Testing\TestCase;
/**
@@ -120,7 +119,7 @@ class EnginesControllerTest extends TestCase
);
$this->assertStringContainsString(
- Util::showMySQLDocu($enginePlugin->getMysqlHelpPage()),
+ MySQLDocumentation::show($enginePlugin->getMysqlHelpPage()),
$actual
);
diff --git a/test/classes/Controllers/Server/VariablesControllerTest.php b/test/classes/Controllers/Server/VariablesControllerTest.php
index 5dfab9de4d..28a6de27b4 100644
--- a/test/classes/Controllers/Server/VariablesControllerTest.php
+++ b/test/classes/Controllers/Server/VariablesControllerTest.php
@@ -11,6 +11,7 @@ namespace PhpMyAdmin\Tests\Controllers\Server;
use PhpMyAdmin\Config;
use PhpMyAdmin\Controllers\Server\VariablesController;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
@@ -98,11 +99,11 @@ class VariablesControllerTest extends TestCase
$html = $controller->index([]);
$this->assertStringContainsString(
- Util::getIcon('b_save', __('Save')),
+ Generator::getIcon('b_save', __('Save')),
$html
);
$this->assertStringContainsString(
- Util::getIcon('b_close', __('Cancel')),
+ Generator::getIcon('b_close', __('Cancel')),
$html
);
$this->assertStringContainsString(
@@ -166,7 +167,7 @@ class VariablesControllerTest extends TestCase
$nameForValueByte,
'3',
];
- list($formattedValue, $isHtmlFormatted) = $method->invokeArgs($controller, $args);
+ [$formattedValue, $isHtmlFormatted] = $method->invokeArgs($controller, $args);
$this->assertEquals(
'3 B ',
$formattedValue
@@ -178,7 +179,7 @@ class VariablesControllerTest extends TestCase
$nameForValueNotByte,
'3',
];
- list($formattedValue, $isHtmlFormatted) = $method->invokeArgs($controller, $args);
+ [$formattedValue, $isHtmlFormatted] = $method->invokeArgs($controller, $args);
$this->assertEquals(
'3',
$formattedValue
@@ -190,7 +191,7 @@ class VariablesControllerTest extends TestCase
$nameForValueNotByte,
'value',
];
- list($formattedValue, $isHtmlFormatted) = $method->invokeArgs($controller, $args);
+ [$formattedValue, $isHtmlFormatted] = $method->invokeArgs($controller, $args);
$this->assertEquals(
'value',
$formattedValue
diff --git a/test/classes/Controllers/Table/IndexesControllerTest.php b/test/classes/Controllers/Table/IndexesControllerTest.php
index 65d4577689..91152bb27b 100644
--- a/test/classes/Controllers/Table/IndexesControllerTest.php
+++ b/test/classes/Controllers/Table/IndexesControllerTest.php
@@ -8,6 +8,8 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Table;
use PhpMyAdmin\Controllers\Table\IndexesController;
+use PhpMyAdmin\Html\MySQLDocumentation;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
@@ -176,7 +178,7 @@ class IndexesControllerTest extends PmaTestCase
$html
);
- $doc_html = Util::showHint(
+ $doc_html = Generator::showHint(
Message::notice(
__(
'"PRIMARY" must be the name of'
@@ -190,7 +192,7 @@ class IndexesControllerTest extends PmaTestCase
);
$this->assertStringContainsString(
- Util::showMySQLDocu('ALTER_TABLE'),
+ MySQLDocumentation::show('ALTER_TABLE'),
$html
);
diff --git a/test/classes/Display/CreateTableTest.php b/test/classes/Display/CreateTableTest.php
index 24ecc925bd..7e1060f42f 100644
--- a/test/classes/Display/CreateTableTest.php
+++ b/test/classes/Display/CreateTableTest.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Display;
use PhpMyAdmin\Display\CreateTable;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Theme;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -63,7 +64,7 @@ class CreateTableTest extends TestCase
//getImage
$this->assertStringContainsString(
- Util::getImage('b_table_add'),
+ Generator::getImage('b_table_add'),
$html
);
diff --git a/test/classes/Html/Forms/Fields/BrowseUploadFileBlockTest.php b/test/classes/Html/Forms/Fields/BrowseUploadFileBlockTest.php
new file mode 100644
index 0000000000..b1c45e7bff
--- /dev/null
+++ b/test/classes/Html/Forms/Fields/BrowseUploadFileBlockTest.php
@@ -0,0 +1,94 @@
+assertEquals(
+ Forms\Fields\BrowseUploadFileBlock::generate($size),
+ '' . __('Browse your computer:')
+ . ' '
+ . '
'
+ . '
'
+ . ' '
+ . '(' . __('Max: ') . $res . $unit . ')' . "\n"
+ . ' ' . "\n"
+ );
+ }
+
+ /**
+ * Data provider for testGetBrowseUploadFileBlock
+ *
+ * @return array
+ */
+ public function providerGetBrowseUploadFileBlock(): array
+ {
+ return [
+ [
+ '10',
+ __('B'),
+ '10',
+ ],
+ [
+ '100',
+ __('B'),
+ '100',
+ ],
+ [
+ '1024',
+ __('B'),
+ '1,024',
+ ],
+ [
+ '102400',
+ __('KiB'),
+ '100',
+ ],
+ [
+ '10240000',
+ __('MiB'),
+ '10',
+ ],
+ [
+ '2147483648',
+ __('MiB'),
+ '2,048',
+ ],
+ [
+ '21474836480',
+ __('GiB'),
+ '20',
+ ],
+ ];
+ }
+}
diff --git a/test/classes/Html/Forms/Fields/DropDownTest.php b/test/classes/Html/Forms/Fields/DropDownTest.php
new file mode 100644
index 0000000000..467022d27c
--- /dev/null
+++ b/test/classes/Html/Forms/Fields/DropDownTest.php
@@ -0,0 +1,140 @@
+' . "\n" . '' . "\n";
+
+ $this->assertEquals(
+ $result,
+ Forms\Fields\DropDown::generate(
+ $name,
+ $choices,
+ $active_choice,
+ $id
+ )
+ );
+ }
+
+ /**
+ * Test for getDropdown
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetDropdown(): void
+ {
+ $name = '&test_dropdown_name';
+ $choices = [
+ 'value_1' => 'label_1',
+ 'value&_2"' => 'label_2',
+ ];
+ $active_choice = null;
+ $id = 'test_<dropdown>_name';
+
+ $result = '';
+ foreach ($choices as $one_choice_value => $one_choice_label) {
+ $result .= "\n" . '';
+ }
+ $result .= "\n" . ' ' . "\n";
+
+ $this->assertEquals(
+ $result,
+ DropDown::generate(
+ $name,
+ $choices,
+ $active_choice,
+ $id
+ )
+ );
+ }
+
+ /**
+ * Test for getDropdown
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetDropdownWithActive(): void
+ {
+ $name = '&test_dropdown_name';
+ $choices = [
+ 'value_1' => 'label_1',
+ 'value&_2"' => 'label_2',
+ ];
+ $active_choice = 'value&_2"';
+ $id = 'test_<dropdown>_name';
+
+ $result = '';
+ foreach ($choices as $one_choice_value => $one_choice_label) {
+ $result .= "\n";
+ $result .= '';
+ }
+ $result .= "\n";
+ $result .= ' ' . "\n";
+
+ $this->assertEquals(
+ $result,
+ DropDown::generate(
+ $name,
+ $choices,
+ $active_choice,
+ $id
+ )
+ );
+ }
+}
diff --git a/test/classes/Html/Forms/Fields/MaxFileSizeTest.php b/test/classes/Html/Forms/Fields/MaxFileSizeTest.php
new file mode 100644
index 0000000000..c646564630
--- /dev/null
+++ b/test/classes/Html/Forms/Fields/MaxFileSizeTest.php
@@ -0,0 +1,54 @@
+assertEquals(
+ Forms\Fields\MaxFileSize::generate($size),
+ ' '
+ );
+ }
+
+ /**
+ * Data provider for testGenerate
+ *
+ * @return array
+ */
+ public function providerGenerate(): array
+ {
+ return [
+ [10],
+ ['100'],
+ [1024],
+ ['1024Mb'],
+ [2147483648],
+ ['some_string'],
+ ];
+ }
+}
diff --git a/test/classes/Html/Forms/Fields/RadioListTest.php b/test/classes/Html/Forms/Fields/RadioListTest.php
new file mode 100644
index 0000000000..5736bc275e
--- /dev/null
+++ b/test/classes/Html/Forms/Fields/RadioListTest.php
@@ -0,0 +1,364 @@
+assertEquals(
+ Forms\Fields\RadioList::generate($name, $choices),
+ ''
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFields(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value_2' => 'choice_2',
+ ];
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= ' ' . $choice_label
+ . ' ';
+ $out .= "\n";
+ $out .= '
';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate($name, $choices),
+ $out
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFieldsWithChecked(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value_2' => 'choice_2',
+ ];
+ $checked_choice = 'value_2';
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= '
' . $choice_label
+ . '';
+ $out .= "\n";
+ $out .= '
';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate(
+ $name,
+ $choices,
+ $checked_choice
+ ),
+ $out
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFieldsWithCheckedWithClass(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value_2' => 'choice_2',
+ ];
+ $checked_choice = 'value_2';
+ $class = 'test_class';
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= '
';
+ $out .= "\n";
+ $out .= ' ' . $choice_label
+ . '';
+ $out .= "\n";
+ $out .= ' ';
+ $out .= "\n";
+ $out .= '
';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate(
+ $name,
+ $choices,
+ $checked_choice,
+ true,
+ false,
+ $class
+ ),
+ $out
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFieldsWithoutBR(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value&_<2>' => 'choice_2',
+ ];
+ $checked_choice = 'choice_2';
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= '
' . $choice_label
+ . '';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate(
+ $name,
+ $choices,
+ $checked_choice,
+ false
+ ),
+ $out
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFieldsEscapeLabelEscapeLabel(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value_&2' => 'choice&_<2>',
+ ];
+ $checked_choice = 'value_2';
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= '
'
+ . htmlspecialchars($choice_label) . '';
+ $out .= "\n";
+ $out .= '
';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate(
+ $name,
+ $choices,
+ $checked_choice,
+ true,
+ true
+ ),
+ $out
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFieldsEscapeLabelNotEscapeLabel(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value_&2' => 'choice&_<2>',
+ ];
+ $checked_choice = 'value_2';
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= '
' . $choice_label
+ . '';
+ $out .= "\n";
+ $out .= '
';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate(
+ $name,
+ $choices,
+ $checked_choice,
+ true,
+ false
+ ),
+ $out
+ );
+ }
+
+ /**
+ * Test for getRadioFields
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetRadioFieldsEscapeLabelEscapeLabelWithClass(): void
+ {
+ $name = 'test_display_radio';
+ $choices = [
+ 'value_1' => 'choice_1',
+ 'value_&2' => 'choice&_<2>',
+ ];
+ $checked_choice = 'value_2';
+ $class = 'test_class';
+
+ $out = '';
+ foreach ($choices as $choice_value => $choice_label) {
+ $html_field_id = $name . '_' . $choice_value;
+ $out .= '
';
+ $out .= "\n";
+ $out .= ' '
+ . htmlspecialchars($choice_label) . '';
+ $out .= "\n";
+ $out .= ' ';
+ $out .= "\n";
+ $out .= '
';
+ $out .= "\n";
+ }
+
+ $this->assertEquals(
+ Forms\Fields\RadioList::generate(
+ $name,
+ $choices,
+ $checked_choice,
+ true,
+ true,
+ $class
+ ),
+ $out
+ );
+ }
+}
diff --git a/test/classes/Html/GeneratorTest.php b/test/classes/Html/GeneratorTest.php
new file mode 100644
index 0000000000..6c472a194a
--- /dev/null
+++ b/test/classes/Html/GeneratorTest.php
@@ -0,0 +1,379 @@
+assertEmpty(Generator::getDbLink());
+ }
+
+ /**
+ * Test for getDbLink
+ *
+ * @return void
+ *
+ * @group medium
+ */
+ public function testGetDbLinkNull(): void
+ {
+ global $cfg;
+ $GLOBALS['db'] = 'test_db';
+ $GLOBALS['server'] = 99;
+ $database = $GLOBALS['db'];
+ $this->assertEquals(
+ '
'
+ . htmlspecialchars($database) . ' ',
+ Generator::getDbLink()
+ );
+ }
+
+ /**
+ * Test for getDbLink
+ *
+ * @return void
+ */
+ public function testGetDbLink(): void
+ {
+ global $cfg;
+ $GLOBALS['server'] = 99;
+ $database = 'test_database';
+ $this->assertEquals(
+ '
'
+ . htmlspecialchars($database) . ' ',
+ Generator::getDbLink($database)
+ );
+ }
+
+ /**
+ * Test for getDbLink
+ *
+ * @return void
+ */
+ public function testGetDbLinkWithSpecialChars(): void
+ {
+ global $cfg;
+ $GLOBALS['server'] = 99;
+ $database = 'test&data\'base';
+ $this->assertEquals(
+ '
'
+ . htmlspecialchars($database) . ' ',
+ Generator::getDbLink($database)
+ );
+ }
+
+ /**
+ * Test for getDivForSliderEffect
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetDivForSliderEffectTest(): void
+ {
+ global $cfg;
+ $cfg['InitialSlidersState'] = 'undefined';
+
+ $id = 'test_id';
+ $message = 'test_message';
+
+ $this->assertXmlStringEqualsXmlString(
+ '
' . Generator::getDivForSliderEffect($id, $message) . ' ',
+ "
\n
"
+ );
+ }
+
+ /**
+ * Test for getDivForSliderEffect
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetDivForSliderEffectTestClosed(): void
+ {
+ global $cfg;
+ $cfg['InitialSlidersState'] = 'closed';
+
+ $id = 'test_id';
+ $message = 'test_message';
+
+ $this->assertXmlStringEqualsXmlString(
+ '
' . Generator::getDivForSliderEffect($id, $message) . ' ',
+ "
\n
"
+ );
+ }
+
+ /**
+ * Test for getDivForSliderEffect
+ *
+ * @return void
+ * @throws Throwable
+ * @throws Twig_Error_Loader
+ * @throws Twig_Error_Runtime
+ * @throws Twig_Error_Syntax
+ */
+ public function testGetDivForSliderEffectTestDisabled(): void
+ {
+ global $cfg;
+ $cfg['InitialSlidersState'] = 'disabled';
+
+ $id = 'test_id';
+ $message = 'test_message';
+
+ $this->assertXmlStringEqualsXmlString(
+ '
' . Generator::getDivForSliderEffect($id, $message) . ' ',
+ "\n
"
+ );
+ }
+
+ /**
+ * Test for Util::getIcon
+ *
+ * @return void
+ */
+ public function testGetIconWithoutActionLinksMode(): void
+ {
+ $GLOBALS['cfg']['ActionLinksMode'] = 'text';
+
+ $this->assertEquals(
+ ' ',
+ Generator::getIcon('b_comment')
+ );
+ }
+
+ /**
+ * Test for Util::getIcon
+ *
+ * @return void
+ */
+ public function testGetIconWithActionLinksMode(): void
+ {
+ $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
+
+ $this->assertEquals(
+ ' ',
+ Generator::getIcon('b_comment')
+ );
+ }
+
+ /**
+ * Test for Util::getIcon
+ *
+ * @return void
+ */
+ public function testGetIconAlternate(): void
+ {
+ $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
+ $alternate_text = 'alt_str';
+
+ $this->assertEquals(
+ ' ',
+ Generator::getIcon('b_comment', $alternate_text)
+ );
+ }
+
+ /**
+ * Test for Util::getIcon
+ *
+ * @return void
+ */
+ public function testGetIconWithForceText(): void
+ {
+ $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
+ $alternate_text = 'alt_str';
+
+ // Here we are checking for an icon embedded inside a span (i.e not a menu
+ // bar icon
+ $this->assertEquals(
+ ' ' . $alternate_text . ' ',
+ Generator::getIcon('b_comment', $alternate_text, true, false)
+ );
+ }
+
+ /**
+ * Test for showPHPDocumentation
+ *
+ * @return void
+ */
+ public function testShowPHPDocumentation(): void
+ {
+ $GLOBALS['server'] = 99;
+ $GLOBALS['cfg']['ServerDefault'] = 0;
+
+ $target = 'docu';
+ $lang = _pgettext('PHP documentation language', 'en');
+ $expected = ''
+ . ' ';
+
+ $this->assertEquals(
+ $expected,
+ Generator::showPHPDocumentation($target)
+ );
+ }
+
+ /**
+ * Test for Generator::linkOrButton
+ *
+ * @param array $params params
+ * @param int $limit limit
+ * @param string $match match
+ *
+ * @return void
+ *
+ * @dataProvider linksOrButtons
+ */
+ public function testLinkOrButton(array $params, $limit, $match): void
+ {
+ $restore = $GLOBALS['cfg']['LinkLengthLimit'] ?? 1000;
+ $GLOBALS['cfg']['LinkLengthLimit'] = $limit;
+ try {
+ $result = call_user_func_array(
+ [
+ Generator::class,
+ 'linkOrButton',
+ ],
+ $params
+ );
+ $this->assertEquals($match, $result);
+ } finally {
+ $GLOBALS['cfg']['LinkLengthLimit'] = $restore;
+ }
+ }
+
+ /**
+ * Data provider for Generator::linkOrButton test
+ *
+ * @return array
+ */
+ public function linksOrButtons(): array
+ {
+ return [
+ [
+ [
+ 'index.php',
+ 'text',
+ ],
+ 1000,
+ 'text ',
+ ],
+ [
+ [
+ 'index.php?some=parameter',
+ 'text',
+ ],
+ 20,
+ 'text ',
+ ],
+ [
+ [
+ 'index.php',
+ 'text',
+ [],
+ 'target',
+ ],
+ 1000,
+ 'text ',
+ ],
+ [
+ [
+ 'url.php?url=http://phpmyadmin.net/',
+ 'text',
+ [],
+ '_blank',
+ ],
+ 1000,
+ 'text ',
+ ],
+ ];
+ }
+
+ /**
+ * Test for formatSql
+ *
+ * @covers \PhpMyAdmin\Html\Generator::formatSql
+ *
+ * @return void
+ */
+ public function testFormatSql(): void
+ {
+ $this->assertEquals(
+ '' . "\n"
+ . 'SELECT 1 < 2' . "\n"
+ . ' ',
+ Generator::formatSql('SELECT 1 < 2')
+ );
+
+ $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 6;
+
+ $this->assertEquals(
+ '' . "\n"
+ . 'SELECT[...]' . "\n"
+ . ' ',
+ Generator::formatSql('SELECT 1 < 2', true)
+ );
+ }
+}
diff --git a/test/classes/Html/MySQLDocumentationTest.php b/test/classes/Html/MySQLDocumentationTest.php
new file mode 100644
index 0000000000..486e93d4bf
--- /dev/null
+++ b/test/classes/Html/MySQLDocumentationTest.php
@@ -0,0 +1,39 @@
+assertEquals(
+ ' ',
+ MySQLDocumentation::showDocumentation('page', 'anchor')
+ );
+ }
+}
diff --git a/test/classes/ImportTest.php b/test/classes/ImportTest.php
index a9518fa04c..2e0b49abaf 100644
--- a/test/classes/ImportTest.php
+++ b/test/classes/ImportTest.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Import;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\Url;
@@ -573,7 +574,7 @@ class ImportTest extends TestCase
$this->assertEquals(
[
- 'sql_query' => Util::formatSql(
+ 'sql_query' => Generator::formatSql(
$analyzed_sql_results['query']
),
'matched_rows' => 2,
diff --git a/test/classes/NormalizationTest.php b/test/classes/NormalizationTest.php
index 3fe67f2f53..fde4ddeb1a 100644
--- a/test/classes/NormalizationTest.php
+++ b/test/classes/NormalizationTest.php
@@ -9,14 +9,13 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Forms\Fields\RadioList;
use PhpMyAdmin\Normalization;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Template;
-use PhpMyAdmin\Theme;
use PhpMyAdmin\Transformations;
use PhpMyAdmin\Types;
use PhpMyAdmin\Url;
-use PhpMyAdmin\Util;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use stdClass;
@@ -550,7 +549,7 @@ class NormalizationTest extends TestCase
'3nf' => __('Third step of normalization (1NF+2NF+3NF)'),
];
- $htmlTmp = Util::getRadioFields(
+ $htmlTmp = RadioList::generate(
'normalizeTo',
$choices,
'1nf',
diff --git a/test/classes/Rte/EventsTest.php b/test/classes/Rte/EventsTest.php
index b4988263fb..5a5dcf6506 100644
--- a/test/classes/Rte/EventsTest.php
+++ b/test/classes/Rte/EventsTest.php
@@ -245,8 +245,8 @@ class EventsTest extends TestCase
/**
* Test for getEditorForm
*
- * @param array $data Data for routine
- * @param array $matcher Matcher
+ * @param array $data Data for routine
+ * @param string $matcher Matcher
*
* @return void
*
@@ -266,7 +266,7 @@ class EventsTest extends TestCase
*
* @return array
*/
- public function providerGetEditorFormEdit()
+ public function providerGetEditorFormEdit(): array
{
$data = [
'item_name' => 'foo',
diff --git a/test/classes/Server/PrivilegesTest.php b/test/classes/Server/PrivilegesTest.php
index b5cbf5df0d..d0f5481caa 100644
--- a/test/classes/Server/PrivilegesTest.php
+++ b/test/classes/Server/PrivilegesTest.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin\Tests\Server;
use PhpMyAdmin\Config;
use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
use PhpMyAdmin\RelationCleanup;
use PhpMyAdmin\Server\Privileges;
@@ -133,10 +134,15 @@ class PrivilegesTest extends TestCase
$_REQUEST['hostname'] = "PMA_hostname";
$_REQUEST['tablename'] = "PMA_tablename";
$_REQUEST['dbname'] = "PMA_dbname";
- list(
- $username, $hostname, $dbname, $tablename, $routinename,
- $db_and_table, $dbname_is_wildcard
- ) = $this->serverPrivileges->getDataForDBInfo();
+ [
+ $username,
+ $hostname,
+ $dbname,
+ $tablename,
+ $routinename,
+ $db_and_table,
+ $dbname_is_wildcard,
+ ] = $this->serverPrivileges->getDataForDBInfo();
$this->assertEquals(
"PMA_username",
$username
@@ -166,8 +172,12 @@ class PrivilegesTest extends TestCase
$_POST['pred_tablename'] = "PMA_pred__tablename";
$_POST['pred_dbname'] = ["PMA_pred_dbname"];
list(
- ,, $dbname, $tablename, $routinename,
- $db_and_table, $dbname_is_wildcard
+ ,,
+ $dbname,
+ $tablename,
+ $routinename,
+ $db_and_table,
+ $dbname_is_wildcard,
) = $this->serverPrivileges->getDataForDBInfo();
$this->assertEquals(
"PMA_pred_dbname",
@@ -507,7 +517,7 @@ class PrivilegesTest extends TestCase
public function testGetDataForChangeOrCopyUser()
{
//$_POST['change_copy'] not set
- list($queries, $password) = $this->serverPrivileges->getDataForChangeOrCopyUser();
+ [$queries, $password] = $this->serverPrivileges->getDataForChangeOrCopyUser();
$this->assertEquals(
null,
$queries
@@ -521,7 +531,7 @@ class PrivilegesTest extends TestCase
$_POST['change_copy'] = true;
$_POST['old_username'] = 'PMA_old_username';
$_POST['old_hostname'] = 'PMA_old_hostname';
- list($queries, $password) = $this->serverPrivileges->getDataForChangeOrCopyUser();
+ [$queries, $password] = $this->serverPrivileges->getDataForChangeOrCopyUser();
$this->assertEquals(
'pma_password',
$password
@@ -544,7 +554,7 @@ class PrivilegesTest extends TestCase
$username = "PMA_username";
$hostname = "PMA_hostname";
- list($title, $export)
+ [$title, $export]
= $this->serverPrivileges->getListForExportUserDefinition($username, $hostname);
//validate 1: $export
@@ -593,10 +603,11 @@ class PrivilegesTest extends TestCase
$_POST['userGroup'] = "username";
$_POST['authentication_plugin'] = 'mysql_native_password';
- list(
- $ret_message,,, $sql_query,
- $_add_user_error
- ) = $this->serverPrivileges->addUser(
+ [
+ $ret_message,,,
+ $sql_query,
+ $_add_user_error,
+ ] = $this->serverPrivileges->addUser(
$dbname,
$username,
$hostname,
@@ -641,10 +652,11 @@ class PrivilegesTest extends TestCase
$_POST['userGroup'] = "username";
$_POST['authentication_plugin'] = 'mysql_native_password';
- list(
- $ret_message,,, $sql_query,
- $_add_user_error
- ) = $this->serverPrivileges->addUser(
+ [
+ $ret_message,,,
+ $sql_query,
+ $_add_user_error,
+ ] = $this->serverPrivileges->addUser(
$dbname,
$username,
$hostname,
@@ -712,7 +724,7 @@ class PrivilegesTest extends TestCase
$_POST['createdb-3'] = true;
$_POST['Grant_priv'] = 'Y';
$_POST['max_questions'] = 1000;
- list ($message, $sql_query)
+ [$message, $sql_query]
= $this->serverPrivileges->getMessageAndSqlQueryForPrivilegesRevoke(
$dbname,
$tablename,
@@ -751,7 +763,7 @@ class PrivilegesTest extends TestCase
$_POST['createdb-3'] = true;
$_POST['Grant_priv'] = 'Y';
$_POST['max_questions'] = 1000;
- list($sql_query, $message) = $this->serverPrivileges->updatePrivileges(
+ [$sql_query, $message] = $this->serverPrivileges->updatePrivileges(
$username,
$hostname,
$tablename,
@@ -973,20 +985,19 @@ class PrivilegesTest extends TestCase
$_POST['authentication_plugin'] = 'mysql_native_password';
$dbname = "PMA_db";
- list(
+ [
$create_user_real,
$create_user_show,
$real_sql_query,
- $sql_query,
- ,
- ,
+ $sql_query,,,
$alter_real_sql_query,
- $alter_sql_query
- ) = $this->serverPrivileges->getSqlQueriesForDisplayAndAddUser(
- $username,
- $hostname,
- $password
- );
+ $alter_sql_query,
+ ]
+ = $this->serverPrivileges->getSqlQueriesForDisplayAndAddUser(
+ $username,
+ $hostname,
+ $password
+ );
//validate 1: $create_user_real
$this->assertEquals(
@@ -1025,7 +1036,7 @@ class PrivilegesTest extends TestCase
);
//Test for addUserAndCreateDatabase
- list($sql_query, $message) = $this->serverPrivileges->addUserAndCreateDatabase(
+ [$sql_query, $message] = $this->serverPrivileges->addUserAndCreateDatabase(
false,
$real_sql_query,
$sql_query,
@@ -1177,7 +1188,7 @@ class PrivilegesTest extends TestCase
$html
);
- $output = Util::showHint(
+ $output = Generator::showHint(
__(
'When Host table is used, this field is ignored '
. 'and values stored in Host table are used instead.'
@@ -1429,7 +1440,7 @@ class PrivilegesTest extends TestCase
//sql_query
$this->assertEquals(
- Util::getMessage(null, $sql_query),
+ Generator::getMessage(null, $sql_query),
$extra_data['sql_query']
);
@@ -1532,7 +1543,7 @@ class PrivilegesTest extends TestCase
//Util::showHint
$this->assertStringContainsString(
- Util::showHint(
+ Generator::showHint(
__('Note: MySQL privilege names are expressed in English.')
),
$html
@@ -1640,7 +1651,7 @@ class PrivilegesTest extends TestCase
$html
);
$this->assertStringContainsString(
- Util::getIcon('b_usradd'),
+ Generator::getIcon('b_usradd'),
$html
);
$this->assertStringContainsString(
diff --git a/test/classes/SqlQueryFormTest.php b/test/classes/SqlQueryFormTest.php
index dc35838885..8e5e79d094 100644
--- a/test/classes/SqlQueryFormTest.php
+++ b/test/classes/SqlQueryFormTest.php
@@ -10,10 +10,10 @@ namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Core;
use PhpMyAdmin\Encoding;
+use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\SqlQueryForm;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
-use PhpMyAdmin\Util;
use PHPUnit\Framework\TestCase;
/**
@@ -129,9 +129,9 @@ class SqlQueryFormTest extends TestCase
$html
);
- //validate 3: showMySQLDocu
+ //validate 3: MySQLDocumentation::show
$this->assertStringContainsString(
- Util::showMySQLDocu('SELECT'),
+ MySQLDocumentation::show('SELECT'),
$html
);
diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php
index 2adb40caf3..badbd4903e 100644
--- a/test/classes/UtilTest.php
+++ b/test/classes/UtilTest.php
@@ -10,10 +10,11 @@ namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Config;
use PhpMyAdmin\Core;
+use PhpMyAdmin\Html\Forms;
+use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\MoTranslator\Loader;
use PhpMyAdmin\SqlParser\Context;
use PhpMyAdmin\SqlParser\Token;
-use PhpMyAdmin\Tests\PmaTestCase;
use PhpMyAdmin\Util;
/**
@@ -172,115 +173,6 @@ class UtilTest extends PmaTestCase
$this->assertEquals(16, strlen(Util::generateRandom(16)));
}
- /**
- * Test for PhpMyAdmin\Util::getBrowseUploadFileBlock
- *
- * @param int $size Size
- * @param string $unit Unit
- * @param string $res Result
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getBrowseUploadFileBlock
- * @dataProvider providerGetBrowseUploadFileBlock
- */
- public function testGetBrowseUploadFileBlock($size, $unit, $res): void
- {
- $GLOBALS['is_upload'] = false;
- $this->assertEquals(
- Util::getBrowseUploadFileBlock($size),
- '' . __("Browse your computer:")
- . ' '
- . '
'
- . '
'
- . ' '
- . "(" . __('Max: ') . $res . $unit . ')' . "\n"
- . ' ' . "\n"
- );
- }
-
- /**
- * Data provider for testGetBrowseUploadFileBlock
- *
- * @return array
- */
- public function providerGetBrowseUploadFileBlock()
- {
- return [
- [
- 10,
- __('B'),
- "10",
- ],
- [
- 100,
- __('B'),
- "100",
- ],
- [
- 1024,
- __('B'),
- "1,024",
- ],
- [
- 102400,
- __('KiB'),
- "100",
- ],
- [
- 10240000,
- __('MiB'),
- "10",
- ],
- [
- 2147483648,
- __('MiB'),
- "2,048",
- ],
- [
- 21474836480,
- __('GiB'),
- "20",
- ],
- ];
- }
-
- /**
- * Test for PhpMyAdmin\Util::buildActionTitles
- *
- * @covers \PhpMyAdmin\Util::buildActionTitles
- *
- * @return void
- */
- public function testBuildActionTitles()
- {
- $GLOBALS['cfg'] = ['ActionLinksMode' => 'both'];
-
- $titles = [];
- $titles['Browse'] = Util::getIcon('b_browse', __('Browse'));
- $titles['NoBrowse'] = Util::getIcon('bd_browse', __('Browse'));
- $titles['Search'] = Util::getIcon('b_select', __('Search'));
- $titles['NoSearch'] = Util::getIcon('bd_select', __('Search'));
- $titles['Insert'] = Util::getIcon('b_insrow', __('Insert'));
- $titles['NoInsert'] = Util::getIcon('bd_insrow', __('Insert'));
- $titles['Structure'] = Util::getIcon('b_props', __('Structure'));
- $titles['Drop'] = Util::getIcon('b_drop', __('Drop'));
- $titles['NoDrop'] = Util::getIcon('bd_drop', __('Drop'));
- $titles['Empty'] = Util::getIcon('b_empty', __('Empty'));
- $titles['NoEmpty'] = Util::getIcon('bd_empty', __('Empty'));
- $titles['Edit'] = Util::getIcon('b_edit', __('Edit'));
- $titles['NoEdit'] = Util::getIcon('bd_edit', __('Edit'));
- $titles['Export'] = Util::getIcon('b_export', __('Export'));
- $titles['NoExport'] = Util::getIcon('bd_export', __('Export'));
- $titles['Execute'] = Util::getIcon('b_nextpage', __('Execute'));
- $titles['NoExecute'] = Util::getIcon('bd_nextpage', __('Execute'));
- $titles['Favorite'] = Util::getIcon('b_favorite', '');
- $titles['NoFavorite'] = Util::getIcon('b_no_favorite', '');
-
- $this->assertEquals($titles, Util::buildActionTitles());
- }
-
/**
* Test if cached data is available after set
*
@@ -885,32 +777,6 @@ class UtilTest extends PmaTestCase
];
}
- /**
- * Test for formatSql
- *
- * @covers \PhpMyAdmin\Util::formatSql
- *
- * @return void
- */
- public function testFormatSql()
- {
- $this->assertEquals(
- '' . "\n"
- . 'SELECT 1 < 2' . "\n"
- . ' ',
- Util::formatSql('SELECT 1 < 2')
- );
-
- $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 6;
-
- $this->assertEquals(
- '' . "\n"
- . 'SELECT[...]' . "\n"
- . ' ',
- Util::formatSql('SELECT 1 < 2', true)
- );
- }
-
/**
* format byte test, globals are defined
*
@@ -1203,309 +1069,6 @@ class UtilTest extends PmaTestCase
];
}
- /**
- * Test for Util::generateHiddenMaxFileSize
- *
- * @param int $size Size
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::generateHiddenMaxFileSize
- * @dataProvider providerGenerateHiddenMaxFileSize
- */
- public function testGenerateHiddenMaxFileSize($size): void
- {
- $this->assertEquals(
- Util::generateHiddenMaxFileSize($size),
- ' '
- );
- }
-
- /**
- * Data provider for testGenerateHiddenMaxFileSize
- *
- * @return array
- */
- public function providerGenerateHiddenMaxFileSize()
- {
- return [
- [10],
- ["100"],
- [1024],
- ["1024Mb"],
- [2147483648],
- ["some_string"],
- ];
- }
-
- /**
- * Test for getDbLink
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDbLink
- * @group medium
- */
- public function testGetDbLinkEmpty()
- {
- $GLOBALS['db'] = null;
- $this->assertEmpty(Util::getDbLink());
- }
-
- /**
- * Test for getDbLink
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDbLink
- * @group medium
- */
- public function testGetDbLinkNull()
- {
- global $cfg;
- $GLOBALS['db'] = 'test_db';
- $GLOBALS['server'] = 99;
- $database = $GLOBALS['db'];
- $this->assertEquals(
- ''
- . htmlspecialchars($database) . ' ',
- Util::getDbLink()
- );
- }
-
- /**
- * Test for getDbLink
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDbLink
- */
- public function testGetDbLink()
- {
- global $cfg;
- $GLOBALS['server'] = 99;
- $database = 'test_database';
- $this->assertEquals(
- ''
- . htmlspecialchars($database) . ' ',
- Util::getDbLink($database)
- );
- }
-
- /**
- * Test for getDbLink
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDbLink
- */
- public function testGetDbLinkWithSpecialChars()
- {
- global $cfg;
- $GLOBALS['server'] = 99;
- $database = 'test&data\'base';
- $this->assertEquals(
- ''
- . htmlspecialchars($database) . ' ',
- Util::getDbLink($database)
- );
- }
-
- /**
- * Test for getDivForSliderEffect
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDivForSliderEffect
- */
- public function testGetDivForSliderEffectTest()
- {
- global $cfg;
- $cfg['InitialSlidersState'] = 'undefined';
-
- $id = "test_id";
- $message = "test_message";
-
- $this->assertXmlStringEqualsXmlString(
- "" . Util::getDivForSliderEffect($id, $message) . " ",
- "\n
"
- );
- }
-
- /**
- * Test for getDivForSliderEffect
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDivForSliderEffect
- */
- public function testGetDivForSliderEffectTestClosed()
- {
- global $cfg;
- $cfg['InitialSlidersState'] = 'closed';
-
- $id = "test_id";
- $message = "test_message";
-
- $this->assertXmlStringEqualsXmlString(
- "" . Util::getDivForSliderEffect($id, $message) . " ",
- "\n
"
- );
- }
-
- /**
- * Test for getDivForSliderEffect
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDivForSliderEffect
- */
- public function testGetDivForSliderEffectTestDisabled()
- {
- global $cfg;
- $cfg['InitialSlidersState'] = 'disabled';
-
- $id = "test_id";
- $message = "test_message";
-
- $this->assertXmlStringEqualsXmlString(
- "" . Util::getDivForSliderEffect($id, $message) . " ",
- "\n
"
- );
- }
-
- /**
- * Test for getDropdown
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDropdown
- */
- public function testGetDropdownEmpty()
- {
- $name = "test_dropdown_name";
- $choices = [];
- $active_choice = null;
- $id = "test_<dropdown>_name";
-
- $result = '' . "\n" . ' ' . "\n";
-
- $this->assertEquals(
- $result,
- Util::getDropdown(
- $name,
- $choices,
- $active_choice,
- $id
- )
- );
- }
-
- /**
- * Test for getDropdown
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDropdown
- */
- public function testGetDropdown()
- {
- $name = "&test_dropdown_name";
- $choices = [
- "value_1" => "label_1",
- "value&_2\"" => "label_2",
- ];
- $active_choice = null;
- $id = "test_<dropdown>_name";
-
- $result = '';
- foreach ($choices as $one_choice_value => $one_choice_label) {
- $result .= "\n" . '';
- }
- $result .= "\n" . ' ' . "\n";
-
- $this->assertEquals(
- $result,
- Util::getDropdown(
- $name,
- $choices,
- $active_choice,
- $id
- )
- );
- }
-
- /**
- * Test for getDropdown
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getDropdown
- */
- public function testGetDropdownWithActive()
- {
- $name = "&test_dropdown_name";
- $choices = [
- "value_1" => "label_1",
- "value&_2\"" => "label_2",
- ];
- $active_choice = "value&_2\"";
- $id = "test_<dropdown>_name";
-
- $result = '';
- foreach ($choices as $one_choice_value => $one_choice_label) {
- $result .= "\n";
- $result .= '';
- }
- $result .= "\n";
- $result .= ' ' . "\n";
-
- $this->assertEquals(
- $result,
- Util::getDropdown(
- $name,
- $choices,
- $active_choice,
- $id
- )
- );
- }
-
/**
* Test for Util::getFormattedMaximumUploadSize
*
@@ -1572,405 +1135,6 @@ class UtilTest extends PmaTestCase
];
}
- /**
- * Test for Util::getIcon
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getIcon
- */
- public function testGetIconWithoutActionLinksMode()
- {
- $GLOBALS['cfg']['ActionLinksMode'] = 'text';
-
- $this->assertEquals(
- ' ',
- Util::getIcon('b_comment')
- );
- }
-
- /**
- * Test for Util::getIcon
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getIcon
- */
- public function testGetIconWithActionLinksMode()
- {
- $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
-
- $this->assertEquals(
- ' ',
- Util::getIcon('b_comment')
- );
- }
-
- /**
- * Test for Util::getIcon
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getIcon
- */
- public function testGetIconAlternate()
- {
- $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
- $alternate_text = 'alt_str';
-
- $this->assertEquals(
- ' ',
- Util::getIcon('b_comment', $alternate_text)
- );
- }
-
- /**
- * Test for Util::getIcon
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getIcon
- */
- public function testGetIconWithForceText()
- {
- $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
- $alternate_text = 'alt_str';
-
- // Here we are checking for an icon embedded inside a span (i.e not a menu
- // bar icon
- $this->assertEquals(
- ' ' . $alternate_text . ' ',
- Util::getIcon('b_comment', $alternate_text, true, false)
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsEmpty()
- {
- $name = "test_display_radio";
- $choices = [];
-
- $this->assertEquals(
- Util::getRadioFields($name, $choices),
- ""
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFields()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value_2' => 'choice_2',
- ];
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= ' ' . $choice_label
- . '';
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields($name, $choices),
- $out
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsWithChecked()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value_2' => 'choice_2',
- ];
- $checked_choice = "value_2";
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= ' ' . $choice_label
- . '';
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields(
- $name,
- $choices,
- $checked_choice
- ),
- $out
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsWithCheckedWithClass()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value_2' => 'choice_2',
- ];
- $checked_choice = "value_2";
- $class = "test_class";
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= '';
- $out .= "\n";
- $out .= ' ' . $choice_label
- . '';
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
- $out .= '
';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields(
- $name,
- $choices,
- $checked_choice,
- true,
- false,
- $class
- ),
- $out
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsWithoutBR()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value&_<2>' => 'choice_2',
- ];
- $checked_choice = "choice_2";
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= ' ' . $choice_label
- . '';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields(
- $name,
- $choices,
- $checked_choice,
- false
- ),
- $out
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsEscapeLabelEscapeLabel()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value_&2' => 'choice&_<2>',
- ];
- $checked_choice = "value_2";
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= ' '
- . htmlspecialchars($choice_label) . '';
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields(
- $name,
- $choices,
- $checked_choice,
- true,
- true
- ),
- $out
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsEscapeLabelNotEscapeLabel()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value_&2' => 'choice&_<2>',
- ];
- $checked_choice = "value_2";
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= ' ' . $choice_label
- . '';
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields(
- $name,
- $choices,
- $checked_choice,
- true,
- false
- ),
- $out
- );
- }
-
- /**
- * Test for getRadioFields
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::getRadioFields
- */
- public function testGetRadioFieldsEscapeLabelEscapeLabelWithClass()
- {
- $name = "test_display_radio";
- $choices = [
- 'value_1' => 'choice_1',
- 'value_&2' => 'choice&_<2>',
- ];
- $checked_choice = "value_2";
- $class = "test_class";
-
- $out = "";
- foreach ($choices as $choice_value => $choice_label) {
- $html_field_id = $name . '_' . $choice_value;
- $out .= '';
- $out .= "\n";
- $out .= ' '
- . htmlspecialchars($choice_label) . '';
- $out .= "\n";
- $out .= ' ';
- $out .= "\n";
- $out .= '
';
- $out .= "\n";
- }
-
- $this->assertEquals(
- Util::getRadioFields(
- $name,
- $choices,
- $checked_choice,
- true,
- true,
- $class
- ),
- $out
- );
- }
-
/**
* Test for Util::getTitleForTarget
*
@@ -2403,49 +1567,6 @@ class UtilTest extends PmaTestCase
}
}
- /**
- * Test for Util::showDocu
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::showDocu
- */
- public function testShowDocu()
- {
- $GLOBALS['server'] = '99';
- $GLOBALS['cfg']['ServerDefault'] = 1;
-
- $this->assertEquals(
- ' ',
- Util::showDocu('page', 'anchor')
- );
- }
-
- /**
- * Test for showPHPDocu
- *
- * @return void
- *
- * @covers \PhpMyAdmin\Util::showPHPDocu
- */
- public function testShowPHPDocu()
- {
- $GLOBALS['server'] = 99;
- $GLOBALS['cfg']['ServerDefault'] = 0;
-
- $target = "docu";
- $lang = _pgettext('PHP documentation language', 'en');
- $expected = ''
- . ' ';
-
- $this->assertEquals(
- $expected,
- Util::showPHPDocu($target)
- );
- }
-
/**
* test of generating user dir, globals are defined
*
@@ -2550,7 +1671,7 @@ class UtilTest extends PmaTestCase
*
* @return void
*
- * @covers PhpMyAdmin\Util::getPageFromPosition
+ * @covers \PhpMyAdmin\Util::getPageFromPosition
*/
public function testGetPageFromPosition()
{
@@ -2561,79 +1682,36 @@ class UtilTest extends PmaTestCase
}
/**
- * Test for Util::linkOrButton
- *
- * @param array $params params
- * @param int $limit limit
- * @param string $match match
+ * Test for PhpMyAdmin\Util::buildActionTitles
*
* @return void
- *
- * @dataProvider linksOrButtons
*/
- public function testLinkOrButton(array $params, $limit, $match): void
+ public function testBuildActionTitles(): void
{
- $restore = $GLOBALS['cfg']['LinkLengthLimit'] ?? 1000;
- $GLOBALS['cfg']['LinkLengthLimit'] = $limit;
- try {
- $result = call_user_func_array(
- [
- 'PhpMyAdmin\Util',
- 'linkOrButton',
- ],
- $params
- );
- $this->assertEquals($match, $result);
- } finally {
- $GLOBALS['cfg']['LinkLengthLimit'] = $restore;
- }
- }
+ $GLOBALS['cfg'] = ['ActionLinksMode' => 'both'];
- /**
- * Data provider for Util::linkOrButton test
- *
- * @return array
- */
- public function linksOrButtons()
- {
- return [
- [
- [
- 'index.php',
- 'text',
- ],
- 1000,
- 'text ',
- ],
- [
- [
- 'index.php?some=parameter',
- 'text',
- ],
- 20,
- 'text ',
- ],
- [
- [
- 'index.php',
- 'text',
- [],
- 'target',
- ],
- 1000,
- 'text ',
- ],
- [
- [
- 'url.php?url=http://phpmyadmin.net/',
- 'text',
- [],
- '_blank',
- ],
- 1000,
- 'text ',
- ],
- ];
+ $titles = [];
+ $titles['Browse'] = Generator::getIcon('b_browse', __('Browse'));
+ $titles['NoBrowse'] = Generator::getIcon('bd_browse', __('Browse'));
+ $titles['Search'] = Generator::getIcon('b_select', __('Search'));
+ $titles['NoSearch'] = Generator::getIcon('bd_select', __('Search'));
+ $titles['Insert'] = Generator::getIcon('b_insrow', __('Insert'));
+ $titles['NoInsert'] = Generator::getIcon('bd_insrow', __('Insert'));
+ $titles['Structure'] = Generator::getIcon('b_props', __('Structure'));
+ $titles['Drop'] = Generator::getIcon('b_drop', __('Drop'));
+ $titles['NoDrop'] = Generator::getIcon('bd_drop', __('Drop'));
+ $titles['Empty'] = Generator::getIcon('b_empty', __('Empty'));
+ $titles['NoEmpty'] = Generator::getIcon('bd_empty', __('Empty'));
+ $titles['Edit'] = Generator::getIcon('b_edit', __('Edit'));
+ $titles['NoEdit'] = Generator::getIcon('bd_edit', __('Edit'));
+ $titles['Export'] = Generator::getIcon('b_export', __('Export'));
+ $titles['NoExport'] = Generator::getIcon('bd_export', __('Export'));
+ $titles['Execute'] = Generator::getIcon('b_nextpage', __('Execute'));
+ $titles['NoExecute'] = Generator::getIcon('bd_nextpage', __('Execute'));
+ $titles['Favorite'] = Generator::getIcon('b_favorite', '');
+ $titles['NoFavorite'] = Generator::getIcon('b_no_favorite', '');
+
+ $this->assertEquals($titles, Util::buildActionTitles());
}
/**