Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: browse_foreigners.php,v 2.20 2005/07/22 17:21:10 lem9 Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 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 // Gets the font sizes to use 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) { 00047 if (opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . urlencode($pk) . ']' : ''); ?>[]']) { 00048 // Edit/Insert form 00049 opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . urlencode($pk) . ']' : ''); ?>[]'].value = key; 00050 self.close(); 00051 return false; 00052 } else if (opener.document.insertForm.elements['field_' + field + '[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]']) { 00053 // Search form 00054 opener.document.insertForm.elements['field_' + field + '[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]'].value = key; 00055 self.close(); 00056 return false; 00057 } 00058 } 00059 00060 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>'); 00061 } 00062 </script> 00063 </head> 00064 00065 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px"> 00066 <?php 00067 $per_page = 200; 00068 require_once('./libraries/relation.lib.php'); // foreign keys 00069 require_once('./libraries/transformations.lib.php'); // Transformations 00070 $cfgRelation = PMA_getRelationsParam(); 00071 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE); 00072 00073 $override_total = TRUE; 00074 00075 if (!isset($pos)) { 00076 $pos = 0; 00077 } 00078 00079 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' '; 00080 if (isset($foreign_navig) && $foreign_navig == $strShowAll) { 00081 unset($foreign_limit); 00082 } 00083 00084 require('./libraries/get_foreign.lib.php'); 00085 ?> 00086 00087 <form action="browse_foreigners.php" method="post"> 00088 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00089 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" /> 00090 <input type="hidden" name="fieldkey" value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" /> 00091 <?php 00092 if (isset($pk)) { 00093 $pk_uri = '&pk=' . urlencode($pk); 00094 ?> 00095 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" /> 00096 <?php 00097 } else { 00098 $pk_uri = '&'; 00099 } 00100 ?> 00101 00102 <table width="100%"> 00103 <?php 00104 if ($cfg['ShowAll'] && ($the_total > $per_page)) { 00105 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />'; 00106 } else { 00107 $showall = ''; 00108 } 00109 00110 $session_max_rows = $per_page; 00111 $pageNow = @floor($pos / $session_max_rows) + 1; 00112 $nbTotalPage = @ceil($the_total / $session_max_rows); 00113 00114 if ($the_total > $per_page) { 00115 $gotopage = PMA_pageselector( 00116 'browse_foreigners.php?field=' . urlencode($field) . 00117 '&' . PMA_generate_common_url($db, $table) 00118 . $pk_uri . 00119 '&fieldkey=' . (isset($fieldkey) ? $fieldkey : '') . 00120 '&', 00121 $session_max_rows, 00122 $pageNow, 00123 $nbTotalPage 00124 ); 00125 } else { 00126 $gotopage = ''; 00127 } 00128 00129 $header = ' <tr> 00130 <th align="left" nowrap="nowrap">' . $strKeyname . '</th> 00131 <th>' . $strDescription . '</th> 00132 <td align="center" width="20%" valign="top"> 00133 ' . $showall . ' 00134 ' . $gotopage . ' 00135 </td> 00136 <th>' . $strDescription . '</th> 00137 <th align="left" nowrap="nowrap">' . $strKeyname . '</th> 00138 </tr>'; 00139 00140 echo $header; 00141 00142 if (isset($disp_row) && is_array($disp_row)) { 00143 function dimsort($arrayA, $arrayB) { 00144 $keyA = key($arrayA); 00145 $keyB = key($arrayB); 00146 00147 if ($arrayA[$keyA] == $arrayB[$keyB]) { 00148 return 0; 00149 } 00150 00151 return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1; 00152 } 00153 00154 $mysql_key_relrow = array(); 00155 $mysql_val_relrow = array(); 00156 $count = 0; 00157 foreach ($disp_row AS $disp_row_key => $relrow) { 00158 if ($foreign_display != FALSE) { 00159 $val = $relrow[$foreign_display]; 00160 } else { 00161 $val = ''; 00162 } 00163 00164 $mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val); 00165 $mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]); 00166 $count++; 00167 } 00168 00169 usort($mysql_val_relrow, 'dimsort'); 00170 00171 $hcount = 0; 00172 for ($i = 0; $i < $count; $i++) { 00173 $hcount++; 00174 $bgcolor = ($hcount % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; 00175 00176 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) { 00177 echo $header; 00178 $hcount = -1; 00179 } 00180 00181 00182 $val = key($mysql_val_relrow[$i]); 00183 $key = $mysql_val_relrow[$i][$val]; 00184 00185 if (PMA_strlen($val) <= $cfg['LimitChars']) { 00186 $value = htmlspecialchars($val); 00187 $vtitle = ''; 00188 } else { 00189 $vtitle = htmlspecialchars($val); 00190 $value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...'); 00191 } 00192 00193 $key_equals_data = isset($data) && $key == $data; 00194 ?> 00195 <tr> 00196 <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> 00197 <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> 00198 <td width="20%"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" alt="" width="1" height="1"></td> 00199 <?php 00200 $key = key($mysql_key_relrow[$i]); 00201 $val = $mysql_key_relrow[$i][$key]; 00202 if (PMA_strlen($val) <= $cfg['LimitChars']) { 00203 $value = htmlspecialchars($val); 00204 $vtitle = ''; 00205 } else { 00206 $vtitle = htmlspecialchars($val); 00207 $value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...'); 00208 } 00209 00210 $key_equals_data = isset($data) && $key == $data; 00211 ?> 00212 <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> 00213 <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> 00214 </tr> 00215 <?php 00216 unset($key_equals_data); 00217 } // end while 00218 } 00219 00220 echo $header; 00221 ?> 00222 </table> 00223 </form> 00224 00225 </body> 00226 </html> 00227 00228 <?php 00232 if (isset($dbh) && $dbh) { 00233 @PMA_DBI_close($dbh); 00234 } 00235 if (isset($userlink) && $userlink) { 00236 @PMA_DBI_close($userlink); 00237 } 00238 00239 00243 if (isset($cfg['OBGzip']) && $cfg['OBGzip'] 00244 && isset($ob_mode) && $ob_mode) { 00245 PMA_outBufferPost($ob_mode); 00246 } 00247 ?>