2.11.11.3 release
[phpmyadmin/arisferyanto.git] / browse_foreigners.php
blob4010dda5753a238cdb866bae58d10f2a76abb380
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 require './libraries/get_foreign.lib.php';
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 = '';
54 // $the_total comes from get_foreign.lib.php
56 if (isset($disp_row) && is_array($disp_row)) {
58 if ($cfg['ShowAll'] && ($the_total > $per_page)) {
59 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
62 $session_max_rows = $per_page;
63 $pageNow = @floor($pos / $session_max_rows) + 1;
64 $nbTotalPage = @ceil($the_total / $session_max_rows);
66 if ($the_total > $per_page) {
67 $gotopage = PMA_pageselector(
68 'browse_foreigners.php?field=' . urlencode($field) .
69 '&amp;' . PMA_generate_common_url($db, $table)
70 . $pk_uri .
71 '&amp;fieldkey=' . (isset($fieldkey) ? urlencode($fieldkey) : '') .
72 '&amp;foreign_filter=' . (isset($foreign_filter) ? urlencode($foreign_filter) : '') .
73 '&amp;',
74 $session_max_rows,
75 $pageNow,
76 $nbTotalPage,
77 200,
80 20,
81 10,
82 $GLOBALS['strPageNumber']
87 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
88 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
89 <html xmlns="http://www.w3.org/1999/xhtml"
90 xml:lang="<?php echo $available_languages[$lang][2]; ?>"
91 lang="<?php echo $available_languages[$lang][2]; ?>"
92 dir="<?php echo $text_dir; ?>">
94 <head>
95 <title>phpMyAdmin</title>
96 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
97 <link rel="stylesheet" type="text/css"
98 href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&amp;js_frame=right&amp;nocache=<?php echo $_SESSION['PMA_Config']->getThemeUniqueValue(); ?>" />
99 <script src="./js/functions.js" type="text/javascript"></script>
100 <script type="text/javascript">
101 //<![CDATA[
102 self.focus();
103 function formupdate(field, key) {
104 if (opener && opener.document && opener.document.insertForm) {
105 var field = 'field_' + field;
107 <?php if (isset($pk)) { ?>
108 var element_name = field + '[multi_edit][<?php echo htmlspecialchars($pk); ?>][]';
109 <?php } else { ?>
110 var element_name = field + '[]';
111 <?php } ?>
113 <?php if (isset($fieldkey) && is_numeric($fieldkey)) { ?>
114 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
115 <?php } else { ?>
116 var element_name_alt = field + '[0]';
117 <?php } ?>
119 if (opener.document.insertForm.elements[element_name]) {
120 // Edit/Insert form
121 opener.document.insertForm.elements[element_name].value = key;
122 self.close();
123 return false;
124 } else if (opener.document.insertForm.elements[element_name_alt]) {
125 // Search form
126 opener.document.insertForm.elements[element_name_alt].value = key;
127 self.close();
128 return false;
132 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
134 //]]>
135 </script>
136 </head>
138 <body id="body_browse_foreigners">
140 <form action="browse_foreigners.php" method="post">
141 <fieldset>
142 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
143 <input type="hidden" name="field" value="<?php echo htmlspecialchars($field); ?>" />
144 <input type="hidden" name="fieldkey"
145 value="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
146 <?php if (isset($pk)) { ?>
147 <input type="hidden" name="pk" value="<?php echo htmlspecialchars($pk); ?>" />
148 <?php } ?>
149 <span class="formelement">
150 <label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
151 <input type="text" name="foreign_filter" id="input_foreign_filter"
152 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
153 <input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
154 </span>
155 <span class="formelement">
156 <?php echo $gotopage; ?>
157 </span>
158 <span class="formelement">
159 <?php echo $showall; ?>
160 </span>
161 </fieldset>
162 </form>
164 <table width="100%">
165 <?php
166 if (isset($disp_row) && is_array($disp_row)) {
167 $header = '<tr>
168 <th>' . $strKeyname . '</th>
169 <th>' . $strDescription . '</th>
170 <td width="20%"></td>
171 <th>' . $strDescription . '</th>
172 <th>' . $strKeyname . '</th>
173 </tr>';
175 echo '<thead>' . $header . '</thead>' . "\n"
176 .'<tfoot>' . $header . '</tfoot>' . "\n"
177 .'<tbody>' . "\n";
179 $values = array();
180 $keys = array();
181 foreach ($disp_row as $relrow) {
182 if ($foreign_display != FALSE) {
183 $values[] = $relrow[$foreign_display];
184 } else {
185 $values[] = '';
188 $keys[] = $relrow[$foreign_field];
191 asort($keys);
193 $hcount = 0;
194 $odd_row = true;
195 $val_ordered_current_row = 0;
196 $val_ordered_current_equals_data = false;
197 $key_ordered_current_equals_data = false;
198 foreach ($keys as $key_ordered_current_row => $value) {
199 //for ($i = 0; $i < $count; $i++) {
200 $hcount++;
202 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
203 echo $header;
204 $hcount = 0;
205 $odd_row = true;
208 $key_ordered_current_key = $keys[$key_ordered_current_row];
209 $key_ordered_current_val = $values[$key_ordered_current_row];
211 $val_ordered_current_key = $keys[$val_ordered_current_row];
212 $val_ordered_current_val = $values[$val_ordered_current_row];
214 $val_ordered_current_row++;
216 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
217 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
218 $val_ordered_current_val_title = '';
219 } else {
220 $val_ordered_current_val_title =
221 htmlspecialchars($val_ordered_current_val);
222 $val_ordered_current_val =
223 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
224 $cfg['LimitChars']) . '...');
226 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
227 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
228 $key_ordered_current_val_title = '';
229 } else {
230 $key_ordered_current_val_title =
231 htmlspecialchars($key_ordered_current_val);
232 $key_ordered_current_val =
233 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
234 $cfg['LimitChars']) . '...');
237 if (! empty($data)) {
238 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
239 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
243 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
244 <td nowrap="nowrap">
245 <?php
246 echo ($key_ordered_current_equals_data ? '<b>' : '')
247 .'<a href="#" title="' . $strUseThisValue
248 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
249 .' onclick="formupdate(\'' . md5($field) . '\', \''
250 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
251 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
252 ?></td>
253 <td>
254 <?php
255 echo ($key_ordered_current_equals_data ? '<b>' : '')
256 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ? ': '
257 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
258 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
259 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
260 ?></td>
261 <td width="20%">
262 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
263 alt="" width="1" height="1"></td>
265 <td>
266 <?php
267 echo ($val_ordered_current_equals_data ? '<b>' : '')
268 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': '
269 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
270 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
271 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
272 ?></td>
273 <td nowrap="nowrap">
274 <?php
275 echo ($val_ordered_current_equals_data ? '<b>' : '') . '<a href="#" title="'
276 . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
277 . '" onclick="formupdate(\'' . md5($field) . '\', \''
278 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
279 . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
280 ?></td>
281 </tr>
282 <?php
283 } // end while
286 </tbody>
287 </table>
289 </body>
290 </html>
292 <?php
294 * Close MySql connections
296 if (isset($controllink) && $controllink) {
297 @PMA_DBI_close($controllink);
299 if (isset($userlink) && $userlink) {
300 @PMA_DBI_close($userlink);