19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
47 wysiwyg_plugin::wysiwyg_plugin($wysiwyg);
48 $this->
_add_button(
'matrixembedmovie',
'MatrixEmbedMovie',
'Embed Movie',
'false',
'53');
49 $this->_img_url = $wysiwyg->web_path.
'plugins/'.$this->
get_popup_href(
'embedded_object.gif');
63 <script type=
"text/javascript" language=
"Javascript">
65 HTMLArea.prototype._matrixEmbedMovie =
function() {
68 var sel = this._getSelection();
69 var range = this._createRange(sel);
76 var show_controls =
"0";
80 var fileprotocol =
'';
83 if (HTMLArea.is_gecko) {
84 var fragment = this._doc.createDocumentFragment();
85 var div = this._doc.createElement(
"div");
86 div.innerHTML = this.getSelectedHTML();
87 while (div.firstChild) {
88 if (div.firstChild.tagName ==
"IMG" && div.firstChild.getAttribute(
'sq_embeded') ==
"1") {
90 var embed_tag = div.firstChild;
94 fragment.appendChild(div.firstChild);
96 }
else if (HTMLArea.is_ie) {
98 if (range.item(0).tagName ==
"IMG" && range.item(0).getAttribute(
'sq_embeded') ==
"1") {
100 var embed_tag = range.item(0);
106 if (is_file && embed_tag) {
107 fileid = embed_tag.getAttribute(
'fileid');
108 if (fileid != null) {
109 fileurl =
'./?a=' + fileid;
111 fileparts = embed_tag.getAttribute(
'fileurl');
112 if (fileparts != null) {
113 if (fileparts.substring(0, 7) ==
'http://') {
114 fileprotocol =
'http://';
115 fileurl = fileparts.substring(7);
116 }
else if (fileparts.substring(0, 8) ==
'https://') {
117 fileprotocol =
'https://';
118 fileurl = fileparts.substring(8);
119 }
else if (fileparts.substring(0, 6) ==
'ftp://') {
120 fileprotocol =
'ftp://';
121 fileurl = fileparts.substring(6);
125 auto_start = embed_tag.getAttribute(
'auto_start');
126 show_controls = embed_tag.getAttribute(
'show_controls');
127 embed_loop = embed_tag.getAttribute(
'embed_loop');
130 style = embed_tag.style;
132 height = style.height;
135 if (!width) { width = embed_tag.getAttribute(
'width'); }
136 if (!height) { height = embed_tag.getAttribute(
'height'); }
139 width = parseInt(width);
140 height = parseInt(height);
143 if (!width) { width =
"" }
144 if (!height) { height =
"" }
149 if (this._inPopup ==
true) { in_popup =
'1'; }
151 editor_<?php echo $this->
wysiwyg->name?>._object =
this;
152 strPage =
"<?php echo $this->get_popup_href('embed_movie_frames.php')?>?f_fileurl=" + escape(fileurl) +
"&f_fileprotocol=" + escape(fileprotocol) +
"&f_width=" + escape(width) +
"&f_height=" + escape(height) +
"&f_auto_start=" + escape(auto_start) +
"&f_show_controls=" + escape(show_controls) +
"&f_embed_loop=" + escape(embed_loop) +
"&editor_name=" + escape(
"<?php echo $this->wysiwyg->name; ?>") +
"&in_popup=" + escape(in_popup);
154 this._popupDialog(
"matrixEmbedMovie", strPage, 780, 500,
true,
function(param) {
159 var html =
'<img sq_embeded="1" src="<?php echo $this->_img_url; ?>"';
160 html +=
' style="width: ' + param[
"f_width"] +
'px; height: ' + param[
"f_height"] +
'px; border: 2px dashed black;"';
161 html +=
' width="' + param[
"f_width"] +
'"';
162 html +=
' height="' + param[
"f_height"] +
'"';
163 if (param[
"use_external"] ==
true) {
164 html +=
' fileurl="' + param[
"external_url"] +
'"';
166 html +=
' fileid="' + param[
"f_fileid"] +
'"';
168 html +=
' auto_start="' + param[
"f_auto_start"] +
'"';
169 html +=
' show_controls="' + param[
"f_show_controls"] +
'"';
170 html +=
' embed_loop="' + param[
"f_embed_loop"] +
'"';
172 html = editor.make_absolute_urls(html);
174 if (!is_file || HTMLArea.is_gecko) {
176 editor.insertHTML(html, range);
179 embed_tag.outerHTML = html;
199 case "matrixembedmovie":
200 this._matrixEmbedMovie();
219 preg_match_all(
'|(<img[^>]+sq_embeded="1"([^>]+)?>)|i', $html, $matches);
221 foreach ($matches[1] as $match) {
224 $match = strtolower($match);
225 $match = substr($match, 4);
226 $match = substr($match, 0, -1);
227 $match = str_replace(
'src="'.$this->_img_url.
'"',
'', $match);
230 preg_match_all(
'|\s+([^=]+)="([^"]+)"|', $match, $pieces);
232 $movie_vars = Array();
233 for (reset($pieces[1]); NULL !== ($k = key($pieces[1])); next($pieces[1])) {
234 $var_name = trim($pieces[1][$k]);
235 $var_value = trim($pieces[2][$k]);
236 $movie_vars[$var_name] = $var_value;
239 if (isset($movie_vars[
'fileurl'])) {
240 $filename = $movie_vars[
'fileurl'];
241 $movie_url = $movie_vars[
'fileurl'];
242 $movie_url = $filename;
244 if (!isset($movie_vars[
'fileid']))
continue;
245 $fileid = $movie_vars[
'fileid'];
246 $file = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($fileid);
248 if (is_null($file))
continue;
249 if (!($file instanceof
File)) {
250 trigger_localised_error(
'SYS0089', E_USER_WARNING, $file->id,
'File');
254 $filename = $file->name;
255 $movie_url =
'./?a='.$fileid;
260 if (isset($movie_vars[
'style'])) {
261 $style = $movie_vars[
'style'];
262 $style_pieces = Array();
263 preg_match_all(
'|([^\s:]+):\s([^\s;]+);?|i', $style, $style_pieces);
265 $style_vars = Array();
266 for (reset($style_pieces[1]); NULL !== ($k = key($style_pieces[1])); next($style_pieces[1])) {
267 $var_name = trim($style_pieces[1][$k]);
268 $var_value = trim($style_pieces[2][$k]);
269 $style_vars[$var_name] = $var_value;
272 if (isset($style_vars[
'width'])) {
273 $width =
'width="'.str_replace(
'px',
'',$style_vars[
'width']).
'"';
275 if (isset($style_vars[
'height'])) {
276 $height =
'height="'.str_replace(
'px',
'',$style_vars[
'height']).
'"';
282 if (isset($movie_vars[
'width'])) {
283 $width =
'width="'.str_replace(
'px',
'',$movie_vars[
'width']).
'"';
286 if (empty($height)) {
287 if (isset($movie_vars[
'height'])) {
288 $height =
'height="'.str_replace(
'px',
'',$movie_vars[
'height']).
'"';
295 <sq_wysiwyg_embed_movie <?php echo $match; ?>>
297 switch (strtolower(get_file_type($filename))) {
301 if (!isset($movie_vars[
'embed_loop'])) {
302 $movie_vars[
'embed_loop'] =
'0';
304 if (!isset($movie_vars[
'show_controls'])) {
305 $movie_vars[
'show_controls'] =
'0';
308 ?><embed src=
"<?php echo $movie_url; ?>" controller=
"<?php echo ($movie_vars['show_controls']) ? 'true' : 'false'?>" cache=
"true" loop=
"<?php echo ($movie_vars['embed_loop']) ? 'true' : 'false'; ?>" <?php echo $width; ?> <?php echo $height; ?>><?php
313 ?><
object classid=
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=
"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" <?php echo $width; ?> <?php echo $height; ?>>
314 <param name=
"movie" value=
"<?php echo $movie_url; ?>">
315 <param name=
"quality" value=
"high">
316 <param name=
"scale" value=
"exactfit">
317 <embed src=
"<?php echo $movie_url; ?>" quality=
"high" pluginspage=
"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type=
"application/x-shockwave-flash" <?php echo $width; ?> <?php echo $height; ?> scale=
"exactfit"></embed>
327 if (!isset($movie_vars[
'embed_loop'])) {
328 $movie_vars[
'embed_loop'] =
'0';
330 if (!isset($movie_vars[
'show_controls'])) {
331 $movie_vars[
'show_controls'] =
'0';
333 if (!isset($movie_vars[
'auto_start'])) {
334 $movie_vars[
'auto_start'] =
'0';
336 ?><
object id=
"WinMedia" classid=
"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
337 codebase=
"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
338 <?php echo $width; ?> <?php echo $height; ?>
339 standby=
"Loading Microsoft Windows Media Player components..." type=
"application/x-oleobject">
340 <param name=
"FileName" value=
"<?php echo $movie_url; ?>">
341 <param name=
"AutoStart" value=
"<?php echo ($movie_vars['auto_start']) ? 'true' : 'false'; ?>">
342 <param name=
"ShowControls" value=
"<?php echo ($movie_vars['show_controls']) ? 'true' : 'false'; ?>">
343 <param name=
"loop" value=
"<?php echo ($movie_vars['embed_loop']) ? 'true' : 'false';?>">
344 <embed type=
"application/x-mplayer2"
345 pluginspage=
"http://www.microsoft.com/Windows/MediaPlayer/"
346 src=
"<?php echo $movie_url; ?>"
348 AutoStart=
"<?php echo ($movie_vars['auto_start']) ? 'true' : 'false'; ?>"
349 ShowControls=
"<?php echo ($movie_vars['show_controls']) ? 'true' : 'false'; ?>"
350 loop=
"<?php echo ($movie_vars['embed_loop']) ? 'true' : 'false'; ?>"
351 <?php echo $width; ?>
352 <?php echo $height; ?>
359 ?></sq_wysiwyg_embed_movie><?php
360 $new_html = ob_get_contents();
363 $html = str_replace($old_html, $new_html, $html);
370 $html_tidy->new_inline_tag(
'sq_wysiwyg_embed_movie');
387 $contents = preg_replace(
'|(<sq_wysiwyg_embed_movie([^>]*)?>)(.*?)(</sq_wysiwyg_embed_movie>)|si',
'<IMG src="'.$this->_img_url.
'" $2>', $contents);
388 $contents = preg_replace(
'|\s+|',
' ', $contents);