summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-06-25 16:12:57 -0300
committerSilvio <silvio@socioambiental.org>2013-06-25 16:12:57 -0300
commit7127b6f8b7e40babc36c8392a2680e13bf702bd8 (patch)
tree9e16b1ae4f6d7e3eb9a4a990c5842b833898fc85
parentdce6099e6d78b79ff3413a6d9a61d9c526510e52 (diff)
downloadtimelinejs-7127b6f8b7e40babc36c8392a2680e13bf702bd8.tar.gz
timelinejs-7127b6f8b7e40babc36c8392a2680e13bf702bd8.tar.bz2
Allow different data sources
-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,