Browse Source

updated menus for secondary tabs and provided example implementations

pull/110/merge
Paul Pound 13 years ago
parent
commit
a2fce4d34e
  1. 66
      islandora.module
  2. 67
      islandora_basic_collection/islandora_basic_collection.module
  3. 52
      islandora_basic_image/islandora_basic_image.module

66
islandora.module

@ -93,7 +93,7 @@ function islandora_menu() {
$items['islandora'] = array(
'title' => 'Islandora Repository',
'page callback' => 'islandora_view_default_object',
'type' => MENU_NORMAL_ITEM,
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_VIEW),
);
@ -117,10 +117,19 @@ function islandora_menu() {
$items['islandora/object/%/view'] = array(
'title' => 'View',
'page callback' => 'islandora_view_object',
//'page callback' => 'islandora_view_object',
'page arguments' => array(2),
'type' => MENU_DEFAULT_LOCAL_TASK,
'access arguments' => array(FEDORA_VIEW),
'weight' => -10
);
$items['islandora/object/%/view/default'] = array(
'title' => 'View',
'page callback' => 'islandora_view_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_VIEW),
'weight' => -10,
);
$items['islandora/object/%/edit'] = array(
@ -130,6 +139,25 @@ function islandora_menu() {
'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_MODIFY_STATE),
);
$items['islandora/object/%/edit/datastreams'] = array(
'title' => 'Manage Datastreams',
'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_PURGE),
'weight' => -10,
);
$items['islandora/object/%/edit/properties'] = array(
'title' => 'Manage Properties',
'page callback' => 'islandora_edit_properties',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_MODIFY_STATE),
'weight' => -5,
);
$items['islandora/object/%/delete'] = array(
'title' => 'Purge object',
@ -185,6 +213,14 @@ function islandora_menu() {
return $items;
}
function islandora_admin_paths_alter(&$paths) {
$paths['*/edit*'] = TRUE;
}
/**
* determines whether we can see the object or not
* checks PID namespace permissions, and user permissions
@ -301,12 +337,16 @@ function islandora_edit_object($object_id) {
$arr = module_invoke_all('islandora_edit_object', $fedora_object);
$output = "";
foreach ($arr as $key => $value) {
$output .= $key . '<br />' . $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
$output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
}
//we could do another module invoke all here to build the edit tab with a default implemented in this module?
return $output;
}
function islandora_edit_properties($object_id){
return 'edit properties '.$object_id;
}
/**
* builds a default page for the edit tab
* @param object $fedora_object
@ -429,7 +469,7 @@ function islandora_view_object($object_id) {
//module_invoke_all(islandora_display($arr)),
$output = "";
foreach ($arr as $key => $value) {
$output .= $key . '<br />' . $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
$output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
}
//we could do another module invoke all here to build the edit tab with a default implemented in this module?
return $output; //just an example as we could have more then one array element
@ -444,14 +484,14 @@ function islandora_view_object($object_id) {
function islandora_islandora_view_object($object) {
$supported_models = islandora_get_types();
$output = "";
foreach ($object->models as $model) {
if (isset($supported_models[$model][ISLANDORA_VIEW_HOOK]) && $supported_models[$model][ISLANDORA_VIEW_HOOK] == TRUE) {//another module is handling the view
return;
}
foreach ($object->models as $model) {
if (isset($supported_models[$model][ISLANDORA_VIEW_HOOK]) && $supported_models[$model][ISLANDORA_VIEW_HOOK] == TRUE) {//another module is handling the view
return;
}
}
$output = theme('islandora_default', array('islandora_object' => $object));
return array('Default Output' => $output);
}
}
/**
* Theme registry function
@ -550,10 +590,10 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
$datastreams = array();
$variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id;
foreach ($islandora_object as $ds) {
$datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id .'/download';
$datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id .'/view';
$datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id .'/delete';
$datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download';
$datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view';
$datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete';
$datastreams['label'] = $ds->label;
$variables['islandora_datastreams'][$ds->id] = $datastreams;
$variables['islandora_datastreams'][$ds->id] = $datastreams;
}
}

67
islandora_basic_collection/islandora_basic_collection.module

@ -22,6 +22,73 @@
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
/**
* Implementation of hook_menu.
* we need some standard entry points so we can have consistent urls for different Object actions
*/
function islandora_basic_collection_menu() {
$items = array();
$items['islandora/object/%/edit/collection'] = array(
'title' => 'Manage Collection',
'page callback' => 'islandora_basic_collection_edit_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_basic_collection_access',
'access arguments' => array(2),
);
$items['islandora/object/%/view/collection'] = array(
'title' => 'Collection View',
'page callback' => 'islandora_basic_collection_view1',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_basic_collection_access',
'access arguments' => array(2),
);
return $items;
}
function islandora_basic_collection_edit_object($object_id){
return 'Collection CModel edit function '.$object_id;
}
function islandora_basic_collection_view1($object_id){
return 'A view returned by the Collection cmodel '.$object_id;
}
/**
* determines whether or not to show this modules manage tab
* @global object $user
* @param string $object_id
* @return boolean
*/
function islandora_basic_collection_access($object_id){
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return FALSE;
}
if (!isset($fedora_object)) {
return FALSE;
}
$models = $fedora_object->models;
$cmodel_list = islandora_basic_collection_islandora_get_types();
foreach ($fedora_object->models as $model) {
if (isset($cmodel_list[$model])){
return user_access(FEDORA_MODIFY_STATE);
}
}
return FALSE;
}
/**
* Theme registry function
* We supply a pattern so we can overide templates at the theme level if needed.

52
islandora_basic_image/islandora_basic_image.module

@ -28,21 +28,60 @@
*/
function islandora_basic_image_menu() {
$items = array();
$items['islandora/object/%/image'] = array(
'title' => 'Manage Image',
'page callback' => 'islandora_edit_object',
$items['islandora/object/%/edit/image'] = array(
'title' => 'Manage Image Types',
'page callback' => 'islandora_basic_image_edit_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_basic_image_access',
'access arguments' => array(2),
);
$items['islandora/object/%/view/image'] = array(
'title' => 'Image View 1',
'page callback' => 'islandora_basic_image_view1',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_basic_image_access',
'access arguments' => array(2),
);
$items['islandora/object/%/view/image2'] = array(
'title' => 'Image View 2',
'page callback' => 'islandora_basic_image_view2',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_basic_image_access',
'access arguments' => array(2),
);
return $items;
}
/**
* an example of adding a new managment section to the manage section of islandora.
* The islandora_basic_image_access function determines whether or not to show this
* section.
* @param string $object_id
* @return string
*/
function islandora_basic_image_edit_object($object_id){
return 'Image CModel edit function '.$object_id;
}
function islandora_basic_image_view1($object_id){
return 'A view returned by the image cmodel';
}
function islandora_basic_image_view2($object_id){
return 'Another view returned by the image cmodel';
}
/**
* determines whether or not to show this modules manage tab
* @global object $user
* @param string $object_id
* @return boolean
*/
function islandora_basic_image_access($object_id){
return true;
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
@ -50,11 +89,10 @@ function islandora_basic_image_access($object_id){
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
return FALSE;
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
return FALSE;
}
$models = $fedora_object->models;
$cmodel_list = islandora_basic_image_islandora_get_types();

Loading…
Cancel
Save