Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: browse_foreigners.php,v 2.28 2005/12/11 20:20:14 nijel Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 /**
5 * display selection for relational field values
6 */
7  
8 /**
9 * Gets a core script and starts output buffering work
10 */
11 require_once('./libraries/common.lib.php');
12  
13 PMA_checkParameters(array('db', 'table', 'field'));
14  
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);
20 }
21 }
22 require_once('./libraries/header_http.inc.php');
23 $field = urldecode($field);
24  
25 /**
26 * Displays the frame
27 */
28 $per_page = 200;
29 require_once('./libraries/relation.lib.php'); // foreign keys
30 require_once('./libraries/transformations.lib.php'); // Transformations
31 $cfgRelation = PMA_getRelationsParam();
32 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
33  
34 $override_total = TRUE;
35  
36 if (!isset($pos)) {
37 $pos = 0;
38 }
39  
40 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
41 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
42 unset($foreign_limit);
43 }
44  
45 require('./libraries/get_foreign.lib.php');
46  
47 if (isset($pk)) {
48 $pk_uri = '&amp;pk=' . urlencode($pk);
49 ?>
50 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
51 <?php
52 } else {
53 $pk_uri = '';
54 }
55  
56 $gotopage = '';
57 $showall = '';
58  
59 if (isset($disp_row) && is_array($disp_row)) {
60 $count = count( $disp_row );
61  
62 if ( $cfg['ShowAll'] && ($count > $per_page) ) {
63 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
64 }
65  
66 $session_max_rows = $per_page;
67 $pageNow = @floor($pos / $session_max_rows) + 1;
68 $nbTotalPage = @ceil($count / $session_max_rows);
69  
70 if ( $count > $per_page ) {
71 $gotopage = PMA_pageselector(
72 'browse_foreigners.php?field=' . urlencode($field) .
73 '&amp;' . PMA_generate_common_url($db, $table)
74 . $pk_uri .
75 '&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') .
76 '&amp;foreign_filter=' . (isset($foreign_filter) ? htmlspecialchars($foreign_filter) : '') .
77 '&amp;',
78 $session_max_rows,
79 $pageNow,
80 $nbTotalPage
81 );
82 }
83 }
84 ?>
85 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
86 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
87 <html xmlns="http://www.w3.org/1999/xhtml"
88 xml:lang="<?php echo $available_languages[$lang][2]; ?>"
89 lang="<?php echo $available_languages[$lang][2]; ?>"
90 dir="<?php echo $text_dir; ?>">
91  
92 <head>
93 <title>phpMyAdmin</title>
94 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
95 <link rel="stylesheet" type="text/css"
96 href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url( '', '' ); ?>&amp;js_frame=right" />
97 <script src="./js/functions.js" type="text/javascript" language="javascript"></script>
98 <script type="text/javascript" language="javascript">
99 //<![CDATA[
100 self.focus();
101 function formupdate( field, key ) {
102 if (opener && opener.document && opener.document.insertForm) {
103 var field = 'field_' + field;
104  
105 <?php if ( isset( $pk ) ) { ?>
106 var element_name = field + '[multi_edit][<?php echo urlencode( $pk ); ?>][]';
107 <?php } else { ?>
108 var element_name = field + '[]';
109 <?php } ?>
110  
111 <?php if ( isset( $fieldkey ) ) { ?>
112 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
113 <?php } else { ?>
114 var element_name_alt = field + '[0]';
115 <?php } ?>
116  
117 if (opener.document.insertForm.elements[element_name]) {
118 // Edit/Insert form
119 opener.document.insertForm.elements[element_name].value = key;
120 self.close();
121 return false;
122 } else if (opener.document.insertForm.elements[element_name_alt]) {
123 // Search form
124 opener.document.insertForm.elements[element_name_alt].value = key;
125 self.close();
126 return false;
127 }
128 }
129  
130 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
131 }
132 //]]>
133 </script>
134 </head>
135  
136 <body id="body_browse_foreigners">
137  
138 <form action="browse_foreigners.php" method="post">
139 <fieldset>
140 <?php echo PMA_generate_common_hidden_inputs( $db, $table ); ?>
141 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
142 <input type="hidden" name="fieldkey"
143 value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
144 <?php if ( isset( $pk ) ) { ?>
145 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
146 <?php } ?>
147 <span class="formelement">
148 <label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
149 <input type="text" name="foreign_filter" id="input_foreign_filter"
150 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
151 <input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
152 </span>
153 <span class="formelement">
154 <?php echo $gotopage; ?>
155 </span>
156 <span class="formelement">
157 <?php echo $showall; ?>
158 </span>
159 </fieldset>
160 </form>
161  
162 <table width="100%">
163 <?php
164 if (isset($disp_row) && is_array($disp_row)) {
165 $header = '<tr>
166 <th>' . $strKeyname . '</th>
167 <th>' . $strDescription . '</th>
168 <td width="20%"></td>
169 <th>' . $strDescription . '</th>
170 <th>' . $strKeyname . '</th>
171 </tr>';
172  
173 echo '<thead>' . $header . '</thead>' . "\n"
174 .'<tfoot>' . $header . '</tfoot>' . "\n"
175 .'<tbody>' . "\n";
176  
177 $values = array();
178 $keys = array();
179 foreach ( $disp_row as $relrow ) {
180 if ($foreign_display != FALSE) {
181 $values[] = $relrow[$foreign_display];
182 } else {
183 $values[] = '';
184 }
185  
186 $keys[] = $relrow[$foreign_field];
187 }
188  
189 asort( $keys );
190  
191 $hcount = 0;
192 $odd_row = true;
193 $val_ordered_current_row = 0;
194 $val_ordered_current_equals_data = false;
195 $key_ordered_current_equals_data = false;
196 foreach ( $keys as $key_ordered_current_row => $value ) {
197 //for ( $i = 0; $i < $count; $i++ ) {
198 $hcount++;
199  
200 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
201 echo $header;
202 $hcount = 0;
203 $odd_row = true;
204 }
205  
206 $key_ordered_current_key = $keys[$key_ordered_current_row];
207 $key_ordered_current_val = $values[$key_ordered_current_row];
208  
209 $val_ordered_current_key = $keys[$val_ordered_current_row];
210 $val_ordered_current_val = $values[$val_ordered_current_row];
211  
212 $val_ordered_current_row++;
213  
214 if (PMA_strlen( $val_ordered_current_val ) <= $cfg['LimitChars']) {
215 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
216 $val_ordered_current_val_title = '';
217 } else {
218 $val_ordered_current_val_title =
219 htmlspecialchars( $val_ordered_current_val );
220 $val_ordered_current_val =
221 htmlspecialchars( PMA_substr( $val_ordered_current_val, 0,
222 $cfg['LimitChars'] ) . '...' );
223 }
224 if (PMA_strlen( $key_ordered_current_val ) <= $cfg['LimitChars']) {
225 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
226 $key_ordered_current_val_title = '';
227 } else {
228 $key_ordered_current_val_title =
229 htmlspecialchars( $key_ordered_current_val );
230 $key_ordered_current_val =
231 htmlspecialchars( PMA_substr( $key_ordered_current_val, 0,
232 $cfg['LimitChars'] ) . '...' );
233 }
234  
235 if ( ! empty( $data ) ) {
236 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
237 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
238 }
239  
240 ?>
241 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
242 <td nowrap="nowrap">
243 <?php
244 echo ($key_ordered_current_equals_data ? '<b>' : '')
245 .'<a href="#" title="' . $strUseThisValue
246 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
247 .' onclick="formupdate(\'' . md5($field) . '\', \''
248 . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
249 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
250 ?></td>
251 <td>
252 <?php
253 echo ($key_ordered_current_equals_data ? '<b>' : '')
254 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ? ': '
255 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
256 . md5($field) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
257 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
258 ?></td>
259 <td width="20%">
260 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
261 alt="" width="1" height="1"></td>
262  
263 <td>
264 <?php
265 echo ($val_ordered_current_equals_data ? '<b>' : '')
266 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': '
267 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
268 . '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); return false;">'
269 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
270 ?></td>
271 <td nowrap="nowrap">
272 <?php
273 echo ($val_ordered_current_equals_data ? '<b>' : '') . '<a href="#" title="'
274 . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
275 . '" onclick="formupdate(\'' . md5($field) . '\', \''
276 . htmlspecialchars($val_ordered_current_key) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
277 . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
278 ?></td>
279 </tr>
280 <?php
281 } // end while
282 }
283 ?>
284 </tbody>
285 </table>
286  
287 </body>
288 </html>
289  
290 <?php
291 /**
292 * Close MySql connections
293 */
294 if (isset($controllink) && $controllink) {
295 @PMA_DBI_close($controllink);
296 }
297 if (isset($userlink) && $userlink) {
298 @PMA_DBI_close($userlink);
299 }
300  
301  
302 /**
303 * Sends bufferized data
304 */
305 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
306 && isset($ob_mode) && $ob_mode) {
307 PMA_outBufferPost($ob_mode);
308 }
309 ?>