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) : '') .
82 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
83 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
84 <html xmlns
="http://www.w3.org/1999/xhtml"
85 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
86 lang
="<?php echo $available_languages[$lang][2]; ?>"
87 dir
="<?php echo $text_dir; ?>">
90 <title
>phpMyAdmin
</title
>
91 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
92 <link rel
="stylesheet" type
="text/css"
93 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=right&nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
94 <script src
="./js/functions.js" type
="text/javascript"></script
>
95 <script type
="text/javascript">
98 function formupdate(field
, key
) {
99 if (opener
&& opener
.document
&& opener
.document
.insertForm
) {
100 var field
= 'field_' + field
;
102 <?php
if (isset($pk)) { ?
>
103 var element_name
= field +
'[multi_edit][<?php echo urlencode($pk); ?>][]';
105 var element_name
= field +
'[]';
108 <?php
if (isset($fieldkey) && is_numeric($fieldkey)) { ?
>
109 var element_name_alt
= field +
'[<?php echo $fieldkey; ?>]';
111 var element_name_alt
= field +
'[0]';
114 if (opener
.document
.insertForm
.elements
[element_name
]) {
116 opener
.document
.insertForm
.elements
[element_name
].value
= key
;
119 } else if (opener
.document
.insertForm
.elements
[element_name_alt
]) {
121 opener
.document
.insertForm
.elements
[element_name_alt
].value
= key
;
127 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
133 <body id
="body_browse_foreigners">
135 <form action
="browse_foreigners.php" method
="post">
137 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
138 <input type
="hidden" name
="field" value
="<?php echo urlencode($field); ?>" />
139 <input type
="hidden" name
="fieldkey"
140 value
="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
141 <?php
if (isset($pk)) { ?
>
142 <input type
="hidden" name
="pk" value
="<?php echo urlencode($pk); ?>" />
144 <span
class="formelement">
145 <label
for="input_foreign_filter"><?php
echo $strSearch . ':'; ?
></label
>
146 <input type
="text" name
="foreign_filter" id
="input_foreign_filter"
147 value
="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
148 <input type
="submit" name
="submit_foreign_filter" value
="<?php echo $strGo;?>" />
150 <span
class="formelement">
151 <?php
echo $gotopage; ?
>
153 <span
class="formelement">
154 <?php
echo $showall; ?
>
161 if (isset($disp_row) && is_array($disp_row)) {
163 <th>' . $strKeyname . '</th>
164 <th>' . $strDescription . '</th>
165 <td width="20%"></td>
166 <th>' . $strDescription . '</th>
167 <th>' . $strKeyname . '</th>
170 echo '<thead>' . $header . '</thead>' . "\n"
171 .'<tfoot>' . $header . '</tfoot>' . "\n"
176 foreach ($disp_row as $relrow) {
177 if ($foreign_display != FALSE) {
178 $values[] = $relrow[$foreign_display];
183 $keys[] = $relrow[$foreign_field];
190 $val_ordered_current_row = 0;
191 $val_ordered_current_equals_data = false;
192 $key_ordered_current_equals_data = false;
193 foreach ($keys as $key_ordered_current_row => $value) {
194 //for ($i = 0; $i < $count; $i++) {
197 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
203 $key_ordered_current_key = $keys[$key_ordered_current_row];
204 $key_ordered_current_val = $values[$key_ordered_current_row];
206 $val_ordered_current_key = $keys[$val_ordered_current_row];
207 $val_ordered_current_val = $values[$val_ordered_current_row];
209 $val_ordered_current_row++
;
211 if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
212 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
213 $val_ordered_current_val_title = '';
215 $val_ordered_current_val_title =
216 htmlspecialchars($val_ordered_current_val);
217 $val_ordered_current_val =
218 htmlspecialchars(PMA_substr($val_ordered_current_val, 0,
219 $cfg['LimitChars']) . '...');
221 if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
222 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
223 $key_ordered_current_val_title = '';
225 $key_ordered_current_val_title =
226 htmlspecialchars($key_ordered_current_val);
227 $key_ordered_current_val =
228 htmlspecialchars(PMA_substr($key_ordered_current_val, 0,
229 $cfg['LimitChars']) . '...');
232 if (! empty($data)) {
233 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
234 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
238 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
241 echo ($key_ordered_current_equals_data ?
'<b>' : '')
242 .'<a href="#" title="' . $strUseThisValue
243 . ($key_ordered_current_val_title != '' ?
': ' . $key_ordered_current_val_title : '') . '"'
244 .' onclick="formupdate(\'' . md5($field) . '\', \''
245 . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
246 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ?
'</b>' : '');
250 echo ($key_ordered_current_equals_data ?
'<b>' : '')
251 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ?
': '
252 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
253 . md5($field) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
254 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ?
'</b>' : '');
257 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
258 alt
="" width
="1" height
="1"></td
>
262 echo ($val_ordered_current_equals_data ?
'<b>' : '')
263 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': '
264 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
265 . '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); return false;">'
266 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ?
'</b>' : '');
270 echo ($val_ordered_current_equals_data ?
'<b>' : '') . '<a href="#" title="'
271 . $strUseThisValue . ($val_ordered_current_val_title != '' ?
': ' . $val_ordered_current_val_title : '')
272 . '" onclick="formupdate(\'' . md5($field) . '\', \''
273 . htmlspecialchars($val_ordered_current_key) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
274 . '</a>' . ($val_ordered_current_equals_data ?
'</b>' : '');
289 * Close MySql connections
291 if (isset($controllink) && $controllink) {
292 @PMA_DBI_close
($controllink);
294 if (isset($userlink) && $userlink) {
295 @PMA_DBI_close
($userlink);