Bugfixing Syntaxcoloring

This commit is contained in:
Mike Beck
2002-06-12 16:12:07 +00:00
parent e4026cda01
commit 923a2c12e6
3 changed files with 25 additions and 13 deletions

View File

@@ -232,7 +232,7 @@ $cfg['colorFunctions'] = 'red';
$cfg['colorKeywords'] = 'blue';
$cfg['colorStrings'] = 'green';
$cfg['colorColType'] = '#FF9900';
$cfg['colorAdd'] = '#9999CC';
$cfg['colorAdd'] = 'blue';
/**
@@ -312,6 +312,7 @@ if($cfg['UseSyntaxColoring']) {
'SELECT',
'INSERT',
'LEFT',
'INNER',
'UPDATE',
'REPLACE',
'EXPLAIN',
@@ -326,7 +327,8 @@ if($cfg['UseSyntaxColoring']) {
'ORDER',
'CHANGE',
'CREATE',
'DELETE'
'DELETE',
'VALUES'
);
} // end if
if($cfg['UseSyntaxColoring']) {

View File

@@ -210,8 +210,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
$_skeyw = '^' . implode('$|^', $cfg['keywords']) . '$';
$_scoltype = '^' . implode('$|^', $cfg['ColumnTypes']) . '$';
$_add = '^' . implode('$|^', $cfg['additional']) . '$';
// first of all lets remove all newlines - we'll add our own later
// first of all lets remove all newlines - we'll add our own later
$sql = str_replace("\n", ' ', $sql);
// there should always be blanks around = and after , ()
$sql = str_replace('=', ' = ', $sql);
@@ -229,16 +229,22 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// we might have added to many blanks when checking for = and ,
// which might lead to empty members in the array
if(strlen($_word)==0){continue;}
$_is_string = FALSE;
// Anything inside quots might be more than one word
// so as we splitted by the blanks we have to try to get those parts back
// together
if (substr($_word, 0, 1) == '\'' || substr($_word, 0, 1) == '"') {
if (
(substr($_word, 0, 1) == '\'' || substr($_word, 0, 1) == '"') &&
(!isset($_temp) || strlen($_temp)==0)
) {
// start of a string
$_temp = $_word;
$_is_string = TRUE;
} else {
if(isset($_temp) && strlen($_temp)>0){
// we are continuing a string
$_temp .= $_word;
$_is_string = TRUE;
}
}
if(substr($_word, strlen($_word)-1, 1) == '\''
@@ -246,7 +252,9 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// End of a String
$_word = '<font color="' . $cfg['colorStrings'] . '">' . $_temp . '</font>';
$_temp = '';
} else {
$_is_string = FALSE;
}
if(!isset($_is_string) || $_is_string == FALSE) {
// no String
if(eregi($_sfuncs, $_word)) {
$_word = '<font color="' . $cfg['colorFunctions'].'">' . $_word . '</font>';
@@ -271,6 +279,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
if($_word==')') {
if(isset($_brack_o)){
unset($_brack_o[count($_brack_o)-1]);
if(count($_brack_o)==0){ unset($_brack_o);}
} else {
$_brack_c[]=$s_nr;
}
@@ -303,7 +312,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
}
}
$sql = implode(' ',$_sql_p);
return nl2br($sql);
$sql = ereg_replace("((\015\012)|(\015)|(\012))+", '<br />', $sql);
return $sql;
} // End of PMA_format_sql function
/**
@@ -1097,7 +1107,7 @@ if (typeof(document.getElementById) != 'undefined'
if (!empty($GLOBALS['show_as_php'])) {
$new_line = '&quot;;<br />' . "\n" . ' $sql .= &quot;';
}else{
$new_line = "\n";
$new_line = "<br />\n";
}
$query_base = htmlspecialchars($GLOBALS['sql_query']);
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);

View File

@@ -355,7 +355,7 @@ if ($sql_query != '') {
$a_sql_query = $pieces[$i];
$result = mysql_query($a_sql_query);
if ($result == FALSE) { // readdump failed
$my_die = PMA_format_sql($a_sql_query);
$my_die = $a_sql_query;
break;
}
if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {