2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * phpMyAdmin designer general code
6 * @package PhpMyAdmin-Designer
8 use PhpMyAdmin\Response
;
10 require_once 'libraries/common.inc.php';
11 require_once 'libraries/pmd_common.php';
12 require_once 'libraries/db_designer.lib.php';
14 $response = Response
::getInstance();
16 if (isset($_REQUEST['dialog'])) {
18 if ($_REQUEST['dialog'] == 'edit') {
19 $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
20 } else if ($_REQUEST['dialog'] == 'delete') {
21 $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
22 } else if ($_REQUEST['dialog'] == 'save_as') {
23 $html = PMA_getHtmlForPageSaveAs($GLOBALS['db']);
24 } else if ($_REQUEST['dialog'] == 'export') {
25 include_once 'libraries/plugin_interface.lib.php';
26 $html = PMA_getHtmlForSchemaExport(
27 $GLOBALS['db'], $_REQUEST['selected_page']
29 } else if ($_REQUEST['dialog'] == 'add_table') {
30 $script_display_field = PMA_getTablesInfo();
31 $required = $GLOBALS['db'] . '.' . $GLOBALS['table'];
32 $tab_column = PMA_getColumnsInfo();
33 $tables_all_keys = PMA_getAllKeys();
34 $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
36 $req_key = array_search($required, $GLOBALS['PMD']['TABLE_NAME']);
38 $GLOBALS['PMD']['TABLE_NAME'] = array($GLOBALS['PMD']['TABLE_NAME'][$req_key]);
39 $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'] = array($GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$req_key]);
40 $GLOBALS['PMD']['TABLE_NAME_SMALL'] = array($GLOBALS['PMD']['TABLE_NAME_SMALL'][$req_key]);
41 $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'] = array($GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$req_key]);
42 $GLOBALS['PMD']['TABLE_TYPE'] = array($GLOBALS['PMD_URL']['TABLE_TYPE'][$req_key]);
43 $GLOBALS['PMD_OUT']['OWNER'] = array($GLOBALS['PMD_OUT']['OWNER'][$req_key]);
45 $html = PMA_getDatabaseTables(
46 array(), -1, $tab_column,
47 $tables_all_keys, $tables_pk_or_unique_keys
52 $response->addHTML($html);
57 if (isset($_REQUEST['operation'])) {
59 if ($_REQUEST['operation'] == 'deletePage') {
60 $success = PMA_deletePage($_REQUEST['selected_page']);
61 $response->setRequestStatus($success);
62 } elseif ($_REQUEST['operation'] == 'savePage') {
63 if ($_REQUEST['save_page'] == 'same') {
64 $page = $_REQUEST['selected_page'];
66 $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
67 $response->addJSON('id', $page);
69 $success = PMA_saveTablePositions($page);
70 $response->setRequestStatus($success);
71 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
73 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
75 $response->setRequestStatus(true);
76 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
77 list($success, $message) = PMA_addNewRelation(
83 $_REQUEST['on_delete'],
84 $_REQUEST['on_update'],
88 $response->setRequestStatus($success);
89 $response->addJSON('message', $message);
90 } elseif ($_REQUEST['operation'] == 'removeRelation') {
91 list($success, $message) = PMA_removeRelation(
97 $response->setRequestStatus($success);
98 $response->addJSON('message', $message);
99 } elseif ($_REQUEST['operation'] == 'save_setting_value') {
100 $success = PMA_saveDesignerSetting($_REQUEST['index'], $_REQUEST['value']);
101 $response->setRequestStatus($success);
107 require 'libraries/db_common.inc.php';
109 $script_display_field = PMA_getTablesInfo();
110 $tab_column = PMA_getColumnsInfo();
111 $script_tables = PMA_getScriptTabs();
112 $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
113 $tables_all_keys = PMA_getAllKeys();
114 $classes_side_menu = PMA_returnClassNamesFromMenuButtons();
117 $selected_page = null;
119 if (isset($_REQUEST['query'])) {
120 $display_page = PMA_getDefaultPage($_REQUEST['db']);
122 if (! empty($_REQUEST['page'])) {
123 $display_page = $_REQUEST['page'];
125 $display_page = PMA_getLoadingPage($_REQUEST['db']);
128 if ($display_page != -1) {
129 $selected_page = PMA_getPageName($display_page);
131 $tab_pos = PMA_getTablePositions($display_page);
132 $script_contr = PMA_getScriptContr();
134 $params = array('lang' => $GLOBALS['lang']);
135 if (isset($_GET['db'])) {
136 $params['db'] = $_GET['db'];
139 $response = Response
::getInstance();
140 $response->getFooter()->setMinimal();
141 $header = $response->getHeader();
142 $header->setBodyId('pmd_body');
144 $scripts = $header->getScripts();
145 $scripts->addFile('vendor/jquery/jquery.fullscreen.js');
146 $scripts->addFile('pmd/designer_db.js');
147 $scripts->addFile('pmd/designer_objects.js');
148 $scripts->addFile('pmd/designer_page.js');
149 $scripts->addFile('pmd/history.js');
150 $scripts->addFile('pmd/move.js');
151 $scripts->addFile('pmd/init.js');
159 $db_is_system_schema,
163 ) = PhpMyAdmin\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
165 // Embed some data into HTML, later it will be read
166 // by pmd/init.js and converted to JS variables.
168 PMA_getHtmlForJSFields(
169 $script_tables, $script_contr, $script_display_field, $display_page
173 PMA_getDesignerPageMenu(
174 isset($_REQUEST['query']),
182 $response->addHTML('<div id="canvas_outer">');
184 '<form action="" id="container-form" method="post" name="form1">'
187 $response->addHTML(PMA_getHTMLCanvas());
188 $response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
191 PMA_getDatabaseTables(
192 $tab_pos, $display_page, $tab_column,
193 $tables_all_keys, $tables_pk_or_unique_keys
196 $response->addHTML('</form>');
197 $response->addHTML('</div>'); // end canvas_outer
199 $response->addHTML('<div id="pmd_hint"></div>');
201 $response->addHTML(PMA_getNewRelationPanel());
202 $response->addHTML(PMA_getDeleteRelationPanel());
204 if (isset($_REQUEST['query'])) {
205 $response->addHTML(PMA_getOptionsPanel());
206 $response->addHTML(PMA_getRenameToPanel());
207 $response->addHTML(PMA_getHavingQueryPanel());
208 $response->addHTML(PMA_getAggregateQueryPanel());
209 $response->addHTML(PMA_getWhereQueryPanel());
210 $response->addHTML(PMA_getQueryDetails());
213 $response->addHTML('<div id="PMA_disable_floating_menubar"></div>');