From 563f9f6ff1f294055b2fee95e5aee69905b2ff90 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 14 Aug 2012 13:37:43 -0300 Subject: Adding print templates --- timelinejs.module | 39 +++++++++++++++++++++++++++++++++------ timelinejs_print.tpl.php | 9 +++++++++ timelinejs_print_event.tpl.php | 3 +++ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 timelinejs_print.tpl.php create mode 100644 timelinejs_print_event.tpl.php diff --git a/timelinejs.module b/timelinejs.module index 731d459..9ca1985 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -60,6 +60,14 @@ function timelinejs_theme($existing, $type, $theme, $path) { 'template' => 'timelinejs_json_event', 'variables' => array('event'), ), + 'timelinejs_print' => array( + 'template' => 'timelinejs_print', + 'variables' => array('headline', 'date', 'text', 'media', 'events'), + ), + 'timelinejs_print_event' => array( + 'template' => 'timelinejs_print_event', + 'variables' => array('event'), + ), ); } @@ -81,9 +89,9 @@ function timelinejs_load_events($nid) { } /** - * Menu callback. + * Load all events from a timeline. */ -function timelinejs_json($nid) { +function timelinejs_fetch_items($nid, $format = 'json') { // Sanitization and basic data. $nid = (int) $nid; $timeline = node_load($nid); @@ -101,21 +109,33 @@ function timelinejs_json($nid) { } foreach ($items as $event) { - $output[] = theme('timelinejs_json_event', array('event' => $event)); - $events = implode(',', $output); + $output[] = theme('timelinejs_'. $format .'_event', array('event' => $event)); + if ($format == 'json') { + $events = implode(',', $output); + } + else { + $events = implode($output); + } } $text = $media = NULL; $headline = $timeline->title; $date = NULL; - print theme('timelinejs_json', array( + return array( 'headline' => $headline, 'date' => $date, 'text' => $text, 'media' => $media, 'events' => $events, - )); + ); +} + +/** + * Menu callback. + */ +function timelinejs_json($nid) { + print theme('timelinejs_json', timelinejs_fetch_items($nid)); # Avoid themable output. exit; @@ -139,3 +159,10 @@ function timelinejs($nid, $width = '960px', $height = '500px') { 'lang' => '/sites/all/libraries/timelinejs/compiled/js/locale/'. $language->language .'.js', )); } + +/** + * Menu callback. + */ +function timelinejs_print($nid) { + return theme('timelinejs_print', timelinejs_fetch_items($nid, 'print')); +} diff --git a/timelinejs_print.tpl.php b/timelinejs_print.tpl.php new file mode 100644 index 0000000..0bef881 --- /dev/null +++ b/timelinejs_print.tpl.php @@ -0,0 +1,9 @@ + +

+

+ + + + diff --git a/timelinejs_print_event.tpl.php b/timelinejs_print_event.tpl.php new file mode 100644 index 0000000..7a0bc7e --- /dev/null +++ b/timelinejs_print_event.tpl.php @@ -0,0 +1,3 @@ +
  • + field_date['und'][0]['value'])); ?> - title; ?>: body['und'][0]['value']; ?> +
  • -- cgit v1.2.3