diff --git a/islandora.module b/islandora.module index e40a98df..22945983 100644 --- a/islandora.module +++ b/islandora.module @@ -22,13 +22,16 @@ */ - +//Permissions define('FEDORA_VIEW', 'view fedora repository'); define('FEDORA_METADATA_EDIT', 'edit fedora metadata'); define('FEDORA_ADD_DS', 'add fedora datastreams'); define('FEDORA_INGEST', 'ingest fedora objects'); define('FEDORA_PURGE', 'delete fedora objects and datastreams'); define('FEDORA_MODIFY_STATE', 'modify fedora state'); +define('FEDORA_MANAGE', 'manage fedora items'); + +//hooks define('ISLANDORA_VIEW_HOOK', 'islandora_view_object'); define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object'); @@ -55,7 +58,7 @@ function islandora_menu() { 'type' => MENU_NORMAL_ITEM, 'weight' => 0, ); - + /* may not need this $items['admin/islandora/solution_packs'] = array( 'title' => 'Solution Packs', 'description' => 'Install content models and collections required by installed solution packs.', @@ -63,7 +66,7 @@ function islandora_menu() { 'access arguments' => array(FEDORA_ADD_DS), 'file' => 'admin/islandora.solutionpacks.inc', 'type' => MENU_NORMAL_ITEM, - ); + );*/ $items['islandoracm.xsd'] = array( 'title' => 'Islandora Content Model XML Schema Definition', @@ -93,7 +96,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,19 +120,47 @@ 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( + $items['islandora/object/%/manage'] = array( 'title' => 'Manage', 'page callback' => 'islandora_edit_object', 'page arguments' => array(2), 'type' => MENU_LOCAL_TASK, 'access arguments' => array(FEDORA_MODIFY_STATE), ); + + $items['islandora/object/%/manage/datastreams'] = array( + 'title' => 'Datastreams', + 'page callback' => 'islandora_edit_object', + 'page arguments' => array(2), + 'type' => MENU_LOCAL_TASK, + 'access arguments' => array(FEDORA_PURGE), + 'weight' => -10, + ); + + $items['islandora/object/%/manage/properties'] = array( + 'title' => '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 +216,14 @@ function islandora_menu() { return $items; } + + +function islandora_admin_paths_alter(&$paths) { + + $paths['*/manage*'] = TRUE; + +} + /** * determines whether we can see the object or not * checks PID namespace permissions, and user permissions @@ -301,12 +340,16 @@ function islandora_edit_object($object_id) { $arr = module_invoke_all('islandora_edit_object', $fedora_object); $output = ""; foreach ($arr as $key => $value) { - $output .= $key . '
' . $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,8 +472,9 @@ function islandora_view_object($object_id) { //module_invoke_all(islandora_display($arr)), $output = ""; foreach ($arr as $key => $value) { - $output .= $key . '
' . $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 +488,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]) && (boolean)$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 @@ -500,6 +544,10 @@ function islandora_permission() { 'title' => t('Change a Fedora objects state'), 'description' => t('Users with this permission will be allowed to change a Fedora objects state.') ), + FEDORA_MANAGE => array( + 'title' => t('View Fedora Manage tabs'), + 'description' => t('Users with this permission will be allowed to view fedora manage manage tabs.') + ) ); } @@ -543,14 +591,17 @@ function islandora_preprocess_islandora_default(&$variables) { function islandora_preprocess_islandora_default_edit(&$variables) { $islandora_object = $variables['islandora_object']; + //module_load_include('inc', 'islandora', 'includes/datastream'); + //$test = ''; + //$dsids = islandora_add_datastream_form($islandora_object->id, $test); global $base_url; $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; } } \ No newline at end of file diff --git a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc new file mode 100644 index 00000000..8311f3e8 --- /dev/null +++ b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc @@ -0,0 +1,16 @@ + 'checkbox', + '#title' => t('Provide the view for the default tab'), + '#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', 'TRUE'), + '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content + on a view tab you may have multiple modules configured to provide content for the default tab.'), + '#weight' => -10 + ); + + return system_settings_form($form); +} + diff --git a/islandora_basic_collection/islandora_basic_collection.module b/islandora_basic_collection/islandora_basic_collection.module index cc79caad..85a8b311 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -22,6 +22,84 @@ * along with the program. If not, see . */ +/** + * 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/%/manage/collection'] = array( + 'title' => 'Collection Related', + 'page callback' => 'islandora_basic_collection_manage_object', + 'page arguments' => array(2), + 'type' => MENU_LOCAL_TASK, + 'access callback' => 'islandora_basic_collection_access', + 'access arguments' => array(2), + ); + + $items['admin/islandora/basic_collection'] = array( + 'title' => 'Islandora Basic Collection', + 'description' => 'Configure the basic Collection solution pack.', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer site configuration'), + 'page arguments' => array('islandora_basic_collection_admin'), + 'file' => 'admin/islandora_basic_collection.admin.inc', + 'type' => MENU_NORMAL_ITEM, + ); + + /* an example of adding a tab for view + $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; +} + +/** + * This function is where we create the view for the related menu item + * @param type $object_id + * @return type + */ +function islandora_basic_collection_manage_object($object_id) { + return 'Collection CModel edit function ' . $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_MANAGE); + } + } + return FALSE; +} + /** * Theme registry function * We supply a pattern so we can overide templates at the theme level if needed. @@ -44,13 +122,15 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) { /** * tells the main module what types of objects we support. This is used to determine whether or not * this module should attempt to respond. + * If ISLANDORA_VIEW_HOOK = TRUE this function will populate the default tab. This should be configurable + * in the modules admin section, otherwise two modules can populate one tab. * @return array * array of content model pids that this module supports */ function islandora_basic_collection_islandora_get_types() { $types = array(); - $types['islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = TRUE; - $types['islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE; + $types['islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = variable_get('islandora_basic_collection_use_for_default_tab', TRUE); + //$types['islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE; return $types; } diff --git a/islandora_basic_image/admin/islandora_basic_image.admin.inc b/islandora_basic_image/admin/islandora_basic_image.admin.inc new file mode 100644 index 00000000..d31dbef0 --- /dev/null +++ b/islandora_basic_image/admin/islandora_basic_image.admin.inc @@ -0,0 +1,16 @@ + 'checkbox', + '#title' => t('Provide the view for the default tab'), + '#default_value' => variable_get('islandora_basic_image_use_for_default_tab', 'TRUE'), + '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content + on a view tab you may have multiple modules configured to provide content for the default tab.'), + '#weight' => -10 + ); + + return system_settings_form($form); +} + diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index 23f8ef39..2a15c695 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -22,6 +22,117 @@ * along with the program. If not, see . */ +/** + * Implementation of hook_menu. + * If you need to add secondary tabs to either view or manage you would create a + * hook_menu function similar to below. You would also need to create an access function + * to tell islandora when to show your tabs. There is an example below. + */ +function islandora_basic_image_menu() { + $items = array(); + $items['admin/islandora/basic_image'] = array( + 'title' => 'Islandora Basic Image', + 'description' => 'Configure the basic image solution pack.', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer site configuration'), + 'page arguments' => array('islandora_basic_image_admin'), + 'file' => 'admin/islandora_basic_image.admin.inc', + 'type' => MENU_NORMAL_ITEM, + ); + /* example menu paths + $items['islandora/object/%/manage/image'] = array( + 'title' => 'Manage Image Types', + 'page callback' => 'islandora_basic_image_manage_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. + * + * This is an example function used by hook_menu above. + * @param string $object_id + * @return string + */ +/** +function islandora_basic_image_manage_object($object_id){ + return 'Image CModel edit function '.$object_id; +}*/ + +/** + * /** + * An example function used by hook_menu + * / + * @param type $object_id + * @return string + */ +/* +function islandora_basic_image_view1($object_id){ + return 'A view returned by the image cmodel'; +}*/ + +/** + * An example function needed by this modules hook_menu + * @param type $object_id + * @return string + */ +/* +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){ + 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_image_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. @@ -33,7 +144,7 @@ function islandora_basic_image_theme($existing, $type, $theme, $path) { return array( 'islandora_basic_image_objects' => array( 'template' => 'islandora-basic-image-view-objects', - 'variables' => array('islandor_objects' => NULL), + 'variables' => array('islandora_objects' => NULL), ), 'islandora_basic_image' => array( 'template' => 'islandora-basic-image', @@ -53,8 +164,8 @@ function islandora_basic_image_theme($existing, $type, $theme, $path) { */ function islandora_basic_image_islandora_get_types() { $types = array(); - $types['islandora:sp_basic_image'][ISLANDORA_VIEW_HOOK] = TRUE; - $types['islandora:sp_basic_image'][ISLANDORA_EDIT_HOOK] = FALSE; + $types['islandora:sp_basic_image'][ISLANDORA_VIEW_HOOK] = variable_get('islandora_basic_image_use_for_default_tab', TRUE); + //$types['islandora:sp_basic_image'][ISLANDORA_EDIT_HOOK] = FALSE; return $types; } @@ -101,12 +212,11 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) { $variables['islandora_dublin_core'] = $dc_object; //create a nicer array for themers //TODO: give this a better home - //$dc_array = array(); //foreach ($dc_object as $element) { // if (!empty($element)) { // foreach ($element as $field => $value) { - // // split value if the result value is an array + // // split value if the result value is an array // if (is_array($value)) { // $value = implode(", ", $value); // } @@ -118,7 +228,7 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) { // } // } //} - + $variables['dc_array'] = $dc_object->as_formatted_array(); $variables['islandora_object_label'] = $islandora_object->label; $variables['theme_hook_suggestions'][] = 'islandora_basic_image__' . str_replace(':', '_', $islandora_object->id);