summaryrefslogtreecommitdiff
path: root/timelinejs.module
diff options
context:
space:
mode:
Diffstat (limited to 'timelinejs.module')
-rw-r--r--timelinejs.module39
1 files changed, 33 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'));
+}