Translated using Weblate (Italian)
[phpmyadmin.git] / db_designer.php
blob2582048285e2fed08cecb5a8ff906cf49784fa7b
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 $result = PMA_deletePage($_REQUEST['selected_page']);
40 if ($result) {
41 $response->isSuccess(true);
42 } else {
43 $response->isSuccess(false);
45 } elseif ($_REQUEST['operation'] == 'savePage') {
46 if ($_REQUEST['save_page'] == 'same') {
47 $page = $_REQUEST['selected_page'];
48 } else { // new
49 $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
50 $response->addJSON('id', $page);
52 if (PMA_saveTablePositions($page)) {
53 $response->isSuccess(true);
54 } else {
55 $response->isSuccess(false);
57 } elseif ($_REQUEST['operation'] == 'setDisplayField') {
58 PMA_saveDisplayField(
59 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['field']
61 $response->isSuccess(true);
62 } elseif ($_REQUEST['operation'] == 'addNewRelation') {
63 list($success, $message) = PMA_addNewRelation(
64 $_REQUEST['db'],
65 $_REQUEST['T1'],
66 $_REQUEST['F1'],
67 $_REQUEST['T2'],
68 $_REQUEST['F2'],
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(
76 $_REQUEST['T1'],
77 $_REQUEST['F1'],
78 $_REQUEST['T2'],
79 $_REQUEST['F2']
81 $response->isSuccess($success);
82 $response->addJSON('message', $message);
84 return;
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();
93 $display_page = -1;
94 $selected_page = null;
96 if (! isset($_REQUEST['query'])) {
97 if (! empty($_REQUEST['page'])) {
98 $display_page = $_REQUEST['page'];
99 } else {
100 $display_page = PMA_getFirstPage($_REQUEST['db']);
103 if ($display_page != -1) {
104 $selected_page = PMA_getPageName($display_page);
106 $tab_pos = PMA_getTablePositions($display_page);
107 $script_contr = PMA_getScriptContr();
109 $params = array('lang' => $GLOBALS['lang']);
110 if (isset($_GET['db'])) {
111 $params['db'] = $_GET['db'];
114 $response = PMA_Response::getInstance();
115 $response->getFooter()->setMinimal();
116 $header = $response->getHeader();
117 $header->setBodyId('pmd_body');
119 $scripts = $header->getScripts();
120 $scripts->addFile('jquery/jquery.fullscreen.js');
121 $scripts->addFile('pmd/designer_db.js');
122 $scripts->addFile('pmd/designer_objects.js');
123 $scripts->addFile('pmd/designer_page.js');
124 $scripts->addFile('pmd/history.js');
125 $scripts->addFile('pmd/move.js');
126 $scripts->addFile('pmd/iecanvas.js', true);
127 $scripts->addFile('pmd/init.js');
129 require 'libraries/db_common.inc.php';
130 require 'libraries/db_info.inc.php';
132 // Embed some data into HTML, later it will be read
133 // by pmd/init.js and converted to JS variables.
134 $response->addHTML(
135 PMA_getHtmlForJSFields(
136 $script_tables, $script_contr, $script_display_field, $display_page
139 $response->addHTML(
140 PMA_getDesignerPageMenu(isset($_REQUEST['query']), $selected_page)
143 $response->addHTML('<div id="canvas_outer">');
144 $response->addHTML('<form action="" id="container-form" method="post" name="form1">');
146 $response->addHTML(PMA_getHTMLCanvas());
147 $response->addHTML(PMA_getHTMLTableList($tab_pos, $display_page));
149 $response->addHTML(
150 PMA_getDatabaseTables(
151 $tab_pos, $display_page, $tab_column,
152 $tables_all_keys, $tables_pk_or_unique_keys
155 $response->addHTML('</form>');
156 $response->addHTML('</div>'); // end canvas_outer
158 $response->addHTML('<div id="pmd_hint"></div>');
160 $response->addHTML(PMA_getNewRelationPanel());
161 $response->addHTML(PMA_getDeleteRelationPanel());
163 if (isset($_REQUEST['query'])) {
164 $response->addHTML(PMA_getOptionsPanel());
165 $response->addHTML(PMA_getRenameToPanel());
166 $response->addHTML(PMA_getHavingQueryPanel());
167 $response->addHTML(PMA_getAggregateQueryPanel());
168 $response->addHTML(PMA_getWhereQueryPanel());
169 $response->addHTML(PMA_getQueryDetails());
172 $response->addHTML(PMA_getCacheImages());