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\PmdCommon
;
10 use PhpMyAdmin\Response
;
12 require_once 'libraries/common.inc.php';
14 $response = Response
::getInstance();
16 if (isset($_REQUEST['dialog'])) {
18 if ($_REQUEST['dialog'] == 'edit') {
19 $html = Designer
::getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
20 } elseif ($_REQUEST['dialog'] == 'delete') {
21 $html = Designer
::getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
22 } elseif ($_REQUEST['dialog'] == 'save_as') {
23 $html = Designer
::getHtmlForPageSaveAs($GLOBALS['db']);
24 } elseif ($_REQUEST['dialog'] == 'export') {
25 $html = Designer
::getHtmlForSchemaExport(
26 $GLOBALS['db'], $_REQUEST['selected_page']
28 } elseif ($_REQUEST['dialog'] == 'add_table') {
29 $script_display_field = PmdCommon
::getTablesInfo();
30 $required = $GLOBALS['db'] . '.' . $GLOBALS['table'];
31 $tab_column = PmdCommon
::getColumnsInfo();
32 $tables_all_keys = PmdCommon
::getAllKeys();
33 $tables_pk_or_unique_keys = PmdCommon
::getPkOrUniqueKeys();
35 $req_key = array_search($required, $GLOBALS['PMD']['TABLE_NAME']);
37 $GLOBALS['PMD']['TABLE_NAME'] = array($GLOBALS['PMD']['TABLE_NAME'][$req_key]);
38 $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'] = array($GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$req_key]);
39 $GLOBALS['PMD']['TABLE_NAME_SMALL'] = array($GLOBALS['PMD']['TABLE_NAME_SMALL'][$req_key]);
40 $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'] = array($GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$req_key]);
41 $GLOBALS['PMD']['TABLE_TYPE'] = array($GLOBALS['PMD_URL']['TABLE_TYPE'][$req_key]);
42 $GLOBALS['PMD_OUT']['OWNER'] = array($GLOBALS['PMD_OUT']['OWNER'][$req_key]);
44 $html = Designer
::getDatabaseTables(
45 array(), -1, $tab_column,
46 $tables_all_keys, $tables_pk_or_unique_keys
51 $response->addHTML($html);
56 if (isset($_REQUEST['operation'])) {
58 if ($_REQUEST['operation'] == 'deletePage') {
59 $success = PmdCommon
::deletePage($_REQUEST['selected_page']);
60 $response->setRequestStatus($success);
61 } elseif ($_REQUEST['operation'] == 'savePage') {
62 if ($_REQUEST['save_page'] == 'same') {
63 $page = $_REQUEST['selected_page'];
65 $page = PmdCommon
::createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
66 $response->addJSON('id', $page);
68 $success = PmdCommon
::saveTablePositions($page);
69 $response->setRequestStatus($success);
70 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
71 PmdCommon
::saveDisplayField(
72 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
74 $response->setRequestStatus(true);
75 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
76 list($success, $message) = PmdCommon
::addNewRelation(
82 $_REQUEST['on_delete'],
83 $_REQUEST['on_update'],
87 $response->setRequestStatus($success);
88 $response->addJSON('message', $message);
89 } elseif ($_REQUEST['operation'] == 'removeRelation') {
90 list($success, $message) = PmdCommon
::removeRelation(
96 $response->setRequestStatus($success);
97 $response->addJSON('message', $message);
98 } elseif ($_REQUEST['operation'] == 'save_setting_value') {
99 $success = PmdCommon
::saveDesignerSetting($_REQUEST['index'], $_REQUEST['value']);
100 $response->setRequestStatus($success);
106 require 'libraries/db_common.inc.php';
108 $script_display_field = PmdCommon
::getTablesInfo();
109 $tab_column = PmdCommon
::getColumnsInfo();
110 $script_tables = PmdCommon
::getScriptTabs();
111 $tables_pk_or_unique_keys = PmdCommon
::getPkOrUniqueKeys();
112 $tables_all_keys = PmdCommon
::getAllKeys();
113 $classes_side_menu = Designer
::returnClassNamesFromMenuButtons();
116 $selected_page = null;
118 if (isset($_REQUEST['query'])) {
119 $display_page = PmdCommon
::getDefaultPage($_REQUEST['db']);
121 if (! empty($_REQUEST['page'])) {
122 $display_page = $_REQUEST['page'];
124 $display_page = PmdCommon
::getLoadingPage($_REQUEST['db']);
127 if ($display_page != -1) {
128 $selected_page = PmdCommon
::getPageName($display_page);
130 $tab_pos = PmdCommon
::getTablePositions($display_page);
131 $script_contr = PmdCommon
::getScriptContr();
133 $params = array('lang' => $GLOBALS['lang']);
134 if (isset($_GET['db'])) {
135 $params['db'] = $_GET['db'];
138 $response = Response
::getInstance();
139 $response->getFooter()->setMinimal();
140 $header = $response->getHeader();
141 $header->setBodyId('pmd_body');
143 $scripts = $header->getScripts();
144 $scripts->addFile('vendor/jquery/jquery.fullscreen.js');
145 $scripts->addFile('pmd/designer_db.js');
146 $scripts->addFile('pmd/designer_objects.js');
147 $scripts->addFile('pmd/designer_page.js');
148 $scripts->addFile('pmd/history.js');
149 $scripts->addFile('pmd/move.js');
150 $scripts->addFile('pmd/init.js');
158 $db_is_system_schema,
162 ) = PhpMyAdmin\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
164 // Embed some data into HTML, later it will be read
165 // by pmd/init.js and converted to JS variables.
167 Designer
::getHtmlForJsFields(
168 $script_tables, $script_contr, $script_display_field, $display_page
172 Designer
::getPageMenu(
173 isset($_REQUEST['query']),
181 $response->addHTML('<div id="canvas_outer">');
183 '<form action="" id="container-form" method="post" name="form1">'
186 $response->addHTML(Designer
::getHtmlCanvas());
187 $response->addHTML(Designer
::getHtmlTableList($tab_pos, $display_page));
190 Designer
::getDatabaseTables(
191 $tab_pos, $display_page, $tab_column,
192 $tables_all_keys, $tables_pk_or_unique_keys
195 $response->addHTML('</form>');
196 $response->addHTML('</div>'); // end canvas_outer
198 $response->addHTML('<div id="pmd_hint"></div>');
200 $response->addHTML(Designer
::getNewRelationPanel());
201 $response->addHTML(Designer
::getDeleteRelationPanel());
203 if (isset($_REQUEST['query'])) {
204 $response->addHTML(Designer
::getOptionsPanel());
205 $response->addHTML(Designer
::getRenameToPanel());
206 $response->addHTML(Designer
::getHavingQueryPanel());
207 $response->addHTML(Designer
::getAggregateQueryPanel());
208 $response->addHTML(Designer
::getWhereQueryPanel());
209 $response->addHTML(Designer
::getQueryDetails($_GET['db']));
212 $response->addHTML('<div id="PMA_disable_floating_menubar"></div>');