2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * phpMyAdmin designer general code
6 * @package PhpMyAdmin-Designer
8 use PMA\libraries\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']
32 $response->addHTML($html);
37 if (isset($_REQUEST['operation'])) {
39 if ($_REQUEST['operation'] == 'deletePage') {
40 $success = PMA_deletePage($_REQUEST['selected_page']);
41 $response->setRequestStatus($success);
42 } elseif ($_REQUEST['operation'] == 'savePage') {
43 if ($_REQUEST['save_page'] == 'same') {
44 $page = $_REQUEST['selected_page'];
46 $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
47 $response->addJSON('id', $page);
49 $success = PMA_saveTablePositions($page);
50 $response->setRequestStatus($success);
51 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
53 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
55 $response->setRequestStatus(true);
56 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
57 list($success, $message) = PMA_addNewRelation(
63 $_REQUEST['on_delete'],
64 $_REQUEST['on_update']
66 $response->setRequestStatus($success);
67 $response->addJSON('message', $message);
68 } elseif ($_REQUEST['operation'] == 'removeRelation') {
69 list($success, $message) = PMA_removeRelation(
75 $response->setRequestStatus($success);
76 $response->addJSON('message', $message);
77 } elseif ($_REQUEST['operation'] == 'save_setting_value') {
78 $success = PMA_saveDesignerSetting($_REQUEST['index'], $_REQUEST['value']);
79 $response->setRequestStatus($success);
85 require 'libraries/db_common.inc.php';
87 $script_display_field = PMA_getTablesInfo();
88 $tab_column = PMA_getColumnsInfo();
89 $script_tables = PMA_getScriptTabs();
90 $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
91 $tables_all_keys = PMA_getAllKeys();
92 $classes_side_menu = PMA_returnClassNamesFromMenuButtons();
95 $selected_page = null;
97 if (isset($_REQUEST['query'])) {
98 $display_page = PMA_getDefaultPage($_REQUEST['db']);
100 if (! empty($_REQUEST['page'])) {
101 $display_page = $_REQUEST['page'];
103 $display_page = PMA_getLoadingPage($_REQUEST['db']);
106 if ($display_page != -1) {
107 $selected_page = PMA_getPageName($display_page);
109 $tab_pos = PMA_getTablePositions($display_page);
110 $script_contr = PMA_getScriptContr();
112 $params = array('lang' => $GLOBALS['lang']);
113 if (isset($_GET['db'])) {
114 $params['db'] = $_GET['db'];
117 $response = Response
::getInstance();
118 $response->getFooter()->setMinimal();
119 $header = $response->getHeader();
120 $header->setBodyId('pmd_body');
122 $scripts = $header->getScripts();
123 $scripts->addFile('jquery/jquery.fullscreen.js');
124 $scripts->addFile('pmd/designer_db.js');
125 $scripts->addFile('pmd/designer_objects.js');
126 $scripts->addFile('pmd/designer_page.js');
127 $scripts->addFile('pmd/history.js');
128 $scripts->addFile('pmd/move.js');
129 $scripts->addFile('pmd/init.js');
137 $db_is_system_schema,
141 ) = PMA\libraries\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
143 // Embed some data into HTML, later it will be read
144 // by pmd/init.js and converted to JS variables.
146 PMA_getHtmlForJSFields(
147 $script_tables, $script_contr, $script_display_field, $display_page
151 PMA_getDesignerPageMenu(
152 isset($_REQUEST['query']),
160 $response->addHTML('<div id="canvas_outer">');
162 '<form action="" id="container-form" method="post" name="form1">'
165 $response->addHTML(PMA_getHTMLCanvas());
166 $response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
169 PMA_getDatabaseTables(
170 $tab_pos, $display_page, $tab_column,
171 $tables_all_keys, $tables_pk_or_unique_keys
174 $response->addHTML('</form>');
175 $response->addHTML('</div>'); // end canvas_outer
177 $response->addHTML('<div id="pmd_hint"></div>');
179 $response->addHTML(PMA_getNewRelationPanel());
180 $response->addHTML(PMA_getDeleteRelationPanel());
182 if (isset($_REQUEST['query'])) {
183 $response->addHTML(PMA_getOptionsPanel());
184 $response->addHTML(PMA_getRenameToPanel());
185 $response->addHTML(PMA_getHavingQueryPanel());
186 $response->addHTML(PMA_getAggregateQueryPanel());
187 $response->addHTML(PMA_getWhereQueryPanel());
188 $response->addHTML(PMA_getQueryDetails());
191 $response->addHTML('<div id="PMA_disable_floating_menubar"></div>');