Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 98d4437

Browse files
author
Jamie Snape
committed
Revise thumbnailcreator module to not require external ImageMagick
1 parent a17e253 commit 98d4437

File tree

33 files changed

+562
-460
lines changed

33 files changed

+562
-460
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"ext-gd": "*",
1616
"ext-json": "*",
1717
"francodacosta/phMagick": "0.4.*@dev",
18+
"intervention/image": "~2.0.12",
1819
"leafo/scssphp": "~0.1.1",
1920
"maennchen/zipstream-php": "~0.2.2",
2021
"michelf/php-markdown": "~1.4.1",

core/database/mysql/3.2.16.sql renamed to core/database/mysql/3.2.17.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
22

3-
-- MySQL core database, version 3.2.16
3+
-- MySQL core database, version 3.2.17
44

55
CREATE TABLE IF NOT EXISTS `activedownload` (
66
`activedownload_id` bigint(20) NOT NULL AUTO_INCREMENT,

core/database/pgsql/3.2.16.sql renamed to core/database/pgsql/3.2.17.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
22

3-
-- PostgreSQL core database, version 3.2.16
3+
-- PostgreSQL core database, version 3.2.17
44

55
SET client_encoding = 'UTF8';
66
SET default_with_oids = FALSE;

core/database/sqlite/3.2.16.sql renamed to core/database/sqlite/3.2.17.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
22

3-
-- SQLite core database, version 3.2.16
3+
-- SQLite core database, version 3.2.17
44

55
CREATE TABLE IF NOT EXISTS "activedownload" (
66
"activedownload_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,

core/models/base/ItemModelBase.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,25 @@ public function replaceThumbnail($item, $tempThumbnailFile)
576576
$item->setThumbnailId($thumb->getKey());
577577
$this->save($item);
578578
}
579+
580+
/**
581+
* Return the latest bitstream from the latest item revision of the given item.
582+
*
583+
* @param ItemDao $itemDao item DAO
584+
* @return BitstreamDao bitstream DAO
585+
* @throws Zend_Exception
586+
*/
587+
public function getLatestBitstream($itemDao)
588+
{
589+
/** @var ItemRevisionModel $itemRevisionModel */
590+
$itemRevisionModel = MidasLoader::loadModel('ItemRevision');
591+
592+
try {
593+
$itemRevisionDao = $this->getLastRevision($itemDao);
594+
} catch (Zend_Exception $exception) {
595+
throw new Zend_Exception('Item does not contain any item revisions');
596+
}
597+
598+
return $itemRevisionModel->getLatestBitstream($itemRevisionDao);
599+
}
579600
}

core/models/base/ItemRevisionModelBase.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,22 @@ public function save($dao)
176176
}
177177
parent::save($dao);
178178
}
179+
180+
/**
181+
* Return the latest bitstream from the given item revision.
182+
*
183+
* @param ItemRevisionDao $itemRevisionDao item revision DAO
184+
* @return BitstreamDao
185+
* @throws Zend_Exception
186+
*/
187+
public function getLatestBitstream($itemRevisionDao)
188+
{
189+
$bitstreamDaos = $itemRevisionDao->getBitstreams();
190+
191+
if (count($bitstreamDaos) === 0) {
192+
throw new Zend_Exception('Item revision does not contain any bitstreams');
193+
}
194+
195+
return $bitstreamDaos[0];
196+
}
179197
}

core/views/rest/index/index.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ $this->headScript()->appendFile($this->coreWebroot.'/public/js/rest/rest.index.j
3333
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot ?>/public/css/rest/rest.index.css"/>
3434

3535
<div class="viewMain">
36-
<pre>Web API URL = Base URL (<?php echo $this->serverURL.$this->webroot ?>
37-
/rest) + API method URL<br/><br/>e.g. <?php echo $this->serverURL.$this->webroot ?>/rest/system/login</pre>
36+
<pre>Web API URL = Base URL (<?php echo $this->serverURL.$this->webroot ?>/rest)+ API method URL<br/><br/>e.g. <?php echo $this->serverURL.$this->webroot ?>/rest/system/login</pre>
3837
<br/>
3938
To authenticate requests, you can provide a parameter of
4039
<b>token</b> with an authentication token value obtained by calling

modules/api/library/KwWebApiCore.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21+
require_once 'XML/Serializer.php';
2122
require_once BASE_PATH.'/modules/api/library/KwUploadAPI.php';
2223

2324
/** Midas API core functionalities */

modules/thumbnailcreator/AppController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
/** App controller for the thumbnailcreator module */
2222
class Thumbnailcreator_AppController extends MIDAS_GlobalModule
2323
{
24+
/** @var string */
2425
public $moduleName = 'thumbnailcreator';
2526
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
5+
All rights reserved.
6+
More information http://www.kitware.com
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/** Bootstrap for the thumbnailcreator module. */
22+
class Thumbnailcreator_Bootstrap extends Zend_Application_Module_Bootstrap
23+
{
24+
}

0 commit comments

Comments
 (0)