3 // vim: expandtab sw=4 ts=4 sts=4:
5 * display selection for relational field values
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');
17 $ob_mode = PMA_outBufferModeGet();
19 PMA_outBufferPre($ob_mode);
22 require_once('./libraries/header_http.inc.php');
23 $field = urldecode($field);
28 // Gets the font sizes to use
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;
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');
51 $pk_uri = '&pk=' . urlencode($pk);
53 <input type
="hidden" name
="pk" value
="<?php echo urlencode($pk); ?>" />
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 '&' . PMA_generate_common_url($db, $table)
78 '&fieldkey=' . (isset($fieldkey) ?
$fieldkey : '') .
79 '&foreign_filter=' . (isset($foreign_filter) ?
htmlspecialchars($foreign_filter) : '') .
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; ?>">
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( '', '' ); ?>&js_frame=right" />
101 <script src
="libraries/functions.js" type
="text/javascript" language
="javascript"></script
>
102 <script type
="text/javascript" language
="javascript">
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 ); ?>][]';
112 var element_name
= field +
'[]';
115 <?php
if ( isset( $fieldkey ) ) { ?
>
116 var element_name_alt
= field +
'[<?php echo $fieldkey; ?>]';
118 var element_name_alt
= field +
'[0]';
121 if (opener
.document
.insertForm
.elements
[element_name
]) {
123 opener
.document
.insertForm
.elements
[element_name
].value
= key
;
126 } else if (opener
.document
.insertForm
.elements
[element_name_alt
]) {
128 opener
.document
.insertForm
.elements
[element_name_alt
].value
= key
;
134 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
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">
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); ?>" />
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;?>" />
155 <span
class="formelement">
156 <?php
echo $gotopage; ?
>
158 <span
class="formelement">
159 <?php
echo $showall; ?
>
166 if (isset($disp_row) && is_array($disp_row)) {
168 <th>' . $strKeyname . '</th>
169 <th>' . $strDescription . '</th>
170 <td width="20%"></td>
171 <th>' . $strDescription . '</th>
172 <th>' . $strKeyname . '</th>
175 echo '<thead>' . $header . '</thead>' . "\n"
176 .'<tfoot>' . $header . '</tfoot>' . "\n"
181 foreach ( $disp_row as $relrow ) {
182 if ($foreign_display != FALSE) {
183 $values[] = $relrow[$foreign_display];
188 $keys[] = $relrow[$foreign_field];
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++ ) {
202 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
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 = '';
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 = '';
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; ?>">
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>' : '');
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>' : '');
262 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
263 alt
="" width
="1" height
="1"></td
>
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>' : '');
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>' : '');
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);