Project

General

Profile

Download (25 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 019d69fa Andreas Kohlbecker
  $items['admin/config/cdm_dataportal/ext_links/appearance'] = [
72
    'title' => 'Appearance',
73
    'page callback' => 'drupal_get_form',
74
    'page arguments' => ['ext_links_admin_appearance_page'],
75
    'access arguments' => ['access administration pages'],
76
    'type' => MENU_LOCAL_TASK,
77
    'weight' => 2,
78
    'file' => 'ext_links.admin.inc',
79
  ];
80 deba3cdd Andreas Kohlbecker
  $items['admin/config/cdm_dataportal/ext_links/%ext_links'] = [ // %ext_links refers to ext_links_load
81
    'title' => 'Edit external link',
82 ecd1141f Andreas Kohlbecker
    'page callback' => 'ext_links_admin_link_template_page',
83
    'page arguments' => [4],
84
    'access arguments' => ['access administration pages'],
85
    'file' => 'ext_links.admin.inc',
86
  ];
87 b03fb28d Andreas Kohlbecker
  $items['admin/config/cdm_dataportal/ext_links/%ext_links/status/%'] = [
88
    'title' => 'Enable or disable external link',
89
    'page callback' => 'ext_links_admin_link_template_set_status',
90
    'page arguments' => [4, 6],
91
    'access arguments' => ['access administration pages'],
92
 //   'type' => MENU_CALLBACK,
93
    'file' => 'ext_links.admin.inc',
94
  ];
95 6657531f Andreas Kohlbecker
  return $items;
96 ecd1141f Andreas Kohlbecker
}
97
98
/**
99
 * Retrieves a list of External Link templates, ordered by weight.
100
 *
101 0e38f1bf Andreas Kohlbecker
 * Empty 'ext_links' tables will be initialized with the default templates.
102
 *
103
 * @see ext_links_template_defaults()
104
 *
105 019d69fa Andreas Kohlbecker
 * @param $enabled_only boolean
106
 *   When TRUE external link templates with status != null are excluded from the list.
107 0e38f1bf Andreas Kohlbecker
 * @return array
108 ecd1141f Andreas Kohlbecker
 *   An array of external link template objects, keyed by the format ID and ordered by
109
 *   weight.
110
 *
111
 */
112 019d69fa Andreas Kohlbecker
function ext_links_templates($enabled_only = FALSE) {
113 ecd1141f Andreas Kohlbecker
  global $language;
114
  $link_templates = &drupal_static(__FUNCTION__, array());
115
116
  // cache_clear_all("ext_links_templates:{$language->language}");
117
  // All available link_templates are cached for performance.
118
  if (!is_array($link_templates) || !count($link_templates)) {
119 0e38f1bf Andreas Kohlbecker
    if ($cache = cache_get("ext_links:{$language->language}")) {
120 ecd1141f Andreas Kohlbecker
      $link_templates = $cache->data;
121
    }
122
    else {
123 0e38f1bf Andreas Kohlbecker
      $test = false;
124 ecd1141f Andreas Kohlbecker
      if($test){
125
        $link_templates = [];
126
        $link_templates_arrays = ext_links_template_defaults();
127
        foreach($link_templates_arrays as $a){
128
          $link_templates[] = (object)$a;
129
        }
130
      } else {
131 019d69fa Andreas Kohlbecker
        $query = db_select('ext_links', 'elt')
132 ecd1141f Andreas Kohlbecker
          ->addTag('translatable')
133 019d69fa Andreas Kohlbecker
          ->fields('elt');
134
        if($enabled_only){
135
          $query = $query->condition('status', '1');
136
        }
137
        $link_templates =
138
          $query->orderBy('category')
139 ecd1141f Andreas Kohlbecker
          ->orderBy('weight')
140 0e38f1bf Andreas Kohlbecker
          ->execute()
141
          ->fetchAllAssoc('id');
142
      }
143
      if(!count($link_templates)) {
144
        $link_templates_arrays = ext_links_template_defaults();
145
        $query = db_insert('ext_links')
146
          ->fields(array_keys(array_values($link_templates_arrays)[0]));
147
        foreach($link_templates_arrays as $a){
148
          $query->values($a);
149
        }
150
        try {
151
          $query->execute();
152
        } catch (Exception $e) {
153
          drupal_set_message("Error while initializing ext_links database: " . $e->getMessage(), "error");
154
        }
155
        $link_templates = [];
156
        foreach($link_templates_arrays as $a){
157
          $link_templates[] = (object)$a;
158
        }
159 ecd1141f Andreas Kohlbecker
      }
160 0e38f1bf Andreas Kohlbecker
      // cache_set("ext_links:{$language->language}", $link_templates);
161 ecd1141f Andreas Kohlbecker
    }
162
  }
163
  return $link_templates;
164
}
165
166 82e80b81 Andreas Kohlbecker
/**
167
 * Resets the text format caches.
168
 *
169
 * @see filter_formats()
170
 */
171
function ext_links_templates_reset() {
172 0e38f1bf Andreas Kohlbecker
  cache_clear_all('ext_links', 'cache', TRUE);
173
  drupal_static_reset('ext_links');
174 82e80b81 Andreas Kohlbecker
}
175
176
/**
177
 * Loads a text format object from the database.
178
 *
179
 * @param $extlink_id
180
 *   The external link ID. ($link->id)
181
 *
182
 * @return
183
 *   A fully-populated text format object, if the requested format exists and
184
 *   is enabled. If the format does not exist, or exists in the database but
185
 *   has been marked as disabled, FALSE is returned.
186
 *
187
 * @see ext_links_exists()
188
 */
189
function ext_links_load($extlink_id) {
190 0e38f1bf Andreas Kohlbecker
  $test = false;
191 deba3cdd Andreas Kohlbecker
  if($test) {
192
    $defaults = ext_links_template_defaults();
193
    return isset($defaults[$extlink_id]) ? (object)$defaults[$extlink_id] : FALSE;
194
  }
195
  else {
196 0e38f1bf Andreas Kohlbecker
   $link_templates = ext_links_templates();
197
    return isset($link_templates[$extlink_id]) ? $link_templates[$extlink_id] : FALSE;
198 deba3cdd Andreas Kohlbecker
  }
199 82e80b81 Andreas Kohlbecker
}
200
201
/**
202
 * Saves a text format object to the database.
203
 *
204
 * @param $link_template
205
 *   A link template object having the properties:
206
 *   - id: The machine name of the external link. If this corresponds
207
 *     to an existing external link, this one will be updated;
208
 *     otherwise, a new external link will be created.
209
 *   - title: The link title
210
 *   - link: The link url template.
211
 *   - glue: The string to concatenate name parts in the URL query string.
212
 *   - status: (optional) An integer indicating whether the ext link is
213
 *     enabled (1) or not (0). Defaults to 1.
214
 *   - weight: (optional) The weight of the external link, which controls its
215
 *     placement in external link block. If omitted, the weight is set to 0.
216
 *     Defaults to NULL.
217
 *
218
 * @return
219
 *   SAVED_NEW or SAVED_UPDATED.
220
 */
221
function ext_links_save($link_template) {
222 0e38f1bf Andreas Kohlbecker
223 82e80b81 Andreas Kohlbecker
  $link_template->title = trim($link_template->title);
224
  $link_template->cache = true;
225
  if (!isset($link_template->status)) {
226
    $link_template->status = 1;
227
  }
228
  if (!isset($link_template->weight)) {
229
    $link_template->weight = 0;
230
  }
231
232
  // Insert or update the text format.
233
  $return = db_merge('ext_links')
234 0e38f1bf Andreas Kohlbecker
    ->key(array('id' => $link_template->id))
235 82e80b81 Andreas Kohlbecker
    ->fields(array(
236
      'id' => $link_template->id,
237
      'title' => $link_template->title,
238
      'link' => $link_template->link,
239
      'glue' => $link_template->glue,
240
      'status' => (int) $link_template->status,
241
      'weight' => (int) $link_template->weight,
242
    ))
243
    ->execute();
244
245
  ext_links_templates_reset();
246
  return $return;
247
}
248
249
/**
250
 * Determines if a external link exists.
251
 *
252
 * @param $ext_link_name
253
 *   The ID of the external link to check.
254
 *
255
 * @return
256
 *   TRUE if the external link exists, FALSE otherwise.
257
 *
258
 * @see ext_links_load()
259
 */
260
function ext_links_exists($ext_link_name) {
261
  return (bool) db_query_range('SELECT 1 FROM {ext_links} WHERE name = :name', 0, 1, array(':name' => $ext_link_name))->fetchField();
262
}
263
264
265
/**
266
 * Returns the genus and the first epithet from the object taxon.
267
 *
268
 * @param $taxon
269
 *   A CDM Taxon instance object
270
 * @return array
271
 *  An associate array with two elements:
272
 *     - genus: the uninomial
273
 *     - species: the species epithet
274
 */
275
function ext_link_species_name($taxon) {
276
  $speciesName = array();
277
  $i = 0;
278
  while (isset($taxon->name->taggedName[$i]) && !isset($speciesName['species'])) {
279
    if ($taxon->name->taggedName[$i]->type == "name") {
280
      if (!isset($speciesName['genus'])) {
281
        $speciesName['genus'] = $taxon->name->taggedName[$i]->text;
282
      }
283
      else {
284
        $speciesName['species'] = $taxon->name->taggedName[$i]->text;
285
      }
286
    }
287
    $i++;
288
  }
289
  return $speciesName;
290
}
291
292 6657531f Andreas Kohlbecker
/**
293
 * Implements hook_block_info().
294
 */
295
function ext_links_block_info() {
296
  if (TRUE) {
297 019d69fa Andreas Kohlbecker
    $block[0]["info"] = t("CDM - External Links");
298 6657531f Andreas Kohlbecker
    return $block;
299
  }
300
}
301
302
/**
303
 * Implements hook_block_view().
304
 */
305
function ext_links_block_view($delta) {
306
  // TODO Rename block deltas (e.g. '0') to readable strings.
307
  switch ($delta) {
308
    case '0':
309
      $block['subject'] = 'External links';
310
311 0af3ce28 Andreas Kohlbecker
      $uuid = get_current_taxon_uuid();
312
      if ($uuid) {
313 6657531f Andreas Kohlbecker
        $taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $uuid);
314
315
        // $taxon->titleCache;
316
        // var_export()
317
        if (!empty($taxon)) {
318
          drupal_add_js(drupal_get_path('module', 'ext_links') . '/ext_links.js');
319 82e80b81 Andreas Kohlbecker
          $speciesName = ext_link_species_name($taxon);
320 6657531f Andreas Kohlbecker
321
          $genus = $taxon->name->taggedName[0]->text;
322 e5f17100 Andreas Kohlbecker
          $species = null;
323
          if(isset($taxon->name->taggedName[1])){
324
            $species = $taxon->name->taggedName[1]->text;
325
          }
326 6657531f Andreas Kohlbecker
          $block_content = '';
327 019d69fa Andreas Kohlbecker
          $grouped = variable_get('ext_links_appearance_grouped', 1);
328
          if ($grouped) {
329 6657531f Andreas Kohlbecker
            $block['content'] = theme('ext_links_list_grouped', array('speciesName' => $speciesName, 'genus' => $genus, 'species' => $species));
330
          }
331
          else {
332
            $block['content'] = theme('ext_links_list_plain', array('speciesName' => $speciesName, 'genus' => $genus, 'species' => $species ));
333
          }
334
335
          // if(variable_get('ext_links_gbif_check', TRUE)) {
336
          // $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 />';
337
          /*
338
           $block_content .=
339
           /* TODO
340
           Please manually fix the parameters on the l() or url() function on the next line.
341
           Typically, this was not changed because of a function call inside an array call like
342
           array('title' => t('View user profile.')).
343
           l(variable_get('ext_links_gbif_text', $ext_links_default[gbif][text_default_value]),
344
           '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],
345
           array(), null, null, true);
346
           */
347
          /*}
348
           if(variable_get('ext_links_biocase_check', 1)) {
349
           $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 />';
350
           }
351
           if(variable_get('ext_links_nybg_check', 1)) {
352
           $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 />';
353
           }
354
           if(variable_get('ext_links_tropicos_check', 1)) {
355
           $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 />';
356
           }
357
           if(variable_get('ext_links_ncbi_check', 1)) {
358
           $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 />';
359
           }
360
           if(variable_get('ext_links_google_check', 1)) {
361
           $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 />';
362
           }
363
           if(variable_get('ext_links_flickr_check', 1)) {
364
           $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 />';
365
           }
366
           if(variable_get('ext_links_scholar_check', 1)) {
367
           $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 />';
368
           }
369
           if(variable_get('ext_links_bhl_check', 1)) {
370
           $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 />';
371
           }
372
373
           $block['content'] = $block_content;
374
           $block['content'] = theme('ext_links_list_plain');
375
376
           }
377
378
           }*/
379
          // if taxon
380
        }
381
      }
382
      // If path.
383
      return $block;
384
  } /* switch */
385
386
}
387
388 019d69fa Andreas Kohlbecker
/**
389
 * Applies the name tokens to the external link templates.
390
 *
391
 * @param $ext_link
392
 * @param $species_name
393
 *
394
 * @return array
395
 *  Array with the keys:
396
 *     - title: the title of the link
397
 *     - url: the url of the link
398
 */
399
function make_ext_link($ext_link, $species_name) {
400
  switch ($ext_link->id) {
401
    case 'nybg':
402
      if ($species_name['genus'] != NULL) {
403
        $query = 'DetFiledAsGenusLocal+%3D+\%27' . $species_name['genus'] . '\%27';
404
      }
405
      if ($species_name['species'] != NULL) {
406
        $query .= $ext_link->glue . 'DetFiledAsSpeciesLocal+%3D+\%27' . $species_name['species'] . '\%27';
407
      }
408
      break;
409
    case 'arkive':
410
      $postURL = '&output=xml_no_dtd&client=arkive-images&site=arkive-images&ie=utf8&oe=utf8&num=20&proxystylesheet=tng-search&filter=0&getfields=*';
411
      $query = str_replace('"', '%22', $species_name['genus']) . variable_get('ext_links_arkive_concat', '+') . str_replace('"', '%22', $species_name['species']) . $postURL;
412
      break;
413
    case 'herbcat':
414
      $postURL = '&x=11&y=13&homePageSearchOption=scientific_name&nameOfSearchPage=home_page';
415
      $query = str_replace('"', '%22', $species_name['genus']) . variable_get('ext_links_herbcat_concat', '+') . str_replace('"', '%22', $species_name['species']) . $postURL;
416
      break;
417
    case 'iucn':
418
    case 'wcsp':
419
      // apparently no search api, thus plain link without genus and species
420
      $query = '';
421
      break;
422
    case 'ipni':
423
      $query = 'find_genus=' . $species_name['genus'] . '&find_species=' . $species_name['species'];
424
      break;
425
    default:
426
      $query = str_replace('"', '%22', $species_name['genus']) . $ext_link->glue . str_replace('"', '%22', $species_name['species']);
427
  }
428
  $ext_link_array = [
429
    'title' => $ext_link->title,
430
    'url' => $ext_link->link . $query
431
  ];
432
  return $ext_link_array;
433
}
434
435 6657531f Andreas Kohlbecker
/**
436
 * @todo Please document this function.
437
 * @see http://drupal.org/node/1354
438
 */
439
function theme_ext_links_list_grouped($variables) {
440
441 019d69fa Andreas Kohlbecker
  $species_name = $variables['speciesName'];
442
  if(!isset($species_name['genus'])) {
443
    $species_name['genus'] = '';
444 6657531f Andreas Kohlbecker
  }
445 019d69fa Andreas Kohlbecker
  if(!isset($species_name['species'])) {
446
    $species_name['species'] = '';
447 6657531f Andreas Kohlbecker
  }
448
449 019d69fa Andreas Kohlbecker
  $ext_links = ext_links_templates(true);
450 6657531f Andreas Kohlbecker
451 019d69fa Andreas Kohlbecker
  $ext_links_by_category = [];
452 6657531f Andreas Kohlbecker
453 019d69fa Andreas Kohlbecker
  foreach ($ext_links as $ext_link) {
454
    if(!array_key_exists($ext_link->category, $ext_links_by_category)){
455
      $ext_links_by_category[$ext_link->category] = [];
456
    }
457
    $ext_link_render_array = make_ext_link($ext_link, $species_name);
458
    $ext_links_by_category[$ext_link->category][] = $ext_link_render_array;
459 6657531f Andreas Kohlbecker
  }
460
461 019d69fa Andreas Kohlbecker
  $block_content = '';
462
  foreach ($ext_links_by_category as $categoryTitle => $ext_links) {
463
    $block_content .= "<div class=\"category\"><h5>" . $categoryTitle . "</h5>\n";
464
    foreach($ext_links as $ext_link){
465
      $block_content .= l($ext_link['title'], 'JavaScript:popupExternalLinks(\'' . $ext_link['url'] . '\')', ['external' => TRUE]) .'<br />';
466 6657531f Andreas Kohlbecker
    }
467
    $block_content .= "</div>";
468
  }
469
470
  return $block_content;
471
}
472
473
/**
474
 * @todo Please document this function.
475
 * @see http://drupal.org/node/1354
476
 */
477
function theme_ext_links_list_plain($variables) {
478
  $speciesName = $variables['speciesName'];
479
  if (!isset($speciesName['genus'])) {
480
    $speciesName['genus'] = '';
481
  }
482
  if (!isset($speciesName['species'])) {
483
    $speciesName['species'] = '';
484
  }
485
486 019d69fa Andreas Kohlbecker
  $ext_links_templates = ext_links_templates(true);
487
  $block_content = '';
488
  foreach ($ext_links_templates as $ext_link) {
489
    $ext_link = make_ext_link($ext_link, $speciesName);
490
    $block_content .= l($ext_link['title'], 'JavaScript:popupExternalLinks(\'' . $ext_link['url'] . '\')', ['external' => TRUE]) .'<br />';
491 6657531f Andreas Kohlbecker
  }
492
  return $block_content;
493
}
494
495
/**
496
 * @todo Please document this function.
497
 * @see http://drupal.org/node/1354
498
 */
499
function ext_links_theme() {
500
  return array(
501
    'ext_links_list_grouped' => array('variables' => array(
502
      'speciesName' => NULL,
503
      'genus' => NULL,
504
      'species' => NULL,
505
      )),
506
    'ext_links_list_plain' => array('variables' => array(
507
      'speciesName' => NULL,
508
      'genus' => NULL,
509
      'species' => NULL,
510
      )),
511 ecd1141f Andreas Kohlbecker
    // theme_ext_links_admin_overview
512
    'ext_links_admin_overview' => array(
513
      'render element' => 'form',
514
      'file' => 'ext_links.admin.inc',
515
    ),
516
//    'ext_links_link_template_filter_order' => array(
517
//      'render element' => 'element',
518
//      'file' => 'ext_links.admin.inc',
519
//    ),
520 6657531f Andreas Kohlbecker
  );
521
}
522
523
/**
524
 * Get the default external links.
525
 *
526
 * @return array
527
 *   Returns an array with default external links values.
528
 */
529 ecd1141f Andreas Kohlbecker
function ext_links_template_defaults() {
530 6657531f Andreas Kohlbecker
  $ext_links_default["gbif"] = array(
531 82e80b81 Andreas Kohlbecker
    'id' => "gbif",
532 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.gbif.org/species/search?q=',
533
    'title' => 'Search GBIF...',
534
    'glue' => ' ',
535
    'weight' => 0,
536
    'status' => 1,
537
    'category' => 'Specimens/Occurrences',
538 6657531f Andreas Kohlbecker
  );
539
  $ext_links_default["biocase"] = array(
540 82e80b81 Andreas Kohlbecker
    'id' => "biocase",
541 ecd1141f Andreas Kohlbecker
    'link' => 'http://search.biocase.org/edit/search/units/simpleSearch/query1?unitName=',
542
    'title' => 'Search BioCASE...',
543
    'glue' => ' ',
544
    'weight' => 0,
545
    'status' => 1,
546
    'category' => 'Specimens/Occurrences',
547 6657531f Andreas Kohlbecker
  );
548
  $ext_links_default["nybg"] = array(
549 82e80b81 Andreas Kohlbecker
    'id' => "nybg",
550 ecd1141f Andreas Kohlbecker
    'link' => 'http://sweetgum.nybg.org/science/vh/specimen_list.php?SummaryData=',
551
    'title' => 'Search NYBG...',
552
    'glue' => '+AND+',
553
    'weight' => 0,
554
    'status' => 1,
555
    'category' => 'Specimens/Occurrences',
556 6657531f Andreas Kohlbecker
  );
557
  $ext_links_default["tropicos"] = array(
558 82e80b81 Andreas Kohlbecker
    'id' => "tropicos",
559 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.tropicos.org/NameSearch.aspx?name=',
560
    'title' => 'Search Tropicos...',
561
    'glue' => '+',
562
    'weight' => 0,
563
    'status' => 1,
564
    'category' => 'Specimens/Occurrences',
565 6657531f Andreas Kohlbecker
  );
566
  $ext_links_default["ncbi"] = array(
567 82e80b81 Andreas Kohlbecker
    'id' => "ncbi",
568 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.ncbi.nlm.nih.gov/gquery/gquery.fcgi?term=',
569
    'title' => 'Search NCBI...',
570
    'glue' => '+AND+',
571
    'weight' => 0,
572
    'status' => 1,
573
    'category' => 'Molecular Resources',
574 6657531f Andreas Kohlbecker
  );
575
  $ext_links_default["google"] = array(
576 82e80b81 Andreas Kohlbecker
    'id' => "google",
577 ecd1141f Andreas Kohlbecker
    'link' => 'http://images.google.com/images?q=',
578
    'title' => 'Search Google Images...',
579
    'glue' => '+',
580
    'weight' => 0,
581
    'status' => 1,
582
    'category' => 'Images',
583 6657531f Andreas Kohlbecker
  );
584
  $ext_links_default["flickr"] = array(
585 82e80b81 Andreas Kohlbecker
    'id' => "flickr",
586 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.flickr.com/search/?w=all&q=',
587
    'title' => 'Search flickr...',
588
    'glue' => '+',
589
    'weight' => 0,
590
    'status' => 1,
591
    'category' => 'Images',
592 6657531f Andreas Kohlbecker
  );
593
  $ext_links_default["scholar"] = array(
594 82e80b81 Andreas Kohlbecker
    'id' => "scholar",
595 ecd1141f Andreas Kohlbecker
    'link' => 'http://scholar.google.de/scholar?hl=de&btnG=Suche&lr=&as_ylo=&as_vis=0&q=',
596
    'title' => 'Search Google scholar...',
597
    'glue' => '+',
598
    'weight' => 0,
599
    'status' => 1,
600
    'category' => 'Literature',
601 6657531f Andreas Kohlbecker
  );
602
  $ext_links_default["bhl"] = array(
603 82e80b81 Andreas Kohlbecker
    'id' => "bhl",
604 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.biodiversitylibrary.org/Search.aspx?searchCat=&searchTerm=',
605
    'title' => 'Search BHL...',
606
    'glue' => ' ',
607
    'weight' => 0,
608
    'status' => 1,
609
    'category' => 'Literature',
610 6657531f Andreas Kohlbecker
  );
611
  $ext_links_default["arkive"] = array(
612 82e80b81 Andreas Kohlbecker
    'id' => "arkive",
613 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.arkive.org/search.html?q=',
614
    'title' => 'Search ARKive...',
615
    'glue' => '+',
616
    'weight' => 0,
617 019d69fa Andreas Kohlbecker
    'status' => 0,
618 ecd1141f Andreas Kohlbecker
    'category' => 'Images',
619 6657531f Andreas Kohlbecker
  );
620
  $ext_links_default["herbcat"] = array(
621 82e80b81 Andreas Kohlbecker
    'id' => "herbcat",
622 ecd1141f Andreas Kohlbecker
    'link' => 'http://apps.kew.org/herbcat/getHomePageResults.do?homePageSearchText=',
623
    'title' => 'Search Kew Herbarium Catalogue...',
624
    'glue' => '+',
625
    'weight' => 0,
626
    'status' => 1,
627
    'category' => 'Specimens/Occurrences',
628 6657531f Andreas Kohlbecker
  );
629
  $ext_links_default["iucn"] = array(
630 82e80b81 Andreas Kohlbecker
    'id' => "iucn",
631 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.iucnredlist.org/',
632
    'title' => 'Go to IUCN Red List...',
633
    'glue' => ' ',
634
    'weight' => 0,
635
    'status' => 1,
636
    'category' => 'Conservation',
637 6657531f Andreas Kohlbecker
  );
638
  $ext_links_default["ipni"] = array(
639 82e80b81 Andreas Kohlbecker
    'id' => "ipni",
640 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.ipni.org/ipni/advPlantNameSearch.do?',
641
    'title' => 'Search IPNI...',
642
    'glue' => '&',
643
    'weight' => 0,
644
    'status' => 1,
645
    'category' => 'Classification',
646 6657531f Andreas Kohlbecker
  );
647
  $ext_links_default["wcsp"] = array(
648 82e80b81 Andreas Kohlbecker
    'id' => "wcsp",
649 ecd1141f Andreas Kohlbecker
    'link' => 'http://wcsp.science.kew.org/qsearch.do?plantName=',
650
    'title' => 'Search World Checklist Monocots...',
651
    'glue' => ' ',
652
    'weight' => 0,
653
    'status' => 1,
654
    'category' => 'Classification',
655 6657531f Andreas Kohlbecker
  );
656
  $ext_links_default["tpl"] = array(
657 82e80b81 Andreas Kohlbecker
    'id' => "tpl",
658 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.theplantlist.org/tpl/search?q=',
659
    'title' => 'Search The Plant List...',
660
    'glue' => '+',
661
    'weight' => 0,
662
    'status' => 1,
663
    'category' => 'Classification',
664 6657531f Andreas Kohlbecker
  );
665
  $ext_links_default["eol"] = array(
666 deba3cdd Andreas Kohlbecker
    'id' => "eol",
667 ecd1141f Andreas Kohlbecker
    'link' => 'http://eol.org/search/?q=',
668
    'title' => 'Search Encyclopaedia of Life...',
669
    'glue' => '+',
670
    'weight' => 0,
671
    'status' => 1,
672
    'category' => 'General',
673 6657531f Andreas Kohlbecker
  );
674
  $ext_links_default["jstor"] = array(
675 82e80b81 Andreas Kohlbecker
    'id' => "jstor",
676 ecd1141f Andreas Kohlbecker
    'link' => 'https://plants.jstor.org/search?filter=name&so=ps_group_by_genus_species+asc&Query=',
677
    'title' => 'Search JSTOR Plant Science...',
678
    'glue' => ' ',
679
    'weight' => 0,
680
    'status' => 1,
681
    'category' => 'General',
682 6657531f Andreas Kohlbecker
  );
683
  $ext_links_default["epic"] = array(
684 82e80b81 Andreas Kohlbecker
    'id' => "epic",
685 ecd1141f Andreas Kohlbecker
    'link' => 'http://epic.kew.org/searchepic/summaryquery.do?scientificName=',
686
    'title' => 'Search ePIC...',
687
    'glue' => '+',
688
    'weight' => 0,
689
    'status' => 1,
690
    'category' => 'General',
691 6657531f Andreas Kohlbecker
  );
692
  $ext_links_default["fairchild"] = array(
693 82e80b81 Andreas Kohlbecker
    'id' => "fairchild",
694 ecd1141f Andreas Kohlbecker
    'link' => 'http://palmguide.org/palmsearch.php?query=',
695
    'title' => 'Search Fairchild Guide To Palms...',
696
    'glue' => '+',
697
    'weight' => 0,
698 82e80b81 Andreas Kohlbecker
    'status' => 0, //disabled since Fairchild Guide To Palms seems to be down
699 ecd1141f Andreas Kohlbecker
    'category' => 'Specimens/Occurrences',
700 6657531f Andreas Kohlbecker
  );
701 522a5b8c Andreas Kohlbecker
  $ext_links_default["ggbn"] = array(
702 82e80b81 Andreas Kohlbecker
    'id' => "ggbn",
703 ecd1141f Andreas Kohlbecker
    'link' => 'http://www.ggbn.org/ggbn_portal/search/result?fullScientificName=',
704
    'title' => 'Search GGBN...',
705
    'glue' => '+',
706
    'weight' => 0,
707
    'status' => 1,
708
    'category' => 'Molecular Resources',
709 522a5b8c Andreas Kohlbecker
  );
710 6657531f Andreas Kohlbecker
  return $ext_links_default;
711
}