1 |
08ea5e99
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Overrides of generic themeing functions in cdm_dataportal.theme.php.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
be5e2d11
|
Andreas Kohlbecker
|
* This operride theme function ignores the original sources and annotations
|
9 |
|
|
* and renders a hardcoded citation string at the end of the list of distibution
|
10 |
|
|
* elements.
|
11 |
|
|
* TODO the same output could also be achieved by collection all source citations
|
12 |
|
|
* as it is done by the footnodesystem and to print the list of citations at the end
|
13 |
|
|
* of the area list. The footnote key must be omitted in this case of course.
|
14 |
|
|
*
|
15 |
08ea5e99
|
Andreas Kohlbecker
|
*/
|
16 |
be5e2d11
|
Andreas Kohlbecker
|
|
17 |
abacccbf
|
Andreas Kohlbecker
|
function xxx_palmweb_2_cdm_descriptionElement_Distribution($variables) {
|
18 |
08ea5e99
|
Andreas Kohlbecker
|
$descriptionElements = $variables['descriptionElements'];
|
19 |
|
|
$enclosingTag = $variables['enclosingTag'];
|
20 |
|
|
|
21 |
|
|
$out = '';
|
22 |
|
|
$separator = ', ';
|
23 |
|
|
|
24 |
|
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
25 |
|
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
26 |
|
|
|
27 |
|
|
$itemCnt = 0;
|
28 |
|
|
foreach ($descriptionElements as $descriptionElement) {
|
29 |
be5e2d11
|
Andreas Kohlbecker
|
|
30 |
|
|
$out .= '<' . $enclosingTag . ' class="DescriptionElement DescriptionElement-' . $descriptionElement->class . '">';
|
31 |
|
|
$out .= $descriptionElement->area->representation_L10n;
|
32 |
|
|
if (++$itemCnt < count($descriptionElements)) {
|
33 |
|
|
$out .= $separator;
|
34 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
35 |
be5e2d11
|
Andreas Kohlbecker
|
$out .= "</" . $enclosingTag . ">";
|
36 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
37 |
fa782b11
|
Andreas Kohlbecker
|
$taxonTrees = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
|
38 |
08ea5e99
|
Andreas Kohlbecker
|
$reference = new stdClass();
|
39 |
|
|
foreach ($taxonTrees as $taxonTree) {
|
40 |
|
|
if ($taxonTree->uuid == variable_get('cdm_taxonomictree_uuid')) {
|
41 |
|
|
if (isset($taxonTree->reference)) {
|
42 |
|
|
$reference = $taxonTree->reference;
|
43 |
|
|
}
|
44 |
|
|
break;
|
45 |
|
|
}
|
46 |
|
|
}
|
47 |
|
|
$referenceCitation = '';
|
48 |
|
|
if (isset($reference->uuid)) {
|
49 |
|
|
$referenceCitation .= '(<span class="reference">';
|
50 |
|
|
$referenceCitation .= l(t('World Checklist of Monocotyledons'), path_to_reference($reference->uuid), array('attributes' => array('class' => array('reference'))));
|
51 |
|
|
$referenceCitation .= '</span>)';
|
52 |
|
|
}
|
53 |
|
|
else {
|
54 |
|
|
// Comment @WA Added for compatibility with D5, but I think it is better to
|
55 |
|
|
// remove this to not show a link rather than the wrong one.
|
56 |
|
|
$referenceCitation .= '(<span class="reference">';
|
57 |
|
|
$referenceCitation .= l(t('World Checklist of Monocotyledons'), '', array('attributes' => array('class' => array('reference'))));
|
58 |
|
|
$referenceCitation .= '</span>)';
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
$sourceRefs = '';
|
62 |
|
|
if ($out && strlen($out) > 0) {
|
63 |
|
|
$sourceRefs = ' ' . $referenceCitation;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
if (strlen($sourceRefs) > 0) {
|
67 |
|
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
RenderHints::popFromRenderStack();
|
71 |
|
|
return $out . $sourceRefs;
|
72 |
|
|
|
73 |
|
|
}
|
74 |
|
|
|
75 |
be5e2d11
|
Andreas Kohlbecker
|
|
76 |
08ea5e99
|
Andreas Kohlbecker
|
/**
|
77 |
|
|
* @todo Please document this function.
|
78 |
|
|
* @see http://drupal.org/node/1354
|
79 |
|
|
*/
|
80 |
|
|
function palmweb_2_cdm_search_results($variables){
|
81 |
|
|
$pager = $variables['pager'];
|
82 |
|
|
$path = $variables['path'];
|
83 |
|
|
$out = '';
|
84 |
|
|
|
85 |
|
|
$showThumbnails = isset($_SESSION['pageoption']['searchtaxa']['showThumbnails']) ? $_SESSION['pageoption']['searchtaxa']['showThumbnails'] : 0;
|
86 |
|
|
if (!is_numeric($showThumbnails)) {
|
87 |
|
|
// AT RBG KEW - 14/11/2011 - Set the show thumbnails to 0 by default.
|
88 |
|
|
$showThumbnails = 0;
|
89 |
|
|
}
|
90 |
|
|
$setSessionUri = url('cdm_api/setvalue/session', array('query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => '')));
|
91 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
92 |
|
|
|
93 |
|
|
// Init.
|
94 |
|
|
if(' . $showThumbnails . ' == 1){
|
95 |
|
|
jQuery(\'.media_gallery\').show(20);
|
96 |
|
|
} else {
|
97 |
|
|
jQuery(\'.media_gallery\').hide(20);
|
98 |
|
|
}
|
99 |
|
|
// Add change hander.
|
100 |
|
|
jQuery(\'#showThumbnails\').change(
|
101 |
|
|
function(event){
|
102 |
|
|
var state = 0;
|
103 |
|
|
if(jQuery(this).is(\':checked\')){
|
104 |
|
|
jQuery(\'.media_gallery\').show(20);
|
105 |
|
|
state = 1;
|
106 |
|
|
} else {
|
107 |
|
|
jQuery(\'.media_gallery\').hide(20);
|
108 |
|
|
}
|
109 |
|
|
// Store state in session variable.
|
110 |
|
|
var uri = \'' . $setSessionUri . '\' + state;
|
111 |
|
|
jQuery.get(uri);
|
112 |
|
|
});
|
113 |
|
|
});', "inline");
|
114 |
|
|
|
115 |
|
|
drupal_set_title(t('Search results'));
|
116 |
|
|
|
117 |
|
|
// AT RBG KEW - 14/11/2011 - Changed the wording of the Show Thumbnails
|
118 |
|
|
// tickbox text.
|
119 |
|
|
$out .= '<div class="page_options">';
|
120 |
|
|
$out .= '<form name="pageoptions">';
|
121 |
|
|
$out .= '<input id="showThumbnails" type="checkbox" name="showThumbnails" ';
|
122 |
|
|
$out .= $showThumbnails == 1 ? 'checked="checked"' : '';
|
123 |
c278f2a0
|
Andreas Kohlbecker
|
$out .= '> ' . t('Display image thumbnails') . '</form></div>';
|
124 |
08ea5e99
|
Andreas Kohlbecker
|
if (!empty($pager) && count($pager->records) > 0) {
|
125 |
|
|
$out .= '<div id="search_results">';
|
126 |
0b8683d9
|
Andreas Kohlbecker
|
$list_of_taxa = compose_list_of_taxa($pager->records);
|
127 |
|
|
$out .= drupal_render($list_of_taxa);
|
128 |
5885d957
|
Andreas Kohlbecker
|
$out .= '</div>';
|
129 |
|
|
$out .= theme('cdm_pager', array(
|
130 |
|
|
'pager' => $pager,
|
131 |
|
|
'path' => $path,
|
132 |
34dd7be9
|
Andreas Kohlbecker
|
'parameters' => $_REQUEST,
|
133 |
08ea5e99
|
Andreas Kohlbecker
|
));
|
134 |
|
|
}
|
135 |
|
|
else {
|
136 |
|
|
$out = '<h4 class="error">Sorry, no matching entries found.</h4>';
|
137 |
|
|
}
|
138 |
|
|
return $out;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
/**
|
142 |
|
|
* @todo Please document this function.
|
143 |
|
|
*/
|
144 |
|
|
function palmweb_2_cdm_media_caption($variables){
|
145 |
|
|
$media = $variables['media'];
|
146 |
|
|
$elements = $variables['elements'];
|
147 |
|
|
|
148 |
97ff635c
|
Andreas Kohlbecker
|
$media_metadata = read_media_metadata($media);
|
149 |
08ea5e99
|
Andreas Kohlbecker
|
|
150 |
|
|
$doTitle = !$elements || array_search('title', $elements) !== FALSE;
|
151 |
|
|
$doDescription = !$elements || array_search('description', $elements) !== FALSE;
|
152 |
|
|
$doArtist = !$elements || array_search('artist', $elements) !== FALSE;
|
153 |
|
|
$doLocation = !$elements || array_search('location', $elements) !== FALSE;
|
154 |
|
|
$doRights = !$elements || array_search('rights', $elements) !== FALSE;
|
155 |
|
|
|
156 |
|
|
$descriptionPrefix = "";
|
157 |
|
|
|
158 |
|
|
$out = '<dl class="media-caption">';
|
159 |
|
|
// Title.
|
160 |
|
|
if ($doTitle) {
|
161 |
|
|
if ($media_metadata['title']) {
|
162 |
|
|
$out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>';
|
163 |
|
|
$descriptionPrefix = "- ";
|
164 |
|
|
}
|
165 |
|
|
elseif (!($doDescription && $media_metadata['description'])) {
|
166 |
|
|
// Use filename as fallbackoption if no description will be shown.
|
167 |
|
|
$out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['filename'] . '</dd>';
|
168 |
|
|
$descriptionPrefix = "- ";
|
169 |
|
|
}
|
170 |
|
|
}
|
171 |
|
|
// Description.
|
172 |
|
|
if ($media_metadata['description'] && $doDescription) {
|
173 |
|
|
$out .= '<dt class = "description">' . t('Description') . '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>';
|
174 |
|
|
}
|
175 |
|
|
// Artist.
|
176 |
|
|
if ($media_metadata['artist'] && $doArtist) {
|
177 |
|
|
$out .= '<dt class = "artist">' . t('Artist') . '</dt> <dd class = "astist">' . str_replace("'","", $media_metadata['artist']) . '</dd>';
|
178 |
|
|
}
|
179 |
|
|
// Location.
|
180 |
|
|
if ($doLocation) {
|
181 |
|
|
$location = '';
|
182 |
|
|
$location .= $media_metadata['location']['sublocation'];
|
183 |
|
|
if ($location && $media_metadata['location']['city']) {
|
184 |
|
|
$location .= ', ';
|
185 |
|
|
}
|
186 |
|
|
$location .= $media_metadata['location']['city'];
|
187 |
|
|
if ($location && $media_metadata['location']['province']) {
|
188 |
|
|
$location .= ', ';
|
189 |
|
|
}
|
190 |
|
|
$location .= $media_metadata['location']['province'];
|
191 |
|
|
if ($location && $media_metadata['location']['country']) {
|
192 |
|
|
$location .= ' (' . $media_metadata['location']['country'] . ')';
|
193 |
|
|
}
|
194 |
|
|
else {
|
195 |
|
|
$location .= $media_metadata['location']['country'];
|
196 |
|
|
}
|
197 |
|
|
if ($location) {
|
198 |
|
|
$out .= '<dt class = "location">' . t('Location') . '</dt> <dd class = "location">' . $location . '</dd>';
|
199 |
|
|
}
|
200 |
|
|
}
|
201 |
|
|
// Rights.
|
202 |
|
|
if ($doRights) {
|
203 |
|
|
$rights = '';
|
204 |
|
|
// Copyrights.
|
205 |
|
|
$cnt = count($media_metadata['rights']['copyright']['agentNames']);
|
206 |
|
|
if ($cnt > 0) {
|
207 |
|
|
$rights .= '<dt class="rights">©</dt> <dd class="rights"> ';
|
208 |
|
|
for ($i = 0; $i < $cnt; $i++) {
|
209 |
|
|
$rights .= str_replace("'","", $media_metadata['rights']['copyright']['agentNames'][$i]);
|
210 |
|
|
if ($i + 1 < $cnt) {
|
211 |
|
|
$rights .= ' / ';
|
212 |
|
|
}
|
213 |
|
|
}
|
214 |
|
|
$rights .= '</dd>';
|
215 |
|
|
}
|
216 |
|
|
// License.
|
217 |
|
|
$cnt = count($media_metadata['rights']['license']['agentNames']);
|
218 |
|
|
if ($cnt > 0) {
|
219 |
|
|
$rights .= '<dt class ="license">' . t('License') . '</dt> <dd class = "license">';
|
220 |
|
|
for ($i = 0; $i < $cnt; $i++) {
|
221 |
|
|
$rights .= $media_metadata['rights']['license']['agentNames'][$i];
|
222 |
|
|
if ($i + 1 < $cnt) {
|
223 |
|
|
$rights .= ' / ';
|
224 |
|
|
}
|
225 |
|
|
}
|
226 |
|
|
$rights .= '</dd>';
|
227 |
|
|
}
|
228 |
|
|
if ($rights) {
|
229 |
|
|
$out .= $rights . '</dt>';
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
// TODO add all other metadata elemenst generically.
|
233 |
|
|
$out .= '</dl>';
|
234 |
|
|
// Return value.
|
235 |
|
|
return $out;
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
/**
|
239 |
be5e2d11
|
Andreas Kohlbecker
|
* Overrive of the original theme_cdm_reference()
|
240 |
|
|
* the main difference here seems to be that
|
241 |
fa782b11
|
Andreas Kohlbecker
|
* this function is completely omitting the citation title cache
|
242 |
1ce9afb7
|
Patric Plitzner
|
* and only sets the authorship as the
|
243 |
be5e2d11
|
Andreas Kohlbecker
|
* _short_form_of_author_team() as $citation.
|
244 |
|
|
*
|
245 |
fa782b11
|
Andreas Kohlbecker
|
* If the authorteam is not set citation was empty,
|
246 |
be5e2d11
|
Andreas Kohlbecker
|
* this has been fixed for http://dev.e-taxonomy.eu/trac/ticket/4261
|
247 |
|
|
*
|
248 |
|
|
* TODO can this be made configuable via the dataportal
|
249 |
|
|
* settings so that we can remove this function?
|
250 |
08ea5e99
|
Andreas Kohlbecker
|
*/
|
251 |
fa782b11
|
Andreas Kohlbecker
|
function xxx_palmweb_2_cdm_reference($variables) {
|
252 |
08ea5e99
|
Andreas Kohlbecker
|
$reference = $variables['reference'];
|
253 |
|
|
$microReference = $variables['microReference'];
|
254 |
|
|
$doLink = $variables['doLink'];
|
255 |
|
|
$referenceStyle = $variables['referenceStyle'];
|
256 |
|
|
|
257 |
1ce9afb7
|
Patric Plitzner
|
if(!isset($reference->authorship)){
|
258 |
be5e2d11
|
Andreas Kohlbecker
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
|
259 |
|
|
} else {
|
260 |
1ce9afb7
|
Patric Plitzner
|
$author_team = $reference->authorship;
|
261 |
be5e2d11
|
Andreas Kohlbecker
|
}
|
262 |
08ea5e99
|
Andreas Kohlbecker
|
|
263 |
|
|
$year = '';
|
264 |
c7f92453
|
Andreas Kohlbecker
|
if (isset($reference->datePublished)) {
|
265 |
|
|
$year = timePeriodToString($reference->datePublished, true, 'YYYY');
|
266 |
08ea5e99
|
Andreas Kohlbecker
|
}
|
267 |
6bbf4d45
|
Andreas Kohlbecker
|
if(isset($author_team->titleCache)){
|
268 |
|
|
$citation = _short_form_of_author_team ($author_team->titleCache) . (!empty($year) ? '. ' . $year : '');
|
269 |
|
|
$citation = str_replace('..', '.', $citation);
|
270 |
|
|
} else {
|
271 |
be5e2d11
|
Andreas Kohlbecker
|
$citation = $reference->titleCache;
|
272 |
6bbf4d45
|
Andreas Kohlbecker
|
}
|
273 |
08ea5e99
|
Andreas Kohlbecker
|
|
274 |
|
|
if ($doLink) {
|
275 |
|
|
$out = '<span class="reference">';
|
276 |
|
|
$out .= l($citation, path_to_reference($reference->uuid), array(
|
277 |
|
|
'attributes' => array('class' => 'reference'),
|
278 |
|
|
'absolute' => TRUE,
|
279 |
|
|
'html' => TRUE,
|
280 |
|
|
));
|
281 |
|
|
$out .= '</span>';
|
282 |
|
|
}
|
283 |
|
|
else {
|
284 |
|
|
$out = '<span class="reference">' . $citation . '</span>';
|
285 |
|
|
}
|
286 |
|
|
// FIXME use microreference webservice instead.
|
287 |
|
|
if (!empty($descriptionElementSource->citationMicroReference)) {
|
288 |
|
|
$out .= ': ' . $descriptionElementSource->citationMicroReference;
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
return $out;
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
/**
|
295 |
|
|
* Sets the body-tag class attribute.
|
296 |
|
|
*
|
297 |
|
|
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
|
298 |
|
|
*/
|
299 |
|
|
function phptemplate_body_class($sidebar_left, $sidebar_right) {
|
300 |
|
|
if ($sidebar_left != '' && $sidebar_right != '') {
|
301 |
|
|
$class = 'sidebars';
|
302 |
|
|
}
|
303 |
|
|
else {
|
304 |
|
|
if ($sidebar_left != '') {
|
305 |
|
|
$class = 'sidebar-left';
|
306 |
|
|
}
|
307 |
|
|
if ($sidebar_right != '') {
|
308 |
|
|
$class = 'sidebar-right';
|
309 |
|
|
}
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
if (isset($class)) {
|
313 |
|
|
print ' class="' . $class . '"';
|
314 |
|
|
}
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
/**
|
318 |
|
|
* Allow themeable wrapping of all comments.
|
319 |
|
|
*/
|
320 |
|
|
function phptemplate_comment_wrapper($content, $type = NULL) {
|
321 |
|
|
static $node_type;
|
322 |
|
|
if (isset($type)) {
|
323 |
|
|
$node_type = $type;
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
if (!$content || $node_type == 'forum') {
|
327 |
|
|
return '<div id="comments">' . $content . '</div>';
|
328 |
|
|
}
|
329 |
|
|
else {
|
330 |
|
|
return '<div id="comments"><h2 class="comments">' . t('Comments') . '</h2>' . $content . '</div>';
|
331 |
|
|
}
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
/**
|
335 |
|
|
* Override or insert PHPTemplate variables into the templates.
|
336 |
|
|
*/
|
337 |
|
|
function _phptemplate_variables($hook, $vars) {
|
338 |
|
|
if ($hook == 'page') {
|
339 |
|
|
|
340 |
|
|
if ($secondary = menu_secondary_local_tasks()) {
|
341 |
|
|
$output = '<span class="clear"></span>';
|
342 |
|
|
$output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
|
343 |
|
|
$vars['tabs2'] = $output;
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
// Hook into color.module
|
347 |
|
|
if (module_exists('color')) {
|
348 |
|
|
_color_page_alter($vars);
|
349 |
|
|
}
|
350 |
|
|
return $vars;
|
351 |
|
|
}
|
352 |
|
|
return array();
|
353 |
|
|
}
|
354 |
|
|
|
355 |
|
|
/**
|
356 |
|
|
* Returns the rendered local tasks. The default implementation renders
|
357 |
|
|
* them as tabs.
|
358 |
|
|
*
|
359 |
|
|
* @ingroup themeable
|
360 |
|
|
*/
|
361 |
|
|
function phptemplate_menu_local_tasks() {
|
362 |
|
|
$output = '';
|
363 |
|
|
|
364 |
|
|
if ($primary = menu_primary_local_tasks()) {
|
365 |
|
|
$output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
return $output;
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
/**
|
372 |
|
|
* @todo Please document this function.
|
373 |
|
|
* @see http://drupal.org/node/1354
|
374 |
|
|
*/
|
375 |
|
|
function palmweb_2_cdm_feature_name($variables){
|
376 |
|
|
$feature_name = $variables['feature_name'];
|
377 |
|
|
switch ($feature_name) {
|
378 |
|
|
case "Protologue": return t("Original Publication");
|
379 |
|
|
default: return t(ucfirst($feature_name));
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
/**
|
384 |
|
|
* Implements hook_preprocess_HOOK() for theme_page().
|
385 |
|
|
*
|
386 |
|
|
* Assign the css classes primary-links and secondary-links to the menus and
|
387 |
|
|
* process the 'Login' menu item, to change into 'My account' after login and
|
388 |
|
|
* change the tab title for the IMCE file browser.
|
389 |
|
|
*
|
390 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
391 |
|
|
*/
|
392 |
|
|
function palmweb_2_preprocess_page(&$vars) {
|
393 |
|
|
|
394 |
|
|
if (isset($vars['main_menu'])) {
|
395 |
|
|
// For the Palmae theme we want to change the menu item 'Login' into
|
396 |
|
|
// 'My account' if a user is logged in.
|
397 |
|
|
global $user;
|
398 |
|
|
foreach ($vars['main_menu'] as $key => $value) {
|
399 |
|
|
if ($value['href'] == 'user' && !empty($user->name)) {
|
400 |
|
|
$vars['main_menu'][$key]['title'] = t('My account');
|
401 |
|
|
$vars['main_menu'][$key]['href'] = 'user/' . $user->uid;
|
402 |
|
|
}
|
403 |
|
|
}
|
404 |
|
|
// Theme the main menu with the desired css classes.
|
405 |
|
|
$vars['primary_nav'] = theme('links__system_main_menu', array(
|
406 |
|
|
'links' => $vars['main_menu'],
|
407 |
|
|
'attributes' => array(
|
408 |
|
|
'class' => array('links', 'inline', 'main-menu', 'primary-links'),
|
409 |
|
|
),
|
410 |
|
|
'heading' => array(
|
411 |
|
|
'text' => t('Main menu'),
|
412 |
|
|
'level' => 'h2',
|
413 |
|
|
'class' => array('element-invisible'),
|
414 |
|
|
)));
|
415 |
|
|
}
|
416 |
|
|
else {
|
417 |
|
|
$vars['primary_nav'] = FALSE;
|
418 |
|
|
}
|
419 |
|
|
if (isset($vars['secondary_menu'])) {
|
420 |
|
|
$vars['secondary_nav'] = theme('links__system_secondary_menu', array(
|
421 |
|
|
'links' => $vars['secondary_menu'],
|
422 |
|
|
'attributes' => array(
|
423 |
|
|
'class' => array('links', 'inline', 'secondary-menu', 'secondary-links'),
|
424 |
|
|
),
|
425 |
|
|
'heading' => array(
|
426 |
|
|
'text' => t('Secondary menu'),
|
427 |
|
|
'level' => 'h2',
|
428 |
|
|
'class' => array('element-invisible'),
|
429 |
|
|
)));
|
430 |
|
|
}
|
431 |
|
|
else {
|
432 |
|
|
$vars['secondary_nav'] = FALSE;
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
// Change IMCE tab to 'Personal Files'.
|
436 |
|
|
if (!empty($vars['tabs']['#primary'])) {
|
437 |
|
|
foreach ($vars['tabs']['#primary'] as $key => $value) {
|
438 |
|
|
if ($value['#link']['path'] == 'user/%/imce') {
|
439 |
|
|
$vars['tabs']['#primary'][$key]['#link']['title'] = t('Personal Files');
|
440 |
|
|
}
|
441 |
|
|
}
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
|
445 |
|
|
/* Display node title as page title for the comment form.
|
446 |
|
|
* Comment @WA: it would probably be better to select $uuid from node_cdm
|
447 |
|
|
* table and link to cdm_dataportal/taxon/%uuid instead.
|
448 |
|
|
*/
|
449 |
|
|
if (arg(0) == 'comment' && arg(1) == 'reply') {
|
450 |
|
|
$node = $vars['page']['content']['system_main']['comment_node']['#node'];
|
451 |
|
|
$vars['title'] = l(check_plain($node->title),'node/' . $node->nid);
|
452 |
|
|
}
|
453 |
|
|
}
|
454 |
|
|
|
455 |
|
|
/**
|
456 |
|
|
* Implements hook_preprocess_HOOK() for theme_node().
|
457 |
|
|
*
|
458 |
|
|
* Fixes file urls in nodes. In nodes, relative urls are used to include files
|
459 |
|
|
* like <img src="/files/..
|
460 |
|
|
*
|
461 |
|
|
* Portals can be installed in configurations with
|
462 |
|
|
* sub-directories however, in which case these urls need to be adjusted.
|
463 |
|
|
* Examples: mysite.org, mysite.org/myportal, mysite.org/portals/myportal.
|
464 |
|
|
*
|
465 |
|
|
* Therefore preprocess nodes and replace these urls with a the appropriate url
|
466 |
|
|
* for the current setup.
|
467 |
|
|
*
|
468 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
469 |
|
|
*/
|
470 |
|
|
function palmweb_2_preprocess_node(&$vars) {
|
471 |
|
|
$body = '';
|
472 |
|
|
// Warning: use #markup value, for which filters like php, html etc are applied!
|
473 |
|
|
if (isset($vars['content']['body'][0]['#markup'])) {
|
474 |
|
|
$body = $vars['content']['body'][0]['#markup'];
|
475 |
|
|
}
|
476 |
|
|
else {
|
477 |
|
|
$vars['fixed_body'] = '';
|
478 |
|
|
return;
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
$file_path = '/' . variable_get('file_public_path', conf_path() . '/files');
|
482 |
|
|
global $base_url;
|
483 |
|
|
if ($base_url == '/') {
|
484 |
|
|
drupal_set_message(t('
|
485 |
|
|
The $base_url in this portal could not be set, please set the $base_url
|
486 |
|
|
manually your Drupal settings.php file.', 'error'
|
487 |
|
|
));
|
488 |
|
|
}
|
489 |
|
|
$fixed_file_path = $base_url . $file_path;
|
490 |
|
|
|
491 |
|
|
$preg_file_path = preg_quote($file_path, '/');
|
492 |
|
|
$body = preg_replace ('/src\s*=\s*["]\s*' . $preg_file_path . '/', 'src="' . $fixed_file_path , $body);
|
493 |
|
|
$body = preg_replace ('/src\s*=\s*[\']\s*' . $preg_file_path . '/', 'src=\'' . $fixed_file_path , $body);
|
494 |
|
|
$body = preg_replace ('/href\s*=\s*["]\s*' . $preg_file_path . '/', 'href="' . $fixed_file_path , $body);
|
495 |
|
|
$body = preg_replace ('/href\s*=\s*[\']\s*' . $preg_file_path . '/', 'href=\'' . $fixed_file_path , $body);
|
496 |
|
|
|
497 |
|
|
$vars['fixed_body'] = $body;
|
498 |
|
|
}
|
499 |
|
|
|
500 |
|
|
/**
|
501 |
|
|
* Implements hook_form_FORM_ID_alter() for comment_form().
|
502 |
|
|
*
|
503 |
|
|
* Alter the comment form to make it look like a D5 style comment form.
|
504 |
|
|
*
|
505 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
506 |
|
|
*/
|
507 |
|
|
function palmweb_2_form_comment_form_alter(&$form, &$form_state) {
|
508 |
|
|
|
509 |
|
|
if (!isset($form['comment_preview'])) {
|
510 |
|
|
$form['header'] = array(
|
511 |
|
|
'#markup' => '<h2>' . t('Reply') . '</h2>',
|
512 |
|
|
'#weight' => -2,
|
513 |
|
|
);
|
514 |
|
|
}
|
515 |
|
|
$form['subject']['#title'] = $form['subject']['#title'] . ':';
|
516 |
|
|
$form['comment_body']['und'][0]['#title'] = $form['comment_body']['und'][0]['#title'] . ':';
|
517 |
|
|
if (isset($form['author']['_author']['#title'])) {
|
518 |
|
|
$form['author']['_author']['#title'] = $form['author']['_author']['#title'] . ':';
|
519 |
|
|
}
|
520 |
|
|
$form['actions']['submit']['#value'] = t('Post comment');
|
521 |
|
|
$form['actions']['submit']['#weight'] = 1000;
|
522 |
|
|
$form['actions']['preview']['#value'] = t('Preview comment');
|
523 |
|
|
}
|
524 |
|
|
|
525 |
|
|
/**
|
526 |
|
|
* Implements hook_preprocess_HOOK() for theme_comment().
|
527 |
|
|
*
|
528 |
|
|
* Alter the comment display to make it look like a D5 style comment.
|
529 |
|
|
*
|
530 |
|
|
* @author W.Addink <w.addink@eti.uva.nl>
|
531 |
|
|
*/
|
532 |
|
|
function palmweb_2_preprocess_comment(&$variables) {
|
533 |
|
|
$comment = $variables['elements']['#comment'];
|
534 |
|
|
if (isset($comment->subject)) {
|
535 |
|
|
// Print title without link.
|
536 |
|
|
$variables['title'] = $comment->subject;
|
537 |
|
|
if ($variables['status'] == 'comment-preview') {
|
538 |
|
|
// Add 'new' to preview.
|
539 |
|
|
$variables['new'] = t('new');
|
540 |
|
|
}
|
541 |
|
|
}
|
542 |
|
|
}
|