Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / node_types.php @ 6eaec849

History | View | Annotate | Download (2.43 KB)

1
<?php
2
/**
3
 * @file
4
 * Node type definitions.
5
 */
6

    
7
define('NODETYPE_TAXON', 'taxon');
8
define('NODETYPE_MEDIA', 'media');
9
define('NODETYPE_REFERENCE', 'reference');
10
define('NODETYPE_NAME', 'name');
11
define('NODETYPE_NAMED_AREA', 'named_area');
12
define('NODETYPE_SPECIMEN', 'specimen');
13
/**
14
 * Implements hook_cdm_nodetypes().
15
 */
16
function cdm_dataportal_cdm_nodetypes() {
17
  static $nodetypes;
18
  if (!$nodetypes) {
19
    $nodetypes = array(
20
      'cdm_' . NODETYPE_REFERENCE => NODETYPE_REFERENCE,
21
      'cdm_' . NODETYPE_TAXON => NODETYPE_TAXON,
22
      'cdm_' . NODETYPE_MEDIA => NODETYPE_MEDIA,
23
      'cdm_' . NODETYPE_NAME => NODETYPE_NAME,
24
      'cdm_' . NODETYPE_NAMED_AREA => NODETYPE_NAMED_AREA,
25
      'cdm_' . NODETYPE_SPECIMEN => NODETYPE_SPECIMEN,
26
    );
27
  }
28
  return $nodetypes;
29
}
30

    
31
/**
32
 * Implements hook_node_info().
33
 */
34
function cdm_dataportal_node_info() {
35
  $nodeinfo = array();
36
  foreach (cdm_get_nodetypes() as $nodeType => $type) {
37
    $nodeinfo[$nodeType] = array(
38
      'name' => t('@type-name', array('@type-name' => ucfirst($type))),
39
      'has_title' => TRUE,
40
      'base' => 'cdm_dataportal',
41
      'description' => t(
42
        'This node type is being used internally to create peer nodes
43
         in drupal for cdm entities of the type !type.', array('!type' => $type)),
44
    );
45
  }
46

    
47
  return $nodeinfo;
48
}
49

    
50
/**
51
 * Implements hook_form().
52
 */
53
function cdm_dataportal_form(&$node) {
54

    
55
  $type = node_type_get_type($node);
56

    
57
  if (is_numeric($node->nid)) {
58
    $cdm_node_notice = t(
59
      'In order to edit CDM content, please use the !taxEditor',
60
      array(
61
        '!taxEditor' => l(t('Taxonomic Editor'), 'http://dev.e-taxonomy.eu/trac/wiki/TaxonomicEditor', array('fragment' => TRUE))
62
      )
63
    );
64
  }
65
  else {
66
    $cdm_node_notice = t('You cannot manually create a node of type @type-name. This node type is only created internally'
67
      , array('@type-name' => $type->name));
68
  }
69
  $form['cdm'] = array(
70
    '#value' => '<div class="cdm_node_notice warning">' . $cdm_node_notice . '</div>',
71
    '#weight' => -5,
72
  );
73

    
74
  // We need to define form elements for the node's title and body.
75
  $form['title'] = array(
76
    '#type' => 'textfield',
77
    '#title' => check_plain($type->title_label),
78
    '#required' => TRUE,
79
    '#disabled' => TRUE,
80
    '#default_value' => $node->title,
81
    '#weight' => -5,
82
  );
83

    
84
  return $form;
85
}
86

    
87
/**
88
 * @todo document this function.
89
 */
90
function cdm_get_nodetypes() {
91
  $nodetypes = module_invoke_all('cdm_nodetypes');
92
  return $nodetypes;
93
}
Add picture from clipboard (Maximum size: 40 MB)