]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/Video.php
getName should not translate
[SourceForge/phpwiki.git] / lib / plugin / Video.php
1 <?php
2
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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 getDescription()
49     {
50         return _("Display video in Flash or HTML5.");
51     }
52
53     function getDefaultArguments()
54     {
55         return array('width' => 460,
56             'height' => 320,
57             'url' => '',
58             'file' => '',
59             'autoplay' => 'false'
60         );
61     }
62
63     function run($dbi, $argstr, &$request, $basepage)
64     {
65
66         global $WikiTheme;
67         $args = $this->getArgs($argstr, $request);
68         extract($args);
69
70         if (!$url && !$file) {
71             return $this->error(_("Both 'url' or 'file' parameters missing."));
72         } elseif ($url && $file) {
73             return $this->error(_("Choose only one of 'url' or 'file' parameters."));
74         } elseif ($file) {
75             // $url = SERVER_URL . getUploadDataPath() . '/' . $file;
76             $url = getUploadDataPath() . '/' . $file;
77         }
78
79         if (string_ends_with($url, ".ogg")) {
80             return HTML::video(array('autoplay' => 'true', 'controls' => 'true', 'src' => $url),
81                 _("Your browser does not understand the HTML 5 video tag."));
82         }
83
84         $html = HTML();
85
86         if (isBrowserIE()) {
87             $object = HTML::object(array('id' => 'flowplayer',
88                 'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
89                 'width' => $width,
90                 'height' => $height));
91
92             $param = HTML::param(array('name' => 'movie',
93                 'value' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.2.4.swf')));
94             $object->pushContent($param);
95
96             $param = HTML::param(array('name' => "allowfullscreen",
97                 'value' => "true"));
98             $object->pushContent($param);
99
100             $param = HTML::param(array('name' => "allowscriptaccess",
101                 'value' => "false"));
102             $object->pushContent($param);
103
104             $flashvars = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}";
105
106             $param = HTML::param(array('name' => 'flashvars',
107                 'value' => $flashvars));
108             $object->pushContent($param);
109
110             $embed = HTML::embed(array('type' => 'application/x-shockwave-flash',
111                 'width' => $width,
112                 'height' => $height,
113                 'src' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.2.4.swf'),
114                 'flashvars' => $flashvars));
115             $object->pushContent($embed);
116
117             $html->pushContent($object);
118
119         } else {
120             $object = HTML::object(array('data' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.2.4.swf'),
121                 'type' => "application/x-shockwave-flash",
122                 'width' => $width,
123                 'height' => $height));
124
125             $param = HTML::param(array('name' => "allowfullscreen",
126                 'value' => "true"));
127             $object->pushContent($param);
128
129             $param = HTML::param(array('name' => "allowscriptaccess",
130                 'value' => "false"));
131             $object->pushContent($param);
132
133             $value = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}";
134             $param = HTML::param(array('name' => "flashvars",
135                 'value' => $value));
136             $object->pushContent($param);
137
138             $html->pushContent($object);
139         }
140         return $html;
141     }
142 }
143
144 // Local Variables:
145 // mode: php
146 // tab-width: 8
147 // c-basic-offset: 4
148 // c-hanging-comment-ender-p: nil
149 // indent-tabs-mode: nil
150 // End: