2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * display selection for relational field values
11 * Gets a core script and starts output buffering work
13 require_once './libraries/common.inc.php';
15 PMA_checkParameters(array('db', 'table', 'field'));
17 require_once './libraries/ob.lib.php';
20 require_once './libraries/header_http.inc.php';
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 $foreignData = PMA_getForeignData($foreigners, $field, $override_total, isset($foreign_filter) ?
$foreign_filter : '', $foreign_limit);
45 $pk_uri = '&pk=' . urlencode($pk);
47 <input type
="hidden" name
="pk" value
="<?php echo htmlspecialchars($pk); ?>" />
56 if (is_array($foreignData['disp_row'])) {
58 if ($cfg['ShowAll'] && ($foreignData['the_total'] > $per_page)) {
59 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
62 $session_max_rows = $per_page;
63 $pageNow = @floor
($pos / $session_max_rows) +
1;
64 $nbTotalPage = @ceil
($foreignData['the_total'] / $session_max_rows);
66 if ($foreignData['the_total'] > $per_page) {
67 $gotopage = PMA_pageselector(
68 'browse_foreigners.php?field=' . urlencode($field) .
69 '&' . PMA_generate_common_url($db, $table)
71 '&fieldkey=' . (isset($fieldkey) ?
urlencode($fieldkey) : '') .
72 '&foreign_filter=' . (isset($foreign_filter) ?
urlencode($foreign_filter) : '') .
82 $GLOBALS['strPageNumber']
87 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
88 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
89 <html xmlns
="http://www.w3.org/1999/xhtml"
90 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
91 lang
="<?php echo $available_languages[$lang][2]; ?>"
92 dir
="<?php echo $text_dir; ?>">
95 <title
>phpMyAdmin
</title
>
96 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
97 <link rel
="stylesheet" type
="text/css"
98 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=right&nocache=<?php echo $_SESSION['PMA_Config']->getThemeUniqueValue(); ?>" />
99 <script src
="./js/functions.js" type
="text/javascript"></script
>
100 <script type
="text/javascript">
103 function formupdate(field
, key
) {
104 if (opener
&& opener
.document
&& opener
.document
.insertForm
) {
105 var field
= 'field_' + field
;
107 <?php
if (isset($pk)) { ?
>
108 var element_name
= field +
'[multi_edit][<?php echo htmlspecialchars($pk); ?>][]';
110 var element_name
= field +
'[]';
113 <?php
if (isset($fieldkey) && is_numeric($fieldkey)) { ?
>
114 var element_name_alt
= field +
'[<?php echo $fieldkey; ?>]';
116 var element_name_alt
= field +
'[0]';
119 if (opener
.document
.insertForm
.elements
[element_name
]) {
121 opener
.document
.insertForm
.elements
[element_name
].value
= key
;
124 } else if (opener
.document
.insertForm
.elements
[element_name_alt
]) {
126 opener
.document
.insertForm
.elements
[element_name_alt
].value
= key
;
132 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
138 <body id
="body_browse_foreigners">
140 <form action
="browse_foreigners.php" method
="post">
142 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
143 <input type
="hidden" name
="field" value
="<?php echo htmlspecialchars($field); ?>" />
144 <input type
="hidden" name
="fieldkey"
145 value
="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
146 <?php
if (isset($pk)) { ?
>
147 <input type
="hidden" name
="pk" value
="<?php echo htmlspecialchars($pk); ?>" />
149 <span
class="formelement">
150 <label
for="input_foreign_filter"><?php
echo $strSearch . ':'; ?
></label
>
151 <input type
="text" name
="foreign_filter" id
="input_foreign_filter"
152 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 (is_array($foreignData['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 ($foreignData['disp_row'] as $relrow) {
182 if ($foreignData['foreign_display'] != FALSE) {
183 $values[] = $relrow[$foreignData['foreign_display']];
188 $keys[] = $relrow[$foreignData['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 ?
'<strong>' : '')
247 .'<a href="#" title="' . $strUseThisValue
248 . ($key_ordered_current_val_title != '' ?
': ' . $key_ordered_current_val_title : '') . '"'
249 .' onclick="formupdate(\'' . md5($field) . '\', \''
250 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
251 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ?
'</strong>' : '');
255 echo ($key_ordered_current_equals_data ?
'<strong>' : '')
256 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ?
': '
257 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
258 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
259 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ?
'</strong>' : '');
262 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
263 alt
="" width
="1" height
="1"></td
>
267 echo ($val_ordered_current_equals_data ?
'<strong>' : '')
268 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': '
269 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
270 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
271 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ?
'</strong>' : '');
275 echo ($val_ordered_current_equals_data ?
'<strong>' : '') . '<a href="#" title="'
276 . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': ' . $val_ordered_current_val_title : '')
277 . '" onclick="formupdate(\'' . md5($field) . '\', \''
278 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
279 . '</a>' . ($val_ordered_current_equals_data ?
'</strong>' : '');