/[drupal]/contributions/modules/swftools/flowplayer3/flowplayer3.admin.inc
ViewVC logotype

Contents of /contributions/modules/swftools/flowplayer3/flowplayer3.admin.inc

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


Revision 1.18 - (show annotations) (download) (as text)
Wed Mar 18 00:21:58 2009 UTC (8 months, 1 week ago) by stuartgreenfield
Branch: MAIN
CVS Tags: HEAD
Changes since 1.17: +11 -2 lines
File MIME type: text/x-php
#405498 by fearfox: Background gradient setting for controlbar missing.
1 <?php
2 // $Id: flowplayer3.admin.inc,v 1.17 2009/03/17 21:35:58 stuartgreenfield Exp $
3
4 /**
5 * Menu callback for the FlowPlayer3 settings form.
6 */
7 function flowplayer3_admin_settings() {
8
9 // Retrieve combination of default and saved settings
10 $saved_settings = _flowplayer3_settings();
11
12 // Retrieve options needed to populate select elements
13 $options = _flowplayer3_options();
14
15 // Initialise array to hold form
16 $form = array();
17
18 // Add color scheme form
19 $form['color'] = array(
20 '#type' => 'fieldset',
21 '#collapsible' => TRUE,
22 '#collapsed' => TRUE,
23 '#title' => t('Color scheme'),
24 '#weight' => -1,
25 '#attributes' => array('id' => 'flowplayer3_scheme_form'),
26 '#theme' => 'flowplayer3_scheme_form',
27 );
28 $form['color'] += flowplayer3_scheme_form($form_state);
29
30 // Player path
31 $form['flowplayer3_files'] = array(
32 '#type' => 'fieldset',
33 '#collapsible' => TRUE,
34 '#collapsed' => TRUE,
35 '#title' => t('Player and plugin files'),
36 );
37
38 $form['flowplayer3_files']['flowplayer3_mediaplayer_file'] = array(
39 '#type' => 'textfield',
40 '#default_value' => variable_get('flowplayer3_mediaplayer_file', FLOWPLAYER3_MEDIAPLAYER_FILE),
41 '#title' => t('Player file'),
42 '#description' => t('Specify the name of the player file - with FlowPlayer 3 this typically changes with each new release.'),
43 '#size' => 30,
44 );
45
46 $form['flowplayer3_files']['flowplayer3_mediaplayer_stream_plugin'] = array(
47 '#type' => 'textfield',
48 '#default_value' => variable_get('flowplayer3_mediaplayer_stream_plugin', FLOWPLAYER3_MEDIAPLAYER_STREAM_PLUGIN),
49 '#title' => t('RTMP streaming plugin'),
50 '#description' => t('Specify the name of the rtmp streaming plugin.'),
51 '#size' => 30,
52 );
53
54 $form['flowplayer3_files']['flowplayer3_product_key'] = array(
55 '#type' => 'textfield',
56 '#default_value' => variable_get('flowplayer3_product_key', ''),
57 '#title' => t('Product key'),
58 '#description' => t('Enter your product key if you are using the commercial version of FlowPlayer 3.'),
59 '#size' => 30,
60 );
61
62 // Initialise tree from this point forward as want to store arrays
63 $form[FLOWPLAYER3_MEDIAPLAYER]['#tree'] = TRUE;
64
65 // Clip settings
66 $form[FLOWPLAYER3_MEDIAPLAYER]['clip'] = array(
67 '#type' => 'fieldset',
68 '#collapsible' => TRUE,
69 '#collapsed' => TRUE,
70 '#title' => t('Overall clip properties'),
71 );
72
73 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['autoPlay'] = array(
74 '#type' => 'select',
75 '#options' => $options['bool'],
76 '#default_value' => $saved_settings['clip']['autoPlay'],
77 '#title' => t('Auto play'),
78 '#description' => t('Flag indicating whether the player should start playback immediately upon loading.'),
79 );
80
81 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['autoBuffering'] = array(
82 '#type' => 'select',
83 '#options' => $options['bool'],
84 '#default_value' => $saved_settings['clip']['autoBuffering'],
85 '#title' => t('Auto buffering'),
86 '#description' => t('Flag indicating whether loading of clip into player\'s memory should begin straight away. '),
87 );
88
89 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['scaling'] = array(
90 '#type' => 'select',
91 '#options' => $options['scaling'],
92 '#default_value' => $saved_settings['clip']['scaling'],
93 '#title' => t('Scaling'),
94 '#description' => t('Specify how the clip should be scaled.'),
95 );
96
97 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['start'] = array(
98 '#type' => 'textfield',
99 '#default_value' => $saved_settings['clip']['start'],
100 '#title' => t('Start'),
101 '#description' => t('Specify start point for playback (only works with a streaming server). Streaming support not yet in place for SWF Tools.'),
102 '#size' => 8,
103 );
104
105 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['duration'] = array(
106 '#type' => 'textfield',
107 '#default_value' => $saved_settings['clip']['duration'],
108 '#title' => t('Duration'),
109 '#description' => t('The time (in seconds) for which a video clip should be played until playback ceases.'),
110 '#size' => 8,
111 );
112
113 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['accelerated'] = array(
114 '#type' => 'select',
115 '#options' => $options['bool'],
116 '#default_value' => $saved_settings['clip']['accelerated'],
117 '#title' => t('Acceleration'),
118 '#description' => t('Flag indicating whether Flash 9 (and above) hardware-accelerated full screen mode should be used.'),
119 );
120
121 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['bufferLength'] = array(
122 '#type' => 'textfield',
123 '#default_value' => $saved_settings['clip']['bufferLength'],
124 '#title' => t('Buffer length'),
125 '#description' => t('The amount of video data (in seconds) which should be loaded into Flowplayer\'s memory in advance of playback commencing. '),
126 '#size' => 8,
127 );
128
129 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['provider'] = array(
130 '#type' => 'textfield',
131 '#default_value' => $saved_settings['clip']['provider'],
132 '#title' => t('Provider'),
133 '#description' => t('Not sure if this will be support in this module. Need to investigate.'),
134 );
135
136 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['fadeInSpeed'] = array(
137 '#type' => 'textfield',
138 '#default_value' => $saved_settings['clip']['fadeInSpeed'],
139 '#title' => t('Fade in speed'),
140 '#description' => t('Time in milliseconds to fade from zero to full opacity upon commencement of video playback.'),
141 '#size' => 8,
142 );
143
144 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['fadeOutSpeed'] = array(
145 '#type' => 'textfield',
146 '#default_value' => $saved_settings['clip']['fadeOutSpeed'],
147 '#title' => t('Fade out speed'),
148 '#description' => t('Time in milliseconds to fade from full to zero opacity upon completion of video playback.'),
149 '#size' => 8,
150 );
151
152 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['linkUrl'] = array(
153 '#type' => 'textfield',
154 '#default_value' => $saved_settings['clip']['linkUrl'],
155 '#title' => t('Link url'),
156 '#description' => t('The URL to direct users to when clicking the video screen.'),
157 );
158
159 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['linkWindow'] = array(
160 '#type' => 'select',
161 '#options' => $options['linkWindow'],
162 '#default_value' => $saved_settings['clip']['linkWindow'],
163 '#title' => t('Link window'),
164 '#description' => t('Setting which defines where URL defined by linkUrl property is opened.'),
165 );
166
167 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['live'] = array(
168 '#type' => 'select',
169 '#options' => $options['bool'],
170 '#default_value' => $saved_settings['clip']['live'],
171 '#title' => t('Live'),
172 '#description' => t('RTMP streaming servers support live streaming, which means that it is possible to setup a video camera or other live video source to stream live video data to Flowplayer. If you have an RTMP server which is providing a live video stream, you should set this property to true. Streaming support not yet in place for SWF Tools.'),
173 );
174
175 $form[FLOWPLAYER3_MEDIAPLAYER]['clip']['cuePointMultiplier'] = array(
176 '#type' => 'textfield',
177 '#default_value' => $saved_settings['clip']['cuePointMultiplier'],
178 '#title' => t('Cue point multiplier'),
179 '#description' => t('The times of embedded cuepoints are multiplied by this value before being used. Some encoding tools embed cuepoints in seconds but Flowplayer processes cuepoints in milliseconds. Note that the times are also rounded to the nearest 100 milliseconds. For example, if a file has a cuepoint at 5.535 seconds, the cuepoint is fired at 5500 milliseconds (assuming the default multiplier value of 1000).'),
180 '#size' => 8,
181 );
182
183 // Control bar settings
184 $form[FLOWPLAYER3_MEDIAPLAYER]['controls'] = array(
185 '#type' => 'fieldset',
186 '#collapsible' => TRUE,
187 '#collapsed' => TRUE,
188 '#title' => t('Controlbar properties'),
189 );
190
191 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['backgroundGradient'] = array(
192 '#type' => 'select',
193 '#options' => $options['gradient'],
194 '#default_value' => $saved_settings['controls']['backgroundGradient'],
195 '#title' => t('Background gradient'),
196 '#description' => t('Gradient setting for the controlbar background.'),
197 );
198
199
200 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['progressGradient'] = array(
201 '#type' => 'select',
202 '#options' => $options['gradient'],
203 '#default_value' => $saved_settings['controls']['progressGradient'],
204 '#title' => t('Progress gradient'),
205 '#description' => t('Gradient setting for the progress bar.'),
206 );
207
208 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['bufferGradient'] = array(
209 '#type' => 'select',
210 '#options' => $options['gradient'],
211 '#default_value' => $saved_settings['controls']['bufferGradient'],
212 '#title' => t('Buffer gradient'),
213 '#description' => t('Gradient setting for the buffer.'),
214 );
215
216 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['sliderGradient'] = array(
217 '#type' => 'select',
218 '#options' => $options['gradient'],
219 '#default_value' => $saved_settings['controls']['sliderGradient'],
220 '#title' => t('Slider gradient'),
221 '#description' => t('Gradient setting for the sliders.'),
222 );
223
224 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['autoHide'] = array(
225 '#type' => 'select',
226 '#options' => $options['autoHide'],
227 '#default_value' => $saved_settings['controls']['autoHide'],
228 '#title' => t('Hide control bar'),
229 '#description' => t('Specifies whether the controlbar should be hidden when the user is not actively using the player.'),
230 );
231
232 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['play'] = array(
233 '#type' => 'select',
234 '#options' => $options['bool'],
235 '#default_value' => $saved_settings['controls']['play'],
236 '#title' => t('Play button'),
237 '#description' => t('Should the play/pause button be visible?'),
238 );
239
240 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['volume'] = array(
241 '#type' => 'select',
242 '#options' => $options['bool'],
243 '#default_value' => $saved_settings['controls']['volume'],
244 '#title' => t('Volume button'),
245 '#description' => t('Should the volume control be visible?'),
246 );
247
248 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['mute'] = array(
249 '#type' => 'select',
250 '#options' => $options['bool'],
251 '#default_value' => $saved_settings['controls']['mute'],
252 '#title' => t('Mute button'),
253 '#description' => t('Should the mute button be visible?'),
254 );
255
256 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['time'] = array(
257 '#type' => 'select',
258 '#options' => $options['bool'],
259 '#default_value' => $saved_settings['controls']['time'],
260 '#title' => t('Time display'),
261 '#description' => t('Should the time display be visible?'),
262 );
263
264 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['stop'] = array(
265 '#type' => 'select',
266 '#options' => $options['bool'],
267 '#default_value' => $saved_settings['controls']['stop'],
268 '#title' => t('Stop button'),
269 '#description' => t('Should the stop button be visible?'),
270 );
271
272 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['playlist'] = array(
273 '#type' => 'select',
274 '#options' => $options['bool'],
275 '#default_value' => $saved_settings['controls']['playlist'],
276 '#title' => t('Playlist buttons'),
277 '#description' => t('Should the playlist buttons be visible. These buttons will allow navigation through the playlist entries that have been configured for the player. These buttons are always hidden if there are less than two entries in the playlist.'),
278 );
279
280 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['fullscreen'] = array(
281 '#type' => 'select',
282 '#options' => $options['bool'],
283 '#default_value' => $saved_settings['controls']['fullscreen'],
284 '#title' => t('Fullscreen button'),
285 '#description' => t('Should the fullscreen button be visible?'),
286 );
287
288 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['scrubber'] = array(
289 '#type' => 'select',
290 '#options' => $options['bool'],
291 '#default_value' => $saved_settings['controls']['scrubber'],
292 '#title' => t('Scrubber'),
293 '#description' => t('The scrubber is a well known nickname for the timeline/playhead combination. This specifies whether it should be visible.'),
294 );
295
296 // Canvas settings
297 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas'] = array(
298 '#type' => 'fieldset',
299 '#collapsible' => TRUE,
300 '#collapsed' => TRUE,
301 '#title' => t('Canvas properties'),
302 );
303
304 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['backgroundImage'] = array(
305 '#type' => 'textfield',
306 '#default_value' => $saved_settings['canvas']['backgroundImage'],
307 '#title' => t('Background image'),
308 '#description' => t('The absolute or relative path to the image that should be used as the background to this plugin. Supported formats are GIF, JPEG and PNG. The syntax is similar to CSS in that you must enclose your path inside a url() wrapper.'),
309 '#size' => 24,
310 );
311
312 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['backgroundRepeat'] = array(
313 '#type' => 'select',
314 '#options' => $options['backgroundRepeat'],
315 '#default_value' => $saved_settings['canvas']['backgroundRepeat'],
316 '#title' => t('Background repeat'),
317 '#description' => t('Default is "repeat", which makes the background image repeat both horizontally and vertically. "no-repeat" displays the background image only once from the top left-hand corner.'),
318 );
319
320 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['backgroundGradient'] = array(
321 '#type' => 'select',
322 '#options' => $options['gradient'],
323 '#default_value' => $saved_settings['canvas']['backgroundGradient'],
324 '#title' => t('Background gradient'),
325 '#description' => t('Gradient setting for the canvas.'),
326 );
327
328 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['border'] = array(
329 '#type' => 'textfield',
330 '#default_value' => $saved_settings['canvas']['border'],
331 '#title' => t('Border'),
332 '#description' => t('Draws a border around a plugin\'s edges. The syntax follows the CSS standard: width style color. For example: "1px solid #cccccc". The only supported style currently is "solid", but the width and colour can be set to any valid value.'),
333 '#size' => 24,
334 );
335
336 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['borderRadius'] = array(
337 '#type' => 'textfield',
338 '#default_value' => $saved_settings['canvas']['borderRadius'],
339 '#title' => t('Border radius'),
340 '#description' => t('Specifies the amount of rounding for each corner. Larger values mean more rounding.'),
341 '#size' => 8,
342 );
343
344 // Return finished form
345 return system_settings_form($form);
346
347 }
348
349
350 /**
351 * Options used to populate the select elements of the form above
352 * Collect them here to make them easier to find and adjust!
353 */
354 function _flowplayer3_options() {
355 $options['bool'] = array('true' => 'true', 'false' => 'false');
356 $options['linkWindow'] = array('_blank' => '_blank', '_parent' => '_parent', '_self' => '_self', '_top' => '_top');
357 $options['scaling'] = array('fit' => 'fit', 'half' => 'half', 'orig' => 'orig', 'scale' => 'scale');
358 $options['gradient'] = array('none' => 'none', 'low' => 'low', 'medium' => 'medium', 'high' => 'high');
359 $options['autoHide'] = array('never' => 'never', 'always' => 'always', 'fullscreen' => 'fullscreen');
360 $options['backgroundRepeat'] = array('no-repeat' => 'no-repeat', 'repeat' => 'repeat');
361 return $options;
362 }
363
364
365 /**
366 * Retrieve the color scheme information for FlowPlayer3 styling.
367 *
368 * @return
369 * An array of data defining color information and names for each preset style.
370 */
371 function flowplayer3_get_info() {
372
373 // Cache $info
374 static $info;
375
376 // If $info is populated, return it
377 if (isset($info)) {
378 return $info;
379 }
380
381 // Gather $info
382 $path = drupal_get_path('module', 'flowplayer3');
383 $file = $path . '/flowplayer3.colorschemes.inc';
384 include $file;
385 return $info;
386 }
387
388
389 /**
390 * Helper function to retrieve the color palette for a particular style.
391 *
392 * @param $default
393 * Optional parameter (default false). If false or omitted returns the
394 * current palette, if true returns the default palette.
395 * @return
396 * An array of key/value pairs - the key defines the componenent and the
397 * value defines the color.
398 */
399 function flowplayer3_get_palette($default = false) {
400
401 // Define palette properties
402 $fields = array(
403 'backgroundColor',
404 'controlbarbackgroundColor',
405 'timeColor',
406 'durationColor',
407 'progressColor',
408 'bufferColor',
409 'sliderColor',
410 'buttonColor',
411 'buttonOverColor',
412 );
413
414 // Get the theme information
415 $info = flowplayer3_get_info();
416
417 // Get the keys (strings of colors) from the available schemes
418 $keys = array_keys($info['schemes']);
419
420 // Exploded the first (default) string in an array
421 foreach (explode(',', array_shift($keys)) as $k => $scheme) {
422 // Build a palette
423 $palette[$fields[$k]] = $scheme;
424 }
425
426 // If default is required, return it, otherwise load palette variable
427 return $default ? $palette : variable_get('flowplayer3_palette', $palette);
428 }
429
430
431 /**
432 * Helper function to produce the color scheme form for the flowplayer
433 */
434 function flowplayer3_scheme_form(&$form_state) {
435
436 // Get path to the flowplayer3 module
437 $base = drupal_get_path('module', 'flowplayer3');
438
439 // Add Farbtastic color picker
440 drupal_add_css('misc/farbtastic/farbtastic.css');
441 drupal_add_js('misc/farbtastic/farbtastic.js');
442
443 // Add custom CSS/JS
444 drupal_add_css($base . '/flowplayer3.colorpicker.css');
445 drupal_add_js($base . '/flowplayer3.colorpicker.js');
446 drupal_add_js(array('color' => array(
447 'reference' => flowplayer3_get_palette(true)
448 )), 'setting');
449
450 // Get info about the current theme color scheme
451 $info = flowplayer3_get_info();
452
453 // See if we're using a predefined scheme
454 // The variable is empty if using the default, or an array of key/value pairs otherwise
455 $current = implode(',', variable_get('flowplayer3_palette', array()));
456
457 // Note: we use the original theme when the default scheme is chosen.
458 $current = isset($info['schemes'][$current]) ? $current : ($current == '' ? reset($info['schemes']) : '');
459
460 // Add custom to scheme selector options
461 $info['schemes'][''] = t('Custom');
462
463 // Add scheme selector to form (the value is a comma separated string of hex colors)
464 $form['flowplayer3_scheme'] = array(
465 '#type' => 'select',
466 '#title' => t('Color set'),
467 '#options' => $info['schemes'],
468 '#default_value' => $current,
469 );
470
471 // Get current palette as an array
472 $palette = flowplayer3_get_palette();
473
474 // Build an array of titles to be used for each palette element
475 $names = array(
476 'backgroundColor' => array(
477 '#title' => t('Background color'),
478 ),
479 'controlbarbackgroundColor' => array(
480 '#title' => t('Control bar background color'),
481 ),
482 'timeColor' => array(
483 '#title' => t('Elapsed time font color'),
484 ),
485 'durationColor' => array(
486 '#title' => t('Total time font color'),
487 ),
488 'progressColor' => array(
489 '#title' => t('Progress bar color'),
490 ),
491 'bufferColor' => array(
492 '#title' => t('Buffer color'),
493 ),
494 'sliderColor' => array(
495 '#title' => t('Slider color'),
496 ),
497 'buttonColor' => array(
498 '#title' => t('Button color'),
499 ),
500 'buttonOverColor' => array(
501 '#title' => t('Button over color'),
502 ),
503 );
504
505 // Form elements to be part of a tree
506 $form['flowplayer3_palette']['#tree'] = true;
507
508 // Cycle through each palette element
509 foreach ($palette as $name => $value) {
510 $form['flowplayer3_palette'][$name] = array(
511 '#type' => 'textfield',
512 '#title' => $names[$name]['#title'],
513 '#default_value' => $value,
514 '#size' => 8,
515 );
516 }
517
518 // Return the form
519 return $form;
520 }
521
522 function theme_flowplayer3_scheme_form($form) {
523
524 $output = '';
525
526 // Wrapper
527 $output .= '<div class="color-form clear-block">';
528
529 // Color schemes
530 $output .= drupal_render($form['flowplayer3_scheme']);
531
532 // Palette
533 $output .= '<div id="palette" class="clear-block">';
534 foreach (element_children($form['flowplayer3_palette']) as $name) {
535 $output .= drupal_render($form['flowplayer3_palette'][$name]);
536 }
537 $output .= '</div>';
538
539 // Close wrapper
540 $output .= '</div>';
541
542 return $output;
543 }

  ViewVC Help
Powered by ViewVC 1.1.2