Bugfixing Syntaxcoloring
This commit is contained in:
@@ -232,7 +232,7 @@ $cfg['colorFunctions'] = 'red';
|
|||||||
$cfg['colorKeywords'] = 'blue';
|
$cfg['colorKeywords'] = 'blue';
|
||||||
$cfg['colorStrings'] = 'green';
|
$cfg['colorStrings'] = 'green';
|
||||||
$cfg['colorColType'] = '#FF9900';
|
$cfg['colorColType'] = '#FF9900';
|
||||||
$cfg['colorAdd'] = '#9999CC';
|
$cfg['colorAdd'] = 'blue';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -312,6 +312,7 @@ if($cfg['UseSyntaxColoring']) {
|
|||||||
'SELECT',
|
'SELECT',
|
||||||
'INSERT',
|
'INSERT',
|
||||||
'LEFT',
|
'LEFT',
|
||||||
|
'INNER',
|
||||||
'UPDATE',
|
'UPDATE',
|
||||||
'REPLACE',
|
'REPLACE',
|
||||||
'EXPLAIN',
|
'EXPLAIN',
|
||||||
@@ -326,7 +327,8 @@ if($cfg['UseSyntaxColoring']) {
|
|||||||
'ORDER',
|
'ORDER',
|
||||||
'CHANGE',
|
'CHANGE',
|
||||||
'CREATE',
|
'CREATE',
|
||||||
'DELETE'
|
'DELETE',
|
||||||
|
'VALUES'
|
||||||
);
|
);
|
||||||
} // end if
|
} // end if
|
||||||
if($cfg['UseSyntaxColoring']) {
|
if($cfg['UseSyntaxColoring']) {
|
||||||
|
@@ -210,8 +210,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
$_skeyw = '^' . implode('$|^', $cfg['keywords']) . '$';
|
$_skeyw = '^' . implode('$|^', $cfg['keywords']) . '$';
|
||||||
$_scoltype = '^' . implode('$|^', $cfg['ColumnTypes']) . '$';
|
$_scoltype = '^' . implode('$|^', $cfg['ColumnTypes']) . '$';
|
||||||
$_add = '^' . implode('$|^', $cfg['additional']) . '$';
|
$_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);
|
$sql = str_replace("\n", ' ', $sql);
|
||||||
// there should always be blanks around = and after , ()
|
// there should always be blanks around = and after , ()
|
||||||
$sql = str_replace('=', ' = ', $sql);
|
$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 ,
|
// we might have added to many blanks when checking for = and ,
|
||||||
// which might lead to empty members in the array
|
// which might lead to empty members in the array
|
||||||
if(strlen($_word)==0){continue;}
|
if(strlen($_word)==0){continue;}
|
||||||
|
$_is_string = FALSE;
|
||||||
// Anything inside quots might be more than one word
|
// 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
|
// so as we splitted by the blanks we have to try to get those parts back
|
||||||
// together
|
// 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
|
// start of a string
|
||||||
$_temp = $_word;
|
$_temp = $_word;
|
||||||
|
$_is_string = TRUE;
|
||||||
} else {
|
} else {
|
||||||
if(isset($_temp) && strlen($_temp)>0){
|
if(isset($_temp) && strlen($_temp)>0){
|
||||||
// we are continuing a string
|
// we are continuing a string
|
||||||
$_temp .= $_word;
|
$_temp .= $_word;
|
||||||
|
$_is_string = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(substr($_word, strlen($_word)-1, 1) == '\''
|
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
|
// End of a String
|
||||||
$_word = '<font color="' . $cfg['colorStrings'] . '">' . $_temp . '</font>';
|
$_word = '<font color="' . $cfg['colorStrings'] . '">' . $_temp . '</font>';
|
||||||
$_temp = '';
|
$_temp = '';
|
||||||
} else {
|
$_is_string = FALSE;
|
||||||
|
}
|
||||||
|
if(!isset($_is_string) || $_is_string == FALSE) {
|
||||||
// no String
|
// no String
|
||||||
if(eregi($_sfuncs, $_word)) {
|
if(eregi($_sfuncs, $_word)) {
|
||||||
$_word = '<font color="' . $cfg['colorFunctions'].'">' . $_word . '</font>';
|
$_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($_word==')') {
|
||||||
if(isset($_brack_o)){
|
if(isset($_brack_o)){
|
||||||
unset($_brack_o[count($_brack_o)-1]);
|
unset($_brack_o[count($_brack_o)-1]);
|
||||||
|
if(count($_brack_o)==0){ unset($_brack_o);}
|
||||||
} else {
|
} else {
|
||||||
$_brack_c[]=$s_nr;
|
$_brack_c[]=$s_nr;
|
||||||
}
|
}
|
||||||
@@ -303,7 +312,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = implode(' ',$_sql_p);
|
$sql = implode(' ',$_sql_p);
|
||||||
return nl2br($sql);
|
$sql = ereg_replace("((\015\012)|(\015)|(\012))+", '<br />', $sql);
|
||||||
|
return $sql;
|
||||||
} // End of PMA_format_sql function
|
} // End of PMA_format_sql function
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1097,7 +1107,7 @@ if (typeof(document.getElementById) != 'undefined'
|
|||||||
if (!empty($GLOBALS['show_as_php'])) {
|
if (!empty($GLOBALS['show_as_php'])) {
|
||||||
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
||||||
}else{
|
}else{
|
||||||
$new_line = "\n";
|
$new_line = "<br />\n";
|
||||||
}
|
}
|
||||||
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
||||||
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
||||||
|
@@ -355,7 +355,7 @@ if ($sql_query != '') {
|
|||||||
$a_sql_query = $pieces[$i];
|
$a_sql_query = $pieces[$i];
|
||||||
$result = mysql_query($a_sql_query);
|
$result = mysql_query($a_sql_query);
|
||||||
if ($result == FALSE) { // readdump failed
|
if ($result == FALSE) { // readdump failed
|
||||||
$my_die = PMA_format_sql($a_sql_query);
|
$my_die = $a_sql_query;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
|
if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
|
||||||
|
Reference in New Issue
Block a user