-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews_plugin_style_fullcalendar_ajax_json.inc
executable file
·152 lines (147 loc) · 5.32 KB
/
views_plugin_style_fullcalendar_ajax_json.inc
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
// require_once(drupal_get_path('module', 'views_ajax_endpoint') . '/views_plugin_style_ajax.inc');
class views_plugin_style_fullcalendar_ajax_json extends views_plugin_style {
/**
* Set default options.
*/
function option_definition() {
$options = parent::option_definition();
return $options;
}
/**
* Extend the options form.
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Style types
$fields = array(0 => '<'. t('None') .'>');
foreach ($this->view->display_handler->get_option('fields') as $field => $definition) {
$fields[$field] = !empty($definition['label']) ? $definition['label'] : $field;
}
$form['field'] = array(
'#title' => t('Field'),
'#description' => t('Choose a field to be used for field updates.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['field'],
);
$form['index'] = array(
'#title' => t('index'),
'#description' => t('Choose a field to be used for index (delta) items.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['index'],
);
$form['nid'] = array(
'#title' => t('nid'),
'#description' => t('Choose a field to be used for the nid.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['nid'],
);
$form['title'] = array(
'#title' => t('title'),
'#description' => t('Choose a field to be used for the title.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['title'],
);
$form['start'] = array(
'#title' => t('start'),
'#description' => t('Choose a field to be used for start date.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['start'],
);
$form['end'] = array(
'#title' => t('end'),
'#description' => t('Choose a field to be used for end date.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['end'],
);
$form['url'] = array(
'#title' => t('url'),
'#description' => t('Choose a field to be used for the URL.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['url'],
);
$form['allDay'] = array(
'#title' => t('allDay'),
'#description' => t('Choose a field to be used for the allDay status.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['allDay'],
);
$form['className'] = array(
'#title' => t('className'),
'#description' => t('Choose a field to be used for the className.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['className'],
);
$form['editable'] = array(
'#title' => t('editable'),
'#description' => t('Choose a field to be used for edit status of the item.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['editable'],
);
$form['description'] = array(
'#title' => t('description'),
'#description' => t('Choose a field to be used for the description of the item.'),
'#type' => 'select',
'#options' => $fields,
'#default_value' => $this->options['description'],
);
}
function render() {
$output = parent::render();
drupal_set_header('Content-type: text/javascript; charset=utf-8');
$jsonoutput = array();
foreach ($this->rendered_fields as $field) {
$structure = array();
foreach ($this->options as $key => $value) {
if (!is_null($value) && $value && ($value != "0")) {
$structure[$key] = $field[$value];
}
if ($key == 'recurring') {
$structure[$key] = FALSE;
}
if ($key == 'allDay') {
$structure[$key] = FALSE;
}
if ($key == 'className') {
$structure[$key] = 'crayon crayon-' . theme('seed_crayon', $field[$value]);
}
if ($key == 'field') {
$structure[$key] = "field_date";
}
if ($key == 'start') {
$structure[$key] = array_pop(explode(' ', strip_tags($field[$value])));
}
if ($key == 'end') {
$structure[$key] = array_shift(explode(' ', strip_tags($field[$value])));
}
}
if (TRUE) {
// Add unexcluded rendered fields to flyout. This is should be in a seperate theme func.
// @todo - This doesn't work, but it feels right. :)
//$structure['flyout'] = theme(array('views_view_fields'), $this->view, $this->options, $row, 'nid');
$structure['flyout'] = '<span class="crayon-popup"><span class="crayon-popup-label">';
foreach ($this->display->display_options['fields'] as $field_name => $options) {
if (empty($options['exclude'])) {
$structure['flyout'] .= '<div>' . $field[$field_name] . '</div>';
}
}
if (spaces_access_admin()) {
$structure['flyout'] .= l('Edit', 'node/' . $field['nid'] . '/edit/nojs', array('attributes' => array('class' => 'ctools-use-modal')));
}
$structure['flyout'] .= '</span></span>';
}
$jsonoutput[] = $structure;
}
return drupal_to_js($jsonoutput);
}
}