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';
25 require_once './libraries/transformations.lib.php'; // Transformations
26 $cfgRelation = PMA_getRelationsParam();
27 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
29 $override_total = TRUE;
35 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
36 if (isset($foreign_navig) && $foreign_navig == __('Show all')) {
37 unset($foreign_limit);
40 $foreignData = PMA_getForeignData($foreigners, $field, $override_total, isset($foreign_filter) ?
$foreign_filter : '', $foreign_limit);
43 $pk_uri = '&pk=' . urlencode($pk);
45 <input type
="hidden" name
="pk" value
="<?php echo htmlspecialchars($pk); ?>" />
54 if (is_array($foreignData['disp_row'])) {
56 if ($cfg['ShowAll'] && ($foreignData['the_total'] > $per_page)) {
57 $showall = '<input type="submit" name="foreign_navig" value="' . __('Show all') . '" />';
60 $session_max_rows = $per_page;
61 $pageNow = @floor
($pos / $session_max_rows) +
1;
62 $nbTotalPage = @ceil
($foreignData['the_total'] / $session_max_rows);
64 if ($foreignData['the_total'] > $per_page) {
65 $gotopage = PMA_pageselector(
66 'browse_foreigners.php?field=' . urlencode($field) .
67 '&' . PMA_generate_common_url($db, $table)
69 '&fieldkey=' . (isset($fieldkey) ?
urlencode($fieldkey) : '') .
70 '&foreign_filter=' . (isset($foreign_filter) ?
urlencode($foreign_filter) : '') .
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][1]; ?>"
89 lang
="<?php echo $available_languages[$lang][1]; ?>"
90 dir
="<?php echo $text_dir; ?>">
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
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=right&nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
97 <script src
="./js/functions.js" type
="text/javascript"></script
>
98 <script type
="text/javascript">
101 function formupdate(field
, key
) {
102 if (opener
&& opener
.document
&& opener
.document
.insertForm
) {
103 var field
= 'field_' + field
;
105 <?php
if (isset($pk)) { ?
>
106 var element_name
= field +
'[multi_edit][<?php echo htmlspecialchars($pk); ?>][]';
108 var element_name
= field +
'[]';
111 <?php
if (isset($fieldkey) && is_numeric($fieldkey)) { ?
>
112 var element_name_alt
= field +
'[<?php echo $fieldkey; ?>]';
114 var element_name_alt
= field +
'[0]';
117 if (opener
.document
.insertForm
.elements
[element_name
]) {
119 opener
.document
.insertForm
.elements
[element_name
].value
= key
;
122 } else if (opener
.document
.insertForm
.elements
[element_name_alt
]) {
124 opener
.document
.insertForm
.elements
[element_name_alt
].value
= key
;
130 alert('<?php echo PMA_jsFormat(__('The target browser window could not be updated
. Maybe you have closed the parent window
, or your browser\'s security settings are configured to block cross
-window updates
.')); ?>');
136 <body id
="body_browse_foreigners">
138 <form action
="browse_foreigners.php" method
="post">
140 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
141 <input type
="hidden" name
="field" value
="<?php echo htmlspecialchars($field); ?>" />
142 <input type
="hidden" name
="fieldkey"
143 value
="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
144 <?php
if (isset($pk)) { ?
>
145 <input type
="hidden" name
="pk" value
="<?php echo htmlspecialchars($pk); ?>" />
147 <span
class="formelement">
148 <label
for="input_foreign_filter"><?php
echo __('Search') . ':'; ?
></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 __('Go');?>" />
153 <span
class="formelement">
154 <?php
echo $gotopage; ?
>
156 <span
class="formelement">
157 <?php
echo $showall; ?
>
164 if (is_array($foreignData['disp_row'])) {
166 <th>' . __('Keyname') . '</th>
167 <th>' . __('Description') . '</th>
168 <td width="20%"></td>
169 <th>' . __('Description') . '</th>
170 <th>' . __('Keyname') . '</th>
173 echo '<thead>' . $header . '</thead>' . "\n"
174 .'<tfoot>' . $header . '</tfoot>' . "\n"
179 foreach ($foreignData['disp_row'] as $relrow) {
180 if ($foreignData['foreign_display'] != FALSE) {
181 $values[] = $relrow[$foreignData['foreign_display']];
186 $keys[] = $relrow[$foreignData['foreign_field']];
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++) {
200 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
206 $key_ordered_current_key = $keys[$key_ordered_current_row];
207 $key_ordered_current_val = $values[$key_ordered_current_row];
209 $val_ordered_current_key = $keys[$val_ordered_current_row];
210 $val_ordered_current_val = $values[$val_ordered_current_row];
212 $val_ordered_current_row++
;
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 = '';
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']) . '...');
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 = '';
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']) . '...');
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;
241 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
244 echo ($key_ordered_current_equals_data ?
'<strong>' : '')
245 .'<a href="#" title="' . __('Use this value')
246 . ($key_ordered_current_val_title != '' ?
': ' . $key_ordered_current_val_title : '') . '"'
247 .' onclick="formupdate(\'' . md5($field) . '\', \''
248 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
249 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ?
'</strong>' : '');
253 echo ($key_ordered_current_equals_data ?
'<strong>' : '')
254 . '<a href="#" title="' . __('Use this value') . ($key_ordered_current_val_title != '' ?
': '
255 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
256 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
257 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ?
'</strong>' : '');
260 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
261 alt
="" width
="1" height
="1"></td
>
265 echo ($val_ordered_current_equals_data ?
'<strong>' : '')
266 . '<a href="#" title="' . __('Use this value') . ($val_ordered_current_val_title != '' ?
': '
267 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
268 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
269 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ?
'</strong>' : '');
273 echo ($val_ordered_current_equals_data ?
'<strong>' : '') . '<a href="#" title="'
274 . __('Use this value') . ($val_ordered_current_val_title != '' ?
': ' . $val_ordered_current_val_title : '')
275 . '" onclick="formupdate(\'' . md5($field) . '\', \''
276 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
277 . '</a>' . ($val_ordered_current_equals_data ?
'</strong>' : '');