Browse Source

Merge pull request #10 from Islandora/7.x

7.x update
pull/576/head
Daniel Aitken 10 years ago
parent
commit
1e759270c3
  1. 65
      includes/breadcrumb.inc
  2. 34
      js/spinner.js
  3. 18
      tests/includes/utilities.inc

65
includes/breadcrumb.inc

@ -77,37 +77,50 @@ function islandora_get_breadcrumbs_recursive($pid, FedoraRepository $repository,
);
}
else {
$query_string = 'select $parentObject $title $content from <#ri>
where (
<info:fedora/' . $pid . '> <fedora-model:label> $title
and $parentObject <fedora-model:hasModel> $content
and (
<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject
)
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>
)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
minus $parentObject <mulgara:is> <info:fedora/' . $pid . '>
order by $title desc';
$results = $repository->ri->itqlQuery($query_string);
if (count($results) > 0 && $context['level'] > 0) {
$parent = $results[0]['parentObject']['value'];
$this_title = $results[0]['title']['value'];
$query = <<<EOQ
PREFIX islandora-rels-ext: <http://islandora.ca/ontology/relsext#>
PREFIX fedora-rels-ext: <info:fedora/fedora-system:def/relations-external#>
SELECT DISTINCT ?object ?label
FROM <#ri>
WHERE {
<info:fedora/!pid> ?collection_predicate ?object;
<fedora-model:label> ?label .
?object <fedora-model:state> <fedora-model:Active>
.
!optionals
!filters
}
EOQ;
if (empty($this_title)) {
$this_title = t('-');
$query_optionals = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_optionals', 'view');
$query_filters = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_filters');
$filter_map = function ($filter) {
return "FILTER($filter)";
};
$query_filters[] = "sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOfCollection>) || sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOf>)";
$query = format_string($query, array(
'!optionals' => !empty($query_optionals) ? ('OPTIONAL {{' . implode('} UNION {', $query_optionals) . '}}') : '',
'!filters' => implode(' ', array_map($filter_map, $query_filters)),
));
$query = format_string($query, array(
'!pid' => $pid,
));
$results = $repository->ri->sparqlQuery($query, 'unlimited');
if (count($results) > 0 && $context['level'] > 0) {
$parent = $results[0]['object']['value'];
$this_label = $results[0]['label']['value'];
if (empty($this_label)) {
$this_label = t('-');
}
$context['level']--;
return array_merge(
islandora_get_breadcrumbs_recursive($parent, $repository, $context),
array(
l($this_title, "islandora/object/$pid"),
)
);
return array_merge(islandora_get_breadcrumbs_recursive($parent, $repository, $context), array(
l($this_label, "islandora/object/$pid"),
));
}
else {
// Add an non-link, as we don't know how to get back to the root, and

34
js/spinner.js

@ -1,9 +1,11 @@
/*jshint browser: true, devel:true*/
/*global jQuery, Drupal, Spinner*/
/**
* @file
* Triggers the display of a spinning icon when the form is submitted.
*/
(function ($) {
'use strict';
Drupal.behaviors.spinner = {
attach: function(context, settings) {
// Store what triggered the submit.
@ -15,35 +17,41 @@
// On enter the first submit button is assumed as is most often the
// case and this is part of the HTML 5 specification, although some
// Browsers may choose the button with the lowest tab-index.
if (event.which == 13) {
if (event.which === 13) {
$(this).data('clicked', $(':submit', this).first());
}
});
});
for (var base in settings.spinner) {
var id = '#' + base;
// Don't add spinner to the hidden next/ingest button.
if (id != '#edit-hidden-next') {
$.each(settings.spinner, function (base, value) {
var id = '#' + base,
message = $('<div/>').text(settings.spinner[base].message);
if (id !== '#edit-hidden-next') {
$(id, context).once('spinner', function () {
var spinner = new Spinner(settings.spinner[base].opts);
$(id).parents('form').one('submit', function (event) {
if ($(this).data('clicked').is(id)) {
$(id).parents('form').submit(function (event) {
// If some other widget is preventing form submission we should
// not attempt to submit at this time.
if (event.isDefaultPrevented()) {
return;
}
if ($(this).data('clicked').is(id) && $(this).data('submitted') === undefined) {
event.preventDefault();
// Prevent this from being entered a second time.
$(this).data('submitted', true);
// Add Message.
var message = $('<div/>').text(settings.spinner[base].message);
$(id).after(message);
// Make UI changes.
spinner.spin(this);
$('#edit-next').hide();
$('#edit-prev').hide();
// Submit the form after a set timeout, this handles problems with
// safari, in that safari submit's immediately..
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
// safari, in that safari submits immediately..
if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
$(':submit').attr('disabled', 'disabled');
}
setTimeout(function () {
// Allow for the button to be clicked, then click it then
// prevent the default behavoir.
// prevent the default behaviour.
$(id).removeAttr('disabled')
.click()
.click(function (event) {
@ -55,7 +63,7 @@
});
});
}
}
});
}
};
})(jQuery);

18
tests/includes/utilities.inc

@ -218,13 +218,14 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
* 'parent' - The PID of the parent collection.
* @param array $datastreams
* An array containing zero or more datastream arrays that use the keys:
* 'dsid' - the datastream ID; randomized if not set.
* 'dsid' - The datastream ID; randomized if not set.
* 'path' - The path to the file to use; defaults to fixtures/test.jpg.
* 'string' - A string to set the datastream from; overrides 'path'.
* 'control_group' - The single-letter control group identifier.
* 'mimetype' - The datastream's mimetype.
*
* @return bool|array
* FALSE if the object ingest failed, or the object array if successful.
* @return bool|AbstractObject
* FALSE if the object ingest failed, or the object if successful.
*/
public function ingestConstructedObject(array $properties = array(), array $datastreams = array()) {
if (!isset($properties['pid'])) {
@ -264,9 +265,6 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
if (!isset($datastream['dsid'])) {
$datastream['dsid'] = DrupalUnitTestCase::randomName();
}
if (!isset($datastream['path'])) {
$datastream['path'] = drupal_get_path('module', 'islandora') . '/tests/fixtures/test.jpg';
}
if (!isset($datastream['control_group'])) {
$new_datastream = $object->constructDatastream($datastream['dsid']);
}
@ -277,7 +275,13 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass {
if (isset($datastream['mimetype'])) {
$new_datastream->mimetype = $datastream['mimetype'];
}
$new_datastream->setContentFromFile($datastream['path']);
if (isset($datastream['string'])) {
$new_datastream->setContentFromString($datastream['string']);
}
else {
$path = isset($datastream['path']) ? $datastream['path'] : drupal_get_path('module', 'islandora') . '/tests/fixtures/test.jpg';
$new_datastream->setContentFromFile($path);
}
$object->ingestDatastream($new_datastream);
}
}

Loading…
Cancel
Save