Merge remote branch 'origin/master'
[phpmyadmin/dkf.git] / pmd_general.php
blobf87d62bee8cbe1e4c7ab2eb341483fb0b75120c2
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package phpMyAdmin-Designer
5 */
7 /**
9 */
10 require_once "./pmd_common.php";
12 $tab_column = get_tab_info();
13 $script_tabs = get_script_tabs();
14 $script_contr = get_script_contr();
15 $tab_pos = get_tab_pos();
16 $tables_pk_or_unique_keys = get_pk_or_unique_keys();
17 $tables_all_keys = get_all_keys();
18 $hidden = "hidden";
21 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
22 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23 <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][1]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][1]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
24 <head>
25 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset ?>" />
26 <link rel="icon" href="pmd/images/favicon.ico" type="image/x-icon" />
27 <link rel="shortcut icon" href="pmd/images/favicon.ico" type="image/x-icon" />
28 <link rel="stylesheet" type="text/css" href="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'] ?>/style1.css" />
29 <title>Designer</title>
30 <script type="text/javascript">
31 // <![CDATA[
32 <?php
33 echo '
34 var server = "' . PMA_escapeJsString($server) . '";
35 var db = "' . PMA_escapeJsString($db) . '";
36 var token = "' . PMA_escapeJsString($token) . '";';
39 // ]]>
40 </script>
41 <?php
42 $params = array('lang' => $GLOBALS['lang']);
43 if (isset($GLOBALS['db'])) {
44 $params['db'] = $GLOBALS['db'];
47 <script src="js/messages.php<?php echo PMA_generate_common_url($params); ?>" type="text/javascript"></script>
48 <script src="pmd/scripts/ajax.js" type="text/javascript"></script>
49 <script src="pmd/scripts/move.js" type="text/javascript"></script>
50 <!--[if IE]>
51 <script src="pmd/scripts/iecanvas.js" type="text/javascript"></script>
52 <![endif]-->
53 <?php
54 echo $script_tabs . $script_contr . $script_display_field;
57 </head>
58 <body onload="Main()" class="general_body" id="pmd_body">
60 <div class="header" id="top_menu">
61 <a href="javascript:Show_left_menu(document.getElementById('key_Show_left_menu'));"
62 onmousedown="return false;" class="M_butt first" target="_self">
63 <img id='key_Show_left_menu' title="<?php echo __('Show/Hide left menu'); ?>"
64 alt="v" src="pmd/images/downarrow2_m.png" /></a>
65 <a href="javascript:Save2();" onmousedown="return false;"
66 class="M_butt" target="_self"
67 ><img title="<?php echo __('Save position') ?>" src="pmd/images/save.png" alt=""
68 /></a><a href="javascript:Start_table_new();" onmousedown="return false;"
69 class="M_butt" target="_self"
70 ><img title="<?php echo __('Create table')?>" src="pmd/images/table.png" alt=""
71 /></a><a href="javascript:Start_relation();" onmousedown="return false;"
72 class="M_butt" id="rel_button" target="_self"
73 ><img title="<?php echo __('Create relation') ?>" src="pmd/images/relation.png" alt=""
74 /></a><a href="javascript:Start_display_field();" onmousedown="return false;"
75 class="M_butt" id="display_field_button" target="_self"
76 ><img title="<?php echo __('Choose column to display') ?>" src="pmd/images/display_field.png" alt=""
77 /></a><a href="javascript:location.reload();" onmousedown="return false;"
78 class="M_butt" target="_self"
79 ><img title="<?php echo __('Reload'); ?>" src="pmd/images/reload.png" alt=""
80 /></a><a href="javascript:Help();" onmousedown="return false;"
81 class="M_butt" target="_self"
82 ><img title="<?php echo __('Help'); ?>" src="pmd/images/help.png" alt=""
83 /></a><img class="M_bord" src="pmd/images/bord.png" alt=""
84 /><a href="javascript:Angular_direct();" onmousedown="return false;"
85 class="M_butt" id="angular_direct_button" target="_self"
86 ><img title="<?php echo __('Angular links') . ' / ' . __('Direct links'); ?>"
87 src="pmd/images/ang_direct.png" alt=""
88 /></a><a href="javascript:Grid();" onmousedown="return false;"
89 class="M_butt" id="grid_button" target="_self"
90 ><img title="<?php echo __('Snap to grid') ?>" src="pmd/images/grid.png" alt=""
91 /></a><img class="M_bord" src="pmd/images/bord.png" alt=""
92 /><a href="javascript:Small_tab_all(document.getElementById('key_SB_all'));"
93 onmousedown="return false;" class="M_butt" target="_self"
94 ><img id='key_SB_all' title="<?php echo __('Small/Big All'); ?>" alt="v"
95 src="pmd/images/downarrow1.png"
96 /></a><a href="javascript:Small_tab_invert();" onmousedown="return false;"
97 class="M_butt" target="_self"
98 ><img title="<?php echo __('Toggle small/big'); ?>" alt="key" src="pmd/images/bottom.png"
99 /></a><img class="M_bord" src="pmd/images/bord.png" alt=""
100 /><a href="javascript:PDF_save();" onmousedown="return false;"
101 class="M_butt" target="_self"
102 ><img src="pmd/images/pdf.png" alt="key" width="20" height="20"
103 title="<?php echo __('Import/Export coordinates for PDF schema'); ?>" /></a>
104 <a href="javascript:Top_menu_right(document.getElementById('key_Left_Right'));"
105 onmousedown="return false;" class="M_butt last" target="_self">
106 <img src="pmd/images/2rightarrow_m.png" id="key_Left_Right" alt=">"
107 title="<?php echo __('Move Menu'); ?>" /></a>
108 </div>
110 <div id="osn_tab">
111 <CANVAS id="canvas" width="100" height="100" onclick="Canvas_click(this)"></CANVAS>
112 </div>
114 <form action="" method="post" name="form1">
115 <div id="layer_menu" style="visibility:<?php echo $hidden ?>;">
116 <div align="center" style="padding-top:5px;">
117 <a href="javascript:Hide_tab_all(document.getElementById('key_HS_all'));"
118 onmousedown="return false;" class="M_butt" target="_self">
119 <img title="<?php echo __('Hide/Show all'); ?>" alt="v"
120 src="pmd/images/downarrow1.png" id='key_HS_all' /></a>
121 <a href="javascript:No_have_constr(document.getElementById('key_HS'));"
122 onmousedown="return false;" class="M_butt" target="_self">
123 <img title="<?php echo __('Hide/Show Tables with no relation'); ?>" alt="v"
124 src="pmd/images/downarrow2.png" id='key_HS' /></a>
125 </div>
127 <div id="id_scroll_tab" class="scroll_tab">
128 <table width="100%" style="padding-left: 3px;">
129 <?php
130 $name_cnt = count($GLOBALS['PMD']['TABLE_NAME']);
131 for ($i = 0; $i < $name_cnt; $i++) {
133 <tr><td title="<?php echo __('Structure'); ?>" width="1px"
134 onmouseover="this.className='L_butt2_2'"
135 onmouseout="this.className='L_butt2_1'">
136 <img onclick="Start_tab_upd('<?php echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]; ?>');"
137 src="pmd/images/exec.png" alt="" /></td>
138 <td width="1px">
139 <input onclick="VisibleTab(this,'<?php echo $GLOBALS['PMD_URL']["TABLE_NAME"][$i]; ?>')"
140 title="<?php echo __('Hide'); ?>"
141 id="check_vis_<?php echo $GLOBALS['PMD_URL']["TABLE_NAME"][$i]; ?>"
142 style="margin:0px;" type="checkbox"
143 value="<?php echo $GLOBALS['PMD_URL']["TABLE_NAME"][$i]; ?>"
144 <?php
145 if (isset($tab_pos[$GLOBALS['PMD']["TABLE_NAME"][$i]])) {
146 echo $tab_pos[$GLOBALS['PMD']["TABLE_NAME"][$i]]["H"] ? 'checked="checked"' : '';
147 } else {
148 echo 'checked="checked"';
150 ?> /></td>
151 <td class="Tabs" onmouseover="this.className='Tabs2'"
152 onmouseout="this.className='Tabs'"
153 onclick="Select_tab('<?php echo $GLOBALS['PMD_URL']["TABLE_NAME"][$i]; ?>');">
154 <?php echo $GLOBALS['PMD_OUT']["TABLE_NAME"][$i]; ?></td>
155 </tr>
156 <?php
159 </table>
160 </div>
162 <div align="center">
163 <?php echo __('Number of tables') . ': ' . $name_cnt; ?>
164 </div>
165 <div align="right">
166 <div id="layer_menu_sizer" onmousedown="layer_menu_cur_click=1">
167 </div>
168 </div>
169 </div>
170 <?php
171 for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
172 $t_n = $GLOBALS['PMD']["TABLE_NAME"][$i];
173 $t_n_url = $GLOBALS['PMD_URL']["TABLE_NAME"][$i];
176 <input name="t_x[<?php echo $t_n_url ?>]" type="hidden" id="t_x_<?php echo $t_n_url ?>_" />
177 <input name="t_y[<?php echo $t_n_url ?>]" type="hidden" id="t_y_<?php echo $t_n_url ?>_" />
178 <input name="t_v[<?php echo $t_n_url ?>]" type="hidden" id="t_v_<?php echo $t_n_url ?>_" />
179 <input name="t_h[<?php echo $t_n_url ?>]" type="hidden" id="t_h_<?php echo $t_n_url ?>_" />
181 <table id="<?php echo $t_n_url ?>" cellpadding="0" cellspacing="0" class="tab"
182 style="position: absolute;
183 left: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["X"]; else echo rand(180, 800); ?>px;
184 top: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["Y"]; else echo rand(30, 500); ?>px;
185 visibility: <?php if (isset($tab_pos[$t_n])) echo $tab_pos[$t_n]["H"] ? "visible" : "hidden"; ?>;
187 <thead>
188 <tr>
189 <td class="small_tab" onmouseover="this.className='small_tab2';"
190 onmouseout="this.className='small_tab';"
191 id="id_hide_tbody_<?php echo $t_n_url ?>"
192 onclick="Small_tab('<?php echo $t_n_url ?>', 1)"><?php
193 // no space alloawd here, between tags and content !!!
194 // JavaScript function does require this
195 if (! isset($tab_pos[$t_n]) || ! empty($tab_pos[$t_n]["V"])) {
196 echo 'v';
197 } else {
198 echo '&gt;';
200 ?></td>
201 <td class="small_tab_pref" onmouseover="this.className='small_tab_pref2';"
202 onmouseout="this.className='small_tab_pref';"
203 onclick="Start_tab_upd('<?php echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]; ?>');">
204 <img src="pmd/images/exec_small.png" alt="" /></td>
205 <td nowrap="nowrap" id="id_zag_<?php echo $t_n_url ?>" class="tab_zag"
206 onmousedown="cur_click=document.getElementById('<?php echo $t_n_url ?>');"
207 onmouseover="this.className = 'tab_zag_2'"
208 onmouseout="this.className = 'tab_zag'">
209 <span class='owner'>
210 <?php
211 echo $GLOBALS['PMD_OUT']["OWNER"][$i];
212 echo '.</span>';
213 echo $GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i];
214 ?></td>
215 </tr>
216 </thead>
217 <tbody id="id_tbody_<?php echo $t_n_url ?>"
218 <?php if ( isset($tab_pos[$t_n])) echo 'style="display: none;"'; ?>>
219 <?php
220 $display_field = PMA_getDisplayField($db, $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]);
221 for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++) {
223 <tr id="id_tr_<?php
224 echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . '.'
225 . urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) ?>"
226 <?php
227 if ($display_field == $tab_column[$t_n]["COLUMN_NAME"][$j]) {
228 echo ' class="tab_field_3" ';
229 } else {
230 echo ' class="tab_field" ';
233 onmouseover="old_class = this.className; this.className = 'tab_field_2';"
234 onmouseout="this.className = old_class;"
235 onmousedown="Click_field('<?php
236 echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]."','".urlencode($tab_column[$t_n]["COLUMN_NAME"][$j])."',";
237 if (! PMA_foreignkey_supported($GLOBALS['PMD']['TABLE_TYPE'][$i])) {
238 echo (isset($tables_pk_or_unique_keys[$t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j]]) ? 1 : 0);
239 } else {
240 // if foreign keys are supported, it's not necessary that the
241 // index is a primary key
242 echo (isset($tables_all_keys[$t_n.".".$tab_column[$t_n]["COLUMN_NAME"][$j]]) ? 1 : 0);
244 ?>)">
245 <td width="10px" colspan="3"
246 id="<?php echo $t_n_url.".".urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) ?>">
247 <div style="white-space:nowrap">
248 <?php
249 if (isset($tables_pk_or_unique_keys[$t_n.".".$tab_column[$t_n]["COLUMN_NAME"][$j]])) {
251 <img src="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE'];?>/images/FieldKey_small.png"
252 alt="*" />
253 <?php
254 } else {
256 <img src="pmd/styles/<?php echo $GLOBALS['PMD']['STYLE']?>/images/Field_small<?php
257 if (strstr($tab_column[$t_n]["TYPE"][$j],'char')
258 || strstr($tab_column[$t_n]["TYPE"][$j],'text')) {
259 echo '_char';
260 } elseif (strstr($tab_column[$t_n]["TYPE"][$j],'int')
261 || strstr($tab_column[$t_n]["TYPE"][$j],'float')
262 || strstr($tab_column[$t_n]["TYPE"][$j],'double')
263 || strstr($tab_column[$t_n]["TYPE"][$j],'decimal')) {
264 echo '_int';
265 } elseif (strstr($tab_column[$t_n]["TYPE"][$j],'date')
266 || strstr($tab_column[$t_n]["TYPE"][$j],'time')
267 || strstr($tab_column[$t_n]["TYPE"][$j],'year')) {
268 echo '_date';
270 ?>.png" alt="*" />
271 <?php
273 echo htmlspecialchars($tab_column[$t_n]["COLUMN_NAME"][$j]
274 . " : " . $tab_column[$t_n]["TYPE"][$j], ENT_QUOTES);
276 </div>
277 </td>
278 </tr>
279 <?php
282 </tbody>
283 </table>
284 <?php
287 </form>
288 <div id="hint"></div>
289 <div id='layer_action' style="visibility:<?php echo $hidden ?>;">Load...</div>
291 <table id="layer_new_relation" style="visibility:<?php echo $hidden ?>;"
292 width="5%" border="0" cellpadding="0" cellspacing="0">
293 <tbody>
294 <tr>
295 <td class="frams1" width="10px"></td>
296 <td class="frams5" width="99%" ></td>
297 <td class="frams2" width="10px"><div class="bor"></div></td>
298 </tr>
299 <tr>
300 <td class="frams8"></td>
301 <td class="input_tab">
302 <table width="168" border="0" align="center" cellpadding="2" cellspacing="0">
303 <thead>
304 <tr>
305 <td colspan="2" align="center" nowrap="nowrap"><strong><?php echo __('Create relation'); ?></strong></td>
306 </tr>
307 </thead>
308 <tbody id="foreign_relation">
309 <tr>
310 <td colspan="2" align="center" nowrap="nowrap"><strong>FOREIGN KEY</strong></td>
311 </tr>
312 <tr>
313 <td width="58" nowrap="nowrap">on delete</td>
314 <td width="102"><select name="on_delete" id="on_delete">
315 <option value="nix" selected="selected">--</option>
316 <option value="CASCADE">CASCADE</option>
317 <option value="SET NULL">SET NULL</option>
318 <option value="NO ACTION">NO ACTION</option>
319 <option value="RESTRICT">RESTRICT</option>
320 </select>
321 </td>
322 </tr>
323 <tr>
324 <td nowrap="nowrap">on update</td>
325 <td><select name="on_update" id="on_update">
326 <option value="nix" selected="selected">--</option>
327 <option value="CASCADE">CASCADE</option>
328 <option value="SET NULL">SET NULL</option>
329 <option value="NO ACTION">NO ACTION</option>
330 <option value="RESTRICT">RESTRICT</option>
331 </select>
332 </td>
333 </tr>
334 </tbody>
335 <tbody>
336 <tr>
337 <td colspan="2" align="center" nowrap="nowrap">
338 <input type="button" class="butt" name="Button"
339 value="<?php echo __('OK'); ?>" onclick="New_relation()" />
340 <input type="button" class="butt" name="Button"
341 value="<?php echo __('Cancel'); ?>"
342 onclick="document.getElementById('layer_new_relation').style.visibility = 'hidden';" />
343 </td>
344 </tr>
345 </tbody>
346 </table>
347 </td>
348 <td class="frams6"></td>
349 </tr>
350 <tr>
351 <td class="frams4"><div class="bor"></div></td>
352 <td class="frams7"></td>
353 <td class="frams3"></td>
354 </tr>
355 </tbody>
356 </table>
358 <table id="layer_upd_relation" style="visibility:<?PHP echo $hidden ?>;"
359 width="5%" border="0" cellpadding="0" cellspacing="0">
360 <tbody>
361 <tr>
362 <td class="frams1" width="10px"></td>
363 <td class="frams5" width="99%"></td>
364 <td class="frams2" width="10px"><div class="bor"></div></td>
365 </tr>
366 <tr>
367 <td class="frams8"></td>
368 <td class="input_tab">
369 <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
370 <tr>
371 <td colspan="3" align="center" nowrap="nowrap"><strong><?php echo __('Delete relation'); ?></strong></td>
372 </tr>
373 <tr>
374 <td colspan="3" align="center" nowrap="nowrap">
375 <input name="Button" type="button" class="butt"
376 onclick="Upd_relation()" value="<?php echo __('Delete'); ?>" />
377 <input type="button" class="butt" name="Button"
378 value="<?php echo __('Cancel'); ?>"
379 onclick="document.getElementById('layer_upd_relation').style.visibility = 'hidden'; Re_load();" />
380 </td>
381 </tr>
382 </table></td>
383 <td class="frams6"></td>
384 </tr>
385 <tr>
386 <td class="frams4"><div class="bor"></div></td>
387 <td class="frams7"></td>
388 <td class="frams3"></td>
389 </tr>
390 </tbody>
391 </table>
392 <!-- cache images -->
393 <img src="pmd/images/2leftarrow_m.png" width="0" height="0" alt="" />
394 <img src="pmd/images/rightarrow1.png" width="0" height="0" alt="" />
395 <img src="pmd/images/rightarrow2.png" width="0" height="0" alt="" />
396 <img src="pmd/images/uparrow2_m.png" width="0" height="0" alt="" />
397 </body>
398 </html>