summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--timelinejs.module88
-rw-r--r--timelinejs.tpl.php16
-rw-r--r--timelinejs_json.tpl.php35
3 files changed, 139 insertions, 0 deletions
diff --git a/timelinejs.module b/timelinejs.module
index 2c7eaca..c42397d 100644
--- a/timelinejs.module
+++ b/timelinejs.module
@@ -5,6 +5,9 @@
* TimelineJS module.
*/
+/**
+ * Implements hook_field_info().
+ */
/*
function timelinejs_field_info() {
return array(
@@ -19,3 +22,88 @@ function timelinejs_field_info() {
);
}
*/
+
+/**
+ * Implements hook_node_view().
+ *
+ * @todo
+ */
+function timelinejs_node_view($node, $view_mode, $langcode) {
+ if ($node->type == 'timeline' && $view_mode == 'full') {
+ }
+}
+
+/**
+ * Implements hook_menu()
+ */
+function timelinejs_menu() {
+ $items['timelinejs/json'] = array(
+ 'page callback' => 'timelinejs_json',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['timeline'] = array(
+ 'page callback' => 'timelinejs',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+}
+
+/**
+ * Implements hook_theme()
+ */
+function timelinejs_theme($existing, $type, $theme, $path) {
+ return array(
+ 'timelinejs' => array(
+ 'template' => 'timelinejs',
+ 'variables' => array('timeline'),
+ ),
+ 'timelinejs_json' => array(
+ 'template' => 'timelinejs_json',
+ 'variables' => array('timeline'),
+ ),
+ );
+}
+
+/**
+ * Get a score nid from an issue nid.
+ */
+function timelinejs_load_events($nid) {
+ $query = db_select('field_data_field_timeline', 't');
+
+ // Basic query.
+ $query
+ ->fields('t', array('entity_id'))
+ ->condition('t.bundle', 'evento')
+ ->condition('t.field_timeline_target_id', $nid, '=');
+
+ $result = $query->execute();
+
+ return $result->fetchAll();
+}
+
+/**
+ * Menu callback.
+ *
+ * @todo
+ */
+function timelinejs_json($nid) {
+ // Sanitization and basic data.
+ $nid = (int) $nid;
+ $events = timelinejs_load_events($nid);
+
+ # Avoid themable output.
+ print theme('timelinejs', array('timeline' => array()));
+ exit;
+}
+
+/**
+ * Menu callback.
+ *
+ * @todo
+ */
+function timelinejs($path) {
+}
diff --git a/timelinejs.tpl.php b/timelinejs.tpl.php
new file mode 100644
index 0000000..0c1004a
--- /dev/null
+++ b/timelinejs.tpl.php
@@ -0,0 +1,16 @@
+<!-- BEGIN Timeline Embed -->
+<div id="timeline-embed" style="width:960px; height: 500px;"></div>
+<script type="text/javascript">
+ var timeline_config = {
+ width: "960px",
+ height: "500px",
+ source: '/sites/boletim/files/timeline-saude-indigena_2.json',
+ start_at_end: false,
+ hash_bookmark: true,
+ css: '/sites/boletim/themes/boletimclean/timeline.css',
+ js: '/sites/all/libraries/timelinejs/compiled/js/timeline.js',
+ lang: '/sites/all/libraries/timelinejs/compiled/js/locale/pt-br.js'
+ }
+</script>
+<script type="text/javascript" src="/sites/all/libraries/timelinejs/compiled/js/timeline-embed.js"></script>
+<!-- END Timeline Embed -->
diff --git a/timelinejs_json.tpl.php b/timelinejs_json.tpl.php
new file mode 100644
index 0000000..68cfcbb
--- /dev/null
+++ b/timelinejs_json.tpl.php
@@ -0,0 +1,35 @@
+<?php
+
+ global $base_url;
+
+?>
+{
+ "timeline":
+ {
+ "headline":"<?php print $headline; ?>",
+ "type":"default",
+ "startDate":"<?php print $date; ?>",
+ "text":"<?php print $text; ?>",
+ "asset":
+ {
+ "media":"<?php print $media; ?>",
+ "credit":"",
+ "caption":""
+ },
+<?php foreach ($events as $event) { ?>
+ "date": [
+ {
+ "startDate":"<?php print $event['date']; ?>",
+ "headline":"<?php print $event['headline']; ?>",
+ "text":"<?php print $event['text']; ?>",
+ "asset":
+ {
+ "media":"<?php print $event['media']; ?>",
+ "credit":"",
+ "caption":""
+ }
+ },
+ ]
+<?php } ?>
+ }
+}