Browse Source

updated get types to provide information about what functions it handles

pull/109/merge
Paul Pound 13 years ago
parent
commit
bbcc0f6a19
  1. 25
      islandora.module
  2. 17
      islandora_basic_collection/islandora_basic_collection.module
  3. 4
      islandora_basic_image/css/islandora_basic_image.admin.css
  4. 17
      islandora_basic_image/islandora_basic_image.module

25
islandora.module

@ -29,6 +29,8 @@ define('FEDORA_ADD_DS', 'add fedora datastreams');
define('FEDORA_INGEST', 'ingest fedora objects'); define('FEDORA_INGEST', 'ingest fedora objects');
define('FEDORA_PURGE', 'delete fedora objects and datastreams'); define('FEDORA_PURGE', 'delete fedora objects and datastreams');
define('FEDORA_MODIFY_STATE', 'modify fedora state'); define('FEDORA_MODIFY_STATE', 'modify fedora state');
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object');
/** /**
* Implementation of hook_menu. * Implementation of hook_menu.
@ -224,6 +226,8 @@ function islandora_purge_object($object_id) {
/** /**
* returns an array listing object types provided by sub modules * returns an array listing object types provided by sub modules
* The array should contain the cmodels it listens for and the hooks it answers to
* example array ('islandora:collectionCModel' => array ('islandora_edit_object' => TRUE, 'islandora_view_object' => TRUE);
* @return array * @return array
*/ */
function islandora_get_types() { function islandora_get_types() {
@ -253,17 +257,24 @@ function islandora_edit_object($object_id) {
foreach ($arr as $key => $value) { foreach ($arr as $key => $value) {
$output .= $key . '<br />' . $value; //if we have multiple modules handle one cmodel we need to iterate over multiple $output .= $key . '<br />' . $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; return $output;
} }
/** /**
* checks to see if any other modules implement this functionality and if there are none
* builds a default page for the edit tab * builds a default page for the edit tab
*
* @param object $fedora_object * @param object $fedora_object
* A tuque Fedora Object * A tuque Fedora Object
*/ */
function islandora_islandora_edit_object($fedora_object) { function islandora_islandora_edit_object($fedora_object) {
$supported_models = islandora_get_types();
$output = "";
foreach ($fedora_object->models as $model) {
if ($supported_models[$model][ISLANDORA_EDIT_HOOK] == TRUE) {//another module is handling the view
return;
}
}
$output = theme('islandora_default_edit', array('islandora_object' => $fedora_object)); $output = theme('islandora_default_edit', array('islandora_object' => $fedora_object));
return array('Default Edit output' => $output); return array('Default Edit output' => $output);
} }
@ -337,14 +348,15 @@ function islandora_view_object($object_id) {
*/ */
function islandora_islandora_view_object($object) { function islandora_islandora_view_object($object) {
$supported_models = islandora_get_types(); $supported_models = islandora_get_types();
$object_models = $object->models;
$combined_list = array_intersect($supported_models, $object->models);
$output = ""; $output = "";
if (empty($combined_list)) { foreach ($object->models as $model) {
if ($supported_models[$model][ISLANDORA_VIEW_HOOK] == TRUE) {//another module is handling the view
return;
}
}
$output = theme('islandora_default', array('islandora_object' => $object)); $output = theme('islandora_default', array('islandora_object' => $object));
return array('Default Output' => $output); return array('Default Output' => $output);
} }
}
/** /**
* Theme registry function * Theme registry function
@ -436,5 +448,4 @@ function islandora_preprocess_islandora_default(&$variables) {
function islandora_preprocess_islandora_default_edit(&$variables) { function islandora_preprocess_islandora_default_edit(&$variables) {
//$islandora_object = $variables['islandora_object']; //$islandora_object = $variables['islandora_object'];
} }

17
islandora_basic_collection/islandora_basic_collection.module

@ -48,7 +48,11 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) {
* array of content model pids that this module supports * array of content model pids that this module supports
*/ */
function islandora_basic_collection_islandora_get_types() { function islandora_basic_collection_islandora_get_types() {
return array('info:fedora/islandora:collectionCModel'); $types = array();
$types['info:fedora/islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = TRUE;
$types['info:fedora/islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE;
return $types;
} }
/** /**
@ -66,13 +70,15 @@ function islandora_basic_collection_islandora_get_types() {
function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) { function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) {
//global $user; //global $user;
$cmodel_list = islandora_basic_collection_islandora_get_types(); $cmodel_list = islandora_basic_collection_islandora_get_types();
$combined_list = array_intersect($cmodel_list, $object->models); $models = $object->models;
if (empty($combined_list)) { foreach ($object->models as $model) {
return NULL; //we don't handle any of this objects cmodels if ($cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
}
$output = theme('islandora_basic_collection', array('islandora_object' => $object)); $output = theme('islandora_basic_collection', array('islandora_object' => $object));
return array('Basic Collection Output' => $output); return array('Basic Collection Output' => $output);
} }
}
return NULL;
}
/** /**
* *
@ -103,7 +109,6 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
if (isset($islandora_object['MEDIUM_SIZE'])) { if (isset($islandora_object['MEDIUM_SIZE'])) {
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view'; $variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
} }
} }
function islandora_basic_collection_get_objects($object) { function islandora_basic_collection_get_objects($object) {

4
islandora_basic_image/css/islandora_basic_image.admin.css

@ -1,12 +1,8 @@
/* /*
Document : islandora_basic_collection.admin.css Document : islandora_basic_collection.admin.css
Created on : May 23, 2012, 11:23:06 AM Created on : May 23, 2012, 11:23:06 AM
Author : ppound
Description: Description:
Purpose of the stylesheet follows. Purpose of the stylesheet follows.
*/ */
root {
display: block;
}

17
islandora_basic_image/islandora_basic_image.module

@ -52,7 +52,10 @@ function islandora_basic_image_theme($existing, $type, $theme, $path) {
* array of content model pids that this module supports * array of content model pids that this module supports
*/ */
function islandora_basic_image_islandora_get_types() { function islandora_basic_image_islandora_get_types() {
return array('info:fedora/islandora:imgageCModel', 'info:fedora/islandora:sp_basic_image'); $types = array();
$types['info:fedora/islandora:sp_basic_image'][ISLANDORA_VIEW_HOOK] = TRUE;
$types['info:fedora/islandora:sp_basic_image'][ISLANDORA_EDIT_HOOK] = TRUE;
return $types;
} }
/** /**
@ -70,14 +73,15 @@ function islandora_basic_image_islandora_get_types() {
function islandora_basic_image_islandora_view_object($object, $user, $page_number, $page_size) { function islandora_basic_image_islandora_view_object($object, $user, $page_number, $page_size) {
//global $user; //global $user;
$cmodel_list = islandora_basic_image_islandora_get_types(); $cmodel_list = islandora_basic_image_islandora_get_types();
$combined_list = array_intersect($cmodel_list, $object->models); $models = $object->models;
if (empty($combined_list)) { foreach ($object->models as $model) {
return NULL; //we don't handle any of this objects cmodels if ($cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
}
$output = theme('islandora_basic_image', array('islandora_object' => $object)); $output = theme('islandora_basic_image', array('islandora_object' => $object));
return array('Basic Image Output' => $output); return array('Basic Image Output' => $output);
} }
}
return NULL;
}
/** /**
* *
@ -107,6 +111,5 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
if (isset($islandora_object['MEDIUM_SIZE'])) { if (isset($islandora_object['MEDIUM_SIZE'])) {
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view'; $variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
} }
} }

Loading…
Cancel
Save