Remove old onchange attribute
[phpmyadmin/mlewandow.git] / browse_foreigners.php
bloba936d60811e29c5c75a080938ac3847774b91790
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * display selection for relational field values
6 * @package phpMyAdmin
7 */
9 /**
10 * Gets a core script and starts output buffering work
12 require_once './libraries/common.inc.php';
14 PMA_checkParameters(array('db', 'table', 'field'));
16 require_once './libraries/ob.lib.php';
17 PMA_outBufferPre();
19 require_once './libraries/header_http.inc.php';
21 /**
22 * Displays the frame
24 require_once './libraries/transformations.lib.php'; // Transformations
25 $cfgRelation = PMA_getRelationsParam();
26 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
28 $override_total = TRUE;
30 if (!isset($pos)) {
31 $pos = 0;
34 $foreign_limit = 'LIMIT ' . $pos . ', ' . $GLOBALS['cfg']['MaxRows'] . ' ';
35 if (isset($foreign_navig) && $foreign_navig == __('Show all')) {
36 unset($foreign_limit);
39 $foreignData = PMA_getForeignData($foreigners, $field, $override_total, isset($foreign_filter) ? $foreign_filter : '', $foreign_limit);
41 if (isset($rownumber)) {
42 $rownumber_param = '&amp;rownumber=' . urlencode($rownumber);
43 } else {
44 $rownumber_param = '';
47 $gotopage = '';
48 $showall = '';
50 if (is_array($foreignData['disp_row'])) {
52 if ($cfg['ShowAll'] && ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows'])) {
53 $showall = '<input type="submit" name="foreign_navig" value="' . __('Show all') . '" />';
56 $session_max_rows = $GLOBALS['cfg']['MaxRows'];
57 $pageNow = @floor($pos / $session_max_rows) + 1;
58 $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);
60 if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) {
61 $gotopage = PMA_pageselector(
62 'browse_foreigners.php?field=' . urlencode($field) .
63 '&amp;' . PMA_generate_common_url($db, $table)
64 . $rownumber_param .
65 '&amp;fieldkey=' . (isset($fieldkey) ? urlencode($fieldkey) : '') .
66 '&amp;foreign_filter=' . (isset($foreign_filter) ? urlencode($foreign_filter) : '') .
67 '&amp;',
68 $session_max_rows,
69 $pageNow,
70 $nbTotalPage,
71 200,
74 20,
75 10,
76 __('Page number:')
81 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
82 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
83 <html xmlns="http://www.w3.org/1999/xhtml"
84 xml:lang="<?php echo $available_languages[$lang][1]; ?>"
85 lang="<?php echo $available_languages[$lang][1]; ?>"
86 dir="<?php echo $text_dir; ?>">
88 <head>
89 <title>phpMyAdmin</title>
90 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
91 <link rel="stylesheet" type="text/css"
92 href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&amp;js_frame=right&amp;nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
93 <?php
94 // includes everything asked for by libraries/common.inc.php
95 require_once './libraries/header_scripts.inc.php';
97 <script type="text/javascript">
98 //<![CDATA[
99 self.focus();
100 function formupdate(fieldmd5, key) {
101 var $inline = window.opener.jQuery('.browse_foreign_clicked');
102 if ($inline.length != 0) {
103 $inline.removeClass('browse_foreign_clicked')
104 // puts new value in the previous element which is
105 // a span with class curr_value
106 .prev().text(key);
107 self.close();
108 return false;
111 if (opener && opener.document && opener.document.insertForm) {
112 var field = 'fields';
114 <?php if (isset($rownumber)) { ?>
115 var element_name = field + '[multi_edit][<?php echo htmlspecialchars($rownumber); ?>][' + fieldmd5 + ']';
116 <?php } else { ?>
117 var element_name = field + '[]';
118 <?php } ?>
120 <?php if (isset($fieldkey) && is_numeric($fieldkey)) { ?>
121 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
122 <?php } else { ?>
123 var element_name_alt = field + '[0]';
124 <?php } ?>
126 if (opener.document.insertForm.elements[element_name]) {
127 // Edit/Insert form
128 opener.document.insertForm.elements[element_name].value = key;
129 self.close();
130 return false;
131 } else if (opener.document.insertForm.elements[element_name_alt]) {
132 // Search form
133 opener.document.insertForm.elements[element_name_alt].value = key;
134 self.close();
135 return false;
139 alert('<?php echo PMA_jsFormat(__('The target browser window could not be updated. Maybe you have closed the parent window, or your browser\'s security settings are configured to block cross-window updates.')); ?>');
141 //]]>
142 </script>
143 </head>
145 <body id="body_browse_foreigners">
147 <form action="browse_foreigners.php" method="post">
148 <fieldset>
149 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
150 <input type="hidden" name="field" value="<?php echo htmlspecialchars($field); ?>" />
151 <input type="hidden" name="fieldkey"
152 value="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
153 <?php if (isset($rownumber)) { ?>
154 <input type="hidden" name="rownumber" value="<?php echo htmlspecialchars($rownumber); ?>" />
155 <?php } ?>
156 <span class="formelement">
157 <label for="input_foreign_filter"><?php echo __('Search') . ':'; ?></label>
158 <input type="text" name="foreign_filter" id="input_foreign_filter"
159 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
160 <input type="submit" name="submit_foreign_filter" value="<?php echo __('Go');?>" />
161 </span>
162 <span class="formelement">
163 <?php echo $gotopage; ?>
164 </span>
165 <span class="formelement">
166 <?php echo $showall; ?>
167 </span>
168 </fieldset>
169 </form>
171 <table width="100%">
172 <?php
173 if (is_array($foreignData['disp_row'])) {
174 $header = '<tr>
175 <th>' . __('Keyname') . '</th>
176 <th>' . __('Description') . '</th>
177 <td width="20%"></td>
178 <th>' . __('Description') . '</th>
179 <th>' . __('Keyname') . '</th>
180 </tr>';
182 echo '<thead>' . $header . '</thead>' . "\n"
183 .'<tfoot>' . $header . '</tfoot>' . "\n"
184 .'<tbody>' . "\n";
186 $values = array();
187 $keys = array();
188 foreach ($foreignData['disp_row'] as $relrow) {
189 if ($foreignData['foreign_display'] != FALSE) {
190 $values[] = $relrow[$foreignData['foreign_display']];
191 } else {
192 $values[] = '';
195 $keys[] = $relrow[$foreignData['foreign_field']];
198 asort($keys);
200 $hcount = 0;
201 $odd_row = true;
202 $val_ordered_current_row = 0;
203 $val_ordered_current_equals_data = false;
204 $key_ordered_current_equals_data = false;
205 foreach ($keys as $key_ordered_current_row => $value) {
206 //for ($i = 0; $i < $count; $i++) {
207 $hcount++;
209 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
210 echo $header;
211 $hcount = 0;
212 $odd_row = true;
215 $key_ordered_current_key = $keys[$key_ordered_current_row];
216 $key_ordered_current_val = $values[$key_ordered_current_row];
218 $val_ordered_current_key = $keys[$val_ordered_current_row];
219 $val_ordered_current_val = $values[$val_ordered_current_row];
221 $val_ordered_current_row++;
223 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
224 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
225 $val_ordered_current_val_title = '';
226 } else {
227 $val_ordered_current_val_title =
228 htmlspecialchars($val_ordered_current_val);
229 $val_ordered_current_val =
230 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
231 $cfg['LimitChars']) . '...');
233 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
234 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
235 $key_ordered_current_val_title = '';
236 } else {
237 $key_ordered_current_val_title =
238 htmlspecialchars($key_ordered_current_val);
239 $key_ordered_current_val =
240 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
241 $cfg['LimitChars']) . '...');
244 if (! empty($data)) {
245 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
246 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
250 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
251 <td nowrap="nowrap">
252 <?php
253 echo ($key_ordered_current_equals_data ? '<strong>' : '')
254 .'<a href="#" title="' . __('Use this value')
255 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
256 .' onclick="formupdate(\'' . md5($field) . '\', \''
257 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
258 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</strong>' : '');
259 ?></td>
260 <td>
261 <?php
262 echo ($key_ordered_current_equals_data ? '<strong>' : '')
263 . '<a href="#" title="' . __('Use this value') . ($key_ordered_current_val_title != '' ? ': '
264 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
265 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
266 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</strong>' : '');
267 ?></td>
268 <td width="20%">
269 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
270 alt="" width="1" height="1" /></td>
272 <td>
273 <?php
274 echo ($val_ordered_current_equals_data ? '<strong>' : '')
275 . '<a href="#" title="' . __('Use this value') . ($val_ordered_current_val_title != '' ? ': '
276 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
277 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
278 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</strong>' : '');
279 ?></td>
280 <td nowrap="nowrap">
281 <?php
282 echo ($val_ordered_current_equals_data ? '<strong>' : '') . '<a href="#" title="'
283 . __('Use this value') . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
284 . '" onclick="formupdate(\'' . md5($field) . '\', \''
285 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
286 . '</a>' . ($val_ordered_current_equals_data ? '</strong>' : '');
287 ?></td>
288 </tr>
289 <?php
290 } // end while
293 </tbody>
294 </table>
296 </body>
297 </html>