From 2a9a1e7982245f48a51a36a6c02242f34d4e6324 Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 17 Nov 2014 16:20:23 -0200 Subject: Date format support --- timelinejs.module | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'timelinejs.module') diff --git a/timelinejs.module b/timelinejs.module index e6d5877..61b90fb 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -71,7 +71,7 @@ function timelinejs_theme($existing, $type, $theme, $path) { ), 'timelinejs_json_event' => array( 'template' => 'timelinejs_json_event', - 'variables' => array('event'), + 'variables' => array('event', 'date_format'), ), 'timelinejs_print' => array( 'template' => 'timelinejs_print', @@ -79,7 +79,7 @@ function timelinejs_theme($existing, $type, $theme, $path) { ), 'timelinejs_print_event' => array( 'template' => 'timelinejs_print_event', - 'variables' => array('event'), + 'variables' => array('event', 'date_format'), ), ); } @@ -115,9 +115,16 @@ function timelinejs_load_events($nid) { */ function timelinejs_fetch_items($nid, $format = 'json') { // Sanitization and basic data. - $nid = (int) $nid; - $timeline = node_load($nid); - $nodes = timelinejs_load_events($nid); + $nid = (int) $nid; + $timeline = node_load($nid); + $nodes = timelinejs_load_events($nid); + + if (isset($timeline->field_date_format['und'][0]['value'])) { + $date_format = $timeline->field_date_format['und'][0]['value']; + } + else { + $date_format = '%Y,%m,%d'; + } foreach ($nodes as $node) { $items[] = node_load($node->entity_id); @@ -135,7 +142,7 @@ function timelinejs_fetch_items($nid, $format = 'json') { $event->body['und'] = NULL; } - $output[] = theme('timelinejs_' . $format . '_event', array('event' => $event)); + $output[] = theme('timelinejs_' . $format . '_event', array('event' => $event, 'date_format' => $date_format)); if ($format == 'json') { $events = implode(',', $output); } -- cgit v1.2.3