From 54acff362ba344c81c8897fca5830797af839afe Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 3 Apr 2013 12:06:11 -0300 Subject: [PATCH 1/3] Handle downloading of clips in core (ONTIME-1262). --- islandora.module | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/islandora.module b/islandora.module index 05a3a57b..43b363fe 100644 --- a/islandora.module +++ b/islandora.module @@ -245,6 +245,14 @@ function islandora_menu() { 'type' => MENU_SUGGESTED_ITEM, 'access arguments' => array(FEDORA_INGEST), ); + $items['islandora/object/%islandora_object/download_clip'] = array( + 'page callback' => 'islandora_download_clip', + 'page arguments' => array(2), + 'type' => MENU_CALLBACK, + 'access callback' => 'islandora_object_access_callback', + 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), + 'load arguments' => array(2), + ); return $items; } @@ -1073,3 +1081,25 @@ function islandora_print_object(FedoraObject $object) { drupal_set_title($object->label); return theme('islandora_object_print', array('object' => $object)); } + +/** + * Menu callback downloads the given clip. + */ +function islandora_download_clip(FedoraObject $object) { + if (isset($_GET['clip'])) { + $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; + $http_protocol = $is_https ? 'https' : 'http'; + $url = $http_protocol . '://' . $_SERVER['HTTP_HOST'] . $_GET['clip']; + $filename = $object->label; + header("Content-Disposition: attachment; filename=\"{$filename}.jpg\""); + header("Content-type: image/jpeg"); + header("Content-Transfer-Encoding: binary"); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_URL, $url); + $response = curl_exec ($ch); + curl_close($ch); + } + exit(); +} \ No newline at end of file From 0b0acd0759dc323b060872d1c5e341d6bdc321fc Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 3 Apr 2013 12:08:00 -0300 Subject: [PATCH 2/3] New line and codesniffer changes. --- islandora.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/islandora.module b/islandora.module index 43b363fe..c9ea373b 100644 --- a/islandora.module +++ b/islandora.module @@ -120,7 +120,7 @@ function islandora_menu() { FEDORA_METADATA_EDIT, FEDORA_ADD_DS, FEDORA_PURGE, - FEDORA_INGEST + FEDORA_INGEST, ), 2), ); @@ -1098,8 +1098,8 @@ function islandora_download_clip(FedoraObject $object) { curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $url); - $response = curl_exec ($ch); + $response = curl_exec($ch); curl_close($ch); } exit(); -} \ No newline at end of file +} From 82fa859e3ba62a73330281c96a07092f52ddceff Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 5 Apr 2013 12:57:58 -0300 Subject: [PATCH 3/3] Coding style fixes. --- islandora.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora.module b/islandora.module index c9ea373b..64c81628 100644 --- a/islandora.module +++ b/islandora.module @@ -1077,7 +1077,7 @@ function islandora_entity_property_info() { * @return array * A renderable array. */ -function islandora_print_object(FedoraObject $object) { +function islandora_print_object(AbstractObject $object) { drupal_set_title($object->label); return theme('islandora_object_print', array('object' => $object)); } @@ -1085,7 +1085,7 @@ function islandora_print_object(FedoraObject $object) { /** * Menu callback downloads the given clip. */ -function islandora_download_clip(FedoraObject $object) { +function islandora_download_clip(AbstractObject $object) { if (isset($_GET['clip'])) { $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; $http_protocol = $is_https ? 'https' : 'http';