- replaced $cfg['Bgcolor*'] with classes

- make use of fieldset
This commit is contained in:
Sebastian Mendel
2005-11-02 16:30:06 +00:00
parent 7a4a72e955
commit 131d56cf90
3 changed files with 212 additions and 151 deletions

View File

@@ -14,6 +14,9 @@ $Source$
* tbl_realtion.php: * tbl_realtion.php:
- fixed html output of table - fixed html output of table
- used fieldset for forms - used fieldset for forms
* libraries/common.lib.php, browse_foreigners.php:
- replaced $cfg['Bgcolor*'] with classes
- make use of fieldset
2005-11-01 Marc Delisle <lem9@users.sourceforge.net> 2005-11-01 Marc Delisle <lem9@users.sourceforge.net>
* server_privileges.php: undefined variable when changing a password * server_privileges.php: undefined variable when changing a password

View File

@@ -1,11 +1,9 @@
<?php <?php
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
/** /**
* Get the variables sent or posted to this script and displays the header * display selection for relational field values
*/ */
require_once('./libraries/grab_globals.lib.php');
/** /**
* Gets a core script and starts output buffering work * Gets a core script and starts output buffering work
@@ -29,41 +27,7 @@ $field = urldecode($field);
*/ */
// Gets the font sizes to use // Gets the font sizes to use
PMA_setFontSizes(); PMA_setFontSizes();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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; ?>">
<head>
<title>phpMyAdmin</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
<base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url( '', '' ); ?>&amp;js_frame=right" />
<script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">
self.focus();
function formupdate(field, key) {
if (opener && opener.document && opener.document.insertForm) {
if (opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . urlencode($pk) . ']' : ''); ?>[]']) {
// Edit/Insert form
opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . urlencode($pk) . ']' : ''); ?>[]'].value = key;
self.close();
return false;
} else if (opener.document.insertForm.elements['field_' + field + '[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]']) {
// Search form
opener.document.insertForm.elements['field_' + field + '[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]'].value = key;
self.close();
return false;
}
}
alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
}
</script>
</head>
<body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
<?php
$per_page = 200; $per_page = 200;
require_once('./libraries/relation.lib.php'); // foreign keys require_once('./libraries/relation.lib.php'); // foreign keys
require_once('./libraries/transformations.lib.php'); // Transformations require_once('./libraries/transformations.lib.php'); // Transformations
@@ -82,41 +46,31 @@ if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
} }
require('./libraries/get_foreign.lib.php'); require('./libraries/get_foreign.lib.php');
?>
<form action="browse_foreigners.php" method="post">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
<input type="hidden" name="fieldkey" value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
<?php
if (isset($pk)) { if (isset($pk)) {
$pk_uri = '&amp;pk=' . urlencode($pk); $pk_uri = '&amp;pk=' . urlencode($pk);
?> ?>
<input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" /> <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
<?php <?php
} else { } else {
$pk_uri = '&amp;'; $pk_uri = '';
} }
?>
<label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label> $gotopage = '';
<input type="text" name="foreign_filter" id="input_foreign_filter" value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" /> $showall = '';
<input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
<hr />
<table width="100%"> if (isset($disp_row) && is_array($disp_row)) {
<?php $count = count( $disp_row );
if ($cfg['ShowAll'] && ($the_total > $per_page)) {
if ( $cfg['ShowAll'] && ($count > $per_page) ) {
$showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />'; $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
} else { }
$showall = '';
}
$session_max_rows = $per_page; $session_max_rows = $per_page;
$pageNow = @floor($pos / $session_max_rows) + 1; $pageNow = @floor($pos / $session_max_rows) + 1;
$nbTotalPage = @ceil($the_total / $session_max_rows); $nbTotalPage = @ceil($count / $session_max_rows);
if ($the_total > $per_page) { if ( $count > $per_page ) {
$gotopage = PMA_pageselector( $gotopage = PMA_pageselector(
'browse_foreigners.php?field=' . urlencode($field) . 'browse_foreigners.php?field=' . urlencode($field) .
'&amp;' . PMA_generate_common_url($db, $table) '&amp;' . PMA_generate_common_url($db, $table)
@@ -128,105 +82,209 @@ if ($the_total > $per_page) {
$pageNow, $pageNow,
$nbTotalPage $nbTotalPage
); );
} else { }
$gotopage = '';
} }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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; ?>">
$header = ' <tr> <head>
<th align="left" nowrap="nowrap">' . $strKeyname . '</th> <title>phpMyAdmin</title>
<th>' . $strDescription . '</th> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
<td align="center" width="20%" valign="top"> <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
' . $showall . ' <link rel="stylesheet" type="text/css"
' . $gotopage . ' href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url( '', '' ); ?>&amp;js_frame=right" />
</td> <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
<th>' . $strDescription . '</th> <script type="text/javascript" language="javascript">
<th align="left" nowrap="nowrap">' . $strKeyname . '</th> //<![CDATA[
</tr>'; self.focus();
function formupdate( field, key ) {
if (opener && opener.document && opener.document.insertForm) {
var field = 'field_' + field;
echo $header; <?php if ( isset( $pk ) ) { ?>
var element_name = field + '[multi_edit][<?php echo urlencode( $pk ); ?>][]';
<?php } else { ?>
var element_name = field + '[]';
<?php } ?>
<?php if ( isset( $fieldkey ) ) { ?>
var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
<?php } else { ?>
var element_name_alt = field + '[0]';
<?php } ?>
if (opener.document.insertForm.elements[element_name]) {
// Edit/Insert form
opener.document.insertForm.elements[element_name].value = key;
self.close();
return false;
} else if (opener.document.insertForm.elements[element_name_alt]) {
// Search form
opener.document.insertForm.elements[element_name_alt].value = key;
self.close();
return false;
}
}
alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
}
//]]>
</script>
</head>
<body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
<form action="browse_foreigners.php" method="post">
<fieldset>
<?php echo PMA_generate_common_hidden_inputs( $db, $table ); ?>
<input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
<input type="hidden" name="fieldkey" value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
<?php if ( isset( $pk ) ) { ?>
<input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
<?php } ?>
<span class="formelement">
<label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
<input type="text" name="foreign_filter" id="input_foreign_filter" value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
<input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
</span>
<span class="formelement">
<?php echo $gotopage; ?>
</span>
<span class="formelement">
<?php echo $showall; ?>
</span>
</fieldset>
</form>
<table width="100%">
<?php
if (isset($disp_row) && is_array($disp_row)) { if (isset($disp_row) && is_array($disp_row)) {
function dimsort($arrayA, $arrayB) { $header = '<tr>
$keyA = key($arrayA); <th>' . $strKeyname . '</th>
$keyB = key($arrayB); <th>' . $strDescription . '</th>
<td width="20%"></td>
<th>' . $strDescription . '</th>
<th>' . $strKeyname . '</th>
</tr>';
if ($arrayA[$keyA] == $arrayB[$keyB]) { echo '<thead>' . $header . '</thead>' . "\n"
return 0; .'<tfoot>' . $header . '</tfoot>' . "\n"
} .'<tbody>' . "\n";
return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1; $values = array();
} $keys = array();
foreach ( $disp_row as $relrow ) {
$mysql_key_relrow = array();
$mysql_val_relrow = array();
$count = 0;
foreach ($disp_row AS $disp_row_key => $relrow) {
if ($foreign_display != FALSE) { if ($foreign_display != FALSE) {
$val = $relrow[$foreign_display]; $values[] = $relrow[$foreign_display];
} else { } else {
$val = ''; $values[] = '';
} }
$mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val); $keys[] = $relrow[$foreign_field];
$mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]);
$count++;
} }
usort($mysql_val_relrow, 'dimsort'); asort( $keys );
$hcount = 0; $hcount = 0;
for ($i = 0; $i < $count; $i++) { $odd_row = true;
$val_ordered_current_row = 0;
$val_ordered_current_equals_data = false;
$key_ordered_current_equals_data = false;
foreach ( $keys as $key_ordered_current_row => $value ) {
//for ( $i = 0; $i < $count; $i++ ) {
$hcount++; $hcount++;
$bgcolor = ($hcount % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) { if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
echo $header; echo $header;
$hcount = -1; $hcount = 0;
$odd_row = true;
} }
$key_ordered_current_key = $keys[$key_ordered_current_row];
$key_ordered_current_val = $values[$key_ordered_current_row];
$val = key($mysql_val_relrow[$i]); $val_ordered_current_key = $keys[$val_ordered_current_row];
$key = $mysql_val_relrow[$i][$val]; $val_ordered_current_val = $values[$val_ordered_current_row];
if (PMA_strlen($val) <= $cfg['LimitChars']) { $val_ordered_current_row++;
$value = htmlspecialchars($val);
$vtitle = ''; if (PMA_strlen( $val_ordered_current_val ) <= $cfg['LimitChars']) {
$val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
$val_ordered_current_val_title = '';
} else { } else {
$vtitle = htmlspecialchars($val); $val_ordered_current_val_title =
$value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...'); htmlspecialchars( $val_ordered_current_val );
$val_ordered_current_val =
htmlspecialchars( PMA_substr( $val_ordered_current_val, 0,
$cfg['LimitChars'] ) . '...' );
} }
if (PMA_strlen( $key_ordered_current_val ) <= $cfg['LimitChars']) {
$key_equals_data = isset($data) && $key == $data; $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
?> $key_ordered_current_val_title = '';
<tr>
<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>
<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>
<td width="20%"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" alt="" width="1" height="1"></td>
<?php
$key = key($mysql_key_relrow[$i]);
$val = $mysql_key_relrow[$i][$key];
if (PMA_strlen($val) <= $cfg['LimitChars']) {
$value = htmlspecialchars($val);
$vtitle = '';
} else { } else {
$vtitle = htmlspecialchars($val); $key_ordered_current_val_title =
$value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...'); htmlspecialchars( $key_ordered_current_val );
$key_ordered_current_val =
htmlspecialchars( PMA_substr( $key_ordered_current_val, 0,
$cfg['LimitChars'] ) . '...' );
} }
$key_equals_data = isset($data) && $key == $data; if ( ! empty( $data ) ) {
?> $val_ordered_current_equals_data = $val_ordered_current_key == $data;
<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> $key_ordered_current_equals_data = $key_ordered_current_key == $data;
<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> }
?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<td nowrap="nowrap">
<?php
echo ($key_ordered_current_equals_data ? '<b>' : '')
.'<a href="#" title="' . $strUseThisValue
. ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
.' onclick="formupdate(\'' . md5($field) . '\', \''
. htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
.htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
?></td>
<td>
<?php
echo ($key_ordered_current_equals_data ? '<b>' : '')
. '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ? ': '
. $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
. md5($field) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
. $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
?></td>
<td width="20%">
<img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
alt="" width="1" height="1"></td>
<td>
<?php
echo ($val_ordered_current_equals_data ? '<b>' : '')
. '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': '
. $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
. '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); return false;">'
. $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
?></td>
<td nowrap="nowrap">
<?php
echo ($val_ordered_current_equals_data ? '<b>' : '') . '<a href="#" title="'
. $strUseThisValue . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
. '" onclick="formupdate(\'' . md5($field) . '\', \''
. htmlspecialchars($val_ordered_current_key) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
. '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
?></td>
</tr> </tr>
<?php <?php
unset($key_equals_data);
} // end while } // end while
} }
echo $header;
?> ?>
</tbody>
</table> </table>
</form>
</body> </body>
</html> </html>

View File

@@ -2809,8 +2809,8 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
* @author Garvin Hicking (pma@supergarv.de) * @author Garvin Hicking (pma@supergarv.de)
*/ */
function PMA_pageselector($url, $rows, $pageNow = 1, $nbTotalPage = 1, $showAll = 200, $sliceStart = 5, $sliceEnd = 5, $percent = 20, $range = 10) { function PMA_pageselector($url, $rows, $pageNow = 1, $nbTotalPage = 1, $showAll = 200, $sliceStart = 5, $sliceEnd = 5, $percent = 20, $range = 10) {
$gotopage = '<br />' . $GLOBALS['strPageNumber'] $gotopage = $GLOBALS['strPageNumber']
. '<select name="goToPage" onchange="goToUrl(this, \'' . $url . '\');">' . "\n"; . ' <select name="goToPage" onchange="goToUrl(this, \'' . $url . '\');">' . "\n";
if ($nbTotalPage < $showAll) { if ($nbTotalPage < $showAll) {
$pages = range(1, $nbTotalPage); $pages = range(1, $nbTotalPage);
} else { } else {