/[drupal]/contributions/modules/timeline/timeline.module
ViewVC logotype

Contents of /contributions/modules/timeline/timeline.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.22 - (show annotations) (download) (as text)
Sat Jul 25 02:14:49 2009 UTC (4 months ago) by xamanu
Branch: MAIN
CVS Tags: HEAD
Changes since 1.21: +14 -2 lines
File MIME type: text/x-php
Bringing HEAD in sync with the DRUPAL-6--2 branch
1 <?php
2 // $Id: timeline.module,v 1.20.2.6.2.4 2009/07/25 01:36:49 xamanu Exp $
3
4 /**
5 * @file
6 * Module providing a scrollable timeline view for Drupal events and nodes.
7 */
8
9 include dirname(__FILE__) .'/timeline.theme.inc';
10
11
12 /**
13 * Implementation of hook_help(). Provides online user help.
14 */
15 function timeline_help($section) {
16 switch ($section) {
17 case 'admin/modules#name':
18 return t('timeline');
19 case 'admin/modules#description':
20 return t('Provides a draggable and scrollable timeline view. Requires the
21 views module and the libraries module and makes use of the cck and date module if available.');
22 case 'admin/settings/timeline':
23 if (module_exists('views_ui'))
24 $timeline_route = t('To actually create and manage timelines, use the <a href="!views">views administration</a> screen.</p>', array('!views' => url('admin/build/views')));
25 else
26 $timeline_route = t('To actually create and manage timelines, enable the Views UI module in the <a href="!modules">modules administration</a> screen.</p>', array('!modules' => url('admin/build/modules')));
27 return t('<p>Timeline views provides a draggable and scrollable widget for
28 visualizing temporal information. This screen allows you to
29 override default settings for each timeline. ' . $timeline_route);
30 }
31 }
32
33 /**
34 * Implementation of hook_views_api().
35 */
36 function timeline_views_api() {
37 return array('api' => 2);
38 }
39
40 /**
41 * Implementation of hook_theme()
42 */
43 function timeline_theme() {
44 return array(
45 'timeline_debug' => array(
46 'arguments' => array('$debug_array'),
47 ),
48 );
49 }
50
51 /**
52 * Implementation of hook_menu(). Defines menu items and page callbacks.
53 */
54 function timeline_menu() {
55 $items = array();
56 $items['admin/settings/timeline'] = array(
57 'title' => 'Timeline',
58 'description' => 'Settings for timeline displays',
59 'page callback' => 'drupal_get_form',
60 'page arguments' => array('timeline_admin_settings'),
61 'access callback' => 'user_access',
62 'access arguments' => array('administer site configuration'),
63 'type' => MENU_NORMAL_ITEM,
64 'file' => 'timeline.admin.inc',
65 );
66 return $items;
67 }
68
69 /**
70 * Converts different expected date formats to one global date format to talk to the timeline.
71 *
72 * @return
73 * date in defined output
74 */
75 function timeline_date_conversion($date, $input_format, $output_format = "Y-m-d\TH:i:s") {
76
77 switch ($input_format) {
78 case 'date':
79 if ($output_format == 'timestamp') return date_convert($date, DATE_ISO, DATE_UNIX);
80 return format_date(date_convert($date, DATE_ISO, DATE_UNIX), 'timestamp', $output_format);
81 case 'datetime':
82 if ($output_format == 'timestamp') return date_convert($date, DATE_DATETIME, DATE_UNIX);
83 return format_date(date_convert($date, DATE_DATETIME, DATE_UNIX), 'timestamp', $output_format);
84 case 'datestamp':
85 case 'timestamp':
86 if ($output_format == 'timestamp') return $date;
87 return format_date($date, 'timestamp', $output_format);
88 }
89 }
90
91
92 /**
93 * Check if all library files properly exist.
94 *
95 * @return: TRUE if everything is correct
96 * FALSE if no library was found
97 * string: with an error message of the missing file.
98 */
99 function timeline_validate_library() {
100 if (module_exists('libraries')) {
101 $timeline_path = libraries_get_path('simile_timeline');
102 $timeline_library_files = array(
103 '/timeline_js/timeline-api.js',
104 '/timeline_js/timeline-bundle.js',
105 '/timeline_ajax/simile-ajax-api.js',
106 '/timeline_ajax/simile-ajax-bundle.js',
107 '/timeline_ajax/scripts/signal.js',
108 );
109 // check if library is available 'sites/all/libraries/simile_timeline'
110 if (file_check_directory($timeline_path)) {
111 $messages = '';
112 foreach ($timeline_library_files as $file) {
113 $file = $timeline_path . $file;
114 if (!file_exists($file)) {
115 $messages .= '<div>' . t('Error: !timeline_filename not found</div>', array('!timeline_filename' => '<span class="error">' . $file . '</span>'));
116 }
117 }
118 // no errors found
119 if ($messages == '')
120 return TRUE;
121 else
122 return $messages;
123 }
124 }
125 // no library found
126 return FALSE;
127 }
128
129 /**
130 * Scans the themes directory to include more themes
131 *
132 * @return
133 * array with the filenames of found theme files plus the classic theme
134 *
135 */
136 function timeline_available_themes() {
137 $timeline_theme_names = array('ClassicTheme' => 'ClassicTheme');
138 $timeline_theme_path = drupal_get_path('module', 'timeline') .'/themes';
139 foreach (file_scan_directory($timeline_theme_path, '.*', array('.', '..', 'CVS'), 0, FALSE) as $timeline_theme) {
140 if (is_dir($timeline_theme_path . '/' . $timeline_theme->basename)) {
141 $timeline_theme_names[$timeline_theme->basename] = $timeline_theme->basename;
142 }
143 }
144 return $timeline_theme_names;
145 }
146
147 // TODO: REMOVE - jm
148 function _timeline_to_dim($string) {
149 return intval($string) . (strpos($string, '%') !== FALSE ? '%' : 'px');
150 }

  ViewVC Help
Powered by ViewVC 1.1.2