| 1 |
<?php
|
| 2 |
// $Id: timeline.theme.inc,v 1.13.2.1.2.5 2009/07/25 01:36:49 xamanu Exp $
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Theme functions for timeline.
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of template_process for views-view-timeline.
|
| 10 |
*/
|
| 11 |
function template_preprocess_views_view_timeline(&$vars) {
|
| 12 |
if(isset($vars['options']['debug'])) {
|
| 13 |
$vars['debug'] = theme('timeline_debug', $vars['options']['debug']);
|
| 14 |
}
|
| 15 |
// create actual timeline
|
| 16 |
if (_timeline_include($vars['options']['timeline']['theme'])) {
|
| 17 |
|
| 18 |
// preprocess css information for the template
|
| 19 |
$vars['id'] = $vars['view']->name;
|
| 20 |
$vars['class'] = $vars['view']->name;
|
| 21 |
$vars['height'] = $vars['options']['timeline']['height'];
|
| 22 |
$vars['width'] = $vars['options']['timeline']['width'];
|
| 23 |
$vars['controls'] = $vars['options']['misc']['controls'];
|
| 24 |
$vars['timeline_theme'] = $vars['options']['timeline']['theme'];
|
| 25 |
}
|
| 26 |
}
|
| 27 |
|
| 28 |
/**
|
| 29 |
* Inlude all js and css files that needs the timeline.
|
| 30 |
* Depending on the timeline views settings the external SIMILE server is used.
|
| 31 |
* Or otherwise a local installation.
|
| 32 |
*
|
| 33 |
* @return: TRUE if everything could be included properly
|
| 34 |
* FALSE if Simile Exhibit Libraries aren't found
|
| 35 |
*/
|
| 36 |
function _timeline_include($timeline_theme_name) {
|
| 37 |
$timeline_mod_path = drupal_get_path('module', 'timeline');
|
| 38 |
|
| 39 |
// Use SIMILE Server
|
| 40 |
if (variable_get('timeline_library_source', 'hosted') == 'hosted') {
|
| 41 |
$timeline_api = 'http://static.simile.mit.edu/timeline/api-2.3.0/timeline-api.js?bundle=true';
|
| 42 |
drupal_set_html_head('<script type="text/javascript" src="'. $timeline_api .'"></script>'); // We have to wait to D7 to get rid of this: #91250 - fd
|
| 43 |
}
|
| 44 |
elseif (variable_get('timeline_library_source', 'hosted') == 'local' && $message = timeline_validate_library()) {
|
| 45 |
$timeline_lib_path = libraries_get_path('simile_timeline');
|
| 46 |
drupal_add_js($timeline_mod_path . '/js/local.js');
|
| 47 |
drupal_add_js($timeline_lib_path . '/timeline_js/timeline-api.js');
|
| 48 |
}
|
| 49 |
else {
|
| 50 |
drupal_set_message(t('Simile Timeline Libraries not found'), 'error');
|
| 51 |
return FALSE;
|
| 52 |
}
|
| 53 |
|
| 54 |
drupal_add_css($timeline_mod_path . '/css/timeline.css');
|
| 55 |
|
| 56 |
// include custom theme files (if activated)
|
| 57 |
if ($timeline_theme_name != 'ClassicTheme' && $timeline_theme_name != FALSE) {
|
| 58 |
drupal_add_js($timeline_mod_path . '/themes/' . $timeline_theme_name . '/' . $timeline_theme_name . '.js');
|
| 59 |
drupal_add_css($timeline_mod_path . '/themes/' . $timeline_theme_name . '/' . $timeline_theme_name . '.css');
|
| 60 |
}
|
| 61 |
drupal_add_js($timeline_mod_path . '/js/timeline.js');
|
| 62 |
return TRUE;
|
| 63 |
}
|
| 64 |
|
| 65 |
/*
|
| 66 |
* Function to theme a textarea with a array inside
|
| 67 |
*/
|
| 68 |
function theme_timeline_debug($debug_array) {
|
| 69 |
$output = '<div id="timeline_debug">';
|
| 70 |
$output .= '<label><strong>DEBUG:</strong></label>';
|
| 71 |
$output .= '<div class="resizable-textarea"><textarea id="edit-code" class="form-textarea resizable textarea-processed" name="code" rows ="10" cols="60">';
|
| 72 |
$output .= var_export($debug_array, TRUE);
|
| 73 |
$output .= '</textarea></div></div>';
|
| 74 |
return $output;
|
| 75 |
}
|