summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--timelinejs.module25
1 files changed, 22 insertions, 3 deletions
diff --git a/timelinejs.module b/timelinejs.module
index fbb2caf..f8ea9f6 100644
--- a/timelinejs.module
+++ b/timelinejs.module
@@ -186,20 +186,39 @@ function timelinejs_widget($nid = NULL, $width = '960px', $height = '500px') {
/**
* Menu callback.
*/
-function timelinejs($nid, $width = '960px', $height = '500px') {
+function timelinejs($nid = NULL, $width = '960px', $height = '500px') {
global $language;
global $theme;
global $base_url;
+ if ($nid == NULL) {
+ drupal_not_found();
+ }
+
+ $node = node_load($nid);
$theme_path = drupal_get_path('theme', $theme);
$library_path = libraries_get_path('timelinejs');
- $css = (file_exists($theme_path .'/timeline.css')) ? '/'. $theme_path .'/timeline.css' : '/'. $library_path .'/compiled/css/timeline.css';
+ // Determine stylesheet
+ if (file_exists($theme_path .'/timeline.css')) {
+ $css = '/'. $theme_path .'/timeline.css';
+ }
+ else {
+ $css = '/'. $library_path .'/compiled/css/timeline.css';
+ }
+
+ // Determine data source
+ if (isset($node->field_source['und'][0]['value'])) {
+ $source = $node->field_source['und'][0]['value'];
+ }
+ else {
+ $source = $base_url .'/timelinejs/json/'. (int) $nid;
+ }
return theme('timelinejs', array(
'width' => $width,
'height' => $height,
- 'source' => $base_url .'/timelinejs/json/'. (int) $nid,
+ 'source' => $source,
'css' => $css,
'lang' => '/'. $library_path .'/compiled/js/locale/'. $language->language .'.js',
'library_path' => $library_path,