1
|
<?php
|
2
|
// $Id$
|
3
|
|
4
|
/**
|
5
|
* Copyright (C) 2007 EDIT
|
6
|
* European Distributed Institute of Taxonomy
|
7
|
* http://www.e-taxonomy.eu
|
8
|
*
|
9
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
10
|
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
|
11
|
*/
|
12
|
|
13
|
define(FOOTNOTE_ANNOTATIONS, 'annotations');
|
14
|
|
15
|
/**
|
16
|
* TODO if getting fragment from request is possible remove $_REQUEST['highlite'] HACK
|
17
|
* NOT WORKING since fragments are not available to the server
|
18
|
function fragment(){
|
19
|
global $fragment;
|
20
|
if(!$fragment){
|
21
|
$fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '#'));
|
22
|
}
|
23
|
return $fragment;
|
24
|
}
|
25
|
*/
|
26
|
|
27
|
function uuid_anchor($uuid, $innerHTML){
|
28
|
$highlite = $_REQUEST['highlite'] == $uuid;
|
29
|
return '<a name="'.$uuid.'" ></a><span class="'.($highlite ? 'highlite' : '').'">'.$innerHTML.'</span>';
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Enter description here...
|
34
|
*
|
35
|
* @param unknown_type $name
|
36
|
* @param unknown_type $numOfNameTokens
|
37
|
* @return unknown
|
38
|
* @deprecated looks like this is not used anymore
|
39
|
*/
|
40
|
function tagNameParts($name, $numOfNameTokens){
|
41
|
|
42
|
$out = '<span class="name">';
|
43
|
|
44
|
$token = strtok($name, " \n\t");
|
45
|
$i = 0;
|
46
|
$noSpace = true;
|
47
|
while($token != false){
|
48
|
if($i == $numOfNameTokens){
|
49
|
$out .= '</span> <span class="authors">';
|
50
|
$noSpace = true;
|
51
|
}
|
52
|
$out .= ($noSpace?'':' ').$token;
|
53
|
$noSpace = false;
|
54
|
$token = strtok(" \n\t");
|
55
|
$i++;
|
56
|
}
|
57
|
return $out.'</span>';
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* Converts an array of TagedText items into a sequence of corresponding html tags whereas
|
62
|
* each item will provided with a class attribute which set to the key of the TaggedText item.
|
63
|
*
|
64
|
* @param array $taggedtxt
|
65
|
* @param String $tag
|
66
|
* @param String $glue the string by which the chained text tokens are concatenated together.
|
67
|
* Default is a blank character
|
68
|
* @return String of HTML
|
69
|
*/
|
70
|
function theme_cdm_taggedtext2html(array &$taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()){
|
71
|
$out = '';
|
72
|
$i = 0;
|
73
|
foreach($taggedtxt as $tt){
|
74
|
if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
|
75
|
$out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' class="'.$tt->type.'">'.t($tt->text).'</'.$tag.'>';
|
76
|
}
|
77
|
}
|
78
|
return $out;
|
79
|
}
|
80
|
|
81
|
/* ============================ annotations ============================= */
|
82
|
|
83
|
/**
|
84
|
* Almost any cdmObject may be annotated. Therefore we provide a generic way to display
|
85
|
* as well as create or update annotations.
|
86
|
* The following cdm classes are annotatable:
|
87
|
*
|
88
|
* DescriptionElementBase
|
89
|
* EventBase
|
90
|
* HomotypicalGroup
|
91
|
* IdentifiableEntity
|
92
|
* DescriptionBase
|
93
|
* IdentifiableMediaEntity
|
94
|
* Media
|
95
|
* Sequence
|
96
|
* TaxonBase
|
97
|
* TaxonNameBase
|
98
|
* TaxonomicTree
|
99
|
* TermBase
|
100
|
* LanguageStringBase
|
101
|
* ReferencedEntityBase
|
102
|
* NomenclaturalStatus
|
103
|
* OriginalSourceBase
|
104
|
* RelationshipBase
|
105
|
* TypeDesignationBase
|
106
|
* TaxonNode
|
107
|
* WorkingSet
|
108
|
*
|
109
|
* TODO it should be configurable which objects can be annotated as this might differ in dataportals
|
110
|
*
|
111
|
*/
|
112
|
function theme_cdm_annotations_as_footnotekeys($cdmBase){
|
113
|
|
114
|
$footNoteKeys = cdm_annotations_as_footnotekeys($cdmBase);
|
115
|
foreach($footNoteKeys as $footNoteKey){
|
116
|
$out .= theme('cdm_footnote_key', $footnoteKey->keyStr, $footnoteKey->footnoteListKey, (isset($out)? ',' : ''));
|
117
|
}
|
118
|
return $out;
|
119
|
}
|
120
|
|
121
|
|
122
|
function theme_cdm_annotation_footnotes($footnoteListKey, $enclosingTag = 'span'){
|
123
|
return theme('cdm_footnotes', $footnoteListKey . '-annotations', $enclosingTag);
|
124
|
}
|
125
|
|
126
|
function theme_cdm_annotation_content($AnnotationTO){
|
127
|
|
128
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
|
129
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
|
130
|
|
131
|
$out .= theme('cdm_list_of_annotations', $AnnotationTO->annotationElements);
|
132
|
|
133
|
$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($AnnotationTO->uuid));
|
134
|
$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_post');
|
135
|
|
136
|
// TODO users have to be authenticated to the dataportal to be able to write annotations
|
137
|
$out .= '
|
138
|
<div class="annotation_create">
|
139
|
<form action="'.$annotationProxyUrl.'" method="POST">
|
140
|
<textarea name="annotation"></textarea>
|
141
|
<input type="hidden" name="commentator" value="">
|
142
|
<input type="submit" value="'.t('Save annotation').'" />
|
143
|
</form>
|
144
|
</div>
|
145
|
';
|
146
|
|
147
|
return $out;
|
148
|
}
|
149
|
|
150
|
function theme_cdm_list_of_annotations($annotationElements){
|
151
|
|
152
|
$out = '<ul class="annotation_list">';
|
153
|
|
154
|
foreach ($annotationElements as $key => $row){
|
155
|
$created[$key] = $row;
|
156
|
}
|
157
|
array_multisort($created, SORT_ASC, $annotationElements);
|
158
|
|
159
|
foreach ($annotationElements as $annotation){
|
160
|
$out .= '<li>' . $annotation->text . '</li>';
|
161
|
}
|
162
|
|
163
|
$out .= '</ul>';
|
164
|
|
165
|
return $out;
|
166
|
|
167
|
}
|
168
|
|
169
|
/* ============================ footnotes ============================= */
|
170
|
|
171
|
function theme_cdm_footnote_key(FootnoteKey $footnoteKey, $separator = '', $highlightable=true){
|
172
|
$out = '<span class="footnote-key footnote-key-'.$footnoteKey->keyStr.' member-of-footnotes-'.$footnoteKey->footnoteListKey.'">'.$separator
|
173
|
.'<a href="#footnote-'.$footnoteKey->keyStr.'">'.$footnoteKey->keyStr.'</a>'
|
174
|
.'</span>';
|
175
|
return $out;
|
176
|
}
|
177
|
|
178
|
function theme_cdm_footnote($footnoteKey, $footnoteText){
|
179
|
_add_js_footnotes();
|
180
|
$out = '<span class="footnote footnote-'.$footnoteKey.'"><a name="footnote-'.$footnoteKey.'"></a><span class="footnote-anchor">'.$footnoteKey.'.</span> '.$footnoteText.'</span>';
|
181
|
return $out;
|
182
|
}
|
183
|
|
184
|
|
185
|
function theme_cdm_footnotes($footnoteListKey, $enclosingTag = 'span'){
|
186
|
|
187
|
$out = '<'.$enclosingTag.' class="footnotes footnotes-'.$footnoteListKey.' ">' . FootnoteManager::renderFootnoteList($footnoteListKey) . '</'.$enclosingTag.'>';
|
188
|
return $out;
|
189
|
}
|
190
|
|
191
|
|
192
|
/* ============================ pager ============================= */
|
193
|
|
194
|
|
195
|
function theme_cdm_pager(&$pager, $path, $parameters){
|
196
|
$out = '';
|
197
|
|
198
|
if ($pager->pagesAvailable > 1) {
|
199
|
|
200
|
$out .= '<div class="pager">';
|
201
|
if($pager->currentIndex > 0){
|
202
|
$out .= theme('cdm_pager_link', t('« first'), 0, $pager, $path, $parameters, array('class' => 'pager-first'));
|
203
|
$out .= theme('cdm_pager_link', t('‹ previous'), $pager->currentIndex - 1, $pager, $path, $parameters, array('class' => 'pager-previous'));
|
204
|
}
|
205
|
|
206
|
if($pager->indices[0] > 0){
|
207
|
$out .= '<div class="pager-list-dots-left">...</div>';
|
208
|
}
|
209
|
|
210
|
foreach($pager->indices as $index){
|
211
|
$label = $index + 1;
|
212
|
$out .= theme('cdm_pager_link', $label, $index, $pager, $path, $parameters, array('class' => 'pager-first'));
|
213
|
}
|
214
|
if($pager->indices[count($pager->indices) - 1] < $pager->pagesAvailable - 1){
|
215
|
$out .= '<div class="pager-list-dots-right">...</div>';
|
216
|
}
|
217
|
|
218
|
if($pager->nextIndex){
|
219
|
$out .= theme('cdm_pager_link', t('next ›'), $pager->nextIndex, $pager, $path, $parameters, array('class' => 'pager-next'));
|
220
|
$out .= theme('cdm_pager_link', t('last »'), $pager->pagesAvailable - 1, $pager, $path, $parameters, array('class' => 'pager-last'));
|
221
|
}
|
222
|
$out .= '</div>';
|
223
|
|
224
|
return $out;
|
225
|
}
|
226
|
}
|
227
|
|
228
|
function theme_cdm_pager_link($text, $linkIndex, &$pager, $path, $parameters = array(), $attributes) {
|
229
|
|
230
|
$out = '';
|
231
|
$parameters['search']['page'] = $linkIndex;
|
232
|
if ($linkIndex == $pager->currentIndex) {
|
233
|
$out = '<strong>'.$text.'</strong>';
|
234
|
} else {
|
235
|
$queryString = drupal_query_string_encode($parameters);
|
236
|
$out = l($text, $path, $attributes, $queryString);
|
237
|
}
|
238
|
return $out;
|
239
|
}
|
240
|
|
241
|
/* ============================ special buttons ============================= */
|
242
|
|
243
|
function theme_cdm_back_to_search_result_button(){
|
244
|
$out = '';
|
245
|
if($_SESSION['cdm']['search']){
|
246
|
/*['cdm']['last_search']*/
|
247
|
//$out .= '<div id="backButton">'.l(t('Back to search result'), $_SESSION ).'</div>';
|
248
|
$out .= '<div id="backButton">'.l(t('Back to search result'), "http://" . $_SERVER['SERVER_NAME'] . $_SESSION['cdm']['last_search'] ).'</div>';
|
249
|
|
250
|
}
|
251
|
return $out;
|
252
|
}
|
253
|
|
254
|
function theme_cdm_back_to_image_gallery_button(){
|
255
|
//$galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
|
256
|
//$gallery_name = $taxon->uuid;
|
257
|
//$mediaList = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
258
|
|
259
|
$out = '<div id="backToGalleryButton">'.l(t('Back to Images'), $_SESSION['cdm']['last_gallery'] ).'</div>';
|
260
|
|
261
|
return $out;
|
262
|
}
|
263
|
|
264
|
function theme_cdm_print_button(){
|
265
|
|
266
|
drupal_add_js ('$(document).ready(function() {
|
267
|
$(\'#print_button\').click(function () {
|
268
|
window.print();
|
269
|
});
|
270
|
});', 'inline');
|
271
|
|
272
|
$output = '<div id="print_button"><img src="'
|
273
|
.drupal_get_path('module', 'cdm_dataportal').'/images/print_icon.gif'
|
274
|
. ' "alt="' . t('Print this page') . ' "title="'.t('Print this page').'" />'; //.t(' Print this page');
|
275
|
//$output .= l(' Print this page', '');
|
276
|
$output .= '<span>Print this page</span>';
|
277
|
$output .= '</div>';
|
278
|
|
279
|
return $output;
|
280
|
}
|
281
|
|
282
|
/* ============================ other ============================= */
|
283
|
|
284
|
//function theme_cdm_credits(){
|
285
|
// return "";
|
286
|
// $secRef_array = _cdm_dataportal_currentSecRef_array();
|
287
|
// return '<span class="sec_reference_citation">'.$secRef_array['citation'].'</span>'
|
288
|
// .( $secRef_array['period'] ? ' <span class="year">'.partialToYear($secRef_array['period']).'</span>' : '')
|
289
|
// .( $secRef_array['authorTeam'] ? '<div class="author">'.$secRef_array['authorTeam']['titleCache'].'</div>' : '');
|
290
|
//}
|
291
|
|
292
|
|
293
|
function theme_cdm_dynabox($label, $content_url, $theme, $enclosingtag = 'li'){
|
294
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_dynabox.js');
|
295
|
|
296
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
|
297
|
$out .= '<li class="dynabox"><span class="label" alt="'.t('Click for accepted taxon').'">'.$label.'</span>';
|
298
|
$out .= '<ul class="dynabox_content" title="'.$cdm_proxy_url.'"><li><img class="loading" src="'.drupal_get_path('module', 'cdm_dataportal').'/images/loading_circle_grey_16.gif" style="display:none;"></li></ul>';
|
299
|
return $out;
|
300
|
}
|
301
|
|
302
|
/* ============================ java script functions ============================= */
|
303
|
|
304
|
function _add_js_thickbox(){
|
305
|
// ---- jQuery thickbox:
|
306
|
/*
|
307
|
* bug: compat-1.0.js && thickbox.js line 237 .trigger("unload")
|
308
|
* -> event is not triggered because of problems with compat-1.0.js'
|
309
|
* see INSTALL.txt
|
310
|
*
|
311
|
*/
|
312
|
//drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.imagetool.min.js');
|
313
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox/thickbox.js');
|
314
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox/cdm_thickbox.css');
|
315
|
}
|
316
|
|
317
|
function _add_js_lightbox($galleryID){
|
318
|
/*
|
319
|
* Important Notice:
|
320
|
* The jquery.lightbox-0.5.js has been modified in order to allow using the "alt" attribute
|
321
|
* for captions instead of the "title" attribute
|
322
|
*/
|
323
|
$lightBoxBasePath = drupal_get_path('module', 'cdm_dataportal') .'/js/jquery-lightbox-0.5';
|
324
|
drupal_add_js($lightBoxBasePath.'/js/jquery.lightbox-0.5.js');
|
325
|
drupal_add_css($lightBoxBasePath.'/css/jquery.lightbox-0.5.css');
|
326
|
drupal_add_js ('$(document).ready(function() {
|
327
|
$(\'#'.$galleryID.' a.lightbox\').lightBox({
|
328
|
fixedNavigation: true,
|
329
|
imageLoading: \''.$lightBoxBasePath.'/images/lightbox-ico-loading.gif\',
|
330
|
imageBtnPrev: \''.$lightBoxBasePath.'/images/lightbox-btn-prev.gif\',
|
331
|
imageBtnNext: \''.$lightBoxBasePath.'/images/lightbox-btn-next.gif\',
|
332
|
imageBtnClose: \''.$lightBoxBasePath.'/images/lightbox-btn-close.gif\',
|
333
|
imageBlank: \''.$lightBoxBasePath.'/images/lightbox-blank.gif\'
|
334
|
});
|
335
|
});
|
336
|
', 'inline');
|
337
|
}
|
338
|
|
339
|
function _add_js_footnotes(){
|
340
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/footnotes.js');
|
341
|
}
|
342
|
|
343
|
|
344
|
function _add_js_cluetip(){
|
345
|
|
346
|
//TODO replace by http://www.socialembedded.com/labs/jQuery-Tooltip-Plugin/jQuery-Tooltip-Plugin.html
|
347
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.js');
|
348
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.dimensions.js');
|
349
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.hoverIntent.js');
|
350
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.css');
|
351
|
drupal_add_js ("$(document).ready(function(){
|
352
|
$('.cluetip').css({color: '#0062C2'}).cluetip({
|
353
|
splitTitle: '|',
|
354
|
showTitle: true,
|
355
|
activation: 'hover',
|
356
|
sicky: true,
|
357
|
arrows: true,
|
358
|
dropShadow: false,
|
359
|
cluetipClass: 'rounded'
|
360
|
});
|
361
|
});", 'inline');
|
362
|
}
|
363
|
|
364
|
function _add_js_ahah(){
|
365
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/ahah-content.js');
|
366
|
}
|