diff --git a/includes/add_datastream.form.inc b/includes/add_datastream.form.inc index 33decefc..dd5b0dbb 100644 --- a/includes/add_datastream.form.inc +++ b/includes/add_datastream.form.inc @@ -22,6 +22,10 @@ function islandora_add_datastream_form(array $form, array &$form_state, Abstract module_load_include('inc', 'islandora', 'includes/content_model'); module_load_include('inc', 'islandora', 'includes/utilities'); form_load_include($form_state, 'inc', 'islandora', 'includes/add_datastream.form'); + $form_state['object_id'] = $object->id; + + // @deprecated Storing objects in $form_state is asking for a bad time... + // Causes issues with derivative generation when we try to use it. $form_state['object'] = $object; $form_state['datastream_requirements'] = islandora_get_missing_datastreams_requirements($object); $unused_datastreams = array_keys($form_state['datastream_requirements']); @@ -93,7 +97,8 @@ function islandora_add_datastream_form(array $form, array &$form_state, Abstract * The Drupal form. */ function islandora_add_datastream_form_field_is_not_an_existing_datastream_id(array $element, array &$form_state, array $form) { - if (isset($form_state['object'][$element['#value']])) { + $object = islandora_object_load($form_state['object_id']); + if (isset($object[$element['#value']])) { form_error($element, t("@title already exists in the object.", array('@title' => $element['#title']))); } } @@ -183,7 +188,7 @@ function islandora_add_datastream_form_validate(array $form, array &$form_state) * The Drupal form state. */ function islandora_add_datastream_form_submit(array $form, array &$form_state) { - $object = $form_state['object']; + $object = islandora_object_load($form_state['object_id']); $form_state['redirect'] = "islandora/object/{$object->id}"; $file = file_load($form_state['values']['file']); try { diff --git a/includes/datastream.inc b/includes/datastream.inc index 26a7a8d5..ba2872c2 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -56,9 +56,12 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F $extension = '.' . $mime_detect->getExtension($datastream->mimetype); // Prevent adding on a duplicate extension. + $label = $datastream->label; $extension_length = strlen($extension); - $duplicate_extension_position = strripos($datastream->label, $extension, -$extension_length); - $filename = $datastream->label; + $duplicate_extension_position = strlen($label) > $extension_length ? + strripos($label, $extension, -$extension_length) : + FALSE; + $filename = $label; if ($duplicate_extension_position === FALSE) { $filename .= $extension; } diff --git a/includes/mime_type.autocomplete.inc b/includes/mime_type.autocomplete.inc new file mode 100644 index 00000000..3ac31079 --- /dev/null +++ b/includes/mime_type.autocomplete.inc @@ -0,0 +1,27 @@ +getMimeTypes(); + $output = array(); + foreach ($mime_types as $mime_type) { + if (preg_match("/{$string}/i", $mime_type) !== 0) { + $output[$mime_type] = $mime_type; + } + } + return drupal_json_output($output); +} diff --git a/includes/regenerate_derivatives.form.inc b/includes/regenerate_derivatives.form.inc index a7ef147c..7fd8d059 100644 --- a/includes/regenerate_derivatives.form.inc +++ b/includes/regenerate_derivatives.form.inc @@ -99,7 +99,7 @@ function islandora_regenerate_object_derivatives_batch(AbstractObject $object) { 'title' => t('Regenerating all derivatives for @label', array('@label' => $object->label)), 'operations' => islandora_do_batch_derivatives($object, array('force' => TRUE)), 'init_message' => t('Preparing to regenerate derivatives...'), - 'progress_message' => t('Time elapsed: @elapsed
Estimated time remaning @estimate.'), + 'progress_message' => t('Time elapsed: @elapsed
Estimated time remaining @estimate.'), 'error_message' => t('An error has occurred.'), 'file' => drupal_get_path('module', 'islandora') . '/includes/regenerate_derivatives.form.inc', 'finished' => 'islandora_regenerate_derivative_batch_finished', @@ -124,7 +124,7 @@ function islandora_regenerate_datastream_derivative_batch(AbstractDatastream $da 'destination_dsid' => $datastream->id, )), 'init_message' => t('Preparing to regenerate derivatives...'), - 'progress_message' => t('Time elapsed: @elapsed
Estimated time remaning @estimate.'), + 'progress_message' => t('Time elapsed: @elapsed
Estimated time remaining @estimate.'), 'error_message' => t('An error has occurred.'), 'file' => drupal_get_path('module', 'islandora') . '/includes/regenerate_derivatives.form.inc', 'finished' => 'islandora_regenerate_derivative_batch_finished', diff --git a/includes/tuque_wrapper.inc b/includes/tuque_wrapper.inc index 98e9c62c..d30af147 100644 --- a/includes/tuque_wrapper.inc +++ b/includes/tuque_wrapper.inc @@ -298,7 +298,14 @@ class IslandoraFedoraApiM extends FedoraApiM { default: $ret = parent::purgeDatastream($pid, $dsid, $params); - islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_PURGED_HOOK, $object->models, $dsid, $object, $dsid); + // We need to remove this object from the cache and reload it as + // Tuque may not have an updated copy. That is the datastream could + // still be present within the object even though it's purged out of + // Fedora. + $tuque = islandora_get_tuque_connection(); + $tuque->cache->delete($pid); + $non_cached_object = islandora_object_load($pid); + islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_PURGED_HOOK, $non_cached_object->models, $dsid, $non_cached_object, $dsid); return $ret; } } diff --git a/includes/utilities.inc b/includes/utilities.inc index d858ff0c..e5d60b95 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -528,7 +528,7 @@ function islandora_display_repository_inaccessible_message() { $link = l($text, 'admin/islandora/configure', array('attributes' => array('title' => $text))); $message = t('Could not connect to the repository. Please check the settings on the !link page.', array('!link' => $link)); - drupal_set_message(check_plain($message), 'error', FALSE); + drupal_set_message(filter_xss($message), 'error', FALSE); } @@ -981,3 +981,17 @@ function islandora_scale_thumbnail($file, $width, $height) { } return FALSE; } + +/** + * Determines if the server operating system is Windows. + * + * @return bool + * TRUE if Windows, FALSE otherwise. + */ +function islandora_deployed_on_windows() { + // Determine if PHP is currently running on Windows. + if (strpos(strtolower(php_uname('s')), 'windows') !== FALSE) { + return TRUE; + } + return FALSE; +} diff --git a/islandora.api.php b/islandora.api.php index 51aeb343..0534ffe7 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -466,6 +466,19 @@ function hook_islandora_ingest_steps(array $form_state) { ), ); } + +/** + * Alter the generated ingest steps. + * + * @param array $steps + * An array of steps as generated by hook_islandora_ingest_steps(). + * + * @param array $form_state + * An array containing the Drupal form_state. + */ +function hook_islandora_ingest_steps_alter(array &$steps, array &$form_state) { +} + /** * Content model specific version of hook_islandora_ingest_steps(). * @@ -479,6 +492,18 @@ function hook_islandora_ingest_steps(array $form_state) { function hook_CMODEL_PID_islandora_ingest_steps(array $form_state) { } +/** +* Alter the generated ingest steps for the given content model. + * + * @param array $steps + * An array of steps as generated by hook_islandora_ingest_steps(). + * + * @param array $form_state + * An array containing the Drupal form_state. + */ +function hook_CMODEL_PID_islandora_ingest_steps_alter(array &$steps, array &$form_state) { +} + /** * Object-level access callback hook. * diff --git a/islandora.drush.inc b/islandora.drush.inc index 6ba73cb5..876f6e39 100644 --- a/islandora.drush.inc +++ b/islandora.drush.inc @@ -70,7 +70,23 @@ function islandora_drush_command() { ), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, ); - + $commands['islandora-solution-pack-install-content_models'] = array( + 'description' => dt('Install Solution Pack content models.'), + 'options' => array( + 'module' => array( + 'description' => dt('The module for which to install the content models.'), + 'required' => TRUE, + ), + ), + 'aliases' => array('ispicm'), + 'drupal dependencies' => array( + 'islandora', + ), + 'examples' => array( + 'drush -u 1 ispicm --module=islandora' => dt('Install missing solution pack objects for the "islandora" module.'), + ), + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, + ); return $commands; } @@ -83,9 +99,7 @@ function drush_islandora_solution_pack_install_required_objects() { $module = drush_get_option('module'); if (module_exists($module)) { islandora_install_solution_pack( - $module, - 'install', - drush_get_option('force', FALSE) + $module, 'install', drush_get_option('force', FALSE) ); } else { @@ -104,8 +118,7 @@ function drush_islandora_solution_pack_uninstall_required_objects() { $module = drush_get_option('module'); if (module_exists($module)) { islandora_uninstall_solution_pack( - $module, - drush_get_option('force', FALSE) + $module, drush_get_option('force', FALSE) ); } else { @@ -152,3 +165,37 @@ function drush_islandora_solution_pack_required_objects_status() { drush_print_table($rows, $header, $widths); } } + +/** + * Command callback to install required objects. + */ +function drush_islandora_solution_pack_install_content_models() { + module_load_include('inc', 'islandora', 'includes/solution_packs'); + $module = drush_get_option('module'); + if (module_exists($module)) { + $info = islandora_solution_packs_get_required_objects($module); + $objects_to_add = array(); + foreach ($info['objects'] as $key => $candidate) { + if (in_array('fedora-system:ContentModel-3.0', $candidate->models)) { + $objects_to_add[] = $candidate; + } + } + if (count($objects_to_add) > 0) { + foreach ($objects_to_add as $object_to_add) { + $old_object = islandora_object_load($object_to_add->id); + if ($old_object) { + $deleted = islandora_delete_object($old_object); + if (!$deleted) { + drush_log(dt('@object did not delete.', array('@object' => $old_object->id), 'error')); + continue; + } + } + $new_object = islandora_add_object($object_to_add); + $verb = $deleted ? dt("Replaced") : dt("Added"); + if ($new_object) { + drush_print("$verb " . $object_to_add->id . " - " . $object_to_add->label); + } + } + } + } +} diff --git a/islandora.module b/islandora.module index 8e480baa..9e7809eb 100644 --- a/islandora.module +++ b/islandora.module @@ -62,6 +62,7 @@ define('ISLANDORA_DERVIATIVE_CREATION_HOOK', 'islandora_derivative'); // Autocomplete paths. define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models'); +define('ISLANDORA_MIME_TYPES_AUTOCOMPLETE', 'islandora/autocomplete/mime-types'); /** * @deprecated Constants. @@ -358,6 +359,15 @@ function islandora_menu() { 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, ); + $items[ISLANDORA_MIME_TYPES_AUTOCOMPLETE] = array( + 'title' => 'Autocomplete callback', + 'description' => 'Autocomplete MIME Types.', + 'file' => 'includes/mime_type.autocomplete.inc', + 'page callback' => 'islandora_mime_type_autocomplete', + 'page arguments' => array(3), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_CALLBACK, + ); $items['admin/islandora/restore/prep'] = array( 'description' => 'Restore or permanantly remove objects with Deleted status', 'title' => 'Manage Deleted Objects', @@ -870,7 +880,8 @@ function islandora_object_manage_access_callback($perms, $object = NULL) { function islandora_manage_overview_object(AbstractObject $object) { module_load_include('inc', 'islandora', 'includes/utilities'); $output = array(); - foreach (islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models) as $hook) { + $hooks = islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models); + foreach ($hooks as $hook) { $temp = module_invoke_all($hook, $object); islandora_as_renderable_array($temp); if (!empty($temp)) { @@ -882,7 +893,7 @@ function islandora_manage_overview_object(AbstractObject $object) { $output = islandora_default_islandora_manage_overview_object($object); } arsort($output); - drupal_alter(ISLANDORA_OVERVIEW_HOOK, $object, $output); + drupal_alter($hooks, $object, $output); islandora_as_renderable_array($output); return $output; } @@ -1027,11 +1038,9 @@ function islandora_view_object(AbstractObject $object) { /** * This will prepare an object to be printed. * - * By default, all fedora objects can print DC record data, - * however, Solution packs that wish to modify the form - * to be printed must implement hook_islandora_view_print_object_alter, - * create a theme.tpl.php file, and return its markup by calling - * theme(themename.tpl.php). + * By default all fedora objects can print DC record data. Solution packs that + * wish to modify the data to be printed can implement + * hook_islandora_view_print_object or hook_islandora_metadata_display_info. * * @param AbstractObject $object * The object to print. diff --git a/tests/scripts/travis_setup.sh b/tests/scripts/travis_setup.sh index 3a52bb75..c1bd7751 100755 --- a/tests/scripts/travis_setup.sh +++ b/tests/scripts/travis_setup.sh @@ -21,7 +21,15 @@ pear channel-discover pear.phpqatools.org pear channel-discover pear.netpirates.net pear install pear/PHP_CodeSniffer-1.4.8 pear install pear.phpunit.de/phpcpd -pear install drush/drush-5.9.0 + +# Install Drush +git clone https://github.com/drush-ops/drush.git +pushd drush +git checkout 5.9.0 +chmod +x drush +popd +sudo ln -s $HOME/drush/drush /usr/local/sbin + phpenv rehash drush dl --yes drupal cd drupal-* diff --git a/theme/islandora-object-img-print.tpl.php b/theme/islandora-object-img-print.tpl.php deleted file mode 100644 index 3ff21455..00000000 --- a/theme/islandora-object-img-print.tpl.php +++ /dev/null @@ -1,18 +0,0 @@ - - -
- -
-