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(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('In order to edit CDM content, please use the ') . l(t('Taxonomic Editor'), 'http://dev.e-taxonomy.eu/trac/wiki/TaxonomicEditor', array('fragment' => TRUE));
|
56
|
}
|
57
|
else {
|
58
|
$cdm_node_notice = t('You cannot manually create a node of type ') . $type->name . '. ' . t('This node type is only created internally');
|
59
|
}
|
60
|
$form['cdm'] = array(
|
61
|
'#value' => '<div class="cdm_node_notice warning">' . $cdm_node_notice . '</div>',
|
62
|
'#weight' => -5,
|
63
|
);
|
64
|
|
65
|
// We need to define form elements for the node's title and body.
|
66
|
$form['title'] = array(
|
67
|
'#type' => 'textfield',
|
68
|
'#title' => check_plain($type->title_label),
|
69
|
'#required' => TRUE,
|
70
|
'#disabled' => TRUE,
|
71
|
'#default_value' => $node->title,
|
72
|
'#weight' => -5,
|
73
|
);
|
74
|
|
75
|
return $form;
|
76
|
}
|
77
|
|
78
|
/**
|
79
|
* @todo document this function.
|
80
|
*/
|
81
|
function cdm_get_nodetypes() {
|
82
|
$nodetypes = module_invoke_all('cdm_nodetypes');
|
83
|
return $nodetypes;
|
84
|
}
|