From 4c16e6af1dcba68d8edd2f56cbb5f9a808934f57 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Tue, 30 Jul 2013 13:57:00 -0300 Subject: [PATCH 01/10] Added the ability to print dc info and images for basic image, large image and pdf solution packs. --- css/islandora.print.css | 72 ++++++++++++ images/print-icon.png | Bin 0 -> 1510 bytes includes/solution_packs.inc | 4 +- islandora.api.php | 10 ++ islandora.module | 135 ++++++++++++++++++++++- js/add_print.js | 18 +++ theme/islandora-object-img-print.tpl.php | 18 +++ theme/islandora-object-print.tpl.php | 30 +++++ theme/islandora-object.tpl.php | 1 + theme/theme.inc | 1 + 10 files changed, 286 insertions(+), 3 deletions(-) create mode 100644 css/islandora.print.css create mode 100644 images/print-icon.png create mode 100644 js/add_print.js create mode 100644 theme/islandora-object-img-print.tpl.php create mode 100644 theme/islandora-object-print.tpl.php diff --git a/css/islandora.print.css b/css/islandora.print.css new file mode 100644 index 00000000..d54bb366 --- /dev/null +++ b/css/islandora.print.css @@ -0,0 +1,72 @@ +/** + * @file + * Print styling + * + * We provide some sane print styling for Drupal using Zen's layout method. + */ +a:link, +a:visited { /* underline all links */ + text-decoration: underline !important; +} + +#site-name a:link, +#site-name a:visited { /* Don't underline header */ + text-decoration: none !important; +} + +#content a[href^="javascript:"]:after, +#content a[href^="#"]:after { /* Only display useful links. */ +/* content: ""; */ +} + +#content abbr[title]:after { /* Add visible title after abbreviations. */ +/* content: " (" attr(title) ")"; */ +} + +#content { + left: 0 !important; + width: 100% !important; +} +uncomment when ready to test printing +#header { + display: none !important; +} + +#content { /* Un-float the content */ + float: none !important; + width: 100% !important; + margin: 0 !important; + padding: 0 !important; +} + +body, +#page, +#main, +#content { /* Turn off any background colors or images */ + color: #000; + background-color: transparent !important; + background-image: none !important; +} + +body.sidebar-first { + left: 0 !important; + width: 100% !important; +} +#skip-link, +#toolbar, +#navigation, +/* .region-sidebar-first, */ +/* .region-sidebar-second, */ +#header, +#footer, +.breadcrumb, +.tabs, +.action-links, +.links, +.book-navigation, +.forum-topic-navigation, +.pager, +.feed-icons { /* Hide sidebars and nav elements */ + visibility: hidden !important; + display: none !important; +} \ No newline at end of file diff --git a/images/print-icon.png b/images/print-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5f5a3b3c95faa1333c9f77f467e136093213cbbd GIT binary patch literal 1510 zcmV5dF;5HnHP8~zkFoB^6K1!iTL0%H)G`Pk`j8ivIL3tFJ zh&Tlq3?C#Kl+J8QMW73ji3`(g4iXduQA*$4y|=ScmqEXFCu!2O_n!Ov&iS8n?nl8S zR$YBA?%~5fa!n?aezLW;MzLqj@;<(P{rd6=S54+dE@0}LU6 zsZIk(r5M0qcLcDp+3f!lV3V(2PY;00<-+mf#Y0(HP6Ei~Wjzu}lCQx)4}j0-BY+YF zknSA7sWSO}afXeM8toL|OJg%w(Es?caR6MDn}a>sLY4^(CbOBx<8?3?j4u-s5{9e*wY9bWeSLlR zA|oTg$H#{_xb*WcAUoF#esku4R-0w9q{ z6pI!ug0ZnNvVhO$LS0iURCb~WeC8ZLON$EpOd8lBj+3B5=%ZM$V1adk z8=nWYNCV}{9tdBt7*&DRK@G5>y`u}>mM z@KS679tXZxv_YYw3xYxdL9cVP3Ruv6?{`@2!Gqj{2pAb1v!0!oN8GI7H(qg@$uK^&YeplfDdFgOC;-Q95Y>eV$=T3VXl%9Sg-u?W#5B!A)($21z6)&I zww25SIuJO5Umwat5Ah6@-wTkYq`;EUP}Eb#NEu=cw6wH@kmQz@mTJPo!?`%*_@h)R zp}edN1g-)Q2!v31x`MP(IsiD#5=ja?8y+P6C4SvHcsXy-IEKrYFGG5IxF@6+ zJ;2M$>(w~MmY<(5m^pLiesUo}Hf`E8LvwTU+r5AFd7Z01OY}kaN+uE|f(xHBxGE~@ zx8b27Cc4&<3klMcEHyRtDS@5HN$l#?+qpc!Ashjnj-CdvmJ$<_k?>wrRM(uB{AaW# zaTA*%XaQLvj4!|trJFTGDkAm-i`bA?W(f- z t('Object status: !image !status', array( '!image' => $solution_pack_status_info['image'], '!status' => $solution_pack_status_info['solution_pack'], - )), + )), '#prefix' => '
', '#suffix' => '
', ), @@ -623,7 +623,7 @@ function theme_islandora_viewers_table($variables) { 'header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'islandora-viewers-table'), - )); + )); $output .= drupal_render_children($form); return $output; } diff --git a/islandora.api.php b/islandora.api.php index 129787f4..80accfde 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -23,6 +23,16 @@ function hook_islandora_view_object($object, $user, $page_number, $page_size) { } +/** + * An alter hook to print friendly page for the given object. + * + * @param object $object + * The object form to print. + * @param string $output + * The object form to print + */ +function hook_islandora_view_print_object_alter($object, &$output) { +} /** * Generate an object's display for the given content model. * diff --git a/islandora.module b/islandora.module index 5b45fb1a..b295b7ea 100644 --- a/islandora.module +++ b/islandora.module @@ -36,6 +36,7 @@ define('FEDORA_MANAGE_PROPERTIES', 'manage object properties'); // Hooks. define('ISLANDORA_VIEW_HOOK', 'islandora_view_object'); +define('ISLANDORA_PRINT_HOOK', 'islandora_view_print_object'); define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object'); define('ISLANDORA_OVERVIEW_HOOK', 'islandora_overview_object'); define('ISLANDORA_PRE_INGEST_HOOK', 'islandora_ingest_pre_ingest'); @@ -102,6 +103,13 @@ function islandora_menu() { 'access callback' => 'islandora_object_access_callback', 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), ); + $items['islandora/print/%islandora_object'] = array( + 'page callback' => 'islandora_printer_object', + 'page arguments' => array(2), + 'type' => MENU_NORMAL_ITEM, + 'access callback' => 'islandora_object_access_callback', + 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), + ); $items['islandora/object/%islandora_object/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, @@ -289,6 +297,12 @@ function islandora_theme() { 'file' => 'theme/theme.inc', 'template' => 'theme/islandora-object-edit', 'variables' => array('islandora_object' => NULL), + ), + // Default edit page. + 'islandora_default_print' => array( + 'file' => 'theme/theme.inc', + 'template' => 'theme/islandora-object-print', + 'variables' => array('islandora_object' => NULL), ), // Admin table for solution pack viewer selection. 'islandora_viewers_table' => array( @@ -298,7 +312,11 @@ function islandora_theme() { // Print object view. 'islandora_object_print' => array( 'file' => 'theme/theme.inc', - 'variables' => array('object' => NULL, 'content' => array()), + 'template' => 'theme/islandora-object-print', + 'variables' => array( + 'object' => NULL, + 'content' => NULL, + 'islandora_content' => NULL), ), // Render a bunch of objects as either a grid or a list. 'islandora_objects' => array( @@ -744,8 +762,20 @@ function islandora_view_default_object() { function islandora_view_object(AbstractObject $object) { module_load_include('inc', 'islandora', 'includes/breadcrumb'); module_load_include('inc', 'islandora', 'includes/utilities'); + + // Add the print button via JavaScript. + $path = drupal_get_path('module', 'islandora'); + drupal_add_js(array( + 'islandora' => array( + 'print_img' => $path . '/images/print-icon.png'), + ), array('type' => 'setting')); + + drupal_add_js(array('islandora' => array('print_link' => '/islandora/print/' . $object->id)), array('type' => 'setting')); + drupal_add_js($path . '/js/add_print.js'); + drupal_set_title($object->label); drupal_set_breadcrumb(islandora_get_breadcrumbs($object)); + // Optional pager parameters. $page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; $page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize']; @@ -764,12 +794,73 @@ function islandora_view_object(AbstractObject $object) { // No results, use the default view. $output = islandora_default_islandora_view_object($object); } + arsort($output); drupal_alter($hooks, $object, $output); islandora_as_renderable_array($output); return $output; } +/** + * This will prepare an object to be printed. + * + * By default, all fedora objects can print DC record data, + * however, Solution packs that wish to modify the form + * to be printed must implement hook_islandora_view_print_object_alter, + * create a theme.tpl.php file, and return its markup by calling + * theme(themename.tpl.php). + * + * @param AbstractObject $object + * The object to print. + * + * @return string + * An HTML representation of this object. + */ +function islandora_printer_object(AbstractObject $object) { + + $output = array(); + $output = NULL; + $islandora_object = islandora_object_load($object->id); + $obj_pid = urldecode($object->id); + $resource_url = ''; + + // Check for a valid image/pdf/large image cmodel + // TODO: More preprocessing on large image and pdf to optimize view. + if (in_array('islandora:sp_basic_image', $islandora_object->models)) { + $resource_url = url("islandora/object/{$obj_pid}/datastream/OBJ/view"); + } + elseif (in_array('islandora:sp_large_image_cmodel', $islandora_object->models)) { + $resource_url = url("islandora/object/{$obj_pid}/datastream/JPG/view"); + } + elseif (in_array('islandora:sp_pdf', $islandora_object->models)) { + // Check for higher quality data stream if available. + $dsid = isset($obj['HQ_JPG']) ? 'HQ_JPG' : 'PREVIEW'; + $resource_url = url("islandora/object/{$obj_pid}/datastream/{$dsid}/view"); + } + + $params = array( + 'title' => $islandora_object->label, + 'path' => $resource_url, + ); + // Theme the image seperatly. + $variables['islandora_img'] = theme('image', $params); + $output = islandora_default_islandora_printer_object($object, $variables['islandora_img']); + + // Dispatch print hook. + foreach (islandora_build_hook_list(ISLANDORA_PRINT_HOOK, $object->models) as $hook) { + $temp = module_invoke_all($hook, $output); + islandora_as_renderable_array($temp); + if (!empty($temp)) { + $output = array_merge_recursive($output, $temp); + } + } + + arsort($output); + drupal_alter(ISLANDORA_PRINT_HOOK, $object, $output); + islandora_as_renderable_array($output); + + return $output; +} /** * Title callback for drupal title. @@ -807,6 +898,48 @@ function islandora_default_islandora_view_object($object) { ); } +/** + * Append the image alter to the printable form. + * + * @param AbstractObject $object + * The fedora object to print. + * @param unknown $alter + * The string representation of the themed viewable object. + * + * @return array + * A renderable array + */ +function islandora_default_islandora_printer_object($object, $alter) { + module_load_include('inc', 'islandora', 'includes/utilities'); + module_load_include('inc', 'islandora', 'includes/datastream'); + + $path = drupal_get_path('module', 'islandora'); + drupal_add_css($path . '/css/islandora.print.css'); + + $islandora_object = islandora_object_load($object->id); + $repository = $islandora_object->repository; + + try { + $dc = $islandora_object['DC']->content; + $dc_object = DublinCore::importFromXMLString($dc); + } + catch (Exception $e) { + drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE); + } + + $variables = isset($dc_object) ? $dc_object->asArray() : array(); + $output = theme('islandora_object_print', array( + 'object' => $object, + 'dc_array' => $variables, + 'islandora_content' => $alter)); + + return array( + 'Default output' => array( + '#markup' => $output, + ), + ); +} + /** * Just a wrapper around fetchings the IslandoraTuque object. * diff --git a/js/add_print.js b/js/add_print.js new file mode 100644 index 00000000..7af5c3ca --- /dev/null +++ b/js/add_print.js @@ -0,0 +1,18 @@ +/** + * @file +* JavaScript file responsable for the print button behaviour. +* +* The print button is added automatically to every view, as metadata +* can be printed from every object. +* +*/ +(function ($) { + $(document).ready(function() { + $('.tabs .primary').append(''); + $('#print_btn').css("cursor","pointer"); + $('#print_btn').click(function() { + window.location=Drupal.settings.islandora.print_link; + }); + }); +})(jQuery); + diff --git a/theme/islandora-object-img-print.tpl.php b/theme/islandora-object-img-print.tpl.php new file mode 100644 index 00000000..2c79a88e --- /dev/null +++ b/theme/islandora-object-img-print.tpl.php @@ -0,0 +1,18 @@ + + +
+ +
+ \ No newline at end of file diff --git a/theme/islandora-object-print.tpl.php b/theme/islandora-object-print.tpl.php new file mode 100644 index 00000000..3e6243bc --- /dev/null +++ b/theme/islandora-object-print.tpl.php @@ -0,0 +1,30 @@ + +
+
+ +
+ +
\ No newline at end of file diff --git a/theme/islandora-object.tpl.php b/theme/islandora-object.tpl.php index 13b40ba0..6fa306c3 100644 --- a/theme/islandora-object.tpl.php +++ b/theme/islandora-object.tpl.php @@ -60,6 +60,7 @@ ?>

+
diff --git a/theme/theme.inc b/theme/theme.inc index f07f95d4..51cc3bee 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -165,6 +165,7 @@ function islandora_preprocess_islandora_object_print(array &$variables) { * Implements theme_hook(). */ function theme_islandora_object_print(array &$variables) { + dsm(array('obj_print' => 'obj_in_print')); return drupal_render($variables['content']); } From 735bc3bce9b611fdbc81569c7d58567742f39809 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Tue, 30 Jul 2013 14:04:47 -0300 Subject: [PATCH 02/10] Removed leftover dsm call. --- theme/theme.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/theme/theme.inc b/theme/theme.inc index 51cc3bee..f07f95d4 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -165,7 +165,6 @@ function islandora_preprocess_islandora_object_print(array &$variables) { * Implements theme_hook(). */ function theme_islandora_object_print(array &$variables) { - dsm(array('obj_print' => 'obj_in_print')); return drupal_render($variables['content']); } From 7a2984bb77bb5dc48c17cd82886c1174b1c09f27 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Tue, 30 Jul 2013 16:05:10 -0300 Subject: [PATCH 03/10] Removed the alter hook, and implemented a generic printer hook to move more printer functionality to the solution packs. --- islandora.api.php | 5 +---- islandora.module | 54 ++++++++++------------------------------------- 2 files changed, 12 insertions(+), 47 deletions(-) diff --git a/islandora.api.php b/islandora.api.php index 80accfde..d026dd11 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -22,16 +22,13 @@ */ function hook_islandora_view_object($object, $user, $page_number, $page_size) { } - /** * An alter hook to print friendly page for the given object. * * @param object $object * The object form to print. - * @param string $output - * The object form to print */ -function hook_islandora_view_print_object_alter($object, &$output) { +function hook_islandora_view_print_object($object) { } /** * Generate an object's display for the given content model. diff --git a/islandora.module b/islandora.module index b295b7ea..69064725 100644 --- a/islandora.module +++ b/islandora.module @@ -103,7 +103,7 @@ function islandora_menu() { 'access callback' => 'islandora_object_access_callback', 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), ); - $items['islandora/print/%islandora_object'] = array( + $items['islandora/object/%islandora_object/print'] = array( 'page callback' => 'islandora_printer_object', 'page arguments' => array(2), 'type' => MENU_NORMAL_ITEM, @@ -241,15 +241,6 @@ function islandora_menu() { 'access arguments' => array(FEDORA_PURGE, 4), 'load arguments' => array(2), ); - $items['islandora/object/%islandora_object/print'] = array( - 'title' => 'Print Object', - 'page callback' => 'islandora_print_object', - 'page arguments' => array(2), - 'type' => MENU_CALLBACK, - 'access callback' => 'islandora_object_access', - 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), - 'load arguments' => array(2), - ); $items['islandora/object/%islandora_object/download_clip'] = array( 'page callback' => 'islandora_download_clip', 'page arguments' => array(2), @@ -770,7 +761,10 @@ function islandora_view_object(AbstractObject $object) { 'print_img' => $path . '/images/print-icon.png'), ), array('type' => 'setting')); - drupal_add_js(array('islandora' => array('print_link' => '/islandora/print/' . $object->id)), array('type' => 'setting')); + drupal_add_js(array( + 'islandora' => array( + 'print_link' => '/islandora/object/' . $object->id . '/print')), + array('type' => 'setting')); drupal_add_js($path . '/js/add_print.js'); drupal_set_title($object->label); @@ -817,48 +811,22 @@ function islandora_view_object(AbstractObject $object) { * An HTML representation of this object. */ function islandora_printer_object(AbstractObject $object) { - $output = array(); - $output = NULL; - $islandora_object = islandora_object_load($object->id); - $obj_pid = urldecode($object->id); - $resource_url = ''; - - // Check for a valid image/pdf/large image cmodel - // TODO: More preprocessing on large image and pdf to optimize view. - if (in_array('islandora:sp_basic_image', $islandora_object->models)) { - $resource_url = url("islandora/object/{$obj_pid}/datastream/OBJ/view"); - } - elseif (in_array('islandora:sp_large_image_cmodel', $islandora_object->models)) { - $resource_url = url("islandora/object/{$obj_pid}/datastream/JPG/view"); - } - elseif (in_array('islandora:sp_pdf', $islandora_object->models)) { - // Check for higher quality data stream if available. - $dsid = isset($obj['HQ_JPG']) ? 'HQ_JPG' : 'PREVIEW'; - $resource_url = url("islandora/object/{$obj_pid}/datastream/{$dsid}/view"); - } - - $params = array( - 'title' => $islandora_object->label, - 'path' => $resource_url, - ); - // Theme the image seperatly. - $variables['islandora_img'] = theme('image', $params); - $output = islandora_default_islandora_printer_object($object, $variables['islandora_img']); - + $temp_arr = array(); // Dispatch print hook. foreach (islandora_build_hook_list(ISLANDORA_PRINT_HOOK, $object->models) as $hook) { - $temp = module_invoke_all($hook, $output); + $temp = module_invoke_all($hook, $object); islandora_as_renderable_array($temp); if (!empty($temp)) { - $output = array_merge_recursive($output, $temp); + $temp_arr = array_merge_recursive($temp_arr, $temp); } } - + $output = islandora_default_islandora_printer_object($object, drupal_render($temp_arr)); arsort($output); - drupal_alter(ISLANDORA_PRINT_HOOK, $object, $output); islandora_as_renderable_array($output); + // Prompt to print. + drupal_add_js('jQuery(document).ready(function () { window.print(); });', 'inline'); return $output; } From 5ec2045e15080fc0ed8a4a2c914ae04199f18cdd Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 5 Aug 2013 09:11:21 -0300 Subject: [PATCH 04/10] Implemented changes requested via code review. --- css/islandora.print.css | 2 +- islandora.api.php | 23 ++++++++++++++++++++--- theme/islandora-object-img-print.tpl.php | 2 +- theme/islandora-object-print.tpl.php | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/css/islandora.print.css b/css/islandora.print.css index d54bb366..364e75e0 100644 --- a/css/islandora.print.css +++ b/css/islandora.print.css @@ -2,7 +2,7 @@ * @file * Print styling * - * We provide some sane print styling for Drupal using Zen's layout method. + * We provide some sane print styling for Drupal, hiding most visuals. */ a:link, a:visited { /* underline all links */ diff --git a/islandora.api.php b/islandora.api.php index d026dd11..984ad6c3 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -21,9 +21,26 @@ * An array whose values are markup. */ function hook_islandora_view_object($object, $user, $page_number, $page_size) { -} -/** - * An alter hook to print friendly page for the given object. +// Example Implementation +// $islandora_object = islandora_object_load($object->id); +// $output = array(); +// if (in_array('islandora:sp_basic_image', $islandora_object->models)) { +// $resource_url = url("islandora/object/{$object->id}/datastream/OBJ/view"); +// $params = array( +// 'title' => $islandora_object->label, +// 'path' => $resource_url, +// ); + +// // Theme the image seperatly. +// $variables['islandora_img'] = theme('image', $params); +// $output = theme('islandora_default_print', array( +// 'islandora_content' => $variables['islandora_img'])); +// } + +// return $output; +} +/** + * Generate a print friendly page for the given object. * * @param object $object * The object form to print. diff --git a/theme/islandora-object-img-print.tpl.php b/theme/islandora-object-img-print.tpl.php index 2c79a88e..3ff21455 100644 --- a/theme/islandora-object-img-print.tpl.php +++ b/theme/islandora-object-img-print.tpl.php @@ -15,4 +15,4 @@
- \ No newline at end of file + diff --git a/theme/islandora-object-print.tpl.php b/theme/islandora-object-print.tpl.php index 3e6243bc..b9569061 100644 --- a/theme/islandora-object-print.tpl.php +++ b/theme/islandora-object-print.tpl.php @@ -27,4 +27,4 @@
- \ No newline at end of file + From dffb15526d6c724c3889aaec14424179807c5d8c Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 5 Aug 2013 09:58:18 -0300 Subject: [PATCH 05/10] Updated via code review feedback. --- islandora.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/islandora.module b/islandora.module index 69064725..8495129e 100644 --- a/islandora.module +++ b/islandora.module @@ -759,7 +759,8 @@ function islandora_view_object(AbstractObject $object) { drupal_add_js(array( 'islandora' => array( 'print_img' => $path . '/images/print-icon.png'), - ), array('type' => 'setting')); + ), array( + 'type' => 'setting')); drupal_add_js(array( 'islandora' => array( From 1314c7dc06a7467ae7c9ee523df52da1a6ec6876 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 5 Aug 2013 10:29:14 -0300 Subject: [PATCH 06/10] Removed old hook. --- css/islandora.print.css | 2 +- islandora.api.php | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/css/islandora.print.css b/css/islandora.print.css index 364e75e0..45fca341 100644 --- a/css/islandora.print.css +++ b/css/islandora.print.css @@ -69,4 +69,4 @@ body.sidebar-first { .feed-icons { /* Hide sidebars and nav elements */ visibility: hidden !important; display: none !important; -} \ No newline at end of file +} diff --git a/islandora.api.php b/islandora.api.php index 984ad6c3..4d54a00f 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -21,23 +21,21 @@ * An array whose values are markup. */ function hook_islandora_view_object($object, $user, $page_number, $page_size) { -// Example Implementation -// $islandora_object = islandora_object_load($object->id); -// $output = array(); -// if (in_array('islandora:sp_basic_image', $islandora_object->models)) { -// $resource_url = url("islandora/object/{$object->id}/datastream/OBJ/view"); -// $params = array( -// 'title' => $islandora_object->label, -// 'path' => $resource_url, -// ); - -// // Theme the image seperatly. -// $variables['islandora_img'] = theme('image', $params); -// $output = theme('islandora_default_print', array( -// 'islandora_content' => $variables['islandora_img'])); -// } - -// return $output; + $output = array(); + if (in_array('islandora:sp_basic_image', $object->models)) { + $resource_url = url("islandora/object/{$object->id}/datastream/OBJ/view"); + $params = array( + 'title' => $object->label, + 'path' => $resource_url, + ); + + // Theme the image seperatly. + $variables['islandora_img'] = theme('image', $params); + $output = theme('islandora_default_print', array( + 'islandora_content' => $variables['islandora_img'])); + } + + return $output; } /** * Generate a print friendly page for the given object. From 1bf6024431672b1fad589ed1e4ffa3c05431d50d Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 5 Aug 2013 10:34:53 -0300 Subject: [PATCH 07/10] Updated via code review feedback. --- islandora.module | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/islandora.module b/islandora.module index 97081e32..625bb4e6 100644 --- a/islandora.module +++ b/islandora.module @@ -242,48 +242,6 @@ function islandora_menu() { 'access arguments' => array(FEDORA_PURGE, 4), 'load arguments' => array(2), ); -<<<<<<< HEAD -======= - $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version'] = array( - 'title' => 'Datastream Versions', - 'page arguments' => array(4), - 'page callback' => 'islandora_datastream_version_table', - 'file' => 'includes/datastream.version.inc', - 'type' => MENU_CALLBACK, - 'access callback' => 'islandora_datastream_access', - 'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4), - 'load arguments' => array(2), - ); - $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/delete'] = array( - 'title' => 'Delete datastream version', - 'page arguments' => array('islandora_delete_datastream_version_form', 4, 6), - 'page callback' => 'drupal_get_form', - 'file' => 'includes/datastream.version.inc', - 'type' => MENU_CALLBACK, - 'access callback' => 'islandora_datastream_access', - 'access arguments' => array(FEDORA_PURGE, 4), - 'load arguments' => array(2), - ); - $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/view'] = array( - 'title' => 'View datastream version', - 'page callback' => 'islandora_view_datastream', - 'page arguments' => array(4, FALSE, 6), - 'type' => MENU_CALLBACK, - 'file' => 'includes/datastream.inc', - 'access callback' => 'islandora_datastream_access', - 'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4), - 'load arguments' => array(2), - ); - $items['islandora/object/%islandora_object/print'] = array( - 'title' => 'Print Object', - 'page callback' => 'islandora_print_object', - 'page arguments' => array(2), - 'type' => MENU_CALLBACK, - 'access callback' => 'islandora_object_access', - 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), - 'load arguments' => array(2), - ); ->>>>>>> 73e09a9d0d9f0f91f2cbca4d6a204a96c9695fa1 $items['islandora/object/%islandora_object/download_clip'] = array( 'page callback' => 'islandora_download_clip', 'page arguments' => array(2), From 735cdca6dac996dc79c79aac27cfac2f7eabe089 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 5 Aug 2013 11:37:36 -0300 Subject: [PATCH 08/10] Travis build was failing, added menu callbacks back into core. --- islandora.module | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/islandora.module b/islandora.module index 625bb4e6..4b0a5411 100644 --- a/islandora.module +++ b/islandora.module @@ -242,6 +242,45 @@ function islandora_menu() { 'access arguments' => array(FEDORA_PURGE, 4), 'load arguments' => array(2), ); + $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version'] = array( + 'title' => 'Datastream Versions', + 'page arguments' => array(4), + 'page callback' => 'islandora_datastream_version_table', + 'file' => 'includes/datastream.version.inc', + 'type' => MENU_CALLBACK, + 'access callback' => 'islandora_datastream_access', + 'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4), + 'load arguments' => array(2), + ); + $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/delete'] = array( + 'title' => 'Delete datastream version', + 'page arguments' => array('islandora_delete_datastream_version_form', 4, 6), + 'page callback' => 'drupal_get_form', + 'file' => 'includes/datastream.version.inc', + 'type' => MENU_CALLBACK, + 'access callback' => 'islandora_datastream_access', + 'access arguments' => array(FEDORA_PURGE, 4), + 'load arguments' => array(2), + ); + $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/view'] = array( + 'title' => 'View datastream version', + 'page callback' => 'islandora_view_datastream', + 'page arguments' => array(4, FALSE, 6), + 'type' => MENU_CALLBACK, + 'file' => 'includes/datastream.inc', + 'access callback' => 'islandora_datastream_access', + 'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4), + 'load arguments' => array(2), + ); + $items['islandora/object/%islandora_object/print'] = array( + 'title' => 'Print Object', + 'page callback' => 'islandora_print_object', + 'page arguments' => array(2), + 'type' => MENU_CALLBACK, + 'access callback' => 'islandora_object_access', + 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), + 'load arguments' => array(2), + ); $items['islandora/object/%islandora_object/download_clip'] = array( 'page callback' => 'islandora_download_clip', 'page arguments' => array(2), From 86431678d0f0a6e32cba37aea162a64fbc48e1a0 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Tue, 6 Aug 2013 09:07:07 -0300 Subject: [PATCH 09/10] Corrected duplicate menu access path in core. --- islandora.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/islandora.module b/islandora.module index 4b0a5411..0704bfc2 100644 --- a/islandora.module +++ b/islandora.module @@ -272,7 +272,7 @@ function islandora_menu() { 'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4), 'load arguments' => array(2), ); - $items['islandora/object/%islandora_object/print'] = array( + $items['islandora/object/%islandora_object/printer'] = array( 'title' => 'Print Object', 'page callback' => 'islandora_print_object', 'page arguments' => array(2), From 0f4a02b7f024e255de11cd5d1952eb568fbf86e4 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Tue, 6 Aug 2013 11:23:14 -0300 Subject: [PATCH 10/10] After consulting my coworkers, i have remoted the previous print preview menu callback in favor of the new print callback i have implemented. --- islandora.module | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/islandora.module b/islandora.module index 0704bfc2..8a136988 100644 --- a/islandora.module +++ b/islandora.module @@ -272,15 +272,6 @@ function islandora_menu() { 'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4), 'load arguments' => array(2), ); - $items['islandora/object/%islandora_object/printer'] = array( - 'title' => 'Print Object', - 'page callback' => 'islandora_print_object', - 'page arguments' => array(2), - 'type' => MENU_CALLBACK, - 'access callback' => 'islandora_object_access', - 'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), - 'load arguments' => array(2), - ); $items['islandora/object/%islandora_object/download_clip'] = array( 'page callback' => 'islandora_download_clip', 'page arguments' => array(2), @@ -329,12 +320,6 @@ function islandora_theme() { 'file' => 'theme/theme.inc', 'template' => 'theme/islandora-object-edit', 'variables' => array('islandora_object' => NULL), - ), - // Default edit page. - 'islandora_default_print' => array( - 'file' => 'theme/theme.inc', - 'template' => 'theme/islandora-object-print', - 'variables' => array('islandora_object' => NULL), ), // Admin table for solution pack viewer selection. 'islandora_viewers_table' => array( @@ -1356,24 +1341,6 @@ function islandora_entity_property_info() { return $info; } - -/** - * Renders the print page for the given object. - * - * Modules can either implement preprocess functions to append content onto the - * 'content' variable, or override the display by providing a theme suggestion. - * - * @param AbstractObject $object - * The object. - * - * @return array - * A renderable array. - */ -function islandora_print_object(AbstractObject $object) { - drupal_set_title($object->label); - return theme('islandora_object_print', array('object' => $object)); -} - /** * Menu callback downloads the given clip. */