diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/FieldPicker.html b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/FieldPicker.html new file mode 100644 index 000000000..8b9f399bf --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/FieldPicker.html @@ -0,0 +1,81 @@ + + + + + + + + + + +
+
+ Please, double click a field to add it into the editor. +
+
+ Label +
+
+ +
+ +
+ + \ No newline at end of file diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/editor_plugin.js b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/editor_plugin.js new file mode 100644 index 000000000..333ce173c --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/editor_plugin.js @@ -0,0 +1,95 @@ +/** +* Name: editor_plugin_src.js (for pmFieldPicker tinyMCE plugin) +**/ + +(function(){ + // set the base url setting + tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; + var strPluginURL; + // the plugin init settings + tinymce.create('tinymce.plugins.pmFieldPickerPlugin', { + init: function(ed, url) + { + strPluginURL = url; // store the URL for future use.. + ed.addCommand('mcepmFieldPicker', function() { + pmFieldPicker(); + }); + ed.addButton('pmFieldPicker', { + title: 'Field Picker', + label : '@#', + cmd: 'mcepmFieldPicker', + image: url + '/img/picker.png' + }); + }, + createControl: function(n, cm) { + return null; + }, + getPluginURL: function() { + return strPluginURL; + } + }); + tinymce.PluginManager.add('pmFieldPicker', tinymce.plugins.pmFieldPickerPlugin); +})(); + +// this function can get called from the plugin inint (above) or from the callback on advlink/advimg plugins.. +// in the latter case, win and type will be set.. +/** + * @function pmFieldPicker + * @description Opens the plugin popup, loading the form inside it. + * @param field_name deprecated + * @param type deprecated + * @param win deprecated + * + */ +function pmFieldPicker(field_name, type, win) { + + var uloc=String(location); + var new_text = uloc.split('/'); + var loc='/'+new_text[3]+'/'+new_text[4]+'/'+new_text[5]+'/controls/varsAjax?displayOption=tinyMCE&sSymbol=@@&&sProcess='+tinyMCE.activeEditor.processID; + var strPluginPath = tinyMCE.activeEditor.plugins.pmFieldPicker.getPluginURL(); // get the path to the uploader plugin + var strUploaderURL = strPluginPath + "/uploader.php"; // generate the path to the uploader script + var strUploadPath = tinyMCE.activeEditor.getParam('plugin_pmFieldPicker_upload_path'); // get the relative upload path + var strSubstitutePath = tinyMCE.activeEditor.getParam('plugin_pmFieldPicker_upload_substitute_path'); // get the path we'll substitute for the for the upload path (i.e. fully qualified) + + if (strUploaderURL.indexOf("?") < 0){ // if we were called without any GET params + strUploaderURL = strUploaderURL + "?type=" + type + "&d=" + strUploadPath + "&subs=" + strSubstitutePath; // add our own params + } else { + strUploaderURL = strUploaderURL + "&type=" + type + "&d=" + strUploadPath + "&subs=" + strSubstitutePath; + } + //tinyMCE.activeEditor.anyVariable='path/to/ProcessMaker' + tinyMCE.activeEditor.windowManager.open({ // open the plugin popup + file : strPluginPath+'/FieldPicker.html', + title : 'Pick a Field', + width : '400px', + height : '120px', + resizable : "yes", + scrollbars : "no", + overflow : false, + inline : 1, // This parameter only has an effect if you use the inlinepopups plugin! + close_previous : "no" + }, { + window : win, + input : field_name + }); + + return false; +} + +/** + * @function closePluginPopup + * @description closes the tinyMCE popup window + */ +function closePluginPopup(){ + tinyMCEPopup.close(); // close popup window +} + +/** + * @function updateEditorContent + * @description insert the editor content with a html code string + * @params serializedHTML String html code + */ +function updateEditorContent(serializedHTML){ + tinyMCE.activeEditor.execCommand('mceInsertContent', false, serializedHTML); + closePluginPopup(); +} + diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/editor_plugin_src.js b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/editor_plugin_src.js new file mode 100644 index 000000000..333ce173c --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/editor_plugin_src.js @@ -0,0 +1,95 @@ +/** +* Name: editor_plugin_src.js (for pmFieldPicker tinyMCE plugin) +**/ + +(function(){ + // set the base url setting + tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; + var strPluginURL; + // the plugin init settings + tinymce.create('tinymce.plugins.pmFieldPickerPlugin', { + init: function(ed, url) + { + strPluginURL = url; // store the URL for future use.. + ed.addCommand('mcepmFieldPicker', function() { + pmFieldPicker(); + }); + ed.addButton('pmFieldPicker', { + title: 'Field Picker', + label : '@#', + cmd: 'mcepmFieldPicker', + image: url + '/img/picker.png' + }); + }, + createControl: function(n, cm) { + return null; + }, + getPluginURL: function() { + return strPluginURL; + } + }); + tinymce.PluginManager.add('pmFieldPicker', tinymce.plugins.pmFieldPickerPlugin); +})(); + +// this function can get called from the plugin inint (above) or from the callback on advlink/advimg plugins.. +// in the latter case, win and type will be set.. +/** + * @function pmFieldPicker + * @description Opens the plugin popup, loading the form inside it. + * @param field_name deprecated + * @param type deprecated + * @param win deprecated + * + */ +function pmFieldPicker(field_name, type, win) { + + var uloc=String(location); + var new_text = uloc.split('/'); + var loc='/'+new_text[3]+'/'+new_text[4]+'/'+new_text[5]+'/controls/varsAjax?displayOption=tinyMCE&sSymbol=@@&&sProcess='+tinyMCE.activeEditor.processID; + var strPluginPath = tinyMCE.activeEditor.plugins.pmFieldPicker.getPluginURL(); // get the path to the uploader plugin + var strUploaderURL = strPluginPath + "/uploader.php"; // generate the path to the uploader script + var strUploadPath = tinyMCE.activeEditor.getParam('plugin_pmFieldPicker_upload_path'); // get the relative upload path + var strSubstitutePath = tinyMCE.activeEditor.getParam('plugin_pmFieldPicker_upload_substitute_path'); // get the path we'll substitute for the for the upload path (i.e. fully qualified) + + if (strUploaderURL.indexOf("?") < 0){ // if we were called without any GET params + strUploaderURL = strUploaderURL + "?type=" + type + "&d=" + strUploadPath + "&subs=" + strSubstitutePath; // add our own params + } else { + strUploaderURL = strUploaderURL + "&type=" + type + "&d=" + strUploadPath + "&subs=" + strSubstitutePath; + } + //tinyMCE.activeEditor.anyVariable='path/to/ProcessMaker' + tinyMCE.activeEditor.windowManager.open({ // open the plugin popup + file : strPluginPath+'/FieldPicker.html', + title : 'Pick a Field', + width : '400px', + height : '120px', + resizable : "yes", + scrollbars : "no", + overflow : false, + inline : 1, // This parameter only has an effect if you use the inlinepopups plugin! + close_previous : "no" + }, { + window : win, + input : field_name + }); + + return false; +} + +/** + * @function closePluginPopup + * @description closes the tinyMCE popup window + */ +function closePluginPopup(){ + tinyMCEPopup.close(); // close popup window +} + +/** + * @function updateEditorContent + * @description insert the editor content with a html code string + * @params serializedHTML String html code + */ +function updateEditorContent(serializedHTML){ + tinyMCE.activeEditor.execCommand('mceInsertContent', false, serializedHTML); + closePluginPopup(); +} + diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/img/picker.png b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/img/picker.png new file mode 100644 index 000000000..0d1642339 Binary files /dev/null and b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/img/picker.png differ diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/langs/en.js b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/langs/en.js new file mode 100644 index 000000000..d272817db --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/langs/en.js @@ -0,0 +1,3 @@ +tinyMCE.addI18n('en.pmFieldPicker', { + desc:"Pick a Field" +}); diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/progress.gif b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/progress.gif new file mode 100644 index 000000000..2aea68c8e Binary files /dev/null and b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmFieldPicker/progress.gif differ diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/langs/en.js b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/langs/en.js index 82cc06aa9..9c5cb5584 100644 --- a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/langs/en.js +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/langs/en.js @@ -1,3 +1,3 @@ -tinyMCE.addI18n('en.ccSimpleUploader', { - desc:"Upload File to Server" +tinyMCE.addI18n('en.pmVariablePicker', { + desc:"Pick a Variable" }); diff --git a/gulliver/system/class.wysiwygEditor.php b/gulliver/system/class.wysiwygEditor.php index d976e145c..a0d118cb2 100644 --- a/gulliver/system/class.wysiwygEditor.php +++ b/gulliver/system/class.wysiwygEditor.php @@ -43,6 +43,8 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field public $defaultValue = '
'; public $editorType = ''; public $processID = ''; + public $dynUID = ''; + /** * render function returns the HTML definition for the Dynaform Field * @@ -142,16 +144,18 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field case 'DYNAFORM_TEMPLATE': $editorDefinition.= ' + var formProcessID = document.getElementById("form[PRO_UID]").value; + var formDynaformID = document.getElementById("form[DYN_UID]").value; tinyMCE.init({ theme : "advanced", - plugins : "advhr,advimage,advlink,advlist,autolink,autoresize,autosave,contextmenu,directionality,emotions,example,example_dependency,fullpage,fullscreen,iespell,inlinepopups,insertdatetime,layer,legacyoutput,lists,media,nonbreaking,noneditable,pagebreak,paste,preview,print,save,searchreplace,spellchecker,style,tabfocus,table,template,visualblocks,visualchars,wordcount,xhtmlxtras,style,table", + plugins : "advhr,advimage,advlink,advlist,autolink,autoresize,autosave,contextmenu,directionality,emotions,example,example_dependency,fullpage,fullscreen,iespell,inlinepopups,insertdatetime,layer,legacyoutput,lists,media,nonbreaking,noneditable,pagebreak,paste,preview,print,save,searchreplace,spellchecker,style,tabfocus,table,template,visualblocks,visualchars,wordcount,xhtmlxtras,style,table,noneditable,pmFieldPicker", mode : "specific_textareas", //apply_source_formatting : true, //remove_linebreaks: false, editor_selector : "tmceEditor", - width : 850, + width : \'100%\', height : 300, - theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,|,cut,copy,paste,|,bullist,numlist", + theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,|,cut,copy,paste,|,bullist,numlist,|,pmFieldPicker", theme_advanced_buttons2 : "tablecontrols,|outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,|,forecolor,backcolor,styleprops,|,hr,removeformat,visualaid,|,sub,sup,|,ltr,rtl,|,code", popup_css : "/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/dialog.css", skin : "o2k7", @@ -162,10 +166,16 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field external_image_list_url : "js/image_list.js", media_external_list_url : "js/media_list.js", extended_valid_elements : "div[*]", +// noneditable_regexp: /[^"|^:|^\']{(.*?)}/g, template_replace_values : { username : "Some User", staffid : "991234" }, + oninit: function () { + tinyMCE.activeEditor.domainURL = domainURL; + tinyMCE.activeEditor.dynUID = formDynaformID; + tinyMCE.activeEditor.proUID = formProcessID; + }, handle_event_callback : function(e) { if(this.isDirty()) { this.save(); diff --git a/workflow/engine/classes/class.dynaformEditor.php b/workflow/engine/classes/class.dynaformEditor.php index 308863436..b3fb60e8e 100755 --- a/workflow/engine/classes/class.dynaformEditor.php +++ b/workflow/engine/classes/class.dynaformEditor.php @@ -416,8 +416,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax } else { $error = 0; } - $HtmlEditor = array('URL' => $A, 'HTML' => $html - ); + $HtmlEditor = array('URL' => $A, 'HTML' => $html, 'DYN_UID' => $file ); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_HtmlEditor', '', $HtmlEditor, '', ''); G::RenderPage("publish", 'raw'); return array('error' => $error, 'html' => ob_get_clean() diff --git a/workflow/engine/methods/processes/processes_Ajax.php b/workflow/engine/methods/processes/processes_Ajax.php index 31db2fafc..f0ad1a768 100755 --- a/workflow/engine/methods/processes/processes_Ajax.php +++ b/workflow/engine/methods/processes/processes_Ajax.php @@ -551,16 +551,16 @@ try { } echo Bootstrap::json_encode( $aVariables ); break; - /** - * returns the prefix mean - * + /** + * returns the prefix mean + * */ case 'getVariablePrefix': $_REQUEST['prefix'] = $_REQUEST['prefix']!=null?$_REQUEST['prefix']:'ID_TO_STRING'; echo G::LoadTranslation($_REQUEST['prefix']); break; - /** - * return an array with all Variables of Grid type + /** + * return an array with all Variables of Grid type */ case 'getGridList': G::LoadClass('xmlfield_InputPM'); @@ -574,8 +574,8 @@ try { } echo Bootstrap::json_encode( $aVariables ); break; - /** - * return an array with all Grid Variables according to Grid + /** + * return an array with all Grid Variables according to Grid */ case 'getVariableGrid': G::LoadClass('xmlfield_InputPM'); @@ -593,6 +593,24 @@ try { echo Bootstrap::json_encode( $aVariables ); break; + case 'getDynaformFieldList': + G::LoadClass( 'dynaformhandler' ); + $dynaformFields = array (); + $resultArray = array (); + $proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:''; + $dynUid= isset( $_REQUEST['DYN_UID'] )?$_REQUEST['DYN_UID']:''; + if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) { + $dyn = new dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' ); + $dynaformFields[] = $dyn->getFields(); + } + foreach ($dynaformFields as $aDynFormFields) { + foreach ($aDynFormFields as $field) { + $resultArray[] = array ("id"=>$field->nodeName, "name"=>$field->nodeName ); + } + } + echo Bootstrap::json_encode( $resultArray ); +// var_dump($resultArray); + break; /* case 'saveFile': global $G_PUBLISH; diff --git a/workflow/engine/xmlform/dynaforms/dynaforms_HtmlEditor.xml b/workflow/engine/xmlform/dynaforms/dynaforms_HtmlEditor.xml index bd671034c..f6d675450 100755 --- a/workflow/engine/xmlform/dynaforms/dynaforms_HtmlEditor.xml +++ b/workflow/engine/xmlform/dynaforms/dynaforms_HtmlEditor.xml @@ -3,7 +3,7 @@ - + Enable HTML Editing @@ -21,7 +21,7 @@ HTML View - + HTML View