Browse Source

Merge pull request #1 from nigelgbanks/7.x-code-review

Code Review
pull/267/head
philsogaDGI 12 years ago
parent
commit
c6618a735a
  1. 92
      islandora.module

92
islandora.module

@ -37,7 +37,11 @@ define('FEDORA_MANAGE_PROPERTIES', 'manage object properties');
// Hooks. // Hooks.
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object'); define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object'); define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object');
define('ISLANDORA_OVERVIEW_HOOK', 'islandora_overview_object'); define('ISLANDORA_PRE_INGEST_HOOK', 'islandora_ingest_pre_ingest'); define('ISLANDORA_POST_INGEST_HOOK', 'islandora_ingest_post_ingest'); define('ISLANDORA_PRE_PURGE_OBJECT_HOOK', 'islandora_pre_purge_object'); define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object'); define('ISLANDORA_OVERVIEW_HOOK', 'islandora_overview_object');
define('ISLANDORA_PRE_INGEST_HOOK', 'islandora_ingest_pre_ingest');
define('ISLANDORA_POST_INGEST_HOOK', 'islandora_ingest_post_ingest');
define('ISLANDORA_PRE_PURGE_OBJECT_HOOK', 'islandora_pre_purge_object');
define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object');
// @todo Add Documentation. // @todo Add Documentation.
define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested'); define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');
@ -110,13 +114,36 @@ function islandora_menu() {
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_object_manage_access_callback', 'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array(array(FEDORA_MANAGE_PROPERTIES, FEDORA_METADATA_EDIT, FEDORA_ADD_DS, FEDORA_PURGE), 2), 'access arguments' => array(
array(
FEDORA_MANAGE_PROPERTIES,
FEDORA_METADATA_EDIT,
FEDORA_ADD_DS,
FEDORA_PURGE,
), 2),
); );
$items['islandora/object/%islandora_object/manage/overview'] = array( 'title' => 'Overview', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -20, ); $items['islandora/object/%islandora_object/manage/overview'] = array(
'title' => 'Overview',
$items['islandora/object/%islandora_object/manage/datastreams'] = array( 'title' => 'Datastreams', 'type' => MENU_LOCAL_TASK, 'page callback' => 'islandora_edit_object', 'page arguments' => array(2), 'access callback' => 'islandora_object_manage_access_callback', 'access arguments' => array(array(FEDORA_METADATA_EDIT, FEDORA_ADD_DS, FEDORA_PURGE), 2), 'weight' => -10, ); 'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -20,
);
$items['islandora/object/%islandora_object/manage/datastreams'] = array(
'title' => 'Datastreams',
'type' => MENU_LOCAL_TASK,
'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array(
array(
FEDORA_METADATA_EDIT,
FEDORA_ADD_DS,
FEDORA_PURGE,
), 2),
'weight' => -10,
);
$items['islandora/object/%islandora_object/manage/properties'] = array( $items['islandora/object/%islandora_object/manage/properties'] = array(
'title' => 'Properties', 'title' => 'Properties',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
@ -409,9 +436,54 @@ function islandora_object_manage_access_callback($perms, $object = NULL) {
* @return string * @return string
* The HTML repersentation of the manage object page. * The HTML repersentation of the manage object page.
*/ */
function islandora_manage_overview_object(FedoraObject $object) {
function islandora_manage_overview_object(FedoraObject $object) { module_load_include('inc', 'islandora', 'includes/utilities'); $output = array(); //return $output; foreach (islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models) as $hook) { $temp = module_invoke_all($hook, $object); if (!empty($temp)) { $output = array_merge_recursive($output, $temp); } } if (empty($output)) { // Add in the default, if we did not get any results. $output = islandora_default_islandora_manage_overview_object($object); } arsort($output); drupal_alter(ISLANDORA_OVERVIEW_HOOK, $object, $output); return implode('', $output); } /** * Renders the default manage object page for the given object. * * @param FedoraObject $object * The object used to render the manage object page. * * @return array * The default rendering of the object manage page, indexed at * 'Default Edit output'. */ function islandora_default_islandora_manage_overview_object(FedoraObject $object) { $output = theme('islandora_default_overview', array('islandora_object' => $object)); return array('Default overview output' => $output); } /** * Renders the given objects manage page. * * Its possible to modify the output of this function if 'ISLANDORA_EDIT_HOOK' * is implemented in other modules. * * If no modules implement 'ISLANDORA_EDIT_HOOK' then this function returns the * default manage view. * * @param FedoraObject $object * The object to manage. * * @return string * The HTML repersentation of the manage object page. */ module_load_include('inc', 'islandora', 'includes/utilities');
$output = array();
foreach (islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models) as $hook) {
$temp = module_invoke_all($hook, $object);
if (!empty($temp)) {
$output = array_merge_recursive($output, $temp);
}
}
if (empty($output)) {
// Add in the default, if we did not get any results.
$output = islandora_default_islandora_manage_overview_object($object);
}
arsort($output);
drupal_alter(ISLANDORA_OVERVIEW_HOOK, $object, $output);
return implode('', $output);
}
/**
* Renders the default manage object page for the given object.
*
* @param FedoraObject $object
* The object used to render the manage object page.
*
* @return array
* The default rendering of the object manage page, indexed at
* 'Default Edit output'.
*/
function islandora_default_islandora_manage_overview_object(FedoraObject $object) {
$output = theme('islandora_default_overview', array('islandora_object' => $object));
return array('Default overview output' => $output);
}
/**
* Renders the given objects manage page.
*
* Its possible to modify the output of this function if 'ISLANDORA_EDIT_HOOK'
* is implemented in other modules.
*
* If no modules implement 'ISLANDORA_EDIT_HOOK' then this function returns the
* default manage view.
*
* @param FedoraObject $object
* The object to manage.
*
* @return string
* The HTML repersentation of the manage object page.
*/
function islandora_edit_object(FedoraObject $object) { function islandora_edit_object(FedoraObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb'); module_load_include('inc', 'islandora', 'includes/breadcrumb');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');

Loading…
Cancel
Save