]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/Video.php
Specific code for Internet Explorer
[SourceForge/phpwiki.git] / lib / plugin / Video.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /*
4  * Copyright 2009 Roger Guignard and Marc-Etienne Vargenau, Alcatel-Lucent
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 /*
24  * Standard Alcatel-Lucent disclaimer for contributing to open source
25  *
26  * "The VideoPlugin ("Contribution") has not been tested and/or
27  * validated for release as or in products, combinations with products or
28  * other commercial use. Any use of the Contribution is entirely made at
29  * the user's own responsibility and the user can not rely on any features,
30  * functionalities or performances Alcatel-Lucent has attributed to the
31  * Contribution.
32  *
33  * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34  * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36  * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37  * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38  * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40  * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41  * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
42  * ALONE BASIS."
43  */
44
45 class WikiPlugin_Video
46 extends WikiPlugin
47 {
48     function getName() {
49         return _("Video");
50     }
51
52     function getDescription() {
53         return _("Display video in Flash");
54     }
55
56     function getVersion() {
57         return preg_replace("/[Revision: $]/", '',
58                             "\$Revision$");
59     }
60
61     function getDefaultArguments() {
62         return array('width'  => 460,
63                      'height' => 320,
64                      'url' => '',
65                      'file' => '',
66                      'autoplay' => 'false'
67                      );
68     }
69
70     function run($dbi, $argstr, &$request, $basepage) {
71
72         global $WikiTheme;
73         $args = $this->getArgs($argstr, $request);
74         extract($args);
75
76         if (! $url && ! $file) {
77             return $this->error(_("Both 'url' or 'file' parameters missing."));
78         } elseif ($url && $file) {
79             return $this->error(_("Choose only one of 'url' or 'page' parameters."));
80         } elseif ($file) {
81             // $url = SERVER_URL . getUploadDataPath() . '/' . $file;
82             $url = getUploadDataPath() . '/' . $file;
83         }
84
85         if (string_ends_with($url, ".ogg")) {
86             return HTML::video(array('autoplay' => 'true', 'controls' => 'true', 'src' => $url),
87                                _("Your browser does not understand the HTML 5 video tag."));
88         }
89
90         $html = HTML();
91
92         if (isBrowserIE()) {
93             $object = HTML::object(array('id' => 'flowplayer',
94                                          'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
95                                          'width' => $width,
96                                          'height' => $height));
97
98             $param = HTML::param(array('name' => 'movie',
99                                        'value' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf')));
100             $object->pushContent($param);
101
102             $param = HTML::param(array('name' => "allowfullscreen",
103                                        'value' => "true"));
104             $object->pushContent($param);
105
106             $param = HTML::param(array('name' => "allowscriptaccess",
107                                        'value' => "false"));
108             $object->pushContent($param);
109
110             $flashvars = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}";
111
112             $param = HTML::param(array('name' => 'flashvars',
113                                        'value' => $flashvars));
114             $object->pushContent($param);
115
116             $embed = HTML::embed(array('type' => 'application/x-shockwave-flash',
117                                        'width' => $width,
118                                        'height' => $height,
119                                        'src' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf'),
120                                        'flashvars' => $flashvars));
121             $object->pushContent($embed);
122
123             $html->pushContent($object);
124
125         } else {
126             $object = HTML::object(array('data' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf'),
127                                          'type' => "application/x-shockwave-flash",
128                                          'width' => $width,
129                                          'height' => $height));
130
131             $param = HTML::param(array('name' => "allowfullscreen",
132                                        'value' => "true"));
133             $object->pushContent($param);
134
135             $param = HTML::param(array('name' => "allowscriptaccess",
136                                        'value' => "false"));
137             $object->pushContent($param);
138
139             $value = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}";
140             $param = HTML::param(array('name' => "flashvars",
141                                        'value' => $value));
142             $object->pushContent($param);
143
144             $html->pushContent($object);
145         }
146         return $html;
147     }
148 };
149
150 // Local Variables:
151 // mode: php
152 // tab-width: 4
153 // c-basic-offset: 4
154 // c-hanging-comment-ender-p: nil
155 // indent-tabs-mode: nil
156 // End:
157 ?>