From 94dcb4ebd3fc3d0562c9c75b3182272c3e2cd2a7 Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 27 May 2013 17:26:16 -0300 Subject: Adding TimelineJS widget --- timelinejs.module | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/timelinejs.module b/timelinejs.module index 2923e5d..0b2397a 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -31,6 +31,12 @@ function timelinejs_menu() { 'type' => MENU_CALLBACK, ); + $items['widgets/timeline'] = array( + 'page callback' => 'timelinejs_widget', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + return $items; } @@ -145,6 +151,36 @@ function timelinejs_json($nid) { exit; } +/** + * Menu callback. + */ +function timelinejs_widget($nid = NULL, $width = '960px', $height = '500px') { + // Check parameters. + if ($nid == NULL) { + drupal_not_found(); + } + else { + $node = node_load($nid); + + if ($node == FALSE) { + drupal_not_found(); + } + } + + // Format output and include timeline. + $output = ''; + $output .= ''; + $output .= ''; + $output .= ''. t('Timeline: @title', array('@title' => $node->title)) .''; + $output .= ''; + $output .= timelinejs($nid, $width, $height); + $output .= ''; + + // Avoid themeable output. + print $output; + exit; +} + /** * Menu callback. */ -- cgit v1.2.3