Skip to content

Commit

Permalink
Merge pull request #1 from Islandora/7.x
Browse files Browse the repository at this point in the history
7.x update
  • Loading branch information
qadan committed Nov 8, 2013
2 parents 798ba7e + 6cec970 commit 9a4b5cc
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ branches:
env:
- FEDORA_VERSION="3.5"
- FEDORA_VERSION="3.6.2"
- FEDORA_VERSION="3.7.0"
before_install:
- export ISLANDORA_DIR=$TRAVIS_BUILD_DIR
- $TRAVIS_BUILD_DIR/tests/scripts/travis_setup.sh
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ REQUIREMENTS
The Tuque library must be installed to use Islandora. It can be found here:
http://github.com/Islandora/tuque
It is expected to be in one of two paths:
- sites/all/libraries/tuque (libraries directory may need to be created)
- sites/all/libraries/tuque (libraries directory may need to be created)
- islandora_folder/libraries/tuque

OPTIONAL REQUIREMENTS
---------------------

If you want to support languages other than English download and enable
[String Translation](https://drupal.org/project/i18n), And follow our
[guide](wiki/Multilingual-Support) for setting up additional languges.


INSTALLATION
------------

Expand Down
14 changes: 13 additions & 1 deletion includes/derivatives.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@ function islandora_derivative_logging(array $logging_results) {
foreach ($logging_results as $result) {
foreach ($result['messages'] as $message) {
if ($message['type'] === 'dsm') {
drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), isset($message['severity']) ? $message['severity'] : 'status');
if (isset($message['severity']) && $message['severity'] != 'status') {
drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), $message['severity']);
}
else {
if (!isset($_SESSION['islandora_event_messages'])) {
$_SESSION['islandora_event_messages'] = array();
}
$_SESSION['islandora_event_messages'][] = array(
'message' => filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())),
'severity' => 'status',
);
drupal_set_message(l(t('Derivatives successfully created.'), 'islandora/event-status'), 'status', FALSE);
}
}
else {
// We know what we are doing here. Passing through the translated
Expand Down
8 changes: 5 additions & 3 deletions includes/dublin_core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ class DublinCore {
}
$dc_label = explode(':', $field);
$element_label = drupal_ucfirst($dc_label[1]);
$dc_array[$field]['label'] = $element_label;
$dc_array[$field]['value'] = $value;
$i18n_object_id = drupal_strtolower($element_label);
$dc_array[$field]['label'] = function_exists('i18n_string') ?
i18n_string("islandora:dc:{$i18n_object_id}:label", $element_label) :
$element_label;
$dc_array[$field]['value'] = filter_xss($value);
$dc_array[$field]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field));
$dc_array[$field]['dcterms'] = preg_replace('/^dc/', 'dcterms', $field);
}
Expand All @@ -140,7 +143,6 @@ class DublinCore {
return $dc_array;
}


/**
* Creates a new instance of the class by parsing dc_xml.
*
Expand Down
3 changes: 3 additions & 0 deletions includes/ingest.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ function islandora_ingest_form_submit(array $form, array &$form_state) {
try {
islandora_add_object($object);
$form_state['redirect'] = "islandora/object/{$object->id}";
drupal_set_message(
t('"@label" (ID: @pid) has been ingested.', array('@label' => $object->label, '@pid' => $object->id)),
'status');
}
catch (Exception $e) {
// If post hooks throws it may already exist at this point but may be
Expand Down
57 changes: 57 additions & 0 deletions includes/utilities.inc
Original file line number Diff line number Diff line change
Expand Up @@ -924,3 +924,60 @@ function islandora_sanitize_input_for_valid_xml($input, $replacement = '') {
$input = preg_replace('/[^\x9\xA\xD\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', $replacement, $input);
return $input;
}

/**
* Page callback for session status messages to be sent to drupal_set_message().
*
* @return array
* Render array containing markup.
*/
function islandora_event_status() {
$results = FALSE;
if (isset($_SESSION['islandora_event_messages'])) {
foreach ($_SESSION['islandora_event_messages'] as $message) {
drupal_set_message($message['message'], $message['severity']);
$results = TRUE;
}
unset($_SESSION['islandora_event_messages']);
}
$text = ($results) ? t('The status messages above will be deleted after viewing this page.') : t('No messages to display.');
return array('#markup' => $text);
}

/**
* Scales the given image.
*
* @param object $file
* The image file to scale.
* @param int $width
* The width to scale the derived image to.
* @param int $height
* The height to scale the derived image to.
*
* @return bool
* TRUE if successful, FALSE otherwise.
*/
function islandora_scale_thumbnail($file, $width, $height) {
$real_path = drupal_realpath($file->uri);
$image = image_load($real_path);
try {
if (!empty($image)) {
$scale = image_scale($image, $width, $height, TRUE);
if ($scale) {
return image_save($image);
}
}
}
catch (exception $e) {
drupal_set_message(t(
"Islandora failed to scale image with message: '@message'",
array("@message" => $e->getMessage())));
watchdog(
'islandora',
'Islandora failed to scale image.<br/> With stack: @trace',
array('@trace' => $e->getTraceAsString()),
WATCHDOG_ERROR
);
}
return FALSE;
}
2 changes: 2 additions & 0 deletions islandora.info
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name = Islandora
description = "View and manage Fedora objects"
package = Islandora
dependencies[] = image
dependencies[] = file
version = 7.x-dev
core = 7.x
configure = admin/islandora/configure
Expand Down
52 changes: 51 additions & 1 deletion islandora.module
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ function islandora_menu() {
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
'load arguments' => array(2),
);
$items['islandora/event-status'] = array(
'title' => 'Event Status',
'page callback' => 'islandora_event_status',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
'file' => 'includes/utilities.inc',
);
$items[ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE] = array(
'title' => 'Autocomplete callback',
'description' => 'Autocomplete a Fedora content model PID.',
Expand Down Expand Up @@ -525,6 +532,48 @@ function islandora_permission() {
);
}

/**
* Implements hook_i18n_string_info().
*/
function islandora_i18n_string_info() {
return array(
'islandora' => array(
'title' => t('Islandora'),
'description' => t('Translatable Metadata labels, etc.'),
'format' => FALSE,
'list' => TRUE,
),
);
}

/**
* Implements islandora_i18n_string_list().
*/
function islandora_i18n_string_list($group) {
if ($group == 'islandora') {
return array(
'islandora' => array(
'dc' => array(
'title' => array('label' => 'Title'),
'creator' => array('label' => 'Creator'),
'subject' => array('label' => 'Subject'),
'description' => array('label' => 'Description'),
'publisher' => array('label' => 'Publisher'),
'contributor' => array('label' => 'Contributor'),
'date' => array('label' => 'Date'),
'type' => array('label' => 'Type'),
'format' => array('label' => 'Format'),
'identifier' => array('label' => 'Identifier'),
'source' => array('label' => 'Source'),
'language' => array('label' => 'Language'),
'relation' => array('label' => 'Relation'),
'coverage' => array('label' => 'Coverage'),
),
),
);
}
}

/**
* Renders the print page for the given object.
*
Expand Down Expand Up @@ -993,7 +1042,7 @@ function islandora_drupal_title(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb');
drupal_set_breadcrumb(islandora_get_breadcrumbs($object));

return $object->label;
return filter_xss($object->label);
}

/**
Expand Down Expand Up @@ -1585,6 +1634,7 @@ function islandora_datastream_access($op, $datastream, $user = NULL) {
* Implements hook_islandora_basic_collection_get_query_filters().
*/
function islandora_islandora_basic_collection_get_query_filters() {
module_load_include('inc', 'islandora', 'includes/utilities');
$enforced = variable_get('islandora_namespace_restriction_enforced', FALSE);
if ($enforced) {
$namespace_array = islandora_get_allowed_namespaces();
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/travis_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pear install drush/drush-5.9.0
phpenv rehash
drush dl --yes drupal
cd drupal-*
drush si standard --db-url=mysql://drupal:drupal@localhost/drupal --yes
drush si minimal --db-url=mysql://drupal:drupal@localhost/drupal --yes
drush runserver --php-cgi=$HOME/.phpenv/shims/php-cgi localhost:8081 &>/dev/null &
ln -s $ISLANDORA_DIR sites/all/modules/islandora
mv sites/all/modules/islandora/tests/travis.test_config.ini sites/all/modules/islandora/tests/test_config.ini
Expand Down
6 changes: 3 additions & 3 deletions theme/islandora-dublin-core-display.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<dl xmlns:dcterms="http://purl.org/dc/terms/" class="islandora-inline-metadata islandora-metadata-fields">
<?php $row_field = 0; ?>
<?php foreach($dc_array as $key => $value): ?>
<dt property="<?php print $value['dcterms']; ?>" content="<?php print $value['value']; ?>" class="<?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $value['label']; ?>
<dt property="<?php print $value['dcterms']; ?>" content="<?php print filter_xss($value['value']); ?>" class="<?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print filter_xss($value['label']); ?>
</dt>
<dd class="<?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $value['value']; ?>
<?php print filter_xss($value['value']); ?>
</dd>
<?php $row_field++; ?>
<?php endforeach; ?>
Expand Down
6 changes: 3 additions & 3 deletions theme/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
);
$row[] = array(
'class' => 'datastream-label',
'data' => $ds->label,
'data' => filter_xss($ds->label),
);
$row[] = array(
'class' => 'datastream-control',
'data' => islandora_control_group_to_human_readable($ds->controlGroup),
);
$row[] = array(
'class' => 'datastream-mime',
'data' => $ds->mimeType,
'data' => filter_xss($ds->mimeType),
);
$row[] = array(
'class' => 'datastream-size',
Expand Down Expand Up @@ -81,7 +81,7 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
);
$rows[] = $row;
}
$caption = $islandora_object->label . ' - ' . $islandora_object->id;
$caption = filter_xss($islandora_object->label) . ' - ' . $islandora_object->id;
$table = array(
'colgroups' => NULL,
'sticky' => TRUE,
Expand Down

0 comments on commit 9a4b5cc

Please sign in to comment.