array( 'label' => t('TimelineJS item'), 'description' => t('An item in a timeline'), 'settings' => array(), 'instance_settings' => array(), 'default_widget' => 'timelinejs_item', 'default_formatter' => 'timelinejs_default', ), ); } */ /** * Implements hook_node_view(). */ function timelinejs_node_view($node, $view_mode, $langcode) { if ($node->type == 'timeline' && $view_mode == 'full') { $node->content['timeline']['#markup'] = timelinejs($node->nid); } } /** * Implements hook_node_view_alter. */ function timelinejs_node_view_alter(&$build) { } /** * 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( 'width' => NULL, 'height' => NULL, 'source' => NULL, 'start_at_end' => 'false', 'hash_bookmark' => 'true', 'css' => NULL, 'js' => '/sites/all/libraries/timelinejs/compiled/js/timeline.js', 'lang' => '/sites/all/libraries/timelinejs/compiled/js/locale/pt-br.js', ), ), 'timelinejs_json' => array( 'template' => 'timelinejs_json', 'variables' => array('headline', 'date', 'text', 'media', 'events'), ), 'timelinejs_json_event' => array( 'template' => 'timelinejs_json_event', 'variables' => array('event'), ), ); } /** * 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; $nodes = timelinejs_load_events($nid); $items = array(); foreach ($items as $event) { $events[] = theme('timelinejs_json_event', array('event' => $event)); $events = implode(',', $events); } print theme('timelinejs_json', array( 'headline' => $headline, 'date' => $date, 'text' => $text, 'media' => $media, 'events' => $events, )); # Avoid themable output. exit; } /** * Menu callback. */ function timelinejs($nid) { return theme('timelinejs', array( 'width' => '960px', 'height' => '500px', 'source' => '/sites/boletim/files/timeline-saude-indigena_2.json', //'source' => '/timelinejs/json/'. (int) $nid, 'css' => '/sites/boletim/themes/boletimclean/timeline.css' )); }