[Phpcms-plugins-cvs] admin4phpCMS/modules/phpcms-content/wysiwyg/tiny_mce/plugins/flash editor_plugi
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-05-26 15:55:44
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/phpcms-content/wysiwyg/tiny_mce/plugins/flash In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290/modules/phpcms-content/wysiwyg/tiny_mce/plugins/flash Added Files: editor_plugin.js flash.htm readme.txt flash.css editor_plugin_src.js Log Message: beginning of phpcms-content and filemanager --- NEW FILE: flash.css --- .mce_plugin_flash { border: 1px dotted #cc0000; background-image: url(images/flash.gif); background-position: center; background-repeat: no-repeat; background-color: #ffffcc; } --- NEW FILE: editor_plugin.js --- /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('flash','en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl');function TinyMCE_flash_initInstance(inst){if(!tinyMCE.settings['flash_skip_plugin_css'])tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/flash/flash.css");}function TinyMCE_flash_getControlHTML(control_name){switch(control_name){case "flash":return '<img id="{$editor_id}_flash" src="{$pluginurl}/images/flash.gif" title="{$lang_insert_flash}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');" />';}return "";}function TinyMCE_flash_parseAttributes(attribute_string){var attributeName="";var attributeValue="";var withInName;var withInValue;var attributes=new Array();var whiteSpaceRegExp=new RegExp('^[ \n\r\t]+','g');if(attribute_string==null||attribute_string.length<2)return null;withInName=withInValue=false;for(var i=0;i<attribute_string.length;i++){var chr=attribute_string.charAt(i);if((chr=='"'||chr=="'")&&!withInValue)withInValue=true;else if((chr=='"'||chr=="'")&&withInValue){withInValue=false;var pos=attributeName.lastIndexOf(' ');if(pos!=-1)attributeName=attributeName.substring(pos+1);attributes[attributeName.toLowerCase()]=attributeValue.substring(1).toLowerCase();attributeName="";attributeValue="";}else if(!whiteSpaceRegExp.test(chr)&&!withInName&&!withInValue)withInName=true;if(chr=='='&&withInName)withInName=false;if(withInName)attributeName+=chr;if(withInValue)attributeValue+=chr;}return attributes;}function TinyMCE_flash_execCommand(editor_id,element,command,user_interface,value){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}switch(command){case "mceFlash":var name="",swffile="",swfwidth="",swfheight="",action="insert";var template=new Array();var inst=tinyMCE.getInstanceById(editor_id);var focusElm=inst.getFocusElement();template['file']='../../plugins/flash/flash.htm';template['width']=400;template['height']=195;if(focusElm!=null&&focusElm.nodeName.toLowerCase()=="img"){name=getAttrib(focusElm,'name');if(name!='mce_plugin_flash')return true;swffile=getAttrib(focusElm,'title');swfwidth=getAttrib(focusElm,'width');swfheight=getAttrib(focusElm,'height');action="update";}tinyMCE.openWindow(template,{editor_id:editor_id,swffile:swffile,swfwidth:swfwidth,swfheight:swfheight,action:action});return true;}return false;}function TinyMCE_flash_cleanup(type,content){switch(type){case "insert_to_editor":var startPos=0;var embedList=new Array();content=content.replace(new RegExp('<[ ]*embed','gi'),'<embed');content=content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');content=content.replace(new RegExp('<[ ]*object','gi'),'<object');content=content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');while((startPos=content.indexOf('<embed',startPos+1))!=-1){var endPos=content.indexOf('>',startPos);var attribs=TinyMCE_flash_parseAttributes(content.substring(startPos+6,endPos));embedList[embedList.length]=attribs;}var index=0;while((startPos=content.indexOf('<object',startPos))!=-1){if(index>=embedList.length)break;var attribs=embedList[index];endPos=content.indexOf('</object>',startPos);endPos+=9;var contentAfter=content.substring(endPos);content=content.substring(0,startPos);content+='<img name="mce_plugin_flash" width="'+attribs["width"]+'" height="'+attribs["height"]+'"';content+=' src="'+(tinyMCE.getParam("theme_href")+'/images/spacer.gif')+'" title="'+attribs["src"]+'"';content+=' alt="'+attribs["src"]+'" class="mce_plugin_flash" />'+content.substring(endPos);content+=contentAfter;index++;startPos++;}break;case "get_from_editor":var startPos=-1;while((startPos=content.indexOf('<img',startPos+1))!=-1){var endPos=content.indexOf('/>',startPos);var attribs=TinyMCE_flash_parseAttributes(content.substring(startPos+4,endPos));if(attribs['name']!="mce_plugin_flash")continue;endPos+=2;var embedHTML='';embedHTML+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';embedHTML+=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';embedHTML+=' width="'+attribs["width"]+'" height="'+attribs["height"]+'">';embedHTML+='<param name="movie" value="'+attribs["title"]+'" />';embedHTML+='<param name="quality" value="high" />';embedHTML+='<param name="menu" value="false" />';embedHTML+='<embed src="'+attribs["title"]+'" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+attribs["width"]+'" height="'+attribs["height"]+'"></embed></object>';chunkBefore=content.substring(0,startPos);chunkAfter=content.substring(endPos);content=chunkBefore+embedHTML+chunkAfter;}break;}return content;}function TinyMCE_flash_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}tinyMCE.switchClassSticky(editor_id+'_flash','mceButtonNormal');if(node==null)return;do{if(node.nodeName.toLowerCase()=="img"&&getAttrib(node,'name').indexOf('mce_plugin_flash')==0)tinyMCE.switchClassSticky(editor_id+'_flash','mceButtonSelected');}while((node=node.parentNode));return true;} --- NEW FILE: editor_plugin_src.js --- /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('flash', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl'); function TinyMCE_flash_initInstance(inst) { if (!tinyMCE.settings['flash_skip_plugin_css']) tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/flash/flash.css"); } function TinyMCE_flash_getControlHTML(control_name) { switch (control_name) { case "flash": return '<img id="{$editor_id}_flash" src="{$pluginurl}/images/flash.gif" title="{$lang_insert_flash}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');" />'; } return ""; } function TinyMCE_flash_parseAttributes(attribute_string) { var attributeName = ""; var attributeValue = ""; var withInName; var withInValue; var attributes = new Array(); var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); if (attribute_string == null || attribute_string.length < 2) return null; withInName = withInValue = false; for (var i=0; i<attribute_string.length; i++) { var chr = attribute_string.charAt(i); if ((chr == '"' || chr == "'") && !withInValue) withInValue = true; else if ((chr == '"' || chr == "'") && withInValue) { withInValue = false; var pos = attributeName.lastIndexOf(' '); if (pos != -1) attributeName = attributeName.substring(pos+1); attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase(); attributeName = ""; attributeValue = ""; } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue) withInName = true; if (chr == '=' && withInName) withInName = false; if (withInName) attributeName += chr; if (withInValue) attributeValue += chr; } return attributes; } function TinyMCE_flash_execCommand(editor_id, element, command, user_interface, value) { function getAttrib(elm, name) { return elm.getAttribute(name) ? elm.getAttribute(name) : ""; } // Handle commands switch (command) { case "mceFlash": var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert"; var template = new Array(); var inst = tinyMCE.getInstanceById(editor_id); var focusElm = inst.getFocusElement(); template['file'] = '../../plugins/flash/flash.htm'; // Relative to theme template['width'] = 400; template['height'] = 195; // Is selection a image if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { name = getAttrib(focusElm, 'name'); if (name != 'mce_plugin_flash') // Not a Flash return true; // Get rest of Flash items swffile = getAttrib(focusElm, 'title'); //swffile = eval(tinyMCE.settings['urlconvertor_callback'] + "(swffile, null, true);"); swfwidth = getAttrib(focusElm, 'width'); swfheight = getAttrib(focusElm, 'height'); action = "update"; } tinyMCE.openWindow(template, {editor_id : editor_id, swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action}); return true; } // Pass to next handler in chain return false; } function TinyMCE_flash_cleanup(type, content) { switch (type) { case "insert_to_editor": var startPos = 0; var embedList = new Array(); // Fix the embed and object elements content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed'); content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>'); content = content.replace(new RegExp('<[ ]*object','gi'),'<object'); content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>'); // Parse all embed tags while ((startPos = content.indexOf('<embed', startPos+1)) != -1) { var endPos = content.indexOf('>', startPos); var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos)); embedList[embedList.length] = attribs; } // Parse all object tags and replace them with images from the embed data var index = 0; while ((startPos = content.indexOf('<object', startPos)) != -1) { if (index >= embedList.length) break; var attribs = embedList[index]; // Find end of object endPos = content.indexOf('</object>', startPos); endPos += 9; // Insert image var contentAfter = content.substring(endPos); content = content.substring(0, startPos); content += '<img name="mce_plugin_flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"'; content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"'; content += ' alt="' + attribs["src"] + '" class="mce_plugin_flash" />' + content.substring(endPos); content += contentAfter; index++; startPos++; } break; case "get_from_editor": // Parse all img tags and replace them with object+embed var startPos = -1; while ((startPos = content.indexOf('<img', startPos+1)) != -1) { var endPos = content.indexOf('/>', startPos); var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos)); // Is not flash, skip it if (attribs['name'] != "mce_plugin_flash") continue; endPos += 2; var embedHTML = ''; // Insert object + embed embedHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"'; embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">'; embedHTML += '<param name="movie" value="' + attribs["title"] + '" />'; embedHTML += '<param name="quality" value="high" />'; embedHTML += '<param name="menu" value="false" />'; embedHTML += '<embed src="' + attribs["title"] + '" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"></embed></object>'; // Insert embed/object chunk chunkBefore = content.substring(0, startPos); chunkAfter = content.substring(endPos); content = chunkBefore + embedHTML + chunkAfter; } break; } // Pass through to next handler in chain return content; } function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { function getAttrib(elm, name) { return elm.getAttribute(name) ? elm.getAttribute(name) : ""; } tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal'); if (node == null) return; do { if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_flash') == 0) tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected'); } while ((node = node.parentNode)); return true; } --- NEW FILE: flash.htm --- <html> <head> <title>{$lang_insert_flash}</title> <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> <script language="javascript"> var url = tinyMCE.getParam("flash_external_list_url"); if (url != null) document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + tinyMCE.documentBasePath + "/" + url + '"></sc'+'ript>'); </script> <script language="javascript" type="text/javascript"> <!-- function init() { // modified 2004-11-10 by Michael Keck (me...@mi...) // supporting onclick event to open pop windows var formObj = document.forms[0]; var swffile = tinyMCE.getWindowArg('swffile'); var swfwidth = '' + tinyMCE.getWindowArg('swfwidth'); var swfheight = '' + tinyMCE.getWindowArg('swfheight'); if (swfwidth.indexOf('%')!=-1) { formObj.width2.value = "%"; formObj.width.value = swfwidth.substring(0,swfwidth.length-1); } else { formObj.width2.value = "px"; formObj.width.value = swfwidth; } if (swfheight.indexOf('%')!=-1) { formObj.height2.value = "%"; formObj.height.value = swfheight.substring(0,swfheight.length-1); } else { formObj.height2.value = "px"; formObj.height.value = swfheight; } formObj.file.value = swffile; formObj.insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); // Handle file browser if (tinyMCE.getParam("file_browser_callback") != null) { document.getElementById('file').style.width = '230px'; var html = ''; html += '<img id="browserBtn" src="../../themes/advanced/images/browse.gif"'; html += ' onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');"'; html += ' onmouseout="tinyMCE.restoreClass(this);"'; html += ' onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');"'; html += ' onclick="javascript:tinyMCE.openFileBrowser(\'file\',document.forms[0].file.value,\'flash\',window);"'; html += ' width="20" height="18" border="0" title="' + tinyMCE.getLang('lang_browse') + '"'; html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" />'; document.getElementById('browser').innerHTML = html; } // Auto select flash in list if (typeof(tinyMCEFlashList) != "undefined" && tinyMCEFlashList.length > 0) { for (var i=0; i<formObj.link_list.length; i++) { if (formObj.link_list.options[i].value == tinyMCE.getWindowArg('swffile')) formObj.link_list.options[i].selected = true; } } window.focus(); } function insertFlash() { var formObj = document.forms[0]; if (window.opener) { var html = ''; var file = formObj.file.value; var width = formObj.width.value; var height = formObj.height.value; if (formObj.width2.value=='%') { width = width + '%'; } if (formObj.height2.value=='%') { height = height + '%'; } if (width == "") width = 100; if (height == "") height = 100; html += '' + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ' + 'width="' + width + '" height="' + height + '" ' + 'border="0" alt="' + file + '" title="' + file + '" class="mce_plugin_flash" name="mce_plugin_flash" />'; tinyMCE.execCommand("mceInsertContent",true,html); top.close(); } } function cancelAction() { top.close(); } //--> </script> <style type="text/css"> <!-- input.radio { border: 1px none #000000; background-color: transparent; vertical-align: middle; } --> </style> </head> <body onload="init();"> <form onsubmit="insertFlash();return false;"> <table border="0" cellpadding="0" cellspacing="4" width="100%"> <tr> <td class="title">{$lang_insert_flash}</td> </tr> <tr> <td><hr size="1" noshade="noshade" /></td> </tr> <tr> <td align="center" valign="middle"><table border="0" cellpadding="4" cellspacing="0"> <tr> <td align="right">{$lang_insert_flash_file}:</td> <td nowrap="nowrap"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><input name="file" type="text" id="file" value="" onfocus="this.select();" style="width: 250px; vertical-align: middle;" /></td> <td id="browser"></td> </tr> </table> </td> </tr> <!-- Link list --> <script language="javascript"> if (typeof(tinyMCEFlashList) != "undefined" && tinyMCEFlashList.length > 0) { var html = ""; html += '<tr><td align="right">{$lang_insert_flash_list}:</td>'; html += '<td><select name="link_list" style="width: 250px" onchange="this.form.file.value=this.options[this.selectedIndex].value;">'; html += '<option value="">---</option>'; for (var i=0; i<tinyMCEFlashList.length; i++) html += '<option value="' + tinyMCEFlashList[i][1] + '">' + tinyMCEFlashList[i][0] + '</option>'; html += '</select></td></tr>'; document.write(html); } </script> <!-- /Link list --> <tr> <td align="right">{$lang_insert_flash_size}:</td> <td nowrap="nowrap"> <input name="width" type="text" id="width" value="" onfocus="this.select();" style="width: 50px; vertical-align: middle;" /> <select name="width2" id="width2" style="width: 50px; vertical-align: middle;"> <option value="">px</option> <option value="%">%</option> </select> x <input name="height" type="text" id="height" value="" onfocus="this.select();" style="width: 50px; vertical-align: middle;" /> <select name="height2" id="height2" style="width: 50px; vertical-align: middle;"> <option value="">px</option> <option value="%">%</option> </select> </td> </tr> </table></td> <tr> <td><hr size="1" noshade="noshade" /></td> </tr> <tr> <td nowrap="nowrap" align="left"> <input style="float:left" type="button" name="insert" value="{$lang_insert}" onclick="insertFlash();" id="insert" /><input style="float:right" type="button" name="cancel" value="{$lang_cancel}" onclick="cancelAction();" id="cancel" /> </td> </tr> </table> </form> </body> </html> --- NEW FILE: readme.txt --- FLASH plugin for TinyMCE ----------------------------- About: This is the INSERT FLASH Dialog contributed by Michael Keck. This one supports popup windows and targets. Note: The placeholder for Flash is called 'mce_plugin_flash' and needs a class 'mce_plugin_flash' in the 'css_-style'. Do not name another image 'name="mce_plugin_flash"! Installation instructions: * Copy the flash directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). * Add plugin to TinyMCE plugin option list example: plugins : "flash". * Add this "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]" to extended_valid_elements option. Initialization example: tinyMCE.init({ theme : "advanced", mode : "textareas", plugins : "flash", extended_valid_elements : "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]" flash_external_list_url : "example_flash_list.js" // Optional URL to a list of Flash movies }); ---------------------------------------------------------------- ADDITIONAL NOTE: The flash plugin has been heavily modified (the original is editor_plugin_original.js) since the original did not play nicely with html content that already contained existing flash tags and in fact stripped out the object tags for existing flash html. The rewrite corrects this as well attempts to preserve the existing flash tags where possible. The tinyMCE.init call should be be something like: Initialization example: tinyMCE.init({ theme : "advanced", mode : "textareas", plugins : "flash", extended_valid_elements : "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|obj|param|embed]" }); Note the extra obj,param,embed attributes for the img tag. These attributes are used to serialize data from existing flash tags so that they can be properly restored. Editing a flash tag with the plugin will cause this information to be lost (sorry !) but still produces a working flash nevertheless. |