2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * phpMyAdmin designer general code
6 * @package PhpMyAdmin-Designer
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']
31 $response->addHTML($html);
36 if (isset($_REQUEST['operation'])) {
38 if ($_REQUEST['operation'] == 'deletePage') {
39 $result = PMA_deletePage($_REQUEST['selected_page']);
41 $response->isSuccess(true);
43 $response->isSuccess(false);
45 } elseif ($_REQUEST['operation'] == 'savePage') {
46 if ($_REQUEST['save_page'] == 'same') {
47 $page = $_REQUEST['selected_page'];
49 $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
50 $response->addJSON('id', $page);
52 if (PMA_saveTablePositions($page)) {
53 $response->isSuccess(true);
55 $response->isSuccess(false);
57 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
59 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
61 $response->isSuccess(true);
62 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
63 list($success, $message) = PMA_addNewRelation(
69 $_REQUEST['on_delete'],
70 $_REQUEST['on_update']
72 $response->isSuccess($success);
73 $response->addJSON('message', $message);
74 } elseif ($_REQUEST['operation'] == 'removeRelation') {
75 list($success, $message) = PMA_removeRelation(
81 $response->isSuccess($success);
82 $response->addJSON('message', $message);
83 } elseif ($_REQUEST['operation'] == 'save_setting_value') {
84 $cfgRelation = PMA_getRelationsParam();
87 'user' => $GLOBALS['cfg']['Server']['user'],
88 'db' => $cfgRelation['db'],
89 'table' => $cfgRelation['designer_settings']
91 if (! empty($cfgDesigner['user'])
92 && ! empty($cfgDesigner['db'])
93 && ! empty($cfgDesigner['table'])
94 && $GLOBALS['cfgRelation']['designer_settingswork']
96 $query = 'INSERT INTO ' . PMA_Util
::backquote($cfgDesigner['db'])
97 . '.' . PMA_Util
::backquote($cfgDesigner['table'])
98 . ' VALUES("' . $cfgDesigner['user'] . '", "'
99 . $_REQUEST['index'] . '", "' . $_REQUEST['value'] . '") ON DUPLICATE KEY '
100 . 'UPDATE `stored_value` = "' . $_REQUEST['value'] . '";';
102 $success = $GLOBALS['dbi']->query($query);
103 $response->isSuccess($success);
110 $script_display_field = PMA_getTablesInfo();
111 $tab_column = PMA_getColumnsInfo();
112 $script_tables = PMA_getScriptTabs();
113 $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
114 $tables_all_keys = PMA_getAllKeys();
115 $classes_side_menu = PMA_returnClassNamesFromMenuButtons();
118 $selected_page = null;
120 if (isset($_REQUEST['query'])) {
121 $display_page = PMA_getDefaultPage($_REQUEST['db']);
123 if (! empty($_REQUEST['page'])) {
124 $display_page = $_REQUEST['page'];
126 $display_page = PMA_getLoadingPage($_REQUEST['db']);
129 if ($display_page != -1) {
130 $selected_page = PMA_getPageName($display_page);
132 $tab_pos = PMA_getTablePositions($display_page);
133 $script_contr = PMA_getScriptContr();
135 $params = array('lang' => $GLOBALS['lang']);
136 if (isset($_GET['db'])) {
137 $params['db'] = $_GET['db'];
140 $response = PMA_Response
::getInstance();
141 $response->getFooter()->setMinimal();
142 $header = $response->getHeader();
143 $header->setBodyId('pmd_body');
145 $scripts = $header->getScripts();
146 $scripts->addFile('jquery/jquery.fullscreen.js');
147 $scripts->addFile('pmd/designer_db.js');
148 $scripts->addFile('pmd/designer_objects.js');
149 $scripts->addFile('pmd/designer_page.js');
150 $scripts->addFile('pmd/history.js');
151 $scripts->addFile('pmd/move.js');
152 $scripts->addFile('pmd/iecanvas.js', true);
153 $scripts->addFile('pmd/init.js');
155 require 'libraries/db_common.inc.php';
156 require 'libraries/db_info.inc.php';
158 // Embed some data into HTML, later it will be read
159 // by pmd/init.js and converted to JS variables.
161 PMA_getHtmlForJSFields(
162 $script_tables, $script_contr, $script_display_field, $display_page
166 PMA_getDesignerPageMenu(isset($_REQUEST['query']), $selected_page, $classes_side_menu)
171 $response->addHTML('<div id="canvas_outer">');
173 '<form action="" id="container-form" method="post" name="form1">'
176 $response->addHTML(PMA_getHTMLCanvas());
177 $response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
180 PMA_getDatabaseTables(
181 $tab_pos, $display_page, $tab_column,
182 $tables_all_keys, $tables_pk_or_unique_keys
185 $response->addHTML('</form>');
186 $response->addHTML('</div>'); // end canvas_outer
188 $response->addHTML('<div id="pmd_hint"></div>');
190 $response->addHTML(PMA_getNewRelationPanel());
191 $response->addHTML(PMA_getDeleteRelationPanel());
193 if (isset($_REQUEST['query'])) {
194 $response->addHTML(PMA_getOptionsPanel());
195 $response->addHTML(PMA_getRenameToPanel());
196 $response->addHTML(PMA_getHavingQueryPanel());
197 $response->addHTML(PMA_getAggregateQueryPanel());
198 $response->addHTML(PMA_getWhereQueryPanel());
199 $response->addHTML(PMA_getQueryDetails());
202 $response->addHTML('<div id="PMA_disable_floating_menubar"></div>');