From 149097510754e175ab93fc9fa8844999713269fb Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 31 Jul 2012 18:37:58 -0300 Subject: Starting to code a dynamic timeline --- timelinejs.module | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'timelinejs.module') diff --git a/timelinejs.module b/timelinejs.module index 2c7eaca..c42397d 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -5,6 +5,9 @@ * TimelineJS module. */ +/** + * Implements hook_field_info(). + */ /* function timelinejs_field_info() { return array( @@ -19,3 +22,88 @@ function timelinejs_field_info() { ); } */ + +/** + * 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) { +} -- cgit v1.2.3