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