diff options
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Controllers/Table')
8 files changed, 0 insertions, 4064 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Table/AbstractController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Table/AbstractController.php deleted file mode 100644 index 35f01ac..0000000 --- a/srcs/phpmyadmin/libraries/classes/Controllers/Table/AbstractController.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Holds the PhpMyAdmin\Controllers\Table\AbstractController - * - * @package PhpMyAdmin\Controllers - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Controllers\Table; - -use PhpMyAdmin\Controllers\AbstractController as Controller; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Response; -use PhpMyAdmin\Template; - -/** - * Handles table related logic - * - * @package PhpMyAdmin\Controllers - */ -abstract class AbstractController extends Controller -{ - /** - * @var string - */ - protected $db; - - /** - * @var string - */ - protected $table; - - /** - * Constructor - * - * @param Response $response Response object - * @param DatabaseInterface $dbi DatabaseInterface object - * @param Template $template Template object - * @param string $db Database name - * @param string $table Table name - */ - public function __construct( - $response, - $dbi, - Template $template, - $db, - $table - ) { - parent::__construct($response, $dbi, $template); - $this->db = $db; - $this->table = $table; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Table/ChartController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Table/ChartController.php deleted file mode 100644 index b2c4176..0000000 --- a/srcs/phpmyadmin/libraries/classes/Controllers/Table/ChartController.php +++ /dev/null @@ -1,261 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Holds the PhpMyAdmin\Controllers\Table\ChartController - * - * @package PhpMyAdmin\Controllers - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Controllers\Table; - -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Message; -use PhpMyAdmin\Response; -use PhpMyAdmin\SqlParser\Components\Limit; -use PhpMyAdmin\SqlParser\Parser; -use PhpMyAdmin\SqlParser\Statements\SelectStatement; -use PhpMyAdmin\Template; -use PhpMyAdmin\Util; - -/** - * Handles table related logic - * - * @package PhpMyAdmin\Controllers - */ -class ChartController extends AbstractController -{ - /** - * @var string - */ - protected $sql_query; - - /** - * @var string - */ - protected $url_query; - - /** - * @var array - */ - protected $cfg; - - /** - * Constructor - * - * @param Response $response Response object - * @param DatabaseInterface $dbi DatabaseInterface object - * @param Template $template Template object - * @param string $db Database name - * @param string $table Table name - * @param string $sql_query Query - * @param string $url_query Query URL - * @param array $cfg Configuration - */ - public function __construct( - $response, - $dbi, - Template $template, - $db, - $table, - $sql_query, - $url_query, - array $cfg - ) { - parent::__construct($response, $dbi, $template, $db, $table); - - $this->sql_query = $sql_query; - $this->url_query = $url_query; - $this->cfg = $cfg; - } - - /** - * Execute the query and return the result - * - * @return void - */ - public function indexAction() - { - $response = Response::getInstance(); - if ($response->isAjax() - && isset($_REQUEST['pos']) - && isset($_REQUEST['session_max_rows']) - ) { - $this->ajaxAction(); - return; - } - - // Throw error if no sql query is set - if (! isset($this->sql_query) || $this->sql_query == '') { - $this->response->setRequestStatus(false); - $this->response->addHTML( - Message::error(__('No SQL query was set to fetch data.')) - ); - return; - } - - $this->response->getHeader()->getScripts()->addFiles( - [ - 'chart.js', - 'table/chart.js', - 'vendor/jqplot/jquery.jqplot.js', - 'vendor/jqplot/plugins/jqplot.barRenderer.js', - 'vendor/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js', - 'vendor/jqplot/plugins/jqplot.canvasTextRenderer.js', - 'vendor/jqplot/plugins/jqplot.categoryAxisRenderer.js', - 'vendor/jqplot/plugins/jqplot.dateAxisRenderer.js', - 'vendor/jqplot/plugins/jqplot.pointLabels.js', - 'vendor/jqplot/plugins/jqplot.pieRenderer.js', - 'vendor/jqplot/plugins/jqplot.enhancedPieLegendRenderer.js', - 'vendor/jqplot/plugins/jqplot.highlighter.js', - ] - ); - - /** - * Extract values for common work - * @todo Extract common files - */ - $db = &$this->db; - $table = &$this->table; - $url_params = []; - - /** - * Runs common work - */ - if (strlen($this->table) > 0) { - $url_params['goto'] = Util::getScriptNameForOption( - $this->cfg['DefaultTabTable'], - 'table' - ); - $url_params['back'] = 'tbl_sql.php'; - include ROOT_PATH . 'libraries/tbl_common.inc.php'; - $this->dbi->selectDb($GLOBALS['db']); - } elseif (strlen($this->db) > 0) { - $url_params['goto'] = Util::getScriptNameForOption( - $this->cfg['DefaultTabDatabase'], - 'database' - ); - $url_params['back'] = 'sql.php'; - include ROOT_PATH . 'libraries/db_common.inc.php'; - } else { - $url_params['goto'] = Util::getScriptNameForOption( - $this->cfg['DefaultTabServer'], - 'server' - ); - $url_params['back'] = 'sql.php'; - include ROOT_PATH . 'libraries/server_common.inc.php'; - } - - $data = []; - - $result = $this->dbi->tryQuery($this->sql_query); - $fields_meta = $this->dbi->getFieldsMeta($result); - while ($row = $this->dbi->fetchAssoc($result)) { - $data[] = $row; - } - - $keys = array_keys($data[0]); - - $numeric_types = [ - 'int', - 'real', - ]; - $numeric_column_count = 0; - foreach ($keys as $idx => $key) { - if (in_array($fields_meta[$idx]->type, $numeric_types)) { - $numeric_column_count++; - } - } - - if ($numeric_column_count == 0) { - $this->response->setRequestStatus(false); - $this->response->addJSON( - 'message', - __('No numeric columns present in the table to plot.') - ); - return; - } - - $url_params['db'] = $this->db; - $url_params['reload'] = 1; - - /** - * Displays the page - */ - $this->response->addHTML( - $this->template->render('table/chart/tbl_chart', [ - 'url_query' => $this->url_query, - 'url_params' => $url_params, - 'keys' => $keys, - 'fields_meta' => $fields_meta, - 'numeric_types' => $numeric_types, - 'numeric_column_count' => $numeric_column_count, - 'sql_query' => $this->sql_query, - ]) - ); - } - - /** - * Handle ajax request - * - * @return void - */ - public function ajaxAction() - { - /** - * Extract values for common work - * @todo Extract common files - */ - $db = &$this->db; - $table = &$this->table; - - if (strlen($this->table) > 0 && strlen($this->db) > 0) { - include ROOT_PATH . 'libraries/tbl_common.inc.php'; - } - - $parser = new Parser($this->sql_query); - /** - * @var SelectStatement $statement - */ - $statement = $parser->statements[0]; - if (empty($statement->limit)) { - $statement->limit = new Limit( - $_REQUEST['session_max_rows'], - $_REQUEST['pos'] - ); - } else { - $start = $statement->limit->offset + $_REQUEST['pos']; - $rows = min( - $_REQUEST['session_max_rows'], - $statement->limit->rowCount - $_REQUEST['pos'] - ); - $statement->limit = new Limit($rows, $start); - } - $sql_with_limit = $statement->build(); - - $data = []; - $result = $this->dbi->tryQuery($sql_with_limit); - while ($row = $this->dbi->fetchAssoc($result)) { - $data[] = $row; - } - - if (empty($data)) { - $this->response->setRequestStatus(false); - $this->response->addJSON('message', __('No data to display')); - return; - } - $sanitized_data = []; - - foreach ($data as $data_row_number => $data_row) { - $tmp_row = []; - foreach ($data_row as $data_column => $data_value) { - $escaped_value = $data_value === null ? null : htmlspecialchars($data_value); - $tmp_row[htmlspecialchars($data_column)] = $escaped_value; - } - $sanitized_data[] = $tmp_row; - } - $this->response->setRequestStatus(true); - $this->response->addJSON('message', null); - $this->response->addJSON('chartData', json_encode($sanitized_data)); - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Table/GisVisualizationController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Table/GisVisualizationController.php deleted file mode 100644 index 18e844f..0000000 --- a/srcs/phpmyadmin/libraries/classes/Controllers/Table/GisVisualizationController.php +++ /dev/null @@ -1,227 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Holds the PhpMyAdmin\Controllers\Table\GisVisualizationController - * - * @package PhpMyAdmin\Controllers - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Controllers\Table; - -use PhpMyAdmin\Core; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Gis\GisVisualization; -use PhpMyAdmin\Message; -use PhpMyAdmin\Response; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; - -/** - * Class GisVisualizationController - * - * @package PhpMyAdmin\Controllers - */ -class GisVisualizationController extends AbstractController -{ - /** - * @var array - */ - protected $url_params; - - /** - * @var string - */ - protected $sql_query; - - /** - * @var array - */ - protected $visualizationSettings; - - /** - * @var GisVisualization - */ - protected $visualization; - - /** - * Constructor - * - * @param Response $response Response object - * @param DatabaseInterface $dbi DatabaseInterface object - * @param Template $template Template object - * @param string $db Database name - * @param string $table Table name - * @param string $sql_query SQL query for retrieving GIS data - * @param array $url_params array of URL parameters - * @param string $goto goto script - * @param string $back back script - * @param array $visualizationSettings visualization settings - */ - public function __construct( - $response, - $dbi, - Template $template, - $db, - $table, - $sql_query, - array $url_params, - $goto, - $back, - array $visualizationSettings - ) { - parent::__construct($response, $dbi, $template, $db, $table); - - require_once ROOT_PATH . 'libraries/common.inc.php'; - require_once ROOT_PATH . 'libraries/db_common.inc.php'; - - $this->sql_query = $sql_query; - $this->url_params = $url_params; - $this->url_params['goto'] = $goto; - $this->url_params['back'] = $back; - $this->visualizationSettings = $visualizationSettings; - } - - /** - * Save to file - * - * @return void - */ - public function saveToFileAction() - { - $this->response->disable(); - $file_name = $this->visualizationSettings['spatialColumn']; - $save_format = $_GET['fileFormat']; - $this->visualization->toFile($file_name, $save_format); - } - - /** - * Index - * - * @return void - */ - public function indexAction() - { - // Throw error if no sql query is set - if (! isset($this->sql_query) || $this->sql_query == '') { - $this->response->setRequestStatus(false); - $this->response->addHTML( - Message::error(__('No SQL query was set to fetch data.')) - ); - return; - } - - // Execute the query and return the result - $result = $this->dbi->tryQuery($this->sql_query); - // Get the meta data of results - $meta = $this->dbi->getFieldsMeta($result); - - // Find the candidate fields for label column and spatial column - $labelCandidates = []; - $spatialCandidates = []; - foreach ($meta as $column_meta) { - if ($column_meta->type == 'geometry') { - $spatialCandidates[] = $column_meta->name; - } else { - $labelCandidates[] = $column_meta->name; - } - } - - // Get settings if any posted - if (Core::isValid($_POST['visualizationSettings'], 'array')) { - $this->visualizationSettings = $_POST['visualizationSettings']; - } - - // Check mysql version - $this->visualizationSettings['mysqlVersion'] = $this->dbi->getVersion(); - - if (! isset($this->visualizationSettings['labelColumn']) - && isset($labelCandidates[0]) - ) { - $this->visualizationSettings['labelColumn'] = ''; - } - - // If spatial column is not set, use first geometric column as spatial column - if (! isset($this->visualizationSettings['spatialColumn'])) { - $this->visualizationSettings['spatialColumn'] = $spatialCandidates[0]; - } - - // Convert geometric columns from bytes to text. - $pos = isset($_GET['pos']) ? $_GET['pos'] - : $_SESSION['tmpval']['pos']; - if (isset($_GET['session_max_rows'])) { - $rows = $_GET['session_max_rows']; - } else { - if ($_SESSION['tmpval']['max_rows'] != 'all') { - $rows = $_SESSION['tmpval']['max_rows']; - } else { - $rows = $GLOBALS['cfg']['MaxRows']; - } - } - $this->visualization = GisVisualization::get( - $this->sql_query, - $this->visualizationSettings, - $rows, - $pos - ); - - if (isset($_GET['saveToFile'])) { - $this->saveToFileAction(); - return; - } - - $this->response->getHeader()->getScripts()->addFiles( - [ - 'vendor/openlayers/OpenLayers.js', - 'vendor/jquery/jquery.svg.js', - 'table/gis_visualization.js', - ] - ); - - // If all the rows contain SRID, use OpenStreetMaps on the initial loading. - if (! isset($_POST['displayVisualization'])) { - if ($this->visualization->hasSrid()) { - $this->visualizationSettings['choice'] = 'useBaseLayer'; - } else { - unset($this->visualizationSettings['choice']); - } - } - - $this->visualization->setUserSpecifiedSettings($this->visualizationSettings); - if ($this->visualizationSettings != null) { - foreach ($this->visualization->getSettings() as $setting => $val) { - if (! isset($this->visualizationSettings[$setting])) { - $this->visualizationSettings[$setting] = $val; - } - } - } - - /** - * Displays the page - */ - $this->url_params['sql_query'] = $this->sql_query; - $downloadUrl = 'tbl_gis_visualization.php' . Url::getCommon( - array_merge( - $this->url_params, - [ - 'saveToFile' => true, - 'session_max_rows' => $rows, - 'pos' => $pos, - ] - ) - ); - $html = $this->template->render('table/gis_visualization/gis_visualization', [ - 'url_params' => $this->url_params, - 'download_url' => $downloadUrl, - 'label_candidates' => $labelCandidates, - 'spatial_candidates' => $spatialCandidates, - 'visualization_settings' => $this->visualizationSettings, - 'sql_query' => $this->sql_query, - 'visualization' => $this->visualization->toImage('svg'), - 'draw_ol' => $this->visualization->asOl(), - 'pma_theme_image' => $GLOBALS['pmaThemeImage'], - ]); - - $this->response->addHTML($html); - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Table/IndexesController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Table/IndexesController.php deleted file mode 100644 index cdbfbb9..0000000 --- a/srcs/phpmyadmin/libraries/classes/Controllers/Table/IndexesController.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Holds the PhpMyAdmin\Controllers\Table\IndexesController - * - * @package PhpMyAdmin\Controllers - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Controllers\Table; - -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Index; -use PhpMyAdmin\Message; -use PhpMyAdmin\Response; -use PhpMyAdmin\Template; -use PhpMyAdmin\Util; - -/** - * Class IndexesController - * - * @package PhpMyAdmin\Controllers - */ -class IndexesController extends AbstractController -{ - /** - * @var Index - */ - protected $index; - - /** - * Constructor - * - * @param Response $response Response object - * @param DatabaseInterface $dbi DatabaseInterface object - * @param Template $template Template object - * @param string $db Database name - * @param string $table Table name - * @param Index $index Index object - */ - public function __construct( - $response, - $dbi, - Template $template, - $db, - $table, - $index - ) { - parent::__construct($response, $dbi, $template, $db, $table); - - $this->index = $index; - } - - /** - * Index - * - * @return void - */ - public function indexAction() - { - if (isset($_POST['do_save_data'])) { - $this->doSaveDataAction(); - return; - } // end builds the new index - - $this->displayFormAction(); - } - - /** - * Display the form to edit/create an index - * - * @return void - */ - public function displayFormAction() - { - $this->dbi->selectDb($GLOBALS['db']); - $add_fields = 0; - if (isset($_POST['index']) && is_array($_POST['index'])) { - // coming already from form - if (isset($_POST['index']['columns']['names'])) { - $add_fields = count($_POST['index']['columns']['names']) - - $this->index->getColumnCount(); - } - if (isset($_POST['add_fields'])) { - $add_fields += $_POST['added_fields']; - } - } elseif (isset($_POST['create_index'])) { - $add_fields = $_POST['added_fields']; - } // end preparing form values - - // Get fields and stores their name/type - if (isset($_POST['create_edit_table'])) { - $fields = json_decode($_POST['columns'], true); - $index_params = [ - 'Non_unique' => $_POST['index']['Index_choice'] == 'UNIQUE' - ? '0' : '1', - ]; - $this->index->set($index_params); - $add_fields = count($fields); - } else { - $fields = $this->dbi->getTable($this->db, $this->table) - ->getNameAndTypeOfTheColumns(); - } - - $form_params = [ - 'db' => $this->db, - 'table' => $this->table, - ]; - - if (isset($_POST['create_index'])) { - $form_params['create_index'] = 1; - } elseif (isset($_POST['old_index'])) { - $form_params['old_index'] = $_POST['old_index']; - } elseif (isset($_POST['index'])) { - $form_params['old_index'] = $_POST['index']; - } - - $this->response->getHeader()->getScripts()->addFile('indexes.js'); - - $this->response->addHTML( - $this->template->render('table/index_form', [ - 'fields' => $fields, - 'index' => $this->index, - 'form_params' => $form_params, - 'add_fields' => $add_fields, - 'create_edit_table' => isset($_POST['create_edit_table']), - 'default_sliders_state' => $GLOBALS['cfg']['InitialSlidersState'], - ]) - ); - } - - /** - * Process the data from the edit/create index form, - * run the query to build the new index - * and moves back to "tbl_sql.php" - * - * @return void - */ - public function doSaveDataAction() - { - $error = false; - - $sql_query = $this->dbi->getTable($this->db, $this->table) - ->getSqlQueryForIndexCreateOrEdit($this->index, $error); - - // If there is a request for SQL previewing. - if (isset($_POST['preview_sql'])) { - $this->response->addJSON( - 'sql_data', - $this->template->render('preview_sql', ['query_data' => $sql_query]) - ); - } elseif (! $error) { - $this->dbi->query($sql_query); - $response = Response::getInstance(); - if ($response->isAjax()) { - $message = Message::success( - __('Table %1$s has been altered successfully.') - ); - $message->addParam($this->table); - $this->response->addJSON( - 'message', - Util::getMessage($message, $sql_query, 'success') - ); - $this->response->addJSON( - 'index_table', - Index::getHtmlForIndexes( - $this->table, - $this->db - ) - ); - } else { - include ROOT_PATH . 'tbl_structure.php'; - } - } else { - $this->response->setRequestStatus(false); - $this->response->addJSON('message', $error); - } - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Table/RelationController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Table/RelationController.php deleted file mode 100644 index 558842c..0000000 --- a/srcs/phpmyadmin/libraries/classes/Controllers/Table/RelationController.php +++ /dev/null @@ -1,398 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Holds the PhpMyAdmin\Controllers\Table\RelationController - * - * @package PhpMyAdmin\Controllers - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Controllers\Table; - -use PhpMyAdmin\Core; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Index; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Response; -use PhpMyAdmin\Table; -use PhpMyAdmin\Template; -use PhpMyAdmin\Util; - -/** - * Handles table relation logic - * - * @package PhpMyAdmin\Controllers - */ -class RelationController extends AbstractController -{ - /** - * @var array - */ - protected $options_array; - - /** - * @var array - */ - protected $cfgRelation; - - /** - * @var array - */ - protected $existrel; - - /** - * @var string - */ - protected $tbl_storage_engine; - - /** - * @var array - */ - protected $existrel_foreign; - - /** - * @var Table - */ - protected $upd_query; - - /** - * @var Relation - */ - private $relation; - - /** - * Constructor - * - * @param Response $response Response object - * @param DatabaseInterface $dbi DatabaseInterface object - * @param Template $template Template object - * @param string $db Database name - * @param string $table Table name - * @param array|null $options_array Options - * @param array|null $cfgRelation Config relation - * @param string $tbl_storage_engine Table storage engine - * @param array|null $existrel Relations - * @param array|null $existrel_foreign External relations - * @param Table $upd_query Update query - * @param Relation $relation Relation instance - */ - public function __construct( - $response, - $dbi, - Template $template, - $db, - $table, - $options_array, - $cfgRelation, - $tbl_storage_engine, - $existrel, - $existrel_foreign, - $upd_query, - Relation $relation - ) { - parent::__construct($response, $dbi, $template, $db, $table); - - $this->options_array = $options_array; - $this->cfgRelation = $cfgRelation; - $this->tbl_storage_engine = $tbl_storage_engine; - $this->existrel = $existrel; - $this->existrel_foreign = $existrel_foreign; - $this->upd_query = $upd_query; - $this->relation = $relation; - } - - /** - * Index - * - * @return void - */ - public function indexAction() - { - // Send table of column names to populate corresponding dropdowns depending - // on the current selection - if (isset($_POST['getDropdownValues']) - && $_POST['getDropdownValues'] === 'true' - ) { - // if both db and table are selected - if (isset($_POST['foreignTable'])) { - $this->getDropdownValueForTableAction(); - } else { // if only the db is selected - $this->getDropdownValueForDbAction(); - } - return; - } - - $this->response->getHeader()->getScripts()->addFiles( - [ - 'table/relation.js', - 'indexes.js', - ] - ); - - // Set the database - $this->dbi->selectDb($this->db); - - // updates for Internal relations - if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) { - $this->updateForInternalRelationAction(); - } - - // updates for foreign keys - $this->updateForForeignKeysAction(); - - // Updates for display field - if ($this->cfgRelation['displaywork'] && isset($_POST['display_field'])) { - $this->updateForDisplayField(); - } - - // If we did an update, refresh our data - if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) { - $this->existrel = $this->relation->getForeigners( - $this->db, - $this->table, - '', - 'internal' - ); - } - if (isset($_POST['destination_foreign_db']) - && Util::isForeignKeySupported($this->tbl_storage_engine) - ) { - $this->existrel_foreign = $this->relation->getForeigners( - $this->db, - $this->table, - '', - 'foreign' - ); - } - - /** - * Dialog - */ - // Now find out the columns of our $table - // need to use DatabaseInterface::QUERY_STORE with $this->dbi->numRows() - // in mysqli - $columns = $this->dbi->getColumns($this->db, $this->table); - - $column_array = []; - $column_hash_array = []; - $column_array[''] = ''; - foreach ($columns as $column) { - if (strtoupper($this->tbl_storage_engine) == 'INNODB' - || ! empty($column['Key']) - ) { - $column_array[$column['Field']] = $column['Field']; - $column_hash_array[$column['Field']] = md5($column['Field']); - } - } - if ($GLOBALS['cfg']['NaturalOrder']) { - uksort($column_array, 'strnatcasecmp'); - } - - // common form - $engine = $this->dbi->getTable($this->db, $this->table)->getStorageEngine(); - $foreignKeySupported = Util::isForeignKeySupported($this->tbl_storage_engine); - $this->response->addHTML( - $this->template->render('table/relation/common_form', [ - 'is_foreign_key_supported' => Util::isForeignKeySupported($engine), - 'db' => $this->db, - 'table' => $this->table, - 'cfg_relation' => $this->cfgRelation, - 'tbl_storage_engine' => $this->tbl_storage_engine, - 'existrel' => isset($this->existrel) ? $this->existrel : [], - 'existrel_foreign' => is_array($this->existrel_foreign) && array_key_exists('foreign_keys_data', $this->existrel_foreign) - ? $this->existrel_foreign['foreign_keys_data'] : [], - 'options_array' => $this->options_array, - 'column_array' => $column_array, - 'column_hash_array' => $column_hash_array, - 'save_row' => array_values($columns), - 'url_params' => $GLOBALS['url_params'], - 'databases' => $GLOBALS['dblist']->databases, - 'dbi' => $this->dbi, - 'default_sliders_state' => $GLOBALS['cfg']['InitialSlidersState'], - 'foreignKeySupported' => $foreignKeySupported, - 'displayIndexesHtml' => $foreignKeySupported ? Index::getHtmlForDisplayIndexes() : null, - ]) - ); - } - - /** - * Update for display field - * - * @return void - */ - public function updateForDisplayField() - { - if ($this->upd_query->updateDisplayField( - $_POST['display_field'], - $this->cfgRelation - ) - ) { - $this->response->addHTML( - Util::getMessage( - __('Display column was successfully updated.'), - '', - 'success' - ) - ); - } - } - - /** - * Update for FK - * - * @return void - */ - public function updateForForeignKeysAction() - { - $multi_edit_columns_name = isset($_POST['foreign_key_fields_name']) - ? $_POST['foreign_key_fields_name'] - : null; - $preview_sql_data = ''; - $seen_error = false; - - // (for now, one index name only; we keep the definitions if the - // foreign db is not the same) - if (isset($_POST['destination_foreign_db']) - && isset($_POST['destination_foreign_table']) - && isset($_POST['destination_foreign_column'])) { - list($html, $preview_sql_data, $display_query, $seen_error) - = $this->upd_query->updateForeignKeys( - $_POST['destination_foreign_db'], - $multi_edit_columns_name, - $_POST['destination_foreign_table'], - $_POST['destination_foreign_column'], - $this->options_array, - $this->table, - is_array($this->existrel_foreign) && array_key_exists('foreign_keys_data', $this->existrel_foreign) - ? $this->existrel_foreign['foreign_keys_data'] : [] - ); - $this->response->addHTML($html); - } - - // If there is a request for SQL previewing. - if (isset($_POST['preview_sql'])) { - Core::previewSQL($preview_sql_data); - } - - if (! empty($display_query) && ! $seen_e |
