diff --git a/islandora_basic_collection/includes/ChangeContentModels.inc b/islandora_basic_collection/includes/change_content_models.inc similarity index 100% rename from islandora_basic_collection/includes/ChangeContentModels.inc rename to islandora_basic_collection/includes/change_content_models.inc diff --git a/islandora_basic_collection/includes/ChildCollection.inc b/islandora_basic_collection/includes/child_collection.inc similarity index 86% rename from islandora_basic_collection/includes/ChildCollection.inc rename to islandora_basic_collection/includes/child_collection.inc index 492d7ff1..763d30fd 100644 --- a/islandora_basic_collection/includes/ChildCollection.inc +++ b/islandora_basic_collection/includes/child_collection.inc @@ -15,8 +15,28 @@ */ function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) { module_load_include('inc', 'islandora', 'RestConnection'); + module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy'); $rest_connection = new RestConnection(); - + $collection_object = new FedoraObject($this_collection_pid, $rest_connection->repository); + $policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); + $collection_policy = new CollectionPolicy($policy_datastream->content); + $current_content_models = $collection_policy->getContentModels(); + + $collection_content_model_exists = FALSE; + + foreach ($current_content_models as $current_content_model) { + if ($current_content_model['pid'] == 'islandora:collectionCModel') { + $collection_content_model_exists = TRUE; + } + } + + if (!$collection_content_model_exists) { + $form['not_collection'] = array( + '#type' => 'item', + '#title' => t("This object can't contain child collections. To fix this add the islandora:collectionCModel to this object's collection policy"), + ); + return $form; + } $restricted = FALSE; if (variable_get('fedora_namespace_restriction_enforced', TRUE)) { $restricted = TRUE; diff --git a/islandora_basic_collection/includes/CollectionManagement.inc b/islandora_basic_collection/includes/collection_management.inc similarity index 66% rename from islandora_basic_collection/includes/CollectionManagement.inc rename to islandora_basic_collection/includes/collection_management.inc index 1df57e28..85541ee6 100644 --- a/islandora_basic_collection/includes/CollectionManagement.inc +++ b/islandora_basic_collection/includes/collection_management.inc @@ -25,7 +25,7 @@ where (\$object repository->ri->itqlQuery($query, 'unlimited', '0'); $represented_models = array(); foreach ($model_pids as $model_pid) { - + if ($model_pid['model']['value'] && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') { $fedora_object = new FedoraObject($model_pid['model']['value'], $rest_connection->repository); $content_model_title = $fedora_object->label; @@ -67,7 +67,6 @@ function islandora_collections_get_collection_from_pid($pid) { return $object_pids; } - /** * Returns an array of pids that match the query contained in the collection * object's QUERY datastream or in the suppled $query parameter. @@ -79,9 +78,9 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe module_load_include('inc', 'islandora', 'RestConnection'); $rest_connection = new RestConnection(); require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; - + global $user; - + // Not sure if this is necessary given that we should never be able to delete objects in a namespace that we don't have access to. // if (!fedora_repository_access('view fedora repository', $collection_pid['object']['value'])) { // drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); @@ -118,85 +117,84 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe $query_string .= ') minus $content order by ' . $orderby; - + $results = $rest_connection->repository->ri->itqlQuery($query_string, $limit, $offset); return $results; } - - /** - * determines whether we can see the object or not - * checks PID namespace permissions, and user permissions - * @global type $user - * @param type $op - * @param type $pid - * @return type - */ - function fedora_repository_access($permission, $pid) { - global $user; - $name_space_access = FALSE; - $is_restricted = variable_get('islandora_namespace_restriction_enforced', TRUE); - if (!$is_restricted) { +/** + * determines whether we can see the object or not + * checks PID namespace permissions, and user permissions + * @global type $user + * @param type $op + * @param type $pid + * @return type + */ +function fedora_repository_access($permission, $pid) { + global $user; + $name_space_access = FALSE; + $is_restricted = variable_get('islandora_namespace_restriction_enforced', TRUE); + if (!$is_restricted) { + $name_space_access = TRUE; + } + if ($pid == NULL) { + $pid = variable_get('islandora_repository_pid', 'islandora:root'); + } + $name_space_allowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); + $pos = NULL; + foreach ($name_space_allowed as $name_space) { + $pos = stripos($pid, $name_space); + if ($pos === 0) { $name_space_access = TRUE; } - if ($pid == NULL) { - $pid = variable_get('islandora_repository_pid', 'islandora:root'); - } - $name_space_allowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); - $pos = NULL; - foreach ($name_space_allowed as $name_space) { - $pos = stripos($pid, $name_space); - if ($pos === 0) { - $name_space_access = TRUE; - } - } - if ($name_space_access) { - $user_access = user_access($permission); - if ($user_access == NULL) { - return FALSE; - } - return $user_access; - } - else { + } + if ($name_space_access) { + $user_access = user_access($permission); + if ($user_access == NULL) { return FALSE; } + return $user_access; } + else { + return FALSE; + } +} - /** - * gets the name of the content models for the specified object - * this now returns an array of pids as in Fedora 3 we can have more then one Cmodel for an object - * @param type $pid - * @param type $include_fedora_system_content_models - * @return array - */ - function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { +/** + * gets the name of the content models for the specified object + * this now returns an array of pids as in Fedora 3 we can have more then one Cmodel for an object + * @param type $pid + * @param type $include_fedora_system_content_models + * @return array + */ +function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { module_load_include('inc', 'islandora', 'RestConnection'); require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; $rest_connection = new RestConnection(); - $pids = array(); - $query = 'select $object from <#ri> + $pids = array(); + $query = 'select $object from <#ri> where $object and $object '; - $content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); - - if (empty($content_models)) { - return $pids; - } + $content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); - $cmodels = array(); - foreach ($content_models as $content_model) { - if (strpos($content_model['object']['uri'], 'fedora-system:FedoraObject-3.0') != FALSE && $include_fedora_system_content_models == FALSE) { - continue; - } - $cmodels[] = substr(strstr($content_model['object']['uri'], '/'), 1); - } + if (empty($content_models)) { + return $pids; + } - return $cmodels; + $cmodels = array(); + foreach ($content_models as $content_model) { + if (strpos($content_model['object']['uri'], 'fedora-system:FedoraObject-3.0') != FALSE && $include_fedora_system_content_models == FALSE) { + continue; + } + $cmodels[] = substr(strstr($content_model['object']['uri'], '/'), 1); } - - /** + + return $cmodels; +} + +/** * Function: get_content_models_as_option_array * * Description: Returns an associative array of all available content models in Fedora instance @@ -206,36 +204,36 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe function get_content_models_as_option_array() { module_load_include('inc', 'islandora', 'RestConnection'); $rest_connection = new RestConnection(); - require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; - - $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); - $namespaces = explode(':', $allowed_string); - foreach ($namespaces as $namespace) { - if ($namespace) { - $allowed[] = trim($namespace); - } + require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; + + $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $namespaces = explode(':', $allowed_string); + foreach ($namespaces as $namespace) { + if ($namespace) { + $allowed[] = trim($namespace); } - $query = 'select $object $title from <#ri> + } + $query = 'select $object $title from <#ri> where ($object $title and ($object or $object ) and $object ) order by $title'; - - $list = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); - $options = array(); - foreach ($list as $item) { //removes blanks - if ($item) { - $item_namespace = explode(':', $item['object']['value']); - if (!$restricted || in_array($item_namespace[0], $allowed)) { - - if (!preg_match('/fedora-system/', $item['object']['value'])) { - $options[$item['object']['value']] = $item['title']['value'] . ' ~ ' . $item['object']['value']; - } - } + + $list = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); + $options = array(); + foreach ($list as $item) { //removes blanks + if ($item) { + $item_namespace = explode(':', $item['object']['value']); + if (!$restricted || in_array($item_namespace[0], $allowed)) { + + if (!preg_match('/fedora-system/', $item['object']['value'])) { + $options[$item['object']['value']] = $item['title']['value'] . ' ~ ' . $item['object']['value']; } + } } + } - return $options; + return $options; } \ No newline at end of file diff --git a/islandora_basic_collection/includes/CollectionManagerTable.inc b/islandora_basic_collection/includes/collection_manager_table.inc similarity index 99% rename from islandora_basic_collection/includes/CollectionManagerTable.inc rename to islandora_basic_collection/includes/collection_manager_table.inc index 7172652c..63a91b25 100644 --- a/islandora_basic_collection/includes/CollectionManagerTable.inc +++ b/islandora_basic_collection/includes/collection_manager_table.inc @@ -2,7 +2,7 @@ /** * @file - * CollectionManagerTable.inc + * collection_manager_table.inc */ /** diff --git a/islandora_basic_collection/includes/DeleteCollection.inc b/islandora_basic_collection/includes/delete_collection.inc similarity index 97% rename from islandora_basic_collection/includes/DeleteCollection.inc rename to islandora_basic_collection/includes/delete_collection.inc index 990f84fd..3f0e441c 100644 --- a/islandora_basic_collection/includes/DeleteCollection.inc +++ b/islandora_basic_collection/includes/delete_collection.inc @@ -13,7 +13,7 @@ * @return string */ function islandora_collection_deletion_form($form, &$form_state, $pid) { - module_load_include('inc', 'islandora_basic_collection', 'CollectionManagerTable'); + module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table'); $potential_collections = get_collections_as_option_array(); $table = islandora_collection_table($pid); $deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection"; diff --git a/islandora_basic_collection/includes/ManagePolicies.inc b/islandora_basic_collection/includes/manage_policies.inc similarity index 97% rename from islandora_basic_collection/includes/ManagePolicies.inc rename to islandora_basic_collection/includes/manage_policies.inc index 413e6fa8..3b6572c9 100644 --- a/islandora_basic_collection/includes/ManagePolicies.inc +++ b/islandora_basic_collection/includes/manage_policies.inc @@ -40,6 +40,7 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) { $collection_policy = new CollectionPolicy($collection_policy_string->content); $supported_collection_models = $collection_policy->getContentModels(); } + $collection_namespace = substr($collection_pid, 0, strpos($collection_pid, ":")); $represented_content_models = get_represented_content_models($collection_pid); @@ -58,11 +59,16 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) { $new_options = array_diff_key($new_content_models, $current_models_in_policy); } + $s = ''; + if (count($current_models_in_policy) > 1) { + $s = 's'; + } + $form['manage_collection_policy']['titlebox'] = array( '#type' => 'item', '#title' => t("Manage collection policy for @collection_pid", array('@collection_pid' => $collection_pid)), - ); - + ); + $form ['manage_collection_policy']['add']['content_model_to_add'] = array( '#title' => "Choose content model", '#type' => 'select', @@ -111,7 +117,7 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) { $form['manage_collection_policy']['remove']['submit'] = array( '#type' => 'submit', - '#value' => t('Remove content model from collection policy'), + '#value' => t('Remove content model@s from collection policy', array('@s' => $s)), '#id' => 'remove_cm' ); } @@ -119,7 +125,7 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) { } function islandora_manage_policies_form_validate($form, &$form_state) { - + } /** @@ -196,7 +202,7 @@ function islandora_manage_policies_form_submit($form, &$form_state) { } } - if ($found !== FALSE && $models->length > 1) { + if ($found !== FALSE && $models->length > 0) { $content_models_element->item(0)->removeChild($found); $ret = TRUE; } diff --git a/islandora_basic_collection/includes/MoveCollection.inc b/islandora_basic_collection/includes/move_collection.inc similarity index 95% rename from islandora_basic_collection/includes/MoveCollection.inc rename to islandora_basic_collection/includes/move_collection.inc index e429d3a5..7f6a2d6f 100644 --- a/islandora_basic_collection/includes/MoveCollection.inc +++ b/islandora_basic_collection/includes/move_collection.inc @@ -14,7 +14,7 @@ * @return string */ function islandora_collection_migrate_form($form, &$form_state, $pid) { - module_load_include('inc', 'islandora_basic_collection', 'CollectionManagerTable'); + module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table'); $potential_collections = get_collections_as_option_array(); $table = islandora_collection_table($pid); if (!$table) { diff --git a/islandora_basic_collection/islandora_basic_collection.module b/islandora_basic_collection/islandora_basic_collection.module index 83ebfe24..69837a18 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -92,13 +92,13 @@ function islandora_basic_collection_menu_local_tasks_alter(&$data, $router_item, */ function islandora_basic_collection_manage_object($object_id) { - module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionManagement'); - module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionManagerTable'); - module_load_include('inc', 'islandora_basic_collection', 'includes/DeleteCollection'); - module_load_include('inc', 'islandora_basic_collection', 'includes/MoveCollection'); - module_load_include('inc', 'islandora_basic_collection', 'includes/ChildCollection'); - module_load_include('inc', 'islandora_basic_collection', 'includes/ManagePolicies'); - module_load_include('inc', 'islandora_basic_collection', 'includes/ChangeContentModels'); + module_load_include('inc', 'islandora_basic_collection', 'includes/collection_management'); + module_load_include('inc', 'islandora_basic_collection', 'includes/collection_manager_table'); + module_load_include('inc', 'islandora_basic_collection', 'includes/delete_collection'); + module_load_include('inc', 'islandora_basic_collection', 'includes/move_collection'); + module_load_include('inc', 'islandora_basic_collection', 'includes/child_collection'); + module_load_include('inc', 'islandora_basic_collection', 'includes/manage_policies'); + module_load_include('inc', 'islandora_basic_collection', 'includes/change_content_models'); $form = array(); @@ -216,7 +216,7 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) { 'islandora_basic_collection_management_form_table' => array( 'file' => 'theme/islandora_basic_collection.theme.inc', 'arguments' => array('element' => NULL), - 'file' => 'includes/CollectionManagerTable.inc', + 'file' => 'includes/collection_manager_table.inc', ), ); } diff --git a/islandora_basic_image/islandora-basic-image.tpl.php b/islandora_basic_image/islandora-basic-image.tpl.php index 74d183b0..fe548d6b 100644 --- a/islandora_basic_image/islandora-basic-image.tpl.php +++ b/islandora_basic_image/islandora-basic-image.tpl.php @@ -21,28 +21,34 @@ * along with the program. If not, see . */ ?> - + + +
TRUE)); ?> - - + + +
-

-

-

-
-

In Collections

-
    - $value): ?> -
  • - -
-
+ +

+

+ + +
+

In Collections

+
    + $value): ?> +
  • + +
+
+