XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
flash.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('Restricted access');
21 
23 {
24  function encode($textarea_id)
25  {
26  $config = parent::loadConfig(dirname(__FILE__));
27  $code = "<img src='{$this->image_path}/swf.gif' alt='" . _XOOPS_FORM_ALTFLASH . "' onclick='xoopsCodeFlash(\"{$textarea_id}\",\"" . htmlspecialchars(_XOOPS_FORM_ENTERFLASHURL, ENT_QUOTES) . "\",\"" . htmlspecialchars(_XOOPS_FORM_ALT_ENTERHEIGHT, ENT_QUOTES) . "\",\"" . htmlspecialchars(_XOOPS_FORM_ALT_ENTERWIDTH, ENT_QUOTES) . "\", \"" . $config['detect_dimension'] . "\");' onmouseover='style.cursor=\"hand\"'/>&nbsp;";
28  $javascript = <<<EOF
29  function xoopsCodeFlash(id, enterFlashPhrase, enterFlashHeightPhrase, enterFlashWidthPhrase, enableDimensionDetect)
30  {
31  var selection = xoopsGetSelect(id);
32  if (selection.length > 0) {
33  var text = selection;
34  } else {
35  var text = prompt(enterFlashPhrase, "");
36  }
37  var domobj = xoopsGetElementById(id);
38  if ( text.length > 0 ) {
39  var text2 = enableDimensionDetect ? "" : prompt(enterFlashWidthPhrase, "");
40  var text3 = enableDimensionDetect ? "" : prompt(enterFlashHeightPhrase, "");
41  var result = "[flash="+text2+","+text3+"]" + text + "[/flash]";
42  xoopsInsertText(domobj, result);
43  }
44  domobj.focus();
45  }
46 EOF;
47 
48  return array(
49  $code ,
50  $javascript);
51  }
52 
53  function load(&$ts)
54  {
55  $ts->patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU";
56  $ts->replacements[] = __CLASS__ . "::decode( '\\5', '\\3', '\\4' )";
57 
58  return true;
59  }
60 
61  function decode($url, $width, $height)
62  {
63  $config = parent::loadConfig(dirname(__FILE__));
64  if ((empty($width) || empty($height)) && !empty($config['detect_dimension'])) {
65  if (!$dimension = @getimagesize($url)) {
66  return "<a href='{$url}' rel='external' title=''>{$url}</a>";
67  }
68  if (!empty($width)) {
69  $height = $dimension[1] * $width / $dimension[0];
70  } else if (! empty($height)) {
71  $width = $dimension[0] * $height / $dimension[1];
72  } else {
73  list ($width, $height) = array(
74  $dimension[0] ,
75  $dimension[1]);
76  }
77  }
78 
79  $rp = "<object width='{$width}' height='{$height}' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>";
80  $rp .= "<param name='movie' value='{$url}'>";
81  $rp .= "<param name='QUALITY' value='high'>";
82  $rp .= "<PARAM NAME='bgcolor' VALUE='#FFFFFF'>";
83  $rp .= "<param name='wmode' value='transparent'>";
84  $rp .= "<embed src='{$url}' width='{$width}' height='{$height}' quality='high' bgcolor='#FFFFFF' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>";
85  $rp .= "</object>";
86  return $rp;
87  }
88 }
89 ?>