XOOPS  2.6.0
flash.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
25 {
30  public function encode($textarea_id)
31  {
32  $config = parent::loadConfig(__DIR__);
33  $code = "<img src='{$this->image_path}/swf.gif' alt='" . XoopsLocale::FLASH . "' onclick='xoopsCodeFlash(\"{$textarea_id}\",\"" . htmlspecialchars(XoopsLocale::FLASH_URL, ENT_QUOTES) . "\",\"" . htmlspecialchars(XoopsLocale::HEIGHT, ENT_QUOTES) . "\",\"" . htmlspecialchars(XoopsLocale::WIDTH, ENT_QUOTES) . "\", \"" . $config['detect_dimension'] . "\");' onmouseover='style.cursor=\"hand\"'/>&nbsp;";
34  $javascript = <<<EOF
35  function xoopsCodeFlash(id, enterFlashPhrase, enterFlashHeightPhrase, enterFlashWidthPhrase, enableDimensionDetect)
36  {
37  var selection = xoopsGetSelect(id);
38  if (selection.length > 0) {
39  var text = selection;
40  } else {
41  var text = prompt(enterFlashPhrase, "");
42  }
43  var domobj = xoopsGetElementById(id);
44  if ( text.length > 0 ) {
45  var text2 = enableDimensionDetect ? "" : prompt(enterFlashWidthPhrase, "");
46  var text3 = enableDimensionDetect ? "" : prompt(enterFlashHeightPhrase, "");
47  var result = "[flash="+text2+","+text3+"]" + text + "[/flash]";
48  xoopsInsertText(domobj, result);
49  }
50  domobj.focus();
51  }
52 EOF;
53 
54  return array(
56  );
57  }
58  static function myCallback($match) {
59  return self::decode( $match[5], $match[3], $match[4] );
60  }
61 
66  public function load(MyTextSanitizer &$ts)
67  {
68 // $ts->patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU";
69 // $ts->replacements[] = __CLASS__ . "::decode( '\\5', '\\3', '\\4' )";
70 
71 //mb------------------------------
72  $ts->callbackPatterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/sU";
73  $ts->callbacks[] = __CLASS__ . "::myCallback";
74 //mb------------------------------
75 
76  return true;
77  }
78 
85  public static function decode($url, $width, $height)
86  {
87  $config = parent::loadConfig(__DIR__);
88  if ((empty($width) || empty($height)) && !empty($config['detect_dimension'])) {
89  if (!$dimension = @getimagesize($url)) {
90  return "<a href='{$url}' rel='external' title=''>{$url}</a>";
91  }
92  if (!empty($width)) {
93  $height = $dimension[1] * $width / $dimension[0];
94  } else {
95  if (!empty($height)) {
96  $width = $dimension[0] * $height / $dimension[1];
97  } else {
98  list ($width, $height) = array(
99  $dimension[0], $dimension[1]
100  );
101  }
102  }
103  }
104 
105  $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'>";
106  $rp .= "<param name='movie' value='{$url}'>";
107  $rp .= "<param name='QUALITY' value='high'>";
108  $rp .= "<PARAM NAME='bgcolor' VALUE='#FFFFFF'>";
109  $rp .= "<param name='wmode' value='transparent'>";
110  $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>";
111  $rp .= "</object>";
112  return $rp;
113  }
114 }
static decode($url, $width, $height)
Definition: flash.php:85
encode($textarea_id)
Definition: flash.php:30
static myCallback($match)
Definition: flash.php:58
load(MyTextSanitizer &$ts)
Definition: flash.php:66
$height
$url
Definition: register.php:72
const FLASH_URL
Definition: en_US.php:393
$width
const HEIGHT
Definition: en_US.php:459
$code
Definition: lostpass.php:48