summaryrefslogtreecommitdiff
path: root/timelinejs.module
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2014-11-17 16:20:23 -0200
committerSilvio <silvio@socioambiental.org>2014-11-17 16:20:23 -0200
commit2a9a1e7982245f48a51a36a6c02242f34d4e6324 (patch)
treedf6fd0a036e961d0ab6c679399133ae9478b5066 /timelinejs.module
parente586f688fd957969f0a49a9bc38cf2a390fe1747 (diff)
downloadtimelinejs-2a9a1e7982245f48a51a36a6c02242f34d4e6324.tar.gz
timelinejs-2a9a1e7982245f48a51a36a6c02242f34d4e6324.tar.bz2
Date format support
Diffstat (limited to 'timelinejs.module')
-rw-r--r--timelinejs.module19
1 files changed, 13 insertions, 6 deletions
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);
}