Project

General

Profile

Download (23.1 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
 * 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
function garland_cichorieae_cdm_taxon_page_profile($variables) {
22
  $taxon = $variables['taxon'];
23
  $mergedTrees = $variables['mergedTrees'];
24
  $media = $variables['media'];
25
  $hideImages = $variables['hideImages'];
26

    
27
  $out = '';
28
  global $base_url;
29

    
30
  RenderHints::pushToRenderStack('taxon_page_description');
31
  // Description TOC.
32
  $out = theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees));
33

    
34
  // Preferred image.
35
  // 2 lines hard coded for testing.
36
  if (variable_get('cdm_dataportal_show_default_image', FALSE) && !$hideImages) {
37

    
38
    // $defaultPreferredImage = drupal_get_path('theme',
39
    // 'garland_cichorieae').'/images/nopic_400x300.jpg';
40
    $defaultRepresentationPart = new stdClass();
41
    $defaultRepresentationPart->width = 400;
42
    $defaultRepresentationPart->height = 300;
43
    $defaultRepresentationPart->uri = $base_url . '/' . drupal_get_path('theme', 'garland_cichorieae') . '/images/nopic_400x300_4x3cm.jpg';
44

    
45
    $imageUriParams = '&width=400&height=300&quality=95&format=jpeg';
46

    
47
    $imageMaxExtend = 400;
48
    $out .= '<div id="taxonProfileImage">' . theme('cdm_preferredImage', array(
49
      'media' => $media,
50
      'defaultRepresentationPart' => $defaultRepresentationPart,
51
      'imageMaxExtend' => $imageMaxExtend,
52
      'parameters' => $imageUriParams,
53
      )) . '</div>';
54
  }
55

    
56
  // Description.
57
  $out .= theme('cdm_featureTrees', array(
58
    'mergedTrees' => $mergedTrees,
59
    'taxon' => $taxon,
60
  ));
61
  RenderHints::popFromRenderStack();
62

    
63
  return $out;
64
}
65

    
66
/**
67
 * @todo Please document this function.
68
 * @see http://drupal.org/node/1354
69
 */
70
function garland_cichorieae_cdm_descriptionElementTextData($variables) {
71
  $element = $variables['element'];
72
  $asListElement = $variables['asListElement'];
73
  $feature_uuid = $variables['feature_uuid'];
74

    
75
  $description = '';
76
  if (isset($element->multilanguageText_L10n->text)) {
77
    $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
78
  }
79
  $sourceRefs = '';
80
  $result = array();
81
  $res_author;
82
  $res_date;
83
  $do_links = TRUE;
84
  $default_theme = variable_get('theme_default', 'garland_cichorieae');
85

    
86
  if (($default_theme == 'flora_malesiana' || $default_theme == 'flore_afrique_centrale' || $default_theme == 'flore_gabon') && $element->feature->titleCache == 'Citation') {
87
    $asListElement = TRUE;
88
  }
89
  elseif ($element->feature->uuid == UUID_CHROMOSOMES_NUMBERS) {
90
    $asListElement = TRUE;
91
  }
92
  else {
93
    $asListElement = FALSE;
94
  }
95

    
96
  // Printing annotations footnotes.
97
  $annotation_fkeys = theme('cdm_annotations_as_footnotekeys', array(
98
    'cdmBase_list' => $element,
99
    'footnote_list_key' => $feature_uuid,
100
  ));
101

    
102
  if ($feature_uuid == UUID_NAME_USAGE || $feature_uuid == UUID_CHROMOSOMES) {
103
    $do_links = FALSE;
104
  }
105

    
106
  if (is_array($element->sources)) {
107
    foreach ($element->sources as $source) {
108
      // Initialize some variables.
109
      if ($feature_uuid == UUID_NAME_USAGE) {
110
        $referenceCitation = cdm_ws_get(
111
          CDM_WS_NOMENCLATURAL_REFERENCE_CITATION,
112
          array($source->citation->uuid),
113
          "microReference=" . urlencode($source->citationMicroReference
114
        ));
115
        $referenceCitation = $referenceCitation->String;
116
      }
117
      else {
118
        $referenceCitation = theme('cdm_OriginalSource', array(
119
          'source' => $source,
120
          'doLink' => $do_links,
121
        ));
122
      }
123
      if ($description && strlen($description) > 0 && $referenceCitation) {
124
        $sourceRefs .= ' (' . $referenceCitation . ')';
125
      }
126
      elseif ($referenceCitation) {
127
        $sourceRefs = $referenceCitation;
128
      }
129
      // Generate the output.
130
      if (strlen($sourceRefs) > 0) {
131
        $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
132
      }
133
      $name_used_in_source_link_to_show = '';
134
      if (isset($source->nameUsedInSource->uuid) && ($feature_uuid != UUID_NAME_USAGE)) {
135
        // Do a link to name page.
136
        $name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array(), NULL, NULL, FALSE, TRUE);
137
      }
138
      elseif (isset($source->nameUsedInSource->uuid) && ($feature_uuid == UUID_NAME_USAGE)) {
139
        // Do not do link for NAME USAGE feature.
140
        $name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache;
141
      }
142
      elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) {
143
        // Show a text without link.
144
        $name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
145
      }
146

    
147
      if ($asListElement && ($feature_uuid == UUID_NAME_USAGE)) {
148
        $out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
149
        // Adding ":" if necesary.
150
        if (!empty($name_used_in_source_link_to_show) && (!empty($description) || !empty($sourceRefs))) {
151
          $out .= ': ';
152
        }
153

    
154
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array(
155
          'cdmBase_list' => $element,
156
          'footnote_list_key' => $feature_uuid,
157
        )) . $annotation_fkeys . '</li>';
158
      }
159
      elseif ($asListElement) {
160

    
161
        $out = '<li class="descriptionText DescriptionElement">';
162
        // Adding ":" if necessary.
163
        if (!empty($name_used_in_source_link_to_show)) {
164
          if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) {
165
            $out .= $name_used_in_source_link_to_show . ': ';
166
          } else {
167
            $out .= $name_used_in_source_link_to_show . ' ';
168
          }
169
        }
170

    
171
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array(
172
          'cdmBase_list' => $element,
173
          'footnote_list_key' => $feature_uuid,
174
        )) . $annotation_fkeys . '</li>';
175
        // Special handling for flora malesiana.
176
        // TODO: possible better way to implement this case?
177
      }
178
      else {
179
        if (isset($name_used_in_source_link_to_show)) {
180
          $name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')';
181
        }
182
        if (!isset($description)) {
183
          $description = '';
184
        }
185
        if (!isset($sourceRefs)) {
186
            $sourceRefs = '';
187
        }
188
        if (!isset($name_used_in_source_link_to_show)) {
189
            $name_used_in_source_link_to_show = '';
190
        }
191
        if (!isset($annotation_fkeys)) {
192
            $annotation_fkeys = '';
193
        }
194
        $out = '<span class="' . html_class_atttibute_ref($element) . '"> ' . $description . $sourceRefs . $name_used_in_source_link_to_show . $annotation_fkeys . '</span>';
195
      }
196
    }
197
  }
198

    
199
  // If no sources, print the description.
200
  if (!isset($out)) {
201
    $out = '<span class="' . html_class_atttibute_ref($element) . '"> ' . $description . $annotation_fkeys . '</span>';
202
  }
203

    
204
  /* Dead code:
205
   *
206
   * Disabled code; can this be removed?
207
  if ($feature_uuid == UUID_NAME_USAGE){ foreach($element->sources as
208
  $source){ $referenceCitation =
209
  cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION,
210
  array($source->citation->uuid),
211
  "microReference=".urlencode($source->citationMicroReference));
212
  $referenceCitation = $referenceCitation->String; if($description &&
213
  strlen($description) > 0 && $referenceCitation ){ $sourceRefs .= '
214
  ('.$referenceCitation.')' ; }else if ($referenceCitation){ $sourceRefs =
215
  $referenceCitation; } } }else{ foreach($element->sources as $source){
216
  $referenceCitation = theme('cdm_OriginalSource', $source,
217
  ($feature_uuid == UUID_NAME_USAGE) ? FALSE : TRUE); if($description &&
218
  strlen($description) > 0 && $referenceCitation ){ $sourceRefs .= '
219
  ('.$referenceCitation.')' ; }else if ($referenceCitation){ $sourceRefs =
220
  $referenceCitation; } } } if(strlen($sourceRefs) > 0){ $sourceRefs = '<span
221
  class="sources">' . $sourceRefs . '</span>'; } if
222
  ($source->nameUsedInSource->uuid && ($feature_uuid != UUID_NAME_USAGE)){
223
  //do a link to name page $name_used_in_source_link_to_show =
224
  l($source->nameUsedInSource->titleCache,
225
  path_to_name($source->nameUsedInSource->uuid), array(), NULL, NULL, FALSE
226
  ,TRUE); }else if ($source->nameUsedInSource->uuid && ($feature_uuid ==
227
  UUID_NAME_USAGE)){ //do not do link for NAME USAGE feature
228
  $name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache;
229
  }else if (strlen($source->nameUsedInSource->originalNameString) > 0){
230
  //show a text without link $name_used_in_source_link_to_show =
231
  $source->nameUsedInSource->originalNameString; } if($asListElement &&
232
  ($feature_uuid == UUID_NAME_USAGE)){ $out = '<li class="descriptionText">'
233
  . $name_used_in_source_link_to_show; //adding ":" if necesary if
234
  ($name_used_in_source_link_to_show && ($description || $sourceRefs)){ $out
235
  .= ': '; } $out .= $description . $sourceRefs .
236
  theme('cdm_annotations_as_footnotekeys', $element) . '</li>'; }else if
237
  ($asListElement){ $out = '<li class="descriptionText">' .
238
  $name_used_in_source_link_to_show; //adding ":" if necesary if
239
  ($name_used_in_source_link_to_show && ($description || $sourceRefs)){ $out
240
  .= ': '; } $out .= $description . $sourceRefs .
241
  theme('cdm_annotations_as_footnotekeys', $element) . '</li>'; //special
242
  handling for flora malesiana TODO: possible better way to implement this
243
  case? }else{ if ($name_used_in_source_link_to_show){
244
  $name_used_in_source_link_to_show = ' (name in source: '.
245
  $name_used_in_source_link_to_show . ')'; } $out = $description .
246
  $sourceRefs . $name_used_in_source_link_to_show; $out .=
247
  theme('cdm_annotations_as_footnotekeys', $element); }
248
  */
249
  // Add annotations as footnote key.
250
  // $out .= theme('cdm_annotations_as_footnotekeys', $element); move above.
251
  return $out;
252
}
253

    
254
// NO LONGER NEEDED - since term representation is changed now in the cdm for
255
// the cichorieae
256
// ====> delete
257
// /**
258
// * @overrides theme_cdm_taggedtext2html in order to replace t.infr and
259
// t.infgen. with '[unranked]'
260
// */
261
// function garland_cichorieae_cdm_taggedtext2html(array &$taggedtxt, $tag =
262
// 'span', $glue = ' ', $skiptags = array()){
263
// $out = '';
264
// $i = 0;
265
// foreach($taggedtxt as $tt){
266
// if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
267
// $out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.'
268
// class="'.$tt->type.'">';
269
// if($tt->type == "rank" && ($tt->text == "t.infr." || $tt->text ==
270
// "t.infgen.")){
271
// $out .= t('[unranked]');
272
// }else{
273
// $out .= t($tt->text);
274
// }
275
// $out .= '</'.$tag.'>';
276
// }
277
// }
278
// return $out;
279
// }
280
/**
281
 * Returns HTML for a cdm_descriptionElementArray.
282
 *
283
 * @param array $variables
284
 *   An associative array containing:
285
 *   - elementArray: The array with CDM description elements being formatted.
286
 *   - feature: The description feature container object for the
287
 *     description element array.
288
 *   - glue: String for joining the description elements together.
289
 *   - sortArray: Boolean, TRUE if the array should be sorted before themeing.
290
 *   - enclosingHTML: HTML tag, e.g. 'div', in which to wrap the description.
291
 *
292
 * @ingroup themeable
293
 */
294
function garland_cichorieae_cdm_descriptionElementArray($variables) {
295
  $elementArray = $variables['elementArray'];
296
  $feature = $variables['feature'];
297
  $glue = $variables['glue'];
298
  $sortArray = $variables['sortArray'];
299
  $enclosingHtml = $variables['enclosingHtml'];
300

    
301
  $enclosingHtml = 'div';
302
  $out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
303

    
304
  if ($sortArray) {
305
    sort($elementArray);
306
  }
307

    
308
  $out .= join($elementArray, $glue);
309

    
310
  $out .= '</' . $enclosingHtml . '>';
311
  return $out;
312
}
313

    
314
/*
315
  ***** GARLAND OVERRIDES *****
316
*/
317

    
318
/**
319
 * Sets the body-tag class attribute.
320
 *
321
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
322
 */
323
function phptemplate_body_class($sidebar_left, $sidebar_right) {
324
  if ($sidebar_left != '' && $sidebar_right != '') {
325
    $class = 'sidebars';
326
  }
327
  else {
328
    if ($sidebar_left != '') {
329
      $class = 'sidebar-left';
330
    }
331
    if ($sidebar_right != '') {
332
      $class = 'sidebar-right';
333
    }
334
  }
335

    
336
  if (isset($class)) {
337
    print ' class="' . $class . '"';
338
  }
339
}
340

    
341
/**
342
 * Allow themable wrapping of all comments.
343
 */
344
/*
345
function phptemplate_comment_wrapper($content, $type = NULL) {
346
  static $node_type;
347
  if (isset($type)) $node_type = $type;
348

    
349
  if (! $content || $node_type == 'forum') {
350
    return '<div id="comments">' . $content . '</div>';
351
  }
352
  else {
353
    return '<div id="comments"><h2 class="comments">' . t('Comments') . '</h2>' . $content . '</div>';
354
  }
355
}
356
*/
357

    
358
/**
359
 * Override or insert PHPTemplate variables into the templates.
360
 */
361
function _phptemplate_variables($hook, $vars) {
362
  if ($hook == 'page') {
363

    
364
    if ($secondary = menu_secondary_local_tasks()) {
365
      $output = '<span class="clear"></span>';
366
      $output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
367
      $vars['tabs2'] = $output;
368
    }
369

    
370
    // Hook into color.module
371
    if (module_exists('color')) {
372
      _color_page_alter($vars);
373
    }
374
    return $vars;
375
  }
376
  return array();
377
}
378

    
379
/**
380
 * Returns HTML for the rendered local tasks.
381
 *
382
 * The default implementation renders them as tabs.
383
 *
384
 * @ingroup themeable
385
 */
386
function phptemplate_menu_local_tasks() {
387
  $output = '';
388

    
389
  if ($primary = menu_primary_local_tasks()) {
390
    $output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
391
  }
392

    
393
  return $output;
394
}
395

    
396
/**
397
 * @deprecated define name render templates via the layout settings
398
 */
399
function garland_cichorieae_get_partDefinition() {
400
  return array(
401
     'BotanicalName' => array(
402
        'namePart' => array('name' => TRUE),
403
        'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
404
        'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
405
        'statusPart' => array('status' => TRUE),
406
        'descriptionPart' => array('description' => TRUE),
407
    )
408
  );
409
}
410

    
411
/**
412
 * @deprecated define name render templates via the layout settings
413
 */
414
function garland_cichorieae_get_nameRenderTemplate($variables) {
415
  $templates = array(
416
   'taxon_page_title,polytomousKey'=> array(
417
        'namePart' => array('#uri' => TRUE),
418
      ),
419
    'taxon_page_synonymy,related_taxon'=> array(
420
        'nameAuthorPart' => array('#uri' => TRUE),
421
        'referencePart' => TRUE,
422
        'statusPart' => TRUE,
423
        'descriptionPart' => TRUE,
424
      ),
425
    'acceptedFor' => array(
426
        'nameAuthorPart' => array('#uri' => TRUE),
427
        'referencePart' => TRUE,
428
      ),
429
    'typedesignations,list_of_taxa' => array(
430
        'nameAuthorPart' => array('#uri' => TRUE),
431
        'referencePart' => TRUE,
432
      ),
433
    '#DEFAULT' => array(
434
        'nameAuthorPart' => array('#uri' => TRUE),
435
        'referencePart' => TRUE,
436
      )
437
    );
438
  return $templates;
439
}
440

    
441
/**
442
 * Returns HTML for taxon list thumbnails.
443
 *
444
 * Theme specific mods:
445
 * $captionElements = array('title', '#uri'=>t('open Image'));
446
 * $mediaLinkType:
447
 * "NORMAL": link to the image page or to the $alternativeMediaUri if it is
448
 * defined instead of
449
 * "LIGHTBOX": open the link in a light box,
450
 * TODO expose those in admin section, by adding 'em to gallery_settings see
451
 * http://dev.e-taxonomy.eu/trac/ticket/2494.
452
 *
453
 * @param array $variables
454
 *   An associative array containing:
455
 *   - taxon: The taxon object for which to theme the thumbnails.
456
 *
457
 * @ingroup themeable
458
 */
459
function garland_cichorieae_cdm_taxon_list_thumbnails($variables) {
460
  $out = '';
461
  $taxon = $variables['taxon'];
462

    
463
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
464

    
465
  $mediaLinkType = 'NORMAL';
466
  $showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
467
  $captionElements = array();
468
  if ($showCaption) {
469
    $captionElements = array('title', '#uri' => t('open Image'));
470
  }
471

    
472
  $gallery_name = $taxon->uuid;
473

    
474
  $mediaQueryParameters = array("type" => "ImageFile");
475
  $galleryLinkUri = path_to_taxon($taxon->uuid, 'images');
476

    
477
  // TODO cdm_dataportal_show_media = ????
478
  $selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
479
  if ($selectShowMedia == 0) {
480
    $mediaList = cdm_ws_get(
481
      CDM_WS_PORTAL_TAXON_MEDIA,
482
      array($taxon->uuid),
483
      queryString($mediaQueryParameters
484
    ));
485
  }
486
  else {
487
    $mediaList = cdm_ws_get(
488
      CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA,
489
      array($taxon->uuid),
490
      queryString($mediaQueryParameters
491
    ));
492
  }
493
  $out .= theme('cdm_media_gallerie', array(
494
    'mediaList' => $mediaList,
495
    'galleryName' => $gallery_name,
496
    'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
497
    'cols' => $gallery_settings['cdm_dataportal_media_cols'],
498
    'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
499
    'captionElements' => $captionElements,
500
    'mediaLinkType' => $mediaLinkType,
501
    'alternativeMediaUri' => $galleryLinkUri,
502
    'showCaption' => NULL,
503
  ));
504

    
505
  return $out;
506
}
507

    
508
/**
509
 * @todo Please document this function.
510
 * @see http://drupal.org/node/1354
511
 */
512
function garland_cichorieae_cdm_feature_name($variables) {
513
  $feature_name = $variables['feature_name'];
514
  switch ($feature_name) {
515
    case "Protologue":
516
      return t("Original Publication");
517
    default:
518
      return ucfirst($feature_name);
519
  }
520
}
521

    
522
/*
523
======== Special functions for subtheme handling=============
524
*/
525

    
526
/**
527
 * @todo Please document this function.
528
 * @see http://drupal.org/node/1354
529
 */
530
function sub_theme() {
531
  global $user, $custom_theme;
532

    
533
  // Only select the user selected theme if it is available in the
534
  // list of enabled themes.
535
  $theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
536

    
537
  // Allow modules to override the present theme... only select custom theme
538
  // if it is available in the list of installed themes.
539
  $theme = $custom_theme && $themes[$custom_theme] ? $custom_theme : $theme;
540

    
541
  return $theme;
542
}
543

    
544
/**
545
 * Return the path to the currently selected sub theme.
546
 */
547
function path_to_sub_theme() {
548
  $themes = list_themes();
549
  $theme = sub_theme();
550
  return dirname($themes[$theme]->filename);
551
}
552

    
553
/**
554
 * Implements hook_preprocess_HOOK() for theme_page().
555
 *
556
 * Assign the css classes primary-links and secondary-links to the menus.
557
 * Modify primary-links if cdm_api module exists.
558
 */
559
function garland_cichorieae_preprocess_page(&$vars) {
560
  if (isset($vars['main_menu'])) {
561
    /*
562
    obsolete, see http://dev.e-taxonomy.eu/trac/ticket/2191
563
    if(module_exists('cdm_api')){ foreach($vars['main_menu'] as $key =>
564
    $menu_item){ // nb this makes each menu item you click opening a new
565
    browser window..
566
    $menu_item['attributes']['target']=generalizeString($menu_item['title']);
567
    $main_menu[] = $menu_item; }; }else{ $main_menu = $vars['main_menu'] ; };
568
    */
569
    $vars['primary_nav'] = theme('links__system_main_menu', array(
570
      'links' => $vars['main_menu'], 'attributes' => array(
571
        'class' => array(
572
          'links', 'inline', 'main-menu', 'primary-links',
573
        )),
574
        'heading' => array(
575
          'text' => t('Main menu'), 'level' => 'h2', 'class' => array(
576
            'element-invisible',
577
          ))));
578
  }
579
  else {
580
    $vars['primary_nav'] = FALSE;
581
  }
582
  if (isset($vars['secondary_menu'])) {
583
    $vars['secondary_nav'] = theme('links__system_secondary_menu', array(
584
      'links' => $vars['secondary_menu'], 'attributes' => array(
585
        'class' => array(
586
          'links',
587
          'inline',
588
          'secondary-menu',
589
          'secondary-links',
590
        )),
591
        'heading' => array(
592
          'text' => t('Secondary menu'),
593
          'level' => 'h2',
594
          'class' => array('element-invisible'),
595
        )));
596
  }
597
  else {
598
    $vars['secondary_nav'] = FALSE;
599
  }
600

    
601
  /*
602
  Display node title as page title for the comment form.
603
  Comment @WA: it would probably be better to select $uuid from node_cdm
604
  table and link to cdm_dataportal/taxon/%uuid instead.
605
  */
606
  if (arg(0) == 'comment' && arg(1) == 'reply') {
607
    $node = $vars['page']['content']['system_main']['comment_node']['#node'];
608
    $vars['title'] = l(check_plain($node->title), 'node/' . $node->nid);
609
  }
610
}
611

    
612
/**
613
 * Implements hook_preprocess_HOOK() for theme_node().
614
 *
615
 * Fixes file urls in nodes. In nodes, relative urls are used to include files
616
 * like <img src="/files/..
617
 *
618
 * Portals can be installed in configurations with
619
 * sub-directories however, in which case these urls need to be adjusted.
620
 * Examples: mysite.org, mysite.org/myportal, mysite.org/portals/myportal.
621
 *
622
 * Therefore preprocess nodes and replace these urls with a the appropriate url
623
 * for the current setup.
624
 *
625
 * @author W.Addink <w.addink@eti.uva.nl>
626
 */
627
function garland_cichorieae_preprocess_node(&$vars) {
628
  $body = '';
629
  // Warning: use #markup value, for which filters like php, html etc are applied!
630
  if (isset($vars['content']['body'][0]['#markup'])) {
631
    $body = $vars['content']['body'][0]['#markup'];
632
  }
633
  else {
634
    $vars['fixed_body'] = '';
635
    return;
636
  }
637

    
638
  $file_path = '/' . variable_get('file_public_path', conf_path() . '/files');
639
  global $base_url;
640
  if ($base_url == '/') {
641
    drupal_set_message(t('
642
      The $base_url in this portal could not be set, please set the $base_url
643
      manually your Drupal settings.php file.', 'error'
644
    ));
645
  }
646
  $fixed_file_path = $base_url . $file_path;
647
  $preg_file_path = preg_quote($file_path, '/');
648
  $body = preg_replace('/src\s*=\s*["]\s*' . $preg_file_path . '/', 'src="' . $fixed_file_path, $body);
649
  $body = preg_replace('/src\s*=\s*[\']\s*' . $preg_file_path . '/', 'src=\'' . $fixed_file_path, $body);
650
  $body = preg_replace('/href\s*=\s*["]\s*' . $preg_file_path . '/', 'href="' . $fixed_file_path, $body);
651
  $body = preg_replace('/href\s*=\s*[\']\s*' . $preg_file_path . '/', 'href=\'' . $fixed_file_path, $body);
652

    
653
  $vars['fixed_body'] = $body;
654
}
655

    
656
/**
657
 * Implements hook_form_FORM_ID_alter() for comment_form().
658
 *
659
 * Alter the comment form to make it look like a D5 style comment form.
660
 *
661
 * @author W.Addink <w.addink@eti.uva.nl>
662
 */
663
function garland_cichorieae_form_comment_form_alter(&$form, &$form_state) {
664

    
665
  if (!isset($form['comment_preview'])) {
666
    $form['header'] = array(
667
      '#markup' => '<h2>' . t('Reply') . '</h2>',
668
      '#weight' => -2,
669
    );
670
  }
671
  $form['subject']['#title'] = $form['subject']['#title'] . ':';
672
  $form['comment_body']['und'][0]['#title'] = $form['comment_body']['und'][0]['#title'] . ':';
673
  if (isset($form['author']['_author']['#title'])) {
674
    $form['author']['_author']['#title'] = $form['author']['_author']['#title'] . ':';
675
  }
676
  $form['actions']['submit']['#value'] = t('Post comment');
677
  $form['actions']['submit']['#weight'] = 1000;
678
  $form['actions']['preview']['#value'] = t('Preview comment');
679
}
680

    
681
/**
682
 * Implements hook_preprocess_HOOK() for theme_comment().
683
 *
684
 * Alter the comment display to make it look like a D5 style comment.
685
 *
686
 * @author W.Addink <w.addink@eti.uva.nl>
687
 */
688
function garland_cichorieae_preprocess_comment(&$variables) {
689
  $comment = $variables['elements']['#comment'];
690
  if (isset($comment->subject)) {
691
    // Print title without link.
692
    $variables['title'] = $comment->subject;
693
    if ($variables['status'] == 'comment-preview') {
694
      // Add 'new' to preview.
695
      $variables['new'] = t('new');
696
    }
697
  }
698
}
(12-12/13)