From 21839bd82a454e760b7434a241c9de14e65ff6de Mon Sep 17 00:00:00 2001 From: norahmollo Date: Mon, 19 Nov 2012 20:48:57 +0000 Subject: [PATCH] WYSIWYG EDITOR Variable Picker WYSIWYG EDITOR variable picker for Output Documents --- .../pmVariablePicker/editor_plugin_src.js | 70 ++++++++++++++++++ .../plugins/pmVariablePicker/img/picker.png | Bin 0 -> 595 bytes .../plugins/pmVariablePicker/langs/en.js | 3 + .../plugins/pmVariablePicker/progress.gif | Bin 0 -> 2005 bytes .../plugins/pmVariablePicker/uploader.php | 63 ++++++++++++++++ gulliver/system/class.wysiwygEditor.php | 45 +++++------ 6 files changed, 153 insertions(+), 28 deletions(-) create mode 100644 gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js create mode 100644 gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/img/picker.png create mode 100644 gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/langs/en.js create mode 100644 gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/progress.gif create mode 100644 gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/uploader.php diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js new file mode 100644 index 000000000..2046710d2 --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js @@ -0,0 +1,70 @@ +/** +* Name: editor_plugin_src.js (for pmVariablePicker tinyMCE plugin) +**/ + +(function(){ + var strPluginURL; + tinymce.create('tinymce.plugins.pmVariablePickerPlugin', { + + init: function(ed, url) + { + strPluginURL = url; // store the URL for future use.. + ed.addCommand('mcepmVariablePicker', function() { + pmVariablePicker(); + }); + ed.addButton('pmVariablePicker', { + title: 'pmVariablePicker', + label : ' @#', + cmd: 'mcepmVariablePicker', + image: url + '/img/picker.png' + }); + }, + createControl: function(n, cm) { + return null; + }, + getPluginURL: function() { + return strPluginURL; + } + }); + tinymce.PluginManager.add('pmVariablePicker', tinymce.plugins.pmVariablePickerPlugin); +})(); + +// 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.. In the rist case, we will just update the main editor window +// with the path of the uploaded file +function pmVariablePicker(field_name, url, type, win) { + var strPluginPath = tinyMCE.activeEditor.plugins.pmVariablePicker.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_pmVariablePicker_upload_path'); // get the relative upload path + var strSubstitutePath = tinyMCE.activeEditor.getParam('plugin_pmVariablePicker_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.windowManager.open({ // open the plugin popup + file : strUploaderURL, + title : 'Upload Variable', + width : 500, + height : 100, + resizable : "yes", + inline : 1, // This parameter only has an effect if you use the inlinepopups plugin! + close_previous : "no" + }, { + window : win, + input : field_name + }); + + return false; +} +// This function will get called when the uploader is done uploading the file and ready to update +// calling dialog and close the upload popup +// strReturnURL should be the string with the path to the uploaded file +function closePluginPopup(){ + tinyMCEPopup.close(); // close popup window +} + +function updateEditorContent(serializedHTML){ + tinyMCE.activeEditor.execCommand('mceInsertContent', false, serializedHTML); +} \ No newline at end of file diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/img/picker.png b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/img/picker.png new file mode 100644 index 0000000000000000000000000000000000000000..0d16423393449c9f17e7ba22f250dfcd735141d6 GIT binary patch literal 595 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkswhI zFm^kcZ3hx8D{xE)(qO#|6+TOsF)%PTc)B=-Se!mP*;>cNQKW7E%)Q#Pr*<%DAJN_z zxw~XVh@4_zhKplsiuNLbt6@UDNmu2jdWDE+DF$-1dZa8C5L~$U!;Mqf@8<@-Ia~Vu zUEJIwDxc3=7C*D^w>186-8tax#rYfS)N`u7go_#c<(%YiS6Tj{*&vgr-f81Wr882N z^-WAJj8Pgb^B^Z^3cik+f@QJTDY0D=RV2t6^U#$SGARwUwPVFHE8OK zMI3)aH&18ojrbPFC;U{t(dFyM%l~p$@%A2@(=m_dY?;dAcNwj&tB-zr%5&{5yW^Ur z?;d)bzj*q(+xp#~TYE1jubs)|?BW#O`K5Bx&a&ATu3e20d8zhii_cjVHh%uRi8IU> zzude)p`kNNvpkC-QGv0QvuH3PL77+kvY#s;W? N!PC{xWt~$(69D=V>#qO+ literal 0 HcmV?d00001 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 new file mode 100644 index 000000000..82cc06aa9 --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/langs/en.js @@ -0,0 +1,3 @@ +tinyMCE.addI18n('en.ccSimpleUploader', { + desc:"Upload File to Server" +}); diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/progress.gif b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/progress.gif new file mode 100644 index 0000000000000000000000000000000000000000..2aea68c8e3aef0278954931058f765c714048b17 GIT binary patch literal 2005 zcmZ?wbhEHboW>x)aD;*3|NsBrzkh%K{{7nbYo|P$((`Oe^|R{Ydq7mYckkY)dr@1r zZuPnsw07-Mr)y4z*Q^Y$8Md^vR99CQ7Z<0crTu3h02Kdo`?-b$J39ur8tEA@GXj+> z{$ycgXAou30ciy}gMsy5!c~uu%y}8B*5$n3SD8J%PIq zAK$z3{6+b-b$oB%rM-L4@bT@3FW)}C{Pk<*^(HO`=2@H?0t}7~%=~I9JJu_1ty{}9T9@-mc}&)dJ+q5M*IsX3%5c0*0WYf^ zeu2;X)erw$%H~HTN%T7|y7VQ(YO=R#idU;!d*7OCRd+S_CFGTtY0N(QI5hDrA0r}O zc<`CJ!Q=fFps5V`D@Zg|geIoS(8N>~nwY9X6H`rSVyX>IOm(4&sXjC@HH0Rn#?Zvn z6q=X{DqZrxrAxpAXz2nfpEq!wF-g2%xbD4;|K+v?8{BoIO7}}9pR@s%&ngcb*E+4g zF<0c!+qC@;re1N>Yd@d9GU=?_?#-8)YyPdXU)s9o-Z_0QXVk)m=9YlU9vWK0iB_Ez zB&hbKAXR52x%a`<+4klIAKZ1i7)~s?=#pVI{X%Szq^RV&8>_aNx#mee_)sSEnrU1A zmRV==W^SLbV~?-@-mQIm_MOweyPB)9skTM5K9Ie$tF^X0fOW#eo|?YN)27duIcxSD JU0{u14FIuDN~Hh* literal 0 HcmV?d00001 diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/uploader.php b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/uploader.php new file mode 100644 index 000000000..43fa98afb --- /dev/null +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/uploader.php @@ -0,0 +1,63 @@ + + Upload an Output Document + + + + + + + + + +' + .'File Name:
' + .'
' + .'' + .' ' + .''; +} +// uploads the file to the destination path, and returns a link with link path substituted for destination path +function uploadVariablePicker() +{ + $StatusMessage = ""; + $ActualFileName = ""; + $FileObject = $_REQUEST["upload_variable"]; // find data on the file + + updateEditorContent(trim($FileObject)); + closeWindow(); +} + + +function showPopUp($PopupText) +{ + echo ""; +} + +function updateEditorContent($serializedHTML) +{ + echo ""; +} + +function closeWindow() +{ + echo ' + + '; +} +?> + diff --git a/gulliver/system/class.wysiwygEditor.php b/gulliver/system/class.wysiwygEditor.php index 3892b8967..c67602643 100755 --- a/gulliver/system/class.wysiwygEditor.php +++ b/gulliver/system/class.wysiwygEditor.php @@ -109,38 +109,27 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field '; break; case 'OUTPUT_DOCUMENT': - $editorDefinition = ' + $editorDefinition = ' tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce" tinyMCE.init({ - theme : "advanced", - plugins : "fullpage, pmSimpleUploader", - mode : "specific_textareas", - editor_selector : "tmceEditor", - width : "770", - height : "305", - theme_advanced_buttons1 : "fontselect,bold,italic,underline,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,numlist,bullist,|,code,|,pmSimpleUploader", - onchange_callback: function(inst) { - if(inst.isDirty()) { - inst.save(); - } - return true; - }/*, - - theme_advanced_buttons1 : "pmSimpleUploader", - theme_advanced_buttons2 : "fontselect,bold,italic,underline,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,numlist,bullist,|,insertfile", - - handle_event_callback : function(e) { - if(this.isDirty()) { - this.save(); - } - return true; - }*/ - - }); - '; - + theme : "advanced", + plugins : "fullpage, pmSimpleUploader, pmVariablePicker", + mode : "specific_textareas", + editor_selector : "tmceEditor", + width : "770", + height : "305", + theme_advanced_buttons1 : "fontselect,bold,italic,underline,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,numlist,bullist,|,code,|,pmSimpleUploader,|,pmVariablePicker", + onchange_callback: function(inst) { + if(inst.isDirty()) { + inst.save(); + } + return true; + } + }); + '; break; + case 'DYNAFORM_TEMPLATE': $editorDefinition = '