Czech translation update.
[phpmyadmin/crack.git] / browse_foreigners.php
blobed04583dc39303213be7e7308575bb695d1fd8fc
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * display selection for relational field values
6 * @version $Id$
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 $per_page = 200;
25 require_once './libraries/relation.lib.php'; // foreign keys
26 require_once './libraries/transformations.lib.php'; // Transformations
27 $cfgRelation = PMA_getRelationsParam();
28 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
30 $override_total = TRUE;
32 if (!isset($pos)) {
33 $pos = 0;
36 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
37 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
38 unset($foreign_limit);
41 $foreignData = PMA_getForeignData($foreigners, $field, $override_total, isset($foreign_filter) ? $foreign_filter : '', $foreign_limit);
43 if (isset($pk)) {
44 $pk_uri = '&amp;pk=' . urlencode($pk);
46 <input type="hidden" name="pk" value="<?php echo htmlspecialchars($pk); ?>" />
47 <?php
48 } else {
49 $pk_uri = '';
52 $gotopage = '';
53 $showall = '';
55 if (is_array($foreignData['disp_row'])) {
57 if ($cfg['ShowAll'] && ($foreignData['the_total'] > $per_page)) {
58 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
61 $session_max_rows = $per_page;
62 $pageNow = @floor($pos / $session_max_rows) + 1;
63 $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);
65 if ($foreignData['the_total'] > $per_page) {
66 $gotopage = PMA_pageselector(
67 'browse_foreigners.php?field=' . urlencode($field) .
68 '&amp;' . PMA_generate_common_url($db, $table)
69 . $pk_uri .
70 '&amp;fieldkey=' . (isset($fieldkey) ? urlencode($fieldkey) : '') .
71 '&amp;foreign_filter=' . (isset($foreign_filter) ? urlencode($foreign_filter) : '') .
72 '&amp;',
73 $session_max_rows,
74 $pageNow,
75 $nbTotalPage,
76 200,
79 20,
80 10,
81 $GLOBALS['strPageNumber']
86 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
87 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
88 <html xmlns="http://www.w3.org/1999/xhtml"
89 xml:lang="<?php echo $available_languages[$lang][2]; ?>"
90 lang="<?php echo $available_languages[$lang][2]; ?>"
91 dir="<?php echo $text_dir; ?>">
93 <head>
94 <title>phpMyAdmin</title>
95 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
96 <link rel="stylesheet" type="text/css"
97 href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&amp;js_frame=right&amp;nocache=<?php echo $_SESSION['PMA_Config']->getThemeUniqueValue(); ?>" />
98 <script src="./js/functions.js" type="text/javascript"></script>
99 <script type="text/javascript">
100 //<![CDATA[
101 self.focus();
102 function formupdate(field, key) {
103 if (opener && opener.document && opener.document.insertForm) {
104 var field = 'field_' + field;
106 <?php if (isset($pk)) { ?>
107 var element_name = field + '[multi_edit][<?php echo htmlspecialchars($pk); ?>][]';
108 <?php } else { ?>
109 var element_name = field + '[]';
110 <?php } ?>
112 <?php if (isset($fieldkey) && is_numeric($fieldkey)) { ?>
113 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
114 <?php } else { ?>
115 var element_name_alt = field + '[0]';
116 <?php } ?>
118 if (opener.document.insertForm.elements[element_name]) {
119 // Edit/Insert form
120 opener.document.insertForm.elements[element_name].value = key;
121 self.close();
122 return false;
123 } else if (opener.document.insertForm.elements[element_name_alt]) {
124 // Search form
125 opener.document.insertForm.elements[element_name_alt].value = key;
126 self.close();
127 return false;
131 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
133 //]]>
134 </script>
135 </head>
137 <body id="body_browse_foreigners">
139 <form action="browse_foreigners.php" method="post">
140 <fieldset>
141 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
142 <input type="hidden" name="field" value="<?php echo htmlspecialchars($field); ?>" />
143 <input type="hidden" name="fieldkey"
144 value="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
145 <?php if (isset($pk)) { ?>
146 <input type="hidden" name="pk" value="<?php echo htmlspecialchars($pk); ?>" />
147 <?php } ?>
148 <span class="formelement">
149 <label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
150 <input type="text" name="foreign_filter" id="input_foreign_filter"
151 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
152 <input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
153 </span>
154 <span class="formelement">
155 <?php echo $gotopage; ?>
156 </span>
157 <span class="formelement">
158 <?php echo $showall; ?>
159 </span>
160 </fieldset>
161 </form>
163 <table width="100%">
164 <?php
165 if (is_array($foreignData['disp_row'])) {
166 $header = '<tr>
167 <th>' . $strKeyname . '</th>
168 <th>' . $strDescription . '</th>
169 <td width="20%"></td>
170 <th>' . $strDescription . '</th>
171 <th>' . $strKeyname . '</th>
172 </tr>';
174 echo '<thead>' . $header . '</thead>' . "\n"
175 .'<tfoot>' . $header . '</tfoot>' . "\n"
176 .'<tbody>' . "\n";
178 $values = array();
179 $keys = array();
180 foreach ($foreignData['disp_row'] as $relrow) {
181 if ($foreignData['foreign_display'] != FALSE) {
182 $values[] = $relrow[$foreignData['foreign_display']];
183 } else {
184 $values[] = '';
187 $keys[] = $relrow[$foreignData['foreign_field']];
190 asort($keys);
192 $hcount = 0;
193 $odd_row = true;
194 $val_ordered_current_row = 0;
195 $val_ordered_current_equals_data = false;
196 $key_ordered_current_equals_data = false;
197 foreach ($keys as $key_ordered_current_row => $value) {
198 //for ($i = 0; $i < $count; $i++) {
199 $hcount++;
201 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
202 echo $header;
203 $hcount = 0;
204 $odd_row = true;
207 $key_ordered_current_key = $keys[$key_ordered_current_row];
208 $key_ordered_current_val = $values[$key_ordered_current_row];
210 $val_ordered_current_key = $keys[$val_ordered_current_row];
211 $val_ordered_current_val = $values[$val_ordered_current_row];
213 $val_ordered_current_row++;
215 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
216 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
217 $val_ordered_current_val_title = '';
218 } else {
219 $val_ordered_current_val_title =
220 htmlspecialchars($val_ordered_current_val);
221 $val_ordered_current_val =
222 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
223 $cfg['LimitChars']) . '...');
225 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
226 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
227 $key_ordered_current_val_title = '';
228 } else {
229 $key_ordered_current_val_title =
230 htmlspecialchars($key_ordered_current_val);
231 $key_ordered_current_val =
232 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
233 $cfg['LimitChars']) . '...');
236 if (! empty($data)) {
237 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
238 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
242 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
243 <td nowrap="nowrap">
244 <?php
245 echo ($key_ordered_current_equals_data ? '<b>' : '')
246 .'<a href="#" title="' . $strUseThisValue
247 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
248 .' onclick="formupdate(\'' . md5($field) . '\', \''
249 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
250 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
251 ?></td>
252 <td>
253 <?php
254 echo ($key_ordered_current_equals_data ? '<b>' : '')
255 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ? ': '
256 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
257 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
258 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
259 ?></td>
260 <td width="20%">
261 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
262 alt="" width="1" height="1"></td>
264 <td>
265 <?php
266 echo ($val_ordered_current_equals_data ? '<b>' : '')
267 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': '
268 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
269 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
270 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
271 ?></td>
272 <td nowrap="nowrap">
273 <?php
274 echo ($val_ordered_current_equals_data ? '<b>' : '') . '<a href="#" title="'
275 . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
276 . '" onclick="formupdate(\'' . md5($field) . '\', \''
277 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
278 . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
279 ?></td>
280 </tr>
281 <?php
282 } // end while
285 </tbody>
286 </table>
288 </body>
289 </html>