jonathangreen
13 years ago
9 changed files with 317 additions and 104 deletions
@ -0,0 +1,50 @@
|
||||
<?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 |
||||
|
||||
$object = $variables['islandora_object']; |
||||
$image_url = $variables['islandora_thumbnail_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 . '"/>'); |
||||
print('<h3>Associated Objects</h3>'); |
||||
foreach($variables['islandora_associated_objects'] as $associated_objects){ |
||||
global $base_url; |
||||
$link = l($associated_objects['title']['value'],$base_url.'/islandora/object/'.$associated_objects['object']['value']); |
||||
print ($link).'<br />'; |
||||
|
||||
} |
||||
?> |
||||
|
@ -0,0 +1,5 @@
|
||||
name = "Islandora Basic Collection" |
||||
description = "A default Islandora Repository module to handle simple collections" |
||||
dependencies[] = islandora |
||||
package = Islandora |
||||
core = 7.x |
@ -0,0 +1,134 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* @file islandora_basic_image.module |
||||
* |
||||
* an Islandora module to handle basic image cmodels |
||||
* |
||||
* |
||||
* 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/>. |
||||
*/ |
||||
|
||||
/** |
||||
* Theme registry function |
||||
* We supply a pattern so we can overide templates at the theme level if needed. |
||||
* we can append a pid to a template and the new template file will be called (the pids |
||||
* colon should be replaced with a dash) |
||||
* @return array |
||||
*/ |
||||
function islandora_basic_collection_theme($existing, $type, $theme, $path) { |
||||
return array( |
||||
'islandora_basic_collection' => array( |
||||
'template' => '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), |
||||
) |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* tells the main module what types of objects we support. This is used to determine whether or not |
||||
* this module should attempt to respond. |
||||
* @return array |
||||
* array of content model pids that this module supports |
||||
*/ |
||||
function islandora_basic_collection_islandora_get_types() { |
||||
return array('info:fedora/islandora:collectionCModel'); |
||||
} |
||||
|
||||
/** |
||||
* this modules implentation of view_object hook will handle objects of type islandora:basicImageCModel and info:fedora/islandora:sp_basic_image |
||||
* as registered in its return types |
||||
* Other modules would handle objects of other types. |
||||
* @param Object $object |
||||
* a tuque fedora object |
||||
* @param object $user |
||||
* @param string $page_number |
||||
* @param string $page_size |
||||
* @return string |
||||
* themed html |
||||
*/ |
||||
function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) { |
||||
//global $user; |
||||
$cmodel_list = islandora_basic_collection_islandora_get_types(); |
||||
$combined_list = array_intersect($cmodel_list, $object->models); |
||||
if (empty($combined_list)) { |
||||
return NULL; //we don't handle any of this objects cmodels |
||||
} |
||||
$output = theme('islandora_basic_collection', array('islandora_object' => $object)); |
||||
return array('Basic Collection Output' => $output); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @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) { |
||||
$islandora_object = $variables['islandora_object']; |
||||
module_load_include('inc', 'islandora', 'utils/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'); |
||||
} |
||||
$variables['islandora_associated_objects'] = islandora_basic_collection_get_objects($islandora_object); |
||||
$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); |
||||
global $base_url; |
||||
if (isset($islandora_object['OBJ'])) { |
||||
$variables['islandora_image_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view'; |
||||
} |
||||
if (isset($islandora_object['TN'])) { |
||||
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view'; |
||||
} |
||||
if (isset($islandora_object['MEDIUM_SIZE'])){ |
||||
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view'; |
||||
} |
||||
|
||||
} |
||||
|
||||
function islandora_basic_collection_get_objects($object){ |
||||
$query = 'select $object $title $content from <#ri> |
||||
where ($object <fedora-model:label> $title |
||||
and $object <fedora-model:hasModel> $content |
||||
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $object->id . '> |
||||
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $object->id . '>) |
||||
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
||||
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> |
||||
order by $title'; |
||||
$page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; |
||||
$page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize']; |
||||
module_load_include('inc', 'islandora', 'RestConnection'); |
||||
$query_array = array('query' => $query, 'type' => 'itql','pid' => $object->id, 'page_size'=>$page_size, 'page_number' => $page_number); |
||||
drupal_alter('islandora_basic_collection_query',$query_array); |
||||
global $user; |
||||
try { |
||||
$restConnection = new RestConnection($user); |
||||
$queryObject = new RepositoryQuery($restConnection->connection); |
||||
$results = $queryObject->query($query_array['query'],$query_array['type']); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Islandora Error getting related objects for %s', array('%s' => $object->id)), 'error'); |
||||
return""; |
||||
} |
||||
return $results; |
||||
} |
||||
|
@ -0,0 +1,55 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* fedora-repository-view-object.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 |
||||
/** |
||||
* This template is an example of overiding a template by pid |
||||
* |
||||
* This template must be placed in your themes template directory and |
||||
* allows you to override a template file for a specific object |
||||
* an example use case would be for theming a collection object differently |
||||
* based on the actual collection object. |
||||
* |
||||
* Best practice would be to create a new cmodel if you have many objects that |
||||
* need to be themed differently but if you only have a few objects that need different |
||||
* templates this method would work. |
||||
*/ |
||||
$object = $variables['islandora_object']; |
||||
$image_url = $variables['islandora_image_url']; |
||||
drupal_set_title($object->label); |
||||
print ('This template has been overridden by a theme suggestion'); |
||||
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 . '"/>'); |
||||
?> |
||||
|
@ -1,4 +1,5 @@
|
||||
name = "Islandora Basic Image" |
||||
description = "A default Islandora Repository module to handle images" |
||||
dependencies[] = islandora |
||||
package = Islandora |
||||
core = 7.x |
||||
|
Loading…
Reference in new issue