diff --git a/db_designer.php b/db_designer.php
index 0dc2c022fb..dcc86b8c85 100644
--- a/db_designer.php
+++ b/db_designer.php
@@ -34,33 +34,26 @@ $designerCommon = $containerBuilder->get('designer_common');
if (isset($_POST['dialog'])) {
if ($_POST['dialog'] == 'edit') {
- $html = $databaseDesigner->getHtmlForEditOrDeletePages($db, 'editPage');
+ $html = $databaseDesigner->getHtmlForEditOrDeletePages($_POST['db'], 'editPage');
} elseif ($_POST['dialog'] == 'delete') {
- $html = $databaseDesigner->getHtmlForEditOrDeletePages($db, 'deletePage');
+ $html = $databaseDesigner->getHtmlForEditOrDeletePages($_POST['db'], 'deletePage');
} elseif ($_POST['dialog'] == 'save_as') {
- $html = $databaseDesigner->getHtmlForPageSaveAs($db);
+ $html = $databaseDesigner->getHtmlForPageSaveAs($_POST['db']);
} elseif ($_POST['dialog'] == 'export') {
$html = $databaseDesigner->getHtmlForSchemaExport(
- $db,
+ $_POST['db'],
$_POST['selected_page']
);
} elseif ($_POST['dialog'] == 'add_table') {
- $script_display_field = $designerCommon->getTablesInfo();
- $required = $db . '.' . $GLOBALS['table'];
- $tab_column = $designerCommon->getColumnsInfo();
- $tables_all_keys = $designerCommon->getAllKeys();
- $tables_pk_or_unique_keys = $designerCommon->getPkOrUniqueKeys();
-
- $req_key = array_search($required, $GLOBALS['designer']['TABLE_NAME']);
-
- $GLOBALS['designer']['TABLE_NAME'] = [$GLOBALS['designer']['TABLE_NAME'][$req_key]];
- $GLOBALS['designer_url']['TABLE_NAME_SMALL'] = [$GLOBALS['designer_url']['TABLE_NAME_SMALL'][$req_key]];
- $GLOBALS['designer']['TABLE_NAME_SMALL'] = [$GLOBALS['designer']['TABLE_NAME_SMALL'][$req_key]];
- $GLOBALS['designer_out']['TABLE_NAME_SMALL'] = [$GLOBALS['designer_out']['TABLE_NAME_SMALL'][$req_key]];
- $GLOBALS['designer']['TABLE_TYPE'] = [$GLOBALS['designer_url']['TABLE_TYPE'][$req_key]];
- $GLOBALS['designer_out']['OWNER'] = [$GLOBALS['designer_out']['OWNER'][$req_key]];
+ // Pass the db and table to the getTablesInfo so we only have the table we asked for
+ $script_display_field = $designerCommon->getTablesInfo($_POST['db'], $_POST['table']);
+ $tab_column = $designerCommon->getColumnsInfo($script_display_field);
+ $tables_all_keys = $designerCommon->getAllKeys($script_display_field);
+ $tables_pk_or_unique_keys = $designerCommon->getPkOrUniqueKeys($script_display_field);
$html = $databaseDesigner->getDatabaseTables(
+ $_POST['db'],
+ $script_display_field,
[],
-1,
$tab_column,
@@ -83,7 +76,7 @@ if (isset($_POST['operation'])) {
if ($_POST['save_page'] == 'same') {
$page = $_POST['selected_page'];
} else { // new
- $page = $designerCommon->createNewPage($_POST['selected_value'], $db);
+ $page = $designerCommon->createNewPage($_POST['selected_value'], $_POST['db']);
$response->addJSON('id', $page);
}
$success = $designerCommon->saveTablePositions($page);
@@ -129,11 +122,6 @@ if (isset($_POST['operation'])) {
require ROOT_PATH . 'libraries/db_common.inc.php';
$script_display_field = $designerCommon->getTablesInfo();
-$tab_column = $designerCommon->getColumnsInfo();
-$script_tables = $designerCommon->getScriptTabs();
-$tables_pk_or_unique_keys = $designerCommon->getPkOrUniqueKeys();
-$tables_all_keys = $designerCommon->getAllKeys();
-$classes_side_menu = $databaseDesigner->returnClassNamesFromMenuButtons();
$display_page = -1;
$selected_page = null;
@@ -149,7 +137,30 @@ if ($display_page != -1) {
$selected_page = $designerCommon->getPageName($display_page);
}
$tab_pos = $designerCommon->getTablePositions($display_page);
-$script_contr = $designerCommon->getScriptContr();
+
+$fullTableNames = [];
+
+foreach ($script_display_field as $designerTable) {
+ $fullTableNames[] = $designerTable->getDbTableString();
+}
+
+foreach ($tab_pos as $position) {
+ if (! in_array($position['dbName'] . '.' . $position['tableName'], $fullTableNames)) {
+ foreach ($designerCommon->getTablesInfo($position['dbName'], $position['tableName']) as $designerTable) {
+ $script_display_field[] = $designerTable;
+ }
+ }
+}
+
+
+$tab_column = $designerCommon->getColumnsInfo($script_display_field);
+$script_tables = $designerCommon->getScriptTabs($script_display_field);
+$tables_pk_or_unique_keys = $designerCommon->getPkOrUniqueKeys($script_display_field);
+$tables_all_keys = $designerCommon->getAllKeys($script_display_field);
+$classes_side_menu = $databaseDesigner->returnClassNamesFromMenuButtons();
+
+
+$script_contr = $designerCommon->getScriptContr($script_display_field);
$params = ['lang' => $GLOBALS['lang']];
if (isset($_GET['db'])) {
@@ -188,6 +199,7 @@ $response->addHTML(
$databaseDesigner->getHtmlForMain(
$db,
$_GET['db'],
+ $script_display_field,
$script_tables,
$script_contr,
$script_display_field,
diff --git a/js/designer/move.js b/js/designer/move.js
index 0fbb0a5c9b..533c2e41e1 100644
--- a/js/designer/move.js
+++ b/js/designer/move.js
@@ -7,6 +7,7 @@
/* global DesignerHistory, historyArray, selectField */ // js/designer/history.js
/* global contr, db, designerTablesEnabled, displayField, hTabs, jTabs, selectedPage:writable, server */ // js/designer/init.js
/* global DesignerPage */ // js/designer/page.js
+/* global pmaThemeImage */ // js/messages.php
var DesignerMove = {};
@@ -524,11 +525,65 @@ DesignerMove.toggleFullscreen = function () {
DesignerMove.saveValueInConfig('full_screen', valueSent);
};
+DesignerMove.addTableToTablesList = function (index, tableDom) {
+ var db = $(tableDom).find('.small_tab_pref').attr('db');
+ var table = $(tableDom).find('.small_tab_pref').attr('table_name');
+ var dbEncoded = $(tableDom).find('.small_tab_pref').attr('db_url');
+ var tableEncoded = $(tableDom).find('.small_tab_pref').attr('table_name_url');
+ var $newTableLine = $('
' +
+ ' ' +
+ ' ' +
+ ' | ' +
+ ' ' +
+ ' ' +
+ ' | ' +
+ ' ' + db + '.' + table + ' | ' +
+ '
');
+ $('#id_scroll_tab table').first().append($newTableLine);
+ $($newTableLine).find('.scroll_tab_struct').click(function () {
+ DesignerMove.startTabUpd(db, table);
+ });
+ $($newTableLine).on('click', '.designer_Tabs2,.designer_Tabs', function () {
+ DesignerMove.selectTab($(this).attr('designer_url_table_name'));
+ });
+ $($newTableLine).find('.scroll_tab_checkbox').click(function () {
+ DesignerMove.visibleTab(this,$(this).val());
+ });
+ var $tablesCounter = $('#tables_counter');
+ $tablesCounter.text(parseInt($tablesCounter.text(), 10) + 1);
+};
+
DesignerMove.addOtherDbTables = function () {
var buttonOptions = {};
buttonOptions[Messages.strGo] = function () {
var db = $('#add_table_from').val();
var table = $('#add_table').val();
+
+ // Check if table already imported or not.
+ var $table = $('[id="' + encodeURIComponent(db) + '.' + encodeURIComponent(table) + '"]');
+ if ($table.length !== 0) {
+ Functions.ajaxShowMessage(
+ Functions.sprintf(Messages.strTableAlreadyExists, db + '.' + table),
+ undefined,
+ 'error'
+ );
+ return;
+ }
+
$.post('db_designer.php', {
'ajax_request' : true,
'dialog' : 'add_table',
@@ -539,18 +594,11 @@ DesignerMove.addOtherDbTables = function () {
var $newTableDom = $(data.message);
$newTableDom.find('a').first().remove();
$('#container-form').append($newTableDom);
- $('.designer_tab').on('click','.tab_field_2,.tab_field_3,.tab_field', function () {
- var params = ($(this).attr('click_field_param')).split(',');
- DesignerMove.clickField(params[3], params[0], params[1], params[2]);
- });
- $('.designer_tab').on('click', '.select_all_store_col', function () {
- var params = ($(this).attr('store_column_param')).split(',');
- DesignerMove.storeColumn(params[0], params[1], params[2]);
- });
- $('.designer_tab').on('click', '.small_tab_pref_click_opt', function () {
- var params = ($(this).attr('Click_option_param')).split(',');
- DesignerMove.clickOption(params[0], params[1], params[2]);
- });
+ DesignerMove.enableTableEvents(null, $newTableDom);
+ DesignerMove.addTableToTablesList(null, $newTableDom);
+ var dbEncoded = $($newTableDom).find('.small_tab_pref').attr('db_url');
+ var tableEncoded = $($newTableDom).find('.small_tab_pref').attr('table_name_url');
+ jTabs[dbEncoded + '.' + tableEncoded] = 1;
});
$(this).dialog('close');
};
@@ -559,10 +607,10 @@ DesignerMove.addOtherDbTables = function () {
};
var $selectDb = $('');
- $selectDb.append('');
+ $selectDb.append('');
var $selectTable = $('');
- $selectTable.append('');
+ $selectTable.append('');
$.post('sql.php', {
'ajax_request' : true,
@@ -601,7 +649,11 @@ DesignerMove.addOtherDbTables = function () {
'server': CommonParams.get('server')
}, function (data) {
$selectTable.html('');
- $(data.message).find('table.table_results.data.ajax').find('td.data').each(function () {
+ var rows = $(data.message).find('table.table_results.data.ajax').find('td.data');
+ if (rows.length === 0) {
+ $selectTable.append('');
+ }
+ rows.each(function () {
var val = $(this)[0].innerHTML;
$selectTable.append('');
});
@@ -635,11 +687,15 @@ DesignerMove.getUrlPos = function (forceString) {
if (designerTablesEnabled || forceString) {
var poststr = '';
var argsep = CommonParams.get('arg_separator');
+ var i = 1;
for (key in jTabs) {
- poststr += argsep + 't_x[' + key + ']=' + parseInt(document.getElementById(key).style.left, 10);
- poststr += argsep + 't_y[' + key + ']=' + parseInt(document.getElementById(key).style.top, 10);
- poststr += argsep + 't_v[' + key + ']=' + (document.getElementById('id_tbody_' + key).style.display === 'none' ? 0 : 1);
- poststr += argsep + 't_h[' + key + ']=' + (document.getElementById('check_vis_' + key).checked ? 1 : 0);
+ poststr += argsep + 't_x[' + i + ']=' + parseInt(document.getElementById(key).style.left, 10);
+ poststr += argsep + 't_y[' + i + ']=' + parseInt(document.getElementById(key).style.top, 10);
+ poststr += argsep + 't_v[' + i + ']=' + (document.getElementById('id_tbody_' + key).style.display === 'none' ? 0 : 1);
+ poststr += argsep + 't_h[' + i + ']=' + (document.getElementById('check_vis_' + key).checked ? 1 : 0);
+ poststr += argsep + 't_db[' + i + ']=' + $(document.getElementById(key)).attr('db_url');
+ poststr += argsep + 't_tbl[' + i + ']=' + $(document.getElementById(key)).attr('table_name_url');
+ i++;
}
return poststr;
} else {
@@ -648,7 +704,10 @@ DesignerMove.getUrlPos = function (forceString) {
if (document.getElementById('check_vis_' + key).checked) {
var x = parseInt(document.getElementById(key).style.left, 10);
var y = parseInt(document.getElementById(key).style.top, 10);
- var tbCoords = new DesignerObjects.TableCoordinate(db, key.split('.')[1], -1, x, y);
+ var tbCoords = new DesignerObjects.TableCoordinate(
+ $(document.getElementById(key)).attr('db_url'),
+ $(document.getElementById(key)).attr('table_name_url'),
+ -1, x, y);
coords.push(tbCoords);
}
}
@@ -659,8 +718,8 @@ DesignerMove.getUrlPos = function (forceString) {
DesignerMove.save2 = function (callback) {
if (designerTablesEnabled) {
var argsep = CommonParams.get('arg_separator');
- var poststr = argsep + 'operation=savePage' + argsep + 'save_page=same' + argsep + 'ajax_request=true';
- poststr += argsep + 'server=' + server + argsep + 'db=' + db + argsep + 'selected_page=' + selectedPage;
+ var poststr = 'operation=savePage' + argsep + 'save_page=same' + argsep + 'ajax_request=true';
+ poststr += argsep + 'server=' + server + argsep + 'db=' + encodeURIComponent(db) + argsep + 'selected_page=' + selectedPage;
poststr += DesignerMove.getUrlPos();
var $msgbox = Functions.ajaxShowMessage(Messages.strProcessingRequest);
@@ -1105,7 +1164,7 @@ DesignerMove.loadPage = function (page) {
if (page !== null) {
paramPage = argsep + 'page=' + page;
}
- $('')
+ $('')
.appendTo($('#page_content'))
.trigger('click');
} else {
@@ -1278,7 +1337,8 @@ DesignerMove.startTableNew = function () {
CommonActions.refreshMain('tbl_create.php');
};
-DesignerMove.startTabUpd = function (table) {
+DesignerMove.startTabUpd = function (db, table) {
+ CommonParams.set('db', db);
CommonParams.set('table', table);
CommonActions.refreshMain('tbl_structure.php');
};
@@ -1287,24 +1347,23 @@ DesignerMove.startTabUpd = function (table) {
// max/min all tables
DesignerMove.smallTabAll = function (idThis) {
var icon = idThis.children[0];
- var key;
var valueSent = '';
if (icon.alt === 'v') {
- for (key in jTabs) {
- if (document.getElementById('id_hide_tbody_' + key).innerHTML === 'v') {
- DesignerMove.smallTab(key, 0);
+ $('.designer_tab .small_tab,.small_tab2').each(function (index, element) {
+ if ($(element).text() === 'v') {
+ DesignerMove.smallTab($(element).attr('table_name'), 0);
}
- }
+ });
icon.alt = '>';
icon.src = icon.dataset.right;
valueSent = 'v';
} else {
- for (key in jTabs) {
- if (document.getElementById('id_hide_tbody_' + key).innerHTML !== 'v') {
- DesignerMove.smallTab(key, 0);
+ $('.designer_tab .small_tab,.small_tab2').each(function (index, element) {
+ if ($(element).text() !== 'v') {
+ DesignerMove.smallTab($(element).attr('table_name'), 0);
}
- }
+ });
icon.alt = 'v';
icon.src = icon.dataset.down;
valueSent = '>';
@@ -1885,6 +1944,64 @@ DesignerMove.addObject = function () {
$('#ab').accordion('refresh');
};
+DesignerMove.enablePageContentEvents = function () {
+ $('#page_content').off('mousedown');
+ $('#page_content').off('mouseup');
+ $('#page_content').off('mousemove');
+ $('#page_content').on('mousedown', function (e) {
+ DesignerMove.mouseDown(e);
+ });
+ $('#page_content').on('mouseup', function (e) {
+ DesignerMove.mouseUp(e);
+ });
+ $('#page_content').on('mousemove', function (e) {
+ DesignerMove.mouseMove(e);
+ });
+};
+
+/**
+ * This function enables the events on table items.
+ * It helps to enable them on page loading and when a table is added on the fly.
+ */
+DesignerMove.enableTableEvents = function (index, element) {
+ $(element).on('click', '.select_all_1', function () {
+ DesignerMove.selectAll($(this).attr('designer_url_table_name'), $(this).attr('designer_out_owner'));
+ });
+ $(element).on('click', '.small_tab,.small_tab2', function () {
+ DesignerMove.smallTab($(this).attr('table_name'), 1);
+ });
+ $(element).on('click', '.small_tab_pref_1', function () {
+ DesignerMove.startTabUpd($(this).attr('db'), $(this).attr('table_name_small'));
+ });
+ $(element).on('click', '.select_all_store_col', function () {
+ var params = ($(this).attr('store_column_param')).split(',');
+ DesignerMove.storeColumn(params[0], params[1], params[2]);
+ });
+ $(element).on('click', '.small_tab_pref_click_opt', function () {
+ var params = ($(this).attr('Click_option_param')).split(',');
+ DesignerMove.clickOption(params[0], params[1], params[2]);
+ });
+ $(element).on('click', '.tab_field_2,.tab_field_3,.tab_field', function () {
+ var params = ($(this).attr('click_field_param')).split(',');
+ DesignerMove.clickField(params[3], params[0], params[1], params[2]);
+ });
+
+ $(element).find('.tab_zag_noquery').mouseover(function () {
+ DesignerMove.tableOnOver($(this).attr('table_name'),0, $(this).attr('query_set'));
+ });
+ $(element).find('.tab_zag_noquery').mouseout(function () {
+ DesignerMove.tableOnOver($(this).attr('table_name'),1, $(this).attr('query_set'));
+ });
+ $(element).find('.tab_zag_query').mouseover(function () {
+ DesignerMove.tableOnOver($(this).attr('table_name'),0, 1);
+ });
+ $(element).find('.tab_zag_query').mouseout(function () {
+ DesignerMove.tableOnOver($(this).attr('table_name'),1, 1);
+ });
+
+ DesignerMove.enablePageContentEvents();
+};
+
AJAX.registerTeardown('designer/move.js', function () {
$('#side_menu').off('mouseenter mouseleave');
$('#key_Show_left_menu').off('click');
@@ -2036,49 +2153,11 @@ AJAX.registerOnload('designer/move.js', function () {
DesignerMove.noHaveConstr(this);
return false;
});
- $('.scroll_tab_struct').on('click', function () {
- DesignerMove.startTabUpd($(this).attr('table_name'));
- });
- $('.scroll_tab_checkbox').on('click', function () {
- DesignerMove.visibleTab(this,$(this).val());
- });
- $('#id_scroll_tab').find('tr').on('click', '.designer_Tabs2,.designer_Tabs', function () {
- DesignerMove.selectTab($(this).attr('designer_url_table_name'));
- });
- $('.designer_tab').on('click', '.select_all_1', function () {
- DesignerMove.selectAll($(this).attr('designer_url_table_name'), $(this).attr('designer_out_owner'));
- });
- $('.designer_tab').on('click', '.small_tab,.small_tab2', function () {
- DesignerMove.smallTab($(this).attr('table_name'), 1);
- });
- $('.designer_tab').on('click', '.small_tab_pref_1', function () {
- DesignerMove.startTabUpd($(this).attr('table_name_small'));
- });
- $('.tab_zag_noquery').mouseover(function () {
- DesignerMove.tableOnOver($(this).attr('table_name'),0, $(this).attr('query_set'));
- });
- $('.tab_zag_noquery').mouseout(function () {
- DesignerMove.tableOnOver($(this).attr('table_name'),1, $(this).attr('query_set'));
- });
- $('.tab_zag_query').mouseover(function () {
- DesignerMove.tableOnOver($(this).attr('table_name'),0, 1);
- });
- $('.tab_zag_query').mouseout(function () {
- DesignerMove.tableOnOver($(this).attr('table_name'),1, 1);
- });
- $('.designer_tab').on('click','.tab_field_2,.tab_field_3,.tab_field', function () {
- var params = ($(this).attr('click_field_param')).split(',');
- DesignerMove.clickField(params[3], params[0], params[1], params[2]);
- });
- $('.designer_tab').on('click', '.select_all_store_col', function () {
- var params = ($(this).attr('store_column_param')).split(',');
- DesignerMove.storeColumn(params[0], params[1], params[2]);
- });
- $('.designer_tab').on('click', '.small_tab_pref_click_opt', function () {
- var params = ($(this).attr('Click_option_param')).split(',');
- DesignerMove.clickOption(params[0], params[1], params[2]);
- });
- $('input#del_button').on('click', function () {
+
+ $('.designer_tab').each(DesignerMove.enableTableEvents);
+ $('.designer_tab').each(DesignerMove.addTableToTablesList);
+
+ $('input#del_button').click(function () {
DesignerMove.updRelation();
});
$('input#cancel_button').on('click', function () {
@@ -2097,13 +2176,5 @@ AJAX.registerOnload('designer/move.js', function () {
$('input#cancel_new_rel_panel').on('click', function () {
document.getElementById('layer_new_relation').style.display = 'none';
});
- $('#page_content').on('mousedown', function (e) {
- DesignerMove.mouseDown(e);
- });
- $('#page_content').on('mouseup', function (e) {
- DesignerMove.mouseUp(e);
- });
- $('#page_content').on('mousemove', function (e) {
- DesignerMove.mouseMove(e);
- });
+ DesignerMove.enablePageContentEvents();
});
diff --git a/js/messages.php b/js/messages.php
index b02de19d1c..2006bee5ea 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -762,6 +762,11 @@ $js_messages['strStrong'] = __('Strong');
$js_messages['strU2FTimeout'] = __('Timed out waiting for security key activation.');
$js_messages['strU2FError'] = __('Failed security key activation (%s).');
+/* Designer */
+$js_messages['strTableAlreadyExists'] = _pgettext('The table already exists in the designer and can not be added once more.', 'Table %s already exists!');
+$js_messages['strHide'] = __('Hide');
+$js_messages['strStructure'] = __('Structure');
+
echo "var Messages = [];\n";
foreach ($js_messages as $name => $js_message) {
Sanitize::printJsValue("Messages." . $name . "", $js_message);
diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php
index 6e821d4c29..09beca0b6a 100644
--- a/libraries/classes/Database/Designer.php
+++ b/libraries/classes/Database/Designer.php
@@ -16,6 +16,7 @@ use PhpMyAdmin\Plugins\SchemaPlugin;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Template;
use PhpMyAdmin\Util;
+use PhpMyAdmin\Database\Designer\DesignerTable;
use stdClass;
/**
@@ -241,24 +242,28 @@ class Designer
/**
* Get HTML to display tables on designer page
*
- * @param array $tab_pos tables positions
- * @param int $display_page page number of the selected page
- * @param array $tab_column table column info
- * @param array $tables_all_keys all indices
- * @param array $tables_pk_or_unique_keys unique or primary indices
+ * @param string $db The database name from the request
+ * @param DeseignerTable[] $designerTables The designer tables
+ * @param array $tab_pos tables positions
+ * @param int $display_page page number of the selected page
+ * @param array $tab_column table column info
+ * @param array $tables_all_keys all indices
+ * @param array $tables_pk_or_unique_keys unique or primary indices
*
* @return string html
*/
public function getDatabaseTables(
+ string $db,
+ array $designerTables,
array $tab_pos,
$display_page,
array $tab_column,
array $tables_all_keys,
array $tables_pk_or_unique_keys
) {
- $table_names = $GLOBALS['designer']['TABLE_NAME'];
$columns_type = [];
- foreach ($table_names as $table_name) {
+ foreach ($designerTables as $designerTable) {
+ $table_name = $designerTable->getDbTableString();
$limit = count($tab_column[$table_name]['COLUMN_ID']);
for ($j = 0; $j < $limit; $j++) {
$table_column_name = $table_name . '.' . $tab_column[$table_name]['COLUMN_NAME'][$j];
@@ -284,20 +289,14 @@ class Designer
}
return $this->template->render('database/designer/database_tables', [
'db' => $GLOBALS['db'],
- 'get_db' => $_GET['db'],
+ 'get_db' => $db,
'has_query' => isset($_REQUEST['query']),
'tab_pos' => $tab_pos,
'display_page' => $display_page,
'tab_column' => $tab_column,
'tables_all_keys' => $tables_all_keys,
'tables_pk_or_unique_keys' => $tables_pk_or_unique_keys,
- 'table_names' => $table_names,
- 'table_names_url' => $GLOBALS['designer_url']['TABLE_NAME'],
- 'table_names_small' => $GLOBALS['designer']['TABLE_NAME_SMALL'],
- 'table_names_small_url' => $GLOBALS['designer_url']['TABLE_NAME_SMALL'],
- 'table_names_small_out' => $GLOBALS['designer_out']['TABLE_NAME_SMALL'],
- 'table_types' => $GLOBALS['designer']['TABLE_TYPE'],
- 'owner_out' => $GLOBALS['designer_out']['OWNER'],
+ 'tables' => $designerTables,
'columns_type' => $columns_type,
'theme' => $GLOBALS['PMA_Theme'],
]);
@@ -307,25 +306,27 @@ class Designer
/**
* Returns HTML for Designer page
*
- * @param string $db database in use
- * @param string $getDb database in url
- * @param array $scriptTables array on foreign key support for each table
- * @param array $scriptContr initialization data array
- * @param array $scriptDisplayField display fields of each table
- * @param int $displayPage page number of the selected page
- * @param boolean $hasQuery whether this is visual query builder
- * @param string $selectedPage name of the selected page
- * @param array $paramsArray array with class name for various buttons on side menu
- * @param array|null $tabPos table positions
- * @param array $tabColumn table column info
- * @param array $tablesAllKeys all indices
- * @param array $tablesPkOrUniqueKeys unique or primary indices
+ * @param string $db database in use
+ * @param string $getDb database in url
+ * @param DesignerTable[] $designerTables The designer tables
+ * @param array $scriptTables array on foreign key support for each table
+ * @param array $scriptContr initialization data array
+ * @param array $scriptDisplayField display fields of each table
+ * @param int $displayPage page number of the selected page
+ * @param boolean $hasQuery whether this is visual query builder
+ * @param string $selectedPage name of the selected page
+ * @param array $paramsArray array with class name for various buttons on side menu
+ * @param array|null $tabPos table positions
+ * @param array $tabColumn table column info
+ * @param array $tablesAllKeys all indices
+ * @param array $tablesPkOrUniqueKeys unique or primary indices
*
* @return string html
*/
public function getHtmlForMain(
string $db,
string $getDb,
+ array $designerTables,
array $scriptTables,
array $scriptContr,
array $scriptDisplayField,
@@ -339,9 +340,9 @@ class Designer
array $tablesPkOrUniqueKeys
): string {
$cfgRelation = $this->relation->getRelationsParam();
- $tableNames = $GLOBALS['designer']['TABLE_NAME'];
$columnsType = [];
- foreach ($tableNames as $tableName) {
+ foreach ($designerTables as $designerTable) {
+ $tableName = $designerTable->getDbTableString();
$limit = count($tabColumn[$tableName]['COLUMN_ID']);
for ($j = 0; $j < $limit; $j++) {
$tableColumnName = $tableName . '.' . $tabColumn[$tableName]['COLUMN_NAME'][$j];
@@ -388,14 +389,7 @@ class Designer
'tab_column' => $tabColumn,
'tables_all_keys' => $tablesAllKeys,
'tables_pk_or_unique_keys' => $tablesPkOrUniqueKeys,
- 'table_names' => $tableNames,
- 'table_names_url' => $GLOBALS['designer_url']['TABLE_NAME'],
- 'table_names_small' => $GLOBALS['designer']['TABLE_NAME_SMALL'],
- 'table_names_small_url' => $GLOBALS['designer_url']['TABLE_NAME_SMALL'],
- 'table_names_small_out' => $GLOBALS['designer_out']['TABLE_NAME_SMALL'],
- 'table_names_out' => $GLOBALS['designer_out']['TABLE_NAME'],
- 'table_types' => $GLOBALS['designer']['TABLE_TYPE'],
- 'owner_out' => $GLOBALS['designer_out']['OWNER'],
+ 'designerTables' => $designerTables,
'columns_type' => $columnsType,
]);
}
diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php
index 90e5cbc2f4..f10419208c 100644
--- a/libraries/classes/Database/Designer/Common.php
+++ b/libraries/classes/Database/Designer/Common.php
@@ -15,6 +15,7 @@ use PhpMyAdmin\Relation;
use PhpMyAdmin\Table;
use PhpMyAdmin\Util;
use function rawurlencode;
+use PhpMyAdmin\Database\Designer\DesignerTable;
/**
* Common functions for Designer
@@ -46,113 +47,84 @@ class Common
}
/**
- * Retrieves table info and stores it in $GLOBALS['designer']
+ * Retrieves table info and returns it
*
- * @return array with table info
+ * @param string $db (optional) Filter only a DB ($table is required if you use $db)
+ * @param string $table (optional) Filter only a table ($db is now required)
+ * @return DesignerTable[] with table info
*/
- public function getTablesInfo()
+ public function getTablesInfo(string $db = null, string $table = null): array
{
- $retval = [];
-
- $GLOBALS['designer']['TABLE_NAME'] = [];// that foreach no error
- $GLOBALS['designer']['OWNER'] = [];
- $GLOBALS['designer']['TABLE_NAME_SMALL'] = [];
- $GLOBALS['designer']['TABLE_TYPE'] = [];
-
- $GLOBALS['designer_url']['TABLE_NAME'] = [];
- $GLOBALS['designer_url']['OWNER'] = [];
- $GLOBALS['designer_url']['TABLE_NAME_SMALL'] = [];
-
- $GLOBALS['designer_out']['TABLE_NAME'] = [];
- $GLOBALS['designer_out']['OWNER'] = [];
- $GLOBALS['designer_out']['TABLE_NAME_SMALL'] = [];
- $tables = $this->dbi->getTablesFull($GLOBALS['db']);
+ $designerTables = [];
+ $db = ($db === null) ? $GLOBALS['db'] : $db;
// seems to be needed later
- $this->dbi->selectDb($GLOBALS['db']);
- $i = 0;
- foreach ($tables as $one_table) {
- $GLOBALS['designer']['TABLE_NAME'][$i]
- = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
- $GLOBALS['designer']['OWNER'][$i] = $GLOBALS['db'];
- $GLOBALS['designer']['TABLE_NAME_SMALL'][$i] = htmlspecialchars(
- $one_table['TABLE_NAME'],
- ENT_QUOTES
- );
-
- $GLOBALS['designer_url']['TABLE_NAME'][$i]
- = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
- $GLOBALS['designer_url']['OWNER'][$i] = $GLOBALS['db'];
- $GLOBALS['designer_url']['TABLE_NAME_SMALL'][$i]
- = $one_table['TABLE_NAME'];
-
- $GLOBALS['designer_out']['TABLE_NAME'][$i] = htmlspecialchars(
- $GLOBALS['db'] . "." . $one_table['TABLE_NAME'],
- ENT_QUOTES
- );
- $GLOBALS['designer_out']['OWNER'][$i] = htmlspecialchars(
- $GLOBALS['db'],
- ENT_QUOTES
- );
- $GLOBALS['designer_out']['TABLE_NAME_SMALL'][$i] = htmlspecialchars(
- $one_table['TABLE_NAME'],
- ENT_QUOTES
- );
-
- $GLOBALS['designer']['TABLE_TYPE'][$i] = mb_strtoupper(
- (string) $one_table['ENGINE']
- );
-
- $DF = $this->relation->getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
- if ($DF != '') {
- $DF = rawurlencode((string) $DF);
- $retval[rawurlencode($GLOBALS['designer_url']["TABLE_NAME_SMALL"][$i])] = $DF;
- }
-
- $i++;
+ $this->dbi->selectDb($db);
+ if ($db === null && $table === null) {
+ $tables = $this->dbi->getTablesFull($db);
+ } else {
+ $tables = $this->dbi->getTablesFull($db, $table);
}
- return $retval;
+
+ foreach ($tables as $one_table) {
+ $DF = $this->relation->getDisplayField($db, $one_table['TABLE_NAME']);
+ $DF = ($DF !== '') ? $DF : null;
+ $designerTables[] = new DesignerTable(
+ $db,
+ $one_table['TABLE_NAME'],
+ $one_table['ENGINE'],
+ $DF
+ );
+ }
+
+ return $designerTables;
}
/**
* Retrieves table column info
*
- * @return array table column nfo
+ * @param DesignerTable[] $designerTables The designer tables
+ * @return array table column nfo
*/
- public function getColumnsInfo()
+ public function getColumnsInfo(array $designerTables): array
{
- $this->dbi->selectDb($GLOBALS['db']);
- $tab_column = [];
- for ($i = 0, $cnt = count($GLOBALS['designer']["TABLE_NAME"]); $i < $cnt; $i++) {
- $fields_rs = $this->dbi->query(
+ //$this->dbi->selectDb($GLOBALS['db']);
+ $tabColumn = [];
+
+ foreach ($designerTables as $designerTable) {
+ $fieldsRs = $this->dbi->query(
$this->dbi->getColumnsSql(
- $GLOBALS['db'],
- $GLOBALS['designer_url']["TABLE_NAME_SMALL"][$i],
+ $designerTable->getDatabaseName(),
+ $designerTable->getTableName(),
null,
true
),
DatabaseInterface::CONNECT_USER,
DatabaseInterface::QUERY_STORE
);
- $tbl_name_i = $GLOBALS['designer']['TABLE_NAME'][$i];
$j = 0;
- while ($row = $this->dbi->fetchAssoc($fields_rs)) {
- $tab_column[$tbl_name_i]['COLUMN_ID'][$j] = $j;
- $tab_column[$tbl_name_i]['COLUMN_NAME'][$j] = $row['Field'];
- $tab_column[$tbl_name_i]['TYPE'][$j] = $row['Type'];
- $tab_column[$tbl_name_i]['NULLABLE'][$j] = $row['Null'];
+ while ($row = $this->dbi->fetchAssoc($fieldsRs)) {
+ if (! isset($tabColumn[$designerTable->getDbTableString()])) {
+ $tabColumn[$designerTable->getDbTableString()] = [];
+ }
+ $tabColumn[$designerTable->getDbTableString()]['COLUMN_ID'][$j] = $j;
+ $tabColumn[$designerTable->getDbTableString()]['COLUMN_NAME'][$j] = $row['Field'];
+ $tabColumn[$designerTable->getDbTableString()]['TYPE'][$j] = $row['Type'];
+ $tabColumn[$designerTable->getDbTableString()]['NULLABLE'][$j] = $row['Null'];
$j++;
}
}
- return $tab_column;
+
+ return $tabColumn;
}
/**
* Returns JavaScript code for initializing vars
*
- * @return array JavaScript code
+ * @param DesignerTable[] $designerTables The designer tables
+ * @return array JavaScript code
*/
- public function getScriptContr()
+ public function getScriptContr(array $designerTables): array
{
$this->dbi->selectDb($GLOBALS['db']);
$con = [];
@@ -199,6 +171,11 @@ class Common
}
}
+ $tableDbNames = [];
+ foreach ($designerTables as $designerTable) {
+ $tableDbNames[] = $designerTable->getDbTableString();
+ }
+
$ti = 0;
$retval = [];
for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) {
@@ -206,9 +183,7 @@ class Common
$dtn_i = $con['DTN'][$i];
$retval[$ti] = [];
$retval[$ti][$c_name_i] = [];
- if (in_array(rawurldecode($dtn_i), $GLOBALS['designer_url']["TABLE_NAME"])
- && in_array(rawurldecode($con['STN'][$i]), $GLOBALS['designer_url']["TABLE_NAME"])
- ) {
+ if (in_array($dtn_i, $tableDbNames) && in_array($con['STN'][$i], $tableDbNames)) {
$retval[$ti][$c_name_i][$dtn_i] = [];
$retval[$ti][$c_name_i][$dtn_i][$con['DCN'][$i]] = [
0 => $con['STN'][$i],
@@ -223,34 +198,36 @@ class Common
/**
* Returns UNIQUE and PRIMARY indices
*
+ * @param DesignerTable[] $designerTables The designer tables
* @return array unique or primary indices
*/
- public function getPkOrUniqueKeys()
+ public function getPkOrUniqueKeys(array $designerTables): array
{
- return $this->getAllKeys(true);
+ return $this->getAllKeys($designerTables, true);
}
/**
* Returns all indices
*
- * @param bool $unique_only whether to include only unique ones
+ * @param DesignerTable[] $designerTables The designer tables
+ * @param bool $unique_only whether to include only unique ones
*
* @return array indices
*/
- public function getAllKeys($unique_only = false)
+ public function getAllKeys(array $designerTables, bool $unique_only = false): array
{
$keys = [];
- foreach ($GLOBALS['designer']['TABLE_NAME_SMALL'] as $I => $table) {
- $schema = $GLOBALS['designer']['OWNER'][$I];
+ foreach ($designerTables as $designerTable) {
+ $schema = $designerTable->getDatabaseName();
// for now, take into account only the first index segment
- foreach (Index::getFromTable($table, $schema) as $index) {
+ foreach (Index::getFromTable($designerTable->getTableName(), $schema) as $index) {
if ($unique_only && ! $index->isUnique()) {
continue;
}
$columns = $index->getColumns();
foreach ($columns as $column_name => $dummy) {
- $keys[$schema . '.' . $table . '.' . $column_name] = 1;
+ $keys[$schema . '.' . $designerTable->getTableName() . '.' . $column_name] = 1;
}
}
}
@@ -258,25 +235,24 @@ class Common
}
/**
- * Return script to create j_tab and h_tab arrays
+ * Return j_tab and h_tab arrays
*
+ * @param DesignerTable[] $designerTables The designer tables
* @return array
*/
- public function getScriptTabs()
+ public function getScriptTabs(array $designerTables): array
{
$retval = [
'j_tabs' => [],
'h_tabs' => [],
];
- for ($i = 0, $cnt = count($GLOBALS['designer']['TABLE_NAME']); $i < $cnt; $i++) {
- $j = 0;
- if (Util::isForeignKeySupported($GLOBALS['designer']['TABLE_TYPE'][$i])) {
- $j = 1;
- }
- $retval['j_tabs'][rawurlencode($GLOBALS['designer_url']['TABLE_NAME'][$i])] = $j;
- $retval['h_tabs'][rawurlencode($GLOBALS['designer_url']['TABLE_NAME'][$i])] = 1;
+ foreach ($designerTables as $designerTable) {
+ $key = rawurlencode($designerTable->getDbTableString());
+ $retval['j_tabs'][$key] = $designerTable->supportsForeignkeys() ? 1 : 0;
+ $retval['h_tabs'][$key] = 1;
}
+
return $retval;
}
@@ -296,6 +272,7 @@ class Common
$query = "
SELECT CONCAT_WS('.', `db_name`, `table_name`) AS `name`,
+ `db_name` as `dbName`, `table_name` as `tableName`,
`x` AS `X`,
`y` AS `Y`,
1 AS `V`,
@@ -483,6 +460,10 @@ class Common
*/
public function saveTablePositions($pg)
{
+ $pageId = $this->dbi->escapeString($pg);
+
+ $db = $this->dbi->escapeString($_POST['db']);
+
$cfgRelation = $this->relation->getRelationsParam();
if (! $cfgRelation['pdfwork']) {
return false;
@@ -493,10 +474,7 @@ class Common
. "." . Util::backquote(
$GLOBALS['cfgRelation']['table_coords']
)
- . " WHERE `db_name` = '" . $this->dbi->escapeString($_REQUEST['db'])
- . "'"
- . " AND `pdf_page_number` = '" . $this->dbi->escapeString($pg)
- . "'";
+ . " WHERE `pdf_page_number` = '" . $pageId . "'";
$res = $this->relation->queryAsControlUser(
$query,
@@ -508,8 +486,9 @@ class Common
return (bool) $res;
}
- foreach ($_REQUEST['t_h'] as $key => $value) {
- list($DB, $TAB) = explode(".", $key);
+ foreach ($_POST['t_h'] as $key => $value) {
+ $DB = $_POST['t_db'][$key];
+ $TAB = $_POST['t_tbl'][$key];
if (! $value) {
continue;
}
@@ -521,9 +500,9 @@ class Common
. " VALUES ("
. "'" . $this->dbi->escapeString($DB) . "', "
. "'" . $this->dbi->escapeString($TAB) . "', "
- . "'" . $this->dbi->escapeString($pg) . "', "
- . "'" . $this->dbi->escapeString($_REQUEST['t_x'][$key]) . "', "
- . "'" . $this->dbi->escapeString($_REQUEST['t_y'][$key]) . "')";
+ . "'" . $pageId . "', "
+ . "'" . $this->dbi->escapeString($_POST['t_x'][$key]) . "', "
+ . "'" . $this->dbi->escapeString($_POST['t_y'][$key]) . "')";
$res = $this->relation->queryAsControlUser(
$query,
@@ -830,7 +809,7 @@ class Common
. Util::backquote($cfgDesigner['db'])
. "." . Util::backquote($cfgDesigner['table'])
. " (username, settings_data)"
- . " VALUES('" . $GLOBALS['dbi']->escapeString($cfgDesigner['user'])
+ . " VALUES('" . $this->dbi->escapeString($cfgDesigner['user'])
. "', '" . json_encode($save_data) . "');";
$success = $this->relation->queryAsControlUser($query);
diff --git a/libraries/classes/Database/Designer/DesignerTable.php b/libraries/classes/Database/Designer/DesignerTable.php
new file mode 100644
index 0000000000..1df41059a6
--- /dev/null
+++ b/libraries/classes/Database/Designer/DesignerTable.php
@@ -0,0 +1,93 @@
+databaseName = $databaseName;
+ $this->tableName = $tableName;
+ $this->tableEngine = $tableEngine;
+ $this->displayField = $displayField;
+ }
+
+ /**
+ * The table engine supports or not foreign keys
+ *
+ * @return bool
+ */
+ public function supportsForeignkeys(): bool
+ {
+ return Util::isForeignKeySupported($this->tableEngine);
+ }
+
+ /**
+ * Get the database name
+ *
+ * @return string
+ */
+ public function getDatabaseName(): string
+ {
+ return $this->databaseName;
+ }
+
+ /**
+ * Get the table name
+ *
+ * @return string
+ */
+ public function getTableName(): string
+ {
+ return $this->tableName;
+ }
+
+ /**
+ * Get the table engine
+ *
+ * @return string
+ */
+ public function getTableEngine(): string
+ {
+ return $this->tableEngine;
+ }
+
+ /**
+ * Get the db and table speparated with a dot
+ *
+ * @return string
+ */
+ public function getDbTableString(): string
+ {
+ return $this->databaseName . '.' . $this->tableName;
+ }
+}
diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php
index 49863009be..34a16b4e0d 100644
--- a/libraries/classes/Export.php
+++ b/libraries/classes/Export.php
@@ -1219,7 +1219,7 @@ class Export
Core::fatalError(__('Bad type!'));
}
- $this->dbi->selectDb($GLOBALS['db']);
- $export_plugin->exportSchema($GLOBALS['db']);
+ $this->dbi->selectDb($_POST['db']);
+ $export_plugin->exportSchema($_POST['db']);
}
}
diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php
index 1666b5f875..6bdda6e538 100644
--- a/libraries/classes/InsertEdit.php
+++ b/libraries/classes/InsertEdit.php
@@ -2117,7 +2117,8 @@ class InsertEdit
} elseif ($trueType == 'binary' || $trueType == 'varbinary') {
$special_chars = bin2hex($column['Default']);
} elseif ('text' === substr($trueType, -4)) {
- $special_chars = stripcslashes((string) substr($column['Default'], 1, -1));
+ $textDefault = substr($column['Default'], 1, -1);
+ $special_chars = stripcslashes($textDefault !== false ? $textDefault : $column['Default']);
} else {
$special_chars = htmlspecialchars($column['Default']);
}
diff --git a/libraries/classes/Plugins/Schema/ExportRelationSchema.php b/libraries/classes/Plugins/Schema/ExportRelationSchema.php
index cc7a156589..c5209c401a 100644
--- a/libraries/classes/Plugins/Schema/ExportRelationSchema.php
+++ b/libraries/classes/Plugins/Schema/ExportRelationSchema.php
@@ -13,6 +13,7 @@ namespace PhpMyAdmin\Plugins\Schema;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
+use function rawurldecode;
/**
* This class is inherited by all schema classes
@@ -248,13 +249,11 @@ class ExportRelationSchema
protected function getTablesFromRequest()
{
$tables = [];
- $dbLength = mb_strlen($this->db);
- foreach ($_REQUEST['t_h'] as $key => $value) {
- if ($value) {
- $tables[] = mb_substr($key, $dbLength + 1);
+ if (isset($_POST['t_tbl'])) {
+ foreach ($_POST['t_tbl'] as $table) {
+ $tables[] = rawurldecode($table);
}
}
-
return $tables;
}
@@ -303,7 +302,7 @@ class ExportRelationSchema
echo ' ' , $error_message , "\n";
echo '' , "\n";
echo '' , __('Back') , '';
echo "\n";
exit;
diff --git a/libraries/classes/Plugins/Schema/TableStats.php b/libraries/classes/Plugins/Schema/TableStats.php
index 5bbffc451d..a3d3b5c570 100644
--- a/libraries/classes/Plugins/Schema/TableStats.php
+++ b/libraries/classes/Plugins/Schema/TableStats.php
@@ -14,6 +14,7 @@ use PhpMyAdmin\Font;
use PhpMyAdmin\Index;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Util;
+use function rawurldecode;
/**
* Table preferences/statistics
@@ -146,11 +147,15 @@ abstract class TableStats
*/
protected function loadCoordinates()
{
- foreach ($_REQUEST['t_h'] as $key => $value) {
- if ($this->db . '.' . $this->tableName == $key) {
- $this->x = (double) $_REQUEST['t_x'][$key];
- $this->y = (double) $_REQUEST['t_y'][$key];
- break;
+ if (isset($_POST['t_h'])) {
+ foreach ($_POST['t_h'] as $key => $value) {
+ $db = rawurldecode($_POST['t_db'][$key]);
+ $tbl = rawurldecode($_POST['t_tbl'][$key]);
+ if ($this->db . '.' . $this->tableName === $db . '.' . $tbl) {
+ $this->x = (double) $_POST['t_x'][$key];
+ $this->y = (double) $_POST['t_y'][$key];
+ break;
+ }
}
}
}
diff --git a/libraries/tbl_columns_definition_form.inc.php b/libraries/tbl_columns_definition_form.inc.php
index 99a28ee8cd..6f3973b067 100644
--- a/libraries/tbl_columns_definition_form.inc.php
+++ b/libraries/tbl_columns_definition_form.inc.php
@@ -322,7 +322,8 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
$columnMeta['DefaultValue'] = $columnMeta['Default'];
if ('text' === substr($columnMeta['Type'], -4)) {
- $columnMeta['Default'] = stripcslashes((string) substr($columnMeta['Default'], 1, -1));
+ $textDefault = substr($columnMeta['Default'], 1, -1);
+ $columnMeta['Default'] = stripcslashes($textDefault !== false ? $textDefault : $columnMeta['Default']);
}
break;
diff --git a/schema_export.php b/schema_export.php
index 527cfeb6e8..ee265b13e8 100644
--- a/schema_export.php
+++ b/schema_export.php
@@ -25,7 +25,7 @@ require_once ROOT_PATH . 'libraries/common.inc.php';
$relation = $containerBuilder->get('relation');
$cfgRelation = $relation->getRelationsParam();
-if (! isset($_REQUEST['export_type'])) {
+if (! isset($_POST['export_type'])) {
Util::checkParameters(['export_type']);
}
@@ -35,4 +35,4 @@ if (! isset($_REQUEST['export_type'])) {
*/
/** @var Export $export */
$export = $containerBuilder->get('export');
-$export->processExportSchema($_REQUEST['export_type']);
+$export->processExportSchema($_POST['export_type']);
diff --git a/templates/database/designer/database_tables.twig b/templates/database/designer/database_tables.twig
index 45e95cdf5d..6f33f781a6 100644
--- a/templates/database/designer/database_tables.twig
+++ b/templates/database/designer/database_tables.twig
@@ -1,11 +1,14 @@
-{% for t_n in table_names %}
+{% for designerTable in tables %}
{% set i = loop.index0 %}
- {% set t_n_url = table_names_url[i] %}
-
-
-
-
-
+
+
+
+
+ designer_url_table_name="{{ t_n_url }}"
+ designer_out_owner="{{ designerTable.getDatabaseName() }}">
{% endif %}
|
- {{ tab_pos[t_n] is not defined or tab_pos[t_n]['V'] is not empty ? 'v' : '>' }}
- |
+ id="id_hide_tbody_{{ t_n_url }}"
+ table_name="{{ t_n_url }}">{{ tab_pos[t_n] is not defined or tab_pos[t_n]['V'] is not empty ? 'v' : '>' }}
+ db="{{ designerTable.getDatabaseName() }}"
+ db_url="{{ designerTable.getDatabaseName()|escape('url') }}"
+ table_name="{{ designerTable.getTableName() }}"
+ table_name_url="{{ designerTable.getTableName()|escape('url') }}">
|
-
-
- {{ owner_out[i]|raw }}
-
- {{ table_names_small_out[i]|raw }}
+ {{ designerTable.getDatabaseName() }}
+ {{ designerTable.getTableName()|raw }}
|
{% if has_query %}
+ id="id_zag_{{ t_n_url }}_2"
+ table_name="{{ t_n_url }}">
|
{% endif %}
-
- {% set display_field = get_display_field(get_db, table_names_small[i]) %}
+ {% set display_field = get_display_field(get_db, t_n) %}
{% for j in 0..tab_column[t_n]['COLUMN_ID']|length - 1 %}
{% set tmp_column = t_n ~ '.' ~ tab_column[t_n]['COLUMN_NAME'][j] %}
{% set click_field_param = [
- table_names_small_url[i],
+ t_n,
tab_column[t_n]['COLUMN_NAME'][j]|url_encode
] %}
- {% if not is_foreign_key_supported(table_types[i]) %}
+ {% if not designerTable.supportsForeignkeys() %}
{% set click_field_param = click_field_param|merge([tables_pk_or_unique_keys[tmp_column] is defined ? 1 : 0]) %}
{% else %}
{# if foreign keys are supported, it's not necessary that the
@@ -72,23 +74,23 @@
{% set click_field_param = click_field_param|merge([tables_all_keys[tmp_column] is defined ? 1 : 0]) %}
{% endif %}
{% set click_field_param = click_field_param|merge([db]) %}
-
{% if has_query %}
|
|
{% endif %}
-
{% set type = columns_type[t_n ~ '.' ~ tab_column[t_n]['COLUMN_NAME'][j]] %}
@@ -100,7 +102,7 @@
+ {{- t_n }}">
|
{% endif %}
diff --git a/templates/database/designer/main.twig b/templates/database/designer/main.twig
index 5a60d9e788..b5108691f5 100644
--- a/templates/database/designer/main.twig
+++ b/templates/database/designer/main.twig
@@ -220,41 +220,11 @@ var designerConfig = {{ designer_config|raw }};
{# end id_scroll_tab #}
- {% trans 'Number of tables:' %} {{ table_names|length }}
+ {% trans 'Number of tables:' %} 0
|