/
template.php
167 lines (138 loc) · 5.72 KB
/
template.php
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/**
* Variables preprocess function for the "page" theming hook.
*/
function may_bragdon_theme_preprocess_page(&$vars) {
$current_path = current_path();
$url_parts = explode( '/', $current_path);
$last_part = null;
if(sizeof($url_parts) > 0 ){
$last_part = $url_parts[sizeof($url_parts) - 1];
}
// Do we have a node?
if (isset($vars['node'])) {
// Ref suggestions.
$suggests = &$vars['theme_hook_suggestions'];
// Get path arguments.
$args = arg();
// Remove first argument of "node".
unset($args[0]);
// Set type.
$type = "page__type_{$vars['node']->type}";
// Bring it all together.
$suggests = array_merge(
$suggests, array($type), theme_get_suggestions($args, $type)
);
// if the url is: 'http://domain.com/node/123/edit'
// and node type is 'blog'..
//
// This will be the suggestions:
//
// - page__node
// - page__node__%
// - page__node__123
// - page__node__edit
// - page__type_blog
// - page__type_blog__%
// - page__type_blog__123
// - page__type_blog__edit
//
// Which connects to these templates:
//
// - page--node.tpl.php
// - page--node--%.tpl.php
// - page--node--123.tpl.php
// - page--node--edit.tpl.php
// - page--type-blog.tpl.php
// - page--type-blog--%.tpl.php
// - page--type-blog--123.tpl.php
// - page--type-blog--edit.tpl.php
//
// Latter items take precedence.
} else {
if($last_part == 'pages') {
// Ref suggestions.
$suggests = &$vars['theme_hook_suggestions'];
// Get path arguments.
$args = arg();
// Remove first argument of "node".
unset($args[0]);
// Set type.
$type = "page__type_pages";
// Bring it all together.
$suggests = array_merge(
$suggests, array($type), theme_get_suggestions($args, $type)
);
} else if (isset($vars['page']['content']['system_main']['islandora_book'])) {
// Ref suggestions.
$suggests = &$vars['theme_hook_suggestions'];
// Get path arguments.
$args = arg();
// Remove first argument of "node".
unset($args[0]);
// Set type.
$type = "page__type_diary";
// Bring it all together.
$suggests = array_merge(
$suggests, array($type), theme_get_suggestions($args, $type)
);
} else if (isset($vars['page']['sidebar_second']['islandora_compound_object_compound_navigation'])) {
// Ref suggestions.
$suggests = &$vars['theme_hook_suggestions'];
// Get path arguments.
$args = arg();
// Remove first argument of "node".
unset($args[0]);
// Set type.
$type = "page__type_inclusion";
// Bring it all together.
$suggests = array_merge(
$suggests, array($type), theme_get_suggestions($args, $type)
);
} else {
//dpm("don't know");
}
}
}
/**
* Implements hook_cmodel_pid_islandora_view_object_alter().
*/
function may_bragdon_theme_islandora_pagecmodel_islandora_view_object_alter(&$object, &$rendered) {
if (isset($object['TEI']) && $object['TEI']->content) {
module_load_include('inc', 'islandora_paged_content', 'includes/utilities');
$book_pid = islandora_paged_content_get_relationship($object->relationships, FEDORA_RELS_EXT_URI, 'isMemberOf', NULL);
$book = islandora_object_load($book_pid);
$pages = islandora_paged_content_get_pages($book);
$params = array(
'object' => $object,
'pages' => $pages,
);
$output = theme('islandora_paged_tei_seadragon_viewer', $params);
$rendered['islandora_book']['#markup'] .= $output;
}
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*/
function may_bragdon_theme_islandora_pageCModel_islandora_solr_object_result_alter(&$search_result, $query_processor) {
// Let's append the islandora_paged_content_page param to the url.
module_load_include('inc', 'islandora_paged_content', 'includes/utilities');
$object = islandora_object_load($search_result['PID']);
$page_num = islandora_paged_content_get_relationship($object->relationships, ISLANDORA_RELS_EXT_URI, 'isPageNumber', NULL);
$search_result['object_url_params']['islandora_paged_content_page'] = $page_num;
// Overwrite the page pid in the url with its book's pid.
$book_pid = islandora_paged_content_get_relationship($object->relationships, ISLANDORA_RELS_EXT_URI, 'isPageOf', NULL);
$book_pid = isset($book_pid) && $book_pid != NULL ? $book_pid : islandora_paged_content_get_relationship($object->relationships, ISLANDORA_RELS_EXT_URI, 'isMemberOf', NULL);
$url = "islandora/object/$book_pid";
$search_result['object_url'] = $url;
}
/**
* Implements template_preprocess_islandora_paged_tei_seadragon_viewer().
*/
function may_bragdon_theme_preprocess_islandora_paged_tei_seadragon_viewer(&$variables) {
$theme_path = drupal_get_path('theme', 'may_bragdon_theme');
$left_src = file_create_url("$theme_path/images/back_white.png");
$right_src = file_create_url("$theme_path/images/next_white.png");
$variables['nav_left'] = '<a title="Previous" href="#" id="islandora-paged-tei-seadragon-navigate-left"><img src="' . $left_src . '"></img></a>';
$variables['nav_right'] = '<a title="Next" href="#" id="islandora-paged-tei-seadragon-navigate-right"><img src="' . $right_src . '"></img></a>';
}