Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x

pull/110/head
rwincewicz 13 years ago
parent
commit
2c9b824cfb
  1. 0
      includes/MimeClass.inc
  2. 0
      includes/datastream.inc
  3. 0
      includes/islandora_dublin_core.inc
  4. 10
      islandora.module
  5. 150
      islandora_basic_collection/includes/CollectionPolicy.inc
  6. 31
      islandora_basic_collection/islandora_basic_collection.module
  7. 19
      islandora_basic_image/css/islandora_basic_image.theme-rtl.css
  8. 97
      islandora_basic_image/css/islandora_basic_image.theme.css
  9. 48
      islandora_basic_image/islandora-basic-image.tpl.php
  10. 30
      islandora_basic_image/islandora_basic_image.module

0
utils/MimeClass.inc → includes/MimeClass.inc

0
utils/datastream.inc → includes/datastream.inc

0
utils/islandora_dublin_core.inc → includes/islandora_dublin_core.inc

10
islandora.module

@ -124,7 +124,7 @@ function islandora_menu() {
); );
$items['islandora/object/%/edit'] = array( $items['islandora/object/%/edit'] = array(
'title' => 'Edit', 'title' => 'Manage',
'page callback' => 'islandora_edit_object', 'page callback' => 'islandora_edit_object',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
@ -144,7 +144,7 @@ function islandora_menu() {
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
'page arguments' => array(2, 4), 'page arguments' => array(2, 4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'utils/datastream.inc', 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
@ -153,7 +153,7 @@ function islandora_menu() {
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
'page arguments' => array(2, 4), 'page arguments' => array(2, 4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'utils/datastream.inc', 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
@ -162,7 +162,7 @@ function islandora_menu() {
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
'page arguments' => array(2, 4), 'page arguments' => array(2, 4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'utils/datastream.inc', 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
@ -525,7 +525,7 @@ function islandora_add_datastream($object_id) {
function islandora_preprocess_islandora_default(&$variables) { function islandora_preprocess_islandora_default(&$variables) {
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'utils/islandora_dublin_core'); module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
try { try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc); //$dc_xml = simplexml_load_string($dc);

150
islandora_basic_collection/includes/CollectionPolicy.inc

@ -0,0 +1,150 @@
<?php
/**
* @file
* This file contains the classes for parsing the collection policy infomration.
*/
/**
* Collection Policy class
*/
class CollectionPolicy {
/**
* Constructor
* NOTE: Use the static constructor methods whenever possible.
*
* @param string $xmlStr
* The COLLECTION_POLICY in string form
*
* @return CollectionPolicy
* The parsed collection policy.
*/
public function __construct($xmlStr) {
$this->xml = new DOMDocument();
$this->xml->loadXML($xmlStr);
$this->name = 'Collection Policy';
}
/**
* Gets the name of the relationship to use
* for members of this collection.
* Returns FALSE on failure.
*
* @return string $relationship
*/
public function getRelationship() {
$ret = trim($this->xml->getElementsByTagName('relationship')->item(0)->nodeValue);
return $ret;
}
/**
* Sets the name of the relationship to use
* for members of this collection.
* Returns FALSE on failure.
*
* @param string $relationship
* @return boolean $ret
*/
public function setRelationship($relationship) {
$ret = FALSE;
if ($this->validate()) {
$relationshipEl = $this->xml->getElementsByTagName('relationship')->item(0);
$relationshipEl->nodeValue = trim($relationship);
$ret = TRUE;
}
return $ret;
}
/**
* Gets a list of ContentModel objects supported by this collection.
*
* @return ContentModel[] $models
*/
function getContentModels() {
$ret = array();
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model');
for ($i = 0; $i < $content_models->length; $i++) {
$cm = array();
$cm['pid'] = $content_models->item($i)->getAttribute('pid');
$cm['namespace'] = $content_models->item($i)->getAttribute('namespace');
$cm['name'] = $content_models->item($i)->getAttribute('name');
if ($cm !== FALSE) {
$ret[] = $cm;
}
}
return $ret;
}
/**
* Removes the specified content model from the collection policy. This will only
* prevent future ingests of the removed model to the collection. $cm should be
* a valid ContentModel object. Returns FALSE on failure or when the CM was not found in
* the collection policy.
*
* @param ContentModel $cm
* @return boolean $valid
*/
function removeModel($cm) {
$ret = FALSE;
if ($this->validate() && $cm->validate()) {
$contentmodelsEl = $this->xml->getElementsByTagName('content_models');
$models = $contentmodelsEl->item(0)->getElementsByTagName('content_model');
$found = FALSE;
for ($i = 0; $found === FALSE && $i < $models->length; $i++) {
if ($models->item($i)->getAttribute('pid') == $cm->pid) {
$found = $models->item($i);
}
}
if ($found !== FALSE && $models->length > 1) {
$contentmodelsEl->item(0)->removeChild($found);
$ret = TRUE;
}
}
return $ret;
}
/**
* addModel ??
* @param ContentModel $cm
* @param type $namespace
* @return type
*/
function addModel($cm, $namespace) {
$ret = FALSE;
if (self::valid_pid($namespace) && $this->validate() && $cm->validate()) {
$contentmodelsEl = $this->xml->getElementsByTagName('content_models');
$models = $contentmodelsEl->item(0)->getElementsByTagName('content_model');
$found = FALSE;
for ($i = 0; !$found && $i < $models->length; $i++) {
if ($models->item($i)->getAttribute('pid') == $cm->pid)
$found = TRUE;
}
if (!$found) {
$cmEl = $this->xml->createElement('content_model');
$cmEl->setAttribute('name', $cm->getName());
$cmEl->setAttribute('dsid', $cm->dsid);
$cmEl->setAttribute('namespace', $namespace);
$cmEl->setAttribute('pid', $cm->pid);
$contentmodelsEl->item(0)->appendChild($cmEl);
}
$ret = !$found;
}
return $ret;
}
/**
* getName ??
* @return type
*/
function getName() {
$ret = FALSE;
if ($this->validate()) {
$ret = $this->xml->getElementsByTagName('collection_policy')->item(0)->getAttribute('name');
}
return $ret;
}
}

31
islandora_basic_collection/islandora_basic_collection.module

@ -48,11 +48,10 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) {
* array of content model pids that this module supports * array of content model pids that this module supports
*/ */
function islandora_basic_collection_islandora_get_types() { function islandora_basic_collection_islandora_get_types() {
$types = array(); $types = array();
$types['info:fedora/islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = TRUE; $types['islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = TRUE;
$types['info:fedora/islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE; $types['islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE;
return $types; return $types;
} }
/** /**
@ -72,7 +71,7 @@ function islandora_basic_collection_islandora_view_object($object, $user, $page_
$cmodel_list = islandora_basic_collection_islandora_get_types(); $cmodel_list = islandora_basic_collection_islandora_get_types();
$models = $object->models; $models = $object->models;
foreach ($object->models as $model) { foreach ($object->models as $model) {
if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
$output = theme('islandora_basic_collection', array('islandora_object' => $object)); $output = theme('islandora_basic_collection', array('islandora_object' => $object));
return array('Basic Collection Output' => $output); return array('Basic Collection Output' => $output);
} }
@ -88,7 +87,7 @@ function islandora_basic_collection_islandora_view_object($object, $user, $page_
*/ */
function islandora_basic_collection_preprocess_islandora_basic_collection(&$variables) { function islandora_basic_collection_preprocess_islandora_basic_collection(&$variables) {
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'utils/islandora_dublin_core'); module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
try { try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc); $dc_object = Dublin_Core::import_from_xml_string($dc);
@ -138,23 +137,17 @@ function islandora_basic_collection_get_objects($object) {
} }
function islandora_basic_collection_islandora_ingest_get_information($models, $object) { function islandora_basic_collection_islandora_ingest_get_information($models, $object) {
if(in_array('islandora:collectionCModel', $models) && isset($object['COLLECTION_POLICY'])) { if (in_array('islandora:collectionCModel', $models) && isset($object['COLLECTION_POLICY'])) {
try { try {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
$return = array(); $return = array();
$xml = new SimpleXMLElement($object['COLLECTION_POLICY']); $policy = new CollectionPolicy($object['COLLECTION_POLICY']->content);
$cms = $xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $return['models'] = $policy->getContentModels();
$return['contentsmodels'] = array(); $return['relationship'] = $policy->getRelationship();
foreach($cms as $cm) {
$contentmodel = array();
$contentmodel['name'] = (string) $cm['name'];
$contentmodel['namespace'] = (string) $cm['namespace'];
$contentmodel['pid'] = (string) $cm['pid'];
$return['contentsmodels'] = (string) $contentmodel;
}
$return['relationship'] = trim($xml->getElementsByTagName('relationship')->item(0)->nodeValue);
return $return; return $return;
} catch (Exception $e) {
drupal_set_message(t('Islandora Error getting collection info for %s', array('%s' => $object->id)), 'error');
} }
catch (Exception $e) { }
} }
} }

19
islandora_basic_image/css/islandora_basic_image.theme-rtl.css

@ -0,0 +1,19 @@
/*
Document : islandora_basic_collection.theme-rtl
Created on : May 23, 2012, 11:23:56 AM
Description:
Purpose of the stylesheet follows.
*/
@media all and (min-width: 768px) {
body.no-sidebars .islandora-basic-image-content {
float: right; /* LTR */
padding: 0 0 0 20px;
}
body.no-sidebars .islandora-basic-image-sidebar {
float: left; /* LTR */
}
}

97
islandora_basic_image/css/islandora_basic_image.theme.css

@ -5,4 +5,101 @@
Purpose of the stylesheet follows. Purpose of the stylesheet follows.
*/ */
.islandora-basic-image-object img {
height: auto;
max-width: 100%;
*width: 100%;
}
.islandora-basic-image-content,
.islandora-basic-image-sidebar {
display: inline;
position: relative;
}
.islandora-basic-image-metadata {
clear: both;
padding-top: 1.5em;
}
dl.islandora-basic-image-fields {
width:100%;
margin: 0 auto;
letter-spacing:-0.31em;
*letter-spacing:normal;
word-spacing:-0.43em;
}
/*
* The width + left/right padding of DTs/DDs equals 88% when compensating for an image
*/
.islandora-basic-image-metadata dt {
margin-right:-1px;
width:12.5%;
font-weight: bold;
text-align: right;
}
.islandora-basic-image-metadata dd {
width:77%;
}
/*
* In this rule, we reset the white-space (see hack above)
*/
.islandora-basic-image-metadata dt,
.islandora-basic-image-metadata dd {
display:inline-block;
*display:inline;
zoom:1;
letter-spacing:normal;
word-spacing:normal;
vertical-align:top;
padding:5px 0 3px 3%;
margin:0;
border-top:1px solid #ddd;
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word; /* webkit */
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
.islandora-basic-image-sidebar,
.islandora-basic-image-sidebar,
body.one-sidebar .islandora-basic-image-sidebar,
body.two-sidebars .islandora-basic-image-sidebar {
clear: both;
width: 100%;
}
.islandora-basic-image-sidebar,
.islandora-basic-image-sidebar,
body.one-sidebar .islandora-basic-image-sidebar,
body.two-sidebars .islandora-basic-image-sidebar {
width: 100%;
}
@media all and (min-width: 768px) {
body.no-sidebars .islandora-basic-image-content,
body.no-sidebars .islandora-basic-image-sidebar {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body.no-sidebars .islandora-basic-image-content {
width: 60%;
padding: 0 20px 0 0;
float: left; /* LTR */
}
body.no-sidebars .islandora-basic-image-sidebar {
float: right; /* LTR */
width: 40%;
clear: none;
}
}

48
islandora_basic_image/islandora-basic-image.tpl.php

@ -21,23 +21,35 @@
* along with the program. If not, see <http ://www.gnu.org/licenses/>. * along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/ */
?> ?>
<?php <?php drupal_set_title(""); ?>
<div class="islandora-basic-image-object">
<div class="islandora-basic-image-content clearfix">
<?php print $islandora_medium_size_url; ?>
</div>
<div class="islandora-basic-image-sidebar">
<h1 class="title"><?php print $islandora_object_label; ?></h1>
<h3><?php print $dc_array['dc:description']['label']; ?></h3>
<p><?php print $dc_array['dc:description']['value']; ?></p>
</div>
<div class="islandora-basic-image-metadata">
<h4>Details</h4>
<dl class="islandora-basic-image-fields">
<?php $row_field = 0; ?>
<?php foreach($dc_array as $key => $value): ?>
<dt class="solr-label <?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $value['label']; ?>
</dt>
<?php if ($key == 'PID'): ?>
<?php $value['value'] = l($value['value'], 'fedora/repository/' . htmlspecialchars($value['value'], ENT_QUOTES, 'utf-8')); ?>
<?php endif; ?>
<dd class="solr-value <?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $value['value']; ?>
</dd>
<?php $row_field++; ?>
<?php endforeach; ?>
</dl>
</div>
$object = $variables['islandora_object'];
$image_url = $variables['islandora_image_url'];
drupal_set_title($object->label);
foreach ($variables['islandora_dublin_core'] as $element) {
if (!empty($element)) {
foreach ($element as $key => $value) {
foreach ($value as $v) {
if (!empty($v)) {
print '<strong>' . ($key) . '</strong>: ';
print($v) . '<br />';
}
}
}
}
}
print('<img src = "' . $image_url . '"/>');
?>
</div>

30
islandora_basic_image/islandora_basic_image.module

@ -53,13 +53,13 @@ function islandora_basic_image_theme($existing, $type, $theme, $path) {
*/ */
function islandora_basic_image_islandora_get_types() { function islandora_basic_image_islandora_get_types() {
$types = array(); $types = array();
$types['info:fedora/islandora:sp_basic_image'][ISLANDORA_VIEW_HOOK] = TRUE; $types['islandora:sp_basic_image'][ISLANDORA_VIEW_HOOK] = TRUE;
$types['info:fedora/islandora:sp_basic_image'][ISLANDORA_EDIT_HOOK] = FALSE; $types['islandora:sp_basic_image'][ISLANDORA_EDIT_HOOK] = FALSE;
return $types; return $types;
} }
/** /**
* this modules implentation of view_object hook will handle objects of type islandora:basicImageCModel and info:fedora/islandora:sp_basic_image * this modules implentation of view_object hook will handle objects of type islandora:basicImageCModel and islandora:sp_basic_image
* as registered in its return types * as registered in its return types
* Other modules would handle objects of other types. * Other modules would handle objects of other types.
* @param Object $object * @param Object $object
@ -77,7 +77,7 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe
foreach ($object->models as $model) { foreach ($object->models as $model) {
if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
$output = theme('islandora_basic_image', array('islandora_object' => $object)); $output = theme('islandora_basic_image', array('islandora_object' => $object));
return array('Basic Image Output' => $output); return array('' => $output);
} }
} }
return NULL; return NULL;
@ -91,7 +91,7 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe
*/ */
function islandora_basic_image_preprocess_islandora_basic_image(&$variables) { function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'utils/islandora_dublin_core'); module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
try { try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc); $dc_object = Dublin_Core::import_from_xml_string($dc);
@ -101,15 +101,20 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
$variables['islandora_dublin_core'] = $dc_object; $variables['islandora_dublin_core'] = $dc_object;
//create a nicer array for themers //create a nicer array for themers
//TODO: give this a better home //TODO: give this a better home
$dc_array = array(); $dc_array = array();
foreach ($dc_object as $element) { foreach ($dc_object as $element) {
if (!empty($element)) { if (!empty($element)) {
foreach ($element as $key => $value) { foreach ($element as $field => $value) {
foreach ($value as $v) { // split value if the result value is an array
if (!empty($v)) { if (is_array($value)) {
$dc_array[] = array($key => $v); $value = implode(", ", $value);
} }
} $dc_label = explode(':', $field);
$element_label = ucfirst($dc_label[1]);
$dc_array[$field]['label'] = $element_label;
$dc_array[$field]['value'] = strip_tags($value);
$dc_array[$field]['class'] = strtolower( preg_replace('/[^A-Za-z0-9]/', '-', $field));
} }
} }
} }
@ -124,7 +129,8 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view'; $variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
} }
if (isset($islandora_object['MEDIUM_SIZE'])) { if (isset($islandora_object['MEDIUM_SIZE'])) {
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view'; $medium_size = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
$variables['islandora_medium_size_url'] = '<img src="' . $medium_size . '"/>';
} }
} }

Loading…
Cancel
Save