Project

General

Profile

Download (25.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Overrides of generic themeing functions in cdm_dataportal.theme.php.
5
 */
6

    
7
/**
8
 * @todo Please document this function.
9
 * @see http://drupal.org/node/1354
10
 */
11
function palmweb_2_cdm_descriptionElementDistribution($variables) {
12
  $descriptionElements = $variables['descriptionElements'];
13
  $enclosingTag = $variables['enclosingTag'];
14

    
15
  $out = '';
16
  $separator = ', ';
17

    
18
  RenderHints::pushToRenderStack('descriptionElementDistribution');
19
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
20

    
21
  $itemCnt = 0;
22
  foreach ($descriptionElements as $descriptionElement) {
23
    /*
24
    $out .= ($descriptionElement->class);
25
    // Annotations as footnotes.
26
    $annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
27
    // Source references as footnotes.
28
    $sourcesFootnoteKeyList = '';
29
    foreach($descriptionElement->sources as $source){
30
      $_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_OriginalSource', $source, FALSE));
31
      $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, ($sourcesFootnoteKeyList ? $separator : ''));
32
    }
33
    if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
34
      $annotationFootnoteKeys .= $separator;
35
    }
36
    */
37
        $out .= '<' . $enclosingTag . ' class="DescriptionElement DescriptionElement-' . $descriptionElement->class . '">';
38
        // $out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList;
39
        $out .= $descriptionElement->area->representation_L10n;
40
        if (++$itemCnt < count($descriptionElements)) {
41
          $out .= $separator;
42
        }
43
        $out .= "</" . $enclosingTag . ">";
44
  }
45
  $taxonTrees = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY);
46
  $reference = new stdClass();
47
  foreach ($taxonTrees as $taxonTree) {
48
    if ($taxonTree->uuid == variable_get('cdm_taxonomictree_uuid')) {
49
      if (isset($taxonTree->reference)) {
50
        $reference = $taxonTree->reference;
51
      }
52
      break;
53
    }
54
  }
55
  $referenceCitation = '';
56
  if (isset($reference->uuid)) {
57
    $referenceCitation .= '(<span class="reference">';
58
    $referenceCitation .= l(t('World Checklist of Monocotyledons'), path_to_reference($reference->uuid), array('attributes' => array('class' => array('reference'))));
59
    $referenceCitation .= '</span>)';
60
  }
61
  else {
62
    // Comment @WA Added for compatibility with D5, but I think it is better to
63
    // remove this to not show a link rather than the wrong one.
64
    $referenceCitation .= '(<span class="reference">';
65
    $referenceCitation .= l(t('World Checklist of Monocotyledons'), '', array('attributes' => array('class' => array('reference'))));
66
    $referenceCitation .= '</span>)';
67
  }
68

    
69
  $sourceRefs = '';
70
  if ($out && strlen($out) > 0) {
71
    $sourceRefs = ' ' . $referenceCitation;
72
  }
73

    
74
  if (strlen($sourceRefs) > 0) {
75
    $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
76
  }
77

    
78
  RenderHints::popFromRenderStack();
79
  return $out . $sourceRefs;
80

    
81
}
82

    
83
/**
84
 * @todo Please document this function.
85
 * @see http://drupal.org/node/1354
86
 */
87
function palmweb_2_cdm_feature_nodes($variables){
88
  $mergedFeatureNodes = $variables['mergedFeatureNodes'];
89
  $taxon = $variables['taxon'];
90

    
91
  $out = '';
92
  RenderHints::pushToRenderStack('feature_nodes');
93

    
94
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
95
  // Creating an array to place the description elements in.
96
  $bibliographyOut = array();
97
  $countFeatures = 0;
98
  $numberOfChildren = count(cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array (get_taxonomictree_uuid_selected(), $taxon->uuid)));
99
  if ($taxon->name->rank->titleCache == "Genus") {
100
    $subRank = "species";
101
  }
102
  if ($taxon->name->rank->titleCache == "Species") {
103
    $subRank = "infraspecific taxa";
104
  }
105
  if ($numberOfChildren != 0) {
106
    $out .= '<a name="number_of_taxa"> </a><H2>Number of Taxa</H2><div class="content"> <ul class="description">';
107
    $out .= '<li class=\"descriptionText DescriptionElement\">' . $numberOfChildren . " " . $subRank . '</li></ul>';
108
  }
109

    
110
  foreach ($mergedFeatureNodes as $node) {
111

    
112
    if (hasFeatureNodeDescriptionElements($node)) {
113

    
114
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
115
      $block = new stdClass();
116
      $block->module = 'cdm_dataportal';
117
      // If the option is enabled the description elements will be added
118
      // to the array.
119
      $show_bibliography = variable_get('cdm_show_bibliography', 1);
120
      if ($show_bibliography) {
121
        $bibliographyOut[] = $node->descriptionElements;
122
      }
123
      $media_list = array();
124
      if ($node->feature->uuid != UUID_IMAGE && $node->feature->uuid != UUID_USE) {
125
        $countFeatures++;
126
        $countFeatures++;
127
        $block->delta = generalizeString($featureRepresentation);
128
        $block->subject = '<span class="' . html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name',  array('feature_name' => $featureRepresentation)) . '</span>';
129
        $block->module = "cdm_dataportal-feature";
130
        $block->content = '';
131

    
132
        /*
133
        Content/DISTRIBUTION.
134
        */
135
        if ($node->feature->uuid == UUID_DISTRIBUTION) {
136

    
137
          if (variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
138
            $distributionTextDataList = array();
139
            $distributionElementsList = array();
140

    
141
            foreach ($node->descriptionElements as $descriptionElement) {
142
              if ($descriptionElement->class == "TextData") {
143
                $distributionTextDataList[] = $descriptionElement;
144
              }
145
              else {
146
                $distributionElementsList[] = $descriptionElement;
147
              }
148
            }
149
            if (count($distributionTextDataList) > 0) {
150
              $node->descriptionElements = $distributionElementsList;
151
              $block->content .= theme('cdm_descriptionElements', array(
152
                'descriptionElements' => $distributionTextDataList,
153
                'featureUuid' => $node->feature->uuid,
154
                'taxon_uuid' => $taxon->uuid,
155
              ));
156
            }
157
          }
158

    
159
          // Display cdm distribution map.
160
          // TODO this is a HACK to a proper generic implementation?
161
                    $map_render_element = compose_distribution_map($taxon);
162
          $block->content .= $map_render_element['#markup'];
163
          $block->content .= theme('cdm_descriptionElements', array(
164
            'descriptionElements' => $node->descriptionElements,
165
            'featureUuid' => $node->feature->uuid,
166
            'taxon_uuid' => $taxon->uuid,
167
          ));
168
        }
169

    
170
        /*
171
        Content/COMMON_NAME.
172
        */
173
        elseif ($node->feature->uuid == UUID_COMMON_NAME) {
174
          // TODO why is theme_cdm_descriptionElement_CommonTaxonName
175
          // not beeing used???
176
          $block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
177
        /*
178
        }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
179
          $block->content .= theme('cdm_image_sources', $node->descriptionElements);
180
        */
181
        }
182

    
183
        /*
184
        Content/ALL OTHER FEATURES.
185
        */
186
        elseif ($node->feature->uuid == UUID_USE_RECORD) {
187
          $block->content .= theme('cdm_block_Uses', $taxon->uuid);
188
          // $block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid),
189
        }
190
        else {
191
          $block->content .= theme('cdm_descriptionElements', array(
192
            'descriptionElements' => $node->descriptionElements,
193
            'featureUuid' => $node->feature->uuid,
194
            'taxon_uuid' => $taxon->uuid,
195
          ));
196

    
197
          /*
198
          Content/ALL OTHER FEATURES/Subordinate Features
199
          subordinate features are printed inline in one floating text,
200
          it is expected that subordinate features only "contain" TextData
201
          elements.
202
          */
203
          // TODO move into own theme.
204
          if (count($node->children) > 0) {
205

    
206
            // TODO support more than one level of children.
207
            // @see http://dev.e-taxonomy.eu/trac/ticket/2393/
208
            $text = '';
209
            foreach ($node->children as $child) {
210
             if (is_array($child->descriptionElements)) {
211
               foreach ($child->descriptionElements as $element) {
212

    
213
                 if (is_array($element->media)) {
214
                   // Append media of subordinate elements to the list of
215
                   // main features.
216
                   $media_list = array_merge($media_list, $element->media);
217
                 }
218

    
219
                 $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
220
                // TODO use localized version of feature name, the locale must
221
                // match the locale of the multilanguage text
222
                // (http://dev.e-taxonomy.eu/trac/ticket/2394).
223
                 $description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
224
               }
225
               $text .= " " . $description;
226
               $description = '';
227
             }
228
            }
229
            $block->content .= $text;
230
          }
231
        }
232

    
233
        /*
234
        Media/ALL FEATURES.
235
        */
236
        $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
237

    
238
        $gallery = theme('cdm_media_gallerie', array(
239
           'mediaList' => $media_list,
240
           'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
241
           'maxExtend' => isset($gallery_settings['cdm_dataportal_media_maxextend']) ? $gallery_settings['cdm_dataportal_media_maxextend'] : NULL ,
242
           'cols' => isset($gallery_settings['cdm_dataportal_media_cols']) ? $gallery_settings['cdm_dataportal_media_cols'] : NULL ,
243
           'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? $gallery_settings['cdm_dataportal_media_maxRows'] : NULL ,
244
           'captionElements' => isset($captionElements) ? $captionElements : NULL ,
245
           )
246
        );
247

    
248
        $block->content .= $gallery;
249
        $block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
250
        $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
251

    
252
        // Add anchor to subject.
253
        $block->subject = '<a name="' . $block->delta . '"></a>' . $block->subject;
254

    
255
        $block->region = FALSE;
256
        $out .= theme('block', array('elements' => array(
257
          '#block' => $block,
258
          '#children' => $block->content,
259
        )));
260
      }
261
    }
262
  }
263
  // Calling the theme function for Bibliography to add it to the output.
264
  // Add the display of the number of taxa in the selected genus.
265
  $out .= theme('cdm_block_Uses', array('taxonUuid' => $taxon->uuid));
266

    
267
  $show_bibliography = variable_get('cdm_show_bibliography', 1);
268
  if ($show_bibliography && $countFeatures != 0) {
269
    $out .= theme('cdm_descriptionElementBibliography', array('descriptionElementsBibliography' => $bibliographyOut));
270
  }
271

    
272
  RenderHints::popFromRenderStack();
273
  return $out;
274
}
275

    
276
/**
277
 * @todo Please document this function.
278
 * @see http://drupal.org/node/1354
279
 */
280
function palmweb_2_cdm_search_results($variables){
281
  $pager = $variables['pager'];
282
  $path = $variables['path'];
283
  $out = '';
284

    
285
  $showThumbnails = isset($_SESSION['pageoption']['searchtaxa']['showThumbnails']) ? $_SESSION['pageoption']['searchtaxa']['showThumbnails'] : 0;
286
  if (!is_numeric($showThumbnails)) {
287
    // AT RBG KEW - 14/11/2011 - Set the show thumbnails to 0 by default.
288
    $showThumbnails = 0;
289
  }
290
  $setSessionUri = url('cdm_api/setvalue/session', array('query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => '')));
291
  drupal_add_js('jQuery(document).ready(function() {
292

    
293
        // Init.
294
        if(' . $showThumbnails . ' == 1){
295
              jQuery(\'.media_gallery\').show(20);
296
        } else {
297
          jQuery(\'.media_gallery\').hide(20);
298
        }
299
        // Add change hander.
300
        jQuery(\'#showThumbnails\').change(
301
          function(event){
302
            var state = 0;
303
            if(jQuery(this).is(\':checked\')){
304
              jQuery(\'.media_gallery\').show(20);
305
              state = 1;
306
            } else {
307
              jQuery(\'.media_gallery\').hide(20);
308
            }
309
            // Store state in session variable.
310
            var uri = \'' . $setSessionUri . '\' + state;
311
            jQuery.get(uri);
312
          });
313
        });', "inline");
314

    
315
  drupal_set_title(t('Search results'));
316

    
317
  // AT RBG KEW - 14/11/2011 - Changed the wording of the Show Thumbnails
318
  // tickbox text.
319
  $out .= '<div class="page_options">';
320
  $out .= '<form name="pageoptions">';
321
  $out .= '<input id="showThumbnails" type="checkbox" name="showThumbnails" ';
322
  $out .= $showThumbnails == 1 ? 'checked="checked"' : '';
323
  $out .= '> ' . t('Show Image Thumbnails') . '</form></div>';
324
  if (!empty($pager) && count($pager->records) > 0) {
325
      $out .= '<div id="search_results">';
326
    $out .= theme('cdm_list_of_taxa', array('records' => $pager->records));
327
    $out .= '</div>';
328
    $out .= theme('cdm_pager', array(
329
      'pager' => $pager,
330
      'path' => $path,
331
      'parameters' => $_REQUEST,
332
    ));
333
  }
334
  else {
335
    $out = '<h4 class="error">Sorry, no matching entries found.</h4>';
336
  }
337
  return $out;
338
}
339

    
340
/*
341
Comment @WA: theme function moved to cdm_dataportal module,
342
theme/cdm_dataportal.bibliography.theme so this can be used by other portals
343
as well.
344
@TODO: should this not be part of the palmweb_2 featuretree and be treated
345
as a normal description feature?
346
function theme_cdm_descriptionElementBibliography
347
function formatReference_for_Bibliography($references) {
348
 */
349

    
350
/**
351
 * @todo Please document this function.
352
 */
353
function palmweb_2_cdm_media_caption($variables){
354
  $media = $variables['media'];
355
  $elements = $variables['elements'];
356
  $fileUri = $variables['fileUri'];
357

    
358
  $media_metadata = cdm_read_media_metadata($media);
359

    
360
  $doTitle = !$elements || array_search('title', $elements) !== FALSE;
361
  $doDescription = !$elements || array_search('description', $elements) !== FALSE;
362
  $doArtist = !$elements || array_search('artist', $elements) !== FALSE;
363
  $doLocation = !$elements || array_search('location', $elements) !== FALSE;
364
  $doRights = !$elements || array_search('rights', $elements) !== FALSE;
365

    
366
  $descriptionPrefix = "";
367

    
368
  $out = '<dl class="media-caption">';
369
  // Title.
370
  if ($doTitle) {
371
    if ($media_metadata['title']) {
372
      $out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>';
373
      $descriptionPrefix = "- ";
374
    }
375
    elseif (!($doDescription && $media_metadata['description'])) {
376
      // Use filename as fallbackoption if no description will be shown.
377
      $out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['filename'] . '</dd>';
378
      $descriptionPrefix = "- ";
379
    }
380
  }
381
  // Description.
382
  if ($media_metadata['description'] && $doDescription) {
383
    $out .= '<dt class = "description">' . t('Description') . '</dt> <dd class = "description">' . $descriptionPrefix . $media_metadata['description'] . '</dd>';
384
  }
385
  // Artist.
386
  if ($media_metadata['artist'] && $doArtist) {
387
    $out .= '<dt class = "artist">' . t('Artist') . '</dt> <dd class = "astist">' . str_replace("'","", $media_metadata['artist']) . '</dd>';
388
  }
389
  // Location.
390
  if ($doLocation) {
391
    $location = '';
392
    $location .= $media_metadata['location']['sublocation'];
393
    if ($location && $media_metadata['location']['city']) {
394
      $location .= ', ';
395
    }
396
    $location .= $media_metadata['location']['city'];
397
    if ($location && $media_metadata['location']['province']) {
398
      $location .= ', ';
399
    }
400
    $location .= $media_metadata['location']['province'];
401
    if ($location && $media_metadata['location']['country']) {
402
      $location .= ' (' . $media_metadata['location']['country'] . ')';
403
    }
404
    else {
405
      $location .= $media_metadata['location']['country'];
406
    }
407
    if ($location) {
408
      $out .= '<dt class = "location">' . t('Location') . '</dt> <dd class = "location">' . $location  . '</dd>';
409
    }
410
  }
411
  // Rights.
412
  if ($doRights) {
413
    $rights = '';
414
    // Copyrights.
415
    $cnt = count($media_metadata['rights']['copyright']['agentNames']);
416
    if ($cnt > 0) {
417
      $rights .= '<dt class="rights">&copy;</dt> <dd class="rights"> ';
418
      for ($i = 0; $i < $cnt; $i++) {
419
        $rights .= str_replace("'","", $media_metadata['rights']['copyright']['agentNames'][$i]);
420
        if ($i + 1 < $cnt) {
421
          $rights .= ' / ';
422
        }
423
      }
424
      $rights .= '</dd>';
425
    }
426
    // License.
427
    $cnt = count($media_metadata['rights']['license']['agentNames']);
428
    if ($cnt > 0) {
429
      $rights .= '<dt class ="license">' . t('License') . '</dt> <dd class = "license">';
430
      for ($i = 0; $i < $cnt; $i++) {
431
        $rights .= $media_metadata['rights']['license']['agentNames'][$i];
432
        if ($i + 1 < $cnt) {
433
          $rights .= ' / ';
434
        }
435
      }
436
      $rights .= '</dd>';
437
    }
438
    if ($rights) {
439
      $out .= $rights . '</dt>';
440
    }
441
  }
442
  // TODO add all other metadata elemenst generically.
443
  $out .= '</dl>';
444
  // Return value.
445
  return $out;
446
}
447

    
448
/**
449
 * @todo document this function.
450
 */
451
function palmweb_2_cdm_reference($variables) {
452
  $reference = $variables['reference'];
453
  $microReference = $variables['microReference'];
454
  $doLink = $variables['doLink'];
455
  $referenceStyle = $variables['referenceStyle'];
456

    
457
  $author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
458

    
459
  $year = '';
460
  if (isset($reference->datePublished->start)) {
461
    $year = partialToYear($reference->datePublished->start);
462
  }
463
  if(isset($author_team->titleCache)){
464
    $citation = _short_form_of_author_team ($author_team->titleCache) . (!empty($year) ? '. ' . $year : '');
465
    $citation = str_replace('..', '.', $citation);
466
  } else {
467
    $citation = '';
468
  }
469

    
470
  if ($doLink) {
471
    $out = '<span class="reference">';
472
    $out .= l($citation, path_to_reference($reference->uuid), array(
473
    'attributes' => array('class' => 'reference'),
474
    'absolute' => TRUE,
475
    'html' => TRUE,
476
    ));
477
    $out .= '</span>';
478
  }
479
  else {
480
    $out = '<span class="reference">' . $citation . '</span>';
481
  }
482
  // FIXME use microreference webservice instead.
483
  if (!empty($descriptionElementSource->citationMicroReference)) {
484
    $out .= ': ' . $descriptionElementSource->citationMicroReference;
485
  }
486

    
487
  return $out;
488
}
489

    
490
/**
491
 * Sets the body-tag class attribute.
492
 *
493
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
494
 */
495
function phptemplate_body_class($sidebar_left, $sidebar_right) {
496
  if ($sidebar_left != '' && $sidebar_right != '') {
497
    $class = 'sidebars';
498
  }
499
  else {
500
    if ($sidebar_left != '') {
501
      $class = 'sidebar-left';
502
    }
503
    if ($sidebar_right != '') {
504
      $class = 'sidebar-right';
505
    }
506
  }
507

    
508
  if (isset($class)) {
509
    print ' class="' . $class . '"';
510
  }
511
}
512

    
513
/**
514
 * Allow themeable wrapping of all comments.
515
 */
516
function phptemplate_comment_wrapper($content, $type = NULL) {
517
  static $node_type;
518
  if (isset($type)) {
519
    $node_type = $type;
520
  }
521

    
522
  if (!$content || $node_type == 'forum') {
523
    return '<div id="comments">' . $content . '</div>';
524
  }
525
  else {
526
    return '<div id="comments"><h2 class="comments">' . t('Comments') . '</h2>' . $content . '</div>';
527
  }
528
}
529

    
530
/**
531
 * Override or insert PHPTemplate variables into the templates.
532
 */
533
function _phptemplate_variables($hook, $vars) {
534
  if ($hook == 'page') {
535

    
536
    if ($secondary = menu_secondary_local_tasks()) {
537
      $output = '<span class="clear"></span>';
538
      $output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
539
      $vars['tabs2'] = $output;
540
    }
541

    
542
    // Hook into color.module
543
    if (module_exists('color')) {
544
      _color_page_alter($vars);
545
    }
546
    return $vars;
547
  }
548
  return array();
549
}
550

    
551
/**
552
 * Returns the rendered local tasks. The default implementation renders
553
 * them as tabs.
554
 *
555
 * @ingroup themeable
556
 */
557
function phptemplate_menu_local_tasks() {
558
  $output = '';
559

    
560
  if ($primary = menu_primary_local_tasks()) {
561
    $output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
562
  }
563

    
564
  return $output;
565
}
566

    
567
/**
568
 * @todo Please document this function.
569
 * @see http://drupal.org/node/1354
570
 */
571
function palmweb_2_cdm_feature_name($variables){
572
  $feature_name = $variables['feature_name'];
573
  switch ($feature_name) {
574
    case "Protologue": return t("Original Publication");
575
    default: return t(ucfirst($feature_name));
576
  }
577
}
578

    
579
/**
580
 * Implements hook_preprocess_HOOK() for theme_page().
581
 *
582
 * Assign the css classes primary-links and secondary-links to the menus and
583
 * process the 'Login' menu item, to change into 'My account' after login and
584
 * change the tab title for the IMCE file browser.
585
 *
586
 * @author W.Addink <w.addink@eti.uva.nl>
587
 */
588
function palmweb_2_preprocess_page(&$vars) {
589

    
590
  if (isset($vars['main_menu'])) {
591
    // For the Palmae theme we want to change the menu item 'Login' into
592
    // 'My account' if a user is logged in.
593
    global $user;
594
    foreach ($vars['main_menu'] as $key => $value) {
595
        if ($value['href'] == 'user' && !empty($user->name)) {
596
            $vars['main_menu'][$key]['title'] = t('My account');
597
            $vars['main_menu'][$key]['href'] = 'user/' . $user->uid;
598
        }
599
    }
600
    // Theme the main menu with the desired css classes.
601
    $vars['primary_nav'] = theme('links__system_main_menu', array(
602
      'links' => $vars['main_menu'],
603
      'attributes' => array(
604
        'class' => array('links', 'inline', 'main-menu', 'primary-links'),
605
      ),
606
      'heading' => array(
607
        'text' => t('Main menu'),
608
        'level' => 'h2',
609
        'class' => array('element-invisible'),
610
      )));
611
  }
612
  else {
613
    $vars['primary_nav'] = FALSE;
614
  }
615
  if (isset($vars['secondary_menu'])) {
616
    $vars['secondary_nav'] = theme('links__system_secondary_menu', array(
617
      'links' => $vars['secondary_menu'],
618
      'attributes' => array(
619
        'class' => array('links', 'inline', 'secondary-menu', 'secondary-links'),
620
      ),
621
      'heading' => array(
622
        'text' => t('Secondary menu'),
623
        'level' => 'h2',
624
        'class' => array('element-invisible'),
625
      )));
626
  }
627
  else {
628
    $vars['secondary_nav'] = FALSE;
629
  }
630

    
631
  // Change IMCE tab to 'Personal Files'.
632
  if (!empty($vars['tabs']['#primary'])) {
633
    foreach ($vars['tabs']['#primary'] as $key => $value) {
634
      if ($value['#link']['path'] == 'user/%/imce') {
635
        $vars['tabs']['#primary'][$key]['#link']['title'] = t('Personal Files');
636
      }
637
    }
638
  }
639

    
640

    
641
  /* Display node title as page title for the comment form.
642
  * Comment @WA: it would probably be better to select $uuid from node_cdm
643
  * table and link to cdm_dataportal/taxon/%uuid instead.
644
  */
645
  if (arg(0) == 'comment' && arg(1) == 'reply') {
646
      $node = $vars['page']['content']['system_main']['comment_node']['#node'];
647
      $vars['title'] = l(check_plain($node->title),'node/' . $node->nid);
648
  }
649
}
650

    
651
/**
652
 * Implements hook_preprocess_HOOK() for theme_node().
653
 *
654
 * Fixes file urls in nodes. In nodes, relative urls are used to include files
655
 * like <img src="/files/..
656
 *
657
 * Portals can be installed in configurations with
658
 * sub-directories however, in which case these urls need to be adjusted.
659
 * Examples: mysite.org, mysite.org/myportal, mysite.org/portals/myportal.
660
 *
661
 * Therefore preprocess nodes and replace these urls with a the appropriate url
662
 * for the current setup.
663
 *
664
 * @author W.Addink <w.addink@eti.uva.nl>
665
 */
666
function palmweb_2_preprocess_node(&$vars) {
667
  $body = '';
668
// Warning: use #markup value, for which filters like php, html etc are applied!
669
  if (isset($vars['content']['body'][0]['#markup'])) {
670
    $body = $vars['content']['body'][0]['#markup'];
671
  }
672
  else {
673
    $vars['fixed_body'] = '';
674
    return;
675
  }
676

    
677
  $file_path = '/' . variable_get('file_public_path', conf_path() . '/files');
678
  global $base_url;
679
  if ($base_url == '/') {
680
    drupal_set_message(t('
681
      The $base_url in this portal could not be set, please set the $base_url
682
      manually your Drupal settings.php file.', 'error'
683
    ));
684
  }
685
  $fixed_file_path = $base_url . $file_path;
686

    
687
  $preg_file_path = preg_quote($file_path, '/');
688
  $body = preg_replace ('/src\s*=\s*["]\s*' . $preg_file_path . '/', 'src="' . $fixed_file_path , $body);
689
  $body = preg_replace ('/src\s*=\s*[\']\s*' . $preg_file_path . '/', 'src=\'' . $fixed_file_path , $body);
690
  $body = preg_replace ('/href\s*=\s*["]\s*' . $preg_file_path . '/', 'href="' . $fixed_file_path , $body);
691
  $body = preg_replace ('/href\s*=\s*[\']\s*' . $preg_file_path . '/', 'href=\'' . $fixed_file_path , $body);
692

    
693
  $vars['fixed_body'] = $body;
694
}
695

    
696
/**
697
 * Implements hook_form_FORM_ID_alter() for comment_form().
698
 *
699
 * Alter the comment form to make it look like a D5 style comment form.
700
 *
701
 * @author W.Addink <w.addink@eti.uva.nl>
702
 */
703
function palmweb_2_form_comment_form_alter(&$form, &$form_state) {
704

    
705
  if (!isset($form['comment_preview'])) {
706
    $form['header'] = array(
707
      '#markup' => '<h2>' . t('Reply') . '</h2>',
708
      '#weight' => -2,
709
    );
710
  }
711
  $form['subject']['#title'] = $form['subject']['#title'] . ':';
712
  $form['comment_body']['und'][0]['#title'] = $form['comment_body']['und'][0]['#title'] . ':';
713
  if (isset($form['author']['_author']['#title'])) {
714
    $form['author']['_author']['#title'] = $form['author']['_author']['#title'] . ':';
715
  }
716
  $form['actions']['submit']['#value'] = t('Post comment');
717
  $form['actions']['submit']['#weight'] = 1000;
718
  $form['actions']['preview']['#value'] = t('Preview comment');
719
}
720

    
721
/**
722
 * Implements hook_preprocess_HOOK() for theme_comment().
723
 *
724
 * Alter the comment display to make it look like a D5 style comment.
725
 *
726
 * @author W.Addink <w.addink@eti.uva.nl>
727
 */
728
function palmweb_2_preprocess_comment(&$variables) {
729
  $comment = $variables['elements']['#comment'];
730
  if (isset($comment->subject)) {
731
    // Print title without link.
732
    $variables['title'] = $comment->subject;
733
    if ($variables['status'] == 'comment-preview') {
734
      // Add 'new' to preview.
735
      $variables['new'] = t('new');
736
    }
737
  }
738
}
(11-11/11)