~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to modules/getid3/module.inc

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: module.inc,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
 
7
 *
 
8
 * This program 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 (at
 
11
 * your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 
21
 */
 
22
/**
 
23
 * @version $Revision: 1.4 $ $Date: 2006/03/22 03:52:31 $
 
24
 * @package Getid3
 
25
 * @author Don Willingham <donwillingham@users.sf.net>
 
26
 */
 
27
 
 
28
/**
 
29
 * getID3() ID3 metadata Module
 
30
 *
 
31
 * This module provides the getID3 metadata toolkit for Gallery
 
32
 *
 
33
 * @package Getid3
 
34
 */
 
35
class Getid3Module extends GalleryModule {
 
36
 
 
37
    function Getid3Module() {
 
38
        global $gallery;
 
39
 
 
40
        $this->setId('getid3');
 
41
        $this->setName($gallery->i18n('Getid3'));
 
42
        $this->setDescription($gallery->i18n('A toolkit for getting id3 tag information'));
 
43
        $this->setVersion('1.0.0'); /* Update upgrade() function below too */
 
44
        $this->setGroup('data', $gallery->i18n('Extra Data'));
 
45
        $this->setCallbacks('getSiteAdminViews');
 
46
        $this->setRequiredCoreApi(array(7, 1));
 
47
        $this->setRequiredModuleApi(array(3, 0));
 
48
    }
 
49
 
 
50
    /**
 
51
     * @see GalleryModule::upgrade()
 
52
     */
 
53
    function upgrade($currentVersion) {
 
54
        global $gallery;
 
55
 
 
56
        if (!isset($currentVersion)) {
 
57
            /* Initial install */
 
58
            GalleryCoreApi::requireOnce('modules/getid3/classes/Getid3Helper.class');
 
59
            $ret = Getid3Helper::setDefaultProperties(GETID3_SUMMARY);
 
60
            if ($ret) {
 
61
                return $ret->wrap(__FILE__, __LINE__);
 
62
            }
 
63
 
 
64
            $ret = Getid3Helper::setDefaultProperties(GETID3_DETAILED);
 
65
            if ($ret) {
 
66
                return $ret->wrap(__FILE__, __LINE__);
 
67
            }
 
68
        } else {
 
69
            switch ($currentVersion) {
 
70
            case '0.0.1':
 
71
            case '0.9.0':
 
72
            case '0.9.1':
 
73
 
 
74
            case 'end of upgrade path':
 
75
                break;
 
76
 
 
77
            default:
 
78
                return GalleryCoreApi::error(ERROR_BAD_PLUGIN, __FILE__, __LINE__,
 
79
                                             sprintf('Unknown module version %s', $currentVersion));
 
80
            }
 
81
        }
 
82
 
 
83
        return null;
 
84
    }
 
85
 
 
86
    /**
 
87
     * @see GalleryModule::performFactoryRegistrations()
 
88
     */
 
89
    function performFactoryRegistrations() {
 
90
        /* Register our graphics class with the factory */
 
91
        $ret = GalleryCoreApi::registerFactoryImplementation(
 
92
            'Getid3Interface_1_0', 'Getid3Extractor', 'Getid3',
 
93
            'modules/getid3/classes/Getid3Extractor.class', 'getid3', null);
 
94
        if ($ret) {
 
95
            return $ret->wrap(__FILE__, __LINE__);
 
96
        }
 
97
 
 
98
        $ret = GalleryCoreApi::registerFactoryImplementation(
 
99
            'GalleryToolkit', 'Getid3Toolkit', 'Getid3',
 
100
            'modules/getid3/classes/Getid3Toolkit.class', 'getid3', null);
 
101
        if ($ret) {
 
102
            return $ret->wrap(__FILE__, __LINE__);
 
103
        }
 
104
 
 
105
        $ret = GalleryCoreApi::registerFactoryImplementation('ItemAddOption',
 
106
            'Getid3DescriptionOption', 'Getid3DescriptionOption',
 
107
            'modules/getid3/Getid3DescriptionOption.inc', 'getid3', null);
 
108
        if ($ret) {
 
109
            return $ret->wrap(__FILE__, __LINE__);
 
110
        }
 
111
 
 
112
 
 
113
        return null;
 
114
    }
 
115
 
 
116
    /**
 
117
     * @see GalleryModule::activate
 
118
     */
 
119
    function activate($postActivationEvent=true) {
 
120
        global $gallery;
 
121
        $ret = GalleryCoreApi::registerToolkitProperty(
 
122
                'Getid3',
 
123
                array('video/x-msvideo'),
 
124
                'originationTimestamp',
 
125
                'int',
 
126
                $gallery->i18n('Get the origination timestamp'));
 
127
        if ($ret) {
 
128
            return array($ret->wrap(__FILE__, __LINE__), null);
 
129
        }
 
130
 
 
131
        /*
 
132
         * Stopgap for now, don't allow installation on Windows until
 
133
         * we resolve the fact that the helperapps dir is missing from
 
134
         * the getid3 lib and the lib won't work properly if there are
 
135
         * spaces in the path.
 
136
         */
 
137
        $platform =& $gallery->getPlatform();
 
138
        if (GalleryUtilities::isA($platform, 'WinNtPlatform')) {
 
139
          return array(null,
 
140
                       array('view' => 'core.SiteAdmin',
 
141
                             'subView' => 'getid3.CantActivate'));
 
142
        }
 
143
 
 
144
        list ($ret, $redirect) = parent::activate($postActivationEvent);
 
145
        if ($ret) {
 
146
            return array($ret->wrap(__FILE__, __LINE__), null);
 
147
        }
 
148
 
 
149
        return array(null, $redirect);
 
150
    }
 
151
 
 
152
    /**
 
153
     * @see GalleryModule::deactivate()
 
154
     */
 
155
    function deactivate() {
 
156
        list ($ret, $redirect) = parent::deactivate();
 
157
        if ($ret) {
 
158
            return array($ret->wrap(__FILE__, __LINE__), null);
 
159
        }
 
160
 
 
161
        /* Unregister all of our properties and operations */
 
162
        $ret = GalleryCoreApi::unregisterToolkit('Getid3');
 
163
        if ($ret) {
 
164
            return array($ret->wrap(__FILE__, __LINE__), null);
 
165
        }
 
166
 
 
167
        return array(null, $redirect);
 
168
    }
 
169
 
 
170
    /**
 
171
     * @see GalleryModule::getSiteAdminViews()
 
172
     */
 
173
    function getSiteAdminViews() {
 
174
        return array(null, array(array('name' => $this->translate('Getid3'),
 
175
                                       'view' => 'getid3:AdminGetid3')));
 
176
    }
 
177
 
 
178
    /**
 
179
     * @see GalleryModule::getConfigurationView()
 
180
     */
 
181
    function getConfigurationView() {
 
182
        return 'getid3.CantActivate';
 
183
    }
 
184
}
 
185
?>