Fixed dailymotion import issues
[embedvideo/.git] / module.inc
1 <?php
2 /*
3  * Gallery - a web based photo album viewer and editor
4  * Copyright (C) 2000-2007 Bharat Mediratta
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at
9  * your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 /**
22  * The implementation of the ItemAddEmbedVideo
23  * Supports ItemAddEmbedVideo
24  *
25  * @package EmbedVideo
26  * @author Alan Pippin <apippin@pippins.net>
27  * @version $Revision: 1 $
28  */
29 class EmbedVideoModule extends GalleryModule {
30
31     function EmbedVideoModule() {
32         global $gallery;
33         $this->setId('embedvideo');
34         $this->setName($gallery->i18n('Embed Video'));
35         $this->setDescription($gallery->i18n('Add embedded videos from the web'));
36         $this->setVersion('1.1.5');
37         $this->setGroup('import', $gallery->i18n('Import'));
38         $this->setCallbacks('getSiteAdminViews');
39         $this->setRequiredCoreApi(array(7, 3));
40         $this->setRequiredModuleApi(array(3, 0));
41     }
42
43     /**
44      * @see GalleryModule::performFactoryRegistrations
45      */
46     function performFactoryRegistrations() {
47
48         $ret = GalleryCoreApi::registerFactoryImplementation(
49             'ItemAddPlugin', 'ItemAddEmbedVideo', 'ItemAddEmbedVideo',
50             'modules/embedvideo/ItemAddEmbedVideo.inc', 'embedvideo', null);
51         if ($ret) {
52             return $ret;
53         }
54
55         return null;
56     }
57
58     /**
59      * @see GalleryModule::getSiteAdminViews
60      */
61     function getSiteAdminViews() {
62         return array(null, array(array('name' => $this->translate($this->getName()),
63                                        'view' => 'embedvideo.EmbedVideoSiteAdmin')));
64     }
65
66     /**
67      * @see GalleryModule::upgrade
68      */
69     function upgrade($currentVersion) {
70        global $gallery;
71
72         list ($ret, $params) =
73             GalleryCoreApi::fetchAllPluginParameters('module', 'embedvideo');
74         if ($ret) {
75             return $ret;
76         }
77
78         if (!isset($params['embedvideodefaultVariables'])) {
79             $ret = $this->setParameter('embedvideodefaultVariables',
80                                        'height=240'.
81                                        '|width=320'.
82                                        '|useInternalFlvPlayer=true'.
83                                        '|useRemoteSize=false'.
84                                        '|youtubeShowRelated=false'.
85                                        '|watermarkVideos=true'
86                                        );
87             if ($ret) {
88                 return $ret;
89             }
90         }
91
92         if (!isset($params['embedvideooverrideVariables'])) {
93             $ret = $this->setParameter('embedvideooverrideVariables', '');
94             if ($ret) {
95                 return $ret;
96             }
97         }
98
99         return null;
100     }
101 }
102 ?>