-
Notifications
You must be signed in to change notification settings - Fork 1
/
islandora_bookviewer.inc
122 lines (104 loc) · 3.84 KB
/
islandora_bookviewer.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
// $Id$
class IslandoraBookviewer {
function __construct($pid = '') {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'CollectionClass');
if (!empty($pid)) {
$this->pid = $pid;
$this->item = new Fedora_Item($pid);
}
}
// an ajax callback has been added in the module
function showAjaxBookViewer($page = 'mainpage.php') {
global $base_url;
$path = drupal_get_path('module', 'islandora_bookviewer');
$fullPath = $path . '/';
// check for a query string - this will be a search-inside query
$query = $_GET["solrq"];
//currently we are loading this as a iframe.
//can be embeded but it looks terrible when embedded. the css would have to be rewritten as most things are set as absolute
//this will take some time but eventually would be worthwhile as the index php does not have access to drupal functions/variables when loaded as
//an iframe
$viewer_url = $base_url . '/' . $fullPath . "$page?pid=" . $this->pid . '&label=' . $this->item->objectProfile->objLabel .
'&showIcon=' . variable_get('islandora_bookviewer_show_ia_logo', '1');
// if we have a search query then pass it to the viewer (to parse in book)
if ($query != "") {
$viewer_url = $viewer_url . '&solrq=' . $query;
}
$viewer_url .= '#mode/' . variable_get('islandora_bookviewer_default_view', '2up');
$html = '<iframe id="iabookviewer" name="iabookviewer" src="' . $viewer_url . '" scrolling="0" frameborder="0" style="width: 100%; height: 800px;">Errors: unable to load viewer</iframe>';
return $html;
}
/**
* @author: William Panting
*
* @date: 16/05/2011
*
* @return tabs: the html to display, in the form of a set of tabs
*/
function showBookStreams() {
//get the book viewer iframe
$viewer = $this->showBookViewer();
//set up tabs
/*
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
if (!empty($pid)) {
$this->pid = $pid;
$this->item = new Fedora_Item($pid);
} */
$tabs = array('#type' => 'tabset');
//note the fedora item
//get metadata info
$metadata = $this->getMetaData();
//populate tabs
//$tabs['Description'] = array(
// '#type' => 'tabpage',
// '#title' => 'Description',
// '#content' => $metadata,
// '#weight' => 2
//);
$tabs['View'] = array(
'#type' => 'tabpage',
'#title' => t('View'),
'#content' => $viewer,
'#weight' => -1
);
//return the tabs for display
return $tabs;
}
/**
* @author: William Panting
*
* @date: 19/05/2011
*
* @return output: the html of data to display
*
* Small modification of UoM's exif plugin
*/
function getMetaData() {
$output = '';
$MODS = $this->item->get_datastream_dissemination('MODS');
if (trim($MODS) != '') {
$MODSDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('MODS'));
if ($MODSDom != NULL) {
$description = $MODSDom->getElementsByTagName('*');
if ($description->length > 0) {
$description = $description->item(0);
$output .= '<div class="fedora_technical_metadata"><ul>';
for ($i = 0; $i < $description->childNodes->length; $i++) {
$name = $description->childNodes->item($i)->nodeName;
$value = $description->childNodes->item($i)->nodeValue;
if ($name != '#text' && !preg_match('/^System\:.*$/', $name) && trim($value) != '') {
list($type, $name) = preg_split('/\:/', $name);
$name = trim(preg_replace('/(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])/', " $1", $name));
$output .= '<li><b>' . $name . '</b>: ' . $value . ' </li>';
}
}
$output .= '</ul></div>';
}
}
}
return $output;
}
}