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/relation.lib.php'; // foreign keys
26 require_once './libraries/transformations.lib.php'; // Transformations
27 $cfgRelation = PMA_getRelationsParam();
28 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
30 $override_total = TRUE;
36 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
37 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
38 unset($foreign_limit);
41 $foreignData = PMA_getForeignData($foreigners, $field, $override_total, isset($foreign_filter) ?
$foreign_filter : '', $foreign_limit);
44 $pk_uri = '&pk=' . urlencode($pk);
46 <input type
="hidden" name
="pk" value
="<?php echo htmlspecialchars($pk); ?>" />
55 if (is_array($foreignData['disp_row'])) {
57 if ($cfg['ShowAll'] && ($foreignData['the_total'] > $per_page)) {
58 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
61 $session_max_rows = $per_page;
62 $pageNow = @floor
($pos / $session_max_rows) +
1;
63 $nbTotalPage = @ceil
($foreignData['the_total'] / $session_max_rows);
65 if ($foreignData['the_total'] > $per_page) {
66 $gotopage = PMA_pageselector(
67 'browse_foreigners.php?field=' . urlencode($field) .
68 '&' . PMA_generate_common_url($db, $table)
70 '&fieldkey=' . (isset($fieldkey) ?
urlencode($fieldkey) : '') .
71 '&foreign_filter=' . (isset($foreign_filter) ?
urlencode($foreign_filter) : '') .
81 $GLOBALS['strPageNumber']
86 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
87 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
88 <html xmlns
="http://www.w3.org/1999/xhtml"
89 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
90 lang
="<?php echo $available_languages[$lang][2]; ?>"
91 dir
="<?php echo $text_dir; ?>">
94 <title
>phpMyAdmin
</title
>
95 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
96 <link rel
="stylesheet" type
="text/css"
97 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=right&nocache=<?php echo $_SESSION['PMA_Config']->getThemeUniqueValue(); ?>" />
98 <script src
="./js/functions.js" type
="text/javascript"></script
>
99 <script type
="text/javascript">
102 function formupdate(field
, key
) {
103 if (opener
&& opener
.document
&& opener
.document
.insertForm
) {
104 var field
= 'field_' + field
;
106 <?php
if (isset($pk)) { ?
>
107 var element_name
= field +
'[multi_edit][<?php echo htmlspecialchars($pk); ?>][]';
109 var element_name
= field +
'[]';
112 <?php
if (isset($fieldkey) && is_numeric($fieldkey)) { ?
>
113 var element_name_alt
= field +
'[<?php echo $fieldkey; ?>]';
115 var element_name_alt
= field +
'[0]';
118 if (opener
.document
.insertForm
.elements
[element_name
]) {
120 opener
.document
.insertForm
.elements
[element_name
].value
= key
;
123 } else if (opener
.document
.insertForm
.elements
[element_name_alt
]) {
125 opener
.document
.insertForm
.elements
[element_name_alt
].value
= key
;
131 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
137 <body id
="body_browse_foreigners">
139 <form action
="browse_foreigners.php" method
="post">
141 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
142 <input type
="hidden" name
="field" value
="<?php echo htmlspecialchars($field); ?>" />
143 <input type
="hidden" name
="fieldkey"
144 value
="<?php echo isset($fieldkey) ? htmlspecialchars($fieldkey) : ''; ?>" />
145 <?php
if (isset($pk)) { ?
>
146 <input type
="hidden" name
="pk" value
="<?php echo htmlspecialchars($pk); ?>" />
148 <span
class="formelement">
149 <label
for="input_foreign_filter"><?php
echo $strSearch . ':'; ?
></label
>
150 <input type
="text" name
="foreign_filter" id
="input_foreign_filter"
151 value
="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
152 <input type
="submit" name
="submit_foreign_filter" value
="<?php echo $strGo;?>" />
154 <span
class="formelement">
155 <?php
echo $gotopage; ?
>
157 <span
class="formelement">
158 <?php
echo $showall; ?
>
165 if (is_array($foreignData['disp_row'])) {
167 <th>' . $strKeyname . '</th>
168 <th>' . $strDescription . '</th>
169 <td width="20%"></td>
170 <th>' . $strDescription . '</th>
171 <th>' . $strKeyname . '</th>
174 echo '<thead>' . $header . '</thead>' . "\n"
175 .'<tfoot>' . $header . '</tfoot>' . "\n"
180 foreach ($foreignData['disp_row'] as $relrow) {
181 if ($foreignData['foreign_display'] != FALSE) {
182 $values[] = $relrow[$foreignData['foreign_display']];
187 $keys[] = $relrow[$foreignData['foreign_field']];
194 $val_ordered_current_row = 0;
195 $val_ordered_current_equals_data = false;
196 $key_ordered_current_equals_data = false;
197 foreach ($keys as $key_ordered_current_row => $value) {
198 //for ($i = 0; $i < $count; $i++) {
201 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
207 $key_ordered_current_key = $keys[$key_ordered_current_row];
208 $key_ordered_current_val = $values[$key_ordered_current_row];
210 $val_ordered_current_key = $keys[$val_ordered_current_row];
211 $val_ordered_current_val = $values[$val_ordered_current_row];
213 $val_ordered_current_row++
;
215 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
216 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
217 $val_ordered_current_val_title = '';
219 $val_ordered_current_val_title =
220 htmlspecialchars($val_ordered_current_val);
221 $val_ordered_current_val =
222 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
223 $cfg['LimitChars']) . '...');
225 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
226 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
227 $key_ordered_current_val_title = '';
229 $key_ordered_current_val_title =
230 htmlspecialchars($key_ordered_current_val);
231 $key_ordered_current_val =
232 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
233 $cfg['LimitChars']) . '...');
236 if (! empty($data)) {
237 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
238 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
242 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
245 echo ($key_ordered_current_equals_data ?
'<b>' : '')
246 .'<a href="#" title="' . $strUseThisValue
247 . ($key_ordered_current_val_title != '' ?
': ' . $key_ordered_current_val_title : '') . '"'
248 .' onclick="formupdate(\'' . md5($field) . '\', \''
249 . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
250 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ?
'</b>' : '');
254 echo ($key_ordered_current_equals_data ?
'<b>' : '')
255 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ?
': '
256 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
257 . md5($field) . '\', \'' . PMA_jsFormat($key_ordered_current_key, false) . '\'); return false;">'
258 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ?
'</b>' : '');
261 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
262 alt
="" width
="1" height
="1"></td
>
266 echo ($val_ordered_current_equals_data ?
'<b>' : '')
267 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': '
268 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
269 . '\', \'' . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">'
270 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ?
'</b>' : '');
274 echo ($val_ordered_current_equals_data ?
'<b>' : '') . '<a href="#" title="'
275 . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': ' . $val_ordered_current_val_title : '')
276 . '" onclick="formupdate(\'' . md5($field) . '\', \''
277 . PMA_jsFormat($val_ordered_current_key, false) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
278 . '</a>' . ($val_ordered_current_equals_data ?
'</b>' : '');