Project

General

Profile

Download (51.3 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
  $ext_links[18] = array(
248
    'form' => 'fairchild',
249
    'form_title' => 'Fairchild Guide To Palms',
250
    'check_title' => 'Display Fairchild Guide To Palms link?',
251
    'link_title' => 'Fairchild Guide To Palms link',
252
    'link_description' => 'The link to Fairchild Guide To Palms without the taxon name.',
253
    'concat_default_value' => '+',
254
    'text_title' => 'Fairchild Guide To Palms text',
255
    'text_description' => 'The text of the link that is displayed..',
256
    'category' => 'Category',
257
  );
258

    
259

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

    
319
  return system_settings_form($form);
320
} // function ext_links_admin()
321

    
322
/**
323
 * @todo Please document this function.
324
 * @see http://drupal.org/node/1354
325
 */
326
function ext_links_permission() {
327

    
328
  return array(
329
    'access extlinks content' => array(
330
      'title' => t('access extlinks content'),
331
      'description' => t("TODO Add a description for 'access extlinks content'"),
332
    ),
333
    'administer extlinks' => array(
334
      'title' => t('administer extlinks'),
335
      'description' => t("TODO Add a description for 'administer extlinks'"),
336
    ),
337
  );
338
} /* function ext_links_permission() */
339

    
340
/**
341
 * Implements hook_menu().
342
 */
343
function ext_links_menu() {
344
  $items = array();
345

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

    
356
  return $items;
357
} /* function ext_links_menu() */
358

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

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

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

    
398
      if (arg(0) == "cdm_dataportal" && arg(1) == "taxon" && arg(2) !== 0) {
399
        $uuid = arg(2);
400
        $taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $uuid);
401

    
402
        // $taxon->titleCache;
403
        // var_export()
404
        if (!empty($taxon)) {
405
          drupal_add_js(drupal_get_path('module', 'ext_links') . '/ext_links.js');
406
          $speciesName = getSpeciesName($taxon);
407

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

    
419
          // if(variable_get('ext_links_gbif_check', TRUE)) {
420
          // $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 />';
421
          /*
422
           $block_content .=
423
           /* TODO
424
           Please manually fix the parameters on the l() or url() function on the next line.
425
           Typically, this was not changed because of a function call inside an array call like
426
           array('title' => t('View user profile.')).
427
           l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
428
           '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],
429
           array(), null, null, true);
430
           */
431
          /*}
432
           if(variable_get('ext_links_biocase_check', 1)) {
433
           $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 />';
434
           }
435
           if(variable_get('ext_links_nybg_check', 1)) {
436
           $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 />';
437
           }
438
           if(variable_get('ext_links_tropicos_check', 1)) {
439
           $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 />';
440
           }
441
           if(variable_get('ext_links_ncbi_check', 1)) {
442
           $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 />';
443
           }
444
           if(variable_get('ext_links_google_check', 1)) {
445
           $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 />';
446
           }
447
           if(variable_get('ext_links_flickr_check', 1)) {
448
           $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 />';
449
           }
450
           if(variable_get('ext_links_scholar_check', 1)) {
451
           $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 />';
452
           }
453
           if(variable_get('ext_links_bhl_check', 1)) {
454
           $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 />';
455
           }
456

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

    
460
           }
461

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

    
470
}
471

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

    
492

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

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

    
502
  // Images section.
503
  if (variable_get('ext_links_google_check', 1)) {
504
    $categoryTitles[] = variable_get('ext_links_google_category', $ext_links_default['google']['category_default_value']);
505
    $categories['google']['title'] = variable_get('ext_links_google_category', $ext_links_default['google']['category_default_value']);
506
    $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 />';
507

    
508
  }
509
  if (variable_get('ext_links_flickr_check', 1)) {
510
    $categoryTitles[] = variable_get('ext_links_flickr_category', $ext_links_default['flickr']['category_default_value']);
511
    $categories['flickr']['title'] = variable_get('ext_links_flickr_category', $ext_links_default['flickr']['category_default_value']);
512
    $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 />';
513
  }
514

    
515
  // Specimen/occurences section.
516
  if (variable_get('ext_links_gbif_check', TRUE)) {
517
    $categoryTitles[] = variable_get('ext_links_gbif_category', $ext_links_default['gbif']['category_default_value']);
518
    $categories['gbif']['title'] = variable_get('ext_links_gbif_category', $ext_links_default['gbif']['category_default_value']);
519
    $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 />';
520
  }
521
  if (variable_get('ext_links_biocase_check', 1)) {
522
    $categoryTitles[] = variable_get('ext_links_biocase_category', $ext_links_default['biocase']['category_default_value']);
523
    $categories['biocase']['title'] = variable_get('ext_links_biocase_category', $ext_links_default['biocase']['category_default_value']);
524
    $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 />';
525
  }
526
  if (variable_get('ext_links_nybg_check', 1)) {
527
    $query = '';
528
    $genusQuery = '';
529
    $speciesQuery = '';
530
    if ($speciesName['genus'] != NULL) {
531
      $query .= 'DetFiledAsGenusLocal+%3D+\%27'. $speciesName['genus']. '\%27';
532
    }
533
    if ($speciesName['species'] != NULL) {
534
      $query .= variable_get('ext_links_nybg_concat', '+AND+'). 'DetFiledAsSpeciesLocal+%3D+\%27'. $speciesName['species'] . '\%27';
535
    }
536
    $categoryTitles[] = variable_get('ext_links_nybg_category', $ext_links_default['nybg']['category_default_value']);
537
    $categories['nybg']['title'] = variable_get('ext_links_nybg_category', $ext_links_default['nybg']['category_default_value']);
538
    $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 />';
539
  }
540
  if (variable_get('ext_links_tropicos_check', 1)) {
541
    $categoryTitles[] = variable_get('ext_links_tropicos_category', $ext_links_default['tropicos']['category_default_value']);
542
    $categories['tropicos']['title'] = variable_get('ext_links_tropicos_category', $ext_links_default['tropicos']['category_default_value']);
543
    $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 />';
544
  }
545

    
546
  // Literature.
547
  if (variable_get('ext_links_scholar_check', 1)) {
548
    $categoryTitles[] = variable_get('ext_links_scholar_category', $ext_links_default['scholar']['category_default_value']);
549
    $categories['scholar']['title'] = variable_get('ext_links_scholar_category', $ext_links_default['scholar']['category_default_value']);
550
    $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 />';
551
  }
552
  if (variable_get('ext_links_bhl_check', 1)) {
553
    $categoryTitles[] = variable_get('ext_links_bhl_category', $ext_links_default['bhl']['category_default_value']);
554
    $categories['bhl']['title'] = variable_get('ext_links_bhl_category', $ext_links_default['bhl']['category_default_value']);
555
    $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 />';
556
  }
557

    
558
  // Molecular resources.
559
  if (variable_get('ext_links_ncbi_check', 1)) {
560
    $categoryTitles[] = variable_get('ext_links_ncbi_category', $ext_links_default['ncbi']['category_default_value']);
561
    $categories['ncbi']['title'] = variable_get('ext_links_ncbi_category', $ext_links_default['ncbi']['category_default_value']);
562
    $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 />';
563
  }
564
  if (variable_get('ext_links_arkive_check', 1)) {
565
    $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
566
    $categoryTitles[] = variable_get('ext_links_arkive_category', $ext_links_default['arkive']['category_default_value']);
567
    $categories['arkive']['title'] = variable_get('ext_links_arkive_category', $ext_links_default['arkive']['category_default_value']);
568
    $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 />';
569
  }
570
  if (variable_get('ext_links_herbcat_check', 1)) {
571
    $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
572
    $categoryTitles[] = variable_get('ext_links_herbcat_category', $ext_links_default['herbcat']['category_default_value']);
573
    $categories['herbcat']['title'] = variable_get('ext_links_herbcat_category', $ext_links_default['herbcat']['category_default_value']);
574
    $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 />';
575
  }
576
  if (variable_get('ext_links_iucn_check', 1)) {
577
    $categoryTitles[] = variable_get('ext_links_iucn_category', $ext_links_default['iucn']['category_default_value']);
578
    $categories['iucn']['title'] = variable_get('ext_links_iucn_category', $ext_links_default['iucn']['category_default_value']);
579
    $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 />';
580
  }
581
  if (variable_get('ext_links_ipni_check', 1)) {
582
    $genusQuery = 'find_genus=' . $speciesName['genus'];
583
    $speciesQuery = 'find_species=' . $speciesName['species'];
584
    $categoryTitles[] = variable_get('ext_links_ipni_category', $ext_links_default['ipni']['category_default_value']);
585
    $categories['ipni']['title'] = variable_get('ext_links_ipni_category', $ext_links_default['ipni']['category_default_value']);
586
    $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 />';
587
  }
588
  if (variable_get('ext_links_wcsp_check', 1)) {
589
    $categoryTitles[] = variable_get('ext_links_wcsp_category', $ext_links_default['wcsp']['category_default_value']);
590
    $categories['wcsp']['title'] = variable_get('ext_links_wcsp_category', $ext_links_default['wcsp']['category_default_value']);
591
    $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 />';
592
  }
593
  if (variable_get('ext_links_tpl_check', 1)) {
594
    $categoryTitles[] = variable_get('ext_links_tpl_category', $ext_links_default['tpl']['category_default_value']);
595
    $categories['tpl']['title'] = variable_get('ext_links_tpl_category', $ext_links_default['tpl']['category_default_value']);
596
    $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 />';
597
  }
598
  if (variable_get('ext_links_eol_check', 1)) {
599
    $categoryTitles[] = variable_get('ext_links_eol_category', $ext_links_default['eol']['category_default_value']);
600
    $categories['eol']['title'] = variable_get('ext_links_eol_category', $ext_links_default['eol']['category_default_value']);
601
    $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 />';
602
  }
603
  if (variable_get('ext_links_jstor_check', 1)) {
604
    $categoryTitles[] = variable_get('ext_links_jstor_category', $ext_links_default['jstor']['category_default_value']);
605
    $categories['jstor']['title'] = variable_get('ext_links_jstor_category', $ext_links_default['jstor']['category_default_value']);
606
    $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 />';
607
  }
608
  if (variable_get('ext_links_epic_check', 1)) {
609
    $postURL = '&searchAll=true&categories=names&categories=bibl&categories=colln&categories=taxon&categories=flora&Submit.x=0&Submit.y=0';
610
    $categoryTitles[] = variable_get('ext_links_epic_category', $ext_links_default['epic']['category_default_value']);
611
    $categories['epic']['title'] = variable_get('ext_links_epic_category', $ext_links_default['epic']['category_default_value']);
612
    $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 />';
613
  }
614
  if (variable_get('ext_links_fairchild_check', 1)) {
615
    $categoryTitles[] = variable_get('ext_links_fairchild_category', $ext_links_default['fairchild']['category_default_value']);
616
    $categories['fairchild']['title'] = variable_get('ext_links_fairchild_category', $ext_links_default['fairchild']['category_default_value']);
617
    $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 />';
618

    
619
  }
620

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

    
633

    
634
  return $block_content;
635
}
636

    
637
/**
638
 * @todo Please document this function.
639
 * @see http://drupal.org/node/1354
640
 */
641
function theme_ext_links_list_plain($variables) {
642
  $speciesName = $variables['speciesName'];
643
  if (!isset($speciesName['genus'])) {
644
    $speciesName['genus'] = '';
645
  }
646
  if (!isset($speciesName['species'])) {
647
    $speciesName['species'] = '';
648
  }
649
  $genus = $variables['genus'];
650
  $species = $variables['species'];
651
  $ext_links_default = ext_links_get_default();
652
  $block_content = '';
653
  if (variable_get('ext_links_gbif_check', TRUE)) {
654
    $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 />';
655
    /*
656
     $block_content .= /* TODO
657
     Please manually fix the parameters on the l() or url() function on the next line.
658
     Typically, this was not changed because of a function call inside an array call like
659
     array('title' => t('View user profile.')).*/
660
    /*
661
     l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
662
     '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],
663
     array(), null, null, true);
664
     */
665
  }
666
  if (variable_get('ext_links_biocase_check', 1)) {
667
    $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 />';
668
  }
669
  if (variable_get('ext_links_nybg_check', 1)) {
670
    // $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 />';
671
    $genusQuery = '';
672
    $speciesQuery = '';
673
    if ($speciesName['genus'] != NULL) {
674
      $genusQuery = 'DetFiledAsGenusLocal+%3D+\%27' . $speciesName['genus'] . '\%27';
675
    }
676
    if ($speciesName['species'] != NULL) {
677
      $speciesQuery = 'DetFiledAsSpeciesLocal+%3D+\%27' . $speciesName['species'] . '\%27';
678
    }
679
    $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 />';
680
  }
681
  if (variable_get('ext_links_tropicos_check', 1)) {
682
    $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 />';
683
  }
684
  if (variable_get('ext_links_ncbi_check', 1)) {
685
    $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 />';
686
  }
687
  if (variable_get('ext_links_google_check', 1)) {
688
    $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 />';
689
  }
690
  if (variable_get('ext_links_flickr_check', 1)) {
691
    $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 />';
692
  }
693
  if (variable_get('ext_links_scholar_check', 1)) {
694
    $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 />';
695
  }
696
  if (variable_get('ext_links_bhl_check', 1)) {
697
    $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 />';
698
  }
699
  if (variable_get('ext_links_fairchild_check', 1)) {
700
    $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 />';
701
  }
702
  if (variable_get('ext_links_arkive_check', 1)) {
703
    $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
704
    $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 />';
705
  }
706
  if (variable_get('ext_links_herbcat_check', 1)) {
707
    $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
708
    $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 />';
709
  }
710
  if (variable_get('ext_links_iucn_check', 1)) {
711
    $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 />';
712

    
713
  }
714
  if (variable_get('ext_links_ipni_check', 1)) {
715
    $genusQuery = 'find_genus=' . $speciesName['genus'];
716
    $speciesQuery = 'find_species=' . $speciesName['species'];
717
    $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 />';
718
  }
719
  if (variable_get('ext_links_wcsp_check', 1)) {
720
    $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 />';
721

    
722
  }
723
  if (variable_get('ext_links_tpl_check', 1)) {
724
    $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 />';
725
  }
726
  if (variable_get('ext_links_eol_check', 1)) {
727
    $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 />';
728
  }
729
  if (variable_get('ext_links_jstor_check', 1)) {
730
    $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 />';
731
  }
732
  if (variable_get('ext_links_epic_check', 1)) {
733
    $postURL = '&searchAll=true&categories=names&categories=bibl&categories=colln&categories=taxon&categories=flora&Submit.x=0&Submit.y=0';
734
    $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 />';
735
  }
736

    
737
  return $block_content;
738
}
739

    
740
// Include the admin form if we really want it to use.
741
/*
742
if (arg(0) === 'admin' AND arg(1) === 'user' AND arg(2) === 'ext_link') {
743
  module_load_include('inc', 'ext_links', 'xt_link_admin');
744
}
745
*/
746

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

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