sorry, wrong version checked in
[phpmyadmin/arisferyanto.git] / browse_foreigners.php
blobc1ddbbdcf9051d03050c5195734c5e0c0632183c
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 /**
5 * display selection for relational field values
6 */
8 /**
9 * Gets a core script and starts output buffering work
11 require_once('./libraries/common.lib.php');
13 PMA_checkParameters(array('db', 'table', 'field'));
15 require_once('./libraries/ob.lib.php');
16 if ($cfg['OBGzip']) {
17 $ob_mode = PMA_outBufferModeGet();
18 if ($ob_mode) {
19 PMA_outBufferPre($ob_mode);
22 require_once('./libraries/header_http.inc.php');
23 $field = urldecode($field);
25 /**
26 * Displays the frame
28 // Gets the font sizes to use
29 PMA_setFontSizes();
31 $per_page = 200;
32 require_once('./libraries/relation.lib.php'); // foreign keys
33 require_once('./libraries/transformations.lib.php'); // Transformations
34 $cfgRelation = PMA_getRelationsParam();
35 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
37 $override_total = TRUE;
39 if (!isset($pos)) {
40 $pos = 0;
43 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
44 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
45 unset($foreign_limit);
48 require('./libraries/get_foreign.lib.php');
50 if (isset($pk)) {
51 $pk_uri = '&amp;pk=' . urlencode($pk);
52 ?>
53 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
54 <?php
55 } else {
56 $pk_uri = '';
59 $gotopage = '';
60 $showall = '';
62 if (isset($disp_row) && is_array($disp_row)) {
63 $count = count( $disp_row );
65 if ( $cfg['ShowAll'] && ($count > $per_page) ) {
66 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
69 $session_max_rows = $per_page;
70 $pageNow = @floor($pos / $session_max_rows) + 1;
71 $nbTotalPage = @ceil($count / $session_max_rows);
73 if ( $count > $per_page ) {
74 $gotopage = PMA_pageselector(
75 'browse_foreigners.php?field=' . urlencode($field) .
76 '&amp;' . PMA_generate_common_url($db, $table)
77 . $pk_uri .
78 '&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') .
79 '&amp;foreign_filter=' . (isset($foreign_filter) ? htmlspecialchars($foreign_filter) : '') .
80 '&amp;',
81 $session_max_rows,
82 $pageNow,
83 $nbTotalPage
88 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
89 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
90 <html xmlns="http://www.w3.org/1999/xhtml"
91 xml:lang="<?php echo $available_languages[$lang][2]; ?>"
92 lang="<?php echo $available_languages[$lang][2]; ?>"
93 dir="<?php echo $text_dir; ?>">
95 <head>
96 <title>phpMyAdmin</title>
97 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
98 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
99 <link rel="stylesheet" type="text/css"
100 href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url( '', '' ); ?>&amp;js_frame=right" />
101 <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
102 <script type="text/javascript" language="javascript">
103 //<![CDATA[
104 self.focus();
105 function formupdate( field, key ) {
106 if (opener && opener.document && opener.document.insertForm) {
107 var field = 'field_' + field;
109 <?php if ( isset( $pk ) ) { ?>
110 var element_name = field + '[multi_edit][<?php echo urlencode( $pk ); ?>][]';
111 <?php } else { ?>
112 var element_name = field + '[]';
113 <?php } ?>
115 <?php if ( isset( $fieldkey ) ) { ?>
116 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
117 <?php } else { ?>
118 var element_name_alt = field + '[0]';
119 <?php } ?>
121 if (opener.document.insertForm.elements[element_name]) {
122 // Edit/Insert form
123 opener.document.insertForm.elements[element_name].value = key;
124 self.close();
125 return false;
126 } else if (opener.document.insertForm.elements[element_name_alt]) {
127 // Search form
128 opener.document.insertForm.elements[element_name_alt].value = key;
129 self.close();
130 return false;
134 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
136 //]]>
137 </script>
138 </head>
140 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
142 <form action="browse_foreigners.php" method="post">
143 <fieldset>
144 <?php echo PMA_generate_common_hidden_inputs( $db, $table ); ?>
145 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
146 <input type="hidden" name="fieldkey" value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
147 <?php if ( isset( $pk ) ) { ?>
148 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
149 <?php } ?>
150 <span class="formelement">
151 <label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
152 <input type="text" name="foreign_filter" id="input_foreign_filter" 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 . htmlspecialchars($key_ordered_current_key) . '\'); 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) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); 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 . '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); 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 . htmlspecialchars($val_ordered_current_key) . '\'); 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($dbh) && $dbh) {
297 @PMA_DBI_close($dbh);
299 if (isset($userlink) && $userlink) {
300 @PMA_DBI_close($userlink);
305 * Sends bufferized data
307 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
308 && isset($ob_mode) && $ob_mode) {
309 PMA_outBufferPost($ob_mode);