2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * display selection for relational field values
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';
19 require_once './libraries/header_http.inc.php';
20 $field = urldecode($field);
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;
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';
45 $pk_uri = '&pk=' . urlencode($pk);
47 <input type
="hidden" name
="pk" value
="<?php echo urlencode($pk); ?>" />
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 '&' . PMA_generate_common_url($db, $table)
72 '&fieldkey=' . (isset($fieldkey) ?
$fieldkey : '') .
73 '&foreign_filter=' . (isset($foreign_filter) ?
htmlspecialchars($foreign_filter) : '') .
83 $GLOBALS['strPageNumber']
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 <link rel
="stylesheet" type
="text/css"
99 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=right&nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
100 <script src
="./js/functions.js" type
="text/javascript"></script
>
101 <script type
="text/javascript">
104 function formupdate(field
, key
) {
105 if (opener
&& opener
.document
&& opener
.document
.insertForm
) {
106 var field
= 'field_' + field
;
108 <?php
if (isset($pk)) { ?
>
109 var element_name
= field +
'[multi_edit][<?php echo urlencode($pk); ?>][]';
111 var element_name
= field +
'[]';
114 <?php
if (isset($fieldkey) && is_numeric($fieldkey)) { ?
>
115 var element_name_alt
= field +
'[<?php echo $fieldkey; ?>]';
117 var element_name_alt
= field +
'[0]';
120 if (opener
.document
.insertForm
.elements
[element_name
]) {
122 opener
.document
.insertForm
.elements
[element_name
].value
= key
;
125 } else if (opener
.document
.insertForm
.elements
[element_name_alt
]) {
127 opener
.document
.insertForm
.elements
[element_name_alt
].value
= key
;
133 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
139 <body id
="body_browse_foreigners">
141 <form action
="browse_foreigners.php" method
="post">
143 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
144 <input type
="hidden" name
="field" value
="<?php echo urlencode($field); ?>" />
145 <input type
="hidden" name
="fieldkey"
146 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"
153 value
="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
154 <input type
="submit" name
="submit_foreign_filter" value
="<?php echo $strGo;?>" />
156 <span
class="formelement">
157 <?php
echo $gotopage; ?
>
159 <span
class="formelement">
160 <?php
echo $showall; ?
>
167 if (isset($disp_row) && is_array($disp_row)) {
169 <th>' . $strKeyname . '</th>
170 <th>' . $strDescription . '</th>
171 <td width="20%"></td>
172 <th>' . $strDescription . '</th>
173 <th>' . $strKeyname . '</th>
176 echo '<thead>' . $header . '</thead>' . "\n"
177 .'<tfoot>' . $header . '</tfoot>' . "\n"
182 foreach ($disp_row as $relrow) {
183 if ($foreign_display != FALSE) {
184 $values[] = $relrow[$foreign_display];
189 $keys[] = $relrow[$foreign_field];
196 $val_ordered_current_row = 0;
197 $val_ordered_current_equals_data = false;
198 $key_ordered_current_equals_data = false;
199 foreach ($keys as $key_ordered_current_row => $value) {
200 //for ($i = 0; $i < $count; $i++) {
203 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
209 $key_ordered_current_key = $keys[$key_ordered_current_row];
210 $key_ordered_current_val = $values[$key_ordered_current_row];
212 $val_ordered_current_key = $keys[$val_ordered_current_row];
213 $val_ordered_current_val = $values[$val_ordered_current_row];
215 $val_ordered_current_row++
;
217 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
218 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
219 $val_ordered_current_val_title = '';
221 $val_ordered_current_val_title =
222 htmlspecialchars($val_ordered_current_val);
223 $val_ordered_current_val =
224 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
225 $cfg['LimitChars']) . '...');
227 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
228 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
229 $key_ordered_current_val_title = '';
231 $key_ordered_current_val_title =
232 htmlspecialchars($key_ordered_current_val);
233 $key_ordered_current_val =
234 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
235 $cfg['LimitChars']) . '...');
238 if (! empty($data)) {
239 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
240 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
244 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
247 echo ($key_ordered_current_equals_data ?
'<b>' : '')
248 .'<a href="#" title="' . $strUseThisValue
249 . ($key_ordered_current_val_title != '' ?
': ' . $key_ordered_current_val_title : '') . '"'
250 .' onclick="formupdate(\'' . md5($field) . '\', \''
251 . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
252 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ?
'</b>' : '');
256 echo ($key_ordered_current_equals_data ?
'<b>' : '')
257 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ?
': '
258 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
259 . md5($field) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
260 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ?
'</b>' : '');
263 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
264 alt
="" width
="1" height
="1"></td
>
268 echo ($val_ordered_current_equals_data ?
'<b>' : '')
269 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': '
270 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
271 . '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); return false;">'
272 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ?
'</b>' : '');
276 echo ($val_ordered_current_equals_data ?
'<b>' : '') . '<a href="#" title="'
277 . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': ' . $val_ordered_current_val_title : '')
278 . '" onclick="formupdate(\'' . md5($field) . '\', \''
279 . htmlspecialchars($val_ordered_current_key) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
280 . '</a>' . ($val_ordered_current_equals_data ?
'</b>' : '');
295 * Close MySql connections
297 if (isset($controllink) && $controllink) {
298 @PMA_DBI_close
($controllink);
300 if (isset($userlink) && $userlink) {
301 @PMA_DBI_close
($userlink);