summaryrefslogtreecommitdiff
path: root/timelinejs.module
blob: c42397df3d7e4b454a671e9971f6da6ffa64fc12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php

/**
 * @file
 * TimelineJS module.
 */

/**
 * Implements hook_field_info().
 */
/*
function timelinejs_field_info() {
  return array(
    'timelinejs' => array(
      'label'             => t('TimelineJS item'),
      'description'       => t('An item in a timeline'),
      'settings'          => array(),
      'instance_settings' => array(),
      'default_widget'    => 'timelinejs_item',
      'default_formatter' => 'timelinejs_default',
    ),
  );
}
 */

/**
 * Implements hook_node_view().
 *
 * @todo
 */
function timelinejs_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'timeline' && $view_mode == 'full') {
  }
}

/**
 * Implements hook_menu()
 */
function timelinejs_menu() {
  $items['timelinejs/json'] = array(
    'page callback'    => 'timelinejs_json',
    'access arguments' => array('access content'),
    'type'             => MENU_CALLBACK,
  );

  $items['timeline'] = array(
    'page callback'    => 'timelinejs',
    'access arguments' => array('access content'),
    'type'             => MENU_CALLBACK,
  );

  return $items;
}

/**
 * Implements hook_theme()
 */
function timelinejs_theme($existing, $type, $theme, $path) {
  return array(
    'timelinejs' => array(
      'template'  => 'timelinejs',
      'variables' => array('timeline'),
    ),
    'timelinejs_json' => array(
      'template'  => 'timelinejs_json',
      'variables' => array('timeline'),
    ),
  );
}

/**
 * Get a score nid from an issue nid.
 */
function timelinejs_load_events($nid) {
  $query = db_select('field_data_field_timeline', 't');

  // Basic query.
  $query
    ->fields('t', array('entity_id'))
    ->condition('t.bundle', 'evento')
    ->condition('t.field_timeline_target_id', $nid, '=');

  $result = $query->execute();

  return $result->fetchAll();
}

/**
 * Menu callback.
 * 
 * @todo
 */
function timelinejs_json($nid) {
  // Sanitization and basic data.
  $nid    = (int) $nid;
  $events = timelinejs_load_events($nid);

  # Avoid themable output.
  print theme('timelinejs', array('timeline' => array()));
  exit;
}

/**
 * Menu callback.
 *
 * @todo
 */
function timelinejs($path) {
}