qadan
11 years ago
15 changed files with 503 additions and 30 deletions
@ -0,0 +1,171 @@
|
||||
<?php |
||||
/** |
||||
* @file |
||||
* Defines functions used when viewing metadata displays on Islandora objects. |
||||
*/ |
||||
|
||||
/** |
||||
* Retrieves the metadata display markup for an Islandora object. |
||||
* |
||||
* @param AbstractObject $object |
||||
* An AbstractObject representing an object within Fedora. |
||||
* @param bool $print |
||||
* Whether the object is being printed. |
||||
* |
||||
* @return string |
||||
* Markup to be rendered for display on Islandora object pages. |
||||
*/ |
||||
function islandora_retrieve_metadata_markup(AbstractObject $object, $print = FALSE) { |
||||
$viewers = module_invoke_all('islandora_metadata_display_info'); |
||||
$viewer = variable_get('islandora_metadata_display', 'dublin_core'); |
||||
$markup = ''; |
||||
if (isset($viewers[$viewer]['metadata callback'])) { |
||||
$markup = call_user_func($viewers[$viewer]['metadata callback'], $object, $print); |
||||
// The callback doesn't have any markup provided for this particular object, |
||||
// default back to the dublin_core display. |
||||
if ($markup === FALSE) { |
||||
$markup = call_user_func($viewers['dublin_core']['metadata callback'], $object, $print); |
||||
} |
||||
} |
||||
return $markup; |
||||
} |
||||
|
||||
/** |
||||
* Retrieves the metadata display description for an Islandora object. |
||||
* |
||||
* @param AbstractObject $object |
||||
* An AbstractObject representing an object within Fedora. |
||||
* |
||||
* @return string |
||||
* Markup to be rendered for description on Islandora object pages. |
||||
*/ |
||||
function islandora_retrieve_description_markup(AbstractObject $object) { |
||||
$viewers = module_invoke_all('islandora_metadata_display_info'); |
||||
$viewer = variable_get('islandora_metadata_display', 'dublin_core'); |
||||
$markup = ''; |
||||
if (isset($viewers[$viewer]['description callback'])) { |
||||
$markup = call_user_func($viewers[$viewer]['description callback'], $object); |
||||
// The callback doesn't have any markup provided for this particular object, |
||||
// default back to the dublin_core display. |
||||
if ($markup === FALSE) { |
||||
$markup = call_user_func($viewers['dublin_core']['description callback'], $object); |
||||
} |
||||
} |
||||
return $markup; |
||||
} |
||||
|
||||
/** |
||||
* Form used for choosing which default metadata display to use for viewing. |
||||
* |
||||
* @param array $form |
||||
* An array representing a Drupal form. |
||||
* @param array $form_state |
||||
* An array containing the Drupal form state. |
||||
* |
||||
* @return array |
||||
* An array representing the metadata display viewer form. |
||||
*/ |
||||
function islandora_metadata_display_form($form, $form_state) { |
||||
module_load_include('inc', 'islandora', 'includes/solution_packs.inc'); |
||||
$form = array(); |
||||
$defined_displays = module_invoke_all('islandora_metadata_display_info'); |
||||
if (!empty($defined_displays)) { |
||||
$no_viewer = array(); |
||||
$no_viewer['none'] = array( |
||||
'label' => t('None'), |
||||
'description' => t("Don't show any metadata for displaying"), |
||||
); |
||||
$viewers = array_merge_recursive($no_viewer, $defined_displays); |
||||
|
||||
$form['viewers'] = array( |
||||
'#type' => 'item', |
||||
'#title' => t('Select a viewer'), |
||||
'#description' => t('Preferred metadata display for Islandora. These may be provided by third-party modules.'), |
||||
'#tree' => TRUE, |
||||
'#theme' => 'islandora_viewers_table', |
||||
); |
||||
|
||||
foreach ($viewers as $name => $profile) { |
||||
$options[$name] = ''; |
||||
$form['viewers']['name'][$name] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => $name, |
||||
); |
||||
$form['viewers']['label'][$name] = array( |
||||
'#type' => 'item', |
||||
'#markup' => $profile['label'], |
||||
); |
||||
$form['viewers']['description'][$name] = array( |
||||
'#type' => 'item', |
||||
'#markup' => $profile['description'], |
||||
); |
||||
$form['viewers']['configuration'][$name] = array( |
||||
'#type' => 'item', |
||||
'#markup' => (isset($profile['configuration']) AND $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '', |
||||
); |
||||
} |
||||
$form['viewers']['default'] = array( |
||||
'#type' => 'radios', |
||||
'#options' => isset($options) ? $options : array(), |
||||
'#default_value' => variable_get('islandora_metadata_display', 'dublin_core'), |
||||
); |
||||
} |
||||
else { |
||||
$form['viewers']['no_viewers'] = array( |
||||
'#markup' => t('No viewers detected.'), |
||||
); |
||||
} |
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t('Save configuration'), |
||||
); |
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Submit handler for the metadata display form which sets the default viewer. |
||||
* |
||||
* @param array $form |
||||
* An array representing a Drupal form. |
||||
* @param array $form_state |
||||
* An array containing the Drupal form state. |
||||
*/ |
||||
function islandora_metadata_display_form_submit($form, $form_state) { |
||||
variable_set('islandora_metadata_display', $form_state['values']['viewers']['default']); |
||||
drupal_set_message(t('The configuration options have been saved.')); |
||||
} |
||||
|
||||
/** |
||||
* Metadata display callback for rendering Dublin Core metadata. |
||||
* |
||||
* @param AbstractObject $object |
||||
* An AbstractObject representing an object within Fedora. |
||||
* @param bool $print |
||||
* Whether the display is being printed or not. |
||||
* |
||||
* @return string |
||||
* Markup representing the rendered metadata from Dublin Core. |
||||
*/ |
||||
function islandora_metadata_display_callback(AbstractObject $object, $print = FALSE) { |
||||
$elements = array( |
||||
'islandora_object' => $object, |
||||
'print' => $print, |
||||
); |
||||
return theme('islandora_dublin_core_display', $elements); |
||||
} |
||||
|
||||
/** |
||||
* Metadata description callback for rendering Dublin Core description. |
||||
* |
||||
* @param AbstractObject $islandora_object |
||||
* An AbstractObject representing an object within Fedora. |
||||
* |
||||
* @return string |
||||
* Markup representing the rendered metadata from Dublin Core. |
||||
*/ |
||||
function islandora_metadata_description_callback(AbstractObject $islandora_object) { |
||||
$elements = array( |
||||
'islandora_object' => $islandora_object, |
||||
); |
||||
return theme('islandora_dublin_core_description', $elements); |
||||
} |
@ -0,0 +1,21 @@
|
||||
The MIT License |
||||
|
||||
Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de] |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
@ -0,0 +1,11 @@
|
||||
CONTENTS OF THIS FILE |
||||
--------------------- |
||||
|
||||
* summary |
||||
|
||||
SUMMARY |
||||
------- |
||||
|
||||
This directory contains the spin.js library: http://fgnass.github.io/spin.js/ |
||||
downloaded from http://fgnass.github.io/spin.js/dist/spin.min.js on Sept 27th |
||||
2013. This project is under version control: https://github.com/fgnass/spin.js. |
@ -0,0 +1 @@
|
||||
(function(t,e){if(typeof exports=="object")module.exports=e();else if(typeof define=="function"&&define.amd)define(e);else t.Spinner=e()})(this,function(){"use strict";var t=["webkit","Moz","ms","O"],e={},i;function o(t,e){var i=document.createElement(t||"div"),o;for(o in e)i[o]=e[o];return i}function n(t){for(var e=1,i=arguments.length;e<i;e++)t.appendChild(arguments[e]);return t}var r=function(){var t=o("style",{type:"text/css"});n(document.getElementsByTagName("head")[0],t);return t.sheet||t.styleSheet}();function s(t,o,n,s){var a=["opacity",o,~~(t*100),n,s].join("-"),f=.01+n/s*100,l=Math.max(1-(1-t)/o*(100-f),t),u=i.substring(0,i.indexOf("Animation")).toLowerCase(),d=u&&"-"+u+"-"||"";if(!e[a]){r.insertRule("@"+d+"keyframes "+a+"{"+"0%{opacity:"+l+"}"+f+"%{opacity:"+t+"}"+(f+.01)+"%{opacity:1}"+(f+o)%100+"%{opacity:"+t+"}"+"100%{opacity:"+l+"}"+"}",r.cssRules.length);e[a]=1}return a}function a(e,i){var o=e.style,n,r;i=i.charAt(0).toUpperCase()+i.slice(1);for(r=0;r<t.length;r++){n=t[r]+i;if(o[n]!==undefined)return n}if(o[i]!==undefined)return i}function f(t,e){for(var i in e)t.style[a(t,i)||i]=e[i];return t}function l(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)if(t[o]===undefined)t[o]=i[o]}return t}function u(t){var e={x:t.offsetLeft,y:t.offsetTop};while(t=t.offsetParent)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}function d(t,e){return typeof t=="string"?t:t[e%t.length]}var p={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:1/4,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"};function c(t){if(typeof this=="undefined")return new c(t);this.opts=l(t||{},c.defaults,p)}c.defaults={};l(c.prototype,{spin:function(t){this.stop();var e=this,n=e.opts,r=e.el=f(o(0,{className:n.className}),{position:n.position,width:0,zIndex:n.zIndex}),s=n.radius+n.length+n.width,a,l;if(t){t.insertBefore(r,t.firstChild||null);l=u(t);a=u(r);f(r,{left:(n.left=="auto"?l.x-a.x+(t.offsetWidth>>1):parseInt(n.left,10)+s)+"px",top:(n.top=="auto"?l.y-a.y+(t.offsetHeight>>1):parseInt(n.top,10)+s)+"px"})}r.setAttribute("role","progressbar");e.lines(r,e.opts);if(!i){var d=0,p=(n.lines-1)*(1-n.direction)/2,c,h=n.fps,m=h/n.speed,y=(1-n.opacity)/(m*n.trail/100),g=m/n.lines;(function v(){d++;for(var t=0;t<n.lines;t++){c=Math.max(1-(d+(n.lines-t)*g)%m*y,n.opacity);e.opacity(r,t*n.direction+p,c,n)}e.timeout=e.el&&setTimeout(v,~~(1e3/h))})()}return e},stop:function(){var t=this.el;if(t){clearTimeout(this.timeout);if(t.parentNode)t.parentNode.removeChild(t);this.el=undefined}return this},lines:function(t,e){var r=0,a=(e.lines-1)*(1-e.direction)/2,l;function u(t,i){return f(o(),{position:"absolute",width:e.length+e.width+"px",height:e.width+"px",background:t,boxShadow:i,transformOrigin:"left",transform:"rotate("+~~(360/e.lines*r+e.rotate)+"deg) translate("+e.radius+"px"+",0)",borderRadius:(e.corners*e.width>>1)+"px"})}for(;r<e.lines;r++){l=f(o(),{position:"absolute",top:1+~(e.width/2)+"px",transform:e.hwaccel?"translate3d(0,0,0)":"",opacity:e.opacity,animation:i&&s(e.opacity,e.trail,a+r*e.direction,e.lines)+" "+1/e.speed+"s linear infinite"});if(e.shadow)n(l,f(u("#000","0 0 4px "+"#000"),{top:2+"px"}));n(t,n(l,u(d(e.color,r),"0 0 1px rgba(0,0,0,.1)")))}return t},opacity:function(t,e,i){if(e<t.childNodes.length)t.childNodes[e].style.opacity=i}});function h(){function t(t,e){return o("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',e)}r.addRule(".spin-vml","behavior:url(#default#VML)");c.prototype.lines=function(e,i){var o=i.length+i.width,r=2*o;function s(){return f(t("group",{coordsize:r+" "+r,coordorigin:-o+" "+-o}),{width:r,height:r})}var a=-(i.width+i.length)*2+"px",l=f(s(),{position:"absolute",top:a,left:a}),u;function p(e,r,a){n(l,n(f(s(),{rotation:360/i.lines*e+"deg",left:~~r}),n(f(t("roundrect",{arcsize:i.corners}),{width:o,height:i.width,left:i.radius,top:-i.width>>1,filter:a}),t("fill",{color:d(i.color,e),opacity:i.opacity}),t("stroke",{opacity:0}))))}if(i.shadow)for(u=1;u<=i.lines;u++)p(u,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(u=1;u<=i.lines;u++)p(u);return n(e,l)};c.prototype.opacity=function(t,e,i,o){var n=t.firstChild;o=o.shadow&&o.lines||0;if(n&&e+o<n.childNodes.length){n=n.childNodes[e+o];n=n&&n.firstChild;n=n&&n.firstChild;if(n)n.opacity=i}}}var m=f(o("group"),{behavior:"url(#default#VML)"});if(!a(m,"transform")&&m.adj)h();else i=a(m,"animation");return c}); |
@ -0,0 +1,58 @@
|
||||
/** |
||||
* @file |
||||
* Triggers the display of a spinning icon when the form is submitted. |
||||
*/ |
||||
(function ($) { |
||||
|
||||
Drupal.behaviors.spinner = { |
||||
attach: function(context, settings) { |
||||
// Store what triggered the submit.
|
||||
$('form').once('submit-resolver', function() { |
||||
$(this).click(function(event) { |
||||
$(this).data('clicked', $(event.target)); |
||||
}); |
||||
$(this).keypress(function(event) { |
||||
// 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) { |
||||
$(this).data('clicked', $(':submit', this).first()); |
||||
} |
||||
}); |
||||
}); |
||||
for (var base in settings.spinner) { |
||||
var id = '#' + base; |
||||
$(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)) { |
||||
event.preventDefault(); |
||||
// 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) {
|
||||
$(':submit').attr('disabled', 'disabled'); |
||||
} |
||||
setTimeout(function() { |
||||
// Allow for the button to be clicked, then click it then
|
||||
// prevent the default behavoir.
|
||||
$(id).removeAttr('disabled') |
||||
.click() |
||||
.click(function(event) { |
||||
event.preventDefault(); |
||||
}); |
||||
}, 500); |
||||
} |
||||
return true; |
||||
}); |
||||
}); |
||||
} |
||||
} |
||||
}; |
||||
})(jQuery); |
@ -0,0 +1,20 @@
|
||||
<?php |
||||
/** |
||||
* @file |
||||
* This is the template file for the Dublin Core metadata description. |
||||
* |
||||
* Available variables: |
||||
* - $islandora_object: The Islandora object rendered in this template file |
||||
* $dc_array: The DC datastream object values as a sanitized array. This |
||||
* includes label, value and class name. |
||||
* |
||||
* @see template_preprocess_islandora_dublin_core_description() |
||||
* @see theme_islandora_dublin_core_description() |
||||
*/ |
||||
?> |
||||
<div class="islandora-metadata-sidebar"> |
||||
<?php if (!empty($dc_array['dc:description']['value'])): ?> |
||||
<h2><?php print $dc_array['dc:description']['label']; ?></h2>
|
||||
<p property="description"><?php print $dc_array['dc:description']['value']; ?></p>
|
||||
<?php endif; ?> |
||||
</div> |
@ -0,0 +1,33 @@
|
||||
<?php |
||||
/** |
||||
* @file |
||||
* This is the template file for the object page for large image |
||||
* |
||||
* Available variables: |
||||
* - $islandora_object: The Islandora object rendered in this template file |
||||
* - $islandora_dublin_core: The DC datastream object |
||||
* - $dc_array: The DC datastream object values as a sanitized array. This |
||||
* includes label, value and class name. |
||||
* - $islandora_object_label: The sanitized object label. |
||||
* |
||||
* @see template_preprocess_islandora_dublin_core_display() |
||||
* @see theme_islandora_dublin_core_display() |
||||
*/ |
||||
?> |
||||
<fieldset <?php $print ? print('class="islandora islandora-metadata"') : print('class="islandora islandora-metadata collapsible collapsed"');?>>
|
||||
<legend><span class="fieldset-legend"><?php print t('Details'); ?></span></legend>
|
||||
<div class="fieldset-wrapper"> |
||||
<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> |
||||
<dd class="<?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
|
||||
<?php print $value['value']; ?> |
||||
</dd> |
||||
<?php $row_field++; ?> |
||||
<?php endforeach; ?> |
||||
</dl> |
||||
</div> |
||||
</fieldset> |
Loading…
Reference in new issue