1 |
6657531f
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Common Theming functions.
|
5 |
|
|
*
|
6 |
|
|
* @copyright
|
7 |
|
|
* (C) 2007-2012 EDIT
|
8 |
|
|
* European Distributed Institute of Taxonomy
|
9 |
|
|
* http://www.e-taxonomy.eu
|
10 |
|
|
*
|
11 |
|
|
* The contents of this module are subject to the Mozilla
|
12 |
|
|
* Public License Version 1.1.
|
13 |
|
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
define('FOOTNOTE_ANNOTATIONS', 'annotations');
|
17 |
|
|
|
18 |
|
|
/**
|
19 |
|
|
* Get the true path to the root of the Drupal site.
|
20 |
|
|
*
|
21 |
|
|
* Better than using DOCUMENT_ROOT and base_path().
|
22 |
|
|
*/
|
23 |
|
|
function absolute_path_to_drupal() {
|
24 |
|
|
static $absolute_path_to_drupal = NULL;
|
25 |
|
|
|
26 |
|
|
if ($absolute_path_to_drupal === NULL) {
|
27 |
|
|
// Get the absolute path to this file:
|
28 |
|
|
$dir = rtrim(str_replace('\\', '/', dirname(__FILE__)), '/');
|
29 |
|
|
$parts = explode('/', $dir);
|
30 |
|
|
// Iterate up the directory hierarchy until we find the website root:
|
31 |
|
|
$done = FALSE;
|
32 |
|
|
do {
|
33 |
|
|
// Check a couple of obvious things:
|
34 |
|
|
$done = is_dir("$dir/sites") && is_dir("$dir/includes") && is_file("$dir/index.php");
|
35 |
|
|
if (!$done) {
|
36 |
|
|
// If there's no more path to examine, we didn't find the site root:
|
37 |
|
|
if (empty($parts)) {
|
38 |
|
|
$absolute_path_to_drupal = FALSE;
|
39 |
|
|
break;
|
40 |
|
|
}
|
41 |
|
|
// Go up one level and look again:
|
42 |
|
|
array_pop($parts);
|
43 |
|
|
$dir = implode('/', $parts);
|
44 |
|
|
}
|
45 |
|
|
} while (!$done);
|
46 |
|
|
|
47 |
|
|
$absolute_path_to_drupal = $dir;
|
48 |
|
|
}
|
49 |
|
|
return $absolute_path_to_drupal;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
6e2a9ba9
|
Andreas Kohlbecker
|
* Checks if the taxon specified by the uuid is contained in the currently focused classification.
|
54 |
|
|
*
|
55 |
|
|
* @param $taxon_uuid
|
56 |
|
|
* @return bool
|
57 |
6657531f
|
Andreas Kohlbecker
|
*/
|
58 |
7663cd0b
|
Andreas Kohlbecker
|
function taxon_in_current_classification($taxon_uuid) {
|
59 |
6657531f
|
Andreas Kohlbecker
|
$taxon_nodes = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODES, $taxon_uuid);
|
60 |
|
|
$taxon_in_current_tree = FALSE;
|
61 |
|
|
if (is_array($taxon_nodes)) {
|
62 |
|
|
foreach ($taxon_nodes as $node) {
|
63 |
64cfdac1
|
Andreas Kohlbecker
|
if (get_current_classification_uuid() == $node->classificationUUID) {
|
64 |
6657531f
|
Andreas Kohlbecker
|
$taxon_in_current_tree = TRUE;
|
65 |
|
|
break;
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
return $taxon_in_current_tree;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
/**
|
73 |
|
|
* TODO if getting fragment from request is possible remove
|
74 |
|
|
* $_REQUEST['highlite'] HACK
|
75 |
|
|
* NOT WORKING since fragments are not available to the server
|
76 |
7a2a14b3
|
Andreas Kohlbecker
|
*
|
77 |
6657531f
|
Andreas Kohlbecker
|
* function fragment(){
|
78 |
7a2a14b3
|
Andreas Kohlbecker
|
* global $fragment;
|
79 |
|
|
* if(!$fragment){
|
80 |
|
|
* $fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '#'));
|
81 |
|
|
* }
|
82 |
|
|
* return $fragment;
|
83 |
6657531f
|
Andreas Kohlbecker
|
* }
|
84 |
|
|
*/
|
85 |
|
|
function uuid_anchor($uuid, $innerHTML) {
|
86 |
|
|
$highlite = FALSE;
|
87 |
|
|
$params = drupal_get_query_parameters();
|
88 |
|
|
if (isset($params['highlite']) && $params['highlite'] == $uuid) {
|
89 |
|
|
$highlite = TRUE;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
return '<a name="' . $uuid . '" ></a><span class="' . ($highlite ? 'highlite' : '') . '">' . $innerHTML . '</span>';
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
* @todo Enter description here...
|
97 |
|
|
* @deprecated looks like this is not used anymore
|
98 |
|
|
*/
|
99 |
|
|
/*
|
100 |
|
|
function tagNameParts($name, $numOfNameTokens) {
|
101 |
|
|
$out = '<span class="name">';
|
102 |
|
|
|
103 |
|
|
$token = strtok($name, " \n\t");
|
104 |
|
|
$i = 0;
|
105 |
|
|
$noSpace = TRUE;
|
106 |
|
|
while ($token != FALSE) {
|
107 |
|
|
if ($i == $numOfNameTokens) {
|
108 |
|
|
$out .= '</span> <span class="authors">';
|
109 |
|
|
$noSpace = TRUE;
|
110 |
|
|
}
|
111 |
|
|
$out .= ($noSpace ? '' : ' ') . $token;
|
112 |
|
|
$noSpace = FALSE;
|
113 |
|
|
$token = strtok(" \n\t");
|
114 |
|
|
$i++;
|
115 |
|
|
}
|
116 |
|
|
return $out . '</span>';
|
117 |
|
|
}
|
118 |
|
|
*/
|
119 |
|
|
|
120 |
|
|
/* ============================ annotations ============================= */
|
121 |
|
|
|
122 |
|
|
/**
|
123 |
|
|
* Returns HTML for annotations to cdm objects.
|
124 |
|
|
*
|
125 |
|
|
* Almost any cdmObject may be annotated. Therefore we provide a generic way to
|
126 |
|
|
* display as well as create or update annotations. The following cdm classes
|
127 |
|
|
* are annotatable:
|
128 |
|
|
*
|
129 |
|
|
* - DescriptionElementBase
|
130 |
|
|
* - EventBase
|
131 |
|
|
* - HomotypicalGroup
|
132 |
|
|
* - IdentifiableEntity
|
133 |
|
|
* - DescriptionBase
|
134 |
|
|
* - IdentifiableMediaEntity
|
135 |
|
|
* - Media
|
136 |
|
|
* - Sequence
|
137 |
|
|
* - TaxonBase
|
138 |
102f8c26
|
Andreas Kohlbecker
|
* - TaxonName
|
139 |
6657531f
|
Andreas Kohlbecker
|
* - TaxonomicTree
|
140 |
|
|
* - TermBase
|
141 |
|
|
* - LanguageStringBase
|
142 |
|
|
* - ReferencedEntityBase
|
143 |
|
|
* - NomenclaturalStatus
|
144 |
|
|
* - OriginalSourceBase
|
145 |
|
|
* - RelationshipBase
|
146 |
|
|
* - TypeDesignationBase
|
147 |
|
|
* - TaxonNode
|
148 |
|
|
* - WorkingSet
|
149 |
|
|
*
|
150 |
|
|
* @param array $variables
|
151 |
|
|
* An associative array containing:
|
152 |
|
|
* - cdmBase_list: An array of CdmBase instances or a single instance.
|
153 |
|
|
* - footnote_list_key
|
154 |
|
|
*
|
155 |
|
|
* @ingroup themeable
|
156 |
|
|
*/
|
157 |
39a9e629
|
Andreas Kohlbecker
|
function theme_cdm_entities_annotations_as_footnotekeys($variables) {
|
158 |
65345976
|
Andreas Kohlbecker
|
$cdm_entities = $variables['cdmBase_list'];
|
159 |
6657531f
|
Andreas Kohlbecker
|
$footnote_list_key = $variables['footnote_list_key'];
|
160 |
39a9e629
|
Andreas Kohlbecker
|
// check if footnotes for annotations are disabled completely
|
161 |
6657531f
|
Andreas Kohlbecker
|
if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
|
162 |
|
|
return '';
|
163 |
|
|
}
|
164 |
|
|
$out = '';
|
165 |
178d1ae6
|
Andreas Kohlbecker
|
if(is_array($cdm_entities)){
|
166 |
|
|
// array of entities
|
167 |
2fc5c836
|
Andreas Kohlbecker
|
$footNoteKeys = cdm_entities_annotations_as_footnotekeys($cdm_entities, $footnote_list_key);
|
168 |
178d1ae6
|
Andreas Kohlbecker
|
} else {
|
169 |
|
|
// single entity
|
170 |
|
|
$footNoteKeys = cdm_entity_annotations_as_footnotekeys($cdm_entities, $footnote_list_key);
|
171 |
|
|
}
|
172 |
6657531f
|
Andreas Kohlbecker
|
foreach ($footNoteKeys as $a) {
|
173 |
b56a52e4
|
Andreas Kohlbecker
|
$out .= cdm_footnote_key($a, ($out ? ',' : ''));
|
174 |
6657531f
|
Andreas Kohlbecker
|
}
|
175 |
|
|
return $out;
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
/**
|
179 |
b810c46f
|
Andreas Kohlbecker
|
* Create markup for the footnotes mapped to the $footnoteListKey.
|
180 |
|
|
*
|
181 |
|
|
* @param null $footnote_list_key
|
182 |
|
|
* The footnote list key, see RenderHints::getFootnoteListKey()
|
183 |
|
|
* @param $element_tag
|
184 |
|
|
* The tag for the footnote element
|
185 |
|
|
*
|
186 |
|
|
* @return string
|
187 |
|
|
* @throws \Exception
|
188 |
6657531f
|
Andreas Kohlbecker
|
*/
|
189 |
b810c46f
|
Andreas Kohlbecker
|
function cdm_annotation_footnotes($footnote_list_key = null, $element_tag = 'span') {
|
190 |
6657531f
|
Andreas Kohlbecker
|
if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
|
191 |
|
|
return '';
|
192 |
|
|
}
|
193 |
b810c46f
|
Andreas Kohlbecker
|
return cdm_footnotes($footnote_list_key . '-annotations', $element_tag);
|
194 |
6657531f
|
Andreas Kohlbecker
|
}
|
195 |
|
|
|
196 |
|
|
/* ============================ footnotes ============================= */
|
197 |
|
|
/**
|
198 |
963f9de3
|
Andreas Kohlbecker
|
* Creates markup for a foot note key
|
199 |
|
|
*
|
200 |
|
|
* @param null $footnoteKey
|
201 |
|
|
* @param string $separator
|
202 |
|
|
* @param bool $separator_off
|
203 |
|
|
*
|
204 |
|
|
* @return string
|
205 |
|
|
* The footnote key markup
|
206 |
6657531f
|
Andreas Kohlbecker
|
*/
|
207 |
963f9de3
|
Andreas Kohlbecker
|
function cdm_footnote_key($footnoteKey = null, $separator = '', $separator_off = false) {
|
208 |
6657531f
|
Andreas Kohlbecker
|
|
209 |
|
|
if (!is_object($footnoteKey) or !isset($footnoteKey->footnoteListKey)) {
|
210 |
|
|
return '';
|
211 |
|
|
}
|
212 |
|
|
if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
|
213 |
|
|
return '';
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
if ($separator_off) {
|
217 |
|
|
$separator = '';
|
218 |
|
|
}
|
219 |
963f9de3
|
Andreas Kohlbecker
|
$out = '<span class="footnote-key footnote-key-' . $footnoteKey->keyStr . ' member-of-footnotes-' . $footnoteKey->footnoteListKey . '">'
|
220 |
|
|
. $separator . '<a href="#footnote-' . $footnoteKey->keyStr . '">' . $footnoteKey->keyStr . '</a>' . '</span>';
|
221 |
6657531f
|
Andreas Kohlbecker
|
return $out;
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
/**
|
225 |
9ece0f7b
|
Andreas Kohlbecker
|
* @param null $footnoteKey
|
226 |
|
|
* @param null $footnoteText
|
227 |
|
|
* @param string $enclosing_tag
|
228 |
|
|
* default is 'span'
|
229 |
|
|
*
|
230 |
|
|
* @return string
|
231 |
6657531f
|
Andreas Kohlbecker
|
*/
|
232 |
9ece0f7b
|
Andreas Kohlbecker
|
function footnote_markup($footnoteKey = null, $footnoteText = null, $enclosing_tag = 'span') {
|
233 |
6657531f
|
Andreas Kohlbecker
|
_add_js_footnotes();
|
234 |
9ece0f7b
|
Andreas Kohlbecker
|
if($enclosing_tag == null){
|
235 |
|
|
$enclosing_tag = 'span';
|
236 |
|
|
}
|
237 |
|
|
return '<' . $enclosing_tag . ' class="footnote footnote-' . $footnoteKey . '">'
|
238 |
fea89e38
|
Andreas Kohlbecker
|
. '<a name="footnote-' . $footnoteKey . '"></a>'
|
239 |
|
|
. '<span class="footnote-anchor">' . $footnoteKey . '.</span> ' . $footnoteText
|
240 |
5611d467
|
Andreas Kohlbecker
|
. '</' . $enclosing_tag . '>';
|
241 |
6657531f
|
Andreas Kohlbecker
|
}
|
242 |
|
|
|
243 |
|
|
/**
|
244 |
b810c46f
|
Andreas Kohlbecker
|
* Create markup for the footnotes mapped to the $footnoteListKey.
|
245 |
|
|
*
|
246 |
|
|
* @param null $footnote_list_key
|
247 |
|
|
* The footnote list key, see RenderHints::getFootnoteListKey()
|
248 |
|
|
* @param $element_tag
|
249 |
|
|
* The tag for the footnote element
|
250 |
|
|
*
|
251 |
|
|
* @return string
|
252 |
6657531f
|
Andreas Kohlbecker
|
*/
|
253 |
b810c46f
|
Andreas Kohlbecker
|
function cdm_footnotes($footnote_list_key = null, $element_tag = 'span') {
|
254 |
|
|
|
255 |
6657531f
|
Andreas Kohlbecker
|
if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
|
256 |
|
|
return '';
|
257 |
|
|
}
|
258 |
fea89e38
|
Andreas Kohlbecker
|
|
259 |
b810c46f
|
Andreas Kohlbecker
|
$out = '<' . $element_tag . ' class="footnotes footnotes-' . $footnote_list_key . ' ">'
|
260 |
|
|
. FootnoteManager::renderFootnoteList($footnote_list_key)
|
261 |
|
|
. '</' . $element_tag . '>';
|
262 |
fea89e38
|
Andreas Kohlbecker
|
|
263 |
b810c46f
|
Andreas Kohlbecker
|
FootnoteManager::removeFootnoteList($footnote_list_key);
|
264 |
6657531f
|
Andreas Kohlbecker
|
return $out;
|
265 |
|
|
}
|
266 |
|
|
|
267 |
991ae630
|
Andreas Kohlbecker
|
/**
|
268 |
|
|
* Renders the footnotes for annotations and sources, etc.
|
269 |
|
|
*
|
270 |
|
|
* @param string $footnote_list_key
|
271 |
|
|
* RenderHints::getFootnoteListKey() will be used if this parameter is undefined.
|
272 |
|
|
* @param string $enclosingTag
|
273 |
|
|
* Default tag is 'span'
|
274 |
|
|
*
|
275 |
|
|
* @return string
|
276 |
|
|
* The markup string
|
277 |
|
|
*
|
278 |
|
|
*/
|
279 |
032f17da
|
Andreas Kohlbecker
|
function render_cdm_footnotes($footnote_list_key = NULL, $enclosingTag = 'span'){
|
280 |
991ae630
|
Andreas Kohlbecker
|
|
281 |
|
|
if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
|
282 |
|
|
return '';
|
283 |
|
|
}
|
284 |
|
|
if(!$footnote_list_key){
|
285 |
|
|
$footnote_list_key = RenderHints::getFootnoteListKey();
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
$out = '<' . $enclosingTag . ' class="footnotes footnotes-' . $footnote_list_key . ' ">'
|
289 |
|
|
. FootnoteManager::renderFootnoteList($footnote_list_key . '-annotations') . ' ' . FootnoteManager::renderFootnoteList($footnote_list_key)
|
290 |
|
|
. '</' . $enclosingTag . '>';
|
291 |
|
|
FootnoteManager::removeFootnoteList($footnote_list_key . '-annotations');
|
292 |
|
|
FootnoteManager::removeFootnoteList($footnote_list_key);
|
293 |
|
|
return $out;
|
294 |
|
|
}
|
295 |
|
|
|
296 |
6657531f
|
Andreas Kohlbecker
|
/**
|
297 |
e9cc637a
|
Andreas Kohlbecker
|
* Created markup for the annotations
|
298 |
|
|
* @param null $annotations
|
299 |
|
|
* @param $enclosingTag
|
300 |
|
|
* Tag name of the DOM element to enclose the annotations.
|
301 |
|
|
*
|
302 |
|
|
* @return string
|
303 |
6657531f
|
Andreas Kohlbecker
|
*/
|
304 |
e9cc637a
|
Andreas Kohlbecker
|
function cdm_annotations($annotations = null, $enclosingTag = span) {
|
305 |
|
|
|
306 |
6657531f
|
Andreas Kohlbecker
|
if (!is_array($annotations)) {
|
307 |
e9cc637a
|
Andreas Kohlbecker
|
return '';
|
308 |
6657531f
|
Andreas Kohlbecker
|
}
|
309 |
|
|
$out = '<' . $enclosingTag . ' class="annotations">';
|
310 |
|
|
$i = 0;
|
311 |
|
|
foreach ($annotations as $annotation) {
|
312 |
|
|
$out .= ($i++ > 0 ? ', ' : '') . $annotation->text;
|
313 |
|
|
}
|
314 |
|
|
$out .= '</' . $enclosingTag . '>';
|
315 |
|
|
return $out;
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
/**
|
319 |
|
|
* @todo Please document this function.
|
320 |
|
|
* @see http://drupal.org/node/1354
|
321 |
|
|
*/
|
322 |
|
|
function cdm_exist_footnote($footnote_list, $footnote) {
|
323 |
|
|
$result = FALSE;
|
324 |
|
|
if (is_array($footnote_list)) {
|
325 |
|
|
foreach ($footnote_list as $element) {
|
326 |
|
|
if ($element == $footnote) {
|
327 |
|
|
$result = TRUE;
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
}
|
331 |
|
|
return $result;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
/**
|
335 |
|
|
* @todo Please document this function.
|
336 |
|
|
* @see http://drupal.org/node/1354
|
337 |
|
|
*/
|
338 |
|
|
function cdm_add_footnote_to_array(&$footnote_list, $footnote) {
|
339 |
|
|
if (!cdm_exist_footnote($footnote_list, $footnote)) {
|
340 |
|
|
$footnote_list[] = $footnote;
|
341 |
|
|
}
|
342 |
|
|
}
|
343 |
|
|
|
344 |
4ae6064e
|
Andreas Kohlbecker
|
/**
|
345 |
|
|
* Theme function for CDM marker instances
|
346 |
|
|
*
|
347 |
|
|
* @see compose_cdm_marker();
|
348 |
|
|
* @param array $variables
|
349 |
|
|
* - markerType_representation_l10n: the localized representation of the marker.markerType field
|
350 |
|
|
*/
|
351 |
|
|
function theme_cdm_marker($variables) {
|
352 |
|
|
$class_attribute = null;
|
353 |
|
|
//TODO class attribute hacked?, use generic drupal way?
|
354 |
|
|
if(isset($variables['attributes']['class'])){
|
355 |
|
|
$class_attribute = $variables['attributes']['class'];
|
356 |
|
|
}
|
357 |
|
|
return '<span class="' . $class_attribute . '">' . $variables['label'] . '</span>';
|
358 |
|
|
}
|
359 |
|
|
|
360 |
6657531f
|
Andreas Kohlbecker
|
/* ============================ pager ============================= */
|
361 |
c278f2a0
|
Andreas Kohlbecker
|
|
362 |
6657531f
|
Andreas Kohlbecker
|
/**
|
363 |
|
|
* @todo Please document this function.
|
364 |
|
|
* @see http://drupal.org/node/1354
|
365 |
|
|
*/
|
366 |
|
|
function theme_cdm_pager($variables) {
|
367 |
|
|
$pager = $variables['pager'];
|
368 |
|
|
$path = $variables['path'];
|
369 |
|
|
$parameters = $variables['parameters'];
|
370 |
|
|
$out = '';
|
371 |
|
|
|
372 |
|
|
if ($pager->pagesAvailable > 1) {
|
373 |
|
|
|
374 |
|
|
$out .= '<div class="pager">';
|
375 |
|
|
if ($pager->currentIndex > 0) {
|
376 |
|
|
$out .= theme('cdm_pager_link', array(
|
377 |
c278f2a0
|
Andreas Kohlbecker
|
'text' => '« ' . t('First'),
|
378 |
6657531f
|
Andreas Kohlbecker
|
'linkIndex' => 0,
|
379 |
|
|
'pager' => $pager,
|
380 |
|
|
'path' => $path,
|
381 |
|
|
'parameters' => $parameters,
|
382 |
|
|
'attributes' => array('class' => array('pager-first')),
|
383 |
|
|
));
|
384 |
|
|
$out .= theme('cdm_pager_link', array(
|
385 |
c278f2a0
|
Andreas Kohlbecker
|
'text' => '‹ ' . t('Previous'),
|
386 |
6657531f
|
Andreas Kohlbecker
|
'linkIndex' => $pager->currentIndex - 1,
|
387 |
|
|
'pager' => $pager,
|
388 |
|
|
'path' => $path,
|
389 |
|
|
'parameters' => $parameters,
|
390 |
|
|
'attributes' => array('class' => array('pager-previous')),
|
391 |
|
|
));
|
392 |
|
|
}
|
393 |
|
|
|
394 |
|
|
if ($pager->indices[0] > 0) {
|
395 |
|
|
$out .= '<div class="pager-list-dots-left">...</div>';
|
396 |
|
|
}
|
397 |
|
|
|
398 |
|
|
foreach ($pager->indices as $index) {
|
399 |
|
|
$label = $index + 1;
|
400 |
|
|
$out .= theme('cdm_pager_link', array('text' => $label, 'linkIndex' => $index, 'pager' => $pager, 'path' => $path, 'parameters' => $parameters, 'attributes' => array(
|
401 |
|
|
'class' => array('pager-first'),
|
402 |
|
|
)));
|
403 |
|
|
}
|
404 |
|
|
if ($pager->indices[count($pager->indices) - 1] < $pager->pagesAvailable - 1) {
|
405 |
|
|
$out .= '<div class="pager-list-dots-right">...</div>';
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
if ($pager->nextIndex) {
|
409 |
c278f2a0
|
Andreas Kohlbecker
|
$out .= theme(
|
410 |
|
|
'cdm_pager_link',
|
411 |
|
|
array(
|
412 |
|
|
'text' => t('Next') . ' ›',
|
413 |
|
|
'linkIndex' => $pager->nextIndex,
|
414 |
|
|
'pager' => $pager,
|
415 |
|
|
'path' => $path,
|
416 |
|
|
'parameters' => $parameters,
|
417 |
|
|
'attributes' => array(
|
418 |
|
|
'class' => array('pager-next'),
|
419 |
|
|
)
|
420 |
|
|
)
|
421 |
|
|
);
|
422 |
|
|
$out .= theme(
|
423 |
|
|
'cdm_pager_link',
|
424 |
|
|
array(
|
425 |
|
|
'text' => t('Last') . ' »',
|
426 |
|
|
'linkIndex' => $pager->pagesAvailable - 1,
|
427 |
|
|
'pager' => $pager,
|
428 |
|
|
'path' => $path,
|
429 |
|
|
'parameters' => $parameters,
|
430 |
|
|
'attributes' => array(
|
431 |
|
|
'class' => array('pager-last'),
|
432 |
|
|
)
|
433 |
|
|
)
|
434 |
|
|
);
|
435 |
6657531f
|
Andreas Kohlbecker
|
}
|
436 |
|
|
$out .= '</div>';
|
437 |
|
|
|
438 |
|
|
return $out;
|
439 |
|
|
}
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
/**
|
443 |
|
|
* @todo Please document this function.
|
444 |
|
|
* @see http://drupal.org/node/1354
|
445 |
|
|
*/
|
446 |
|
|
function theme_cdm_pager_link($variables) {
|
447 |
|
|
$text = $variables['text'];
|
448 |
|
|
$linkIndex = $variables['linkIndex'];
|
449 |
|
|
$pager = $variables['pager'];
|
450 |
|
|
$path = $variables['path'];
|
451 |
|
|
$parameters = $variables['parameters'];
|
452 |
|
|
$attributes = $variables['attributes'];
|
453 |
34dd7be9
|
Andreas Kohlbecker
|
|
454 |
17cfc574
|
Andreas Kohlbecker
|
// the parameters may still contain the q param,
|
455 |
|
|
// but this is already in the path variable
|
456 |
|
|
unset($parameters['q']);
|
457 |
|
|
|
458 |
34dd7be9
|
Andreas Kohlbecker
|
$parameters['pager']['pageNumber'] = $linkIndex;
|
459 |
6657531f
|
Andreas Kohlbecker
|
if ($linkIndex == $pager->currentIndex) {
|
460 |
|
|
$out = '<strong>' . $text . '</strong>';
|
461 |
|
|
}
|
462 |
|
|
else {
|
463 |
|
|
// $queryString = drupal_query_string_encode($parameters);
|
464 |
|
|
$queryString = $parameters;
|
465 |
|
|
$out = l($text, $path, array(
|
466 |
|
|
'attributes' => $attributes,
|
467 |
|
|
'query' => $queryString,
|
468 |
|
|
));
|
469 |
|
|
}
|
470 |
|
|
return $out;
|
471 |
|
|
}
|
472 |
|
|
|
473 |
|
|
/* ============================ special buttons ============================= */
|
474 |
|
|
|
475 |
|
|
/**
|
476 |
|
|
* @todo Please document this function.
|
477 |
|
|
* @see http://drupal.org/node/1354
|
478 |
|
|
*/
|
479 |
|
|
function theme_cdm_print_button() {
|
480 |
|
|
|
481 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
482 |
|
|
jQuery(\'#print_button\').click(function () {
|
483 |
|
|
window.print();
|
484 |
|
|
});
|
485 |
|
|
});', array('type' => 'inline'));
|
486 |
|
|
|
487 |
c8234bdf
|
Andreas Kohlbecker
|
$output = '<div id="print_button"><img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/print_icon.gif"' . ' alt="' . t('Print this page') . '" title="' . t('Print this page') . '" />';
|
488 |
6657531f
|
Andreas Kohlbecker
|
// .t('Print this page');
|
489 |
|
|
// $output .= l('Print this page', '');
|
490 |
|
|
$output .= '<span>Print this page</span>';
|
491 |
|
|
$output .= '</div>';
|
492 |
|
|
|
493 |
|
|
return $output;
|
494 |
|
|
}
|