Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.common.theme @ 806baeb2

History | View | Annotate | Download (11.8 KB)

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
/**
14
 * TODO if getting fragment from request is possible remove $_REQUEST['highlite'] HACK
15
 * NOT WORKING since fragments are not available to the server
16
 function fragment(){
17
 global $fragment;
18
 if(!$fragment){
19
 $fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '#'));
20
 }
21
 return $fragment;
22
 }
23
 */
24

    
25
function uuid_anchor($uuid, $innerHTML){
26
	$highlite = $_REQUEST['highlite'] == $uuid;
27
	return '<a name="'.$uuid.'" ></a><span class="'.($highlite ? 'highlite' : '').'">'.$innerHTML.'</span>';
28
}
29

    
30
/**
31
 * Enter description here...
32
 *
33
 * @param unknown_type $name
34
 * @param unknown_type $numOfNameTokens
35
 * @return unknown
36
 * @deprecated looks like this is not used anymore
37
 */
38
function tagNameParts($name, $numOfNameTokens){
39

    
40
	$out = '<span class="name">';
41

    
42
	$token = strtok($name, " \n\t");
43
	$i = 0;
44
	$noSpace = true;
45
	while($token != false){
46
		if($i == $numOfNameTokens){
47
			$out .= '</span> <span class="authors">';
48
			$noSpace = true;
49
		}
50
		$out .= ($noSpace?'':' ').$token;
51
		$noSpace = false;
52
		$token = strtok(" \n\t");
53
		$i++;
54
	}
55
	return $out.'</span>';
56
}
57

    
58
/**
59
 * Converts an array of TagedText items into a sequence of corresponding html tags whereas
60
 * each item will provided with a class attribute which set to the key of the TaggedText item.
61
 *
62
 * @param array $taggedtxt
63
 * @param String $tag
64
 * @param String $glue the string by which the chained text tokens are concatenated together.
65
 *       Default is a blank character
66
 * @return String of HTML
67
 */
68
function theme_cdm_taggedtext2html(array &$taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()){
69
	$out = '';
70
	$i = 0;
71
	foreach($taggedtxt as $tt){
72
		if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
73
			$out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' class="'.$tt->type.'">'.t($tt->text).'</'.$tag.'>';
74
		}
75
	}
76
	return $out;
77
}
78

    
79
/* ============================ annotations ============================= */
80

    
81
/**
82
 * Almost any cdmObject may be annotated. Therefore we provide a generic way to display
83
 * as well as create or update annotations.
84
 *
85
 * TODO it should be configurable which objects can be annotated as this might differ in dataportals
86
 *
87
 */
88
function theme_cdm_annotation($cdmBase){
89
	if(!$cdmBase->uuid){
90
		return;
91
	}else{
92

    
93
		drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
94
		drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
95

    
96
		$annotatableUuid = $cdmBase->uuid;
97
		//FIXME annotations only available as property of e.g. taxon, name, ...
98
		$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($annotatableUuid));
99

    
100
		$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_content');
101

    
102
		$out = ' <span class="annotation">';
103
		$out .= '<span class="annotation_toggle" rel="'.$annotationProxyUrl.'">+</span>';
104
			
105

    
106
		$out .= '<div class="annotation_box"></div>';
107
		$out .= '</span>';
108

    
109
		return $out;
110

    
111
	}
112
}
113

    
114
function theme_cdm_annotation_content($AnnotationTO){
115

    
116
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
117
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
118

    
119
	$out .= theme('cdm_list_of_annotations', $AnnotationTO->annotationElements);
120

    
121
	$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($AnnotationTO->uuid));
122
	$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_post');
123

    
124
	// TODO users have to be authenticated to the dataportal to be able to write annotations
125
	$out .= '
126
  			<div class="annotation_create">
127
  				<form action="'.$annotationProxyUrl.'" method="POST">
128
  					<textarea name="annotation"></textarea>
129
  					<input type="hidden" name="commentator" value="">
130
  					<input type="submit" value="'.t('Save annotation').'" />
131
  				</form>
132
 			</div>
133
	';
134

    
135
	return $out;
136
}
137

    
138
function theme_cdm_list_of_annotations($annotationElements){
139

    
140
	$out = '<ul class="annotation_list">';
141

    
142
	foreach ($annotationElements as $key => $row){
143
		$created[$key] = $row;
144
	}
145
	array_multisort($created, SORT_ASC, $annotationElements);
146

    
147
	foreach ($annotationElements as $annotation){
148
		$out .= '<li>' . $annotation->text . '</li>';
149
	}
150

    
151
	$out .= '</ul>';
152

    
153
	return $out;
154

    
155
}
156

    
157
/* ============================ footnotes ============================= */
158

    
159
function theme_cdm_footnote_key($footnoteKey){
160
  $out = '<a href="#footnote-'.$footnoteKey.'" class="footnote-key">'.$footnoteKey.'</a>';
161
  return $out;
162
}
163

    
164
function theme_cdm_footnote($footnoteKey, $footnoteText){
165
  _add_js_footnotes();
166
  $out = '<span class="footnote footnote-'.$footnoteKey.'"><a name="footnote-'.$footnoteKey.'"></a><span class="footnote-anchor">'.$footnoteKey.'.</span>&nbsp;'.$footnoteText.'</span>';
167
  return $out;
168
}
169

    
170

    
171
/* ============================ pager ============================= */
172

    
173

    
174
function theme_cdm_pager(&$pager, $path, $parameters){
175
	$out = '';
176

    
177
	if ($pager->pagesAvailable > 1) {
178

    
179
		$out .= '<div class="pager">';
180
		if($pager->currentIndex > 0){
181
			$out .= theme('cdm_pager_link', t('« first'), 0,  $pager, $path, $parameters, array('class' => 'pager-first'));
182
			$out .= theme('cdm_pager_link', t('‹ previous'), $pager->currentIndex - 1, $pager, $path, $parameters, array('class' => 'pager-previous'));
183
		}
184

    
185
		if($pager->indices[0] > 0){
186
			$out .= '<div class="pager-list-dots-left">...</div>';
187
		}
188

    
189
		foreach($pager->indices as $index){
190
			$label = $index + 1;
191
			$out .= theme('cdm_pager_link', $label, $index,  $pager, $path, $parameters, array('class' => 'pager-first'));
192
		}
193
		if($pager->indices[count($pager->indices) - 1] < $pager->pagesAvailable - 1){
194
			$out .= '<div class="pager-list-dots-right">...</div>';
195
		}
196

    
197
		if($pager->nextIndex){
198
			$out .= theme('cdm_pager_link', t('next ›'), $pager->nextIndex, $pager, $path, $parameters, array('class' => 'pager-next'));
199
			$out .= theme('cdm_pager_link', t('last »'), $pager->pagesAvailable - 1, $pager, $path, $parameters, array('class' => 'pager-last'));
200
		}
201
		$out .= '</div>';
202

    
203
		return $out;
204
	}
205
}
206

    
207
function theme_cdm_pager_link($text, $linkIndex, &$pager, $path, $parameters = array(), $attributes) {
208

    
209
	$out = '';
210
	$parameters['search']['page'] = $linkIndex;
211
	if ($linkIndex == $pager->currentIndex) {
212
		$out = '<strong>'.$text.'</strong>';
213
	} else {
214
		$queryString = drupal_query_string_encode($parameters);
215
		$out = l($text, $path, $attributes, $queryString);
216
	}
217
	return $out;
218
}
219

    
220
/* ============================ special buttons ============================= */
221

    
222
function theme_cdm_back_to_search_result_button(){
223
	$out = '';
224
	if($_SESSION['cdm']['search']){
225
		/*['cdm']['last_search']*/
226
		//$out .= '<div id="backButton">'.l(t('Back to search result'), $_SESSION ).'</div>';
227
		$out .= '<div id="backButton">'.l(t('Back to search result'), "http://" . $_SERVER['SERVER_NAME'] . $_SESSION['cdm']['last_search'] ).'</div>';
228

    
229
	}
230
	return $out;
231
}
232

    
233
function theme_cdm_back_to_image_gallery_button(){
234
	//$galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
235
	//$gallery_name = $taxon->uuid;
236
	//$mediaList = cdm_ws_get(CDM_WS_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
237

    
238
	$out = '<div id="backToGalleryButton">'.l(t('Back to Images'), $_SESSION['cdm']['last_gallery'] ).'</div>';
239

    
240
	return $out;
241
}
242

    
243
function theme_cdm_print_button(){
244

    
245
	drupal_add_js ('$(document).ready(function() {
246
         $(\'#print_button\').click(function () { 
247
         window.print();
248
     });
249
  });', 'inline');
250

    
251
	$output = '<div id="print_button"><img src="'
252
	.drupal_get_path('module', 'cdm_dataportal').'/images/print_icon.gif'
253
	. ' "alt="' . t('Print this page') . ' "title="'.t('Print this page').'" />'; //.t(' Print this page');
254
	//$output .= l(' Print this page', '');
255
	$output .= '<span>Print this page</span>';
256
	$output .= '</div>';
257

    
258
	return $output;
259
}
260

    
261
/* ============================ other ============================= */
262

    
263
function theme_cdm_credits(){
264
	return null;
265
	$secRef_array = _cdm_dataportal_currentSecRef_array();
266
	return '<span class="sec_reference_citation">'.$secRef_array['citation'].'</span>'
267
	.( $secRef_array['period'] ? ' <span class="year">'.partialToYear($secRef_array['period']).'</span>' : '')
268
	.( $secRef_array['authorTeam'] ? '<div class="author">'.$secRef_array['authorTeam']['titleCache'].'</div>' : '');
269
}
270

    
271

    
272
function theme_cdm_dynabox($label, $content_url, $theme, $enclosingtag = 'li'){
273
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_dynabox.js');
274

    
275
	$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
276
	$out .= '<li class="dynabox"><span class="label" alt="'.t('Click for accepted taxon').'">'.$label.'</span>';
277
	$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>';
278
	return $out;
279
}
280

    
281
/* ============================ java script functions ============================= */
282

    
283
function _add_js_thickbox(){
284
	// ---- jQuery thickbox:
285
	/*
286
	* bug: compat-1.0.js && thickbox.js line 237 .trigger("unload")
287
	* -> event is not triggered because of problems with compat-1.0.js'
288
	* see INSTALL.txt
289
	*
290
	*/
291
	//drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.imagetool.min.js');
292
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox/thickbox.js');
293
	drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox/cdm_thickbox.css');
294
}
295

    
296
function _add_js_lightbox($galleryID){
297
	/*
298
	 * Important Notice:
299
	 * The jquery.lightbox-0.5.js has been modified in order to allow using the "alt" attribute
300
	 * for captions instead of the "title" attribute
301
	 */
302
	$lightBoxBasePath = drupal_get_path('module', 'cdm_dataportal') .'/js/jquery-lightbox-0.5';
303
	drupal_add_js($lightBoxBasePath.'/js/jquery.lightbox-0.5.js');
304
	drupal_add_css($lightBoxBasePath.'/css/jquery.lightbox-0.5.css');
305
	drupal_add_js ('$(document).ready(function() {
306
      $(\'#'.$galleryID.' a.lightbox\').lightBox({
307
        fixedNavigation:  true,
308
        imageLoading:     \''.$lightBoxBasePath.'/images/lightbox-ico-loading.gif\', 
309
        imageBtnPrev:     \''.$lightBoxBasePath.'/images/lightbox-btn-prev.gif\',    
310
        imageBtnNext:     \''.$lightBoxBasePath.'/images/lightbox-btn-next.gif\',   
311
        imageBtnClose:    \''.$lightBoxBasePath.'/images/lightbox-btn-close.gif\',  
312
        imageBlank:       \''.$lightBoxBasePath.'/images/lightbox-blank.gif\'
313
      });
314
    });
315
    ', 'inline');
316
}
317

    
318
function _add_js_footnotes(){
319
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/footnotes.js');
320
}
321

    
322

    
323
function _add_js_cluetip(){
324

    
325
	//TODO replace by http://www.socialembedded.com/labs/jQuery-Tooltip-Plugin/jQuery-Tooltip-Plugin.html
326
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.js');
327
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.dimensions.js');
328
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.hoverIntent.js');
329
	drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.css');
330
	drupal_add_js ("$(document).ready(function(){
331
      $('.cluetip').css({color: '#0062C2'}).cluetip({
332
        splitTitle: '|',
333
        showTitle: true,
334
        activation: 'hover',
335
        sicky: true,
336
        arrows: true,
337
        dropShadow: false,
338
        cluetipClass: 'rounded'
339
      });
340
    });", 'inline');
341
}
342

    
343
function _add_js_ahah(){
344
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/ahah-content.js');
345
}
Add picture from clipboard (Maximum size: 40 MB)