3
3
* $RCSfile: module.inc,v $
5
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2005 Bharat Mediratta
6
* Copyright (C) 2000-2006 Bharat Mediratta
8
8
* This program is free software; you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
20
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23
* @version $Revision: 1.13 $ $Date: 2005/09/10 20:28:12 $
23
* @version $Revision: 1.18.2.1 $ $Date: 2006/04/05 00:19:53 $
25
25
* @author Bharat Mediratta <bharat@menalto.com>
41
41
$this->setName($gallery->i18n('Dcraw'));
42
42
$this->setDescription(
43
43
$gallery->i18n('Graphics toolkit for processing images in raw format'));
44
$this->setVersion('1.0.0');
45
$this->setGroup('toolkits', $this->translate('Graphics Toolkits'));
44
$this->setVersion('1.0.5');
45
$this->setGroup('toolkits', $gallery->i18n('Graphics Toolkits'));
46
46
$this->setCallbacks('getSiteAdminViews');
47
$this->setRequiredCoreApi(array(6, 0));
48
$this->setRequiredModuleApi(array(2, 0));
47
$this->setRequiredCoreApi(array(7, 0));
48
$this->setRequiredModuleApi(array(3, 0));
56
56
$ret = GalleryCoreApi::registerFactoryImplementation(
57
57
'GalleryToolkit', 'DcrawToolkit', 'Dcraw',
58
58
'modules/dcraw/classes/DcrawToolkit.class', 'dcraw', null);
59
if ($ret->isError()) {
60
60
return $ret->wrap(__FILE__, __LINE__);
63
return GalleryStatus::success();
72
72
list ($ret, $priority) = GalleryCoreApi::getToolkitPriorityById('Dcraw');
73
if ($ret->isError()) {
74
74
return array($ret->wrap(__FILE__, __LINE__), null);
78
78
list ($ret, $priority) = GalleryCoreApi::getMaximumManagedToolkitPriority();
79
if ($ret->isError()) {
80
80
return array($ret->wrap(__FILE__, __LINE__), null);
85
85
$ret = GalleryCoreApi::registerToolkitOperation(
86
86
'Dcraw', array('image/x-dcraw'), 'convert-to-image/x-portable-pixmap',
87
87
array(), $gallery->i18n('Convert to PPM'), 'image/x-portable-pixmap', $priority);
88
if ($ret->isError()) {
89
89
return array($ret->wrap(__FILE__, __LINE__), null);
92
92
$ret = GalleryCoreApi::registerToolkitProperty(
93
93
'Dcraw', array('image/x-dcraw'), 'dimensions', 'int,int',
94
94
$gallery->i18n('Get the width and height of the image'));
95
if ($ret->isError()) {
96
96
return array($ret->wrap(__FILE__, __LINE__), null);
101
101
'fff', 'k25', 'kdc', 'mos', 'mrw', 'nef', 'orf',
102
102
'pef', 'raf', 'rdc', 'srf', 'x3f') as $extension) {
103
103
$ret = GalleryCoreApi::addMimeType($extension, 'image/x-dcraw', 0);
104
if ($ret->isError()) {
105
105
if (!($ret->getErrorCode() & ERROR_COLLISION)) {
106
106
return array($ret->wrap(__FILE__, __LINE__), null);
111
/* Detect the version of the binary (it may have changed since last activation) */
112
GalleryCoreApi::requireOnce('modules/dcraw/classes/DcrawToolkitHelper.class');
114
list ($ret, $path) = $this->getParameter('path');
116
return array($ret->wrap(__FILE__, __LINE__), null);
119
list ($ret, $testResults, $version) = DcrawToolkitHelper::testBinary($path);
121
return array($ret->wrap(__FILE__, __LINE__), null);
124
$ret = $this->setParameter('version', $version);
126
return array($ret->wrap(__FILE__, __LINE__), null);
111
129
list ($ret, $redirect) = parent::activate($postActivationEvent);
112
if ($ret->isError()) {
113
131
return array($ret->wrap(__FILE__, __LINE__), null);
116
return array(GalleryStatus::success(), $redirect);
134
return array(null, $redirect);
126
144
* be after the deactivation is done.
128
146
$ret = GalleryCoreApi::unregisterToolkit('Dcraw');
129
if ($ret->isError()) {
130
148
return array($ret->wrap(__FILE__, __LINE__), null);
133
151
list ($ret, $redirect) = parent::deactivate($postDeactivationEvent);
134
if ($ret->isError()) {
135
153
return array($ret->wrap(__FILE__, __LINE__), null);
138
return array(GalleryStatus::success(), $redirect);
156
return array(null, $redirect);
142
160
* @see GalleryModule::needsConfiguration
144
162
function needsConfiguration() {
145
list ($ret, $value) = $this->getParameter('path');
146
if ($ret->isError()) {
147
return array($ret->wrap(__FILE__, __LINE__), null);
150
return array(GalleryStatus::success(), empty($value));
154
* @see GalleryModule::isRecommendedDuringInstall
156
function isRecommendedDuringInstall() {
163
list ($ret, $path) = $this->getParameter('path');
165
return array($ret->wrap(__FILE__, __LINE__), null);
168
list ($ret, $version) = $this->getParameter('version');
170
return array($ret->wrap(__FILE__, __LINE__), null);
173
return array(null, empty($path) || empty($version));
166
182
list ($ret, $needsConfiguration) = $this->needsConfiguration();
167
if ($ret->isError()) {
168
184
return array($ret->wrap(__FILE__, __LINE__), false);
171
187
if (!$needsConfiguration) {
172
return array(GalleryStatus::success(), true);
188
return array(null, true);
175
191
/* Try a bunch of likely seeming paths to see if any of them work. */
176
$platform = $gallery->getPlatform();
192
$platform =& $gallery->getPlatform();
177
193
$slash = $platform->getDirectorySeparator();
217
233
$paths[] = '/bin/dcraw';
218
234
$paths[] = '/sw/bin/dcraw';
220
return array(GalleryStatus::success(), false);
236
return array(null, false);
223
239
/* Load any classes we require */
224
GalleryCoreApi::relativeRequireOnce('modules/dcraw/classes/DcrawToolkitHelper.class');
240
GalleryCoreApi::requireOnce('modules/dcraw/classes/DcrawToolkitHelper.class');
226
242
/* Now try each path in turn to see which ones work */
227
243
foreach ($paths as $path) {
228
list ($ret, $testResults) = DcrawToolkitHelper::testBinary($path);
229
if ($ret->isError()) {
244
list ($ret, $testResults, $version) = DcrawToolkitHelper::testBinary($path);
230
246
/* This path failed. Continue with the next one */
242
258
if ($failCount == 0) {
243
259
/* We have a winner */
244
260
$ret = GalleryCoreApi::setPluginParameter('module', 'dcraw', 'path', $path);
245
if ($ret->isError()) {
246
262
return array($ret->wrap(__FILE__, __LINE__), false);
249
return array(GalleryStatus::success(), true);
265
return array(null, true);
253
return array(GalleryStatus::success(), false);
269
return array(null, false);
257
273
* @see GalleryModule::getSiteAdminViews
259
275
function getSiteAdminViews() {
260
return array(GalleryStatus::success(),
261
277
array(array('name' => $this->translate('Dcraw'),
262
278
'view' => 'dcraw.AdminDcraw')));