[ Index ] |
|
Code source de PHP NUKE 7.9 |
1 /* Import plugin specific language pack */ 2 tinyMCE.importPluginLanguagePack('flash', 'albanian,arabic,brazilian,catala,chinese,czech,danish,dutch,english,euskara,finnish,french,galego,german,greek,hungarian,icelandic,indonesian,italian,macedonian,norwegian,polish,portuguese,romanian,russian,slovak,slovenian,spanish,swedish,thai,turkish,ukrainian,vietnamese'); 3 4 function TinyMCE_flash_getControlHTML(control_name) { 5 switch (control_name) { 6 case "flash": 7 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\');" />'; 8 } 9 10 return ""; 11 } 12 13 function TinyMCE_flash_parseAttributes(attribute_string) { 14 var attributeName = ""; 15 var attributeValue = ""; 16 var withInName; 17 var withInValue; 18 var attributes = new Array(); 19 var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); 20 21 if (attribute_string == null || attribute_string.length < 2) 22 return null; 23 24 withInName = withInValue = false; 25 26 for (var i=0; i<attribute_string.length; i++) { 27 var chr = attribute_string.charAt(i); 28 29 if ((chr == '"' || chr == "'") && !withInValue) 30 withInValue = true; 31 else if ((chr == '"' || chr == "'") && withInValue) { 32 withInValue = false; 33 34 var pos = attributeName.lastIndexOf(' '); 35 if (pos != -1) 36 attributeName = attributeName.substring(pos+1); 37 38 attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase(); 39 40 attributeName = ""; 41 attributeValue = ""; 42 } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue) 43 withInName = true; 44 45 if (chr == '=' && withInName) 46 withInName = false; 47 48 if (withInName) 49 attributeName += chr; 50 51 if (withInValue) 52 attributeValue += chr; 53 } 54 55 return attributes; 56 } 57 58 function TinyMCE_flash_execCommand(editor_id, element, command, user_interface, value) { 59 function getAttrib(elm, name) { 60 return elm.getAttribute(name) ? elm.getAttribute(name) : ""; 61 } 62 63 // Handle commands 64 switch (command) { 65 case "mceFlash": 66 var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert"; 67 var template = new Array(); 68 var inst = tinyMCE.getInstanceById(editor_id); 69 var focusElm = inst.getFocusElement(); 70 71 template['file'] = '../../plugins/flash/flash.htm'; // Relative to theme 72 template['width'] = 400; 73 template['height'] = 195; 74 75 // Is selection a image 76 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { 77 name = getAttrib(focusElm, 'name'); 78 79 if (name != 'mce_plugin_flash') // Not a Flash 80 return true; 81 82 // Get rest of Flash items 83 swffile = getAttrib(focusElm, 'title'); 84 //swffile = eval(tinyMCE.settings['urlconvertor_callback'] + "(swffile, null, true);"); 85 swfwidth = getAttrib(focusElm, 'width'); 86 swfheight = getAttrib(focusElm, 'height'); 87 action = "update"; 88 } 89 90 tinyMCE.openWindow(template, {editor_id : editor_id, swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action}); 91 return true; 92 } 93 94 // Pass to next handler in chain 95 return false; 96 } 97 98 function TinyMCE_flash_cleanup(type, content) { 99 switch (type) { 100 case "insert_to_editor": 101 var startPos = 0; 102 var embedList = new Array(); 103 104 // Fix the embed and object elements 105 content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed'); 106 content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>'); 107 content = content.replace(new RegExp('<[ ]*object','gi'),'<object'); 108 content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>'); 109 110 // Parse all embed tags 111 while ((startPos = content.indexOf('<embed', startPos+1)) != -1) { 112 var endPos = content.indexOf('>', startPos); 113 var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos)); 114 embedList[embedList.length] = attribs; 115 } 116 117 // Parse all object tags and replace them with images from the embed data 118 var index = 0; 119 while ((startPos = content.indexOf('<object', startPos)) != -1) { 120 var endPos = content.indexOf('>', startPos); 121 122 // Find end of embed 123 endPos = content.indexOf('/>', endPos); 124 if (endPos == -1) { 125 endPos = content.indexOf('</object>', endPos); 126 endPos += 8; 127 } else 128 endPos += 2; 129 130 if (index >= embedList.length) 131 break; 132 133 var attribs = embedList[index]; 134 135 // Insert image 136 var contentAfter = content.substring(endPos+1); 137 content = content.substring(0, startPos); 138 content += '<img name="mce_plugin_flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"'; 139 content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"'; 140 content += ' alt="' + attribs["src"] + '" class="mce_plugin_flash" />' + content.substring(endPos+1); 141 content += contentAfter; 142 index++; 143 144 startPos++; 145 } 146 break; 147 148 case "get_from_editor": 149 // Parse all img tags and replace them with object+embed 150 var startPos = 0; 151 while ((startPos = content.indexOf('<img', startPos)) != -1) { 152 var endPos = content.indexOf('/>', startPos); 153 var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos)); 154 155 // Is not flash 156 if (attribs['name'] != "mce_plugin_flash") 157 break; 158 159 endPos += 2; 160 161 var embedHTML = ''; 162 163 // Insert object + embed 164 embedHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; 165 embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"'; 166 embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">'; 167 embedHTML += '<param name="movie" value="' + attribs["title"] + '" />'; 168 embedHTML += '<param name="quality" value="high" />'; 169 embedHTML += '<param name="menu" value="false" />'; 170 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>'; 171 172 /* 173 <object 174 classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" 175 codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="360" height="305" hspace="0" vspace="0"> 176 <param name="src" value="<?=$_REQUEST['url']?>"> 177 <param name="autoplay" value="true"> 178 <param name="controller" value="true"> 179 <embed src="<?=$_REQUEST['url']?>" width="360" height="305" hspace="0" vspace="0" 180 autoplay="true" controller="true" 181 pluginspage="http://www.apple.com/quicktime/download/"> 182 </embed></object> 183 184 */ 185 186 content = content.substring(0, startPos) + embedHTML + content.substring(endPos+1); 187 188 startPos++; 189 } 190 break; 191 } 192 193 // Pass through to next handler in chain 194 return content; 195 } 196 197 function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { 198 function getAttrib(elm, name) { 199 return elm.getAttribute(name) ? elm.getAttribute(name) : ""; 200 } 201 202 tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal'); 203 204 if (node == null) 205 return; 206 207 do { 208 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_flash') == 0) 209 tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected'); 210 } while ((node = node.parentNode)); 211 212 return true; 213 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |