summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--timelinejs.module39
-rw-r--r--timelinejs_print.tpl.php9
-rw-r--r--timelinejs_print_event.tpl.php3
3 files changed, 45 insertions, 6 deletions
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 @@
+<!--<h2><?php print $headline; ?></h2>-->
+<h3><?php print $date; ?></h3>
+<h3><?php print $text; ?></h3>
+
+<?php print $media; ?>
+
+<ul>
+ <?php print $events; ?>
+</ul>
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 @@
+<li class="timeline">
+ <?php print strftime('%d/%m/%Y', strtotime($event->field_date['und'][0]['value'])); ?> - <?php print $event->title; ?>: <?php print $event->body['und'][0]['value']; ?>
+</li>