My favorites | Sign in
Project Home Downloads Issues Source
Checkout   Browse   Changes    
 
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
if ( !class_exists('swfobject') ) :
/**
* swfobject - PHP class for creating dynamic content of SWFObject V2.1
*
* @author Alex Rabe
* @package NextGEN Gallery
* @version 0.6
* @copyright GNU General Public License Version 2
* @access public
* @example http://code.google.com/p/swfobject/
*/
class swfobject {
/**
* id of the HTML element
*
* @var string
*/
var $id;
/**
* specifies the width of your SWF
*
* @var string
* @private
*/
var $width;
/**
* specifies the height of your SWF
*
* @var string
* @privat
*/
var $height;
/**
* the javascript output
*
* @var string
*/
var $js;
/**
* the replacemnt message
*
* @var string
*/
var $message = 'The <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> and <a href="http://www.mozilla.com/firefox/">a browser with Javascript support</a> are needed..';
/**
* the classname for the div element
*
* @var string
*/
var $classname = 'swfobject';
/**
* array of flashvars
*
* @var array
*/
var $flashvars;
/**
* array of nested object element params
*
* @var array
*/
var $params;
/**
* array of object's attributest
*
* @var array
*/
var $attributes;

/**
* swfobject::swfobject()
*
* @param string $swfUrl (required) specifies the URL of your SWF
* @param string $id (required) specifies the id of the HTML element (containing your alternative content) you would like to have replaced by your Flash content
* @param string $width (required) specifies the width of your SWF
* @param string $height (required) specifies the height of your SWF
* @param string $version (required) specifies the Flash player version your SWF is published for (format is: "major.minor.release")
* @param string $expressInstallSwfurl (optional) specifies the URL of your express install SWF and activates Adobe express install
* @param array $flashvars (optional) specifies your flashvars with name:value pairs
* @param array $params (optional) specifies your nested object element params with name:value pair
* @param array $attributes (optional) specifies your object's attributes with name:value pairs
* @return string the content
*/
function swfobject( $swfUrl, $id, $width, $height, $version, $expressInstallSwfurl = false, $flashvars = false, $params = false, $attributes = false ) {

global $swfCounter;

// look for a other swfobject instance
if ( !isset($swfCounter) )
$swfCounter = 1;

$this->id = $id . '_' . $swfCounter;
$this->width = $width;
$this->height = $height;

$this->flashvars = ( is_array($flashvars) ) ? $flashvars : array();
$this->params = ( is_array($params) ) ? $params : array();
$this->attributes = ( is_array($attributes) ) ? $attributes : array();

$this->embedSWF = 'swfobject.embedSWF("'. $swfUrl .'", "'. $this->id .'", "'. $width .'", "'. $height .'", "'. $version .'", '. $expressInstallSwfurl .', this.flashvars, this.params , this.attr );' . "\n";
}

function output () {

global $swfCounter;

// count up if we have more than one swfobject
$swfCounter++;

$out = "\n" . '<div class="'. $this->classname .'" id="'. $this->id .'" style="width:'.$this->width .'px; height:'. $this->height .'px;">';
$out .= "\n" . $this->message;
$out .= "\n" . '</div>';

return $out;
}

function javascript () {

//Build javascript
$this->js = "\nvar " . $this->id . " = {\n";
$this->js .= $this->add_js_parameters('params', $this->params) . ",\n";
$this->js .= $this->add_js_parameters('flashvars', $this->flashvars) . ",\n";
$this->js .= $this->add_js_parameters('attr', $this->attributes) . ",\n";
$this->js .= "\tstart : function() {" . "\n\t\t";
$this->js .= $this->embedSWF;
$this->js .= "\t}\n}\n";
$this->js .= $this->id . '.start();';

return $this->js;
}

function add_flashvars ( $key, $value, $default = '', $type = '', $prefix = '' ) {

if ( is_bool( $value ) )
$value = ( $value ) ? 'true' : 'false';
elseif ( $type == 'bool' )
$value = ( $value == '1' ) ? 'true' : 'false';

// do not add the variable if we hit the default setting
if ( $value == $default )
return;

$this->flashvars[$key] = $prefix . $value;
return;
}

function add_params ( $key, $value, $default = '', $type = '', $prefix = '' ) {

if ( is_bool( $value ) )
$value = ( $value ) ? 'true' : 'false';
elseif ( $type == 'bool' )
$value = ( $value == '1' ) ? 'true' : 'false';

// do not add the variable if we hit the default setting
if ( $value == $default )
return;

$this->params[$key] = $prefix . $value;
return;
}

function add_attributes ( $key, $value, $default = '', $type = '', $prefix = '' ) {

if ( is_bool( $value ) )
$value = ( $value ) ? 'true' : 'false';
elseif ( $type == 'bool' )
$value = ( $value == '1' ) ? 'true' : 'false';

// do not add the variable if we hit the default setting
if ( $value == $default )
return;

$this->attributes[$key] = $prefix . $value;
return;
}

function add_js_parameters( $name, $params ) {
$list = '';
if ( is_array($params) ) {
foreach ($params as $key => $value) {
if ( !empty($list) )
$list .= ",";
if (false === strrpos($key, '.') )
$list .= "\n\t\t" . $key . ' : ' . '"' . $value .'"';
else
$list .= "\n\t\t'" . $key . '\' : ' . '"' . $value .'"';
}
}
$js = "\t" . $name . ' : {' . $list . '}';
return $js;
}

}
endif;

?>

Change log

r804 by alex.cologne on Sep 7, 2010   Diff
Resync swfobject.php with wordTube
Go to: 

Older revisions

r791 by alex.cologne on Aug 29, 2010   Diff
Updated language files
Bugfix for upgrade
Bugfix for overstrech option via
custom fields
r742 by alex.cologne on May 1, 2010   Diff
Updated swfobject.php for correct
interpretation of boolean
r724 by alex.cologne on Mar 28, 2010   Diff
Bugfix for slideshow option
All revisions of this file

File info

Size: 5658 bytes, 197 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting