addHTML($html); } return; } if (isset($_REQUEST['operation'])) { if ($_REQUEST['operation'] == 'deletePage') { $result = PMA_deletePage($_REQUEST['selected_page']); if ($result) { $response->isSuccess(true); } else { $response->isSuccess(false); } } elseif ($_REQUEST['operation'] == 'savePage') { if ($_REQUEST['save_page'] == 'same') { $page = $_REQUEST['selected_page']; } else { // new $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']); $response->addJSON('id', $page); } if (PMA_saveTablePositions($page)) { $response->isSuccess(true); } else { $response->isSuccess(false); } } elseif ($_REQUEST['operation'] == 'setDisplayField') { PMA_saveDisplayField( $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field'] ); $response->isSuccess(true); } elseif ($_REQUEST['operation'] == 'addNewRelation') { list($success, $message) = PMA_addNewRelation( $_REQUEST['db'], $_REQUEST['T1'], $_REQUEST['F1'], $_REQUEST['T2'], $_REQUEST['F2'], $_REQUEST['on_delete'], $_REQUEST['on_update'] ); $response->isSuccess($success); $response->addJSON('message', $message); } elseif ($_REQUEST['operation'] == 'removeRelation') { list($success, $message) = PMA_removeRelation( $_REQUEST['T1'], $_REQUEST['F1'], $_REQUEST['T2'], $_REQUEST['F2'] ); $response->isSuccess($success); $response->addJSON('message', $message); } elseif ($_REQUEST['operation'] == 'save_setting_value') { $cfgRelation = PMA_getRelationsParam(); $cfgDesigner = array( 'user' => $GLOBALS['cfg']['Server']['user'], 'db' => $cfgRelation['db'], 'table' => $cfgRelation['designer_settings'] ); if (! empty($cfgDesigner['user']) && ! empty($cfgDesigner['db']) && ! empty($cfgDesigner['table']) && $GLOBALS['cfgRelation']['designersettingswork'] ) { $orig_data_query = 'SELECT ' . PMA_Util::backquote('settings_data') . ' FROM `' . $cfgDesigner['db'] . '`.`' . $cfgDesigner['table'] . '` WHERE ' . PMA_Util::backquote('username') . ' = "' . $cfgDesigner['user'] . '"'; $orig_data = $GLOBALS['dbi']->fetchSingleRow($orig_data_query); $success = false; if (isset($orig_data) && ! empty($orig_data) && $orig_data ) { $orig_data = json_decode($orig_data['settings_data'], true); $orig_data[$_REQUEST['index']] = $_REQUEST['value']; $orig_data = json_encode($orig_data); $save_query = 'UPDATE `' . $cfgDesigner['db'] . '`.`' . $cfgDesigner['table'] . '` SET ' . PMA_Util::backquote('settings_data') . ' = \'' . $orig_data . '\' WHERE ' . PMA_Util::backquote('username') . ' = "' . $cfgDesigner['user'] . '";'; $success = $GLOBALS['dbi']->query($save_query); } else { $save_data = array($_REQUEST['index'] => $_REQUEST['value']); $query = 'INSERT INTO ' . PMA_Util::backquote($cfgDesigner['db']) . '.' . PMA_Util::backquote($cfgDesigner['table']) . ' VALUES("' . PMA_Util::sqlAddSlashes($cfgDesigner['user']) . '", \'' . PMA_Util::sqlAddSlashes(json_encode($save_data)) . '\');'; $success = $GLOBALS['dbi']->query($query); } $response->isSuccess($success); } } return; } $script_display_field = PMA_getTablesInfo(); $tab_column = PMA_getColumnsInfo(); $script_tables = PMA_getScriptTabs(); $tables_pk_or_unique_keys = PMA_getPKOrUniqueKeys(); $tables_all_keys = PMA_getAllKeys(); $classes_side_menu = PMA_returnClassNamesFromMenuButtons(); $display_page = -1; $selected_page = null; if (isset($_REQUEST['query'])) { $display_page = PMA_getDefaultPage($_REQUEST['db']); } else { if (! empty($_REQUEST['page'])) { $display_page = $_REQUEST['page']; } else { $display_page = PMA_getLoadingPage($_REQUEST['db']); } } if ($display_page != -1) { $selected_page = PMA_getPageName($display_page); } $tab_pos = PMA_getTablePositions($display_page); $script_contr = PMA_getScriptContr(); $params = array('lang' => $GLOBALS['lang']); if (isset($_GET['db'])) { $params['db'] = $_GET['db']; } $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setBodyId('pmd_body'); $scripts = $header->getScripts(); $scripts->addFile('jquery/jquery.fullscreen.js'); $scripts->addFile('pmd/designer_db.js'); $scripts->addFile('pmd/designer_objects.js'); $scripts->addFile('pmd/designer_page.js'); $scripts->addFile('pmd/history.js'); $scripts->addFile('pmd/move.js'); $scripts->addFile('pmd/iecanvas.js', true); $scripts->addFile('pmd/init.js'); require 'libraries/db_common.inc.php'; require 'libraries/db_info.inc.php'; // Embed some data into HTML, later it will be read // by pmd/init.js and converted to JS variables. $response->addHTML( PMA_getHtmlForJSFields( $script_tables, $script_contr, $script_display_field, $display_page ) ); $response->addHTML( PMA_getDesignerPageMenu(isset($_REQUEST['query']), $selected_page, $classes_side_menu) ); $response->addHTML('