Browse Source

merge conflicts removed

pull/38/head
Alan Stanley 13 years ago
parent
commit
ee39a4d798
  1. 5
      CollectionClass.inc
  2. 58
      MimeClass.inc
  3. 6
      ObjectHelper.inc
  4. 4
      README
  5. 2
      api/fedora_item.inc
  6. 96
      api/fedora_utils.inc
  7. 1
      fedora_repository.info
  8. 28
      fedora_repository.module

5
CollectionClass.inc

@ -515,6 +515,7 @@ class CollectionClass {
// Check the form post to see if we are in the middle of an ingest operation.
$show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form');
$add_to_collection = $this->getIngestInterface();
$show_batch_tab = TRUE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
$content_models = $policy->getContentModels();
@ -525,6 +526,10 @@ class CollectionClass {
$view_selected = true;
}
$view_selected = !$show_ingest_tab;
drupal_set_message();
$tabset['view_tab'] = array(
'#type' => 'tabpage',

58
MimeClass.inc

@ -301,21 +301,23 @@ class MimeClass {
*/
private function system_mime_type_extensions() {
$out = array();
$file = fopen($this->etc_mime_types, 'r');
while (($line = fgets($file)) !== FALSE) {
$line = trim(preg_replace('/#.*/', '', $line));
if (!$line)
continue;
$parts = preg_split('/\s+/', $line);
if (count($parts) == 1)
continue;
// A single part means a mimetype without extensions, which we ignore.
$type = array_shift($parts);
if (!isset($out[$type]))
$out[$type] = array_shift($parts);
// We take the first ext from the line if many are present.
if (file_exists($this->etc_mime_types)) {
$file = fopen($this->etc_mime_types, 'r');
while (($line = fgets($file)) !== FALSE) {
$line = trim(preg_replace('/#.*/', '', $line));
if (!$line)
continue;
$parts = preg_split('/\s+/', $line);
if (count($parts) == 1)
continue;
// A single part means a mimetype without extensions, which we ignore.
$type = array_shift($parts);
if (!isset($out[$type]))
$out[$type] = array_shift($parts);
// We take the first ext from the line if many are present.
}
fclose($file);
}
fclose($file);
return $out;
}
@ -328,20 +330,22 @@ class MimeClass {
*/
private function system_extension_mime_types() {
$out = array();
$file = fopen($this->etc_mime_types, 'r');
while (($line = fgets($file)) !== FALSE) {
$line = trim(preg_replace('/#.*/', '', $line));
if (!$line)
continue;
$parts = preg_split('/\s+/', $line);
if (count($parts) == 1)
continue;
// A single part means a mimetype without extensions, which we ignore.
$type = array_shift($parts);
foreach ($parts as $part)
$out[$part] = $type;
if (file_exists($this->etc_mime_types)) {
$file = fopen($this->etc_mime_types, 'r');
while (($line = fgets($file)) !== FALSE) {
$line = trim(preg_replace('/#.*/', '', $line));
if (!$line)
continue;
$parts = preg_split('/\s+/', $line);
if (count($parts) == 1)
continue;
// A single part means a mimetype without extensions, which we ignore.
$type = array_shift($parts);
foreach ($parts as $part)
$out[$part] = $type;
}
fclose($file);
}
fclose($file);
return $out;
}

6
ObjectHelper.inc

@ -601,7 +601,7 @@ class ObjectHelper {
$namespaceAccess = TRUE;
}
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
$pid = variable_get('fedora_repository_pid', 'islandora:root');
}
$nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$pos = NULL;
@ -923,7 +923,7 @@ class ObjectHelper {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
// Before executing the query, we hve a base case of accessing the top-level collection
global $base_url;
if ($pid == variable_get('fedora_repository_pid', 'islandora:top')) {
if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
}
@ -949,7 +949,7 @@ class ObjectHelper {
$parent = preg_replace('/^info:fedora\//', '', $matches[0]);
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) {
if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
}

4
README

@ -4,10 +4,6 @@ For installation and customization instructions please see the documentation and
https://wiki.duraspace.org/display/ISLANDORA/Islandora
Specifically the Islandora Guide:
https://wiki.duraspace.org/display/ISLANDORA/Islandora+Guide
All bugs, feature requests and improvement suggestions are tracked at the DuraSpace JIRA:
https://jira.duraspace.org/browse/ISLANDORA

2
api/fedora_item.inc

@ -145,7 +145,7 @@ class Fedora_Item {
* @return type
*/
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = NULL) {
$dir = sys_get_temp_dir();
$dir = file_directory_temp();
$tmpfilename = tempnam($dir, 'fedoratmp');
$tmpfile = fopen($tmpfilename, 'w');
fwrite($tmpfile, $str, strlen($str));

96
api/fedora_utils.inc

@ -30,17 +30,76 @@ if (!function_exists('str_getcsv')) {
}
/**
* do curl
* @global type $user
* @param type $url
* @param type $return_to_variable
* @param type $number_of_post_vars
* @param type $post
* @return type
*
* Utility method to get data from a url location using curl_exec and return
*
* This method takes identical parameters to do_curl_ext and passes them
* directly to do_curl_ext. The output from do_curl_ext is processed into
* either a TRUE, FALSE, or NULL value.
*
* This method exists for historical reasons as existing code makes use of
* do_curl directly and expects a simple return value and not an array.
*
* @param $url
* URL to be accessed by the function
* @param $return_to_variable
* Indicates whether the resource accessed by the curl call (HTML page,
* XML page, etc.) is returned directly from the function to the calling
* program or if it is sent directly to output.
* @param $number_of_post_vars
* Number of variable sot be posted
* @param $post
* Whether the curl_exec is done as a "get" or a "post"
*
* @return
* TRUE, FALSE, NULL, or the data returned from accessing the URL
*/
function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) {
$return_array = do_curl_ext($url, $return_to_variable, $number_of_post_vars, $post);
return ($return_array != NULL) ? $return_array[0] : NULL;
}
/**
*
* Utility method to get data from a url location using curl_exec
*
* This method takes a URL and three associated parameters and initializes the
* structure required to make a call to curl_exec. As a part of the
* initialization the permissions associated with the (global) user are added
* to the call. This ensures access to any potentially user restricted URLs.
*
* Various defaults are used for the parameters required by curl_exec including
* the user agent and timeout. These are hard-coded.
*
* @param $url
* URL to be accessed by the function
* @param $return_to_variable
* Indicates whether the resource accessed by the curl call (HTML page,
* XML page, etc.) is returned directly from the function to the calling
* program or if it is sent directly to output.
* @param $number_of_post_vars
* Number of variable sot be posted
* @param $post
* Whether the curl_exec is done as a "get" or a "post"
*
* @return
* an array that consists of three value or NULL if curl is not suported:
* - element 0:
* The value returned from the curl_exec function call.
* This is either a TRUE or FALSE value or the actual data returned from
* accessing the URL.
* - element 1:
* The error code reslting from attempting to access the URL with curl_exec
* - element 2:
* A string representing a textual representation of the error code that
* resulted from attempting to access the URL with curl_exec
*/
function do_curl_ext($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) {
global $user;
// Check if we are inside Drupal and there is a valid user.
// If the user is not valid for a Fedora call curl will throw an exception.
if ((!isset($user)) || $user->uid == 0) {
$fedora_user = 'anonymous';
$fedora_pass = 'anonymous';
@ -67,8 +126,14 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
curl_setopt($ch, CURLOPT_POST, $number_of_post_vars);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$post");
}
return curl_exec($ch);
$ret_val = curl_exec($ch);
$error_code = curl_errno($ch);
$error_string = curl_error($ch);
return array ($ret_val, $error_code, $error_string);
}
else {
if (function_exists(drupal_set_message)) {
drupal_set_message(t('No curl support.'), 'error');
@ -83,10 +148,21 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
*/
function fedora_available() {
$response = do_curl(variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/describe');
return strstr($response, 'Repository Information HTML Presentation') !== FALSE;
$response = do_curl_ext(variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/describe');
return ($response != NULL) ? ($response[1] == 0) : FALSE;
}
/**
* Resource index search available
* @return type
*/
function risearch_available() {
$response = do_curl_ext(variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'));
return ($response != NULL) ? ($response[1] == 0): FALSE;
}
/**
* Returns a UTF-8-encoded transcripiton of the string given in $in_str.
* @param string $in_str

1
fedora_repository.info

@ -2,6 +2,7 @@
name = Digital Repository
dependencies[] = imageapi
dependencies[] = tabs
dependencies[] = islandora_content_model_forms
description = Shows a list of items in a fedora collection.
package = Islandora
version = 11.2.beta1

28
fedora_repository.module

@ -82,7 +82,7 @@ function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pag
$objectHelper = new ObjectHelper();
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
$pid = variable_get('fedora_repository_pid', 'islandora:root');
}
$content = '';
@ -909,13 +909,19 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
return '';
}
if (!risearch_available()) {
drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE);
return '';
}
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
$pid = variable_get('fedora_repository_pid', 'islandora:root');
}
$item = new fedora_item($pid);
if (!$item->exists()) {
drupal_not_found();
exit();
}
if ($pid & !valid_pid($pid)) {
@ -938,7 +944,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
$objectHelper = new ObjectHelper();
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
$pid = variable_get('fedora_repository_pid', 'islandora:root');
}
$headers = module_invoke_all('file_download', "/fedora/repository/$pid");
if (in_array(-1, $headers)) {
@ -1056,7 +1062,7 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU
return ' ';
}
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
$pid = variable_get('fedora_repository_pid', 'islandora:root');
}
$headers = module_invoke_all('file_download', "/fedora/repository/$pid");
if (in_array(-1, $headers)) {
@ -1452,7 +1458,7 @@ function fedora_repository_demo_objects_form() {
foreach (array(
'islandora:collectionCModel' => 'Islandora default content models',
'islandora:top' => 'Islandora top-level collection',
'islandora:root' => 'Islandora top-level collection',
'islandora:demos' => 'Islandora demos collection',
'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)',
)
@ -1559,7 +1565,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain');
$cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:top');
$cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:root');
$cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
$cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X');
$cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M');
@ -1569,13 +1575,13 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
}
}
if (!empty($form_state['values']['demo_collections']['islandora:top'])) {
$new_item = Fedora_Item::ingest_new_item('islandora:top', 'A', 'Islandora Top-level Collection');
if (!empty($form_state['values']['demo_collections']['islandora:root'])) {
$new_item = Fedora_Item::ingest_new_item('islandora:root', 'A', 'Islandora Top-level Collection');
$new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
$cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X');
try {
$tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:top\">islandora:top</a>."), 'message');
drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:root\">islandora:root</a>."), 'message');
} catch (exception $e) {
}
@ -1583,7 +1589,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
if (!empty($form_state['values']['demo_collections']['islandora:demos'])) {
$new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection');
$new_item->add_relationship('isMemberOfCollection', 'islandora:top');
$new_item->add_relationship('isMemberOfCollection', 'islandora:root');
$new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
$cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X');
@ -2147,7 +2153,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : '';
if (empty($object['foxml_file']) && !defined($new_item)) {
if (empty($object['foxml_file']) && !isset($new_item)) {
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
}
if (!empty($object['cmodel'])) {

Loading…
Cancel
Save