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 +++++++++++++++++++++++++++++++++++++++++++++++++ timelinejs.tpl.php | 16 +++++++++ timelinejs_json.tpl.php | 35 ++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 timelinejs.tpl.php create mode 100644 timelinejs_json.tpl.php 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) { +} diff --git a/timelinejs.tpl.php b/timelinejs.tpl.php new file mode 100644 index 0000000..0c1004a --- /dev/null +++ b/timelinejs.tpl.php @@ -0,0 +1,16 @@ + +
+ + + diff --git a/timelinejs_json.tpl.php b/timelinejs_json.tpl.php new file mode 100644 index 0000000..68cfcbb --- /dev/null +++ b/timelinejs_json.tpl.php @@ -0,0 +1,35 @@ + +{ + "timeline": + { + "headline":"", + "type":"default", + "startDate":"", + "text":"", + "asset": + { + "media":"", + "credit":"", + "caption":"" + }, + + "date": [ + { + "startDate":"", + "headline":"", + "text":"", + "asset": + { + "media":"", + "credit":"", + "caption":"" + } + }, + ] + + } +} -- cgit v1.2.3