- added PMA_getDbLink

- use fieldset for create table from
This commit is contained in:
Sebastian Mendel
2005-11-09 10:38:33 +00:00
parent 713f2d4836
commit bfddbeafa4
3 changed files with 127 additions and 130 deletions

View File

@@ -12,6 +12,8 @@ $Source$
* db_details_structure.php: * db_details_structure.php:
- fixed display issues - fixed display issues
- display default engine in footer - display default engine in footer
* libraries/common.lib.php: added PMA_getDbLink
* libraries/display_create_table.lib.php: use fieldset
2005-11-08 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2005-11-08 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* Documentation.html, browse_foreigners.php, error.php, * Documentation.html, browse_foreigners.php, error.php,

View File

@@ -151,7 +151,7 @@ if (!isset($cfg['Servers']) || count($cfg['Servers']) == 0) {
. '&char=' . urlencode( $charset ) . '&char=' . urlencode( $charset )
. '&dir=' . urlencode( $text_dir ) . '&dir=' . urlencode( $text_dir )
. '&type=' . urlencode( $strError ) . '&type=' . urlencode( $strError )
. '&error=' . urlencode( . '&error=' . urlencode(
// FIXME: We could translate this message, however it's translations freeze right now: // FIXME: We could translate this message, however it's translations freeze right now:
sprintf( 'Invalid server index: "%s"', $key)) sprintf( 'Invalid server index: "%s"', $key))
. '&' . SID . '&' . SID
@@ -175,7 +175,7 @@ if (!function_exists('preg_replace')) {
. '&char=' . urlencode( $charset ) . '&char=' . urlencode( $charset )
. '&dir=' . urlencode( $text_dir ) . '&dir=' . urlencode( $text_dir )
. '&type=' . urlencode( $strError ) . '&type=' . urlencode( $strError )
. '&error=' . urlencode( . '&error=' . urlencode(
strtr( sprintf( $strCantLoad, 'pcre' ), strtr( sprintf( $strCantLoad, 'pcre' ),
array('<br />' => '[br]') ) ) array('<br />' => '[br]') ) )
. '&' . SID . '&' . SID
@@ -423,7 +423,7 @@ if ($is_minimum_common == FALSE) {
* (converts \n to \\n, \r to \\r) * (converts \n to \\n, \r to \\r)
* *
* @param boolean whether this function is used as part of the * @param boolean whether this function is used as part of the
* "Create PHP code" dialog * "Create PHP code" dialog
* *
* @return string the slashed string * @return string the slashed string
* *
@@ -444,10 +444,10 @@ if ($is_minimum_common == FALSE) {
} }
if ($php_code) { if ($php_code) {
$a_string = str_replace('\'', '\\\'', $a_string); $a_string = str_replace('\'', '\\\'', $a_string);
} else { } else {
$a_string = str_replace('\'', '\'\'', $a_string); $a_string = str_replace('\'', '\'\'', $a_string);
} }
return $a_string; return $a_string;
} // end of the 'PMA_sqlAddslashes()' function } // end of the 'PMA_sqlAddslashes()' function
@@ -561,7 +561,7 @@ if ($is_minimum_common == FALSE) {
function PMA_showMySQLDocu($chapter, $link, $big_icon = FALSE) function PMA_showMySQLDocu($chapter, $link, $big_icon = FALSE)
{ {
global $cfg; global $cfg;
if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) return ''; if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) return '';
// Fixup for newly used names: // Fixup for newly used names:
@@ -728,19 +728,19 @@ if ($is_minimum_common == FALSE) {
// 2005-01-17 modified by mkkeck bugfix // 2005-01-17 modified by mkkeck bugfix
if (substr($error_message, 1, 4) == '1062') { if (substr($error_message, 1, 4) == '1062') {
// get the duplicate entry // get the duplicate entry
// get table name // get table name
preg_match( '<27>ALTER\sTABLE\s\`([^\`]+)\`<60>iu', $the_query, $error_table = array() ); preg_match( '<27>ALTER\sTABLE\s\`([^\`]+)\`<60>iu', $the_query, $error_table = array() );
$error_table = $error_table[1]; $error_table = $error_table[1];
// get fields // get fields
preg_match( '<27>\(([^\)]+)\)<29>i', $the_query, $error_fields = array() ); preg_match( '<27>\(([^\)]+)\)<29>i', $the_query, $error_fields = array() );
$error_fields = explode( ',', $error_fields[1] ); $error_fields = explode( ',', $error_fields[1] );
// duplicate value // duplicate value
preg_match( '<27>\'([^\']+)\'<27>i', $tmp_mysql_error, $duplicate_value = array() ); preg_match( '<27>\'([^\']+)\'<27>i', $tmp_mysql_error, $duplicate_value = array() );
$duplicate_value = $duplicate_value[1]; $duplicate_value = $duplicate_value[1];
$sql = ' $sql = '
SELECT * SELECT *
FROM ' . PMA_backquote( $error_table ) . ' FROM ' . PMA_backquote( $error_table ) . '
@@ -748,7 +748,7 @@ if ($is_minimum_common == FALSE) {
= "' . PMA_sqlAddslashes( $duplicate_value ) . '" = "' . PMA_sqlAddslashes( $duplicate_value ) . '"
ORDER BY ' . implode( ', ', $error_fields ); ORDER BY ' . implode( ', ', $error_fields );
unset( $error_table, $error_fields, $duplicate_value ); unset( $error_table, $error_fields, $duplicate_value );
echo ' <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n" echo ' <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n"
.' <input type="hidden" name="sql_query" value="' . htmlentities( $sql ) . '" />' . "\n" .' <input type="hidden" name="sql_query" value="' . htmlentities( $sql ) . '" />' . "\n"
.' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" .' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"
@@ -825,7 +825,7 @@ if ($is_minimum_common == FALSE) {
/** /**
* returns array with dbs grouped with extended infos * returns array with dbs grouped with extended infos
* *
* @uses $GLOBALS['dblist'] from PMA_availableDatabases() * @uses $GLOBALS['dblist'] from PMA_availableDatabases()
* @uses $GLOBALS['num_dbs'] from PMA_availableDatabases() * @uses $GLOBALS['num_dbs'] from PMA_availableDatabases()
* @uses $GLOBALS['cfgRelation']['commwork'] * @uses $GLOBALS['cfgRelation']['commwork']
@@ -872,14 +872,14 @@ function PMA_getDbList() {
$group = $db; $group = $db;
$disp_name_cut = $db; $disp_name_cut = $db;
} }
$disp_name = $db; $disp_name = $db;
if ( $db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB'] ) { if ( $db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB'] ) {
$disp_name = $db_tooltip; $disp_name = $db_tooltip;
$disp_name_cut = $db_tooltip; $disp_name_cut = $db_tooltip;
$db_tooltip = $db; $db_tooltip = $db;
} }
$dbgroups[$group][$db] = array( $dbgroups[$group][$db] = array(
'name' => $db, 'name' => $db,
'disp_name_cut' => $disp_name_cut, 'disp_name_cut' => $disp_name_cut,
@@ -887,13 +887,13 @@ function PMA_getDbList() {
'comment' => $db_tooltip, 'comment' => $db_tooltip,
'num_tables' => PMA_getTableCount( $db ), 'num_tables' => PMA_getTableCount( $db ),
); );
} // end foreach ( $dblist as $db ) } // end foreach ( $dblist as $db )
return $dbgroups; return $dbgroups;
} }
/** /**
* returns html code for select form element with dbs * returns html code for select form element with dbs
* *
* @return string html code select * @return string html code select
*/ */
function PMA_getHtmlSelectDb( $selected = '' ) { function PMA_getHtmlSelectDb( $selected = '' ) {
@@ -921,7 +921,7 @@ function PMA_getHtmlSelectDb( $selected = '' ) {
if ( $db['name'] == $selected ) { if ( $db['name'] == $selected ) {
$return .= ' selected="selected"'; $return .= ' selected="selected"';
} }
$return .= '>' . ( $cut ? $db['disp_name_cut'] : $db['disp_name'] ) $return .= '>' . ( $cut ? $db['disp_name_cut'] : $db['disp_name'] )
.' (' . $db['num_tables'] . ')</option>' . "\n"; .' (' . $db['num_tables'] . ')</option>' . "\n";
} }
if ( count( $dbs ) > 1 ) { if ( count( $dbs ) > 1 ) {
@@ -929,13 +929,13 @@ function PMA_getHtmlSelectDb( $selected = '' ) {
} }
} }
$return .= '</select>'; $return .= '</select>';
return $return; return $return;
} }
/** /**
* returns count of tables in given db * returns count of tables in given db
* *
* @param string $db database to count tables for * @param string $db database to count tables for
* @return integer count of tables in $db * @return integer count of tables in $db
*/ */
@@ -949,7 +949,7 @@ function PMA_getTableCount( $db ) {
} else { } else {
$num_tables = 0; $num_tables = 0;
} }
return $num_tables; return $num_tables;
} }
@@ -1271,7 +1271,7 @@ if ($is_minimum_common == FALSE) {
// the autodetect code works well enough that we don't display the // the autodetect code works well enough that we don't display the
// warning at all. The user can still set PmaAbsoluteUri manually. // warning at all. The user can still set PmaAbsoluteUri manually.
// See https://sourceforge.net/tracker/index.php?func=detail&aid=1257134&group_id=23067&atid=377411 // See https://sourceforge.net/tracker/index.php?func=detail&aid=1257134&group_id=23067&atid=377411
} else { } else {
// The URI is specified, however users do often specify this // The URI is specified, however users do often specify this
// wrongly, so we try to fix this. // wrongly, so we try to fix this.
@@ -1296,19 +1296,19 @@ if ($is_minimum_common == FALSE) {
$cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')) . '/'; $cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')) . '/';
$is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0; $is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0;
// //
if ($cfg['ForceSLL'] && !$is_https) { if ($cfg['ForceSLL'] && !$is_https) {
header( header(
'Location: ' . preg_replace( 'Location: ' . preg_replace(
'/^http/', 'https', $cfg['PmaAbsoluteUri'] ) '/^http/', 'https', $cfg['PmaAbsoluteUri'] )
. ( isset( $_SERVER['REQUEST_URI'] ) . ( isset( $_SERVER['REQUEST_URI'] )
? preg_replace( '@' . $pma_uri_parts['path'] . '@', ? preg_replace( '@' . $pma_uri_parts['path'] . '@',
'', $_SERVER['REQUEST_URI'] ) '', $_SERVER['REQUEST_URI'] )
: '' ) : '' )
. '&' . SID ); . '&' . SID );
exit; exit;
} }
$dblist = array(); $dblist = array();
@@ -1374,7 +1374,7 @@ if ($is_minimum_common == FALSE) {
. '&dir=' . urlencode( $text_dir ) . '&dir=' . urlencode( $text_dir )
. '&type=' . urlencode( $strError ) . '&type=' . urlencode( $strError )
. '&error=' . urlencode( . '&error=' . urlencode(
$strInvalidAuthMethod . ' ' $strInvalidAuthMethod . ' '
. $cfg['Server']['auth_type'] ) . $cfg['Server']['auth_type'] )
. '&' . SID . '&' . SID
); );
@@ -1614,20 +1614,20 @@ if ($is_minimum_common == FALSE) {
} // end else } // end else
$num_dbs = count( $dblist ); $num_dbs = count( $dblist );
// natural order for db list; but do not sort if user asked // natural order for db list; but do not sort if user asked
// for a specific order with the 'only_db' mechanism // for a specific order with the 'only_db' mechanism
if ( ! is_array( $GLOBALS['cfg']['Server']['only_db'] ) if ( ! is_array( $GLOBALS['cfg']['Server']['only_db'] )
&& $GLOBALS['cfg']['NaturalOrder'] ) { && $GLOBALS['cfg']['NaturalOrder'] ) {
natsort( $dblist ); natsort( $dblist );
} }
return TRUE; return TRUE;
} // end of the 'PMA_availableDatabases()' function } // end of the 'PMA_availableDatabases()' function
/** /**
* returns array with tables of given db with extended infomation and grouped * returns array with tables of given db with extended infomation and grouped
* *
* @uses $GLOBALS['cfg']['LeftFrameTableSeparator'] * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
* @uses $GLOBALS['cfg']['LeftFrameTableLevel'] * @uses $GLOBALS['cfg']['LeftFrameTableLevel']
* @uses $GLOBALS['cfg']['ShowTooltipAliasTB'] * @uses $GLOBALS['cfg']['ShowTooltipAliasTB']
@@ -1644,40 +1644,40 @@ if ($is_minimum_common == FALSE) {
*/ */
function PMA_getTableList( $db ) { function PMA_getTableList( $db ) {
$sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
$tables = PMA_DBI_get_tables_full($db); $tables = PMA_DBI_get_tables_full($db);
if ( count( $tables ) < 1 ) { if ( count( $tables ) < 1 ) {
return $tables; return $tables;
} }
if ( $GLOBALS['cfg']['NaturalOrder'] ) { if ( $GLOBALS['cfg']['NaturalOrder'] ) {
uksort( $tables, 'strcmp' ); uksort( $tables, 'strcmp' );
} }
$default = array( $default = array(
'Name' => '', 'Name' => '',
'Rows' => 0, 'Rows' => 0,
'Comment' => '', 'Comment' => '',
'disp_name' => '', 'disp_name' => '',
); );
$table_groups = array(); $table_groups = array();
foreach ( $tables as $table_name => $table ) { foreach ( $tables as $table_name => $table ) {
// check for correct row count // check for correct row count
if ( NULL === $table['Rows'] ) { if ( NULL === $table['Rows'] ) {
$table['Rows'] = PMA_countRecords( $db, $table['Name'], $table['Rows'] = PMA_countRecords( $db, $table['Name'],
$return = true, $force_exact = true ); $return = true, $force_exact = true );
} }
// in $group we save the reference to the place in $table_groups // in $group we save the reference to the place in $table_groups
// where to store the table info // where to store the table info
if ( $GLOBALS['cfg']['LeftFrameDBTree'] if ( $GLOBALS['cfg']['LeftFrameDBTree']
&& $sep && strstr( $table_name, $sep ) ) && $sep && strstr( $table_name, $sep ) )
{ {
$parts = explode( $sep, $table_name ); $parts = explode( $sep, $table_name );
$group =& $table_groups; $group =& $table_groups;
$i = 0; $i = 0;
$group_name_full = ''; $group_name_full = '';
@@ -1685,7 +1685,7 @@ if ($is_minimum_common == FALSE) {
&& $i < $GLOBALS['cfg']['LeftFrameTableLevel'] ) { && $i < $GLOBALS['cfg']['LeftFrameTableLevel'] ) {
$group_name = $parts[$i] . $sep; $group_name = $parts[$i] . $sep;
$group_name_full .= $group_name; $group_name_full .= $group_name;
if ( ! isset( $group[$group_name] ) ) { if ( ! isset( $group[$group_name] ) ) {
$group[$group_name] = array(); $group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true; $group[$group_name]['is' . $sep . 'group'] = true;
@@ -1711,8 +1711,8 @@ if ($is_minimum_common == FALSE) {
} }
$group =& $table_groups; $group =& $table_groups;
} }
if ( $GLOBALS['cfg']['ShowTooltipAliasTB'] if ( $GLOBALS['cfg']['ShowTooltipAliasTB']
&& $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' ) { && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' ) {
// switch tooltip and name // switch tooltip and name
@@ -1721,7 +1721,7 @@ if ($is_minimum_common == FALSE) {
} else { } else {
$table['disp_name'] = $table['Name']; $table['disp_name'] = $table['Name'];
} }
$group[$table_name] = array_merge( $default, $table ); $group[$table_name] = array_merge( $default, $table );
} }
@@ -1947,23 +1947,23 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
} }
} }
unset($tbl_status); unset($tbl_status);
?> ?>
<br /> <br />
<div align="<?php echo $GLOBALS['cell_align_left']; ?>"> <div align="<?php echo $GLOBALS['cell_align_left']; ?>">
<?php <?php
if ( ! empty( $GLOBALS['show_error_header'] ) ) { if ( ! empty( $GLOBALS['show_error_header'] ) ) {
?> ?>
<div class="error"> <div class="error">
<h1><?php echo $GLOBALS['strError']; ?></h1> <h1><?php echo $GLOBALS['strError']; ?></h1>
<?php <?php
} }
echo $message; echo $message;
if (isset($GLOBALS['special_message'])) { if (isset($GLOBALS['special_message'])) {
echo PMA_sanitize($GLOBALS['special_message']); echo PMA_sanitize($GLOBALS['special_message']);
unset($GLOBALS['special_message']); unset($GLOBALS['special_message']);
} }
if ( ! empty( $GLOBALS['show_error_header'] ) ) { if ( ! empty( $GLOBALS['show_error_header'] ) ) {
echo '</div>'; echo '</div>';
} }
@@ -1979,7 +1979,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
// xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />") // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
// If we want to show some sql code it is easiest to create it here // If we want to show some sql code it is easiest to create it here
/* SQL-Parser-Analyzer */ /* SQL-Parser-Analyzer */
if (!empty($GLOBALS['show_as_php'])) { if (!empty($GLOBALS['show_as_php'])) {
$new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' '; $new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' ';
} }
@@ -1998,7 +1998,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
} else { } else {
$parsed_sql = PMA_SQP_parse($query_base); $parsed_sql = PMA_SQP_parse($query_base);
} }
// Analyze it // Analyze it
$analyzed_display_query = PMA_SQP_analyze($parsed_sql); $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
@@ -2014,7 +2014,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
if (isset($analyzed_display_query[0]['queryflags']['select_from']) if (isset($analyzed_display_query[0]['queryflags']['select_from'])
&& isset($GLOBALS['sql_limit_to_append'])) { && isset($GLOBALS['sql_limit_to_append'])) {
$query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit']; $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
// Need to reparse query // Need to reparse query
$parsed_sql = PMA_SQP_parse($query_base); $parsed_sql = PMA_SQP_parse($query_base);
} }
@@ -2172,14 +2172,14 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
echo '\';'; echo '\';';
} }
echo '</fieldset>' . "\n"; echo '</fieldset>' . "\n";
if ( ! empty( $edit_target ) ) { if ( ! empty( $edit_target ) ) {
echo '<fieldset class="tblFooters">'; echo '<fieldset class="tblFooters">';
echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link; echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
echo '</fieldset>'; echo '</fieldset>';
} }
} }
?> ?>
</div><br /> </div><br />
<?php <?php
} // end of the 'PMA_showMessage()' function } // end of the 'PMA_showMessage()' function
@@ -2255,7 +2255,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
$GLOBALS['number_decimal_separator'], $GLOBALS['number_decimal_separator'],
$GLOBALS['number_thousands_separator'] ); $GLOBALS['number_thousands_separator'] );
} }
// this units needs no translation, ISO // this units needs no translation, ISO
$units = array( $units = array(
-8 => 'y', -8 => 'y',
@@ -2276,12 +2276,12 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
7 => 'Z', 7 => 'Z',
8 => 'Y' 8 => 'Y'
); );
// we need at least 3 digits to be displayed // we need at least 3 digits to be displayed
if ( 3 > $length + $comma ) { if ( 3 > $length + $comma ) {
$length = 3 - $comma; $length = 3 - $comma;
} }
// check for negativ value to retain sign // check for negativ value to retain sign
if ( $value < 0 ) { if ( $value < 0 ) {
$sign = '-'; $sign = '-';
@@ -2404,24 +2404,24 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
'attr' => '', 'attr' => '',
'args' => '', 'args' => '',
); );
$tab = array_merge( $defaults, $tab ); $tab = array_merge( $defaults, $tab );
// determine aditional style-class // determine aditional style-class
if ( empty( $tab['class'] ) ) { if ( empty( $tab['class'] ) ) {
if ( $tab['text'] == $GLOBALS['strEmpty'] if ( $tab['text'] == $GLOBALS['strEmpty']
|| $tab['text'] == $GLOBALS['strDrop'] ) { || $tab['text'] == $GLOBALS['strDrop'] ) {
$tab['class'] = 'caution'; $tab['class'] = 'caution';
} }
elseif ( isset( $tab['active'] ) && $tab['active'] elseif ( isset( $tab['active'] ) && $tab['active']
|| isset( $GLOBALS['active_page'] ) || isset( $GLOBALS['active_page'] )
&& $GLOBALS['active_page'] == $tab['link'] && $GLOBALS['active_page'] == $tab['link']
|| basename( $GLOBALS['PHP_SELF'] ) == $tab['link'] ) || basename( $GLOBALS['PHP_SELF'] ) == $tab['link'] )
{ {
$tab['class'] = 'active'; $tab['class'] = 'active';
} }
} }
// build the link // build the link
if ( ! empty( $tab['link'] ) ) { if ( ! empty( $tab['link'] ) ) {
$tab['link'] = htmlentities( $tab['link'] ); $tab['link'] = htmlentities( $tab['link'] );
@@ -2430,12 +2430,12 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
PMA_generate_common_url() : $GLOBALS['url_query'] ); PMA_generate_common_url() : $GLOBALS['url_query'] );
if ( ! empty( $tab['args'] ) ) { if ( ! empty( $tab['args'] ) ) {
foreach( $tab['args'] as $param => $value ) { foreach( $tab['args'] as $param => $value ) {
$tab['link'] .= '&amp;' . urlencode( $param ) . '=' $tab['link'] .= '&amp;' . urlencode( $param ) . '='
. urlencode( $value ); . urlencode( $value );
} }
} }
} }
// display icon, even if iconic is disabled but the link-text is missing // display icon, even if iconic is disabled but the link-text is missing
if ( ( $GLOBALS['cfg']['MainPageIconic'] || empty( $tab['text'] ) ) if ( ( $GLOBALS['cfg']['MainPageIconic'] || empty( $tab['text'] ) )
&& isset( $tab['icon'] ) ) { && isset( $tab['icon'] ) ) {
@@ -2446,7 +2446,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
// check to not display an empty link-text // check to not display an empty link-text
elseif ( empty( $tab['text'] ) ) { elseif ( empty( $tab['text'] ) ) {
$tab['text'] = '?'; $tab['text'] = '?';
trigger_error( __FILE__ . '(' . __LINE__ . '): ' trigger_error( __FILE__ . '(' . __LINE__ . '): '
. 'empty linktext in function ' . __FUNCTION__ . '()', . 'empty linktext in function ' . __FUNCTION__ . '()',
E_USER_NOTICE ); E_USER_NOTICE );
} }
@@ -2462,7 +2462,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
return $out; return $out;
} // end of the 'PMA_printTab()' function } // end of the 'PMA_printTab()' function
/** /**
* returns html-code for a tab navigation * returns html-code for a tab navigation
* *
@@ -2471,21 +2471,21 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
* @param array $tabs one element per tab * @param array $tabs one element per tab
* @param string $tag_id id used for the html-tag * @param string $tag_id id used for the html-tag
* @return string html-code for tab-navigation * @return string html-code for tab-navigation
*/ */
function PMA_getTabs( $tabs, $tag_id = 'topmenu' ) { function PMA_getTabs( $tabs, $tag_id = 'topmenu' ) {
$tab_navigation = $tab_navigation =
'<div id="' . htmlentities( $tag_id ) . 'container">' . "\n" '<div id="' . htmlentities( $tag_id ) . 'container">' . "\n"
.'<ul id="' . htmlentities( $tag_id ) . '">' . "\n"; .'<ul id="' . htmlentities( $tag_id ) . '">' . "\n";
foreach ( $tabs as $tab ) { foreach ( $tabs as $tab ) {
$tab_navigation .= '<li>' . PMA_getTab( $tab ) . '</li>' . "\n"; $tab_navigation .= '<li>' . PMA_getTab( $tab ) . '</li>' . "\n";
} }
$tab_navigation .= $tab_navigation .=
'</ul>' . "\n" '</ul>' . "\n"
.'<div class="clearfloat"></div>' .'<div class="clearfloat"></div>'
.'</div>' . "\n"; .'</div>' . "\n";
return $tab_navigation; return $tab_navigation;
} }
@@ -2518,14 +2518,14 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
if ( ! empty( $target ) ) { if ( ! empty( $target ) ) {
$tag_params['target'] = htmlentities( $target ); $tag_params['target'] = htmlentities( $target );
} }
$tag_params_strings = array(); $tag_params_strings = array();
foreach( $tag_params as $par_name => $par_value ) { foreach( $tag_params as $par_name => $par_value ) {
// htmlentities() only on non javascript // htmlentities() only on non javascript
$par_value = substr( $par_name,0 ,2 ) == 'on' ? $par_value : htmlentities( $par_value ); $par_value = substr( $par_name,0 ,2 ) == 'on' ? $par_value : htmlentities( $par_value );
$tag_params_strings[] = $par_name . '="' . $par_value . '"'; $tag_params_strings[] = $par_name . '="' . $par_value . '"';
} }
// previously the limit was set to 2047, it seems 1000 is better // previously the limit was set to 2047, it seems 1000 is better
if (strlen($url) <= 1000) { if (strlen($url) <= 1000) {
$ret = '<a href="' . $url . '" ' . implode( ' ', $tag_params_strings ) . '>' . "\n" $ret = '<a href="' . $url . '" ' . implode( ' ', $tag_params_strings ) . '>' . "\n"
@@ -2535,7 +2535,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
// no spaces (linebreaks) at all // no spaces (linebreaks) at all
// or after the hidden fields // or after the hidden fields
// IE will display them all // IE will display them all
// add class=link to submit button // add class=link to submit button
if ( empty( $tag_params['class'] ) ) { if ( empty( $tag_params['class'] ) ) {
$tag_params['class'] = 'link'; $tag_params['class'] = 'link';
@@ -2923,16 +2923,16 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
// when the default current_timestamp is checked // when the default current_timestamp is checked
$query = PMA_backquote($name) . ' ' . $type; $query = PMA_backquote($name) . ' ' . $type;
if ($length != '' if ($length != ''
&& !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i', $type)) { && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i', $type)) {
$query .= '(' . $length . ')'; $query .= '(' . $length . ')';
} }
if ($attribute != '') { if ($attribute != '') {
$query .= ' ' . $attribute; $query .= ' ' . $attribute;
} }
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($collation) && $collation != 'NULL' && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) { if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($collation) && $collation != 'NULL' && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {
$query .= PMA_generateCharsetQueryPart($collation); $query .= PMA_generateCharsetQueryPart($collation);
} }
@@ -2975,7 +2975,7 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
} }
return $query; return $query;
} // end function } // end function
function PMA_generateAlterTable($oldcol, $newcol, $type, $length, $attribute, $collation, $null, $default, $default_current_timestamp, $extra, $comment='', $default_orig) { function PMA_generateAlterTable($oldcol, $newcol, $type, $length, $attribute, $collation, $null, $default, $default_current_timestamp, $extra, $comment='', $default_orig) {
$empty_a = array(); $empty_a = array();
return PMA_backquote($oldcol) . ' ' . PMA_generateFieldSpec($newcol, $type, $length, $attribute, $collation, $null, $default, $default_current_timestamp, $extra, $comment, $empty_a, -1, $default_orig); return PMA_backquote($oldcol) . ' ' . PMA_generateFieldSpec($newcol, $type, $length, $attribute, $collation, $null, $default, $default_current_timestamp, $extra, $comment, $empty_a, -1, $default_orig);
@@ -2991,6 +2991,29 @@ window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFor
return str_replace('%u', $cfg['Server']['user'], $dir); return str_replace('%u', $cfg['Server']['user'], $dir);
} }
} // end if: minimal common.lib needed? /**
* returns html code for db link to default db page
*
* @uses $GLOBALS['cfg']['DefaultTabDatabase']
* @uses $GLOBALS['db']
* @uses $GLOBALS['strJumpToDB']
* @uses PMA_generate_common_url()
* @param string $database
* @return string html link to default db page
*/
function PMA_getDbLink( $database = NULL ) {
if ( empty( $database ) ) {
if ( empty( $GLOBALS['db'] ) ) {
return '';
}
$database = $GLOBALS['db'];
}
return '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url( $database ) . '"'
.' title="' . sprintf( $GLOBALS['strJumpToDB'], htmlspecialchars( $database ) ) . '">'
.htmlspecialchars( $database ) . '</a>';
}
} // end if: minimal common.lib needed?
?> ?>

View File

@@ -8,7 +8,7 @@ require_once('./libraries/check_user_privileges.lib.php');
$is_create_table_priv = FALSE; $is_create_table_priv = FALSE;
foreach($dbs_where_create_table_allowed as $allowed_db) { foreach( $dbs_where_create_table_allowed as $allowed_db ) {
// if we find the exact db name, we stop here // if we find the exact db name, we stop here
if ($allowed_db == $db) { if ($allowed_db == $db) {
@@ -67,61 +67,33 @@ foreach($dbs_where_create_table_allowed as $allowed_db) {
} // end foreach } // end foreach
unset($i, $max_position, $chunk, $pattern); unset($i, $max_position, $chunk, $pattern);
if ($is_create_table_priv) {
?> ?>
<!-- Create a new table --> <form method="post" action="tbl_create.php"
<form method="post" action="tbl_create.php" onsubmit="return (emptyFormElements(this, 'table') &amp;&amp; checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))"> onsubmit="return (emptyFormElements(this, 'table') &amp;&amp; checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))">
<table border="0" cellpadding="2" cellspacing="0"> <fieldset>
<tr> <legend>
<td class="tblHeaders" colspan="3" nowrap="nowrap"><?php <?php
echo PMA_generate_common_hidden_inputs($db); if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
if($cfg['PropertiesIconic']){ echo '<img class="icon" src="' . $pmaThemeImage . 'b_newtbl.png" width="16" height="16" alt="" />'; } echo '<img class="icon" src="' . $pmaThemeImage . 'b_newtbl.png" width="16" height="16" alt="" />';
// if you want navigation: }
$strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url() . '&amp;db=' . urlencode($GLOBALS['db']) . '">' echo sprintf( $strCreateNewTable, PMA_getDbLink() );
. htmlspecialchars($GLOBALS['db']) . '</a>';
// else use
// $strDBLink = htmlspecialchars($db);
echo ' ' . sprintf($strCreateNewTable, $strDBLink) . ':&nbsp;' . "\n";
echo ' </td></tr>';
echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
echo ' ' . $strName . ':&nbsp;' . "\n";
echo ' </td>';
echo ' <td nowrap="nowrap">';
echo ' ' . '<input type="text" name="table" maxlength="64" size="30" class="textfield" />';
echo ' </td><td>&nbsp;</td></tr>';
echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
if (!isset($strNumberOfFields)) {
$strNumberOfFields = $strFields;
}
echo ' ' . $strNumberOfFields . ':&nbsp;' . "\n";
echo ' </td>';
echo ' <td nowrap="nowrap">';
echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
echo ' </td>';
echo ' <td align="right">';
echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
echo ' </td> </tr>';
echo ' </table>';
echo '</form>' . "\n";
} else {
?>
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td class="tblHeaders" colspan="3" nowrap="nowrap"><?php
if($cfg['PropertiesIconic']) {
echo '<img class="icon" src="' . $pmaThemeImage . 'b_newtbl.png" width="16" height="16" alt="" />' . "\n";
}
$strDBLink = htmlspecialchars($db);
echo ' ' . sprintf($strCreateNewTable, $strDBLink) . ':&nbsp;' . "\n";
echo ' </td></tr>' . "\n";
echo ' <tr>' . "\n";
echo ' <td>' . "\n";
echo '<span class="noPrivileges">'
. ($cfg['ErrorIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 's_error2.png" width="11" height="11" alt="" />' : '')
. '' . $strNoPrivileges .'</span>' . "\n";
echo ' </td>' . "\n";
echo ' </tr>' . "\n";
echo ' </table>' . "\n";
} // end if
?> ?>
</legend>
<?php if ( $is_create_table_priv ) { ?>
<?php echo PMA_generate_common_hidden_inputs( $db ); ?>
<div class="formelement">
<?php echo $strName; ?>:
<input type="text" name="table" maxlength="64" size="30" />
</div>
<div class="formelement">
<?php echo $strNumberOfFields; ?>:
<input type="text" name="num_fields" size="2" />
</div>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo $strGo; ?>" />
<?php } else { ?>
<div class="error"><?php echo $strNoPrivileges; ?></div>
<?php } // end if else ?>
</fieldset>
</form>