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