patch #1731280 unneeded for trunk
[phpmyadmin/crack.git] / browse_foreigners.php
blob82187e782b0febc61bb840aa7edda4eb1f0d5dec
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';
20 $field = urldecode($field);
22 /**
23 * Displays the frame
25 $per_page = 200;
26 require_once './libraries/relation.lib.php'; // foreign keys
27 require_once './libraries/transformations.lib.php'; // Transformations
28 $cfgRelation = PMA_getRelationsParam();
29 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
31 $override_total = TRUE;
33 if (!isset($pos)) {
34 $pos = 0;
37 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
38 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
39 unset($foreign_limit);
42 require './libraries/get_foreign.lib.php';
44 if (isset($pk)) {
45 $pk_uri = '&amp;pk=' . urlencode($pk);
47 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
48 <?php
49 } else {
50 $pk_uri = '';
53 $gotopage = '';
54 $showall = '';
55 // $the_total comes from get_foreign.lib.php
57 if (isset($disp_row) && is_array($disp_row)) {
59 if ($cfg['ShowAll'] && ($the_total > $per_page)) {
60 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
63 $session_max_rows = $per_page;
64 $pageNow = @floor($pos / $session_max_rows) + 1;
65 $nbTotalPage = @ceil($the_total / $session_max_rows);
67 if ($the_total > $per_page) {
68 $gotopage = PMA_pageselector(
69 'browse_foreigners.php?field=' . urlencode($field) .
70 '&amp;' . PMA_generate_common_url($db, $table)
71 . $pk_uri .
72 '&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') .
73 '&amp;foreign_filter=' . (isset($foreign_filter) ? htmlspecialchars($foreign_filter) : '') .
74 '&amp;',
75 $session_max_rows,
76 $pageNow,
77 $nbTotalPage
82 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
83 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
84 <html xmlns="http://www.w3.org/1999/xhtml"
85 xml:lang="<?php echo $available_languages[$lang][2]; ?>"
86 lang="<?php echo $available_languages[$lang][2]; ?>"
87 dir="<?php echo $text_dir; ?>">
89 <head>
90 <title>phpMyAdmin</title>
91 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
92 <link rel="stylesheet" type="text/css"
93 href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&amp;js_frame=right&amp;nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
94 <script src="./js/functions.js" type="text/javascript"></script>
95 <script type="text/javascript">
96 //<![CDATA[
97 self.focus();
98 function formupdate(field, key) {
99 if (opener && opener.document && opener.document.insertForm) {
100 var field = 'field_' + field;
102 <?php if (isset($pk)) { ?>
103 var element_name = field + '[multi_edit][<?php echo urlencode($pk); ?>][]';
104 <?php } else { ?>
105 var element_name = field + '[]';
106 <?php } ?>
108 <?php if (isset($fieldkey) && is_numeric($fieldkey)) { ?>
109 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
110 <?php } else { ?>
111 var element_name_alt = field + '[0]';
112 <?php } ?>
114 if (opener.document.insertForm.elements[element_name]) {
115 // Edit/Insert form
116 opener.document.insertForm.elements[element_name].value = key;
117 self.close();
118 return false;
119 } else if (opener.document.insertForm.elements[element_name_alt]) {
120 // Search form
121 opener.document.insertForm.elements[element_name_alt].value = key;
122 self.close();
123 return false;
127 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
129 //]]>
130 </script>
131 </head>
133 <body id="body_browse_foreigners">
135 <form action="browse_foreigners.php" method="post">
136 <fieldset>
137 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
138 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
139 <input type="hidden" name="fieldkey"
140 value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
141 <?php if (isset($pk)) { ?>
142 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
143 <?php } ?>
144 <span class="formelement">
145 <label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
146 <input type="text" name="foreign_filter" id="input_foreign_filter"
147 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
148 <input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
149 </span>
150 <span class="formelement">
151 <?php echo $gotopage; ?>
152 </span>
153 <span class="formelement">
154 <?php echo $showall; ?>
155 </span>
156 </fieldset>
157 </form>
159 <table width="100%">
160 <?php
161 if (isset($disp_row) && is_array($disp_row)) {
162 $header = '<tr>
163 <th>' . $strKeyname . '</th>
164 <th>' . $strDescription . '</th>
165 <td width="20%"></td>
166 <th>' . $strDescription . '</th>
167 <th>' . $strKeyname . '</th>
168 </tr>';
170 echo '<thead>' . $header . '</thead>' . "\n"
171 .'<tfoot>' . $header . '</tfoot>' . "\n"
172 .'<tbody>' . "\n";
174 $values = array();
175 $keys = array();
176 foreach ($disp_row as $relrow) {
177 if ($foreign_display != FALSE) {
178 $values[] = $relrow[$foreign_display];
179 } else {
180 $values[] = '';
183 $keys[] = $relrow[$foreign_field];
186 asort($keys);
188 $hcount = 0;
189 $odd_row = true;
190 $val_ordered_current_row = 0;
191 $val_ordered_current_equals_data = false;
192 $key_ordered_current_equals_data = false;
193 foreach ($keys as $key_ordered_current_row => $value) {
194 //for ($i = 0; $i < $count; $i++) {
195 $hcount++;
197 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
198 echo $header;
199 $hcount = 0;
200 $odd_row = true;
203 $key_ordered_current_key = $keys[$key_ordered_current_row];
204 $key_ordered_current_val = $values[$key_ordered_current_row];
206 $val_ordered_current_key = $keys[$val_ordered_current_row];
207 $val_ordered_current_val = $values[$val_ordered_current_row];
209 $val_ordered_current_row++;
211 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
212 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
213 $val_ordered_current_val_title = '';
214 } else {
215 $val_ordered_current_val_title =
216 htmlspecialchars($val_ordered_current_val);
217 $val_ordered_current_val =
218 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
219 $cfg['LimitChars']) . '...');
221 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
222 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
223 $key_ordered_current_val_title = '';
224 } else {
225 $key_ordered_current_val_title =
226 htmlspecialchars($key_ordered_current_val);
227 $key_ordered_current_val =
228 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
229 $cfg['LimitChars']) . '...');
232 if (! empty($data)) {
233 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
234 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
238 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
239 <td nowrap="nowrap">
240 <?php
241 echo ($key_ordered_current_equals_data ? '<b>' : '')
242 .'<a href="#" title="' . $strUseThisValue
243 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
244 .' onclick="formupdate(\'' . md5($field) . '\', \''
245 . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
246 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
247 ?></td>
248 <td>
249 <?php
250 echo ($key_ordered_current_equals_data ? '<b>' : '')
251 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ? ': '
252 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
253 . md5($field) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
254 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
255 ?></td>
256 <td width="20%">
257 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
258 alt="" width="1" height="1"></td>
260 <td>
261 <?php
262 echo ($val_ordered_current_equals_data ? '<b>' : '')
263 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': '
264 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
265 . '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); return false;">'
266 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
267 ?></td>
268 <td nowrap="nowrap">
269 <?php
270 echo ($val_ordered_current_equals_data ? '<b>' : '') . '<a href="#" title="'
271 . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
272 . '" onclick="formupdate(\'' . md5($field) . '\', \''
273 . htmlspecialchars($val_ordered_current_key) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
274 . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
275 ?></td>
276 </tr>
277 <?php
278 } // end while
281 </tbody>
282 </table>
284 </body>
285 </html>
287 <?php
289 * Close MySql connections
291 if (isset($controllink) && $controllink) {
292 @PMA_DBI_close($controllink);
294 if (isset($userlink) && $userlink) {
295 @PMA_DBI_close($userlink);