1 |
08ea5e99
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Overrides of generic themeing functions in cdm_dataportal.theme.php.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Returns HTML for a cdm_taxon_page_profile.
|
9 |
|
|
*
|
10 |
|
|
* The description page is supposed to be the front page for a taxon.
|
11 |
|
|
*
|
12 |
|
|
* @param array $variables
|
13 |
|
|
* An associative array containing:
|
14 |
|
|
* - taxon: The taxon object displayed on the taxon page.
|
15 |
|
|
* - mergedTrees
|
16 |
|
|
* - media:
|
17 |
|
|
* - hideImages: boolean, FALSE if images should be hided.
|
18 |
|
|
*
|
19 |
|
|
* @ingroup themeable
|
20 |
|
|
*/
|
21 |
5885d957
|
Andreas Kohlbecker
|
function palmweb_2_cdm_taxon_page_profile($variables){
|
22 |
08ea5e99
|
Andreas Kohlbecker
|
|
23 |
|
|
$taxon = $variables['taxon'];
|
24 |
|
|
$mergedTrees = $variables['mergedTrees'];
|
25 |
|
|
$media = $variables['media'];
|
26 |
|
|
$hideImages = $variables['hideImages'];
|
27 |
|
|
|
28 |
|
|
$out = '';
|
29 |
|
|
|
30 |
|
|
if (!$hideImages) {
|
31 |
|
|
// Preferred image.
|
32 |
|
|
// Hardcoded for testing.
|
33 |
6d9b8e14
|
Andreas Kohlbecker
|
$defaultRepresentationPart = new stdClass();
|
34 |
08ea5e99
|
Andreas Kohlbecker
|
$defaultRepresentationPart->width = 184;
|
35 |
|
|
$defaultRepresentationPart->height = 144;
|
36 |
|
|
$defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2') . '/images/no_picture.png';
|
37 |
|
|
|
38 |
|
|
// Preferred image size 184px × 144.
|
39 |
|
|
$imageMaxExtend = 184;
|
40 |
|
|
$out .= '<div id="taxonProfileImage">';
|
41 |
|
|
$out .= theme('cdm_preferredImage', array(
|
42 |
|
|
'media' => $media,
|
43 |
|
|
'defaultRepresentationPart' => $defaultRepresentationPart,
|
44 |
|
|
'imageMaxExtend' => $imageMaxExtend,
|
45 |
|
|
));
|
46 |
|
|
$out .= '</div>';
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
// Description TOC.
|
50 |
|
|
$out .= theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees));
|
51 |
|
|
|
52 |
|
|
// Description.
|
53 |
|
|
$out .= theme('cdm_featureTrees', array('mergedTrees' => $mergedTrees, 'taxon' => $taxon));
|
54 |
|
|
|
55 |
|
|
return $out;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
/**
|
59 |
|
|
* @todo Please document this function.
|
60 |
|
|
* @see http://drupal.org/node/1354
|
61 |
|
|
*/
|
62 |
|
|
function palmweb_2_cdm_descriptionElementDistribution($variables) {
|
63 |
|
|
$descriptionElements = $variables['descriptionElements'];
|
64 |
|
|
$enclosingTag = $variables['enclosingTag'];
|
65 |
|
|
|
66 |
|
|
$out = '';
|
67 |
|
|
$separator = ', ';
|
68 |
|
|
|
69 |
|
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
70 |
|
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
71 |
|
|
|
72 |
|
|
$itemCnt = 0;
|
73 |
|
|
foreach ($descriptionElements as $descriptionElement) {
|
74 |
|
|
/*
|
75 |
|
|
$out .= ($descriptionElement->class);
|
76 |
|
|
// Annotations as footnotes.
|
77 |
|
|
$annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
|
78 |
|
|
// Source references as footnotes.
|
79 |
|
|
$sourcesFootnoteKeyList = '';
|
80 |
|
|
foreach($descriptionElement->sources as $source){
|
81 |
1b04a204
|
Andreas Kohlbecker
|
$_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_OriginalSource', $source, FALSE));
|
82 |
08ea5e99
|
Andreas Kohlbecker
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, ($sourcesFootnoteKeyList ? $separator : ''));
|
83 |
|
|
}
|
84 |
|
|
if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
|
85 |
|
|
$annotationFootnoteKeys .= $separator;
|
86 |
|
|
}
|
87 |
|
|
*/
|
88 |
5885d957
|
Andreas Kohlbecker
|
$out .= '<' . $enclosingTag . ' class="DescriptionElement DescriptionElement-' . $descriptionElement->class . '">';
|
89 |
|
|
// $out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList;
|
90 |
|
|
$out .= $descriptionElement->area->representation_L10n;
|
91 |
|
|
if (++$itemCnt < count($descriptionElements)) {
|
92 |
|
|
$out .= $separator;
|
93 |
|
|
}
|
94 |
|
|
$out .= "</" . $enclosingTag . ">";
|
95 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
96 |
|
|
$taxonTrees = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY);
|
97 |
|
|
$reference = new stdClass();
|
98 |
|
|
foreach ($taxonTrees as $taxonTree) {
|
99 |
|
|
if ($taxonTree->uuid == variable_get('cdm_taxonomictree_uuid')) {
|
100 |
|
|
if (isset($taxonTree->reference)) {
|
101 |
|
|
$reference = $taxonTree->reference;
|
102 |
|
|
}
|
103 |
|
|
break;
|
104 |
|
|
}
|
105 |
|
|
}
|
106 |
|
|
$referenceCitation = '';
|
107 |
|
|
if (isset($reference->uuid)) {
|
108 |
|
|
$referenceCitation .= '(<span class="reference">';
|
109 |
|
|
$referenceCitation .= l(t('World Checklist of Monocotyledons'), path_to_reference($reference->uuid), array('attributes' => array('class' => array('reference'))));
|
110 |
|
|
$referenceCitation .= '</span>)';
|
111 |
|
|
}
|
112 |
|
|
else {
|
113 |
|
|
// Comment @WA Added for compatibility with D5, but I think it is better to
|
114 |
|
|
// remove this to not show a link rather than the wrong one.
|
115 |
|
|
$referenceCitation .= '(<span class="reference">';
|
116 |
|
|
$referenceCitation .= l(t('World Checklist of Monocotyledons'), '', array('attributes' => array('class' => array('reference'))));
|
117 |
|
|
$referenceCitation .= '</span>)';
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
$sourceRefs = '';
|
121 |
|
|
if ($out && strlen($out) > 0) {
|
122 |
|
|
$sourceRefs = ' ' . $referenceCitation;
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
if (strlen($sourceRefs) > 0) {
|
126 |
|
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
RenderHints::popFromRenderStack();
|
130 |
|
|
return $out . $sourceRefs;
|
131 |
|
|
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
/**
|
135 |
|
|
* @todo Please document this function.
|
136 |
|
|
* @see http://drupal.org/node/1354
|
137 |
|
|
*/
|
138 |
5885d957
|
Andreas Kohlbecker
|
function palmweb_2_cdm_feature_nodesTOC($variables){
|
139 |
08ea5e99
|
Andreas Kohlbecker
|
$featureNodes = $variables['featureNodes'];
|
140 |
|
|
$out = '';
|
141 |
|
|
|
142 |
|
|
global $theme;
|
143 |
|
|
|
144 |
|
|
$out .= '<ul>';
|
145 |
|
|
$countFeatures = 0;
|
146 |
5885d957
|
Andreas Kohlbecker
|
$numberOfChildren = count(cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array (
|
147 |
08ea5e99
|
Andreas Kohlbecker
|
get_taxonomictree_uuid_selected(),
|
148 |
5885d957
|
Andreas Kohlbecker
|
substr(strrchr($_GET["q"],'/'), 1),
|
149 |
08ea5e99
|
Andreas Kohlbecker
|
)));
|
150 |
|
|
if ($numberOfChildren != 0) {
|
151 |
|
|
$out .= '<li>';
|
152 |
|
|
$out .= l(t(theme('cdm_feature_name', array('feature_name' => 'Number of Taxa'))), $_GET['q'], array(
|
153 |
|
|
'attributes' => array('class' => array('toc')),
|
154 |
|
|
'fragment' => generalizeString('Number Of Taxa'),
|
155 |
|
|
));
|
156 |
|
|
$out .= '</li>';
|
157 |
|
|
}
|
158 |
|
|
foreach ($featureNodes as $node) {
|
159 |
|
|
if (hasFeatureNodeDescriptionElements($node)) {
|
160 |
|
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
161 |
|
|
|
162 |
|
|
// HACK to implement images for taxa, should be removed.
|
163 |
|
|
if ($node->feature->uuid != UUID_IMAGE && $node->feature->uuid != UUID_USE) {
|
164 |
|
|
$countFeatures++;
|
165 |
|
|
$countFeatures++;
|
166 |
|
|
$out .= '<li>' . l(t(theme('cdm_feature_name', array('feature_name' => $featureRepresentation))), $_GET['q'],
|
167 |
|
|
array('attributes' => array('class' => array('toc')),'fragment' => generalizeString($featureRepresentation))) . '</li>';
|
168 |
|
|
}
|
169 |
|
|
}
|
170 |
|
|
}
|
171 |
|
|
// Setting the Anchor to the Bibliography section if the option is enabled.
|
172 |
|
|
$show_bibliography = variable_get('cdm_show_bibliography', 1);
|
173 |
|
|
|
174 |
|
|
$markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
|
175 |
5885d957
|
Andreas Kohlbecker
|
$useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, substr(strrchr($_GET["q"], '/'), 1), queryString($markerTypes));
|
176 |
08ea5e99
|
Andreas Kohlbecker
|
if (!empty($useDescriptions)) {
|
177 |
|
|
$out .= '<li>';
|
178 |
|
|
$out .= l(t(theme('cdm_feature_name', array('feature_name' => 'Uses'))), $_GET['q'], array(
|
179 |
|
|
'attributes' => array('class' => array('toc')),
|
180 |
|
|
'fragment' => 'userecords',
|
181 |
|
|
));
|
182 |
|
|
$out .= '</li>';
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
if ($show_bibliography && $countFeatures != 0) {
|
186 |
|
|
$out .= '<li>' . l(t(theme('cdm_feature_name', array('feature_name' => 'Bibliography'))), $_GET['q'], array('attributes' => array('class' => array('toc')), 'fragment' => 'bibliography')) . '</li>';
|
187 |
|
|
}
|
188 |
|
|
$out .= '</ul>';
|
189 |
|
|
return $out;
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
/**
|
193 |
|
|
* @todo Please document this function.
|
194 |
|
|
* @see http://drupal.org/node/1354
|
195 |
|
|
*/
|
196 |
5885d957
|
Andreas Kohlbecker
|
function palmweb_2_cdm_feature_nodes($variables){
|
197 |
08ea5e99
|
Andreas Kohlbecker
|
$mergedFeatureNodes = $variables['mergedFeatureNodes'];
|
198 |
|
|
$taxon = $variables['taxon'];
|
199 |
|
|
|
200 |
|
|
$out = '';
|
201 |
|
|
RenderHints::pushToRenderStack('feature_nodes');
|
202 |
|
|
|
203 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
|
204 |
|
|
// Creating an array to place the description elements in.
|
205 |
|
|
$bibliographyOut = array();
|
206 |
|
|
$countFeatures = 0;
|
207 |
5885d957
|
Andreas Kohlbecker
|
$numberOfChildren = count(cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array (get_taxonomictree_uuid_selected(), $taxon->uuid)));
|
208 |
08ea5e99
|
Andreas Kohlbecker
|
if ($taxon->name->rank->titleCache == "Genus") {
|
209 |
|
|
$subRank = "species";
|
210 |
|
|
}
|
211 |
|
|
if ($taxon->name->rank->titleCache == "Species") {
|
212 |
|
|
$subRank = "infraspecific taxa";
|
213 |
|
|
}
|
214 |
|
|
if ($numberOfChildren != 0) {
|
215 |
|
|
$out .= '<a name="number_of_taxa"> </a><H2>Number of Taxa</H2><div class="content"> <ul class="description">';
|
216 |
|
|
$out .= '<li class=\"descriptionText DescriptionElement\">' . $numberOfChildren . " " . $subRank . '</li></ul>';
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
foreach ($mergedFeatureNodes as $node) {
|
220 |
|
|
|
221 |
|
|
if (hasFeatureNodeDescriptionElements($node)) {
|
222 |
|
|
|
223 |
|
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
224 |
6d9b8e14
|
Andreas Kohlbecker
|
$block = new stdClass();
|
225 |
08ea5e99
|
Andreas Kohlbecker
|
$block->module = 'cdm_dataportal';
|
226 |
|
|
// If the option is enabled the description elements will be added
|
227 |
|
|
// to the array.
|
228 |
|
|
$show_bibliography = variable_get('cdm_show_bibliography', 1);
|
229 |
|
|
if ($show_bibliography) {
|
230 |
|
|
$bibliographyOut[] = $node->descriptionElements;
|
231 |
|
|
}
|
232 |
|
|
$media_list = array();
|
233 |
|
|
if ($node->feature->uuid != UUID_IMAGE && $node->feature->uuid != UUID_USE) {
|
234 |
|
|
$countFeatures++;
|
235 |
|
|
$countFeatures++;
|
236 |
|
|
$block->delta = generalizeString($featureRepresentation);
|
237 |
5885d957
|
Andreas Kohlbecker
|
$block->subject = '<span class="' . html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name', array('feature_name' => $featureRepresentation)) . '</span>';
|
238 |
08ea5e99
|
Andreas Kohlbecker
|
$block->module = "cdm_dataportal-feature";
|
239 |
|
|
$block->content = '';
|
240 |
|
|
|
241 |
|
|
/*
|
242 |
|
|
Content/DISTRIBUTION.
|
243 |
|
|
*/
|
244 |
|
|
if ($node->feature->uuid == UUID_DISTRIBUTION) {
|
245 |
|
|
|
246 |
|
|
if (variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
|
247 |
|
|
$distributionTextDataList = array();
|
248 |
|
|
$distributionElementsList = array();
|
249 |
|
|
|
250 |
|
|
foreach ($node->descriptionElements as $descriptionElement) {
|
251 |
|
|
if ($descriptionElement->class == "TextData") {
|
252 |
|
|
$distributionTextDataList[] = $descriptionElement;
|
253 |
|
|
}
|
254 |
|
|
else {
|
255 |
|
|
$distributionElementsList[] = $descriptionElement;
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
|
|
if (count($distributionTextDataList) > 0) {
|
259 |
|
|
$node->descriptionElements = $distributionElementsList;
|
260 |
|
|
$block->content .= theme('cdm_descriptionElements', array(
|
261 |
|
|
'descriptionElements' => $distributionTextDataList,
|
262 |
|
|
'featureUuid' => $node->feature->uuid,
|
263 |
|
|
'taxon_uuid' => $taxon->uuid,
|
264 |
|
|
));
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
// Display cdm distribution map.
|
269 |
|
|
// TODO this is a HACK to a proper generic implementation?
|
270 |
|
|
$block->content .= theme('cdm_distribution_map', array('taxon' => $taxon));
|
271 |
|
|
$block->content .= theme('cdm_descriptionElements', array(
|
272 |
|
|
'descriptionElements' => $node->descriptionElements,
|
273 |
|
|
'featureUuid' => $node->feature->uuid,
|
274 |
|
|
'taxon_uuid' => $taxon->uuid,
|
275 |
|
|
));
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
/*
|
279 |
|
|
Content/COMMON_NAME.
|
280 |
|
|
*/
|
281 |
|
|
elseif ($node->feature->uuid == UUID_COMMON_NAME) {
|
282 |
|
|
// TODO why is theme_cdm_descriptionElement_CommonTaxonName
|
283 |
|
|
// not beeing used???
|
284 |
|
|
$block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
|
285 |
5885d957
|
Andreas Kohlbecker
|
/*
|
286 |
|
|
}else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
|
287 |
|
|
$block->content .= theme('cdm_image_sources', $node->descriptionElements);
|
288 |
|
|
*/
|
289 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
290 |
|
|
|
291 |
|
|
/*
|
292 |
|
|
Content/ALL OTHER FEATURES.
|
293 |
|
|
*/
|
294 |
|
|
elseif ($node->feature->uuid == UUID_USE_RECORD) {
|
295 |
|
|
$block->content .= theme('cdm_block_Uses', $taxon->uuid);
|
296 |
|
|
// $block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid),
|
297 |
|
|
}
|
298 |
|
|
else {
|
299 |
|
|
$block->content .= theme('cdm_descriptionElements', array(
|
300 |
|
|
'descriptionElements' => $node->descriptionElements,
|
301 |
|
|
'featureUuid' => $node->feature->uuid,
|
302 |
|
|
'taxon_uuid' => $taxon->uuid,
|
303 |
|
|
));
|
304 |
|
|
|
305 |
|
|
/*
|
306 |
|
|
Content/ALL OTHER FEATURES/Subordinate Features
|
307 |
|
|
subordinate features are printed inline in one floating text,
|
308 |
|
|
it is expected that subordinate features only "contain" TextData
|
309 |
|
|
elements.
|
310 |
|
|
*/
|
311 |
|
|
// TODO move into own theme.
|
312 |
|
|
if (count($node->children) > 0) {
|
313 |
|
|
|
314 |
|
|
// TODO support more than one level of children.
|
315 |
|
|
// @see http://dev.e-taxonomy.eu/trac/ticket/2393/
|
316 |
|
|
$text = '';
|
317 |
|
|
foreach ($node->children as $child) {
|
318 |
5885d957
|
Andreas Kohlbecker
|
if (is_array($child->descriptionElements)) {
|
319 |
|
|
foreach ($child->descriptionElements as $element) {
|
320 |
|
|
|
321 |
|
|
if (is_array($element->media)) {
|
322 |
|
|
// Append media of subordinate elements to the list of
|
323 |
|
|
// main features.
|
324 |
|
|
$media_list = array_merge($media_list, $element->media);
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
328 |
|
|
// TODO use localized version of feature name, the locale must
|
329 |
|
|
// match the locale of the multilanguage text
|
330 |
|
|
// (http://dev.e-taxonomy.eu/trac/ticket/2394).
|
331 |
|
|
$description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
|
332 |
|
|
}
|
333 |
|
|
$text .= " " . $description;
|
334 |
|
|
$description = '';
|
335 |
|
|
}
|
336 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
337 |
|
|
$block->content .= $text;
|
338 |
|
|
}
|
339 |
|
|
}
|
340 |
|
|
|
341 |
|
|
/*
|
342 |
|
|
Media/ALL FEATURES.
|
343 |
|
|
*/
|
344 |
|
|
$media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
|
345 |
|
|
|
346 |
|
|
$gallery = theme('cdm_media_gallerie', array(
|
347 |
|
|
'mediaList' => $media_list,
|
348 |
|
|
'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
|
349 |
|
|
'maxExtend' => isset($gallery_settings['cdm_dataportal_media_maxextend']) ? $gallery_settings['cdm_dataportal_media_maxextend'] : NULL ,
|
350 |
|
|
'cols' => isset($gallery_settings['cdm_dataportal_media_cols']) ? $gallery_settings['cdm_dataportal_media_cols'] : NULL ,
|
351 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? $gallery_settings['cdm_dataportal_media_maxRows'] : NULL ,
|
352 |
|
|
'captionElements' => isset($captionElements) ? $captionElements : NULL ,
|
353 |
|
|
)
|
354 |
|
|
);
|
355 |
|
|
|
356 |
|
|
$block->content .= $gallery;
|
357 |
|
|
$block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
|
358 |
|
|
$block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
|
359 |
|
|
|
360 |
|
|
// Add anchor to subject.
|
361 |
|
|
$block->subject = '<a name="' . $block->delta . '"></a>' . $block->subject;
|
362 |
|
|
|
363 |
|
|
$block->region = FALSE;
|
364 |
5885d957
|
Andreas Kohlbecker
|
$out .= theme('block', array('elements' => array(
|
365 |
|
|
'#block' => $block,
|
366 |
|
|
'#children' => $block->content,
|
367 |
|
|
)));
|
368 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
369 |
|
|
}
|
370 |
|
|
}
|
371 |
|
|
// Calling the theme function for Bibliography to add it to the output.
|
372 |
|
|
// Add the display of the number of taxa in the selected genus.
|
373 |
|
|
$out .= theme('cdm_block_Uses', array('taxonUuid' => $taxon->uuid));
|
374 |
|
|
|
375 |
|
|
$show_bibliography = variable_get('cdm_show_bibliography', 1);
|
376 |
|
|
if ($show_bibliography && $countFeatures != 0) {
|
377 |
|
|
$out .= theme('cdm_descriptionElementBibliography', array('descriptionElementsBibliography' => $bibliographyOut));
|
378 |
|
|
}
|
379 |
|
|
|
380 |
|
|
RenderHints::popFromRenderStack();
|
381 |
|
|
return $out;
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
/**
|
385 |
|
|
* @todo Please document this function.
|
386 |
|
|
* @see http://drupal.org/node/1354
|
387 |
|
|
*/
|
388 |
|
|
function palmweb_2_cdm_search_results($variables){
|
389 |
|
|
$pager = $variables['pager'];
|
390 |
|
|
$path = $variables['path'];
|
391 |
|
|
$query_parameters = $variables['query_parameters'];
|
392 |
|
|
$out = '';
|
393 |
|
|
|
394 |
|
|
$showThumbnails = isset($_SESSION['pageoption']['searchtaxa']['showThumbnails']) ? $_SESSION['pageoption']['searchtaxa']['showThumbnails'] : 0;
|
395 |
|
|
if (!is_numeric($showThumbnails)) {
|
396 |
|
|
// AT RBG KEW - 14/11/2011 - Set the show thumbnails to 0 by default.
|
397 |
|
|
$showThumbnails = 0;
|
398 |
|
|
}
|
399 |
|
|
$setSessionUri = url('cdm_api/setvalue/session', array('query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => '')));
|
400 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
401 |
|
|
|
402 |
|
|
// Init.
|
403 |
|
|
if(' . $showThumbnails . ' == 1){
|
404 |
|
|
jQuery(\'.media_gallery\').show(20);
|
405 |
|
|
} else {
|
406 |
|
|
jQuery(\'.media_gallery\').hide(20);
|
407 |
|
|
}
|
408 |
|
|
// Add change hander.
|
409 |
|
|
jQuery(\'#showThumbnails\').change(
|
410 |
|
|
function(event){
|
411 |
|
|
var state = 0;
|
412 |
|
|
if(jQuery(this).is(\':checked\')){
|
413 |
|
|
jQuery(\'.media_gallery\').show(20);
|
414 |
|
|
state = 1;
|
415 |
|
|
} else {
|
416 |
|
|
jQuery(\'.media_gallery\').hide(20);
|
417 |
|
|
}
|
418 |
|
|
// Store state in session variable.
|
419 |
|
|
var uri = \'' . $setSessionUri . '\' + state;
|
420 |
|
|
jQuery.get(uri);
|
421 |
|
|
});
|
422 |
|
|
});', "inline");
|
423 |
|
|
|
424 |
|
|
drupal_set_title(t('Search results'));
|
425 |
|
|
|
426 |
|
|
// AT RBG KEW - 14/11/2011 - Changed the wording of the Show Thumbnails
|
427 |
|
|
// tickbox text.
|
428 |
|
|
$out .= '<div class="page_options">';
|
429 |
|
|
$out .= '<form name="pageoptions">';
|
430 |
|
|
$out .= '<input id="showThumbnails" type="checkbox" name="showThumbnails" ';
|
431 |
|
|
$out .= $showThumbnails == 1 ? 'checked="checked"' : '';
|
432 |
|
|
$out .= '> ' . t('Show Image Thumbnails') . '</form></div>';
|
433 |
|
|
if (!empty($pager) && count($pager->records) > 0) {
|
434 |
|
|
$out .= '<div id="search_results">';
|
435 |
5885d957
|
Andreas Kohlbecker
|
$out .= theme('cdm_list_of_taxa', array('records' => $pager->records));
|
436 |
|
|
$out .= '</div>';
|
437 |
|
|
$out .= theme('cdm_pager', array(
|
438 |
|
|
'pager' => $pager,
|
439 |
|
|
'path' => $path,
|
440 |
|
|
'parameters' => $query_parameters,
|
441 |
08ea5e99
|
Andreas Kohlbecker
|
));
|
442 |
|
|
}
|
443 |
|
|
else {
|
444 |
|
|
$out = '<h4 class="error">Sorry, no matching entries found.</h4>';
|
445 |
|
|
}
|
446 |
|
|
return $out;
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
/*
|
450 |
|
|
Comment @WA: theme function moved to cdm_dataportal module,
|
451 |
|
|
theme/cdm_dataportal.bibliography.theme so this can be used by other portals
|
452 |
|
|
as well.
|
453 |
|
|
@TODO: should this not be part of the palmweb_2 featuretree and be treated
|
454 |
|
|
as a normal description feature?
|
455 |
|
|
function theme_cdm_descriptionElementBibliography
|
456 |
|
|
function formatReference_for_Bibliography($references) {
|
457 |
|
|
*/
|
458 |
|
|
|
459 |
|
|
/**
|
460 |
|
|
* @todo Please document this function.
|
461 |
|
|
*/
|
462 |
|
|
function palmweb_2_cdm_media_caption($variables){
|
463 |
|
|
$media = $variables['media'];
|
464 |
|
|
$elements = $variables['elements'];
|
465 |
|
|
$fileUri = $variables['fileUri'];
|
466 |
|
|
|
467 |
|
|
$media_metadata = cdm_read_media_metadata($media);
|
468 |
|
|
|
469 |
|
|
$doTitle = !$elements || array_search('title', $elements) !== FALSE;
|
470 |
|
|
$doDescription = !$elements || array_search('description', $elements) !== FALSE;
|
471 |
|
|
$doArtist = !$elements || array_search('artist', $elements) !== FALSE;
|
472 |
|
|
$doLocation = !$elements || array_search('location', $elements) !== FALSE;
|
473 |
|
|
$doRights = !$elements || array_search('rights', $elements) !== FALSE;
|
474 |
|
|
|
475 |
|
|
$descriptionPrefix = "";
|
476 |
|
|
|
477 |
|
|
$out = '<dl class="media-caption">';
|
478 |
|
|
// Title.
|
479 |
|
|
if ($doTitle) {
|
480 |
|
|
if ($media_metadata['title']) {
|
481 |
|
|
$out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>';
|
482 |
|
|
$descriptionPrefix = "- ";
|
483 |
|
|
}
|
484 |
|
|
elseif (!($doDescription && $media_metadata['description'])) {
|
485 |
|
|
// Use filename as fallbackoption if no description will be shown.
|
486 |
|
|
$out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['filename'] . '</dd>';
|
487 |
|
|
$descriptionPrefix = "- ";
|
488 |
|
|
}
|
489 |
|
|
}
|
490 |
|
|
// Description.
|
491 |
|
|
if ($media_metadata['description'] && $doDescription) {
|
492 |
|
|
$out .= '<dt class = "description">' . t('Description') . '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>';
|
493 |
|
|
}
|
494 |
|
|
// Artist.
|
495 |
|
|
if ($media_metadata['artist'] && $doArtist) {
|
496 |
|
|
$out .= '<dt class = "artist">' . t('Artist') . '</dt> <dd class = "astist">' . str_replace("'","", $media_metadata['artist']) . '</dd>';
|
497 |
|
|
}
|
498 |
|
|
// Location.
|
499 |
|
|
if ($doLocation) {
|
500 |
|
|
$location = '';
|
501 |
|
|
$location .= $media_metadata['location']['sublocation'];
|
502 |
|
|
if ($location && $media_metadata['location']['city']) {
|
503 |
|
|
$location .= ', ';
|
504 |
|
|
}
|
505 |
|
|
$location .= $media_metadata['location']['city'];
|
506 |
|
|
if ($location && $media_metadata['location']['province']) {
|
507 |
|
|
$location .= ', ';
|
508 |
|
|
}
|
509 |
|
|
$location .= $media_metadata['location']['province'];
|
510 |
|
|
if ($location && $media_metadata['location']['country']) {
|
511 |
|
|
$location .= ' (' . $media_metadata['location']['country'] . ')';
|
512 |
|
|
}
|
513 |
|
|
else {
|
514 |
|
|
$location .= $media_metadata['location']['country'];
|
515 |
|
|
}
|
516 |
|
|
if ($location) {
|
517 |
|
|
$out .= '<dt class = "location">' . t('Location') . '</dt> <dd class = "location">' . $location . '</dd>';
|
518 |
|
|
}
|
519 |
|
|
}
|
520 |
|
|
// Rights.
|
521 |
|
|
if ($doRights) {
|
522 |
|
|
$rights = '';
|
523 |
|
|
// Copyrights.
|
524 |
|
|
$cnt = count($media_metadata['rights']['copyright']['agentNames']);
|
525 |
|
|
if ($cnt > 0) {
|
526 |
|
|
$rights .= '<dt class="rights">©</dt> <dd class="rights"> ';
|
527 |
|
|
for ($i = 0; $i < $cnt; $i++) {
|
528 |
|
|
$rights .= str_replace("'","", $media_metadata['rights']['copyright']['agentNames'][$i]);
|
529 |
|
|
if ($i + 1 < $cnt) {
|
530 |
|
|
$rights .= ' / ';
|
531 |
|
|
}
|
532 |
|
|
}
|
533 |
|
|
$rights .= '</dd>';
|
534 |
|
|
}
|
535 |
|
|
// License.
|
536 |
|
|
$cnt = count($media_metadata['rights']['license']['agentNames']);
|
537 |
|
|
if ($cnt > 0) {
|
538 |
|
|
$rights .= '<dt class ="license">' . t('License') . '</dt> <dd class = "license">';
|
539 |
|
|
for ($i = 0; $i < $cnt; $i++) {
|
540 |
|
|
$rights .= $media_metadata['rights']['license']['agentNames'][$i];
|
541 |
|
|
if ($i + 1 < $cnt) {
|
542 |
|
|
$rights .= ' / ';
|
543 |
|
|
}
|
544 |
|
|
}
|
545 |
|
|
$rights .= '</dd>';
|
546 |
|
|
}
|
547 |
|
|
if ($rights) {
|
548 |
|
|
$out .= $rights . '</dt>';
|
549 |
|
|
}
|
550 |
|
|
}
|
551 |
|
|
// TODO add all other metadata elemenst generically.
|
552 |
|
|
$out .= '</dl>';
|
553 |
|
|
// Return value.
|
554 |
|
|
return $out;
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
/**
|
558 |
|
|
* @todo document this function.
|
559 |
|
|
*/
|
560 |
|
|
function palmweb_2_cdm_reference($variables) {
|
561 |
|
|
$reference = $variables['reference'];
|
562 |
|
|
$microReference = $variables['microReference'];
|
563 |
|
|
$doLink = $variables['doLink'];
|
564 |
|
|
$referenceStyle = $variables['referenceStyle'];
|
565 |
|
|
|
566 |
|
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
|
567 |
|
|
|
568 |
|
|
$year = '';
|
569 |
|
|
if (isset($reference->datePublished->start)) {
|
570 |
|
|
$year = partialToYear($reference->datePublished->start);
|
571 |
|
|
}
|
572 |
|
|
$citation = _short_form_of_author_team ($author_team->titleCache) . (!empty($year) ? '. ' . $year : '');
|
573 |
|
|
$citation = str_replace('..', '.', $citation);
|
574 |
|
|
|
575 |
|
|
if ($doLink) {
|
576 |
|
|
$out = '<span class="reference">';
|
577 |
|
|
$out .= l($citation, path_to_reference($reference->uuid), array(
|
578 |
|
|
'attributes' => array('class' => 'reference'),
|
579 |
|
|
'absolute' => TRUE,
|
580 |
|
|
'html' => TRUE,
|
581 |
|
|
));
|
582 |
|
|
$out .= '</span>';
|
583 |
|
|
}
|
584 |
|
|
else {
|
585 |
|
|
$out = '<span class="reference">' . $citation . '</span>';
|
586 |
|
|
}
|
587 |
|
|
// FIXME use microreference webservice instead.
|
588 |
|
|
if (!empty($descriptionElementSource->citationMicroReference)) {
|
589 |
|
|
$out .= ': ' . $descriptionElementSource->citationMicroReference;
|
590 |
|
|
}
|
591 |
|
|
|
592 |
|
|
return $out;
|
593 |
|
|
}
|
594 |
|
|
|
595 |
|
|
/**
|
596 |
|
|
* Sets the body-tag class attribute.
|
597 |
|
|
*
|
598 |
|
|
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
|
599 |
|
|
*/
|
600 |
|
|
function phptemplate_body_class($sidebar_left, $sidebar_right) {
|
601 |
|
|
if ($sidebar_left != '' && $sidebar_right != '') {
|
602 |
|
|
$class = 'sidebars';
|
603 |
|
|
}
|
604 |
|
|
else {
|
605 |
|
|
if ($sidebar_left != '') {
|
606 |
|
|
$class = 'sidebar-left';
|
607 |
|
|
}
|
608 |
|
|
if ($sidebar_right != '') {
|
609 |
|
|
$class = 'sidebar-right';
|
610 |
|
|
}
|
611 |
|
|
}
|
612 |
|
|
|
613 |
|
|
if (isset($class)) {
|
614 |
|
|
print ' class="' . $class . '"';
|
615 |
|
|
}
|
616 |
|
|
}
|
617 |
|
|
|
618 |
|
|
/**
|
619 |
|
|
* Allow themeable wrapping of all comments.
|
620 |
|
|
*/
|
621 |
|
|
function phptemplate_comment_wrapper($content, $type = NULL) {
|
622 |
|
|
static $node_type;
|
623 |
|
|
if (isset($type)) {
|
624 |
|
|
$node_type = $type;
|
625 |
|
|
}
|
626 |
|
|
|
627 |
|
|
if (!$content || $node_type == 'forum') {
|
628 |
|
|
return '<div id="comments">' . $content . '</div>';
|
629 |
|
|
}
|
630 |
|
|
else {
|
631 |
|
|
return '<div id="comments"><h2 class="comments">' . t('Comments') . '</h2>' . $content . '</div>';
|
632 |
|
|
}
|
633 |
|
|
}
|
634 |
|
|
|
635 |
|
|
/**
|
636 |
|
|
* Override or insert PHPTemplate variables into the templates.
|
637 |
|
|
*/
|
638 |
|
|
function _phptemplate_variables($hook, $vars) {
|
639 |
|
|
if ($hook == 'page') {
|
640 |
|
|
|
641 |
|
|
if ($secondary = menu_secondary_local_tasks()) {
|
642 |
|
|
$output = '<span class="clear"></span>';
|
643 |
|
|
$output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
|
644 |
|
|
$vars['tabs2'] = $output;
|
645 |
|
|
}
|
646 |
|
|
|
647 |
|
|
// Hook into color.module
|
648 |
|
|
if (module_exists('color')) {
|
649 |
|
|
_color_page_alter($vars);
|
650 |
|
|
}
|
651 |
|
|
return $vars;
|
652 |
|
|
}
|
653 |
|
|
return array();
|
654 |
|
|
}
|
655 |
|
|
|
656 |
|
|
/**
|
657 |
|
|
* Returns the rendered local tasks. The default implementation renders
|
658 |
|
|
* them as tabs.
|
659 |
|
|
*
|
660 |
|
|
* @ingroup themeable
|
661 |
|
|
*/
|
662 |
|
|
function phptemplate_menu_local_tasks() {
|
663 |
|
|
$output = '';
|
664 |
|
|
|
665 |
|
|
if ($primary = menu_primary_local_tasks()) {
|
666 |
|
|
$output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
|
667 |
|
|
}
|
668 |
|
|
|
669 |
|
|
return $output;
|
670 |
|
|
}
|
671 |
|
|
|
672 |
|
|
/**
|
673 |
0f5f1c12
|
Andreas Kohlbecker
|
* @deprecated define name render templates via the layout settings
|
674 |
08ea5e99
|
Andreas Kohlbecker
|
*/
|
675 |
|
|
function palmweb_2_get_partDefinition($variables) {
|
676 |
|
|
|
677 |
0f5f1c12
|
Andreas Kohlbecker
|
return array(
|
678 |
|
|
'BotanicalName'=> array(
|
679 |
d5bfe2da
|
Andreas Kohlbecker
|
'namePart' => array('name' => TRUE, 'authors' => TRUE),
|
680 |
|
|
'authorshipPart' => array(),
|
681 |
0f5f1c12
|
Andreas Kohlbecker
|
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
|
682 |
|
|
'statusPart' => array('status' => TRUE),
|
683 |
|
|
'descriptionPart' => array('description' => TRUE),
|
684 |
|
|
),
|
685 |
|
|
'ZoologicalName' => array(
|
686 |
|
|
'namePart' => array('name' => TRUE),
|
687 |
|
|
'referencePart' => array('authorTeam' => TRUE),
|
688 |
|
|
'microreferencePart' => array('microreference' => TRUE),
|
689 |
|
|
'statusPart' => array('status' => TRUE),
|
690 |
|
|
'descriptionPart' => array('description' => TRUE),
|
691 |
|
|
),
|
692 |
|
|
'#DEFAULT' => array(
|
693 |
|
|
'namePart' => array(
|
694 |
|
|
'name' => TRUE,
|
695 |
|
|
'authorTeam' => TRUE
|
696 |
|
|
),
|
697 |
|
|
'referencePart' => array(
|
698 |
|
|
'reference' => TRUE
|
699 |
|
|
),
|
700 |
|
|
'microreferencePart' => array(
|
701 |
|
|
'microreference' => TRUE,
|
702 |
|
|
),
|
703 |
|
|
'statusPart' => array(
|
704 |
|
|
'status' => TRUE,
|
705 |
|
|
),
|
706 |
|
|
'descriptionPart' => array(
|
707 |
|
|
'description' => TRUE,
|
708 |
|
|
),
|
709 |
|
|
)
|
710 |
|
|
);
|
711 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
712 |
|
|
|
713 |
|
|
/**
|
714 |
0f5f1c12
|
Andreas Kohlbecker
|
* @deprecated define name render templates via the layout settings
|
715 |
08ea5e99
|
Andreas Kohlbecker
|
*/
|
716 |
|
|
function palmweb_2_get_nameRenderTemplate($variables){
|
717 |
0f5f1c12
|
Andreas Kohlbecker
|
return array(
|
718 |
|
|
'acceptedFor' =>
|
719 |
|
|
$template = array(
|
720 |
|
|
'namePart' => array('#uri'=>TRUE),
|
721 |
|
|
),
|
722 |
|
|
'typedesignations' => array(
|
723 |
|
|
'namePart' => array('#uri'=>TRUE),
|
724 |
|
|
'referencePart' => TRUE,
|
725 |
|
|
),
|
726 |
|
|
'taxon_page_title,list_of_taxa,taxon_page_synonymy,related_taxon,polytomousKey' => array(
|
727 |
|
|
'namePart' => array('#uri'=>TRUE),
|
728 |
|
|
'referencePart' => TRUE,
|
729 |
|
|
'descriptionPart' => TRUE,
|
730 |
|
|
'statusPart' => TRUE,
|
731 |
|
|
),
|
732 |
|
|
'#DEFAULT' => array(
|
733 |
|
|
'namePart' => array('#uri'=>TRUE),
|
734 |
|
|
'referencePart' => TRUE,
|
735 |
|
|
'descriptionPart' => TRUE,
|
736 |
|
|
'statusPart' => TRUE,
|
737 |
|
|
)
|
738 |
|
|
);
|
739 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
740 |
|
|
|
741 |
|
|
/**
|
742 |
|
|
* @todo Please document this function.
|
743 |
|
|
* @see http://drupal.org/node/1354
|
744 |
|
|
*/
|
745 |
|
|
function palmweb_2_cdm_feature_name($variables){
|
746 |
|
|
$feature_name = $variables['feature_name'];
|
747 |
|
|
switch ($feature_name) {
|
748 |
|
|
case "Protologue": return t("Original Publication");
|
749 |
|
|
default: return t(ucfirst($feature_name));
|
750 |
|
|
}
|
751 |
|
|
}
|
752 |
|
|
|
753 |
|
|
/**
|
754 |
|
|
* @todo Please document this function.
|
755 |
|
|
* @see http://drupal.org/node/1354
|
756 |
|
|
*/
|
757 |
|
|
function palmweb_2_cdm_taxon_page_title($variables){
|
758 |
|
|
$taxon = $variables['taxon'];
|
759 |
|
|
$uuid = $variables['uuid'];
|
760 |
|
|
$synonym_uuid = $variables['synonym_uuid'];
|
761 |
|
|
|
762 |
|
|
RenderHints::pushToRenderStack('taxon_page_title');
|
763 |
|
|
$synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $synonym_uuid);
|
764 |
|
|
$referenceUri = '';
|
765 |
|
|
if (isset($taxon->name->nomenclaturalReference)) {
|
766 |
|
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
767 |
|
|
}
|
768 |
|
|
|
769 |
|
|
$out = theme('cdm_taxonName', array(
|
770 |
|
|
'taxonName' => $taxon->name,
|
771 |
|
|
'nameLink' => NULL,
|
772 |
|
|
'refenceLink' => $referenceUri,
|
773 |
|
|
'show_annotations' => FALSE,
|
774 |
|
|
));
|
775 |
|
|
|
776 |
|
|
RenderHints::popFromRenderStack();
|
777 |
|
|
if (isset($synonym->name->titleCache)) {
|
778 |
|
|
$result = '<span class = "synonym_title">' . $synonym->name->titleCache . ' is synonym of ' . '</span>' .
|
779 |
|
|
'<span class="' . $taxon->class . '">' . $out . '</span>';
|
780 |
|
|
}
|
781 |
|
|
else {
|
782 |
|
|
$result = '<span class="' . $taxon->class . '">' . $out . '</span>';
|
783 |
|
|
}
|
784 |
|
|
return $result;
|
785 |
|
|
|
786 |
|
|
}
|
787 |
|
|
|
788 |
|
|
// Comment @WA this theme function does not exist..
|
789 |
|
|
/*
|
790 |
|
|
function palmweb_2_cdm_uri_to_synonym($synonymUuid, $acceptedUuid, $pagePart = NULL) {
|
791 |
|
|
$acceptedPath = path_to_taxon($acceptedUuid, TRUE);
|
792 |
|
|
return url($acceptedPath . ($pagePart ? '/'.$pagePart : '') . '/'.$synonymUuid, 'highlite='.$synonymUuid);
|
793 |
|
|
//return url($acceptedPath.($pagePart ? '/'.$pagePart : ''), 'highlite='.$synonymUuid, $synonymUuid."/$synonymUuid");
|
794 |
|
|
//return url("$acceptedPath/$synonymUuid".($pagePart ? '/'.$pagePart : ''), 'highlite='.$synonymUuid);
|
795 |
|
|
}
|
796 |
|
|
*/
|
797 |
|
|
|
798 |
|
|
/**
|
799 |
|
|
* Implements hook_preprocess_HOOK() for theme_page().
|
800 |
|
|
*
|
801 |
|
|
* Assign the css classes primary-links and secondary-links to the menus and
|
802 |
|
|
* process the 'Login' menu item, to change into 'My account' after login and
|
803 |
|
|
* change the tab title for the IMCE file browser.
|
804 |
|
|
*
|
805 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
806 |
|
|
*/
|
807 |
|
|
function palmweb_2_preprocess_page(&$vars) {
|
808 |
|
|
|
809 |
|
|
if (isset($vars['main_menu'])) {
|
810 |
|
|
// For the Palmae theme we want to change the menu item 'Login' into
|
811 |
|
|
// 'My account' if a user is logged in.
|
812 |
|
|
global $user;
|
813 |
|
|
foreach ($vars['main_menu'] as $key => $value) {
|
814 |
|
|
if ($value['href'] == 'user' && !empty($user->name)) {
|
815 |
|
|
$vars['main_menu'][$key]['title'] = t('My account');
|
816 |
|
|
$vars['main_menu'][$key]['href'] = 'user/' . $user->uid;
|
817 |
|
|
}
|
818 |
|
|
}
|
819 |
|
|
// Theme the main menu with the desired css classes.
|
820 |
|
|
$vars['primary_nav'] = theme('links__system_main_menu', array(
|
821 |
|
|
'links' => $vars['main_menu'],
|
822 |
|
|
'attributes' => array(
|
823 |
|
|
'class' => array('links', 'inline', 'main-menu', 'primary-links'),
|
824 |
|
|
),
|
825 |
|
|
'heading' => array(
|
826 |
|
|
'text' => t('Main menu'),
|
827 |
|
|
'level' => 'h2',
|
828 |
|
|
'class' => array('element-invisible'),
|
829 |
|
|
)));
|
830 |
|
|
}
|
831 |
|
|
else {
|
832 |
|
|
$vars['primary_nav'] = FALSE;
|
833 |
|
|
}
|
834 |
|
|
if (isset($vars['secondary_menu'])) {
|
835 |
|
|
$vars['secondary_nav'] = theme('links__system_secondary_menu', array(
|
836 |
|
|
'links' => $vars['secondary_menu'],
|
837 |
|
|
'attributes' => array(
|
838 |
|
|
'class' => array('links', 'inline', 'secondary-menu', 'secondary-links'),
|
839 |
|
|
),
|
840 |
|
|
'heading' => array(
|
841 |
|
|
'text' => t('Secondary menu'),
|
842 |
|
|
'level' => 'h2',
|
843 |
|
|
'class' => array('element-invisible'),
|
844 |
|
|
)));
|
845 |
|
|
}
|
846 |
|
|
else {
|
847 |
|
|
$vars['secondary_nav'] = FALSE;
|
848 |
|
|
}
|
849 |
|
|
|
850 |
|
|
// Change IMCE tab to 'Personal Files'.
|
851 |
|
|
if (!empty($vars['tabs']['#primary'])) {
|
852 |
|
|
foreach ($vars['tabs']['#primary'] as $key => $value) {
|
853 |
|
|
if ($value['#link']['path'] == 'user/%/imce') {
|
854 |
|
|
$vars['tabs']['#primary'][$key]['#link']['title'] = t('Personal Files');
|
855 |
|
|
}
|
856 |
|
|
}
|
857 |
|
|
}
|
858 |
|
|
|
859 |
|
|
|
860 |
|
|
/* Display node title as page title for the comment form.
|
861 |
|
|
* Comment @WA: it would probably be better to select $uuid from node_cdm
|
862 |
|
|
* table and link to cdm_dataportal/taxon/%uuid instead.
|
863 |
|
|
*/
|
864 |
|
|
if (arg(0) == 'comment' && arg(1) == 'reply') {
|
865 |
|
|
$node = $vars['page']['content']['system_main']['comment_node']['#node'];
|
866 |
|
|
$vars['title'] = l(check_plain($node->title),'node/' . $node->nid);
|
867 |
|
|
}
|
868 |
|
|
}
|
869 |
|
|
|
870 |
|
|
/**
|
871 |
|
|
* Implements hook_preprocess_HOOK() for theme_node().
|
872 |
|
|
*
|
873 |
|
|
* Fixes file urls in nodes. In nodes, relative urls are used to include files
|
874 |
|
|
* like <img src="/files/..
|
875 |
|
|
*
|
876 |
|
|
* Portals can be installed in configurations with
|
877 |
|
|
* sub-directories however, in which case these urls need to be adjusted.
|
878 |
|
|
* Examples: mysite.org, mysite.org/myportal, mysite.org/portals/myportal.
|
879 |
|
|
*
|
880 |
|
|
* Therefore preprocess nodes and replace these urls with a the appropriate url
|
881 |
|
|
* for the current setup.
|
882 |
|
|
*
|
883 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
884 |
|
|
*/
|
885 |
|
|
function palmweb_2_preprocess_node(&$vars) {
|
886 |
|
|
$body = '';
|
887 |
|
|
// Warning: use #markup value, for which filters like php, html etc are applied!
|
888 |
|
|
if (isset($vars['content']['body'][0]['#markup'])) {
|
889 |
|
|
$body = $vars['content']['body'][0]['#markup'];
|
890 |
|
|
}
|
891 |
|
|
else {
|
892 |
|
|
$vars['fixed_body'] = '';
|
893 |
|
|
return;
|
894 |
|
|
}
|
895 |
|
|
|
896 |
|
|
$file_path = '/' . variable_get('file_public_path', conf_path() . '/files');
|
897 |
|
|
global $base_url;
|
898 |
|
|
if ($base_url == '/') {
|
899 |
|
|
drupal_set_message(t('
|
900 |
|
|
The $base_url in this portal could not be set, please set the $base_url
|
901 |
|
|
manually your Drupal settings.php file.', 'error'
|
902 |
|
|
));
|
903 |
|
|
}
|
904 |
|
|
$fixed_file_path = $base_url . $file_path;
|
905 |
|
|
|
906 |
|
|
$preg_file_path = preg_quote($file_path, '/');
|
907 |
|
|
$body = preg_replace ('/src\s*=\s*["]\s*' . $preg_file_path . '/', 'src="' . $fixed_file_path , $body);
|
908 |
|
|
$body = preg_replace ('/src\s*=\s*[\']\s*' . $preg_file_path . '/', 'src=\'' . $fixed_file_path , $body);
|
909 |
|
|
$body = preg_replace ('/href\s*=\s*["]\s*' . $preg_file_path . '/', 'href="' . $fixed_file_path , $body);
|
910 |
|
|
$body = preg_replace ('/href\s*=\s*[\']\s*' . $preg_file_path . '/', 'href=\'' . $fixed_file_path , $body);
|
911 |
|
|
|
912 |
|
|
$vars['fixed_body'] = $body;
|
913 |
|
|
}
|
914 |
|
|
|
915 |
|
|
/**
|
916 |
|
|
* Implements hook_form_FORM_ID_alter() for comment_form().
|
917 |
|
|
*
|
918 |
|
|
* Alter the comment form to make it look like a D5 style comment form.
|
919 |
|
|
*
|
920 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
921 |
|
|
*/
|
922 |
|
|
function palmweb_2_form_comment_form_alter(&$form, &$form_state) {
|
923 |
|
|
|
924 |
|
|
if (!isset($form['comment_preview'])) {
|
925 |
|
|
$form['header'] = array(
|
926 |
|
|
'#markup' => '<h2>' . t('Reply') . '</h2>',
|
927 |
|
|
'#weight' => -2,
|
928 |
|
|
);
|
929 |
|
|
}
|
930 |
|
|
$form['subject']['#title'] = $form['subject']['#title'] . ':';
|
931 |
|
|
$form['comment_body']['und'][0]['#title'] = $form['comment_body']['und'][0]['#title'] . ':';
|
932 |
|
|
if (isset($form['author']['_author']['#title'])) {
|
933 |
|
|
$form['author']['_author']['#title'] = $form['author']['_author']['#title'] . ':';
|
934 |
|
|
}
|
935 |
|
|
$form['actions']['submit']['#value'] = t('Post comment');
|
936 |
|
|
$form['actions']['submit']['#weight'] = 1000;
|
937 |
|
|
$form['actions']['preview']['#value'] = t('Preview comment');
|
938 |
|
|
}
|
939 |
|
|
|
940 |
|
|
/**
|
941 |
|
|
* Implements hook_preprocess_HOOK() for theme_comment().
|
942 |
|
|
*
|
943 |
|
|
* Alter the comment display to make it look like a D5 style comment.
|
944 |
|
|
*
|
945 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
946 |
|
|
*/
|
947 |
|
|
function palmweb_2_preprocess_comment(&$variables) {
|
948 |
|
|
$comment = $variables['elements']['#comment'];
|
949 |
|
|
if (isset($comment->subject)) {
|
950 |
|
|
// Print title without link.
|
951 |
|
|
$variables['title'] = $comment->subject;
|
952 |
|
|
if ($variables['status'] == 'comment-preview') {
|
953 |
|
|
// Add 'new' to preview.
|
954 |
|
|
$variables['new'] = t('new');
|
955 |
|
|
}
|
956 |
|
|
}
|
957 |
|
|
}
|