2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * phpMyAdmin designer general code
6 * @package PhpMyAdmin-Designer
8 use PhpMyAdmin\Database\Designer
;
9 use PhpMyAdmin\Database\Designer\Common
;
10 use PhpMyAdmin\Response
;
12 require_once 'libraries/common.inc.php';
14 $response = Response
::getInstance();
16 $databaseDesigner = new Designer();
17 $designerCommon = new Common();
19 if (isset($_REQUEST['dialog'])) {
21 if ($_GET['dialog'] == 'edit') {
22 $html = $databaseDesigner->getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
23 } elseif ($_GET['dialog'] == 'delete') {
24 $html = $databaseDesigner->getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
25 } elseif ($_GET['dialog'] == 'save_as') {
26 $html = $databaseDesigner->getHtmlForPageSaveAs($GLOBALS['db']);
27 } elseif ($_GET['dialog'] == 'export') {
28 $html = $databaseDesigner->getHtmlForSchemaExport(
29 $GLOBALS['db'], $_GET['selected_page']
31 } elseif ($_POST['dialog'] == 'add_table') {
32 $script_display_field = $designerCommon->getTablesInfo();
33 $required = $GLOBALS['db'] . '.' . $GLOBALS['table'];
34 $tab_column = $designerCommon->getColumnsInfo();
35 $tables_all_keys = $designerCommon->getAllKeys();
36 $tables_pk_or_unique_keys = $designerCommon->getPkOrUniqueKeys();
38 $req_key = array_search($required, $GLOBALS['designer']['TABLE_NAME']);
40 $GLOBALS['designer']['TABLE_NAME'] = array($GLOBALS['designer']['TABLE_NAME'][$req_key]);
41 $GLOBALS['designer_url']['TABLE_NAME_SMALL'] = array($GLOBALS['designer_url']['TABLE_NAME_SMALL'][$req_key]);
42 $GLOBALS['designer']['TABLE_NAME_SMALL'] = array($GLOBALS['designer']['TABLE_NAME_SMALL'][$req_key]);
43 $GLOBALS['designer_out']['TABLE_NAME_SMALL'] = array($GLOBALS['designer_out']['TABLE_NAME_SMALL'][$req_key]);
44 $GLOBALS['designer']['TABLE_TYPE'] = array($GLOBALS['designer_url']['TABLE_TYPE'][$req_key]);
45 $GLOBALS['designer_out']['OWNER'] = array($GLOBALS['designer_out']['OWNER'][$req_key]);
47 $html = $databaseDesigner->getDatabaseTables(
48 array(), -1, $tab_column,
49 $tables_all_keys, $tables_pk_or_unique_keys
54 $response->addHTML($html);
59 if (isset($_POST['operation'])) {
61 if ($_POST['operation'] == 'deletePage') {
62 $success = $designerCommon->deletePage($_POST['selected_page']);
63 $response->setRequestStatus($success);
64 } elseif ($_POST['operation'] == 'savePage') {
65 if ($_POST['save_page'] == 'same') {
66 $page = $_POST['selected_page'];
68 $page = $designerCommon->createNewPage($_POST['selected_value'], $GLOBALS['db']);
69 $response->addJSON('id', $page);
71 $success = $designerCommon->saveTablePositions($page);
72 $response->setRequestStatus($success);
73 } elseif ($_POST['operation'] == 'setDisplayField') {
74 $designerCommon->saveDisplayField(
75 $_POST['db'], $_POST['table'], $_POST['field']
77 $response->setRequestStatus(true);
78 } elseif ($_POST['operation'] == 'addNewRelation') {
79 list($success, $message) = $designerCommon->addNewRelation(
90 $response->setRequestStatus($success);
91 $response->addJSON('message', $message);
92 } elseif ($_POST['operation'] == 'removeRelation') {
93 list($success, $message) = $designerCommon->removeRelation(
99 $response->setRequestStatus($success);
100 $response->addJSON('message', $message);
101 } elseif ($_POST['operation'] == 'save_setting_value') {
102 $success = $designerCommon->saveSetting($_POST['index'], $_POST['value']);
103 $response->setRequestStatus($success);
109 require 'libraries/db_common.inc.php';
111 $script_display_field = $designerCommon->getTablesInfo();
112 $tab_column = $designerCommon->getColumnsInfo();
113 $script_tables = $designerCommon->getScriptTabs();
114 $tables_pk_or_unique_keys = $designerCommon->getPkOrUniqueKeys();
115 $tables_all_keys = $designerCommon->getAllKeys();
116 $classes_side_menu = $databaseDesigner->returnClassNamesFromMenuButtons();
119 $selected_page = null;
121 if (isset($_GET['query'])) {
122 $display_page = $designerCommon->getDefaultPage($_GET['db']);
124 if (! empty($_GET['page'])) {
125 $display_page = $_GET['page'];
127 $display_page = $designerCommon->getLoadingPage($_GET['db']);
130 if ($display_page != -1) {
131 $selected_page = $designerCommon->getPageName($display_page);
133 $tab_pos = $designerCommon->getTablePositions($display_page);
134 $script_contr = $designerCommon->getScriptContr();
136 $params = array('lang' => $GLOBALS['lang']);
137 if (isset($_GET['db'])) {
138 $params['db'] = $_GET['db'];
141 $response = Response
::getInstance();
142 $response->getFooter()->setMinimal();
143 $header = $response->getHeader();
144 $header->setBodyId('designer_body');
146 $scripts = $header->getScripts();
147 $scripts->addFile('vendor/jquery/jquery.fullscreen.js');
148 $scripts->addFile('designer/database.js');
149 $scripts->addFile('designer/objects.js');
150 $scripts->addFile('designer/page.js');
151 $scripts->addFile('designer/history.js');
152 $scripts->addFile('designer/move.js');
153 $scripts->addFile('designer/init.js');
161 $db_is_system_schema,
165 ) = PhpMyAdmin\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
167 // Embed some data into HTML, later it will be read
168 // by designer/init.js and converted to JS variables.
170 $databaseDesigner->getHtmlForJsFields(
171 $script_tables, $script_contr, $script_display_field, $display_page
175 $databaseDesigner->getPageMenu(
176 isset($_GET['query']),
184 $response->addHTML('<div id="canvas_outer">');
186 '<form action="" id="container-form" method="post" name="form1">'
189 $response->addHTML($databaseDesigner->getHtmlCanvas());
190 $response->addHTML($databaseDesigner->getHtmlTableList($tab_pos, $display_page));
193 $databaseDesigner->getDatabaseTables(
194 $tab_pos, $display_page, $tab_column,
195 $tables_all_keys, $tables_pk_or_unique_keys
198 $response->addHTML('</form>');
199 $response->addHTML('</div>'); // end canvas_outer
201 $response->addHTML('<div id="designer_hint"></div>');
203 $response->addHTML($databaseDesigner->getNewRelationPanel());
204 $response->addHTML($databaseDesigner->getDeleteRelationPanel());
206 if (isset($_GET['query'])) {
207 $response->addHTML($databaseDesigner->getOptionsPanel());
208 $response->addHTML($databaseDesigner->getRenameToPanel());
209 $response->addHTML($databaseDesigner->getHavingQueryPanel());
210 $response->addHTML($databaseDesigner->getAggregateQueryPanel());
211 $response->addHTML($databaseDesigner->getWhereQueryPanel());
212 $response->addHTML($databaseDesigner->getQueryDetails($_GET['db']));
215 $response->addHTML('<div id="PMA_disable_floating_menubar"></div>');