-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_timeline.module
73 lines (64 loc) · 1.97 KB
/
simple_timeline.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @file
* simple_timeline.module
* Created by JetBrains PhpStorm.
* User: alan
*/
/**
* Implements hook_views_api().
*/
function simple_timeline_views_api() {
return array(
'api' => '3.0',
'path' => backdrop_get_path('module', 'simple_timeline'),
'template_path' => backdrop_get_path('module', 'simple_timeline')
);
}
/**
* Implements hook_theme().
*/
function simple_timeline_theme() {
return array(
'simple_timeline_fields' => array(
'arguments' => array('plugin' => NULL, 'input' => NULL),
'path' => backdrop_get_path('module', 'simple_timeline'),
'template' => 'simple-timeline-fields',
),
);
}
/**
* Implements template_preprocess_hook().
*
* @param array $vars
* The variables that will be passed to the template.
*/
function template_preprocess_simple_timeline_fields(&$vars) {
$view = & $vars['view'];
$options = $vars['options'];
$vars['simple_timeline_date'] = $vars['simple_timeline_text'] = array();
$vars['simple_timeline_image'] = NULL;
foreach ($view->field as $id => $field) {
$field_output = $view->field[$id]->theme($vars['row']);
if (in_array($id, array_filter($options['simple_timeline_date']))) {
$vars['simple_timeline_date'][] = $field_output;
}
if (in_array($id, array_filter($options['simple_timeline_text']))) {
$vars['simple_timeline_text'][] = $field_output;
}
if ($id == $options['simple_timeline_image']) {
$vars['simple_timeline_image'] = $field_output;
}
}
$vars['simple_timeline_date'] = implode($options['simple_timeline_date_separator'], $vars['simple_timeline_date']);
$vars['simple_timeline_text'] = implode($options['simple_timeline_text_separator'], $vars['simple_timeline_text']);
}
/**
* Implements hook_autoload_info().
*/
function simple_timeline_autoload_info() {
return array(
'simple_timeline_row_plugin' => 'simple_timeline_row_plugin.inc',
'simple_timeline_style_plugin' => 'simple_timeline_style_plugin.inc',
);
}