Browse Source

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

pull/122/merge
jonathangreen 13 years ago
parent
commit
a91b5e6a85
  1. 50
      islandora_basic_collection/css/islandora_basic_collection.theme.css
  2. 35
      islandora_basic_collection/islandora-basic-collection.tpl.php
  3. 130
      islandora_basic_collection/islandora_basic_collection.module
  4. 2
      islandora_basic_collection/theme/islandora-basic-collection-grid.tpl.php
  5. 0
      islandora_basic_collection/theme/islandora-basic-collection-wrapper.tpl.php
  6. 53
      islandora_basic_collection/theme/islandora-basic-collection.tpl.php
  7. 114
      islandora_basic_collection/theme/islandora_basic_collection.theme.inc
  8. 4
      islandora_basic_image/islandora-basic-image.tpl.php

50
islandora_basic_collection/css/islandora_basic_collection.theme.css

@ -6,12 +6,16 @@
*/
.islandora-basic-collection {
margin: 1.5em auto;
overflow: hidden;
width: 96%;
width: 100%;
margin: 0 auto;
}
dl.islandora-basic-collection-object
.islandora-basic-collection-object {
margin: 1.5em auto 3em;
}
.islandora-basic-collection-grid dl.islandora-basic-collection-object
{
width: 20%;
min-width: 100px;
@ -25,7 +29,7 @@ dl.islandora-basic-collection-object
_height: 180px;
}
.islandora-basic-collection-object dt img {
.islandora-basic-collection-grid .islandora-basic-collection-object dt img {
max-width: 100%;
*width: 100%;
-webkit-border-radius: 5px;
@ -33,7 +37,7 @@ dl.islandora-basic-collection-object
border-radius: 5px;
}
.islandora-basic-collection-object dd
.islandora-basic-collection-grid .islandora-basic-collection-object dd
{
margin: 0;
padding: 0;
@ -44,3 +48,39 @@ dl.islandora-basic-collection-object
#islandora-collection-migrate-form table th.select-all {
width: 20px;
}
/* the base css for lists is set in islandora, just adding details */
dl.islandora-basic-collection-thumb
{
float: left;
width: 15%;
margin: 0;
}
.islandora-basic-collection-thumb dt,
.islandora-basic-collection-thumb dd
{
margin: 0;
}
dl.islandora-basic-collection-fields
{
float: right;
width: 83%;
border-top: 0px solid #ddd;
padding-left: 10px;
}
.islandora-basic-collection-fields dt,
.islandora-basic-collection-fields dd
{
border-top: 1px solid #ddd;
}
.islandora-basic-collection-fields dt.first,
.islandora-basic-collection-fields dd.first
{
border-top: 1px solid #ddd;
}

35
islandora_basic_collection/islandora-basic-collection.tpl.php

@ -1,35 +0,0 @@
<?php
/*
* islandora-basic-collection.tpl.php
*
*
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
?>
<?php drupal_set_title($islandora_object->label); ?>
<div class="islandora-basic-collection-wrapper">
<div class="islandora-basic-collection clearfix">
<?php foreach($associated_objects_array as $key => $value): ?>
<dl class="islandora-basic-collection-object <?php print $value['class']; ?>">
<dt class="islandora-basic-collection-thumb"><?php print $value['thumb_link']; ?></dt>
<dd class="islandora-basic-collection-caption"><?php print $value['title_link']; ?></dd>
</dl>
<?php endforeach; ?>
</div>
</div>

130
islandora_basic_collection/islandora_basic_collection.module

@ -65,11 +65,10 @@ function islandora_basic_collection_menu() {
* Implements hook_menu_local_tasks_alter().
*/
function islandora_basic_collection_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if (module_exists('islandora_content_model_forms')) {
// Add action link
if ($root_path == 'islandora/object/%/manage/collection') {
$object_id = $router_item['page_arguments'][0];
$item = menu_get_item("islandora/ingest_form/$object_id");
$item = menu_get_item("islandora/ingest/$object_id");
$item['title'] = 'Add a repository item';
if ($item['access']) {
$data['actions']['output'][] = array(
@ -78,7 +77,6 @@ function islandora_basic_collection_menu_local_tasks_alter(&$data, $router_item,
);
}
}
}
}
/**
@ -191,22 +189,26 @@ function islandora_basic_collection_access($object_id) {
function islandora_basic_collection_theme($existing, $type, $theme, $path) {
return array(
'islandora_basic_collection' => array(
'template' => 'islandora-basic-collection',
'file' => 'theme/islandora_basic_collection.theme.inc',
'template' => 'theme/islandora-basic-collection',
'pattern' => 'islandora_basic_collection__', //we can add pids to the end of this pattern in our preprocess function
// and templates will be able to have have a pid appended to the template name to overide a template on a per object basis
//an example template would be named islandora-basic-image--islandora-27.tpl.phps
'variables' => array('islandora_object' => NULL),
),
'islandora_basic_collection_grid' => array(
'template' => 'islandora-basic-collection-grid',
'file' => 'theme/islandora_basic_collection.theme.inc',
'template' => 'theme/islandora-basic-collection-grid',
'pattern' => 'islandora_basic_collection_grid__',
'variables' => array('islandora_object' => NULL, 'collection_results' => NULL),
),
'islandora_basic_collection_wrapper' => array(
'template' => 'islandora-basic-collection-wrapper',
'file' => 'theme/islandora_basic_collection.theme.inc',
'template' => 'theme/islandora-basic-collection-wrapper',
'variables' => array('islandora_object' => NULL),
),
'islandora_basic_collection_management_form_table' => array(
'file' => 'theme/islandora_basic_collection.theme.inc',
'arguments' => array('element' => NULL),
'file' => 'includes/CollectionManagerTable.inc',
),
@ -254,110 +256,11 @@ function islandora_basic_collection_islandora_view_object($object, $user) {
}
/**
* list view preprocess
* currently just calls normal view preprocess as variables are the same
* @param type $variables
*/
function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables) {
islandora_basic_collection_preprocess_islandora_basic_collection($variables);
}
function islandora_basic_collection_preprocess_islandora_basic_collection_wrapper(&$variables) {
$page_number = (empty($_GET['page'])) ? 0 : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize'];
$islandora_object = $variables['islandora_object'];
$results = islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size);
$total_count = count($results);
pager_default_initialize($total_count, $page_size);
$variables['collection_pager'] = theme('pager', array('quantity' => 10));
$display = (empty($_GET['display'])) ? 'list' : $_GET['display'];
if ($display == 'grid') {
$collection_content = theme('islandora_basic_collection_grid', array('islandora_object' => $islandora_object, 'collection_results' => $results));
}
else {
$collection_content = theme('islandora_basic_collection', array('islandora_object' => $islandora_object, 'collection_results' => $results));
}
$variables['collection_content'] = $collection_content;
}
/**
*
* @global type $base_url
* @param array $variables
* an array of variables that will be passed to the theme function
* a wrappert to retrieve an object from Fedora
* @global object $user
* @param string $object_id
* @return null|\FedoraObject
*/
function islandora_basic_collection_preprocess_islandora_basic_collection(&$variables) {
// base url
global $base_url;
// base path
global $base_path;
$islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
try {
$dc = $islandora_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc);
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$page_number = (empty($_GET['page'])) ? 0 : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize'];
$results = $variables['collection_results'];//islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size);
$total_count = count($results);
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
$variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id);
if (isset($islandora_object['OBJ'])) {
$full_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';
$variables['islandora_full_img'] = '<img src="' . $full_size_url . '"/>';
}
if (isset($islandora_object['TN'])) {
$thumbnail_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
$variables['islandora_thumbnail_img'] = '<img src="' . $thumbnail_size_url . '"/>';
}
if (isset($islandora_object['MEDIUM_SIZE'])) {
$medium_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
$variables['islandora_medium_img'] = '<img src="' . $medium_size_url . '"/>';
}
$associated_objects_array = array();
$start = $page_size * ($page_number);
$end = min($start + $page_size, $total_count);
for ($i = $start; $i < $end; $i++) {
$pid = $results[$i]['object']['value'];
$fc_object = islandora_basic_collection_get_object($pid);
if (!isset($fc_object)) {
continue; //null object so don't show in collection view;
}
$associated_objects_array[$pid]['object'] = $fc_object;
try {
$dc = $fc_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc);
$associated_objects_array[$pid]['dc_array'] = $dc_object->as_formatted_array();
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$object_url = 'islandora/object/' . $pid;
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
$title = $results[$i]['title']['value'];
$associated_objects_array[$pid]['pid'] = $pid;
$associated_objects_array[$pid]['path'] = $object_url;
$associated_objects_array[$pid]['title'] = $title;
$associated_objects_array[$pid]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $pid));
if (isset($fc_object['TN'])) {
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
}
else {
//TODO: change this default image url
$thumbnail_img = '<img src="http://codesprint-centos.islandora.ca/islandora/object/islandora%3A52/datastream/TN"' . '/>';
}
$associated_objects_array[$pid]['thumbnail'] = $thumbnail_img;
$associated_objects_array[$pid]['title_link'] = l($title, $object_url, array('html' => TRUE, 'attributes' => array('title' => $title)));
$associated_objects_array[$pid]['thumb_link'] = l($thumbnail_img, $object_url, array('html' => TRUE, 'attributes' => array('title' => $title)));
}
$variables['associated_objects_array'] = $associated_objects_array;
}
function islandora_basic_collection_get_object($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
@ -371,6 +274,15 @@ function islandora_basic_collection_get_object($object_id) {
return $fedora_object;
}
/**
* gets objects associated with this object with teh isMemberOf or isMemberOfCollection
*
* @global object $user
* @param object $object
* @param string $page_number
* @param string $page_size
* @return array
*/
function islandora_basic_collection_get_objects($object, $page_number = 1, $page_size = 5) {
$query = 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title

2
islandora_basic_collection/islandora-basic-collection-grid.tpl.php → islandora_basic_collection/theme/islandora-basic-collection-grid.tpl.php

@ -24,7 +24,7 @@
<div class="islandora-basic-collection-wrapper">
<div class="islandora-basic-collection clearfix">
<div class="islandora-basic-collection-grid clearfix">
<?php foreach($associated_objects_array as $key => $value): ?>
<dl class="islandora-basic-collection-object <?php print $value['class']; ?>">
<dt class="islandora-basic-collection-thumb"><?php print $value['thumb_link']; ?></dt>

0
islandora_basic_collection/islandora-basic-collection-wrapper.tpl.php → islandora_basic_collection/theme/islandora-basic-collection-wrapper.tpl.php

53
islandora_basic_collection/theme/islandora-basic-collection.tpl.php

@ -0,0 +1,53 @@
<?php
/*
* islandora-basic-collection.tpl.php
*
*
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
?>
<?php drupal_set_title($islandora_object->label); ?>
<div class="islandora islandora-basic-collection-wrapper">
<?php $row_field = 0; ?>
<?php foreach($associated_objects_array as $associated_object): ?>
<div class="islandora-basic-collection-object clearfix">
<dl class="islandora-basic-collection-thumb <?php print $associated_object['class']; ?>">
<dt><?php print $associated_object['thumb_link']; ?></dt>
<dd></dd>
</dl>
<dl class="islandora-inline-metadata islandora-basic-collection-fields">
<dt class="collection-label <?php print $associated_object['dc_array']['dc:title']['class']; ?> <?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $associated_object['dc_array']['dc:title']['label']; ?>
</dt>
<dd class="collection-value <?php print $associated_object['dc_array']['dc:title']['class']; ?> <?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $associated_object['title_link']; ?>
</dd>
<?php if ($associated_object['dc_array']['dc:description']['value']): ?>
<dt class="collection-label <?php print $associated_object['dc_array']['dc:description']['class']; ?>">
<?php print $associated_object['dc_array']['dc:description']['label']; ?>
</dt>
<dd class="collection-value <?php print $associated_object['dc_array']['dc:description']['class']; ?>">
<?php print $associated_object['dc_array']['dc:description']['value']; ?>
</dd>
<?php $row_field++; ?>
<?php endif; ?>
</dl>
</div>
<?php endforeach; ?>
</div>

114
islandora_basic_collection/theme/islandora_basic_collection.theme.inc

@ -0,0 +1,114 @@
<?php
/**
* list view preprocess
* currently just calls normal view preprocess as variables are the same
* @param type $variables
*/
function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables) {
islandora_basic_collection_preprocess_islandora_basic_collection($variables);
}
function islandora_basic_collection_preprocess_islandora_basic_collection_wrapper(&$variables) {
$page_number = (empty($_GET['page'])) ? 0 : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize'];
$islandora_object = $variables['islandora_object'];
$results = islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size);
$total_count = count($results);
pager_default_initialize($total_count, $page_size);
$variables['collection_pager'] = theme('pager', array('quantity' => 10));
$display = (empty($_GET['display'])) ? 'list' : $_GET['display'];
if ($display == 'grid') {
$collection_content = theme('islandora_basic_collection_grid', array('islandora_object' => $islandora_object, 'collection_results' => $results));
}
else {
$collection_content = theme('islandora_basic_collection', array('islandora_object' => $islandora_object, 'collection_results' => $results));
}
$variables['collection_content'] = $collection_content;
}
/**
*
* @global type $base_url
* @param array $variables
* an array of variables that will be passed to the theme function
*/
function islandora_basic_collection_preprocess_islandora_basic_collection(&$variables) {
// base url
global $base_url;
// base path
global $base_path;
$islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
try {
$dc = $islandora_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc);
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$page_number = (empty($_GET['page'])) ? 0 : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize'];
$results = $variables['collection_results']; //islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size);
$total_count = count($results);
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
$display = (empty($_GET['display'])) ? 'list' : $_GET['display'];
if ($display == 'grid') {
$variables['theme_hook_suggestions'][] = 'islandora_basic_collection_grid__' . str_replace(':', '_', $islandora_object->id);
}
else {
$variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id);
}
if (isset($islandora_object['OBJ'])) {
$full_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';
$variables['islandora_full_img'] = '<img src="' . $full_size_url . '"/>';
}
if (isset($islandora_object['TN'])) {
$thumbnail_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
$variables['islandora_thumbnail_img'] = '<img src="' . $thumbnail_size_url . '"/>';
}
if (isset($islandora_object['MEDIUM_SIZE'])) {
$medium_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
$variables['islandora_medium_img'] = '<img src="' . $medium_size_url . '"/>';
}
$associated_objects_array = array();
$start = $page_size * ($page_number);
$end = min($start + $page_size, $total_count);
for ($i = $start; $i < $end; $i++) {
$pid = $results[$i]['object']['value'];
$fc_object = islandora_basic_collection_get_object($pid);
if (!isset($fc_object)) {
continue; //null object so don't show in collection view;
}
$associated_objects_array[$pid]['object'] = $fc_object;
try {
$dc = $fc_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc);
$associated_objects_array[$pid]['dc_array'] = $dc_object->as_formatted_array();
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$object_url = 'islandora/object/' . $pid;
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
$title = $results[$i]['title']['value'];
$associated_objects_array[$pid]['pid'] = $pid;
$associated_objects_array[$pid]['path'] = $object_url;
$associated_objects_array[$pid]['title'] = $title;
$associated_objects_array[$pid]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $pid));
if (isset($fc_object['TN'])) {
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
}
else {
//TODO: change this default image url
$thumbnail_img = '<img src="http://codesprint-centos.islandora.ca/islandora/object/islandora%3A52/datastream/TN"' . '/>';
}
$associated_objects_array[$pid]['thumbnail'] = $thumbnail_img;
$associated_objects_array[$pid]['title_link'] = l($title, $object_url, array('html' => TRUE, 'attributes' => array('title' => $title)));
$associated_objects_array[$pid]['thumb_link'] = l($thumbnail_img, $object_url, array('html' => TRUE, 'attributes' => array('title' => $title)));
}
$variables['associated_objects_array'] = $associated_objects_array;
}
?>

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

@ -25,7 +25,11 @@
<div class="islandora-basic-image-object islandora">
<div class="islandora-basic-image-content clearfix">
<?php if(isset($islandora_full_url)): ?>
<?php print l($islandora_medium_img, $islandora_full_url, array('html' => TRUE)); ?>
<?php else: ?>
<?php print $islandora_medium_img; ?>
<?php endif; ?>
</div>
<div class="islandora-basic-image-sidebar">
<h1 class="title"><?php print $islandora_object_label; ?></h1>

Loading…
Cancel
Save