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
|
|
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
|
);
|
26
|
}
|
27
|
return $nodetypes;
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* Implements hook_node_info().
|
32
|
*/
|
33
|
function cdm_dataportal_node_info() {
|
34
|
$nodeinfo = array();
|
35
|
foreach (cdm_get_nodetypes() as $nodeType => $type) {
|
36
|
$nodeinfo[$nodeType] = array(
|
37
|
'name' => t('@type-name', array('@type-name' => ucfirst($type))),
|
38
|
'has_title' => TRUE,
|
39
|
'base' => 'cdm_dataportal',
|
40
|
'description' => t(
|
41
|
'This node type is being used internally to create peer nodes
|
42
|
in drupal for cdm entities of the type !type.', array('!type' => $type)),
|
43
|
);
|
44
|
}
|
45
|
|
46
|
return $nodeinfo;
|
47
|
}
|
48
|
|
49
|
/**
|
50
|
* Implements hook_form().
|
51
|
*/
|
52
|
function cdm_dataportal_form(&$node) {
|
53
|
|
54
|
$type = node_type_get_type($node);
|
55
|
|
56
|
if (is_numeric($node->nid)) {
|
57
|
$cdm_node_notice = t(
|
58
|
'In order to edit CDM content, please use the !taxEditor',
|
59
|
array(
|
60
|
'!taxEditor' => l(t('Taxonomic Editor'), 'http://dev.e-taxonomy.eu/trac/wiki/TaxonomicEditor', array('fragment' => TRUE))
|
61
|
)
|
62
|
);
|
63
|
}
|
64
|
else {
|
65
|
$cdm_node_notice = t('You cannot manually create a node of type @type-name. This node type is only created internally'
|
66
|
, array('@type-name' => $type->name));
|
67
|
}
|
68
|
$form['cdm'] = array(
|
69
|
'#value' => '<div class="cdm_node_notice warning">' . $cdm_node_notice . '</div>',
|
70
|
'#weight' => -5,
|
71
|
);
|
72
|
|
73
|
// We need to define form elements for the node's title and body.
|
74
|
$form['title'] = array(
|
75
|
'#type' => 'textfield',
|
76
|
'#title' => check_plain($type->title_label),
|
77
|
'#required' => TRUE,
|
78
|
'#disabled' => TRUE,
|
79
|
'#default_value' => $node->title,
|
80
|
'#weight' => -5,
|
81
|
);
|
82
|
|
83
|
return $form;
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @todo document this function.
|
88
|
*/
|
89
|
function cdm_get_nodetypes() {
|
90
|
$nodetypes = module_invoke_all('cdm_nodetypes');
|
91
|
return $nodetypes;
|
92
|
}
|