Adding feature to coloring and check syntaxis on trigger editor.

This commit is contained in:
ralph
2013-03-22 15:52:26 -04:00
parent 8bde064996
commit cbe2fbe871
10 changed files with 346 additions and 23 deletions

View File

@@ -19,6 +19,8 @@ var PHPHTMLMixedParser = Editor.Parser = (function() {
var htmlParser = XMLParser.make(stream), localParser = null, var htmlParser = XMLParser.make(stream), localParser = null,
inTag = false, lastAtt = null, phpParserState = null; inTag = false, lastAtt = null, phpParserState = null;
var iter = {next: top, copy: copy}; var iter = {next: top, copy: copy};
if (Editor.Parser.options && Editor.Parser.options.parserConfig.phpOnly == true)
iter.next = local(PHPParser, "?>");
function top() { function top() {
var token = htmlParser.next(); var token = htmlParser.next();
@@ -49,6 +51,10 @@ var PHPHTMLMixedParser = Editor.Parser = (function() {
lastAtt = null; lastAtt = null;
inTag = false; inTag = false;
} }
else if (token.type == "xml-text" && token.style == "xml-text") {
if (Editor.Parser.options && Editor.Parser.options.parserConfig.phpOnly == true)
iter.next = local(PHPParser, "?>");
}
return token; return token;
} }
function local(parser, tag) { function local(parser, tag) {

View File

@@ -956,6 +956,14 @@ var tokenizePHP = (function() {
"SplQueue", "SplStack", "SQLite3", "SQLite3Result", "SQLite3Stmt", "SQLiteDatabase", "SplQueue", "SplStack", "SQLite3", "SQLite3Result", "SQLite3Stmt", "SQLiteDatabase",
"SQLiteException", "SQLiteResult", "SQLiteUnbuffered", "Svn", "SvnNode", "SvnWc", "SQLiteException", "SQLiteResult", "SQLiteUnbuffered", "Svn", "SvnNode", "SvnWc",
"SvnWcSchedule", "XSLTProcessor", "ZipArchive", "SvnWcSchedule", "XSLTProcessor", "ZipArchive",
"PMFTaskCase","PMFTaskList","PMFUserList","PMFGroupList",
"PMFRoleList","PMFCaseList","PMFProcessList","PMFSendVariables",
"PMFDerivateCase","PMFNewCaseImpersonate","PMFNewCase","PMFPauseCase",
"PMFUnpauseCase","PMFAssignUserToGroup","PMFCreateUser","PMFUpdateUser",
"PMFInformationUser","generateCode","setCaseTrackerCode","jumping",
"PMFRedirectToStep","pauseCase","PMFSendMessage","PMFgetLabelOption",
"PMFGenerateOutputDocument","PMFGetUserEmailAddress","PMFGetNextAssignedUser","PMFDeleteCase",
"PMFCancelCase","PMFAddInputDocument","PMFAddCaseNote","PMFGetCaseNotes"
].forEach(function(element, index, array) { ].forEach(function(element, index, array) {
result[element] = token("t_string", "php-predefined-class"); result[element] = token("t_string", "php-predefined-class");
}); });

View File

@@ -0,0 +1,114 @@
/*
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed by
Yahoo! Inc. under the BSD (revised) open source license
@author Dan Vlad Dascalescu <dandv@yahoo-inc.com>
*/
html {
cursor: text;
}
.editbox {
margin: .4em;
padding: 0;
font-family: monospace;
font-size: 10pt;
}
/*We should define specific styles for every element of the syntax.
the setting below will cause some annoying color to show through if we missed
defining a style for a token. This is also the "color" of the whitespace and
of the cursor.
*/
pre.code, .editbox {
color: red;
}
.editbox p {
margin: 0;
}
span.php-punctuation {
color: blue;
}
span.php-keyword {
color: #770088;
font-weight: bold;
}
span.php-operator {
color: blue;
}
/* __FILE__ etc.; http://php.net/manual/en/reserved.php */
span.php-compile-time-constant {
color: #776088;
font-weight: bold;
}
/* output of get_defined_constants(). Differs from http://php.net/manual/en/reserved.constants.php */
span.php-predefined-constant {
color: darkgreen;
font-weight: bold;
}
/* PHP reserved "language constructs"... echo() etc.; http://php.net/manual/en/reserved.php */
span.php-reserved-language-construct {
color: green;
font-weight: bold;
}
/* PHP built-in functions: glob(), chr() etc.; output of get_defined_functions()["internal"] */
span.php-predefined-function {
color: green;
}
/* PHP predefined classes: PDO, Exception etc.; output of get_declared_classes() and different from http://php.net/manual/en/reserved.classes.php */
span.php-predefined-class {
color: green;
}
span.php-atom {
color: #228811;
}
/* class, interface, namespace or function names, but not $variables */
span.php-t_string {
color: black;
}
span.php-variable {
color: black;
font-weight: bold;
}
span.js-localvariable {
color: #004499;
}
span.php-comment {
color: #AA7700;
font-stretch: condensed;
/* font-style: italic; This causes line height to slightly change, getting line numbers out of sync */
}
span.php-string-single-quoted {
color: #AA2222;
}
/* double quoted strings allow interpolation */
span.php-string-double-quoted {
color: #AA2222;
font-weight: bold;
}
span.syntax-error {
background-color: red;
}
span.deprecated {
font-size: smaller;
}

View File

@@ -420,8 +420,10 @@ var Editor = (function(){
if (!Editor.Parser) if (!Editor.Parser)
throw "No parser loaded."; throw "No parser loaded.";
if (options.parserConfig && Editor.Parser.configure) if (options.parserConfig && Editor.Parser.configure) {
Editor.Parser.configure(options.parserConfig); Editor.Parser.configure(options.parserConfig);
Editor.Parser.options = options;
}
if (!options.readOnly && !internetExplorer) if (!options.readOnly && !internetExplorer)
select.setCursorPos(container, {node: null, offset: 0}); select.setCursorPos(container, {node: null, offset: 0});

View File

@@ -63,9 +63,10 @@ if (isset( $_GET['TRI_UID'] )) {
$xmlform = 'triggers/triggersProperties'; $xmlform = 'triggers/triggersProperties';
$xmlform_action = '../triggers/triggers_Save'; $xmlform_action = '../triggers/triggers_Save';
} }
G::LoadClass( 'xmlfield_InputPM' ); G::LoadClass( 'xmlfield_InputPM' );
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $aFields, $xmlform_action ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $aFields, $xmlform_action );
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher->addScriptFile('/js/codemirror/js/codemirror.js', 1);
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );

View File

@@ -17,6 +17,8 @@
<cssFile file="sprite.css" enabledBrowsers="ALL" disabledBrowsers="ie7"></cssFile> <cssFile file="sprite.css" enabledBrowsers="ALL" disabledBrowsers="ie7"></cssFile>
<cssFile file="xmlcolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile> <cssFile file="xmlcolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="jscolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile> <cssFile file="jscolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="csscolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="phpcolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="rtl.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile> <cssFile file="rtl.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
</skin> </skin>
<blank> <blank>
@@ -49,7 +51,9 @@
<cssFile file="sprite.css" enabledBrowsers="ALL" disabledBrowsers="ie7"></cssFile> <cssFile file="sprite.css" enabledBrowsers="ALL" disabledBrowsers="ie7"></cssFile>
<cssFile file="xmlcolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile> <cssFile file="xmlcolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="jscolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile> <cssFile file="jscolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="csscolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="phpcolors.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
<cssFile file="rtl.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile> <cssFile file="rtl.css" enabledBrowsers="ALL" disabledBrowsers=""></cssFile>
</extjs> </extjs>
</cssFiles> </cssFiles>
</skinConfiguration> </skinConfiguration>

View File

@@ -0,0 +1,55 @@
html {
cursor: text;
}
.editbox {
margin: .4em;
padding: 0;
font-family: monospace;
font-size: 10pt;
color: black;
}
pre.code, .editbox {
color: #666;
}
.editbox p {
margin: 0;
}
span.css-at {
color: #708;
}
span.css-unit {
color: #281;
}
span.css-value {
color: #708;
}
span.css-identifier {
color: black;
}
span.css-selector {
color: #11B;
}
span.css-important {
color: #00F;
}
span.css-colorcode {
color: #299;
}
span.css-comment {
color: #A70;
}
span.css-string {
color: #A22;
}

View File

@@ -0,0 +1,114 @@
/*
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed by
Yahoo! Inc. under the BSD (revised) open source license
@author Dan Vlad Dascalescu <dandv@yahoo-inc.com>
*/
html {
cursor: text;
}
.editbox {
margin: .4em;
padding: 0;
font-family: monospace;
font-size: 10pt;
}
/*We should define specific styles for every element of the syntax.
the setting below will cause some annoying color to show through if we missed
defining a style for a token. This is also the "color" of the whitespace and
of the cursor.
*/
pre.code, .editbox {
color: red;
}
.editbox p {
margin: 0;
}
span.php-punctuation {
color: blue;
}
span.php-keyword {
color: #770088;
font-weight: bold;
}
span.php-operator {
color: blue;
}
/* __FILE__ etc.; http://php.net/manual/en/reserved.php */
span.php-compile-time-constant {
color: #776088;
font-weight: bold;
}
/* output of get_defined_constants(). Differs from http://php.net/manual/en/reserved.constants.php */
span.php-predefined-constant {
color: darkgreen;
font-weight: bold;
}
/* PHP reserved "language constructs"... echo() etc.; http://php.net/manual/en/reserved.php */
span.php-reserved-language-construct {
color: green;
font-weight: bold;
}
/* PHP built-in functions: glob(), chr() etc.; output of get_defined_functions()["internal"] */
span.php-predefined-function {
color: green;
}
/* PHP predefined classes: PDO, Exception etc.; output of get_declared_classes() and different from http://php.net/manual/en/reserved.classes.php */
span.php-predefined-class {
color: green;
}
span.php-atom {
color: #228811;
}
/* class, interface, namespace or function names, but not $variables */
span.php-t_string {
color: black;
}
span.php-variable {
color: black;
font-weight: bold;
}
span.js-localvariable {
color: #004499;
}
span.php-comment {
color: #AA7700;
font-stretch: condensed;
/* font-style: italic; This causes line height to slightly change, getting line numbers out of sync */
}
span.php-string-single-quoted {
color: #AA2222;
}
/* double quoted strings allow interpolation */
span.php-string-double-quoted {
color: #AA2222;
font-weight: bold;
}
span.syntax-error {
background-color: red;
}
span.deprecated {
font-size: smaller;
}

View File

@@ -35,8 +35,8 @@
</div> </div>
<div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div> <div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div>
</div> </div>
<script type="text/javascript"> <script src="js/codemirror/js/codemirror.js" type="text/javascript">
{$form.JS} {$form.JS}
</script> </script>
</form> </form>

View File

@@ -14,11 +14,20 @@
<en>Cancel</en> <en>Cancel</en>
</BTN_CANCEL> </BTN_CANCEL>
<SAVE type="button" onclick="triggerSave1(this.form);"> <SAVE type="button" onclick="document.getElementById('form[TRI_WEBBOT]').value = triggerEditor.getCode(); triggerSave1(this.form);">
<en>Save</en> <en>Save</en>
</SAVE> </SAVE>
<JS type="JavaScript"><![CDATA[ <JS type="JavaScript"><![CDATA[
var triggerEditor = CodeMirror.fromTextArea('form[TRI_WEBBOT]', {
height: "380px",
width: "90%",
parserfile: ["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js",
"../contrib/php/js/tokenizephp.js", "../contrib/php/js/parsephp.js",
"../contrib/php/js/parsephphtmlmixed.js"],
stylesheet: ["css/xmlcolors.css", "css/jscolors.css", "css/csscolors.css", "css/phpcolors.css" ],
path: "js/", lineNumbers: true, continuousScanning: 500, parserConfig: { phpOnly:true} });
var _oVarsPanel_; var _oVarsPanel_;
var showDynaformsFormVars = function(sFieldName, sAjaxServer, sProcess, sSymbol) { var showDynaformsFormVars = function(sFieldName, sAjaxServer, sProcess, sSymbol) {
_oVarsPanel_ = new leimnud.module.panel(); _oVarsPanel_ = new leimnud.module.panel();
@@ -54,27 +63,37 @@ var showDynaformsFormVars = function(sFieldName, sAjaxServer, sProcess, sSymbol)
}; };
var insertFormVar = function(sFieldName, sValue) { var insertFormVar = function(sFieldName, sValue) {
oAux = document.getElementById(sFieldName); //DEPRECTED
if (oAux.setSelectionRange) { //oAux = document.getElementById(sFieldName);
var rangeStart = oAux.selectionStart; //if (oAux.setSelectionRange) {
var rangeEnd = oAux.selectionEnd; //var rangeStart = oAux.selectionStart;
var tempStr1 = oAux.value.substring(0,rangeStart); //var rangeEnd = oAux.selectionEnd;
var tempStr2 = oAux.value.substring(rangeEnd); //var tempStr1 = oAux.value.substring(0,rangeStart);
oAux.value = tempStr1 + sValue + tempStr2; //var tempStr2 = oAux.value.substring(rangeEnd);
} //oAux.value = tempStr1 + sValue + tempStr2;
else { //}
if (document.selection) { //else {
oAux.focus(); //if (document.selection) {
document.selection.createRange().text = sValue; //oAux.focus();
} //document.selection.createRange().text = sValue;
} //}
_oVarsPanel_.remove(); //}
//codeMirror code
if (triggerEditor.selection() == "") {
pos = triggerEditor.cursorPosition();
line = triggerEditor.cursorLine();
triggerEditor.insertIntoLine(line, pos.character, sValue);
} else {
triggerEditor.replaceSelection(sValue);
}
_oVarsPanel_.remove();
triggerEditor.focus();
triggerEditor.focusIfIE();
}; };
function cancel(){ function cancel(){
currentPopupWindow.remove(); currentPopupWindow.remove();
} }
]]></JS> ]]></JS>
</dynaForm> </dynaForm>