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