Project

General

Profile

Download (48.1 KB) Statistics
| Branch: | Tag: | Revision:
1 6657531f Andreas Kohlbecker
<?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
  switch ($path) {
33
    case 'admin/help#ext_links':
34
      $output = '<p>' . t("Link to external sources like ## for taxa.") . '</p>';
35 ecd1141f Andreas Kohlbecker
      return $output;
36
    case 'admin/config/cdm_dataportal/ext_links':
37
      $output = '<p>' . t('The external links module allows to configure URL templates for links to external data sources.');
38
      return $output;
39
    case 'admin/config/cdm_dataportal/ext_links/%':
40
      $output = '<p>' . t('An external link template.');
41
      return $output;
42 6657531f Andreas Kohlbecker
  }
43 ecd1141f Andreas Kohlbecker
}
44 6657531f Andreas Kohlbecker
45
/**
46
 * Implements hook_menu().
47
 */
48
function ext_links_menu() {
49 ecd1141f Andreas Kohlbecker
  $items = [];
50 6657531f Andreas Kohlbecker
51 ecd1141f Andreas Kohlbecker
  $items['admin/config/cdm_dataportal/ext_links'] = [
52 6657531f Andreas Kohlbecker
    'title' => 'External links',
53 ecd1141f Andreas Kohlbecker
    'description' => 'Configure external links templates.',
54 6657531f Andreas Kohlbecker
    'page callback' => 'drupal_get_form',
55 ecd1141f Andreas Kohlbecker
    'page arguments' => ['ext_links_admin_overview'],
56
    'access arguments' => ['access administration pages'],
57
    'file' => 'ext_links.admin.inc'
58
  ];
59
  $items['admin/config/cdm_dataportal/ext_links/list'] = [
60
    'title' => 'List',
61
    'type' => MENU_DEFAULT_LOCAL_TASK,
62
  ];
63
  $items['admin/config/cdm_dataportal/ext_links/add'] = [
64
    'title' => 'Add external link',
65
    'page callback' => 'ext_links_admin_link_template_page',
66
    'access arguments' => ['access administration pages'],
67
    'type' => MENU_LOCAL_ACTION,
68
    'weight' => 1,
69
    'file' => 'ext_links.admin.inc',
70
  ];
71 deba3cdd Andreas Kohlbecker
  $items['admin/config/cdm_dataportal/ext_links/%ext_links'] = [ // %ext_links refers to ext_links_load
72
    'title' => 'Edit external link',
73 ecd1141f Andreas Kohlbecker
    'page callback' => 'ext_links_admin_link_template_page',
74
    'page arguments' => [4],
75
    'access arguments' => ['access administration pages'],
76
    'file' => 'ext_links.admin.inc',
77
  ];
78 6657531f Andreas Kohlbecker
  return $items;
79 ecd1141f Andreas Kohlbecker
}
80
81
/**
82
 * Retrieves a list of External Link templates, ordered by weight.
83
 *
84 0e38f1bf Andreas Kohlbecker
 * Empty 'ext_links' tables will be initialized with the default templates.
85
 *
86
 * @see ext_links_template_defaults()
87
 *
88
 * @return array
89 ecd1141f Andreas Kohlbecker
 *   An array of external link template objects, keyed by the format ID and ordered by
90
 *   weight.
91
 *
92
 */
93
function ext_links_templates() {
94
  global $language;
95
  $link_templates = &drupal_static(__FUNCTION__, array());
96
97
  // cache_clear_all("ext_links_templates:{$language->language}");
98
  // All available link_templates are cached for performance.
99
  if (!is_array($link_templates) || !count($link_templates)) {
100 0e38f1bf Andreas Kohlbecker
    if ($cache = cache_get("ext_links:{$language->language}")) {
101 ecd1141f Andreas Kohlbecker
      $link_templates = $cache->data;
102
    }
103
    else {
104 0e38f1bf Andreas Kohlbecker
      $test = false;
105 ecd1141f Andreas Kohlbecker
      if($test){
106
        $link_templates = [];
107
        $link_templates_arrays = ext_links_template_defaults();
108
        foreach($link_templates_arrays as $a){
109
          $link_templates[] = (object)$a;
110
        }
111
      } else {
112 82e80b81 Andreas Kohlbecker
        $link_templates = db_select('ext_links', 'elt')
113 ecd1141f Andreas Kohlbecker
          ->addTag('translatable')
114 82e80b81 Andreas Kohlbecker
          ->fields('elt')
115 0e38f1bf Andreas Kohlbecker
          ->orderBy('category')
116 ecd1141f Andreas Kohlbecker
          ->orderBy('weight')
117 0e38f1bf Andreas Kohlbecker
          ->execute()
118
          ->fetchAllAssoc('id');
119
      }
120
      if(!count($link_templates)) {
121
        $link_templates_arrays = ext_links_template_defaults();
122
        $query = db_insert('ext_links')
123
          ->fields(array_keys(array_values($link_templates_arrays)[0]));
124
        foreach($link_templates_arrays as $a){
125
          $query->values($a);
126
        }
127
        try {
128
          $query->execute();
129
        } catch (Exception $e) {
130
          drupal_set_message("Error while initializing ext_links database: " . $e->getMessage(), "error");
131
        }
132
        $link_templates = [];
133
        foreach($link_templates_arrays as $a){
134
          $link_templates[] = (object)$a;
135
        }
136 ecd1141f Andreas Kohlbecker
      }
137 0e38f1bf Andreas Kohlbecker
      // cache_set("ext_links:{$language->language}", $link_templates);
138 ecd1141f Andreas Kohlbecker
    }
139
  }
140
  return $link_templates;
141
}
142
143 82e80b81 Andreas Kohlbecker
/**
144
 * Resets the text format caches.
145
 *
146
 * @see filter_formats()
147
 */
148
function ext_links_templates_reset() {
149 0e38f1bf Andreas Kohlbecker
  cache_clear_all('ext_links', 'cache', TRUE);
150
  drupal_static_reset('ext_links');
151 82e80b81 Andreas Kohlbecker
}
152
153
/**
154
 * Loads a text format object from the database.
155
 *
156
 * @param $extlink_id
157
 *   The external link ID. ($link->id)
158
 *
159
 * @return
160
 *   A fully-populated text format object, if the requested format exists and
161
 *   is enabled. If the format does not exist, or exists in the database but
162
 *   has been marked as disabled, FALSE is returned.
163
 *
164
 * @see ext_links_exists()
165
 */
166
function ext_links_load($extlink_id) {
167 0e38f1bf Andreas Kohlbecker
  $test = false;
168 deba3cdd Andreas Kohlbecker
  if($test) {
169
    $defaults = ext_links_template_defaults();
170
    return isset($defaults[$extlink_id]) ? (object)$defaults[$extlink_id] : FALSE;
171
  }
172
  else {
173 0e38f1bf Andreas Kohlbecker
   $link_templates = ext_links_templates();
174
    return isset($link_templates[$extlink_id]) ? $link_templates[$extlink_id] : FALSE;
175 deba3cdd Andreas Kohlbecker
  }
176 82e80b81 Andreas Kohlbecker
}
177
178
/**
179
 * Saves a text format object to the database.
180
 *
181
 * @param $link_template
182
 *   A link template object having the properties:
183
 *   - id: The machine name of the external link. If this corresponds
184
 *     to an existing external link, this one will be updated;
185
 *     otherwise, a new external link will be created.
186
 *   - title: The link title
187
 *   - link: The link url template.
188
 *   - glue: The string to concatenate name parts in the URL query string.
189
 *   - status: (optional) An integer indicating whether the ext link is
190
 *     enabled (1) or not (0). Defaults to 1.
191
 *   - weight: (optional) The weight of the external link, which controls its
192
 *     placement in external link block. If omitted, the weight is set to 0.
193
 *     Defaults to NULL.
194
 *
195
 * @return
196
 *   SAVED_NEW or SAVED_UPDATED.
197
 */
198
function ext_links_save($link_template) {
199 0e38f1bf Andreas Kohlbecker
200 82e80b81 Andreas Kohlbecker
  $link_template->title = trim($link_template->title);
201
  $link_template->cache = true;
202
  if (!isset($link_template->status)) {
203
    $link_template->status = 1;
204
  }
205
  if (!isset($link_template->weight)) {
206
    $link_template->weight = 0;
207
  }
208
209
  // Insert or update the text format.
210
  $return = db_merge('ext_links')
211 0e38f1bf Andreas Kohlbecker
    ->key(array('id' => $link_template->id))
212 82e80b81 Andreas Kohlbecker
    ->fields(array(
213
      'id' => $link_template->id,
214
      'title' => $link_template->title,
215
      'link' => $link_template->link,
216
      'glue' => $link_template->glue,
217
      'status' => (int) $link_template->status,
218
      'weight' => (int) $link_template->weight,
219
    ))
220
    ->execute();
221
222
  ext_links_templates_reset();
223
  return $return;
224
}
225
226
/**
227
 * Determines if a external link exists.
228
 *
229
 * @param $ext_link_name
230
 *   The ID of the external link to check.
231
 *
232
 * @return
233
 *   TRUE if the external link exists, FALSE otherwise.
234
 *
235
 * @see ext_links_load()
236
 */
237
function ext_links_exists($ext_link_name) {
238
  return (bool) db_query_range('SELECT 1 FROM {ext_links} WHERE name = :name', 0, 1, array(':name' => $ext_link_name))->fetchField();
239
}
240
241
242
/**
243
 * Returns the genus and the first epithet from the object taxon.
244
 *
245
 * @param $taxon
246
 *   A CDM Taxon instance object
247
 * @return array
248
 *  An associate array with two elements:
249
 *     - genus: the uninomial
250
 *     - species: the species epithet
251
 */
252
function ext_link_species_name($taxon) {
253
  $speciesName = array();
254
  $i = 0;
255
  while (isset($taxon->name->taggedName[$i]) && !isset($speciesName['species'])) {
256
    if ($taxon->name->taggedName[$i]->type == "name") {
257
      if (!isset($speciesName['genus'])) {
258
        $speciesName['genus'] = $taxon->name->taggedName[$i]->text;
259
      }
260
      else {
261
        $speciesName['species'] = $taxon->name->taggedName[$i]->text;
262
      }
263
    }
264
    $i++;
265
  }
266
  return $speciesName;
267
}
268
269 6657531f Andreas Kohlbecker
/**
270
 * Implements hook_block_info().
271
 */
272
function ext_links_block_info() {
273
  if (TRUE) {
274
    $block[0]["info"] = t("External Taxon Links");
275
    return $block;
276
  }
277
}
278
279
/**
280
 * Implements hook_block_view().
281
 */
282
function ext_links_block_view($delta) {
283
  // TODO Rename block deltas (e.g. '0') to readable strings.
284
  switch ($delta) {
285
    case '0':
286
      $block['subject'] = 'External links';
287
288 0af3ce28 Andreas Kohlbecker
      $uuid = get_current_taxon_uuid();
289
      if ($uuid) {
290 6657531f Andreas Kohlbecker
        $taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $uuid);
291
292
        // $taxon->titleCache;
293
        // var_export()
294
        if (!empty($taxon)) {
295
          drupal_add_js(drupal_get_path('module', 'ext_links') . '/ext_links.js');
296 82e80b81 Andreas Kohlbecker
          $speciesName = ext_link_species_name($taxon);
297 6657531f Andreas Kohlbecker
298
          $genus = $taxon->name->taggedName[0]->text;
299 e5f17100 Andreas Kohlbecker
          $species = null;
300
          if(isset($taxon->name->taggedName[1])){
301
            $species = $taxon->name->taggedName[1]->text;
302
          }
303 6657531f Andreas Kohlbecker
          $block_content = '';
304
          $listOption = variable_get("ext_links_options", 0);
305
          if (isset($listOption)) {
306
            $block['content'] = theme('ext_links_list_grouped', array('speciesName' => $speciesName, 'genus' => $genus, 'species' => $species));
307
          }
308
          else {
309
            $block['content'] = theme('ext_links_list_plain', array('speciesName' => $speciesName, 'genus' => $genus, 'species' => $species ));
310
          }
311
312
          // if(variable_get('ext_links_gbif_check', TRUE)) {
313
          // $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 />';
314
          /*
315
           $block_content .=
316
           /* TODO
317
           Please manually fix the parameters on the l() or url() function on the next line.
318
           Typically, this was not changed because of a function call inside an array call like
319
           array('title' => t('View user profile.')).
320
           l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
321
           '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],
322
           array(), null, null, true);
323
           */
324
          /*}
325
           if(variable_get('ext_links_biocase_check', 1)) {
326
           $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 />';
327
           }
328
           if(variable_get('ext_links_nybg_check', 1)) {
329
           $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 />';
330
           }
331
           if(variable_get('ext_links_tropicos_check', 1)) {
332
           $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 />';
333
           }
334
           if(variable_get('ext_links_ncbi_check', 1)) {
335
           $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 />';
336
           }
337
           if(variable_get('ext_links_google_check', 1)) {
338
           $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 />';
339
           }
340
           if(variable_get('ext_links_flickr_check', 1)) {
341
           $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 />';
342
           }
343
           if(variable_get('ext_links_scholar_check', 1)) {
344
           $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 />';
345
           }
346
           if(variable_get('ext_links_bhl_check', 1)) {
347
           $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 />';
348
           }
349
350
           $block['content'] = $block_content;
351
           $block['content'] = theme('ext_links_list_plain');
352
353
           }
354
355
           }*/
356
          // if taxon
357
        }
358
      }
359
      // If path.
360
      return $block;
361
  } /* switch */
362
363
}
364
365
/**
366
 * @todo Please document this function.
367
 * @see http://drupal.org/node/1354
368
 */
369
function theme_ext_links_list_grouped($variables) {
370
  // comment @WA: perhaps this function could be merged with ext_list_plain
371
  // into one function?
372
  $speciesName = $variables['speciesName'];
373
  if(!isset($speciesName['genus'])) {
374
    $speciesName['genus'] = '';
375
  }
376
  if(!isset($speciesName['species'])) {
377
    $speciesName['species'] = '';
378
  }
379
  $genus = $variables['genus'];
380
  $species = $variables['species'];
381
  $block_content = '';
382
  $categories = NULL;
383 82e80b81 Andreas Kohlbecker
  $ext_links_default = ext_links_templates();
384 6657531f Andreas Kohlbecker
385
386
  /*
387
  foreach ($ext_links_default as $ext_link) {
388
389
   //$block_content .= $ext_link['ext_links_bhl_category'];
390
   $category[] = variable_get('ext_links_bhl_category', $ext_links_default[][text_default_value]);
391
   $block_content .= variable_get('ext_links_bhl_category', $ext_links_default[][text_default_value]);
392
   }
393
   */
394
395
  // Images section.
396
  if (variable_get('ext_links_google_check', 1)) {
397
    $categoryTitles[] = variable_get('ext_links_google_category', $ext_links_default['google']['category_default_value']);
398
    $categories['google']['title'] = variable_get('ext_links_google_category', $ext_links_default['google']['category_default_value']);
399
    $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 />';
400
401
  }
402
  if (variable_get('ext_links_flickr_check', 1)) {
403
    $categoryTitles[] = variable_get('ext_links_flickr_category', $ext_links_default['flickr']['category_default_value']);
404
    $categories['flickr']['title'] = variable_get('ext_links_flickr_category', $ext_links_default['flickr']['category_default_value']);
405
    $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 />';
406
  }
407
408
  // Specimen/occurences section.
409
  if (variable_get('ext_links_gbif_check', TRUE)) {
410
    $categoryTitles[] = variable_get('ext_links_gbif_category', $ext_links_default['gbif']['category_default_value']);
411
    $categories['gbif']['title'] = variable_get('ext_links_gbif_category', $ext_links_default['gbif']['category_default_value']);
412
    $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 />';
413
  }
414
  if (variable_get('ext_links_biocase_check', 1)) {
415
    $categoryTitles[] = variable_get('ext_links_biocase_category', $ext_links_default['biocase']['category_default_value']);
416
    $categories['biocase']['title'] = variable_get('ext_links_biocase_category', $ext_links_default['biocase']['category_default_value']);
417
    $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 />';
418
  }
419
  if (variable_get('ext_links_nybg_check', 1)) {
420
    $query = '';
421
    $genusQuery = '';
422
    $speciesQuery = '';
423
    if ($speciesName['genus'] != NULL) {
424
      $query .= 'DetFiledAsGenusLocal+%3D+\%27'. $speciesName['genus']. '\%27';
425
    }
426
    if ($speciesName['species'] != NULL) {
427
      $query .= variable_get('ext_links_nybg_concat', '+AND+'). 'DetFiledAsSpeciesLocal+%3D+\%27'. $speciesName['species'] . '\%27';
428
    }
429
    $categoryTitles[] = variable_get('ext_links_nybg_category', $ext_links_default['nybg']['category_default_value']);
430
    $categories['nybg']['title'] = variable_get('ext_links_nybg_category', $ext_links_default['nybg']['category_default_value']);
431
    $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 />';
432
  }
433
  if (variable_get('ext_links_tropicos_check', 1)) {
434
    $categoryTitles[] = variable_get('ext_links_tropicos_category', $ext_links_default['tropicos']['category_default_value']);
435
    $categories['tropicos']['title'] = variable_get('ext_links_tropicos_category', $ext_links_default['tropicos']['category_default_value']);
436
    $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 />';
437
  }
438
439
  // Literature.
440
  if (variable_get('ext_links_scholar_check', 1)) {
441
    $categoryTitles[] = variable_get('ext_links_scholar_category', $ext_links_default['scholar']['category_default_value']);
442
    $categories['scholar']['title'] = variable_get('ext_links_scholar_category', $ext_links_default['scholar']['category_default_value']);
443
    $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 />';
444
  }
445
  if (variable_get('ext_links_bhl_check', 1)) {
446
    $categoryTitles[] = variable_get('ext_links_bhl_category', $ext_links_default['bhl']['category_default_value']);
447
    $categories['bhl']['title'] = variable_get('ext_links_bhl_category', $ext_links_default['bhl']['category_default_value']);
448
    $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 />';
449
  }
450
451
  // Molecular resources.
452
  if (variable_get('ext_links_ncbi_check', 1)) {
453
    $categoryTitles[] = variable_get('ext_links_ncbi_category', $ext_links_default['ncbi']['category_default_value']);
454
    $categories['ncbi']['title'] = variable_get('ext_links_ncbi_category', $ext_links_default['ncbi']['category_default_value']);
455
    $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 />';
456
  }
457
  if (variable_get('ext_links_arkive_check', 1)) {
458
    $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
459
    $categoryTitles[] = variable_get('ext_links_arkive_category', $ext_links_default['arkive']['category_default_value']);
460
    $categories['arkive']['title'] = variable_get('ext_links_arkive_category', $ext_links_default['arkive']['category_default_value']);
461
    $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 />';
462
  }
463
  if (variable_get('ext_links_herbcat_check', 1)) {
464
    $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
465
    $categoryTitles[] = variable_get('ext_links_herbcat_category', $ext_links_default['herbcat']['category_default_value']);
466
    $categories['herbcat']['title'] = variable_get('ext_links_herbcat_category', $ext_links_default['herbcat']['category_default_value']);
467
    $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 />';
468
  }
469
  if (variable_get('ext_links_iucn_check', 1)) {
470
    $categoryTitles[] = variable_get('ext_links_iucn_category', $ext_links_default['iucn']['category_default_value']);
471
    $categories['iucn']['title'] = variable_get('ext_links_iucn_category', $ext_links_default['iucn']['category_default_value']);
472
    $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 />';
473
  }
474
  if (variable_get('ext_links_ipni_check', 1)) {
475
    $genusQuery = 'find_genus=' . $speciesName['genus'];
476
    $speciesQuery = 'find_species=' . $speciesName['species'];
477
    $categoryTitles[] = variable_get('ext_links_ipni_category', $ext_links_default['ipni']['category_default_value']);
478
    $categories['ipni']['title'] = variable_get('ext_links_ipni_category', $ext_links_default['ipni']['category_default_value']);
479
    $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 />';
480
  }
481
  if (variable_get('ext_links_wcsp_check', 1)) {
482
    $categoryTitles[] = variable_get('ext_links_wcsp_category', $ext_links_default['wcsp']['category_default_value']);
483
    $categories['wcsp']['title'] = variable_get('ext_links_wcsp_category', $ext_links_default['wcsp']['category_default_value']);
484
    $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 />';
485
  }
486
  if (variable_get('ext_links_tpl_check', 1)) {
487
    $categoryTitles[] = variable_get('ext_links_tpl_category', $ext_links_default['tpl']['category_default_value']);
488
    $categories['tpl']['title'] = variable_get('ext_links_tpl_category', $ext_links_default['tpl']['category_default_value']);
489
    $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 />';
490
  }
491
  if (variable_get('ext_links_eol_check', 1)) {
492
    $categoryTitles[] = variable_get('ext_links_eol_category', $ext_links_default['eol']['category_default_value']);
493
    $categories['eol']['title'] = variable_get('ext_links_eol_category', $ext_links_default['eol']['category_default_value']);
494
    $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 />';
495
  }
496
  if (variable_get('ext_links_jstor_check', 1)) {
497
    $categoryTitles[] = variable_get('ext_links_jstor_category', $ext_links_default['jstor']['category_default_value']);
498
    $categories['jstor']['title'] = variable_get('ext_links_jstor_category', $ext_links_default['jstor']['category_default_value']);
499
    $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 />';
500
  }
501
  if (variable_get('ext_links_epic_check', 1)) {
502
    $postURL = '&searchAll=true&categories=names&categories=bibl&categories=colln&categories=taxon&categories=flora&Submit.x=0&Submit.y=0';
503
    $categoryTitles[] = variable_get('ext_links_epic_category', $ext_links_default['epic']['category_default_value']);
504
    $categories['epic']['title'] = variable_get('ext_links_epic_category', $ext_links_default['epic']['category_default_value']);
505
    $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 />';
506
  }
507 522a5b8c Andreas Kohlbecker
//  if (variable_get('ext_links_fairchild_check', 1)) {
508
//    $categoryTitles[] = variable_get('ext_links_fairchild_category', $ext_links_default['fairchild']['category_default_value']);
509
//    $categories['fairchild']['title'] = variable_get('ext_links_fairchild_category', $ext_links_default['fairchild']['category_default_value']);
510
//    $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 />';
511
//  }
512
  if (variable_get('ext_links_ggbn_check', 1)) {
513
    $categoryTitles[] = variable_get('ext_links_ggbn_category', $ext_links_default['ggbn']['category_default_value']);
514
    $categories['ggbn']['title'] = variable_get('ext_links_ggnb_category', $ext_links_default['ggbn']['category_default_value']);
515
    $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 />';
516 6657531f Andreas Kohlbecker
  }
517
518
  $categoryTitles = array_unique($categoryTitles);
519
  foreach ($categoryTitles as $categoryTitle) {
520
    // $block_content .= "specName" . $speciesName;
521
    $block_content .= "<div class=\"category\"><h5>" . $categoryTitle . "</h5>";
522
    foreach ($categories as $category) {
523
      if ($category['title'] == $categoryTitle) {
524
        $block_content .= $category['content'];
525
      }
526
    }
527
    $block_content .= "</div>";
528
  }
529
530
531
  return $block_content;
532
}
533
534
/**
535
 * @todo Please document this function.
536
 * @see http://drupal.org/node/1354
537
 */
538
function theme_ext_links_list_plain($variables) {
539
  $speciesName = $variables['speciesName'];
540
  if (!isset($speciesName['genus'])) {
541
    $speciesName['genus'] = '';
542
  }
543
  if (!isset($speciesName['species'])) {
544
    $speciesName['species'] = '';
545
  }
546
  $genus = $variables['genus'];
547
  $species = $variables['species'];
548
  $ext_links_default = ext_links_get_default();
549
  $block_content = '';
550
  if (variable_get('ext_links_gbif_check', TRUE)) {
551
    $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 />';
552
    /*
553
     $block_content .= /* TODO
554
     Please manually fix the parameters on the l() or url() function on the next line.
555
     Typically, this was not changed because of a function call inside an array call like
556
     array('title' => t('View user profile.')).*/
557
    /*
558
     l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
559
     '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],
560
     array(), null, null, true);
561
     */
562
  }
563
  if (variable_get('ext_links_biocase_check', 1)) {
564
    $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 />';
565
  }
566
  if (variable_get('ext_links_nybg_check', 1)) {
567
    // $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 />';
568
    $genusQuery = '';
569
    $speciesQuery = '';
570
    if ($speciesName['genus'] != NULL) {
571
      $genusQuery = 'DetFiledAsGenusLocal+%3D+\%27' . $speciesName['genus'] . '\%27';
572
    }
573
    if ($speciesName['species'] != NULL) {
574
      $speciesQuery = 'DetFiledAsSpeciesLocal+%3D+\%27' . $speciesName['species'] . '\%27';
575
    }
576
    $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 />';
577
  }
578
  if (variable_get('ext_links_tropicos_check', 1)) {
579
    $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 />';
580
  }
581
  if (variable_get('ext_links_ncbi_check', 1)) {
582
    $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 />';
583
  }
584
  if (variable_get('ext_links_google_check', 1)) {
585
    $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 />';
586
  }
587
  if (variable_get('ext_links_flickr_check', 1)) {
588
    $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 />';
589
  }
590
  if (variable_get('ext_links_scholar_check', 1)) {
591
    $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 />';
592
  }
593
  if (variable_get('ext_links_bhl_check', 1)) {
594
    $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 />';
595
  }
596 522a5b8c Andreas Kohlbecker
//  if (variable_get('ext_links_fairchild_check', 1)) {
597
//    $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 />';
598
//  }
599
  if (variable_get('ext_links_ggbn_check', 1)) {
600
    $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 />';
601 6657531f Andreas Kohlbecker
  }
602
  if (variable_get('ext_links_arkive_check', 1)) {
603
    $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
604
    $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 />';
605
  }
606
  if (variable_get('ext_links_herbcat_check', 1)) {
607
    $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
608
    $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 />';
609
  }
610
  if (variable_get('ext_links_iucn_check', 1)) {
611
    $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 />';
612
613
  }
614
  if (variable_get('ext_links_ipni_check', 1)) {
615
    $genusQuery = 'find_genus=' . $speciesName['genus'];
616
    $speciesQuery = 'find_species=' . $speciesName['species'];
617
    $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 />';
618
  }
619
  if (variable_get('ext_links_wcsp_check', 1)) {
620
    $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 />';
621
622
  }
623
  if (variable_get('ext_links_tpl_check', 1)) {
624
    $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 />';
625
  }
626
  if (variable_get('ext_links_eol_check', 1)) {
627
    $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 />';
628
  }
629
  if (variable_get('ext_links_jstor_check', 1)) {
630
    $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 />';
631
  }
632
  if (variable_get('ext_links_epic_check', 1)) {
633
    $postURL = '&searchAll=true&categories=names&categories=bibl&categories=colln&categories=taxon&categories=flora&Submit.x=0&Submit.y=0';
634
    $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 />';
635
  }
636
637
  return $block_content;
638
}
639
640
// Include the admin form if we really want it to use.
641
/*
642
if (arg(0) === 'admin' AND arg(1) === 'user' AND arg(2) === 'ext_link') {
643
  module_load_include('inc', 'ext_links', 'xt_link_admin');
644
}
645
*/
646
647
/**
648
 * @todo Please document this function.
649
 * @see http://drupal.org/node/1354
650
 */
651
function ext_links_theme() {
652
  return array(
653
    'ext_links_list_grouped' => array('variables' => array(
654
      'speciesName' => NULL,
655
      'genus' => NULL,
656
      'species' => NULL,
657
      )),
658
    'ext_links_list_plain' => array('variables' => array(
659
      'speciesName' => NULL,
660
      'genus' => NULL,
661
      'species' => NULL,
662
      )),
663 ecd1141f Andreas Kohlbecker
    // theme_ext_links_admin_overview
664
    'ext_links_admin_overview' => array(
665
      'render element' => 'form',
666
      'file' => 'ext_links.admin.inc',
667
    ),
668
//    'ext_links_link_template_filter_order' => array(
669
//      'render element' => 'element',
670
//      'file' => 'ext_links.admin.inc',
671
//    ),
672 6657531f Andreas Kohlbecker
  );
673
}
674
675
/**
676
 * Get the default external links.
677
 *
678
 * @return array
679
 *   Returns an array with default external links values.
680
 */
681 ecd1141f Andreas Kohlbecker
function ext_links_template_defaults() {
682 6657531f Andreas Kohlbecker
  $ext_links_default["gbif"] = array(
683 82e80b81 Andreas Kohlbecker
    'id' => "gbif",
684 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.gbif.org/species/search?q=',
685
    'title' => 'Search GBIF...',
686
    'glue' => ' ',
687
    'weight' => 0,
688
    'status' => 1,
689
    'category' => 'Specimens/Occurrences',
690 6657531f Andreas Kohlbecker
  );
691
  $ext_links_default["biocase"] = array(
692 82e80b81 Andreas Kohlbecker
    'id' => "biocase",
693 ecd1141f Andreas Kohlbecker
    'link' => 'http://search.biocase.org/edit/search/units/simpleSearch/query1?unitName=',
694
    'title' => 'Search BioCASE...',
695
    'glue' => ' ',
696
    'weight' => 0,
697
    'status' => 1,
698
    'category' => 'Specimens/Occurrences',
699 6657531f Andreas Kohlbecker
  );
700
  $ext_links_default["nybg"] = array(
701 82e80b81 Andreas Kohlbecker
    'id' => "nybg",
702 ecd1141f Andreas Kohlbecker
    'link' => 'http://sweetgum.nybg.org/science/vh/specimen_list.php?SummaryData=',
703
    'title' => 'Search NYBG...',
704
    'glue' => '+AND+',
705
    'weight' => 0,
706
    'status' => 1,
707
    'category' => 'Specimens/Occurrences',
708 6657531f Andreas Kohlbecker
  );
709
  $ext_links_default["tropicos"] = array(
710 82e80b81 Andreas Kohlbecker
    'id' => "tropicos",
711 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.tropicos.org/NameSearch.aspx?name=',
712
    'title' => 'Search Tropicos...',
713
    'glue' => '+',
714
    'weight' => 0,
715
    'status' => 1,
716
    'category' => 'Specimens/Occurrences',
717 6657531f Andreas Kohlbecker
  );
718
  $ext_links_default["ncbi"] = array(
719 82e80b81 Andreas Kohlbecker
    'id' => "ncbi",
720 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.ncbi.nlm.nih.gov/gquery/gquery.fcgi?term=',
721
    'title' => 'Search NCBI...',
722
    'glue' => '+AND+',
723
    'weight' => 0,
724
    'status' => 1,
725
    'category' => 'Molecular Resources',
726 6657531f Andreas Kohlbecker
  );
727
  $ext_links_default["google"] = array(
728 82e80b81 Andreas Kohlbecker
    'id' => "google",
729 ecd1141f Andreas Kohlbecker
    'link' => 'http://images.google.com/images?q=',
730
    'title' => 'Search Google Images...',
731
    'glue' => '+',
732
    'weight' => 0,
733
    'status' => 1,
734
    'category' => 'Images',
735 6657531f Andreas Kohlbecker
  );
736
  $ext_links_default["flickr"] = array(
737 82e80b81 Andreas Kohlbecker
    'id' => "flickr",
738 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.flickr.com/search/?w=all&q=',
739
    'title' => 'Search flickr...',
740
    'glue' => '+',
741
    'weight' => 0,
742
    'status' => 1,
743
    'category' => 'Images',
744 6657531f Andreas Kohlbecker
  );
745
  $ext_links_default["scholar"] = array(
746 82e80b81 Andreas Kohlbecker
    'id' => "scholar",
747 ecd1141f Andreas Kohlbecker
    'link' => 'http://scholar.google.de/scholar?hl=de&btnG=Suche&lr=&as_ylo=&as_vis=0&q=',
748
    'title' => 'Search Google scholar...',
749
    'glue' => '+',
750
    'weight' => 0,
751
    'status' => 1,
752
    'category' => 'Literature',
753 6657531f Andreas Kohlbecker
  );
754
  $ext_links_default["bhl"] = array(
755 82e80b81 Andreas Kohlbecker
    'id' => "bhl",
756 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.biodiversitylibrary.org/Search.aspx?searchCat=&searchTerm=',
757
    'title' => 'Search BHL...',
758
    'glue' => ' ',
759
    'weight' => 0,
760
    'status' => 1,
761
    'category' => 'Literature',
762 6657531f Andreas Kohlbecker
  );
763
  $ext_links_default["arkive"] = array(
764 82e80b81 Andreas Kohlbecker
    'id' => "arkive",
765 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.arkive.org/search.html?q=',
766
    'title' => 'Search ARKive...',
767
    'glue' => '+',
768
    'weight' => 0,
769
    'status' => 1,
770
    'category' => 'Images',
771 6657531f Andreas Kohlbecker
  );
772
  $ext_links_default["herbcat"] = array(
773 82e80b81 Andreas Kohlbecker
    'id' => "herbcat",
774 ecd1141f Andreas Kohlbecker
    'link' => 'http://apps.kew.org/herbcat/getHomePageResults.do?homePageSearchText=',
775
    'title' => 'Search Kew Herbarium Catalogue...',
776
    'glue' => '+',
777
    'weight' => 0,
778
    'status' => 1,
779
    'category' => 'Specimens/Occurrences',
780 6657531f Andreas Kohlbecker
  );
781
  $ext_links_default["iucn"] = array(
782 82e80b81 Andreas Kohlbecker
    'id' => "iucn",
783 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.iucnredlist.org/',
784
    'title' => 'Go to IUCN Red List...',
785
    'glue' => ' ',
786
    'weight' => 0,
787
    'status' => 1,
788
    'category' => 'Conservation',
789 6657531f Andreas Kohlbecker
  );
790
  $ext_links_default["ipni"] = array(
791 82e80b81 Andreas Kohlbecker
    'id' => "ipni",
792 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.ipni.org/ipni/advPlantNameSearch.do?',
793
    'title' => 'Search IPNI...',
794
    'glue' => '&',
795
    'weight' => 0,
796
    'status' => 1,
797
    'category' => 'Classification',
798 6657531f Andreas Kohlbecker
  );
799
  $ext_links_default["wcsp"] = array(
800 82e80b81 Andreas Kohlbecker
    'id' => "wcsp",
801 ecd1141f Andreas Kohlbecker
    'link' => 'http://wcsp.science.kew.org/qsearch.do?plantName=',
802
    'title' => 'Search World Checklist Monocots...',
803
    'glue' => ' ',
804
    'weight' => 0,
805
    'status' => 1,
806
    'category' => 'Classification',
807 6657531f Andreas Kohlbecker
  );
808
  $ext_links_default["tpl"] = array(
809 82e80b81 Andreas Kohlbecker
    'id' => "tpl",
810 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.theplantlist.org/tpl/search?q=',
811
    'title' => 'Search The Plant List...',
812
    'glue' => '+',
813
    'weight' => 0,
814
    'status' => 1,
815
    'category' => 'Classification',
816 6657531f Andreas Kohlbecker
  );
817
  $ext_links_default["eol"] = array(
818 deba3cdd Andreas Kohlbecker
    'id' => "eol",
819 ecd1141f Andreas Kohlbecker
    'link' => 'http://eol.org/search/?q=',
820
    'title' => 'Search Encyclopaedia of Life...',
821
    'glue' => '+',
822
    'weight' => 0,
823
    'status' => 1,
824
    'category' => 'General',
825 6657531f Andreas Kohlbecker
  );
826
  $ext_links_default["jstor"] = array(
827 82e80b81 Andreas Kohlbecker
    'id' => "jstor",
828 ecd1141f Andreas Kohlbecker
    'link' => 'https://plants.jstor.org/search?filter=name&so=ps_group_by_genus_species+asc&Query=',
829
    'title' => 'Search JSTOR Plant Science...',
830
    'glue' => ' ',
831
    'weight' => 0,
832
    'status' => 1,
833
    'category' => 'General',
834 6657531f Andreas Kohlbecker
  );
835
  $ext_links_default["epic"] = array(
836 82e80b81 Andreas Kohlbecker
    'id' => "epic",
837 ecd1141f Andreas Kohlbecker
    'link' => 'http://epic.kew.org/searchepic/summaryquery.do?scientificName=',
838
    'title' => 'Search ePIC...',
839
    'glue' => '+',
840
    'weight' => 0,
841
    'status' => 1,
842
    'category' => 'General',
843 6657531f Andreas Kohlbecker
  );
844
  $ext_links_default["fairchild"] = array(
845 82e80b81 Andreas Kohlbecker
    'id' => "fairchild",
846 ecd1141f Andreas Kohlbecker
    'link' => 'http://palmguide.org/palmsearch.php?query=',
847
    'title' => 'Search Fairchild Guide To Palms...',
848
    'glue' => '+',
849
    'weight' => 0,
850 82e80b81 Andreas Kohlbecker
    'status' => 0, //disabled since Fairchild Guide To Palms seems to be down
851 ecd1141f Andreas Kohlbecker
    'category' => 'Specimens/Occurrences',
852 6657531f Andreas Kohlbecker
  );
853 522a5b8c Andreas Kohlbecker
  $ext_links_default["ggbn"] = array(
854 82e80b81 Andreas Kohlbecker
    'id' => "ggbn",
855 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.ggbn.org/ggbn_portal/search/result?fullScientificName=',
856
    'title' => 'Search GGBN...',
857
    'glue' => '+',
858
    'weight' => 0,
859
    'status' => 1,
860
    'category' => 'Molecular Resources',
861 522a5b8c Andreas Kohlbecker
  );
862 6657531f Andreas Kohlbecker
  return $ext_links_default;
863
}