-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews_slideshow_imageflow_advanced.views_slideshow.inc
294 lines (274 loc) · 13 KB
/
views_slideshow_imageflow_advanced.views_slideshow.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<?php
/**
* @file
* The default options available with Views Slideshow: ImageFlow Advanced.
*/
/**
* @todo: get rid of extra stuff here
*/
function views_slideshow_imageflow_advanced_views_slideshow_slideshow_info() {
$options = array(
'views_slideshow_imageflow_advanced' => array(
'name' => t('ImageFlow'),
'type' => 'imageflow',
'accepts' => array(),
'calls' => array(),
),
);
return $options;
}
/**
* Implements hook_views_slideshow_options_form().
*/
function views_slideshow_imageflow_advanced_views_slideshow_slideshow_type_form(&$form, &$form_state, &$view) {
// Create the form elements for our ImageFlow view options.
$form['views_slideshow_imageflow_advanced']['container_width'] = array(
'#type' => 'textfield',
'#title' => t('Container width'),
'#size' => 10,
'#description' => t('Width of ImageFlow container in px, % or em. Set 0 to not apply width to container.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['container_width'],
);
$form['views_slideshow_imageflow_advanced']['aspectRatio'] = array(
'#type' => 'textfield',
'#title' => t('Aspect ratio'),
'#size' => 10,
'#description' => t('Aspect ratio of the ImageFlow container (width divided by height).'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['aspectRatio'],
);
$form['views_slideshow_imageflow_advanced']['imagesHeight'] = array(
'#type' => 'textfield',
'#title' => t('Images height'),
'#size' => 10,
'#description' => t('Height of the images div container to be multiplied.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['imagesHeight'],
);
$form['views_slideshow_imageflow_advanced']['slider'] = array(
'#type' => 'checkbox',
'#title' => t('Show slider'),
'#description' => t('Disables / enables the scrollbar.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['slider'],
);
$form['views_slideshow_imageflow_advanced']['sliderCursor'] = array(
'#type' => 'select',
'#title' => t('Slider cursor'),
'#description' => t('Cursor type for the slider.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['sliderCursor'],
'#options' => array(
'pointer' => t('pointer'),
'default' => t('default'),
'e-resize' => t('e-resize'),
),
'#process' => array('ctools_dependent_process'),
'#dependency' => array('edit-style-options-views-slideshow-imageflow-advanced-slider' => array(1)),
);
$form['views_slideshow_imageflow_advanced']['scrollbarP'] = array(
'#type' => 'textfield',
'#title' => t('Slider width multiplier'),
'#size' => 10,
'#description' => t('Width of slider relative to width of container. Values for 0 to 1.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['scrollbarP'],
'#process' => array('ctools_dependent_process'),
'#dependency' => array('edit-style-options-views-slideshow-imageflow-advanced-slider' => array(1)),
);
$form['views_slideshow_imageflow_advanced']['start'] = array(
'#type' => 'select',
'#title' => t('Start position'),
'#description' => t('The position to begin the ImageFlow.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['start'],
'#options' => array(
'start' => t('Start'),
'middle' => t('Middle'),
'end' => t('End'),
'random' => t('Random'),
),
);
$form['views_slideshow_imageflow_advanced']['min_img_qty'] = array(
'#type' => 'textfield',
'#title' => t('Minimum images'),
'#description' => t('How many images to start slideshow.<bt/>If less images then specified value - images will be shown as is, without ImageFlow plugin.<br/>Useful when rotation of 2 items looks odd.<br/>Value must be greater then 0.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['min_img_qty'],
'#size' => 5,
);
$form['views_slideshow_imageflow_advanced']['captions'] = array(
'#type' => 'checkbox',
'#title' => t('Display captions'),
'#description' => t('Disables / enables the display of captions.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['captions'],
);
// Need to wrap this so it indents correctly.
$form['views_slideshow_imageflow_advanced']['captions_wrapper'] = array(
'#markup' => '<div class="vs-dependent">',
);
$caption_fields = array();
foreach ($view->display->handler->get_handlers('field') as $field => $handler) {
$caption_fields[$field] = $handler->ui_name();
}
$form['views_slideshow_imageflow_advanced']['captions_source'] = array(
'#type' => 'select',
'#title' => t('Caption source'),
'#description' => t('Select source field for captions'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['captions_source'],
'#options' => $caption_fields,
'#states' => array(
'visible' => array(
':input[name="style_options[views_slideshow_imageflow_advanced][captions]"]' => array('checked' => TRUE),
),
),
);
$form['views_slideshow_imageflow_advanced']['captions_wrapper_close'] = array(
'#markup' => '</div>',
);
$form['views_slideshow_imageflow_advanced']['imageFocusM'] = array(
'#type' => 'textfield',
'#title' => t('Image focus multiplier'),
'#size' => 10,
'#description' => t('Multiplier for the focussed image size.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['imageFocusM'],
);
$form['views_slideshow_imageflow_advanced']['imageFocusMax'] = array(
'#type' => 'textfield',
'#title' => t('Image focus max'),
'#size' => 10,
'#description' => t('Maximum number of images on each side of the focussed one.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['imageFocusMax'],
);
$form['views_slideshow_imageflow_advanced']['imageCursor'] = array(
'#type' => 'select',
'#title' => t('Image cursor'),
'#description' => t('Cursor type for the images.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['imageCursor'],
'#options' => array(
'pointer' => t('pointer'),
'default' => t('default'),
'e-resize' => t('e-resize'),
),
);
$form['views_slideshow_imageflow_advanced']['onClick'] = array(
'#type' => 'textarea',
'#title' => t('onClick override'),
'#description' => t('You may override the onClick JavaScript function of slide show image frames here.'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['onClick'],
);
$form['views_slideshow_imageflow_advanced']['slideshowAutoplay'] = array(
'#type' => 'checkbox',
'#title' => t('Autoplay'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['slideshowAutoplay'],
'#description' => t('Toggle automatic slideshow play on startup.'),
);
// Need to wrap this so it indents correctly.
$form['views_slideshow_imageflow_advanced']['slideshowAutoplay_wrapper'] = array(
'#markup' => '<div class="vs-dependent">',
);
$form['views_slideshow_imageflow_advanced']['slideshowSpeed'] = array(
'#type' => 'textfield',
'#title' => t('Slideshow speed'),
'#size' => 10,
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['slideshowSpeed'],
'#description' => t('Time in miliseconds between rotations.'),
'#states' => array(
'visible' => array(
':input[name="style_options[views_slideshow_imageflow_advanced][slideshowAutoplay]"]' => array('checked' => TRUE),
),
),
);
$form['views_slideshow_imageflow_advanced']['show_slideshow_controls'] = array(
'#type' => 'checkbox',
'#title' => t('Show slideshow controls'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['show_slideshow_controls'],
'#description' => t('Toggle slideshow Play/Pause button.'),
'#states' => array(
'visible' => array(
':input[name="style_options[views_slideshow_imageflow_advanced][slideshowAutoplay]"]' => array('checked' => TRUE),
),
),
);
$form['views_slideshow_imageflow_advanced']['slideshowAutoplay_wrapper_close'] = array(
'#markup' => '</div>',
);
$form['views_slideshow_imageflow_advanced']['circular'] = array(
'#type' => 'checkbox',
'#title' => t('Circular'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['circular'],
'#description' => t('Toggle circular rotation.'),
);
$form['views_slideshow_imageflow_advanced']['startAnimation'] = array(
'#type' => 'checkbox',
'#title' => t('Start with animation'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['startAnimation'],
'#description' => t('Animate images to start position after images loaded.If disabled, images will simply appear once loaded.'),
);
$form['views_slideshow_imageflow_advanced']['reflections'] = array(
'#type' => 'checkbox',
'#title' => t('Reflections'),
'#default_value' => $view->options['views_slideshow_imageflow_advanced']['reflections'],
'#description' => t('Use reflect3.php script shipped with this module to create reflected images. Alternatively, ImageApi with effects can be used to create images with reflection.'),
);
}
/**
* Implements hook_views_slideshow_option_definition().
*/
function views_slideshow_imageflow_advanced_views_slideshow_option_definition() {
// Set our default options.
$options['views_slideshow_imageflow_advanced'] = array(
'default' => array(
'aspectRatio' => 1.964,
'captions' => TRUE,
'circular' => FALSE,
'container_width' => 0,
'imageCursor' => 'pointer',
'imagesHeight' => 0.67,
'imageFocusM' => 1.0,
'imageFocusMax' => 4,
'onClick' => 'function() { document.location = this.url; }',
'reflections' => FALSE,
'scrollbarP' => 0.6,
'show_slideshow_controls' => TRUE,
'slider' => TRUE,
'sliderCursor' => 'pointer',
'slideshowAutoplay' => FALSE,
'slideshowSpeed' => 1500,
'start' => 'middle',
'startAnimation' => FALSE,
'min_img_qty' => 1,
),
);
return $options;
}
/**
* Implements hook_views_slideshow_options_form_validate().
*/
function views_slideshow_imageflow_advanced_views_slideshow_options_form_validate(&$form, &$form_state, &$view) {
// Validate this plugin only if it is selected in "Slideshow type" dropdown.
// We need to make sure that all plugins use this check.
if ($form_state['values']['style_options']['slideshow_type'] == 'views_slideshow_imageflow_advanced') {
$fs = $form_state['values']['style_options']['views_slideshow_imageflow_advanced'];
if (!is_numeric($fs['aspectRatio'])) {
form_error($form['views_slideshow_imageflow_advanced']['aspectRatio'], t('<em>!setting</em> must be a number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['aspectRatio']['#title'])));
}
if (!preg_match('/^0$|^[0-9]+(.[0-9]+)?(px|em|%|)$/', $fs['container_width'])) {
form_error($form['views_slideshow_imageflow_advanced']['container_width'], t('<em>!setting</em> must be 0 or a number with a suffix of px, em or %.', array('!setting' => $form['views_slideshow_imageflow_advanced']['container_width']['#title'])));
}
if (!is_numeric($fs['imagesHeight'])) {
form_error($form['views_slideshow_imageflow_advanced']['imagesHeight'], t('<em>!setting</em> must be a number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['imagesHeight']['#title'])));
}
if (!is_numeric($fs['imageFocusM'])) {
form_error($form['views_slideshow_imageflow_advanced']['imageFocusM'], t('<em>!setting</em> must be a number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['imageFocusM']['#title'])));
}
if (!preg_match('/^([0-9])+$/', $fs['imageFocusMax'])) {
form_error($form['views_slideshow_imageflow_advanced']['imageFocusMax'], t('<em>!setting</em> must be an integer number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['imageFocusMax']['#title'])));
}
if (!is_numeric($fs['scrollbarP'])) {
form_error($form['views_slideshow_imageflow_advanced']['scrollbarP'], t('<em>!setting</em> must be a number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['scrollbarP']['#title'])));
}
if (!is_numeric($fs['slideshowSpeed'])) {
form_error($form['views_slideshow_imageflow_advanced']['slideshowSpeed'], t('<em>!setting</em> must be a number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['slideshowSpeed']['#title'])));
}
if (!is_numeric($fs['min_img_qty'])) {
form_error($form['views_slideshow_imageflow_advanced']['min_img_qty'], t('<em>!setting</em> must be a number.', array('!setting' => $form['views_slideshow_imageflow_advanced']['min_img_qty']['#title'])));
}
elseif (intval($fs['min_img_qty']) < 1) {
form_error($form['views_slideshow_imageflow_advanced']['min_img_qty'], t('<em>!setting</em> must be greater then 0.', array('!setting' => $form['views_slideshow_imageflow_advanced']['min_img_qty']['#title'])));
}
}
}