Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / themes / garland_cichorieae / template.php @ b5e773ef

History | View | Annotate | Download (11 KB)

1
<?php
2
// $Id$
3

    
4
/**
5
 * Overrides of generic themeing functions in cdm_datportal.theme.php
6
 */
7

    
8

    
9
/**
10
 * The description page is supposed to be the front page for a taxon.
11
 *
12
 * @param TaxonTO $taxonTO
13
 * @return
14
 */
15
function garland_cichorieae_cdm_taxon_page_description($taxon, $mergedTrees, $media, $hideImages = false){
16

    
17
        RenderHints::pushToRenderStack('taxon_page_description');
18
  // description TOC
19
  $out = theme('cdm_featureTreeTOCs', $mergedTrees);
20

    
21
  // preferred image
22
  // 2 lines hard coded for testing
23
  if(!$hideImages){
24
    
25
    //$defaultPreferredImage = drupal_get_path('theme', 'garland_cichorieae').'/images/nopic_400x300.jpg';
26
    $defaultRepresentationPart = false;
27
    $defaultRepresentationPart->width = 400;
28
    $defaultRepresentationPart->height = 300;
29
    $defaultRepresentationPart->uri = drupal_get_path('theme', 'garland_cichorieae').'/images/nopic_400x300.jpg';
30
    
31
    $imageUriParams = '&width=400&height=300&quality=95&format=jpeg'; 
32
    
33
    $imageMaxExtend = 400;
34
    $out .= '<div class="preferredImage">'.theme('cdm_preferredImage', $media, $defaultRepresentationPart, $imageMaxExtend, $imageUriParams).'</div>';
35
  }
36

    
37
  // description
38
  $out .= theme('cdm_featureTrees', $mergedTrees, $taxon);
39
  RenderHints::popFromRenderStack();   
40
  
41
  return $out;
42
}
43

    
44
function garland_cichorieae_cdm_descriptionElementTextData($element){
45

    
46
  $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
47
  $referenceCitation = '';
48
  if($element->reference){
49
    // disabling references for cichorieae description Elements because they all have faulty references
50
    //$referenceCitation = '; '.theme('cdm_fullreference', $element->reference, TRUE);
51
  }
52
  return '<p class="descriptionText">' . $description . $referenceCitation.'</p>';
53
}
54

    
55

    
56
function garland_cichorieae_cdm_taxon_page_images($taxon, $media){
57

    
58
  $flashLink = isset($media[0]);
59
  
60
  if($flashLink){
61
    
62
    $taggedName = $taxon->name->taggedName;
63
    
64
    $nameArray = array();
65
    foreach($taggedName as $taggedText){
66
      if($taggedText->type == 'name'){
67
        $nameArray[] = $taggedText->text;
68
      }
69
    }
70
    
71
    $query = join("%5F", $nameArray) . '%20AND%20EditWP6%20AND%20jpg';
72
    
73
  $out = '
74
  
75
<script type="text/javascript" src="http://media.bgbm.org/erez/js/fsiwriter.js"></script>
76

77
<script type="text/javascript">
78
<!--
79
        writeFlashCode( "http://media.bgbm.org/erez/fsi/fsi.swf?&cfg=showcase_presets/showcase_info.fsi&effects=%26quality%3D95&showcase_query='.$query.'&skin=silver&showcase_labeltextheight=50&textbox_textfrom=IPTC_WP6&textbox_height=50&param_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343&plugins=textbox,fullscreen",
80
                "http://media.bgbm.org/erez/erez?src=erez-private/flashrequired.svg&tmp=Large&quality=97&width=620&height=400",
81
                "width=620;height=400;bgcolor=454343;wmode=opaque");
82
// -->
83
</script>
84
<noscript>
85
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" width="470" height="400">
86
                <param name="movie" value="http://media.bgbm.org/erez/fsi/fsi.swf?&cfg=showcase_presets/showcase_info.fsi&effects=%26quality%3D95&showcase_query='.$query.'&skin=silver&showcase_labeltextheight=50&textbox_textfrom=IPTC_WP6&textbox_height=50&param_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343plugins=textbox,fullscreen"/>
87
                <param name="bgcolor" value="454343" />
88
                <param name="wmode" value="opaque" />
89
                <param name="allowscriptaccess" value="always" />
90
                <param name="allowfullscreen" value="true" />
91
                <param name="quality" value="high" />
92
                <embed src="http://media.bgbm.org/erez/fsi/fsi.swf?&cfg=showcase_presets/showcase_info.fsi&effects=%26quality%3D95&showcase_query='.$query.'&skin=silver&showcase_labeltextheight=50&textbox_textfrom=IPTC_WP6&textbox_height=50&param_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343plugins=PrintSave,textbox,fullscreen"
93
                        width="620"
94
                        height="400"
95
                        bgcolor="454343"
96
                        wmode="opaque"
97
                        allowscriptaccess="always"
98
                        allowfullscreen="true"
99
                        quality="high"
100
                        type="application/x-shockwave-flash"
101
                        pluginspage="http://www.adobe.com/go/getflashplayer">
102
                </embed>
103
        </object>
104

105
</noscript>';
106

    
107
  }else{
108
    $out = 'No images available.';
109

    
110
  }
111
  return $out;
112
}
113

    
114
function garland_cichorieae_cdm_taxon_page_images_cichorieae_copyright(){
115
        $out = '<div id="cichorieae-copyright">';
116
        $out .= '<p>';
117
        $out .= '&copy; Images used on this website remain copyright of the individual photographer.<br> To obtain permission to use images in publications or websites please contact the network at <a href="edit-wp6-cichorieae@bgbm.org">edit-wp6-cichorieae@bgbm.org</a>. Images may be used for personal use, such as PowerPoint presentations, without permission.';
118
        $out .= '</p>';
119
    $out .= '</div>';
120
    
121
        return $out;
122
}
123

    
124
/**
125
 * @overrides theme_cdm_taggedtext2html in order to replace t.infr and t.infgen. with '[unranked]'
126
 */
127
function garland_cichorieae_cdm_taggedtext2html(array &$taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()){
128
  $out = '';
129
  $i = 0;
130
  foreach($taggedtxt as $tt){
131
    if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
132
      $out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' class="'.$tt->type.'">';
133
      if($tt->type == "rank" && ($tt->text == "t.infr." || $tt->text == "t.infgen.")){
134
        $out .= t('[unranked]');
135
      }else{
136
        $out .= t($tt->text);
137
      }
138
      $out .= '</'.$tag.'>';
139
    }
140
  }
141
  return $out;
142
}
143

    
144
function garland_cichorieae_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){
145
  $enclosingHtml = 'div';
146
  $out = '<'.$enclosingHtml.' class="description" id="'.$feature->representation_L10n.'">';
147

    
148
  if($sortArray) sort($elementArray);
149

    
150
  $out .= join($elementArray, $glue);
151

    
152
  $out .= '</'.$enclosingHtml.'>';
153
  return $out;
154
}
155

    
156

    
157
/**
158
 * all reference links switched of
159
 */
160
function garland_cichorieae_cdm_nomenclaturalReferenceSTO($referenceSTO, $doLink = FALSE, $cssClass = '', $separator = '<br />' , $enclosingTag = 'li'){
161

    
162
  $doLink = FALSE;
163

    
164
  if(isset($referenceSTO->microReference)){
165
    // it is a ReferenceTO
166
    $nomref_citation = theme('cdm_fullreference', $referenceSTO);
167
  } else {
168
    // it is ReferenceSTO
169
    $nomref_citation = $referenceSTO->fullCitation;
170
  }
171

    
172
  $is_IN_reference = str_beginsWith($nomref_citation, 'in');
173

    
174
  if($doLink){
175
    $nomref_citation = l($nomref_citation, "/cdm_dataportal/reference/".$referenceSTO->uuid, array(), NULL, NULL, FALSE, TRUE);
176
  }
177

    
178
  if(!empty($nomref_citation)){
179
    $nomref_citation = ($is_IN_reference ? '&nbsp;':',&nbsp;') . $nomref_citation;
180
  }
181

    
182
  return $nomref_citation;
183
}
184

    
185

    
186
/***** GARLAND OVERRIDES ******/
187

    
188
/**
189
 * Sets the body-tag class attribute.
190
 *
191
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
192
 */
193
function phptemplate_body_class($sidebar_left, $sidebar_right) {
194
  if ($sidebar_left != '' && $sidebar_right != '') {
195
    $class = 'sidebars';
196
  }
197
  else {
198
    if ($sidebar_left != '') {
199
      $class = 'sidebar-left';
200
    }
201
    if ($sidebar_right != '') {
202
      $class = 'sidebar-right';
203
    }
204
  }
205

    
206
  if (isset($class)) {
207
    print ' class="'. $class .'"';
208
  }
209
}
210

    
211
/**
212
 * Return a themed breadcrumb trail.
213
 *
214
 * @param $breadcrumb
215
 *   An array containing the breadcrumb links.
216
 * @return a string containing the breadcrumb output.
217
 */
218
function phptemplate_breadcrumb($breadcrumb) {
219
  if (!empty($breadcrumb)) {
220
    return '<div class="breadcrumb">'. implode('', $breadcrumb) .'</div>';
221
  }
222
}
223

    
224
/**
225
 * Allow themable wrapping of all comments.
226
 */
227
function phptemplate_comment_wrapper($content, $type = null) {
228
  static $node_type;
229
  if (isset($type)) $node_type = $type;
230

    
231
  if (!$content || $node_type == 'forum') {
232
    return '<div id="comments">'. $content . '</div>';
233
  }
234
  else {
235
    return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
236
  }
237
}
238

    
239
/**
240
 * Override or insert PHPTemplate variables into the templates.
241
 */
242
function _phptemplate_variables($hook, $vars) {
243
  if ($hook == 'page') {
244

    
245
    if ($secondary = menu_secondary_local_tasks()) {
246
      $output = '<span class="clear"></span>';
247
      $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
248
      $vars['tabs2'] = $output;
249
    }
250

    
251
    // Hook into color.module
252
    if (module_exists('color')) {
253
      _color_page_alter($vars);
254
    }
255
    return $vars;
256
  }
257
  return array();
258
}
259

    
260
/**
261
 * Returns the rendered local tasks. The default implementation renders
262
 * them as tabs.
263
 *
264
 * @ingroup themeable
265
 */
266
function phptemplate_menu_local_tasks() {
267
  $output = '';
268

    
269
  if ($primary = menu_primary_local_tasks()) {
270
    $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
271
  }
272

    
273
  return $output;
274
}
275

    
276
function garland_cichorieae_get_partDefinition($nameType){
277
  if($nameType == 'BotanicalName'){
278
    return array(
279
        'namePart' => array(
280
          'name' => true
281
    ),
282
        'nameAuthorPart' => array(
283
          'name' => true,
284
          'authors' => true
285
    ),
286
        'referencePart' => array(
287
          'reference' => true,
288
          'microreference' => true,
289
    ),
290
        'statusPart' => array(
291
          'status' => true,
292
    ),
293
        'descriptionPart' => array(
294
          'description' => true,
295
    ),
296
    );
297
  }
298
  return false;
299
}
300

    
301
function garland_cichorieae_get_nameRenderTemplate($renderPath){
302

    
303
  switch($renderPath) {
304
    case 'taxon_page_title':
305
      $template = array(
306
            'namePart' => array('#uri'=>true)
307
      );
308
      break;
309
    case 'taxon_page_synonymy':
310
    case 'related_taxon':
311
      $template = array(
312
          'nameAuthorPart' => array('#uri'=>true),
313
          'referencePart' => true,
314
          'statusPart' => true,
315
          'descriptionPart' => true
316
      );
317
      break;
318
    case 'acceptedFor':
319
      $template = array(
320
            'nameAuthorPart' => array('#uri'=>true),
321
            'referencePart' => true
322
      );
323
      break;
324
    case 'typedesignations':
325
    case 'list_of_taxa':
326
    case '#DEFAULT':
327
      $template = array(
328
            'nameAuthorPart' => array('#uri'=>true),
329
            'referencePart' => true
330
      );
331
  }
332
  return $template;
333
}
334

    
335
/**
336
 */
337
function garland_cichorieae_cdm_taxon_list_thumbnails($taxon){
338
      
339
    $gallery_name = $taxon->uuid;
340
    
341
    $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
342
    $prefMimeTypeRegex = 'image:.*';
343
    $prefMediaQuality = '*';
344
    $cols = variable_get('cdm_dataportal_findtaxa_media_cols', 3);
345
    $maxRows = variable_get('cdm_dataportal_findtaxa_media_maxRows', 1);
346
    $maxExtend = variable_get('cdm_dataportal_findtaxa_media_maxextend', 120);
347
    
348
    if($showCaption){
349
      $captionElements = array('title', '#uri'=>t('open Image'));
350
    }
351
    
352
    $galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
353
    $mediaList = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
354
    $out .= theme('cdm_media_gallerie', $mediaList, $gallery_name ,$maxExtend, $cols, $maxRows, $captionElements, 'NORMAL', $galleryLinkUri, null);
355

    
356
    return $out;
357
}
358

    
Add picture from clipboard (Maximum size: 40 MB)