| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: flowplayer3.admin.inc,v 1.13.2.8 2009/04/18 23:30:52 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 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['progressGradient'] = array( 200 '#type' => 'select', 201 '#options' => $options['gradient'], 202 '#default_value' => $saved_settings['controls']['progressGradient'], 203 '#title' => t('Progress gradient'), 204 '#description' => t('Gradient setting for the progress bar.'), 205 ); 206 207 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['bufferGradient'] = array( 208 '#type' => 'select', 209 '#options' => $options['gradient'], 210 '#default_value' => $saved_settings['controls']['bufferGradient'], 211 '#title' => t('Buffer gradient'), 212 '#description' => t('Gradient setting for the buffer.'), 213 ); 214 215 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['sliderGradient'] = array( 216 '#type' => 'select', 217 '#options' => $options['gradient'], 218 '#default_value' => $saved_settings['controls']['sliderGradient'], 219 '#title' => t('Slider gradient'), 220 '#description' => t('Gradient setting for the sliders.'), 221 ); 222 223 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['autoHide'] = array( 224 '#type' => 'select', 225 '#options' => $options['autoHide'], 226 '#default_value' => $saved_settings['controls']['autoHide'], 227 '#title' => t('Hide control bar'), 228 '#description' => t('Specifies whether the controlbar should be hidden when the user is not actively using the player.'), 229 ); 230 231 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['play'] = array( 232 '#type' => 'select', 233 '#options' => $options['bool'], 234 '#default_value' => $saved_settings['controls']['play'], 235 '#title' => t('Play button'), 236 '#description' => t('Should the play/pause button be visible?'), 237 ); 238 239 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['volume'] = array( 240 '#type' => 'select', 241 '#options' => $options['bool'], 242 '#default_value' => $saved_settings['controls']['volume'], 243 '#title' => t('Volume button'), 244 '#description' => t('Should the volume control be visible?'), 245 ); 246 247 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['mute'] = array( 248 '#type' => 'select', 249 '#options' => $options['bool'], 250 '#default_value' => $saved_settings['controls']['mute'], 251 '#title' => t('Mute button'), 252 '#description' => t('Should the mute button be visible?'), 253 ); 254 255 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['time'] = array( 256 '#type' => 'select', 257 '#options' => $options['bool'], 258 '#default_value' => $saved_settings['controls']['time'], 259 '#title' => t('Time display'), 260 '#description' => t('Should the time display be visible?'), 261 ); 262 263 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['stop'] = array( 264 '#type' => 'select', 265 '#options' => $options['bool'], 266 '#default_value' => $saved_settings['controls']['stop'], 267 '#title' => t('Stop button'), 268 '#description' => t('Should the stop button be visible?'), 269 ); 270 271 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['playlist'] = array( 272 '#type' => 'select', 273 '#options' => $options['bool'], 274 '#default_value' => $saved_settings['controls']['playlist'], 275 '#title' => t('Playlist buttons'), 276 '#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.'), 277 ); 278 279 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['fullscreen'] = array( 280 '#type' => 'select', 281 '#options' => $options['bool'], 282 '#default_value' => $saved_settings['controls']['fullscreen'], 283 '#title' => t('Fullscreen button'), 284 '#description' => t('Should the fullscreen button be visible?'), 285 ); 286 287 $form[FLOWPLAYER3_MEDIAPLAYER]['controls']['scrubber'] = array( 288 '#type' => 'select', 289 '#options' => $options['bool'], 290 '#default_value' => $saved_settings['controls']['scrubber'], 291 '#title' => t('Scrubber'), 292 '#description' => t('The scrubber is a well known nickname for the timeline/playhead combination. This specifies whether it should be visible.'), 293 ); 294 295 // Canvas settings 296 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas'] = array( 297 '#type' => 'fieldset', 298 '#collapsible' => TRUE, 299 '#collapsed' => TRUE, 300 '#title' => t('Canvas properties'), 301 ); 302 303 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['height'] = array( 304 '#type' => 'textfield', 305 '#default_value' => $saved_settings['canvas']['height'], 306 '#title' => t('Height'), 307 '#description' => t('The height of the player in pixels.'), 308 '#size' => 8, 309 ); 310 311 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['width'] = array( 312 '#type' => 'textfield', 313 '#default_value' => $saved_settings['canvas']['width'], 314 '#title' => t('Width'), 315 '#description' => t('The width of the player in pixels.'), 316 '#size' => 8, 317 ); 318 319 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['backgroundImage'] = array( 320 '#type' => 'textfield', 321 '#default_value' => $saved_settings['canvas']['backgroundImage'], 322 '#title' => t('Background image'), 323 '#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.'), 324 '#size' => 24, 325 ); 326 327 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['backgroundRepeat'] = array( 328 '#type' => 'select', 329 '#options' => $options['backgroundRepeat'], 330 '#default_value' => $saved_settings['canvas']['backgroundRepeat'], 331 '#title' => t('Background repeat'), 332 '#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.'), 333 ); 334 335 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['backgroundGradient'] = array( 336 '#type' => 'select', 337 '#options' => $options['gradient'], 338 '#default_value' => $saved_settings['canvas']['backgroundGradient'], 339 '#title' => t('Background gradient'), 340 '#description' => t('Gradient setting for the canvas.'), 341 ); 342 343 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['border'] = array( 344 '#type' => 'textfield', 345 '#default_value' => $saved_settings['canvas']['border'], 346 '#title' => t('Border'), 347 '#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.'), 348 '#size' => 24, 349 ); 350 351 $form[FLOWPLAYER3_MEDIAPLAYER]['canvas']['borderRadius'] = array( 352 '#type' => 'textfield', 353 '#default_value' => $saved_settings['canvas']['borderRadius'], 354 '#title' => t('Border radius'), 355 '#description' => t('Specifies the amount of rounding for each corner. Larger values mean more rounding.'), 356 '#size' => 8, 357 ); 358 359 // Add custom form handler to flush cache upon submit 360 $form['#submit'][] = 'flowplayer3_admin_settings_submit'; 361 362 // Return finished form 363 return system_settings_form($form); 364 365 } 366 367 368 /** 369 * Options used to populate the select elements of the form above 370 * Collect them here to make them easier to find and adjust! 371 */ 372 function _flowplayer3_options() { 373 $options['bool'] = array('true' => 'true', 'false' => 'false'); 374 $options['linkWindow'] = array('_blank' => '_blank', '_parent' => '_parent', '_self' => '_self', '_top' => '_top'); 375 $options['scaling'] = array('fit' => 'fit', 'half' => 'half', 'orig' => 'orig', 'scale' => 'scale'); 376 $options['gradient'] = array('none' => 'none', 'low' => 'low', 'medium' => 'medium', 'high' => 'high'); 377 $options['autoHide'] = array('never' => 'never', 'always' => 'always', 'fullscreen' => 'fullscreen'); 378 $options['backgroundRepeat'] = array('no-repeat' => 'no-repeat', 'repeat' => 'repeat'); 379 return $options; 380 } 381 382 383 /** 384 * Retrieve the color scheme information for FlowPlayer3 styling. 385 * 386 * @return 387 * An array of data defining color information and names for each preset style. 388 */ 389 function flowplayer3_get_info() { 390 391 // Cache $info 392 static $info; 393 394 // If $info is populated, return it 395 if (isset($info)) { 396 return $info; 397 } 398 399 // Gather $info 400 $path = drupal_get_path('module', 'flowplayer3'); 401 $file = $path . '/flowplayer3.colorschemes.inc'; 402 include $file; 403 return $info; 404 } 405 406 407 /** 408 * Helper function to retrieve the color palette for a particular style. 409 * 410 * @param $default 411 * Optional parameter (default false). If false or omitted returns the 412 * current palette, if true returns the default palette. 413 * @return 414 * An array of key/value pairs - the key defines the componenent and the 415 * value defines the color. 416 */ 417 function flowplayer3_get_palette($default = false) { 418 419 // Define palette properties 420 $fields = array( 421 'backgroundColor', 422 'controlbarbackgroundColor', 423 'timeColor', 424 'durationColor', 425 'progressColor', 426 'bufferColor', 427 'sliderColor', 428 'buttonColor', 429 'buttonOverColor', 430 ); 431 432 // Get the theme information 433 $info = flowplayer3_get_info(); 434 435 // Get the keys (strings of colors) from the available schemes 436 $keys = array_keys($info['schemes']); 437 438 // Exploded the first (default) string in an array 439 foreach (explode(',', array_shift($keys)) as $k => $scheme) { 440 // Build a palette 441 $palette[$fields[$k]] = $scheme; 442 } 443 444 // If default is required, return it, otherwise load palette variable 445 return $default ? $palette : variable_get('flowplayer3_palette', $palette); 446 } 447 448 449 /** 450 * Helper function to produce the color scheme form for the flowplayer 451 */ 452 function flowplayer3_scheme_form(&$form_state) { 453 454 // Get path to the flowplayer3 module 455 $base = drupal_get_path('module', 'flowplayer3'); 456 457 // Add Farbtastic color picker 458 drupal_add_css('misc/farbtastic/farbtastic.css'); 459 drupal_add_js('misc/farbtastic/farbtastic.js'); 460 461 // Add custom CSS/JS 462 drupal_add_css($base . '/flowplayer3.colorpicker.css'); 463 drupal_add_js($base . '/flowplayer3.colorpicker.js'); 464 drupal_add_js(array('color' => array( 465 'reference' => flowplayer3_get_palette(true) 466 )), 'setting'); 467 468 // Get info about the current theme color scheme 469 $info = flowplayer3_get_info(); 470 471 // See if we're using a predefined scheme 472 // The variable is empty if using the default, or an array of key/value pairs otherwise 473 $current = implode(',', variable_get('flowplayer3_palette', array())); 474 475 // Note: we use the original theme when the default scheme is chosen. 476 $current = isset($info['schemes'][$current]) ? $current : ($current == '' ? reset($info['schemes']) : ''); 477 478 // Add custom to scheme selector options 479 $info['schemes'][''] = t('Custom'); 480 481 // Add scheme selector to form (the value is a comma separated string of hex colors) 482 $form['flowplayer3_scheme'] = array( 483 '#type' => 'select', 484 '#title' => t('Color set'), 485 '#options' => $info['schemes'], 486 '#default_value' => $current, 487 ); 488 489 // Get current palette as an array 490 $palette = flowplayer3_get_palette(); 491 492 // Build an array of titles to be used for each palette element 493 $names = array( 494 'backgroundColor' => array( 495 '#title' => t('Background color'), 496 ), 497 'controlbarbackgroundColor' => array( 498 '#title' => t('Control bar background color'), 499 ), 500 'timeColor' => array( 501 '#title' => t('Elapsed time font color'), 502 ), 503 'durationColor' => array( 504 '#title' => t('Total time font color'), 505 ), 506 'progressColor' => array( 507 '#title' => t('Progress bar color'), 508 ), 509 'bufferColor' => array( 510 '#title' => t('Buffer color'), 511 ), 512 'sliderColor' => array( 513 '#title' => t('Slider color'), 514 ), 515 'buttonColor' => array( 516 '#title' => t('Button color'), 517 ), 518 'buttonOverColor' => array( 519 '#title' => t('Button over color'), 520 ), 521 ); 522 523 // Form elements to be part of a tree 524 $form['flowplayer3_palette']['#tree'] = true; 525 526 // Cycle through each palette element 527 foreach ($palette as $name => $value) { 528 $form['flowplayer3_palette'][$name] = array( 529 '#type' => 'textfield', 530 '#title' => $names[$name]['#title'], 531 '#default_value' => $value, 532 '#size' => 8, 533 ); 534 } 535 536 // Return the form 537 return $form; 538 } 539 540 541 /** 542 * Theme the FlowPlayer3 color settings for the admin form. 543 */ 544 function theme_flowplayer3_scheme_form($form) { 545 546 $output = ''; 547 548 // Wrapper 549 $output .= '<div class="color-form clear-block">'; 550 551 // Color schemes 552 $output .= drupal_render($form['flowplayer3_scheme']); 553 554 // Palette 555 $output .= '<div id="palette" class="clear-block">'; 556 foreach (element_children($form['flowplayer3_palette']) as $name) { 557 $output .= drupal_render($form['flowplayer3_palette'][$name]); 558 } 559 $output .= '</div>'; 560 561 // Close wrapper 562 $output .= '</div>'; 563 564 return $output; 565 } 566 567 568 /** 569 * Flush all caches when new FlowPlayer3 settings are stored. 570 */ 571 function flowplayer3_admin_settings_submit($form, &$form_state) { 572 573 // Flush all caches so new players appear 574 drupal_flush_all_caches(); 575 576 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |