-
Notifications
You must be signed in to change notification settings - Fork 6
/
islandora_flexpaper_viewer.module
108 lines (104 loc) · 3.22 KB
/
islandora_flexpaper_viewer.module
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
<?php
/**
* @file
* @author: Adam Vessey, William Panting
* This is the global code for islandora_flexpaper_viewer
*/
/**
* This function is the hook into the 'islandora viewer sphere'.
*
* It reports that this module can handle the SWF mime type and the theme
* function to call to use it.
*
* @param string $mime_type
* The mime_type that is being queried for
*
* @return mixed
* array: 'application/x-shockwave-flash'=>'islandora_flexpaper'
* string : 'islandora_flexpaper'
*/
function islandora_flexpaper_viewer_islandora_viewers($mime_type = NULL) {
if ($mime_type == NULL) {
return array('application/x-shockwave-flash' => 'islandora_flexpaper');
}
elseif ($mime_type == 'application/x-shockwave-flash') {
return 'islandora_flexpaper';
}
}
/**
* This function makes available the islandroa_flexpaper theme.
*
* The theme will display a flexpaper viewerd
*
* @return array
* the themes available from this module
*/
function islandora_flexpaper_viewer_theme() {
$base = drupal_get_path('module', 'islandora_flexpaper_viewer');
return array(
'islandora_flexpaper' => array(
'variables' => array(
'pid' => NULL,
'dsid' => 'SWF',
'pagenumber' => 1,
'flexpaper_config' => array(
'Scale' => 0.6,
'ZoomTransition' => 'easeOut',
'ZoomTime' => 0.5,
'ZoomInterval' => 0.1,
'FitPageOnLoad' => FALSE,
'FitWidthOnLoad' => TRUE,
'PrintEnabled' => FALSE,
'FullScreenAsMaxWindow' => TRUE,
'ProgressiveLoading' => TRUE,
'MinZoomSize' => 0.2,
'MaxZoomSize' => 5,
'SearchMatchAll' => FALSE,
'InitViewMode' => 'Portrait',
'ViewModeToolsVisible' => TRUE,
'ZoomToolsVisible' => TRUE,
'NavToolsVisible' => TRUE,
'CursorToolsVisible' => TRUE,
'SearchToolsVisible' => FALSE,
'localeChain' => 'en_US',
),
),
'template' => 'islandora_flexpaper',
),
);
}
/**
* Prepares variables for islandora_flexpaper templates.
*
* Default template: islandora_flexpaper.tpl.php
*
* @param array $vars
* The variables to prepare for themeing
*/
function template_preprocess_islandora_flexpaper(&$vars) {
$pid = $vars['pid'];
$dsid = $vars['dsid'];
if (isset($vars['flexpaper_config']) && !isset($vars['flexpaper_config']['SwfFile'])) {
$vars['flexpaper_config']['SwfFile'] = url("islandora/object/$pid/datastream/$dsid/view", array(
'absolute' => TRUE,
'language' => language_default(),
));
}
$base = drupal_get_path('module', 'islandora_flexpaper_viewer');
drupal_add_js("$base/lib/flexpaper/js/flexpaper.js");
drupal_add_js("$base/lib/flexpaper/js/flexpaper_handlers.js");
drupal_add_css("$base/css/flexpaper_setup.css");
drupal_add_js("$base/js/islandora_flexpaper.js");
drupal_add_js(
array(
'islandora_flexpaper_viewer' => array(
'config' => $vars['flexpaper_config'] + array(
'jsDirectory' => file_create_url("$base/lib/flexpaper/js/"),
'cssDirectory' => file_create_url("$base/lib/flexpaper/css/"),
'localeDirectory' => file_create_url("$base/lib/flexpaper/locale/"),
),
),
),
'setting'
);
}