Move addScriptFiles method to ResponseRenderer class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
15d560c439
commit
235c61da17
@ -4036,7 +4036,7 @@ parameters:
|
||||
path: src/Controllers/Table/ChangeController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$files of method PhpMyAdmin\\\\Controllers\\\\AbstractController\\:\\:addScriptFiles\\(\\) expects array\\<string\\>, mixed given\\.$#"
|
||||
message: "#^Parameter \\#1 \\$files of method PhpMyAdmin\\\\ResponseRenderer\\:\\:addScriptFiles\\(\\) expects array\\<int, string\\>, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Controllers/Table/ChangeController.php
|
||||
|
||||
|
||||
@ -26,14 +26,6 @@ abstract class AbstractController implements InvocableController
|
||||
$this->response->addHTML($this->template->render($templatePath, $templateData));
|
||||
}
|
||||
|
||||
/** @param string[] $files */
|
||||
protected function addScriptFiles(array $files): void
|
||||
{
|
||||
$header = $this->response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFiles($files);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $params */
|
||||
protected function redirect(string $route, array $params = []): void
|
||||
{
|
||||
|
||||
@ -91,7 +91,7 @@ class CentralColumnsController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'vendor/jquery/jquery.uitablefilter.js',
|
||||
'vendor/jquery/jquery.tablesorter.js',
|
||||
'database/central_columns.js',
|
||||
|
||||
@ -223,7 +223,7 @@ class DesignerController extends AbstractController
|
||||
$header = $this->response->getHeader();
|
||||
$header->setBodyId('designer_body');
|
||||
|
||||
$this->addScriptFiles(['designer/init.js']);
|
||||
$this->response->addScriptFiles(['designer/init.js']);
|
||||
|
||||
$columnsType = $this->databaseDesigner->getColumnTypes($tableColumn, $tablesAllKeys);
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ final class EventsController extends AbstractController
|
||||
$GLOBALS['errors'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['database/events.js', 'sql.js']);
|
||||
$this->response->addScriptFiles(['database/events.js', 'sql.js']);
|
||||
|
||||
if (! $request->isAjax()) {
|
||||
if (! $this->checkParameters(['db'])) {
|
||||
|
||||
@ -50,7 +50,7 @@ final class ExportController extends AbstractController
|
||||
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
|
||||
$pageSettingsHtml = $this->pageSettings->getHTML();
|
||||
|
||||
$this->addScriptFiles(['export.js']);
|
||||
$this->response->addScriptFiles(['export.js']);
|
||||
|
||||
if (! $this->checkParameters(['db'])) {
|
||||
return null;
|
||||
|
||||
@ -50,7 +50,7 @@ final class ImportController extends AbstractController
|
||||
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
|
||||
$pageSettingsHtml = $this->pageSettings->getHTML();
|
||||
|
||||
$this->addScriptFiles(['import.js']);
|
||||
$this->response->addScriptFiles(['import.js']);
|
||||
|
||||
if (! $this->checkParameters(['db'])) {
|
||||
return null;
|
||||
|
||||
@ -25,7 +25,7 @@ class MultiTableQueryController extends AbstractController
|
||||
|
||||
public function __invoke(ServerRequest $request): Response|null
|
||||
{
|
||||
$this->addScriptFiles(['database/multi_table_query.js', 'database/query_generator.js']);
|
||||
$this->response->addScriptFiles(['database/multi_table_query.js', 'database/query_generator.js']);
|
||||
|
||||
$queryInstance = new MultiTableQuery($this->dbi, $this->template, Current::$database);
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ class PrivilegesController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
$this->response->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
|
||||
/**
|
||||
* Checks if the user is allowed to do what they try to...
|
||||
|
||||
@ -54,7 +54,7 @@ class RoutinesController extends AbstractController
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['database/routines.js', 'sql.js']);
|
||||
$this->response->addScriptFiles(['database/routines.js', 'sql.js']);
|
||||
|
||||
$type = $_REQUEST['type'] ?? null;
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ class SearchController extends AbstractController
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['database/search.js', 'sql.js', 'makegrid.js']);
|
||||
$this->response->addScriptFiles(['database/search.js', 'sql.js', 'makegrid.js']);
|
||||
|
||||
if (! $this->checkParameters(['db'])) {
|
||||
return null;
|
||||
|
||||
@ -43,7 +43,7 @@ class SqlController extends AbstractController
|
||||
$GLOBALS['back'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']);
|
||||
$this->response->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']);
|
||||
|
||||
$this->pageSettings->init('Sql');
|
||||
$this->response->addHTML($this->pageSettings->getErrorHTML());
|
||||
|
||||
@ -151,7 +151,7 @@ final class StructureController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['database/structure.js', 'table/change.js']);
|
||||
$this->response->addScriptFiles(['database/structure.js', 'table/change.js']);
|
||||
|
||||
// Gets the database structure
|
||||
$this->getDatabaseInfo($request);
|
||||
|
||||
@ -46,7 +46,7 @@ class TrackingController extends AbstractController
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'database/tracking.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'database/tracking.js']);
|
||||
|
||||
if (! $this->checkParameters(['db'])) {
|
||||
return null;
|
||||
|
||||
@ -90,7 +90,7 @@ final class ExportController extends AbstractController
|
||||
$tableStructure = $request->getParsedBodyParam('table_structure');
|
||||
$lockTables = $request->hasBodyParam('lock_tables');
|
||||
|
||||
$this->addScriptFiles(['export_output.js']);
|
||||
$this->response->addScriptFiles(['export_output.js']);
|
||||
|
||||
$this->setGlobalsFromRequest($postParams);
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ class HomeController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['home.js']);
|
||||
$this->response->addScriptFiles(['home.js']);
|
||||
|
||||
// This is for $cfg['ShowDatabasesNavigationAsTree'] = false;
|
||||
// See: https://github.com/phpmyadmin/phpmyadmin/issues/16520
|
||||
|
||||
@ -23,7 +23,7 @@ final class FirstStepController extends AbstractController
|
||||
|
||||
public function __invoke(ServerRequest $request): Response|null
|
||||
{
|
||||
$this->addScriptFiles(['normalization.js', 'vendor/jquery/jquery.uitablefilter.js']);
|
||||
$this->response->addScriptFiles(['normalization.js', 'vendor/jquery/jquery.uitablefilter.js']);
|
||||
|
||||
$normalForm = '1nf';
|
||||
$normalizeTo = $request->getParsedBodyParam('normalizeTo');
|
||||
|
||||
@ -16,7 +16,7 @@ class MainController extends AbstractController
|
||||
{
|
||||
public function __invoke(ServerRequest $request): Response|null
|
||||
{
|
||||
$this->addScriptFiles(['normalization.js', 'vendor/jquery/jquery.uitablefilter.js']);
|
||||
$this->response->addScriptFiles(['normalization.js', 'vendor/jquery/jquery.uitablefilter.js']);
|
||||
$this->render('table/normalization/normalization', ['db' => Current::$database, 'table' => Current::$table]);
|
||||
|
||||
return null;
|
||||
|
||||
@ -57,7 +57,7 @@ class DatabaseController extends AbstractController
|
||||
|
||||
$userPrivileges = $this->userPrivilegesFactory->getPrivileges();
|
||||
|
||||
$this->addScriptFiles(['database/operations.js']);
|
||||
$this->response->addScriptFiles(['database/operations.js']);
|
||||
|
||||
$GLOBALS['sql_query'] = '';
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ class TableController extends AbstractController
|
||||
|
||||
$pmaTable = $this->dbi->getTable(Current::$database, Current::$table);
|
||||
|
||||
$this->addScriptFiles(['table/operations.js']);
|
||||
$this->response->addScriptFiles(['table/operations.js']);
|
||||
|
||||
if (! $this->checkParameters(['db', 'table'])) {
|
||||
return null;
|
||||
|
||||
@ -45,7 +45,7 @@ class ViewController extends AbstractController
|
||||
$tableObject = $this->dbi->getTable(Current::$database, Current::$table);
|
||||
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
$this->addScriptFiles(['table/operations.js']);
|
||||
$this->response->addScriptFiles(['table/operations.js']);
|
||||
|
||||
if (! $this->checkParameters(['db', 'table'])) {
|
||||
return null;
|
||||
|
||||
@ -86,7 +86,7 @@ class DatabasesController extends AbstractController
|
||||
Assert::string($sortOrder);
|
||||
$this->sortOrder = strtolower($sortOrder) !== 'desc' ? 'asc' : 'desc';
|
||||
|
||||
$this->addScriptFiles(['server/databases.js']);
|
||||
$this->response->addScriptFiles(['server/databases.js']);
|
||||
$GLOBALS['errorUrl'] = Url::getFromRoute('/');
|
||||
|
||||
if ($this->dbi->isSuperUser()) {
|
||||
|
||||
@ -47,7 +47,7 @@ final class ExportController extends AbstractController
|
||||
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
|
||||
$pageSettingsHtml = $this->pageSettings->getHTML();
|
||||
|
||||
$this->addScriptFiles(['export.js']);
|
||||
$this->response->addScriptFiles(['export.js']);
|
||||
|
||||
$GLOBALS['select_item'] = $GLOBALS['tmp_select'] ?? '';
|
||||
$databases = $this->export->getDatabasesForSelectOptions($GLOBALS['select_item']);
|
||||
|
||||
@ -47,7 +47,7 @@ final class ImportController extends AbstractController
|
||||
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
|
||||
$pageSettingsHtml = $this->pageSettings->getHTML();
|
||||
|
||||
$this->addScriptFiles(['import.js']);
|
||||
$this->response->addScriptFiles(['import.js']);
|
||||
$GLOBALS['errorUrl'] = Url::getFromRoute('/');
|
||||
|
||||
if ($this->dbi->isSuperUser()) {
|
||||
|
||||
@ -40,7 +40,7 @@ class PluginsController extends AbstractController
|
||||
$this->dbi->selectDb('mysql');
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'server/plugins.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'server/plugins.js']);
|
||||
|
||||
$plugins = [];
|
||||
$serverPlugins = $this->plugins->getAll();
|
||||
|
||||
@ -55,7 +55,7 @@ class PrivilegesController extends AbstractController
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
$this->response->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
|
||||
$relationCleanup = new RelationCleanup($this->dbi, $this->relation);
|
||||
$serverPrivileges = new Privileges(
|
||||
|
||||
@ -56,7 +56,7 @@ class ReplicationController extends AbstractController
|
||||
$primaryInfo = $replicationInfo->getPrimaryInfo();
|
||||
$replicaInfo = $replicationInfo->getReplicaInfo();
|
||||
|
||||
$this->addScriptFiles(['server/privileges.js', 'replication.js', 'vendor/zxcvbn-ts.js']);
|
||||
$this->response->addScriptFiles(['server/privileges.js', 'replication.js', 'vendor/zxcvbn-ts.js']);
|
||||
|
||||
$urlParams = $request->getParsedBodyParam('url_params');
|
||||
if (is_array($urlParams)) {
|
||||
|
||||
@ -33,7 +33,7 @@ class SqlController extends AbstractController
|
||||
{
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']);
|
||||
$this->response->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']);
|
||||
|
||||
$this->pageSettings->init('Sql');
|
||||
$this->response->addHTML($this->pageSettings->getErrorHTML());
|
||||
|
||||
@ -35,7 +35,7 @@ class MonitorController extends AbstractController
|
||||
$this->dbi->selectDb('mysql');
|
||||
}
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'vendor/jquery/jquery.tablesorter.js',
|
||||
'jquery.sortable-table.js',
|
||||
'vendor/jqplot/jquery.jqplot.js',
|
||||
|
||||
@ -38,7 +38,7 @@ class ProcessesController extends AbstractController
|
||||
$this->dbi->selectDb('mysql');
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['server/status/processes.js']);
|
||||
$this->response->addScriptFiles(['server/status/processes.js']);
|
||||
|
||||
$listHtml = $this->template->render('server/status/processes/list', $this->processes->getList(
|
||||
$showExecuting,
|
||||
|
||||
@ -45,7 +45,7 @@ class QueriesController extends AbstractController
|
||||
$this->dbi->selectDb('mysql');
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['vendor/chart.umd.js', 'server/status/queries.js']);
|
||||
$this->response->addScriptFiles(['vendor/chart.umd.js', 'server/status/queries.js']);
|
||||
|
||||
$chart = [];
|
||||
if ($this->data->dataLoaded) {
|
||||
|
||||
@ -46,7 +46,7 @@ class VariablesController extends AbstractController
|
||||
$this->dbi->selectDb('mysql');
|
||||
}
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'server/status/variables.js',
|
||||
'vendor/jquery/jquery.tablesorter.js',
|
||||
]);
|
||||
|
||||
@ -38,7 +38,7 @@ class UserGroupsController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['server/user_groups.js']);
|
||||
$this->response->addScriptFiles(['server/user_groups.js']);
|
||||
|
||||
/**
|
||||
* Only allowed to superuser
|
||||
|
||||
@ -42,7 +42,7 @@ class VariablesController extends AbstractController
|
||||
|
||||
$filterValue = $request->getQueryParam('filter', '');
|
||||
|
||||
$this->addScriptFiles(['server/variables.js']);
|
||||
$this->response->addScriptFiles(['server/variables.js']);
|
||||
|
||||
$variables = [];
|
||||
$serverVarsResult = $this->dbi->tryQuery('SHOW SESSION VARIABLES;');
|
||||
|
||||
@ -58,7 +58,7 @@ class SqlController extends AbstractController
|
||||
$this->response->addHTML($this->pageSettings->getErrorHTML());
|
||||
$this->response->addHTML($this->pageSettings->getHTML());
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'vendor/jquery/jquery.uitablefilter.js',
|
||||
'table/change.js',
|
||||
'gis_data_editor.js',
|
||||
|
||||
@ -57,7 +57,7 @@ class AddFieldController extends AbstractController
|
||||
/** @var string|null $numberOfFields */
|
||||
$numberOfFields = $request->getParsedBodyParam('num_fields');
|
||||
|
||||
$this->addScriptFiles(['table/structure.js']);
|
||||
$this->response->addScriptFiles(['table/structure.js']);
|
||||
|
||||
if (! $this->checkParameters(['db', 'table'])) {
|
||||
return null;
|
||||
@ -187,7 +187,7 @@ class AddFieldController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
|
||||
|
||||
if (! $this->checkParameters(['server', 'db', 'table'])) {
|
||||
return null;
|
||||
|
||||
@ -155,7 +155,7 @@ class ChangeController extends AbstractController
|
||||
* START REGULAR OUTPUT
|
||||
*/
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'makegrid.js',
|
||||
'sql.js',
|
||||
'table/change.js',
|
||||
@ -263,7 +263,7 @@ class ChangeController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
$this->addScriptFiles($GLOBALS['plugin_scripts']);
|
||||
$this->response->addScriptFiles($GLOBALS['plugin_scripts']);
|
||||
|
||||
unset($GLOBALS['unsaved_values'], $GLOBALS['plugin_scripts']);
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ class ChartController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'chart.js',
|
||||
'table/chart.js',
|
||||
'vendor/jqplot/jquery.jqplot.js',
|
||||
|
||||
@ -146,7 +146,7 @@ class CreateController extends AbstractController
|
||||
// Do not display the table in the header since it hasn't been created yet
|
||||
$this->response->getHeader()->getMenu()->setTable('');
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
|
||||
|
||||
if (! $this->checkParameters(['server', 'db'])) {
|
||||
return null;
|
||||
|
||||
@ -48,7 +48,7 @@ class ExportController extends AbstractController
|
||||
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
|
||||
$pageSettingsHtml = $this->pageSettings->getHTML();
|
||||
|
||||
$this->addScriptFiles(['export.js']);
|
||||
$this->response->addScriptFiles(['export.js']);
|
||||
|
||||
if (! $this->checkParameters(['db', 'table'])) {
|
||||
return null;
|
||||
|
||||
@ -110,7 +110,7 @@ class FindReplaceController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['table/find_replace.js']);
|
||||
$this->response->addScriptFiles(['table/find_replace.js']);
|
||||
|
||||
if ($request->hasBodyParam('replace')) {
|
||||
$findString = (string) $request->getParsedBodyParam('findString');
|
||||
|
||||
@ -120,7 +120,7 @@ final class GisVisualizationController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['vendor/openlayers/OpenLayers.js', 'table/gis_visualization.js']);
|
||||
$this->response->addScriptFiles(['vendor/openlayers/OpenLayers.js', 'table/gis_visualization.js']);
|
||||
|
||||
// If all the rows contain SRID, use OpenStreetMaps on the initial loading.
|
||||
$useBaseLayer = isset($_POST['redraw']) ? isset($_POST['useBaseLayer']) : $visualization->hasSrid();
|
||||
|
||||
@ -52,7 +52,7 @@ final class ImportController extends AbstractController
|
||||
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
|
||||
$pageSettingsHtml = $this->pageSettings->getHTML();
|
||||
|
||||
$this->addScriptFiles(['import.js']);
|
||||
$this->response->addScriptFiles(['import.js']);
|
||||
|
||||
if (! $this->checkParameters(['db', 'table'])) {
|
||||
return null;
|
||||
|
||||
@ -54,7 +54,7 @@ class PrivilegesController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
$this->response->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
|
||||
/**
|
||||
* Checks if the user is allowed to do what they try to...
|
||||
|
||||
@ -88,7 +88,7 @@ final class RelationController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['table/relation.js']);
|
||||
$this->response->addScriptFiles(['table/relation.js']);
|
||||
|
||||
// Set the database
|
||||
$this->dbi->selectDb(Current::$database);
|
||||
|
||||
@ -72,7 +72,7 @@ final class ReplaceController extends AbstractController
|
||||
|
||||
$this->dbi->selectDb(Current::$database);
|
||||
|
||||
$this->addScriptFiles(['makegrid.js', 'sql.js', 'gis_data_editor.js']);
|
||||
$this->response->addScriptFiles(['makegrid.js', 'sql.js', 'gis_data_editor.js']);
|
||||
|
||||
$afterInsert = $request->getParsedBodyParam('after_insert');
|
||||
if (in_array($afterInsert, ['new_insert', 'same_insert', 'edit_next'], true)) {
|
||||
@ -366,7 +366,7 @@ final class ReplaceController extends AbstractController
|
||||
$GLOBALS['sql_query'] = $returnToSqlQuery;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/additional-methods.js', 'table/change.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/additional-methods.js', 'table/change.js']);
|
||||
|
||||
/**
|
||||
* If user asked for "and then Insert another new row" we have to remove
|
||||
|
||||
@ -198,7 +198,7 @@ class SearchController extends AbstractController
|
||||
|
||||
$this->loadTableInfo();
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'makegrid.js',
|
||||
'sql.js',
|
||||
'table/select.js',
|
||||
|
||||
@ -44,7 +44,7 @@ class SqlController extends AbstractController
|
||||
$GLOBALS['goto'] ??= null;
|
||||
$GLOBALS['back'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']);
|
||||
$this->response->addScriptFiles(['makegrid.js', 'vendor/jquery/jquery.uitablefilter.js', 'sql.js']);
|
||||
|
||||
$this->pageSettings->init('Sql');
|
||||
$this->response->addHTML($this->pageSettings->getErrorHTML());
|
||||
|
||||
@ -91,7 +91,7 @@ final class ChangeController extends AbstractController
|
||||
*/
|
||||
$userPrivileges = $this->userPrivilegesFactory->getPrivileges();
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
|
||||
|
||||
$templateData = $this->columnsDefinition->displayForm(
|
||||
$userPrivileges,
|
||||
|
||||
@ -57,7 +57,7 @@ final class PartitioningController extends AbstractController
|
||||
$this->response->addHTML($this->pageSettings->getErrorHTML());
|
||||
$this->response->addHTML($this->pageSettings->getHTML());
|
||||
|
||||
$this->addScriptFiles(['table/structure.js']);
|
||||
$this->response->addScriptFiles(['table/structure.js']);
|
||||
|
||||
$partitionDetails = null;
|
||||
if (! isset($_POST['partition_by'])) {
|
||||
|
||||
@ -74,7 +74,7 @@ class StructureController extends AbstractController
|
||||
$this->response->addHTML($this->pageSettings->getErrorHTML());
|
||||
$this->response->addHTML($this->pageSettings->getHTML());
|
||||
|
||||
$this->addScriptFiles(['table/structure.js']);
|
||||
$this->response->addScriptFiles(['table/structure.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ final class TrackingController extends AbstractController
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'table/tracking.js']);
|
||||
$this->response->addScriptFiles(['vendor/jquery/jquery.tablesorter.js', 'table/tracking.js']);
|
||||
|
||||
if (! $this->checkParameters(['db', 'table'])) {
|
||||
return null;
|
||||
@ -153,7 +153,7 @@ final class TrackingController extends AbstractController
|
||||
$this->tracking->exportAsSqlExecution($entries);
|
||||
$message = Message::success(__('SQL statements executed.'))->getDisplay();
|
||||
} elseif ($reportExportType === 'sqldump') {
|
||||
$this->addScriptFiles(['sql.js']);
|
||||
$this->response->addScriptFiles(['sql.js']);
|
||||
$sqlDump = $this->tracking->exportAsSqlDump($entries);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class ZoomSearchController extends AbstractController
|
||||
|
||||
$this->loadTableInfo();
|
||||
|
||||
$this->addScriptFiles([
|
||||
$this->response->addScriptFiles([
|
||||
'makegrid.js',
|
||||
'sql.js',
|
||||
'vendor/jqplot/jquery.jqplot.js',
|
||||
|
||||
@ -51,7 +51,7 @@ final class IndexController extends AbstractController
|
||||
$GLOBALS['urlParams'] ??= null;
|
||||
$GLOBALS['errorUrl'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['triggers.js', 'sql.js']);
|
||||
$this->response->addScriptFiles(['triggers.js', 'sql.js']);
|
||||
|
||||
if (! $request->isAjax()) {
|
||||
$config = Config::getInstance();
|
||||
|
||||
@ -36,7 +36,7 @@ class UserPasswordController extends AbstractController
|
||||
$GLOBALS['username'] ??= null;
|
||||
$GLOBALS['change_password_message'] ??= null;
|
||||
|
||||
$this->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
$this->response->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
|
||||
$config = Config::getInstance();
|
||||
/**
|
||||
|
||||
@ -190,7 +190,7 @@ class CreateController extends AbstractController
|
||||
$GLOBALS['urlParams']['db'] = Current::$database;
|
||||
$GLOBALS['urlParams']['reload'] = 1;
|
||||
|
||||
$this->addScriptFiles(['sql.js']);
|
||||
$this->response->addScriptFiles(['sql.js']);
|
||||
|
||||
$this->render('view_create', [
|
||||
'ajax_dialog' => $ajaxdialog,
|
||||
|
||||
@ -446,4 +446,10 @@ class ResponseRenderer
|
||||
$this->addHeader('Location', $url);
|
||||
$this->setStatusCode($statusCode);
|
||||
}
|
||||
|
||||
/** @psalm-param list<string> $files */
|
||||
public function addScriptFiles(array $files): void
|
||||
{
|
||||
$this->getHeader()->getScripts()->addFiles($files);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,11 +8,14 @@ use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Footer;
|
||||
use PhpMyAdmin\Header;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Scripts;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function array_column;
|
||||
|
||||
#[CoversClass(ResponseRenderer::class)]
|
||||
class ResponseRendererTest extends AbstractTestCase
|
||||
{
|
||||
@ -30,6 +33,7 @@ class ResponseRendererTest extends AbstractTestCase
|
||||
public function testSetAjax(): void
|
||||
{
|
||||
$_REQUEST = [];
|
||||
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
|
||||
$response = ResponseRenderer::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$footer = (new ReflectionProperty(ResponseRenderer::class, 'footer'))->getValue($response);
|
||||
@ -50,5 +54,25 @@ class ResponseRendererTest extends AbstractTestCase
|
||||
self::assertFalse($response->isAjax());
|
||||
self::assertFalse($headerIsAjax->getValue($header));
|
||||
self::assertFalse($footerIsAjax->getValue($footer));
|
||||
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
|
||||
}
|
||||
|
||||
public function testAddScriptFiles(): void
|
||||
{
|
||||
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
|
||||
$response = ResponseRenderer::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$headerScripts = (new ReflectionProperty(Header::class, 'scripts'))->getValue($header);
|
||||
self::assertInstanceOf(Scripts::class, $headerScripts);
|
||||
$files = array_column($headerScripts->getFiles(), 'name');
|
||||
self::assertNotContains('server/privileges.js', $files);
|
||||
self::assertNotContains('vendor/zxcvbn-ts.js', $files);
|
||||
|
||||
$response->addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']);
|
||||
|
||||
$files = array_column($headerScripts->getFiles(), 'name');
|
||||
self::assertContains('server/privileges.js', $files);
|
||||
self::assertContains('vendor/zxcvbn-ts.js', $files);
|
||||
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user