Translation update done using Pootle.
[phpmyadmin.git] / browse_foreigners.php
blob3eff09f4c9997dee86ef26875ea7eb9983fa4255
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 $session_max_rows,
63 $pageNow,
64 $nbTotalPage,
65 200,
68 20,
69 10,
70 __('Page number:')
75 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
76 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
77 <html xmlns="http://www.w3.org/1999/xhtml"
78 xml:lang="<?php echo $available_languages[$lang][1]; ?>"
79 lang="<?php echo $available_languages[$lang][1]; ?>"
80 dir="<?php echo $text_dir; ?>">
82 <head>
83 <title>phpMyAdmin</title>
84 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
85 <link rel="stylesheet" type="text/css"
86 href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&amp;js_frame=right&amp;nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
87 <?php
88 // includes everything asked for by libraries/common.inc.php
89 require_once './libraries/header_scripts.inc.php';
91 <script type="text/javascript">
92 //<![CDATA[
93 self.focus();
94 function formupdate(fieldmd5, key) {
95 var $inline = window.opener.jQuery('.browse_foreign_clicked');
96 if ($inline.length != 0) {
97 $inline.removeClass('browse_foreign_clicked')
98 // for grid editing,
99 // puts new value in the previous element which is
100 // a span with class curr_value
101 .prev('.curr_value').text(key);
102 // for zoom-search editing, puts new value in the previous
103 // element which is an input field
104 $inline.prev('input[type=text]').val(key);
105 self.close();
106 return false;
109 if (opener && opener.document && opener.document.insertForm) {
110 var field = 'fields';
111 var field_null = 'fields_null';
113 <?php if (isset($rownumber)) { ?>
114 var element_name = field + '[multi_edit][<?php echo htmlspecialchars($rownumber); ?>][' + fieldmd5 + ']';
115 var null_name = field_null + '[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 if (opener.document.insertForm.elements[null_name]) {
130 opener.document.insertForm.elements[null_name].checked = false;
132 self.close();
133 return false;
134 } else if (opener.document.insertForm.elements[element_name_alt]) {
135 // Search form
136 opener.document.insertForm.elements[element_name_alt].value = key;
137 self.close();
138 return false;
142 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.')); ?>');
144 //]]>
145 </script>
146 </head>
148 <body id="body_browse_foreigners">
150 <form action="browse_foreigners.php" method="post">
151 <fieldset>
152 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
153 <input type="hidden" name="field" value="<?php echo htmlspecialchars($field); ?>" />
154 <input type="hidden" name="fieldkey"
155 value="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
156 <?php if (isset($rownumber)) { ?>
157 <input type="hidden" name="rownumber" value="<?php echo htmlspecialchars($rownumber); ?>" />
158 <?php } ?>
159 <span class="formelement">
160 <label for="input_foreign_filter"><?php echo __('Search') . ':'; ?></label>
161 <input type="text" name="foreign_filter" id="input_foreign_filter"
162 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
163 <input type="submit" name="submit_foreign_filter" value="<?php echo __('Go');?>" />
164 </span>
165 <span class="formelement">
166 <?php echo $gotopage; ?>
167 </span>
168 <span class="formelement">
169 <?php echo $showall; ?>
170 </span>
171 </fieldset>
172 </form>
174 <table width="100%">
175 <?php
176 if (is_array($foreignData['disp_row'])) {
177 $header = '<tr>
178 <th>' . __('Keyname') . '</th>
179 <th>' . __('Description') . '</th>
180 <td width="20%"></td>
181 <th>' . __('Description') . '</th>
182 <th>' . __('Keyname') . '</th>
183 </tr>';
185 echo '<thead>' . $header . '</thead>' . "\n"
186 .'<tfoot>' . $header . '</tfoot>' . "\n"
187 .'<tbody>' . "\n";
189 $values = array();
190 $keys = array();
191 foreach ($foreignData['disp_row'] as $relrow) {
192 if ($foreignData['foreign_display'] != false) {
193 $values[] = $relrow[$foreignData['foreign_display']];
194 } else {
195 $values[] = '';
198 $keys[] = $relrow[$foreignData['foreign_field']];
201 asort($keys);
203 $hcount = 0;
204 $odd_row = true;
205 $val_ordered_current_row = 0;
206 $val_ordered_current_equals_data = false;
207 $key_ordered_current_equals_data = false;
208 foreach ($keys as $key_ordered_current_row => $value) {
209 //for ($i = 0; $i < $count; $i++) {
210 $hcount++;
212 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
213 echo $header;
214 $hcount = 0;
215 $odd_row = true;
218 $key_ordered_current_key = $keys[$key_ordered_current_row];
219 $key_ordered_current_val = $values[$key_ordered_current_row];
221 $val_ordered_current_key = $keys[$val_ordered_current_row];
222 $val_ordered_current_val = $values[$val_ordered_current_row];
224 $val_ordered_current_row++;
226 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
227 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
228 $val_ordered_current_val_title = '';
229 } else {
230 $val_ordered_current_val_title
231 = htmlspecialchars($val_ordered_current_val);
232 $val_ordered_current_val = htmlspecialchars(
233 PMA_substr($val_ordered_current_val, 0, $cfg['LimitChars'])
234 . '...'
237 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
238 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
239 $key_ordered_current_val_title = '';
240 } else {
241 $key_ordered_current_val_title
242 = htmlspecialchars($key_ordered_current_val);
243 $key_ordered_current_val
244 = htmlspecialchars(
245 PMA_substr($key_ordered_current_val, 0, $cfg['LimitChars']) . '...'
249 if (! empty($data)) {
250 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
251 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
255 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
256 <td nowrap="nowrap">
257 <?php
258 echo ($key_ordered_current_equals_data ? '<strong>' : '')
259 .'<a href="#" title="' . __('Use this value')
260 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
261 .' onclick="formupdate(\'' . md5($field) . '\', \''
262 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
263 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</strong>' : '');
264 ?></td>
265 <td>
266 <?php
267 echo ($key_ordered_current_equals_data ? '<strong>' : '')
268 . '<a href="#" title="' . __('Use this value') . ($key_ordered_current_val_title != '' ? ': '
269 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
270 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
271 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</strong>' : '');
272 ?></td>
273 <td width="20%">
274 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
275 alt="" width="1" height="1" /></td>
277 <td>
278 <?php
279 echo ($val_ordered_current_equals_data ? '<strong>' : '')
280 . '<a href="#" title="' . __('Use this value') . ($val_ordered_current_val_title != '' ? ': '
281 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
282 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
283 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</strong>' : '');
284 ?></td>
285 <td nowrap="nowrap">
286 <?php
287 echo ($val_ordered_current_equals_data ? '<strong>' : '') . '<a href="#" title="'
288 . __('Use this value') . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
289 . '" onclick="formupdate(\'' . md5($field) . '\', \''
290 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
291 . '</a>' . ($val_ordered_current_equals_data ? '</strong>' : '');
292 ?></td>
293 </tr>
294 <?php
295 } // end while
298 </tbody>
299 </table>
301 </body>
302 </html>