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 $script_display_field = PMA_getTablesInfo();
14 $tab_column = PMA_getColumnsInfo();
15 $script_tables = PMA_getScriptTabs();
16 $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys();
17 $tables_all_keys = PMA_getAllKeys();
20 $response = PMA_Response
::getInstance();
22 if (isset($_REQUEST['dialog'])) {
24 if ($_REQUEST['dialog'] == 'edit') {
25 $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'editPage');
26 } else if ($_REQUEST['dialog'] == 'delete') {
27 $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'deletePage');
28 } else if ($_REQUEST['dialog'] == 'save_as') {
29 $html = PMA_getHtmlForPageSaveAs($GLOBALS['db']);
30 } else if ($_REQUEST['dialog'] == 'export') {
31 include_once 'libraries/plugin_interface.lib.php';
32 $html = PMA_getHtmlForSchemaExport(
33 $GLOBALS['db'], $_REQUEST['selected_page']
37 $response->addHTML($html);
41 if (isset($_REQUEST['operation'])) {
43 if ($_REQUEST['operation'] == 'deletePage') {
44 $result = PMA_deletePage($_REQUEST['selected_page']);
46 $response->isSuccess(true);
48 $response->isSuccess(false);
50 } elseif ($_REQUEST['operation'] == 'savePage') {
51 if ($_REQUEST['save_page'] == 'same') {
52 $page = $_REQUEST['selected_page'];
53 } elseif ($_REQUEST['save_page'] == 'new') {
54 $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
55 $response->addJSON('id', $page);
57 if (PMA_saveTablePositions($page)) {
58 $response->isSuccess(true);
60 $response->isSuccess(false);
62 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
64 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
66 $response->isSuccess(true);
67 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
68 list($success, $message) = PMA_addNewRelation(
74 $_REQUEST['on_delete'],
75 $_REQUEST['on_update']
77 $response->isSuccess($success);
78 $response->addJSON($success ?
'message' : 'error', $message);
79 } elseif ($_REQUEST['operation'] == 'removeRelation') {
86 $response->isSuccess(true);
90 if (! empty($_REQUEST['page'])) {
91 $display_page = $_REQUEST['page'];
93 $display_page = PMA_getFirstPage($_REQUEST['db']);
97 $tab_pos = PMA_getTablePositions($display_page);
98 $selected_page = PMA_getPageName($display_page);
99 $script_contr = PMA_getScriptContr();
101 $params = array('lang' => $GLOBALS['lang']);
102 if (isset($_GET['db'])) {
103 $params['db'] = $_GET['db'];
106 $response = PMA_Response
::getInstance();
107 $response->getFooter()->setMinimal();
108 $header = $response->getHeader();
109 $header->setBodyId('pmd_body');
111 $scripts = $header->getScripts();
112 $scripts->addFile('jquery/jquery.fullscreen.js');
113 $scripts->addFile('pmd/designer_db.js');
114 $scripts->addFile('pmd/designer_objects.js');
115 $scripts->addFile('pmd/designer_page.js');
116 $scripts->addFile('pmd/history.js');
117 $scripts->addFile('pmd/move.js');
118 $scripts->addFile('pmd/iecanvas.js', true);
119 $scripts->addFile('pmd/init.js');
121 require 'libraries/db_common.inc.php';
122 require 'libraries/db_info.inc.php';
124 // Embed some data into HTML, later it will be read
125 // by pmd/init.js and converted to JS variables.
127 PMA_getHtmlForJSFields(
128 $script_tables, $script_contr, $script_display_field, $display_page
131 $response->addHTML(PMA_getDesignerPageTopMenu($selected_page));
133 $response->addHTML('<div id="canvas_outer">');
134 $response->addHTML('<form action="" method="post" name="form1">');
136 $response->addHTML(PMA_getHTMLCanvas());
137 $response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
140 PMA_getDatabaseTables(
141 $tab_pos, $display_page, $tab_column,
142 $tables_all_keys, $tables_pk_or_unique_keys
145 $response->addHTML('</form>');
146 $response->addHTML('</div>'); // end canvas_outer
148 $response->addHTML('<div id="pmd_hint"></div>');
150 $response->addHTML(PMA_getNewRelationPanel());
151 $response->addHTML(PMA_getDeleteRelationPanel());
153 $response->addHTML(PMA_getOptionsPanel());
154 $response->addHTML(PMA_getRenameToPanel());
155 $response->addHTML(PMA_getHavingQueryPanel());
156 $response->addHTML(PMA_getAggregateQueryPanel());
157 $response->addHTML(PMA_getWhereQueryPanel());
158 if (! empty($_REQUEST['query'])) {
159 $response->addHTML(PMA_getQueryDetails());
162 $response->addHTML(PMA_getCacheImages());