-
Notifications
You must be signed in to change notification settings - Fork 0
/
flash-object.php
93 lines (84 loc) · 2.72 KB
/
flash-object.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
*
* @author : Domenico Biancardi
* @email : domenico.biancardi@gmail.com
* Created : 02/04/13 - {9.44}
*/
class FlashObject
{
public $attributes = array();
public $params = array();
public $variables = array();
public $path;
public $width;
public $height;
public $id;
public static $default_alt_content = '<a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>';
function __construct($path = '#', $width = 100, $height = 100, $alt_content = '', $id = '')
{
$this->path = $path;
$this->width = $width;
$this->height = $height;
$this->alt_content = !empty($alt_content) ? $alt_content : $this->default_alt_content;
$this->id = !empty($id) ? ' id="' . $id . '"' : '';
}
function setAltContent($str)
{
$this->alt_content = $str;
}
function setVariables($arr)
{
$this->variables = $arr;
}
function setParams($arr)
{
$this->params = $arr;
}
function setAttributes($arr)
{
$this->attributes = $arr;
}
function setId($id)
{
$this->id = $id;
}
function get()
{
$attributes = '';
$params = '';
$variables = array();
foreach ($this->attributes as $key => $val) {
if ($key !== 'id') {
$attributes .= ' ' . $key . '=' . '"' . $val . '"';
}
}
foreach ($this->params as $key => $val) {
$params .= "<param name=\"{$key}\" value=\"{$val}\" />";
}
foreach ($this->variables as $key => $val) {
$variables[] = $key . '=' . urlencode($val);
}
if (count($variables)) {
$params .= "<param name=\"flashvars\" value=\"" . implode('&', $variables) . "\" />";
}
$str = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"{$this->width}\" height=\"{$this->height}\"{$this->id}{$attributes}>";
$str .= "<param name=\"movie\" value=\"{$this->path}\" />";
$str .= $params;
$str .= '<!--[if !IE]>-->';
$str .= "<object type=\"application/x-shockwave-flash\" data=\"{$this->path}\" width=\"{$this->width}\" height=\"{$this->height}\"{$attributes}>";
$str .= $params;
$str .= '<!--<![endif]-->';
$str .= $this->alt_content;
$str .= '<!--[if !IE]>-->';
$str .= '</object>';
$str .= '<!--<![endif]-->';
$str .= '</object>';
return $str;
}
function render()
{
echo $this->get();
}
}
?>