|
@@ -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. |
|
|
|
* |
|
|
0 comments on commit
4c16e6a