Revert "Login screen improvements and added favicon (#227)"
[openemr.git] / phpmyadmin / db_designer.php
blobb1d63ec4ef98f2ecf360bd6701bfed62b32aee0d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * phpMyAdmin designer general code
6 * @package PhpMyAdmin-Designer
7 */
9 require_once 'libraries/common.inc.php';
10 require_once 'libraries/pmd_common.php';
11 require_once 'libraries/db_designer.lib.php';
13 $response = PMA_Response::getInstance();
15 if (isset($_REQUEST['dialog'])) {
17 if ($_REQUEST['dialog'] == 'edit') {
18 $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
19 } else if ($_REQUEST['dialog'] == 'delete') {
20 $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
21 } else if ($_REQUEST['dialog'] == 'save_as') {
22 $html = PMA_getHtmlForPageSaveAs($GLOBALS['db']);
23 } else if ($_REQUEST['dialog'] == 'export') {
24 include_once 'libraries/plugin_interface.lib.php';
25 $html = PMA_getHtmlForSchemaExport(
26 $GLOBALS['db'], $_REQUEST['selected_page']
30 if (! empty($html)) {
31 $response->addHTML($html);
33 return;
36 if (isset($_REQUEST['operation'])) {
38 if ($_REQUEST['operation'] == 'deletePage') {
39 $success = PMA_deletePage($_REQUEST['selected_page']);
40 $response->isSuccess($success);
41 } elseif ($_REQUEST['operation'] == 'savePage') {
42 if ($_REQUEST['save_page'] == 'same') {
43 $page = $_REQUEST['selected_page'];
44 } else { // new
45 $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
46 $response->addJSON('id', $page);
48 $success = PMA_saveTablePositions($page);
49 $response->isSuccess($success);
50 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
51 PMA_saveDisplayField(
52 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
54 $response->isSuccess(true);
55 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
56 list($success, $message) = PMA_addNewRelation(
57 $_REQUEST['db'],
58 $_REQUEST['T1'],
59 $_REQUEST['F1'],
60 $_REQUEST['T2'],
61 $_REQUEST['F2'],
62 $_REQUEST['on_delete'],
63 $_REQUEST['on_update']
65 $response->isSuccess($success);
66 $response->addJSON('message', $message);
67 } elseif ($_REQUEST['operation'] == 'removeRelation') {
68 list($success, $message) = PMA_removeRelation(
69 $_REQUEST['T1'],
70 $_REQUEST['F1'],
71 $_REQUEST['T2'],
72 $_REQUEST['F2']
74 $response->isSuccess($success);
75 $response->addJSON('message', $message);
76 } elseif ($_REQUEST['operation'] == 'save_setting_value') {
77 $success = PMA_saveDesignerSetting($_REQUEST['index'], $_REQUEST['value']);
78 $response->isSuccess($success);
81 return;
84 require 'libraries/db_common.inc.php';
86 $script_display_field = PMA_getTablesInfo();
87 $tab_column = PMA_getColumnsInfo();
88 $script_tables = PMA_getScriptTabs();
89 $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
90 $tables_all_keys = PMA_getAllKeys();
91 $classes_side_menu = PMA_returnClassNamesFromMenuButtons();
93 $display_page = -1;
94 $selected_page = null;
96 if (isset($_REQUEST['query'])) {
97 $display_page = PMA_getDefaultPage($_REQUEST['db']);
98 } else {
99 if (! empty($_REQUEST['page'])) {
100 $display_page = $_REQUEST['page'];
101 } else {
102 $display_page = PMA_getLoadingPage($_REQUEST['db']);
105 if ($display_page != -1) {
106 $selected_page = PMA_getPageName($display_page);
108 $tab_pos = PMA_getTablePositions($display_page);
109 $script_contr = PMA_getScriptContr();
111 $params = array('lang' => $GLOBALS['lang']);
112 if (isset($_GET['db'])) {
113 $params['db'] = $_GET['db'];
116 $response = PMA_Response::getInstance();
117 $response->getFooter()->setMinimal();
118 $header = $response->getHeader();
119 $header->setBodyId('pmd_body');
121 $scripts = $header->getScripts();
122 $scripts->addFile('jquery/jquery.fullscreen.js');
123 $scripts->addFile('pmd/designer_db.js');
124 $scripts->addFile('pmd/designer_objects.js');
125 $scripts->addFile('pmd/designer_page.js');
126 $scripts->addFile('pmd/history.js');
127 $scripts->addFile('pmd/move.js');
128 $scripts->addFile('pmd/iecanvas.js', true);
129 $scripts->addFile('pmd/init.js');
131 list(
132 $tables,
133 $num_tables,
134 $total_num_tables,
135 $sub_part,
136 $is_show_stats,
137 $db_is_system_schema,
138 $tooltip_truename,
139 $tooltip_aliasname,
140 $pos
141 ) = PMA_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.
145 $response->addHTML(
146 PMA_getHtmlForJSFields(
147 $script_tables, $script_contr, $script_display_field, $display_page
150 $response->addHTML(
151 PMA_getDesignerPageMenu(isset($_REQUEST['query']), $selected_page, $classes_side_menu)
156 $response->addHTML('<div id="canvas_outer">');
157 $response->addHTML(
158 '<form action="" id="container-form" method="post" name="form1">'
161 $response->addHTML(PMA_getHTMLCanvas());
162 $response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
164 $response->addHTML(
165 PMA_getDatabaseTables(
166 $tab_pos, $display_page, $tab_column,
167 $tables_all_keys, $tables_pk_or_unique_keys
170 $response->addHTML('</form>');
171 $response->addHTML('</div>'); // end canvas_outer
173 $response->addHTML('<div id="pmd_hint"></div>');
175 $response->addHTML(PMA_getNewRelationPanel());
176 $response->addHTML(PMA_getDeleteRelationPanel());
178 if (isset($_REQUEST['query'])) {
179 $response->addHTML(PMA_getOptionsPanel());
180 $response->addHTML(PMA_getRenameToPanel());
181 $response->addHTML(PMA_getHavingQueryPanel());
182 $response->addHTML(PMA_getAggregateQueryPanel());
183 $response->addHTML(PMA_getWhereQueryPanel());
184 $response->addHTML(PMA_getQueryDetails());
187 $response->addHTML('<div id="PMA_disable_floating_menubar"></div>');