]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/Video.php
rcs_id no longer makes sense with Subversion global version number
[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  * Copyright 2009 Reini Urban
6  *
7  * This file is part of PhpWiki.
8  *
9  * PhpWiki is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * PhpWiki is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with PhpWiki; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 /*
25  * Standard Alcatel-Lucent disclaimer for contributing to open source
26  *
27  * "The VideoPlugin ("Contribution") has not been tested and/or
28  * validated for release as or in products, combinations with products or
29  * other commercial use. Any use of the Contribution is entirely made at
30  * the user's own responsibility and the user can not rely on any features,
31  * functionalities or performances Alcatel-Lucent has attributed to the
32  * Contribution.
33  *
34  * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
35  * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
36  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
37  * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
38  * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
39  * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
40  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
41  * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
42  * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
43  * ALONE BASIS."
44  */
45
46 class WikiPlugin_Video
47 extends WikiPlugin
48 {
49     function getName() {
50         return _("Video");
51     }
52
53     function getDescription() {
54         return _("Display video in Flash");
55     }
56
57     function getDefaultArguments() {
58         return array('width'    => 460,
59                      'height'   => 320,
60                      'url'      => '',
61                      'file'     => '',
62                      'autoplay' => 'false',
63                      'image'    => ''
64                      );
65     }
66
67     function run($dbi, $argstr, &$request, $basepage) {
68
69         global $WikiTheme;
70         $args = $this->getArgs($argstr, $request);
71         extract($args);
72
73         if (! $url && ! $file) {
74             return $this->error(_("Both 'url' or 'file' parameters missing."));
75         } elseif ($url && $file) {
76             return $this->error(_("Choose only one of 'url' or 'file' parameters."));
77         } elseif ($file) {
78             $url = getUploadDataPath() . $file;
79         }
80
81         // TODO: Check HTML5 browser capabilities
82         if (string_ends_with($url, ".ogg")) {
83             return HTML::video(array('autoplay' => 'true', 'controls' => 'true', 'src' => $url),
84                                _("Your browser does not understand the HTML 5 video tag."));
85         }
86         if (!$image) $image = $url;
87         if ($autoplay != 'true' and $autoplay != 'false')
88             return $this->error(fmt("Invalid argument %s", "autoplay"));
89         if (!is_numeric($width))
90             return $this->error(fmt("Invalid argument %s", "width"));
91         if (!is_numeric($height))
92             return $this->error(fmt("Invalid argument %s", "height"));
93         if (preg_match("/'/", $url))
94             return $this->error(fmt("Invalid argument %s", "url"));
95
96         $params = array("data" => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.4.swf'),
97                         "type"              => "application/x-shockwave-flash",
98                         "width"             => $width,
99                         "height"            => $height,
100                         "allowfullscreen"   => "true",
101                         "allowscriptaccess" => "false",
102                         "flashvars"=>
103                           "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}'");
104         return ImgObject(HTML::img(array('src' => $image)), $params);
105     }
106 };
107
108 // Local Variables:
109 // mode: php
110 // tab-width: 4
111 // c-basic-offset: 4
112 // c-hanging-comment-ender-p: nil
113 // indent-tabs-mode: nil
114 // End:
115 ?>