Project

General

Profile

Download (53.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Provides external links for sources to taxa information.
5
 *
6
 * @copyright
7
 *   (C) 2007-2012 EDIT
8
 *   European Distributed Institute of Taxonomy
9
 *   http://www.e-taxonomy.eu
10
 *
11
 *   The contents of this module are subject to the Mozilla
12
 *   Public License Version 1.1.
13
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14
 *
15
 * @author
16
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
17
 *   - Wouter Addink <w.addink@eti.uva.nl> (migration from Drupal 5 to Drupal7)
18
 */
19

    
20
/**
21
 * Display help and module information.
22
 *
23
 * @param string $path
24
 *   For which path of the site we're displaying help.
25
 * @param array $arg
26
 *   Array that holds the current path as would be returned from arg() function.
27
 *
28
 * @return string
29
 *   Help text for the path.
30
 */
31
function ext_links_help($path, $arg) {
32
  $output = '';
33
  switch ($path) {
34
    case 'admin/help#ext_links':
35
      // TODO.
36
      $output = '<p>' . t("Link to external sources like ## for taxa.") . '</p>';
37
      break;
38
  }
39
  return $output;
40
} // function ext_links_help
41

    
42
/**
43
 * Generate the HTML text for the ext_link login block.
44
 */
45
function ext_links_admin($form, &$form_state) {
46
  // Default values for the external links.
47
  $ext_links_default = ext_links_get_default();
48

    
49
  $ext_links[0] = array(
50
    'form' => 'gbif',
51
    'form_title' => 'GBIF',
52
    'check_title' => 'GBIF',
53
    'link_title' => 'GBIF link',
54
    'link_description' => 'The link to GBIF without the taxon name.',
55
    'concat_default_value' => ' ',
56
    'text_title' => 'GBIF text',
57
    'text_description' => 'The text of the link that is displayed..',
58
    'category' => 'Category',
59
  );
60
  $ext_links[1] = array(
61
    'form' => 'biocase',
62
    'form_title' => 'BioCASE',
63
    'check_title' => 'Display BioCASE link?',
64
    'link_title' => 'BioCASE link',
65
    'link_description' => 'The link to BioCASE without the taxon name.',
66
    'concat_default_value' => ' ',
67
    'text_title' => 'BioCASE text',
68
    'text_description' => 'The text of the link that is displayed..',
69
    'category' => 'Category',
70
  );
71
  $ext_links[2] = array(
72
    'form' => 'nybg',
73
    'form_title' => 'The New York Botanical Garden',
74
    'check_title' => 'Display NYBG link?',
75
    'link_title' => 'NYBG link',
76
    'link_description' => 'The link to NCBI without the taxon name.',
77
    'concat_default_value' => '+AND+',
78
    'text_title' => 'NYBG text',
79
    'text_description' => 'The text of the link that is displayed..',
80
    'category' => 'Category',
81
  );
82
  $ext_links[3] = array(
83
    'form' => 'tropicos',
84
    'form_title' => 'Tropicos',
85
    'check_title' => 'Display Tropicos link?',
86
    'link_title' => 'Tropicos link',
87
    'link_description' => 'The link to Tropicos without the taxon name.',
88
    'concat_default_value' => '+',
89
    'text_title' => 'Tropicos text',
90
    'text_description' => 'The text of the link that is displayed..',
91
    'category' => 'Category',
92
  );
93
  $ext_links[4] = array(
94
    'form' => 'ncbi',
95
    'form_title' => 'NCBI',
96
    'check_title' => 'Display NCBI link?',
97
    'link_title' => 'NCBI link',
98
    'link_description' => 'The link to NCBI without the taxon name.',
99
    'concat_default_value' => '+AND+',
100
    'text_title' => 'NCBI text',
101
    'text_description' => 'The text of the link that is displayed..',
102
    'category' => 'Category',
103
  );
104
  $ext_links[5] = array(
105
    'form' => 'google',
106
    'form_title' => 'Google Images',
107
    'check_title' => 'Display Google Images link?',
108
    'link_title' => 'Google Images link',
109
    'link_description' => 'The link to Google Images without the taxon name.',
110
    'concat_default_value' => '+',
111
    'text_title' => 'Google Images text',
112
    'text_description' => 'The text of the link that is displayed..',
113
    'category' => 'Category',
114
  );
115
  $ext_links[6] = array(
116
    'form' => 'flickr',
117
    'form_title' => 'flickr',
118
    'check_title' => 'Display flickr link?',
119
    'link_title' => 'flickr link',
120
    'link_description' => 'The link to flickr without the taxon name.',
121
    'concat_default_value' => '+',
122
    'text_title' => 'flickr text',
123
    'text_description' => 'The text of the link that is displayed..',
124
    'category' => 'Category',
125
  );
126
  $ext_links[7] = array(
127
    'form' => 'scholar',
128
    'form_title' => 'Google scholar',
129
    'check_title' => 'Display Google scholar link?',
130
    'link_title' => 'Google scholar link',
131
    'link_description' => 'The link to Google scholar without the taxon name.',
132
    'concat_default_value' => '+',
133
    'text_title' => 'Google scholar text',
134
    'text_description' => 'The text of the link that is displayed..',
135
    'category' => 'Category',
136
  );
137
  $ext_links[8] = array(
138
    'form' => 'bhl',
139
    'form_title' => 'Biodiversity Heritage Library (BHL)',
140
    'check_title' => 'Display BHL link?',
141
    'link_title' => 'BHL link',
142
    'link_description' => 'The link to BHL without the taxon name.',
143
    'concat_default_value' => ' ',
144
    'text_title' => 'BHL text',
145
    'text_description' => 'The text of the link that is displayed..',
146
    'category' => 'Category',
147
  );
148
  $ext_links[9] = array(
149
    'form' => 'arkive',
150
    'form_title' => 'ARKive',
151
    'check_title' => 'Display ARKive link?',
152
    'link_title' => 'ARKive link',
153
    'link_description' => 'The link to ARKive without the taxon name.',
154
    'concat_default_value' => '+',
155
    'text_title' => 'ARKive text',
156
    'text_description' => 'The text of the link that is displayed..',
157
    'category' => 'Category',
158
  );
159
  $ext_links[10] = array(
160
    'form' => 'herbcat',
161
    'form_title' => 'Kew Herbarium Catalogue',
162
    'check_title' => 'Display Kew Herbarium Catalogue link?',
163
    'link_title' => 'Kew Herbarium Catalogue link',
164
    'link_description' => 'The link to Kew Herbarium Catalogue without the taxon name.',
165
    'concat_default_value' => '+',
166
    'text_title' => 'Kew Herbarium Catalogue text',
167
    'text_description' => 'The text of the link that is displayed..',
168
    'category' => 'Category',
169
  );
170
  $ext_links[11] = array(
171
    'form' => 'iucn',
172
    'form_title' => 'IUCN Red List',
173
    'check_title' => 'Display IUCN Red List link?',
174
    'link_title' => 'IUCN Red List link',
175
    'link_description' => 'The link to IUCN Red List without the taxon name.',
176
    'concat_default_value' => ' ',
177
    'text_title' => 'IUCN Red List text',
178
    'text_description' => 'The text of the link that is displayed..',
179
    'category' => 'Category',
180
  );
181
  $ext_links[12] = array(
182
    'form' => 'ipni',
183
    'form_title' => 'IPNI',
184
    'check_title' => 'Display IPNI link?',
185
    'link_title' => 'IPNI link',
186
    'link_description' => 'The link to IPNI without the taxon name.',
187
    'concat_default_value' => '&',
188
    'text_title' => 'IPNI text',
189
    'text_description' => 'The text of the link that is displayed..',
190
    'category' => 'Category',
191
  );
192
  $ext_links[13] = array(
193
    'form' => 'wcsp',
194
    'form_title' => 'World Checklist of Monocots',
195
    'check_title' => 'Display World Checklist of Monocots link?',
196
    'link_title' => 'World Checklist of Monocots link',
197
    'link_description' => 'The link to World Checklist of Monocots without the taxon name.',
198
    'concat_default_value' => ' ',
199
    'text_title' => 'World Checklist of Monocots text',
200
    'text_description' => 'The text of the link that is displayed..',
201
    'category' => 'Category',
202
  );
203
  $ext_links[14] = array(
204
    'form' => 'tpl',
205
    'form_title' => 'The Plant List',
206
    'check_title' => 'Display The Plant List link?',
207
    'link_title' => 'The Plant List link',
208
    'link_description' => 'The link to The Plant List without the taxon name.',
209
    'concat_default_value' => '+',
210
    'text_title' => 'The Plant List text',
211
    'text_description' => 'The text of the link that is displayed..',
212
    'category' => 'Category',
213
  );
214
  $ext_links[15] = array(
215
    'form' => 'eol',
216
    'form_title' => 'Encyclopaedia of Life',
217
    'check_title' => 'Display Encyclopaedia of Life link?',
218
    'link_title' => 'Encyclopaedia of Life link',
219
    'link_description' => 'The link to Encyclopaedia of Life without the taxon name.',
220
    'concat_default_value' => '+',
221
    'text_title' => 'Encyclopaedia of Life text',
222
    'text_description' => 'The text of the link that is displayed..',
223
    'category' => 'Category',
224
  );
225
  $ext_links[16] = array(
226
    'form' => 'jstor',
227
    'form_title' => 'JSTOR Plant Science',
228
    'check_title' => 'Display JSTOR Plant Science link?',
229
    'link_title' => 'JSTOR Plant Science link',
230
    'link_description' => 'The link to JSTOR Plant Science without the taxon name.',
231
    'concat_default_value' => ' ',
232
    'text_title' => 'JSTOR Plant Science text',
233
    'text_description' => 'The text of the link that is displayed..',
234
    'category' => 'Category',
235
  );
236
  $ext_links[17] = array(
237
    'form' => 'epic',
238
    'form_title' => 'ePIC',
239
    'check_title' => 'Display ePIC link?',
240
    'link_title' => 'ePIC link',
241
    'link_description' => 'The link to ePIC without the taxon name.',
242
    'concat_default_value' => '+',
243
    'text_title' => 'ePIC text',
244
    'text_description' => 'The text of the link that is displayed..',
245
    'category' => 'Category',
246
  );
247
  /*
248
  $ext_links[18] = array(
249
    'form' => 'fairchild',
250
    'form_title' => 'Fairchild Guide To Palms',
251
    'check_title' => 'Display Fairchild Guide To Palms link?',
252
    'link_title' => 'Fairchild Guide To Palms link',
253
    'link_description' => 'The link to Fairchild Guide To Palms without the taxon name.',
254
    'concat_default_value' => '+',
255
    'text_title' => 'Fairchild Guide To Palms text',
256
    'text_description' => 'The text of the link that is displayed..',
257
    'category' => 'Category',
258
  );
259
  */
260
  $ext_links[19] = array(
261
    'form' => 'ggbm',
262
    'form_title' => 'Global Genome Biodiversity Network',
263
    'check_title' => 'Display Global Genome Biodiversity Network Link?',
264
    'link_title' => 'Global Genome Biodiversity Network link',
265
    'link_description' => 'The link to GGBN search without the taxon name.',
266
    'concat_default_value' => '+',
267
    'text_title' => 'Global Genome Biodiversity Network text',
268
    'text_description' => 'The text of the link that is displayed..',
269
    'category' => 'Category',
270
  );
271

    
272

    
273
  for ($i = 0; $i < sizeof($ext_links); $i++) {
274
    $form[$ext_links[$i]['form']] = array(
275
      '#type' => 'fieldset',
276
      '#title' => t('@title', array('@title' => $ext_links[$i]['form_title'])),
277
      '#collapsible' => TRUE,
278
      '#collapsed' => TRUE,
279
    );
280
    $form[$ext_links[$i]['form']]['ext_links_' . $ext_links[$i]['form'] . '_check'] = array(
281
      '#type' => 'checkbox',
282
      '#title' => t('@title', array('@title' => $ext_links[$i]['check_title'])),
283
      '#default_value' => variable_get('ext_links_' . $ext_links[$i]['form'] . '_check', 1),
284
    );
285
    $form[$ext_links[$i]['form']]['ext_links_' . $ext_links[$i]['form'] . '_link'] = array(
286
      '#type' => 'textfield',
287
      '#title' => t('@title :', array('@title' => $ext_links[$i]['link_title'])),
288
      '#default_value' => variable_get('ext_links_' . $ext_links[$i]['form'] . '_link', $ext_links_default[$ext_links[$i]['form']]['link_default_value']),
289
      '#size' => 70,
290
      '#maxlength' => 255,
291
      '#description' => t('@description', array('@description' => $ext_links[$i]['link_description'])),
292
    );
293
    $form[$ext_links[$i]['form']]['ext_links_' . $ext_links[$i]['form'] . '_concat'] = array(
294
      '#type' => 'textfield',
295
      '#title' => t('Concatenate string') . ':',
296
      '#default_value' => variable_get('ext_links_' . $ext_links[$i]['form'] . '_concat', $ext_links[$i]['concat_default_value']),
297
      '#size' => 70,
298
      '#maxlength' => 255,
299
      '#description' => t('Concatenate string between genus and species'),
300
    );
301
    $form[$ext_links[$i]['form']]['ext_links_' . $ext_links[$i]['form'] . '_text'] = array(
302
      '#type' => 'textfield',
303
      '#title' => t('@title :', array('@title' => $ext_links[$i]['text_title'])),
304
      '#default_value' => variable_get('ext_links_' . $ext_links[$i]['form'] . '_text', $ext_links_default[$ext_links[$i]['form']]['text_default_value']),
305
      '#size' => 70,
306
      '#maxlength' => 255,
307
      '#description' => t('@description', array('@description' => $ext_links[$i]['text_description'])),
308
    );
309
    $form[$ext_links[$i]['form']]['ext_links_' . $ext_links[$i]['form'] . '_category'] = array(
310
      '#type' => 'textfield',
311
      '#title' => t('@title :', array('@title' => $ext_links[$i]['category'])),
312
      '#default_value' => variable_get('ext_links_' . $ext_links[$i]['form'] . '_category', $ext_links_default[$ext_links[$i]['form']]['category_default_value']),
313
      '#size' => 70,
314
      '#maxlength' => 255,
315
      '#description' => t('@description', array('@description' => $ext_links[$i]['category'])),
316
    );
317
  }
318
  $form['ext_links_options'] = array(
319
    '#type' => 'checkbox',
320
    '#title' => t('Enable sorted list with headings'),
321
    '#default_value' => variable_get('ext_links_options', 0),
322
    '#prefix' => "<div class = \"sorted_list_option\"",
323
    '#suffix' => "</div>",
324
  );
325
  // @WA: D7 form api does not support reset buttons,
326
  // so to mimic the D5 reset button we add one like this.
327
  $form['actions']['reset'] = array(
328
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
329
    '#weight' => 1000,
330
  );
331

    
332
  return system_settings_form($form);
333
} // function ext_links_admin()
334

    
335

    
336
/**
337
 * Implements hook_menu().
338
 */
339
function ext_links_menu() {
340
  $items = array();
341

    
342
  $items['admin/config/cdm_dataportal/extlinks'] = array(
343
    'title' => 'External links',
344
    'description' => 'Description of your External links.',
345
    'page callback' => 'drupal_get_form',
346
    'page arguments' => array('ext_links_admin'),
347
    'access arguments' => array('access administration pages'),
348
    'type' => MENU_NORMAL_ITEM,
349
    'weight' =>30,
350
  );
351

    
352
  return $items;
353
} /* function ext_links_menu() */
354

    
355
/**
356
 * Returns the genus and the first epithet from the object taxon.
357
 */
358
function getSpeciesName($taxon) {
359
  $speciesName = array();
360
  $i = 0;
361
  while (isset($taxon->name->taggedName[$i]) && !isset($speciesName['species'])) {
362
    if ($taxon->name->taggedName[$i]->type == "name") {
363
      if (!isset($speciesName['genus'])) {
364
        $speciesName['genus'] = $taxon->name->taggedName[$i]->text;
365
      }
366
      else {
367
        $speciesName['species'] = $taxon->name->taggedName[$i]->text;
368
      }
369
    }
370
    $i++;
371
  }
372
  return $speciesName;
373
}
374

    
375
/**
376
 * Implements hook_block_info().
377
 */
378
function ext_links_block_info() {
379
  if (TRUE) {
380
    $block[0]["info"] = t("External Taxon Links");
381
    return $block;
382
  }
383
}
384

    
385
/**
386
 * Implements hook_block_view().
387
 */
388
function ext_links_block_view($delta) {
389
  // TODO Rename block deltas (e.g. '0') to readable strings.
390
  switch ($delta) {
391
    case '0':
392
      $block['subject'] = 'External links';
393

    
394
      $uuid = get_current_taxon_uuid();
395
      if ($uuid) {
396
        $taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $uuid);
397

    
398
        // $taxon->titleCache;
399
        // var_export()
400
        if (!empty($taxon)) {
401
          drupal_add_js(drupal_get_path('module', 'ext_links') . '/ext_links.js');
402
          $speciesName = getSpeciesName($taxon);
403

    
404
          $genus = $taxon->name->taggedName[0]->text;
405
          $species = null;
406
          if(isset($taxon->name->taggedName[1])){
407
            $species = $taxon->name->taggedName[1]->text;
408
          }
409
          $block_content = '';
410
          $listOption = variable_get("ext_links_options", 0);
411
          if (isset($listOption)) {
412
            $block['content'] = theme('ext_links_list_grouped', array('speciesName' => $speciesName, 'genus' => $genus, 'species' => $species));
413
          }
414
          else {
415
            $block['content'] = theme('ext_links_list_plain', array('speciesName' => $speciesName, 'genus' => $genus, 'species' => $species ));
416
          }
417

    
418
          // if(variable_get('ext_links_gbif_check', TRUE)) {
419
          // $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_gbif_link', $ext_links_default[gbif][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_gbif_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]).'</a><br />';
420
          /*
421
           $block_content .=
422
           /* TODO
423
           Please manually fix the parameters on the l() or url() function on the next line.
424
           Typically, this was not changed because of a function call inside an array call like
425
           array('title' => t('View user profile.')).
426
           l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
427
           'JavaScript:popupExternalLinks('.variable_get('ext_links_gbif_link', $ext_links_default[gbif][link_default_value]).$speciesName[genus].variable_get('ext_links_gbif_concat', ' ').$speciesName[species],
428
           array(), null, null, true);
429
           */
430
          /*}
431
           if(variable_get('ext_links_biocase_check', 1)) {
432
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_biocase_link', $ext_links_default[biocase][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_biocase_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_biocase_text', $ext_links_default[biocase][text_default_value]).'</a><br />';
433
           }
434
           if(variable_get('ext_links_nybg_check', 1)) {
435
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_nybg_link', $ext_links_default[nybg][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_nybg_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_nybg_text', $ext_links_default[nybg][text_default_value]).'</a><br />';
436
           }
437
           if(variable_get('ext_links_tropicos_check', 1)) {
438
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_tropicos_link', $ext_links_default[tropicos][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_tropicos_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_tropicos_text', $ext_links_default[tropicos][text_default_value]).'</a><br />';
439
           }
440
           if(variable_get('ext_links_ncbi_check', 1)) {
441
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_ncbi_link', $ext_links_default[ncbi][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_ncbi_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_ncbi_text', $ext_links_default[ncbi][text_default_value]).'</a><br />';
442
           }
443
           if(variable_get('ext_links_google_check', 1)) {
444
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_google_link', $ext_links_default[google][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_google_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_google_text', $ext_links_default[google][text_default_value]).'</a><br />';
445
           }
446
           if(variable_get('ext_links_flickr_check', 1)) {
447
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_flickr_link', $ext_links_default[flickr][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_flickr_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_flickr_text', $ext_links_default[flickr][text_default_value]).'</a><br />';
448
           }
449
           if(variable_get('ext_links_scholar_check', 1)) {
450
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_scholar_link', $ext_links_default[scholar][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_scholar_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_scholar_text', $ext_links_default[scholar][text_default_value]).'</a><br />';
451
           }
452
           if(variable_get('ext_links_bhl_check', 1)) {
453
           $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_bhl_link', $ext_links_default[bhl][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_bhl_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_bhl_text', $ext_links_default[bhl][text_default_value]).'</a><br />';
454
           }
455

    
456
           $block['content'] = $block_content;
457
           $block['content'] = theme('ext_links_list_plain');
458

    
459
           }
460

    
461
           }*/
462
          // if taxon
463
        }
464
      }
465
      // If path.
466
      return $block;
467
  } /* switch */
468

    
469
}
470

    
471
/**
472
 * @todo Please document this function.
473
 * @see http://drupal.org/node/1354
474
 */
475
function theme_ext_links_list_grouped($variables) {
476
  // comment @WA: perhaps this function could be merged with ext_list_plain
477
  // into one function?
478
  $speciesName = $variables['speciesName'];
479
  if(!isset($speciesName['genus'])) {
480
    $speciesName['genus'] = '';
481
  }
482
  if(!isset($speciesName['species'])) {
483
    $speciesName['species'] = '';
484
  }
485
  $genus = $variables['genus'];
486
  $species = $variables['species'];
487
  $block_content = '';
488
  $categories = NULL;
489
  $ext_links_default = ext_links_get_default();
490

    
491

    
492
  /*
493
  foreach ($ext_links_default as $ext_link) {
494

    
495
   //$block_content .= $ext_link['ext_links_bhl_category'];
496
   $category[] = variable_get('ext_links_bhl_category', $ext_links_default[][text_default_value]);
497
   $block_content .= variable_get('ext_links_bhl_category', $ext_links_default[][text_default_value]);
498
   }
499
   */
500

    
501
  // Images section.
502
  if (variable_get('ext_links_google_check', 1)) {
503
    $categoryTitles[] = variable_get('ext_links_google_category', $ext_links_default['google']['category_default_value']);
504
    $categories['google']['title'] = variable_get('ext_links_google_category', $ext_links_default['google']['category_default_value']);
505
    $categories['google']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_google_link', $ext_links_default['google']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_google_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_google_text', $ext_links_default['google']['text_default_value']) . '</a><br />';
506

    
507
  }
508
  if (variable_get('ext_links_flickr_check', 1)) {
509
    $categoryTitles[] = variable_get('ext_links_flickr_category', $ext_links_default['flickr']['category_default_value']);
510
    $categories['flickr']['title'] = variable_get('ext_links_flickr_category', $ext_links_default['flickr']['category_default_value']);
511
    $categories['flickr']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_flickr_link', $ext_links_default['flickr']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_flickr_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_flickr_text', $ext_links_default['flickr']['text_default_value']) . '</a><br />';
512
  }
513

    
514
  // Specimen/occurences section.
515
  if (variable_get('ext_links_gbif_check', TRUE)) {
516
    $categoryTitles[] = variable_get('ext_links_gbif_category', $ext_links_default['gbif']['category_default_value']);
517
    $categories['gbif']['title'] = variable_get('ext_links_gbif_category', $ext_links_default['gbif']['category_default_value']);
518
    $categories['gbif']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_gbif_link', $ext_links_default['gbif']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_gbif_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_gbif_text', $ext_links_default['gbif']['text_default_value']) . '</a><br />';
519
  }
520
  if (variable_get('ext_links_biocase_check', 1)) {
521
    $categoryTitles[] = variable_get('ext_links_biocase_category', $ext_links_default['biocase']['category_default_value']);
522
    $categories['biocase']['title'] = variable_get('ext_links_biocase_category', $ext_links_default['biocase']['category_default_value']);
523
    $categories['biocase']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_biocase_link', $ext_links_default['biocase']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_biocase_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_biocase_text', $ext_links_default['biocase']['text_default_value']) . '</a><br />';
524
  }
525
  if (variable_get('ext_links_nybg_check', 1)) {
526
    $query = '';
527
    $genusQuery = '';
528
    $speciesQuery = '';
529
    if ($speciesName['genus'] != NULL) {
530
      $query .= 'DetFiledAsGenusLocal+%3D+\%27'. $speciesName['genus']. '\%27';
531
    }
532
    if ($speciesName['species'] != NULL) {
533
      $query .= variable_get('ext_links_nybg_concat', '+AND+'). 'DetFiledAsSpeciesLocal+%3D+\%27'. $speciesName['species'] . '\%27';
534
    }
535
    $categoryTitles[] = variable_get('ext_links_nybg_category', $ext_links_default['nybg']['category_default_value']);
536
    $categories['nybg']['title'] = variable_get('ext_links_nybg_category', $ext_links_default['nybg']['category_default_value']);
537
    $categories['nybg']['content'] = '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_nybg_link', $ext_links_default['nybg']['link_default_value']).$query.'\')">'.variable_get('ext_links_nybg_text', $ext_links_default['nybg']['text_default_value']).'</a><br />';
538
  }
539
  if (variable_get('ext_links_tropicos_check', 1)) {
540
    $categoryTitles[] = variable_get('ext_links_tropicos_category', $ext_links_default['tropicos']['category_default_value']);
541
    $categories['tropicos']['title'] = variable_get('ext_links_tropicos_category', $ext_links_default['tropicos']['category_default_value']);
542
    $categories['tropicos']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_tropicos_link', $ext_links_default['tropicos']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_tropicos_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_tropicos_text', $ext_links_default['tropicos']['text_default_value']) . '</a><br />';
543
  }
544

    
545
  // Literature.
546
  if (variable_get('ext_links_scholar_check', 1)) {
547
    $categoryTitles[] = variable_get('ext_links_scholar_category', $ext_links_default['scholar']['category_default_value']);
548
    $categories['scholar']['title'] = variable_get('ext_links_scholar_category', $ext_links_default['scholar']['category_default_value']);
549
    $categories['scholar']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_scholar_link', $ext_links_default['scholar']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_scholar_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_scholar_text', $ext_links_default['scholar']['text_default_value']) . '</a><br />';
550
  }
551
  if (variable_get('ext_links_bhl_check', 1)) {
552
    $categoryTitles[] = variable_get('ext_links_bhl_category', $ext_links_default['bhl']['category_default_value']);
553
    $categories['bhl']['title'] = variable_get('ext_links_bhl_category', $ext_links_default['bhl']['category_default_value']);
554
    $categories['bhl']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_bhl_link', $ext_links_default['bhl']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_bhl_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_bhl_text', $ext_links_default['bhl']['text_default_value']) . '</a><br />';
555
  }
556

    
557
  // Molecular resources.
558
  if (variable_get('ext_links_ncbi_check', 1)) {
559
    $categoryTitles[] = variable_get('ext_links_ncbi_category', $ext_links_default['ncbi']['category_default_value']);
560
    $categories['ncbi']['title'] = variable_get('ext_links_ncbi_category', $ext_links_default['ncbi']['category_default_value']);
561
    $categories['ncbi']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_ncbi_link', $ext_links_default['ncbi']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_ncbi_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_ncbi_text', $ext_links_default['ncbi']['text_default_value']) . '</a><br />';
562
  }
563
  if (variable_get('ext_links_arkive_check', 1)) {
564
    $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
565
    $categoryTitles[] = variable_get('ext_links_arkive_category', $ext_links_default['arkive']['category_default_value']);
566
    $categories['arkive']['title'] = variable_get('ext_links_arkive_category', $ext_links_default['arkive']['category_default_value']);
567
    $categories['arkive']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_arkive_link', $ext_links_default['arkive']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_arkive_concat', '+') . str_replace('"', '%22', $speciesName['species']) . $postURL . '\')">' . variable_get('ext_links_arkive_text', $ext_links_default['arkive']['text_default_value']) . '</a><br />';
568
  }
569
  if (variable_get('ext_links_herbcat_check', 1)) {
570
    $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
571
    $categoryTitles[] = variable_get('ext_links_herbcat_category', $ext_links_default['herbcat']['category_default_value']);
572
    $categories['herbcat']['title'] = variable_get('ext_links_herbcat_category', $ext_links_default['herbcat']['category_default_value']);
573
    $categories['herbcat']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_herbcat_link', $ext_links_default['herbcat']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_herbcat_concat', '+') . str_replace('"', '%22', $speciesName['species']) . $postURL . '\')">' . variable_get('ext_links_herbcat_text', $ext_links_default['herbcat']['text_default_value']) . '</a><br />';
574
  }
575
  if (variable_get('ext_links_iucn_check', 1)) {
576
    $categoryTitles[] = variable_get('ext_links_iucn_category', $ext_links_default['iucn']['category_default_value']);
577
    $categories['iucn']['title'] = variable_get('ext_links_iucn_category', $ext_links_default['iucn']['category_default_value']);
578
    $categories['iucn']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_iucn_link', $ext_links_default['iucn']['link_default_value']) . '\')">' . variable_get('ext_links_iucn_text', $ext_links_default['iucn']['text_default_value']) . '</a><br />';
579
  }
580
  if (variable_get('ext_links_ipni_check', 1)) {
581
    $genusQuery = 'find_genus=' . $speciesName['genus'];
582
    $speciesQuery = 'find_species=' . $speciesName['species'];
583
    $categoryTitles[] = variable_get('ext_links_ipni_category', $ext_links_default['ipni']['category_default_value']);
584
    $categories['ipni']['title'] = variable_get('ext_links_ipni_category', $ext_links_default['ipni']['category_default_value']);
585
    $categories['ipni']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_ipni_link', $ext_links_default['ipni']['link_default_value']) . $genusQuery . variable_get('ext_links_ipni_concat', '&') . $speciesQuery . '\')">' . variable_get('ext_links_ipni_text', $ext_links_default['ipni']['text_default_value']) . '</a><br />';
586
  }
587
  if (variable_get('ext_links_wcsp_check', 1)) {
588
    $categoryTitles[] = variable_get('ext_links_wcsp_category', $ext_links_default['wcsp']['category_default_value']);
589
    $categories['wcsp']['title'] = variable_get('ext_links_wcsp_category', $ext_links_default['wcsp']['category_default_value']);
590
    $categories['wcsp']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_wcsp_link', $ext_links_default['wcsp']['link_default_value']) . '\')">' . variable_get('ext_links_wcsp_text', $ext_links_default['wcsp']['text_default_value']) . '</a><br />';
591
  }
592
  if (variable_get('ext_links_tpl_check', 1)) {
593
    $categoryTitles[] = variable_get('ext_links_tpl_category', $ext_links_default['tpl']['category_default_value']);
594
    $categories['tpl']['title'] = variable_get('ext_links_tpl_category', $ext_links_default['tpl']['category_default_value']);
595
    $categories['tpl']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_tpl_link', $ext_links_default['tpl']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_tpl_concat', '+') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_tpl_text', $ext_links_default['tpl']['text_default_value']) . '</a><br />';
596
  }
597
  if (variable_get('ext_links_eol_check', 1)) {
598
    $categoryTitles[] = variable_get('ext_links_eol_category', $ext_links_default['eol']['category_default_value']);
599
    $categories['eol']['title'] = variable_get('ext_links_eol_category', $ext_links_default['eol']['category_default_value']);
600
    $categories['eol']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_eol_link', $ext_links_default['eol']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_eol_concat', '+') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_eol_text', $ext_links_default['eol']['text_default_value']) . '</a><br />';
601
  }
602
  if (variable_get('ext_links_jstor_check', 1)) {
603
    $categoryTitles[] = variable_get('ext_links_jstor_category', $ext_links_default['jstor']['category_default_value']);
604
    $categories['jstor']['title'] = variable_get('ext_links_jstor_category', $ext_links_default['jstor']['category_default_value']);
605
    $categories['jstor']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_jstor_link', $ext_links_default['jstor']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_jstor_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_jstor_text', $ext_links_default['jstor']['text_default_value']) . '</a><br />';
606
  }
607
  if (variable_get('ext_links_epic_check', 1)) {
608
    $postURL = '&searchAll=true&categories=names&categories=bibl&categories=colln&categories=taxon&categories=flora&Submit.x=0&Submit.y=0';
609
    $categoryTitles[] = variable_get('ext_links_epic_category', $ext_links_default['epic']['category_default_value']);
610
    $categories['epic']['title'] = variable_get('ext_links_epic_category', $ext_links_default['epic']['category_default_value']);
611
    $categories['epic']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_epic_link', $ext_links_default['epic']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_epic_concat', '+') . str_replace('"', '%22', $speciesName['species']) . $postURL . '\')">' . variable_get('ext_links_epic_text', $ext_links_default['epic']['text_default_value']) . '</a><br />';
612
  }
613
//  if (variable_get('ext_links_fairchild_check', 1)) {
614
//    $categoryTitles[] = variable_get('ext_links_fairchild_category', $ext_links_default['fairchild']['category_default_value']);
615
//    $categories['fairchild']['title'] = variable_get('ext_links_fairchild_category', $ext_links_default['fairchild']['category_default_value']);
616
//    $categories['fairchild']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_fairchild_link', $ext_links_default['fairchild']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_fairchild_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_fairchild_text', $ext_links_default['fairchild']['text_default_value']) . '</a><br />';
617
//  }
618
  if (variable_get('ext_links_ggbn_check', 1)) {
619
    $categoryTitles[] = variable_get('ext_links_ggbn_category', $ext_links_default['ggbn']['category_default_value']);
620
    $categories['ggbn']['title'] = variable_get('ext_links_ggnb_category', $ext_links_default['ggbn']['category_default_value']);
621
    $categories['ggbn']['content'] = '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_ggbn_link', $ext_links_default['ggbn']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_ggbn_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_ggbn_text', $ext_links_default['ggbn']['text_default_value']) . '</a><br />';
622
  }
623

    
624
  $categoryTitles = array_unique($categoryTitles);
625
  foreach ($categoryTitles as $categoryTitle) {
626
    // $block_content .= "specName" . $speciesName;
627
    $block_content .= "<div class=\"category\"><h5>" . $categoryTitle . "</h5>";
628
    foreach ($categories as $category) {
629
      if ($category['title'] == $categoryTitle) {
630
        $block_content .= $category['content'];
631
      }
632
    }
633
    $block_content .= "</div>";
634
  }
635

    
636

    
637
  return $block_content;
638
}
639

    
640
/**
641
 * @todo Please document this function.
642
 * @see http://drupal.org/node/1354
643
 */
644
function theme_ext_links_list_plain($variables) {
645
  $speciesName = $variables['speciesName'];
646
  if (!isset($speciesName['genus'])) {
647
    $speciesName['genus'] = '';
648
  }
649
  if (!isset($speciesName['species'])) {
650
    $speciesName['species'] = '';
651
  }
652
  $genus = $variables['genus'];
653
  $species = $variables['species'];
654
  $ext_links_default = ext_links_get_default();
655
  $block_content = '';
656
  if (variable_get('ext_links_gbif_check', TRUE)) {
657
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_gbif_link', $ext_links_default['gbif']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_gbif_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_gbif_text', $ext_links_default['gbif']['text_default_value']) . '</a><br />';
658
    /*
659
     $block_content .= /* TODO
660
     Please manually fix the parameters on the l() or url() function on the next line.
661
     Typically, this was not changed because of a function call inside an array call like
662
     array('title' => t('View user profile.')).*/
663
    /*
664
     l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
665
     'JavaScript:popupExternalLinks('.variable_get('ext_links_gbif_link', $ext_links_default[gbif][link_default_value]).$speciesName[genus].variable_get('ext_links_gbif_concat', ' ').$speciesName[species],
666
     array(), null, null, true);
667
     */
668
  }
669
  if (variable_get('ext_links_biocase_check', 1)) {
670
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_biocase_link', $ext_links_default['biocase']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_biocase_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_biocase_text', $ext_links_default['biocase']['text_default_value']) . '</a><br />';
671
  }
672
  if (variable_get('ext_links_nybg_check', 1)) {
673
    // $block_content .= '<a href="JavaScript:popupExternalLinks(\''.variable_get('ext_links_nybg_link', $ext_links_default[nybg][link_default_value]).str_replace('"','%22',$speciesName[genus]).variable_get('ext_links_nybg_concat', ' ').str_replace('"','%22',$speciesName[species]).'\')">'.variable_get('ext_links_nybg_text', $ext_links_default[nybg][text_default_value]).'</a><br />';
674
    $genusQuery = '';
675
    $speciesQuery = '';
676
    if ($speciesName['genus'] != NULL) {
677
      $genusQuery = 'DetFiledAsGenusLocal+%3D+\%27' . $speciesName['genus'] . '\%27';
678
    }
679
    if ($speciesName['species'] != NULL) {
680
      $speciesQuery = 'DetFiledAsSpeciesLocal+%3D+\%27' . $speciesName['species'] . '\%27';
681
    }
682
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_nybg_link', $ext_links_default['nybg']['link_default_value']) . $genusQuery . variable_get('ext_links_nybg_concat', '+AND+') . $speciesQuery . '\')">' . variable_get('ext_links_nybg_text', $ext_links_default['nybg']['text_default_value']) . '</a><br />';
683
  }
684
  if (variable_get('ext_links_tropicos_check', 1)) {
685
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_tropicos_link', $ext_links_default['tropicos']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_tropicos_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_tropicos_text', $ext_links_default['tropicos']['text_default_value']) . '</a><br />';
686
  }
687
  if (variable_get('ext_links_ncbi_check', 1)) {
688
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_ncbi_link', $ext_links_default['ncbi']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_ncbi_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_ncbi_text', $ext_links_default['ncbi']['text_default_value']) . '</a><br />';
689
  }
690
  if (variable_get('ext_links_google_check', 1)) {
691
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_google_link', $ext_links_default['google']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_google_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_google_text', $ext_links_default['google']['text_default_value']) . '</a><br />';
692
  }
693
  if (variable_get('ext_links_flickr_check', 1)) {
694
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_flickr_link', $ext_links_default['flickr']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_flickr_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_flickr_text', $ext_links_default['flickr']['text_default_value']) . '</a><br />';
695
  }
696
  if (variable_get('ext_links_scholar_check', 1)) {
697
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_scholar_link', $ext_links_default['scholar']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_scholar_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_scholar_text', $ext_links_default['scholar']['text_default_value']) . '</a><br />';
698
  }
699
  if (variable_get('ext_links_bhl_check', 1)) {
700
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_bhl_link', $ext_links_default['bhl']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_bhl_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_bhl_text', $ext_links_default['bhl']['text_default_value']) . '</a><br />';
701
  }
702
//  if (variable_get('ext_links_fairchild_check', 1)) {
703
//    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_fairchild_link', $ext_links_default['fairchild']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_fairchild_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_fairchild_text', $ext_links_default['fairchild']['text_default_value']) . '</a><br />';
704
//  }
705
  if (variable_get('ext_links_ggbn_check', 1)) {
706
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_ggbn_link', $ext_links_default['ggbn']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_ggbn_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_ggbn_text', $ext_links_default['ggbn']['text_default_value']) . '</a><br />';
707
  }
708
  if (variable_get('ext_links_arkive_check', 1)) {
709
    $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
710
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_arkive_link', $ext_links_default['arkive']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_arkive_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . $postURL . '\')">' . variable_get('ext_links_arkive_text', $ext_links_default['arkive']['text_default_value']) . '</a><br />';
711
  }
712
  if (variable_get('ext_links_herbcat_check', 1)) {
713
    $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
714
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_herbcat_link', $ext_links_default['herbcat']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_herbcat_concat', '+') . str_replace('"', '%22', $speciesName['species']) . $postURL . '\')">' . variable_get('ext_links_herbcat_text', $ext_links_default['herbcat']['text_default_value']) . '</a><br />';
715
  }
716
  if (variable_get('ext_links_iucn_check', 1)) {
717
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_iucn_link', $ext_links_default['iucn']['link_default_value']) . '\')">' . variable_get('ext_links_iucn_text', $ext_links_default['iucn']['text_default_value']) . '</a><br />';
718

    
719
  }
720
  if (variable_get('ext_links_ipni_check', 1)) {
721
    $genusQuery = 'find_genus=' . $speciesName['genus'];
722
    $speciesQuery = 'find_species=' . $speciesName['species'];
723
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_ipni_link', $ext_links_default['ipni']['link_default_value']) . $genusQuery . variable_get('ext_links_ipni_concat', '&') . $speciesQuery . '\')">' . variable_get('ext_links_ipni_text', $ext_links_default['ipni']['text_default_value']) . '</a><br />';
724
  }
725
  if (variable_get('ext_links_wcsp_check', 1)) {
726
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_wcsp_link', $ext_links_default['wcsp']['link_default_value']) . '\')">' . variable_get('ext_links_wcsp_text', $ext_links_default['wcsp']['text_default_value']) . '</a><br />';
727

    
728
  }
729
  if (variable_get('ext_links_tpl_check', 1)) {
730
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_tpl_link', $ext_links_default['tpl']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_tpl_concat', '+') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_tpl_text', $ext_links_default['tpl']['text_default_value']) . '</a><br />';
731
  }
732
  if (variable_get('ext_links_eol_check', 1)) {
733
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_eol_link', $ext_links_default['eol']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_eol_concat', '+') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_eol_text', $ext_links_default['eol']['text_default_value']) . '</a><br />';
734
  }
735
  if (variable_get('ext_links_jstor_check', 1)) {
736
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_jstor_link', $ext_links_default['jstor']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_jstor_concat', ' ') . str_replace('"', '%22', $speciesName['species']) . '\')">' . variable_get('ext_links_jstor_text', $ext_links_default['jstor']['text_default_value']) . '</a><br />';
737
  }
738
  if (variable_get('ext_links_epic_check', 1)) {
739
    $postURL = '&searchAll=true&categories=names&categories=bibl&categories=colln&categories=taxon&categories=flora&Submit.x=0&Submit.y=0';
740
    $block_content .= '<a href="JavaScript:popupExternalLinks(\'' . variable_get('ext_links_epic_link', $ext_links_default['epic']['link_default_value']) . str_replace('"', '%22', $speciesName['genus']) . variable_get('ext_links_epic_concat', '+') . str_replace('"', '%22', $speciesName['species']) . $postURL . '\')">' . variable_get('ext_links_epic_text', $ext_links_default['epic']['text_default_value']) . '</a><br />';
741
  }
742

    
743
  return $block_content;
744
}
745

    
746
// Include the admin form if we really want it to use.
747
/*
748
if (arg(0) === 'admin' AND arg(1) === 'user' AND arg(2) === 'ext_link') {
749
  module_load_include('inc', 'ext_links', 'xt_link_admin');
750
}
751
*/
752

    
753
/**
754
 * @todo Please document this function.
755
 * @see http://drupal.org/node/1354
756
 */
757
function ext_links_theme() {
758
  return array(
759
    'ext_links_list_grouped' => array('variables' => array(
760
      'speciesName' => NULL,
761
      'genus' => NULL,
762
      'species' => NULL,
763
      )),
764
    'ext_links_list_plain' => array('variables' => array(
765
      'speciesName' => NULL,
766
      'genus' => NULL,
767
      'species' => NULL,
768
      )),
769
  );
770
}
771

    
772
/**
773
 * Get the default external links.
774
 *
775
 * @return array
776
 *   Returns an array with default external links values.
777
 */
778
function ext_links_get_default() {
779
  $ext_links_default["gbif"] = array(
780
    'link_default_value' => 'http://www.gbif.org/species/search?q=',
781
    'text_default_value' => 'Search GBIF...',
782
    'category_default_value' => 'Specimens/Occurrences',
783
  );
784
  $ext_links_default["biocase"] = array(
785
    'link_default_value' => 'http://search.biocase.org/edit/search/units/simpleSearch/query1?unitName=',
786
    'text_default_value' => 'Search BioCASE...',
787
    'category_default_value' => 'Specimens/Occurrences',
788
  );
789
  $ext_links_default["nybg"] = array(
790
    'link_default_value' => 'http://sweetgum.nybg.org/science/vh/specimen_list.php?SummaryData=',
791
    'text_default_value' => 'Search NYBG...',
792
    'category_default_value' => 'Specimens/Occurrences',
793
  );
794
  $ext_links_default["tropicos"] = array(
795
    'link_default_value' => 'http://www.tropicos.org/NameSearch.aspx?name=',
796
    'text_default_value' => 'Search Tropicos...',
797
    'category_default_value' => 'Specimens/Occurrences',
798
  );
799
  $ext_links_default["ncbi"] = array(
800
    'link_default_value' => 'http://www.ncbi.nlm.nih.gov/gquery/gquery.fcgi?term=',
801
    'text_default_value' => 'Search NCBI...',
802
    'category_default_value' => 'Molecular Resources',
803
  );
804
  $ext_links_default["google"] = array(
805
    'link_default_value' => 'http://images.google.com/images?q=',
806
    'text_default_value' => 'Search Google Images...',
807
    'category_default_value' => 'Images',
808
  );
809
  $ext_links_default["flickr"] = array(
810
    'link_default_value' => 'http://www.flickr.com/search/?w=all&q=',
811
    'text_default_value' => 'Search flickr...',
812
    'category_default_value' => 'Images',
813
  );
814
  $ext_links_default["scholar"] = array(
815
    'link_default_value' => 'http://scholar.google.de/scholar?hl=de&btnG=Suche&lr=&as_ylo=&as_vis=0&q=',
816
    'text_default_value' => 'Search Google scholar...',
817
    'category_default_value' => 'Literature',
818
  );
819
  $ext_links_default["bhl"] = array(
820
    'link_default_value' => 'http://www.biodiversitylibrary.org/Search.aspx?searchCat=&searchTerm=',
821
    'text_default_value' => 'Search BHL...',
822
    'category_default_value' => 'Literature',
823
  );
824
  $ext_links_default["arkive"] = array(
825
    'link_default_value' => 'http://www.arkive.org/search.html?q=',
826
    'text_default_value' => 'Search ARKive...',
827
    'category_default_value' => 'Images',
828
  );
829
  $ext_links_default["herbcat"] = array(
830
    'link_default_value' => 'http://apps.kew.org/herbcat/getHomePageResults.do?homePageSearchText=',
831
    'text_default_value' => 'Search Kew Herbarium Catalogue...',
832
    'category_default_value' => 'Specimens/Occurrences',
833
  );
834
  $ext_links_default["iucn"] = array(
835
    'link_default_value' => 'http://www.iucnredlist.org/',
836
    'text_default_value' => 'Go to IUCN Red List...',
837
    'category_default_value' => 'Conservation',
838
  );
839
  $ext_links_default["ipni"] = array(
840
    'link_default_value' => 'http://www.ipni.org/ipni/advPlantNameSearch.do?',
841
    'text_default_value' => 'Search IPNI...',
842
    'category_default_value' => 'Classification',
843
  );
844
  $ext_links_default["wcsp"] = array(
845
    'link_default_value' => 'http://wcsp.science.kew.org/qsearch.do?plantName=',
846
    'text_default_value' => 'Search World Checklist Monocots...',
847
    'category_default_value' => 'Classification',
848
  );
849
  $ext_links_default["tpl"] = array(
850
    'link_default_value' => 'http://www.theplantlist.org/tpl/search?q=',
851
    'text_default_value' => 'Search The Plant List...',
852
    'category_default_value' => 'Classification',
853
  );
854
  $ext_links_default["eol"] = array(
855
    'link_default_value' => 'http://eol.org/search/?q=',
856
    'text_default_value' => 'Search Encyclopaedia of Life...',
857
    'category_default_value' => 'General',
858
  );
859
  $ext_links_default["jstor"] = array(
860
    'link_default_value' => 'https://plants.jstor.org/search?filter=name&so=ps_group_by_genus_species+asc&Query=',
861
    'text_default_value' => 'Search JSTOR Plant Science...',
862
    'category_default_value' => 'General',
863
  );
864
  $ext_links_default["epic"] = array(
865
    'link_default_value' => 'http://epic.kew.org/searchepic/summaryquery.do?scientificName=',
866
    'text_default_value' => 'Search ePIC...',
867
    'category_default_value' => 'General',
868
  );
869
  /*
870
   * hidden since Fairchild Guide To Palms seems to be down
871
  $ext_links_default["fairchild"] = array(
872
    'link_default_value' => 'http://palmguide.org/palmsearch.php?query=',
873
    'text_default_value' => 'Search Fairchild Guide To Palms...',
874
    'category_default_value' => 'Specimens/Occurrences',
875
  );
876
  */
877
  $ext_links_default["ggbn"] = array(
878
    'link_default_value' => 'http://www.ggbn.org/ggbn_portal/search/result?fullScientificName=',
879
    'text_default_value' => 'Search GGBN...',
880
    'category_default_value' => 'Molecular Resources',
881
  );
882
  //
883
  return $ext_links_default;
884
}
(3-3/3)