Project

General

Profile

Download (2.24 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2

    
3
define(NODETYPE_TAXON, 'taxon');
4
define(NODETYPE_MEDIA, 'media');
5
define(NODETYPE_REFERENCE, 'reference');
6

    
7
/**
8
 * Implementation of hook_node_info().
9
 */
10
function cdm_dataportal_node_info() {
11
  
12
  static $nodetypes;
13
  if(!$nodetype){
14
    $nodetypes = array(NODETYPE_REFERENCE, NODETYPE_TAXON, NODETYPE_MEDIA); 
15
  }
16
  
17
  $nodeinfo = array();
18
  foreach( $nodetypes as $type){
19
    $nodeinfo['cdm_'.$type] = array(
20
      'name' => t(ucfirst($type)),
21
      'has_title' => TRUE,
22
      'module' => 'cdm_dataportal',
23
      'description' => t('Node type with reflects cdm entities of the type' . $type . '.')
24
    );
25
  }
26
  
27
  return $nodeinfo;
28
}
29

    
30
/**
31
 *  Implementation of hook_form()
32
 */
33
function cdm_dataportal_form(&$node) {
34
  
35
  $type = node_get_types('type', $node);
36
  
37
  if(is_numeric($node->nid)){
38
    $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', NULL, NULL, TRUE);   
39
  } else {
40
    $cdm_node_notice = t('You cannot manually create a node of type ').$type->name . '. '. t('This node type is only created internally');
41
  }
42
  $form['cdm'] = array(
43
    '#value' => '<div class="cdm_node_notice warning">' . $cdm_node_notice . '</div>',
44
    '#weight' => -5
45
  );
46
  // We need to define form elements for the node's title and body.
47
  $form['title'] = array(
48
    '#type' => 'textfield',
49
    '#title' => check_plain($type->title_label),
50
    '#required' => TRUE,
51
    '#disabled' => TRUE,
52
    '#default_value' => $node->title,
53
    '#weight' => -5
54
  );
55
  
56
  return $form;
57
}
58

    
59

    
60
/**
61
 * Implementation of hook_nodeapi().
62
 */
63
function cdm_dataportal_nodeapi(&$node, $op, $teaser, $page) {
64
  switch ($op) {
65
    case 'view':
66
      switch($node->type){
67
        case 'cdm_'.NODETYPE_TAXON : 
68
          if(arg(0) == 'node'){
69
            $cdmnode = db_fetch_object(db_query('SELECT * FROM {node_cdm} WHERE nid = \'%d\''
70
              , $node->nid));
71
            $taxonpage = cdm_dataportal_taxon_view($cdmnode->uuid);
72
            drupal_set_title($taxonpage->title);
73
            cdm_add_node_content($node, $taxonpage->content, variable_get('cdm_content_weight', -1));
74
          }
75
          break;
76
      }
77
      break;   
78
  }
79
}
(10-10/10)