00001 <?php
00002
00003
00004
00008 require_once('./libraries/grab_globals.lib.php');
00009
00013 require_once('./libraries/common.lib.php');
00014
00015 PMA_checkParameters(array('db', 'table', 'field'));
00016
00017 require_once('./libraries/ob.lib.php');
00018 if ($cfg['OBGzip']) {
00019 $ob_mode = PMA_outBufferModeGet();
00020 if ($ob_mode) {
00021 PMA_outBufferPre($ob_mode);
00022 }
00023 }
00024 require_once('./libraries/header_http.inc.php');
00025 $field = urldecode($field);
00026
00030
00031 PMA_setFontSizes();
00032 ?>
00033 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
00034 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00035 <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; ?>">
00036
00037 <head>
00038 <title>phpMyAdmin</title>
00039 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
00040 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
00041 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&js_frame=right" />
00042 <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
00043 <script type="text/javascript" language="javascript">
00044 self.focus();
00045 function formupdate(field, key) {
00046 if (opener && opener.document && opener.document.insertForm && opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . $pk . ']' : ''); ?>[]']) {
00047 opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . $pk . ']' : ''); ?>[]'].value = key;
00048 self.close();
00049 } else {
00050 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
00051 }
00052 }
00053 </script>
00054 </head>
00055
00056 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
00057 <?php
00058 $per_page = 200;
00059 require_once('./libraries/relation.lib.php');
00060 require_once('./libraries/transformations.lib.php');
00061 $cfgRelation = PMA_getRelationsParam();
00062 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
00063
00064 $override_total = TRUE;
00065
00066 if (!isset($pos)) {
00067 $pos = 0;
00068 }
00069
00070 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
00071 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
00072 unset($foreign_limit);
00073 }
00074
00075 require('./libraries/get_foreign.lib.php');
00076 ?>
00077
00078 <form action="browse_foreigners.php" method="post">
00079 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00080 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
00081 <?php
00082 if (isset($pk)) {
00083 $pk_uri = '&pk=' . $pk;
00084 ?>
00085 <input type="hidden" name="pk" value="<?php echo $pk; ?>" />
00086 <?php
00087 } else {
00088 $pk_uri = '&';
00089 }
00090 ?>
00091
00092 <table width="100%">
00093 <?php
00094 if ($cfg['ShowAll'] && ($the_total > $per_page)) {
00095 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
00096 } else {
00097 $showall = '';
00098 }
00099
00100 $session_max_rows = $per_page;
00101 $pageNow = @floor($pos / $session_max_rows) + 1;
00102 $nbTotalPage = @ceil($the_total / $session_max_rows);
00103
00104 if ($the_total > $per_page) {
00105 $gotopage = '<br />' . $GLOBALS['strPageNumber']
00106 . '<select name="goToPage" onChange="goToUrl(this, \'browse_foreigners.php?field=' . urlencode($field) . '&' . PMA_generate_common_url($db, $table) . $pk_uri . '\');">';
00107 if ($nbTotalPage < 200) {
00108 $firstPage = 1;
00109 $lastPage = $nbTotalPage;
00110 } else {
00111 $range = 20;
00112 $firstPage = ($pageNow - $range < 1 ? 1 : $pageNow - $range);
00113 $lastPage = ($pageNow + $range > $nbTotalPage ? $nbTotalPage : $pageNow + $range);
00114 }
00115
00116 for ($i=$firstPage; $i<=$lastPage; $i++){
00117 if ($i == $pageNow) {
00118 $selected = 'selected="selected"';
00119 } else {
00120 $selected = '';
00121 }
00122 $gotopage .= ' <option ' . $selected . ' value="' . (($i - 1) * $session_max_rows) . '">' . $i . '</option>' . "\n";
00123 }
00124 } else {
00125 $gotopage = '';
00126 }
00127
00128 $header = ' <tr>
00129 <th align="left" nowrap="nowrap">' . $strKeyname . '</th>
00130 <th>' . $strDescription . '</th>
00131 <td align="center" width="20%" valign="top">
00132 ' . $showall . '
00133 ' . $gotopage . '
00134 </td>
00135 <th>' . $strDescription . '</th>
00136 <th align="left" nowrap="nowrap">' . $strKeyname . '</th>
00137 </tr>';
00138
00139 echo $header;
00140
00141 if (isset($disp) && $disp) {
00142 function dimsort($arrayA, $arrayB) {
00143 $keyA = key($arrayA);
00144 $keyB = key($arrayB);
00145
00146 if ($arrayA[$keyA] == $arrayB[$keyB]) {
00147 return 0;
00148 }
00149
00150 return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1;
00151 }
00152
00153 $mysql_key_relrow = array();
00154 $mysql_val_relrow = array();
00155 $count = 0;
00156 while ($relrow = @PMA_mysql_fetch_array($disp)) {
00157 if ($foreign_display != FALSE) {
00158 $val = $relrow[$foreign_display];
00159 } else {
00160 $val = '';
00161 }
00162
00163 $mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val);
00164 $mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]);
00165 $count++;
00166 }
00167
00168 usort($mysql_val_relrow, 'dimsort');
00169
00170 $hcount = 0;
00171 for ($i = 0; $i < $count; $i++) {
00172 $hcount++;
00173 $bgcolor = ($hcount % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
00174
00175 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
00176 echo $header;
00177 $hcount = -1;
00178 }
00179
00180
00181 $val = key($mysql_val_relrow[$i]);
00182 $key = $mysql_val_relrow[$i][$val];
00183
00184 if (strlen($val) <= $cfg['LimitChars']) {
00185 $value = htmlspecialchars($val);
00186 $vtitle = '';
00187 } else {
00188 $vtitle = htmlspecialchars($val);
00189 $value = htmlspecialchars(substr($val, 0, $cfg['LimitChars']) . '...');
00190 }
00191
00192 $key_equals_data = isset($data) && $key == $data;
00193 ?>
00194 <tr>
00195 <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>
00196 <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>
00197 <td width="20%"><img src="images/spacer.gif" alt="" width="1" height="1"></td>
00198 <?php
00199 $key = key($mysql_key_relrow[$i]);
00200 $val = $mysql_key_relrow[$i][$key];
00201 if (strlen($val) <= $cfg['LimitChars']) {
00202 $value = htmlspecialchars($val);
00203 $vtitle = '';
00204 } else {
00205 $vtitle = htmlspecialchars($val);
00206 $value = htmlspecialchars(substr($val, 0, $cfg['LimitChars']) . '...');
00207 }
00208
00209 $key_equals_data = isset($data) && $key == $data;
00210 ?>
00211 <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>
00212 <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>
00213 </tr>
00214 <?php
00215 unset($key_equals_data);
00216 }
00217 }
00218
00219 echo $header;
00220 ?>
00221 </table>
00222 </form>
00223
00224 </body>
00225 </html>
00226
00227 <?php
00231 if (isset($dbh) && $dbh) {
00232 @mysql_close($dbh);
00233 }
00234 if (isset($userlink) && $userlink) {
00235 @mysql_close($userlink);
00236 }
00237
00238
00242 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
00243 && isset($ob_mode) && $ob_mode) {
00244 PMA_outBufferPost($ob_mode);
00245 }
00246 ?>