From cbe2fbe871afd3e9e182b8f0dea82a7a69b48d3c Mon Sep 17 00:00:00 2001 From: ralph Date: Fri, 22 Mar 2013 15:52:26 -0400 Subject: [PATCH] Adding feature to coloring and check syntaxis on trigger editor. --- .../contrib/php/js/parsephphtmlmixed.js | 6 + .../codemirror/contrib/php/js/tokenizephp.js | 8 ++ gulliver/js/codemirror/css/phpcolors.css | 114 ++++++++++++++++++ gulliver/js/codemirror/js/editor.js | 4 +- .../engine/methods/triggers/triggers_Edit.php | 3 +- workflow/engine/skinEngine/base/config.xml | 6 +- .../engine/skinEngine/base/css/csscolors.css | 55 +++++++++ .../engine/skinEngine/base/css/phpcolors.css | 114 ++++++++++++++++++ .../xmlform/triggers/triggers_Edit.html | 4 +- .../engine/xmlform/triggers/triggers_Edit.xml | 55 ++++++--- 10 files changed, 346 insertions(+), 23 deletions(-) create mode 100755 gulliver/js/codemirror/css/phpcolors.css create mode 100755 workflow/engine/skinEngine/base/css/csscolors.css create mode 100755 workflow/engine/skinEngine/base/css/phpcolors.css diff --git a/gulliver/js/codemirror/contrib/php/js/parsephphtmlmixed.js b/gulliver/js/codemirror/contrib/php/js/parsephphtmlmixed.js index fa189c18c..7c23007c2 100755 --- a/gulliver/js/codemirror/contrib/php/js/parsephphtmlmixed.js +++ b/gulliver/js/codemirror/contrib/php/js/parsephphtmlmixed.js @@ -19,6 +19,8 @@ var PHPHTMLMixedParser = Editor.Parser = (function() { var htmlParser = XMLParser.make(stream), localParser = null, inTag = false, lastAtt = null, phpParserState = null; var iter = {next: top, copy: copy}; + if (Editor.Parser.options && Editor.Parser.options.parserConfig.phpOnly == true) + iter.next = local(PHPParser, "?>"); function top() { var token = htmlParser.next(); @@ -49,6 +51,10 @@ var PHPHTMLMixedParser = Editor.Parser = (function() { lastAtt = null; 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; } function local(parser, tag) { diff --git a/gulliver/js/codemirror/contrib/php/js/tokenizephp.js b/gulliver/js/codemirror/contrib/php/js/tokenizephp.js index 39041dc29..70b683f89 100755 --- a/gulliver/js/codemirror/contrib/php/js/tokenizephp.js +++ b/gulliver/js/codemirror/contrib/php/js/tokenizephp.js @@ -956,6 +956,14 @@ var tokenizePHP = (function() { "SplQueue", "SplStack", "SQLite3", "SQLite3Result", "SQLite3Stmt", "SQLiteDatabase", "SQLiteException", "SQLiteResult", "SQLiteUnbuffered", "Svn", "SvnNode", "SvnWc", "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) { result[element] = token("t_string", "php-predefined-class"); }); diff --git a/gulliver/js/codemirror/css/phpcolors.css b/gulliver/js/codemirror/css/phpcolors.css new file mode 100755 index 000000000..43d4057b1 --- /dev/null +++ b/gulliver/js/codemirror/css/phpcolors.css @@ -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 +*/ + +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; +} diff --git a/gulliver/js/codemirror/js/editor.js b/gulliver/js/codemirror/js/editor.js index fddd0939a..4732686d4 100755 --- a/gulliver/js/codemirror/js/editor.js +++ b/gulliver/js/codemirror/js/editor.js @@ -420,8 +420,10 @@ var Editor = (function(){ if (!Editor.Parser) throw "No parser loaded."; - if (options.parserConfig && Editor.Parser.configure) + if (options.parserConfig && Editor.Parser.configure) { Editor.Parser.configure(options.parserConfig); + Editor.Parser.options = options; + } if (!options.readOnly && !internetExplorer) select.setCursorPos(container, {node: null, offset: 0}); diff --git a/workflow/engine/methods/triggers/triggers_Edit.php b/workflow/engine/methods/triggers/triggers_Edit.php index ddbea6e5b..3d9a7ecb7 100755 --- a/workflow/engine/methods/triggers/triggers_Edit.php +++ b/workflow/engine/methods/triggers/triggers_Edit.php @@ -63,9 +63,10 @@ if (isset( $_GET['TRI_UID'] )) { $xmlform = 'triggers/triggersProperties'; $xmlform_action = '../triggers/triggers_Save'; } - G::LoadClass( 'xmlfield_InputPM' ); $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $aFields, $xmlform_action ); +$oHeadPublisher =& headPublisher::getSingleton(); +$oHeadPublisher->addScriptFile('/js/codemirror/js/codemirror.js', 1); G::RenderPage( 'publish', 'raw' ); diff --git a/workflow/engine/skinEngine/base/config.xml b/workflow/engine/skinEngine/base/config.xml index ddcf56ea6..30e05b49e 100755 --- a/workflow/engine/skinEngine/base/config.xml +++ b/workflow/engine/skinEngine/base/config.xml @@ -17,6 +17,8 @@ + + @@ -49,7 +51,9 @@ + + - \ No newline at end of file + diff --git a/workflow/engine/skinEngine/base/css/csscolors.css b/workflow/engine/skinEngine/base/css/csscolors.css new file mode 100755 index 000000000..cd4b79e3c --- /dev/null +++ b/workflow/engine/skinEngine/base/css/csscolors.css @@ -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; +} diff --git a/workflow/engine/skinEngine/base/css/phpcolors.css b/workflow/engine/skinEngine/base/css/phpcolors.css new file mode 100755 index 000000000..43d4057b1 --- /dev/null +++ b/workflow/engine/skinEngine/base/css/phpcolors.css @@ -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 +*/ + +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; +} diff --git a/workflow/engine/xmlform/triggers/triggers_Edit.html b/workflow/engine/xmlform/triggers/triggers_Edit.html index d892c1436..9209f7c45 100755 --- a/workflow/engine/xmlform/triggers/triggers_Edit.html +++ b/workflow/engine/xmlform/triggers/triggers_Edit.html @@ -35,8 +35,8 @@
- - \ No newline at end of file + diff --git a/workflow/engine/xmlform/triggers/triggers_Edit.xml b/workflow/engine/xmlform/triggers/triggers_Edit.xml index 82cb4418b..875499d96 100755 --- a/workflow/engine/xmlform/triggers/triggers_Edit.xml +++ b/workflow/engine/xmlform/triggers/triggers_Edit.xml @@ -14,11 +14,20 @@ Cancel - + Save - \ No newline at end of file +