Translation update done using Pootle.
[phpmyadmin.git] / browse_foreigners.php
blob75f9be5f58be8b3795b7400be7c4f28427ecc8f4
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 if (opener && opener.document && opener.document.insertForm) {
102 var field = 'fields';
104 <?php if (isset($rownumber)) { ?>
105 var element_name = field + '[multi_edit][<?php echo htmlspecialchars($rownumber); ?>][' + fieldmd5 + ']';
106 <?php } else { ?>
107 var element_name = field + '[]';
108 <?php } ?>
110 <?php if (isset($fieldkey) && is_numeric($fieldkey)) { ?>
111 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
112 <?php } else { ?>
113 var element_name_alt = field + '[0]';
114 <?php } ?>
116 if (opener.document.insertForm.elements[element_name]) {
117 // Edit/Insert form
118 opener.document.insertForm.elements[element_name].value = key;
119 self.close();
120 return false;
121 } else if (opener.document.insertForm.elements[element_name_alt]) {
122 // Search form
123 opener.document.insertForm.elements[element_name_alt].value = key;
124 self.close();
125 return false;
129 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.')); ?>');
131 //]]>
132 </script>
133 </head>
135 <body id="body_browse_foreigners">
137 <form action="browse_foreigners.php" method="post">
138 <fieldset>
139 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
140 <input type="hidden" name="field" value="<?php echo htmlspecialchars($field); ?>" />
141 <input type="hidden" name="fieldkey"
142 value="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
143 <?php if (isset($rownumber)) { ?>
144 <input type="hidden" name="rownumber" value="<?php echo htmlspecialchars($rownumber); ?>" />
145 <?php } ?>
146 <span class="formelement">
147 <label for="input_foreign_filter"><?php echo __('Search') . ':'; ?></label>
148 <input type="text" name="foreign_filter" id="input_foreign_filter"
149 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
150 <input type="submit" name="submit_foreign_filter" value="<?php echo __('Go');?>" />
151 </span>
152 <span class="formelement">
153 <?php echo $gotopage; ?>
154 </span>
155 <span class="formelement">
156 <?php echo $showall; ?>
157 </span>
158 </fieldset>
159 </form>
161 <table width="100%">
162 <?php
163 if (is_array($foreignData['disp_row'])) {
164 $header = '<tr>
165 <th>' . __('Keyname') . '</th>
166 <th>' . __('Description') . '</th>
167 <td width="20%"></td>
168 <th>' . __('Description') . '</th>
169 <th>' . __('Keyname') . '</th>
170 </tr>';
172 echo '<thead>' . $header . '</thead>' . "\n"
173 .'<tfoot>' . $header . '</tfoot>' . "\n"
174 .'<tbody>' . "\n";
176 $values = array();
177 $keys = array();
178 foreach ($foreignData['disp_row'] as $relrow) {
179 if ($foreignData['foreign_display'] != FALSE) {
180 $values[] = $relrow[$foreignData['foreign_display']];
181 } else {
182 $values[] = '';
185 $keys[] = $relrow[$foreignData['foreign_field']];
188 asort($keys);
190 $hcount = 0;
191 $odd_row = true;
192 $val_ordered_current_row = 0;
193 $val_ordered_current_equals_data = false;
194 $key_ordered_current_equals_data = false;
195 foreach ($keys as $key_ordered_current_row => $value) {
196 //for ($i = 0; $i < $count; $i++) {
197 $hcount++;
199 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
200 echo $header;
201 $hcount = 0;
202 $odd_row = true;
205 $key_ordered_current_key = $keys[$key_ordered_current_row];
206 $key_ordered_current_val = $values[$key_ordered_current_row];
208 $val_ordered_current_key = $keys[$val_ordered_current_row];
209 $val_ordered_current_val = $values[$val_ordered_current_row];
211 $val_ordered_current_row++;
213 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
214 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
215 $val_ordered_current_val_title = '';
216 } else {
217 $val_ordered_current_val_title =
218 htmlspecialchars($val_ordered_current_val);
219 $val_ordered_current_val =
220 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
221 $cfg['LimitChars']) . '...');
223 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
224 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
225 $key_ordered_current_val_title = '';
226 } else {
227 $key_ordered_current_val_title =
228 htmlspecialchars($key_ordered_current_val);
229 $key_ordered_current_val =
230 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
231 $cfg['LimitChars']) . '...');
234 if (! empty($data)) {
235 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
236 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
240 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
241 <td nowrap="nowrap">
242 <?php
243 echo ($key_ordered_current_equals_data ? '<strong>' : '')
244 .'<a href="#" title="' . __('Use this value')
245 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
246 .' onclick="formupdate(\'' . md5($field) . '\', \''
247 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
248 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</strong>' : '');
249 ?></td>
250 <td>
251 <?php
252 echo ($key_ordered_current_equals_data ? '<strong>' : '')
253 . '<a href="#" title="' . __('Use this value') . ($key_ordered_current_val_title != '' ? ': '
254 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
255 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
256 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</strong>' : '');
257 ?></td>
258 <td width="20%">
259 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
260 alt="" width="1" height="1" /></td>
262 <td>
263 <?php
264 echo ($val_ordered_current_equals_data ? '<strong>' : '')
265 . '<a href="#" title="' . __('Use this value') . ($val_ordered_current_val_title != '' ? ': '
266 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
267 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
268 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</strong>' : '');
269 ?></td>
270 <td nowrap="nowrap">
271 <?php
272 echo ($val_ordered_current_equals_data ? '<strong>' : '') . '<a href="#" title="'
273 . __('Use this value') . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
274 . '" onclick="formupdate(\'' . md5($field) . '\', \''
275 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
276 . '</a>' . ($val_ordered_current_equals_data ? '</strong>' : '');
277 ?></td>
278 </tr>
279 <?php
280 } // end while
283 </tbody>
284 </table>
286 </body>
287 </html>