3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Get the variables sent or posted to this script and displays the header
8 require_once('./libraries/grab_globals.lib.php');
11 * Gets a core script and starts output buffering work
13 require_once('./libraries/common.lib.php');
15 PMA_checkParameters(array('db', 'table', 'field'));
17 require_once('./libraries/ob.lib.php');
19 $ob_mode = PMA_outBufferModeGet();
21 PMA_outBufferPre($ob_mode);
24 require_once('./libraries/header_http.inc.php');
25 $field = urldecode($field);
30 // Gets the font sizes to use
33 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
34 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
35 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="<?php echo $available_languages[$lang][2]; ?>" lang
="<?php echo $available_languages[$lang][2]; ?>" dir
="<?php echo $text_dir; ?>">
38 <title
>phpMyAdmin
</title
>
39 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
40 <base
<?php
if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?
> />
41 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&js_frame=right" />
42 <script src
="libraries/functions.js" type
="text/javascript" language
="javascript"></script
>
43 <script type
="text/javascript" language
="javascript">
45 function formupdate(field
, key
) {
46 if (opener
&& opener
.document
&& opener
.document
.insertForm
) {
47 if (opener
.document
.insertForm
.elements
['field_' + field +
'<?php echo (isset($pk) ? '[multi_edit
][' . urlencode($pk) . ']' : ''); ?>[]']) {
49 opener
.document
.insertForm
.elements
['field_' + field +
'<?php echo (isset($pk) ? '[multi_edit
][' . urlencode($pk) . ']' : ''); ?>[]'].value
= key
;
52 } else if (opener
.document
.insertForm
.elements
['field_' + field +
'[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]']) {
54 opener
.document
.insertForm
.elements
['field_' + field +
'[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]'].value
= key
;
60 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
65 <body bgcolor
="<?php echo $cfg['LeftBgColor']; ?>" style
="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
68 require_once('./libraries/relation.lib.php'); // foreign keys
69 require_once('./libraries/transformations.lib.php'); // Transformations
70 $cfgRelation = PMA_getRelationsParam();
71 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
73 $override_total = TRUE;
79 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
80 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
81 unset($foreign_limit);
84 require('./libraries/get_foreign.lib.php');
87 <form action
="browse_foreigners.php" method
="post">
88 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
89 <input type
="hidden" name
="field" value
="<?php echo urlencode($field); ?>" />
90 <input type
="hidden" name
="fieldkey" value
="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
93 $pk_uri = '&pk=' . urlencode($pk);
95 <input type
="hidden" name
="pk" value
="<?php echo urlencode($pk); ?>" />
104 if ($cfg['ShowAll'] && ($the_total > $per_page)) {
105 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
110 $session_max_rows = $per_page;
111 $pageNow = @floor
($pos / $session_max_rows) +
1;
112 $nbTotalPage = @ceil
($the_total / $session_max_rows);
114 if ($the_total > $per_page) {
115 $gotopage = PMA_pageselector(
116 'browse_foreigners.php?field=' . urlencode($field) .
117 '&' . PMA_generate_common_url($db, $table)
119 '&fieldkey=' . (isset($fieldkey) ?
$fieldkey : '') .
130 <th align="left" nowrap="nowrap">' . $strKeyname . '</th>
131 <th>' . $strDescription . '</th>
132 <td align="center" width="20%" valign="top">
136 <th>' . $strDescription . '</th>
137 <th align="left" nowrap="nowrap">' . $strKeyname . '</th>
142 if (isset($disp_row) && is_array($disp_row)) {
143 function dimsort($arrayA, $arrayB) {
144 $keyA = key($arrayA);
145 $keyB = key($arrayB);
147 if ($arrayA[$keyA] == $arrayB[$keyB]) {
151 return ($arrayA[$keyA] < $arrayB[$keyB]) ?
-1 : 1;
154 $mysql_key_relrow = array();
155 $mysql_val_relrow = array();
157 foreach ($disp_row AS $disp_row_key => $relrow) {
158 if ($foreign_display != FALSE) {
159 $val = $relrow[$foreign_display];
164 $mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val);
165 $mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]);
169 usort($mysql_val_relrow, 'dimsort');
172 for ($i = 0; $i < $count; $i++
) {
174 $bgcolor = ($hcount %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
176 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
182 $val = key($mysql_val_relrow[$i]);
183 $key = $mysql_val_relrow[$i][$val];
185 if (PMA_strlen($val) <= $cfg['LimitChars']) {
186 $value = htmlspecialchars($val);
189 $vtitle = htmlspecialchars($val);
190 $value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...');
193 $key_equals_data = isset($data) && $key == $data;
196 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($key_equals_data ?
'<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ?
': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . htmlspecialchars($key) . '</a>' . ($key_equals_data ?
'</b>' : ''); ?
></td
>
197 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($key_equals_data ?
'<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ?
': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . $value . '</a>' . ($key_equals_data ?
'</b>' : ''); ?
></td
>
198 <td width
="20%"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" alt
="" width
="1" height
="1"></td
>
200 $key = key($mysql_key_relrow[$i]);
201 $val = $mysql_key_relrow[$i][$key];
202 if (PMA_strlen($val) <= $cfg['LimitChars']) {
203 $value = htmlspecialchars($val);
206 $vtitle = htmlspecialchars($val);
207 $value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...');
210 $key_equals_data = isset($data) && $key == $data;
212 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($key_equals_data ?
'<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ?
': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . $value . '</a>' . ($key_equals_data ?
'</b>' : ''); ?
></td
>
213 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($key_equals_data ?
'<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ?
': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . htmlspecialchars($key) . '</a>' . ($key_equals_data ?
'</b>' : ''); ?
></td
>
216 unset($key_equals_data);
230 * Close MySql connections
232 if (isset($dbh) && $dbh) {
233 @PMA_DBI_close
($dbh);
235 if (isset($userlink) && $userlink) {
236 @PMA_DBI_close
($userlink);
241 * Sends bufferized data
243 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
244 && isset($ob_mode) && $ob_mode) {
245 PMA_outBufferPost($ob_mode);