| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: swftools.admin.inc,v 1.4.2.3 2009/04/18 23:30:52 stuartgreenfield Exp $ 3 4 function swftools_admin_embed_form() { 5 6 // Clear all caches 7 drupal_flush_all_caches(); 8 9 // Get array of options that will be used for form elements 10 $swf_options = _swftools_options(); 11 12 // Add admin css 13 drupal_add_css(drupal_get_path('module', 'swftools') . '/swftools.admin.css', 'module', 'all', FALSE); 14 15 // Get playlist path 16 $playlist_path = swftools_get_playlist_path(); 17 18 // Get player path 19 $player_directory = swftools_get_player_path() . '/'; 20 21 // Initialise array to hold the form 22 $form = array(); 23 24 // Start a fieldset to hold the embedding methods 25 $form['swftools_method'] = array( 26 '#type' => 'fieldset', 27 '#title' => t('Embedding methods'), 28 '#collapsible' => TRUE, 29 '#collapsed' => TRUE, 30 ); 31 32 // Get the available embedding methods 33 $methods = swftools_methods_available(SWFTOOLS_EMBED_METHOD); 34 35 // Build array of options ready for the selector 36 if (count($methods)) { 37 foreach ($methods AS $method => $info) { 38 39 // Only show this method as an embedding method if it is not a private method 40 if (!isset($info['private'])) { 41 42 // Start with the name of the player 43 $swf_embed_methods[$method] = $info['title']; 44 45 // If the required shared file is missing add a message explaining 46 if (!file_exists($player_directory . $info['shared_file'])) { 47 48 // Set an error on the form so the field set expands and highlights the error 49 form_set_error(SWFTOOLS_EMBED_METHOD, t('The shared file for @method is missing.', array('@method' => $info['title']))); 50 51 // Add missing message to the form 52 $swf_embed_methods[$method] = $swf_embed_methods[$method] . ' - <span class="error">Missing '. $info['shared_file'] .'</span>'; 53 54 // If download data is available then add a download link 55 if ($info['download']) { 56 $swf_embed_methods[$method] = $swf_embed_methods[$method] . ' - ' . l(t('Download here'), $info['download']); 57 } 58 } 59 } 60 } 61 } 62 63 $form['swftools_method'][SWFTOOLS_EMBED_METHOD] = array( 64 '#type' => 'radios', 65 '#title' => t('Method'), 66 '#default_value' => variable_get(SWFTOOLS_EMBED_METHOD, SWFTOOLS_NOJAVASCRIPT), 67 '#options' => $swf_embed_methods, 68 '#description' => t('Choose the method that will be used for Flash replacement. JavaScript methods 69 require supporting JavaScript files to be downloaded and added to an appropriate 70 sub-directory of <em>%default</em>. Direct embedding is built in to SWF Tools.', 71 array('%default' => t(drupal_get_path('module', 'swftools') . '/shared')) 72 ), 73 ); 74 75 // Might have another setting like above for SIFR, if it ever gets used 76 $form['swftools_method']['swftools_always_add_js'] = array( 77 '#type' => 'checkbox', 78 '#title' => t('Add JavaScript to all pages'), 79 '#default_value' => variable_get('swftools_always_add_js', SWFTOOLS_ALWAYS_ADD_JS), 80 '#description' => t('Modules such as filters result in caching of the mark up generated 81 to display Flash content. In these cases SWF Tools will not be 82 triggered to add the necessary JavaScript to the page and the Flash 83 content will not display. Enable this setting to push the necessary 84 JavaScript into the header of every page. This will ensure that cached 85 filter results are processed correctly. 86 '), 87 ); 88 89 /** 90 // This feature is not yet implemented 91 $form['swftools_method']['swftools_user_no_js'] = array( 92 '#type' => 'checkbox', 93 '#title' => t('Allow users to override embedding methods'), 94 '#disabled' => TRUE, 95 '#default_value' => variable_get('swftools_user_no_js', FALSE), 96 '#description' => t('User can choose how Flash content is delivered overriding 97 the \'Method\' setting above. Adds a setting to the profile page.'), 98 ); 99 **/ 100 101 $form['swftools_method']['swftools_html_alt'] = array( 102 '#type' => 'textarea', 103 '#title' => t('HTML alternative'), 104 '#default_value' => variable_get('swftools_html_alt', SWFTOOLS_DEFAULT_HTML_ALT), 105 '#description' => t('Enter the default HTML that will appear if the Flash 106 content cannot be embedded.'), 107 ); 108 109 $form['swftools_params'] = array( 110 '#type' => 'fieldset', 111 '#collapsible' => TRUE, 112 '#collapsed' => TRUE, 113 '#title' => t('Default settings for embedding'), 114 '#description' => t('Please refer to !technote for more details about each setting. 115 If you are looking for the \'base\' option, this is defined 116 in the \'File Locations\' settings above.', 117 array('!technote' => l('Adobe technote 12701', 'http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701'))), 118 ); 119 120 $form['swftools_params']['swftools_params_version'] = array( 121 '#type' => 'textfield', 122 '#size' => '5', 123 '#title' => 'Flash version', 124 '#default_value' => variable_get('swftools_params_version', '7'), 125 ); 126 127 $form['swftools_params']['swftools_params_play'] = array( 128 '#type' => 'checkbox', 129 '#title' => t('<strong>Play immediately</strong> (play)'), 130 '#default_value' => variable_get('swftools_params_play', TRUE), 131 ); 132 133 $form['swftools_params']['swftools_params_loop'] = array( 134 '#type' => 'checkbox', 135 '#title' => t('<strong>Loop movie</strong> (loop) .'), 136 '#default_value' => variable_get('swftools_params_loop', TRUE), 137 ); 138 139 $form['swftools_params']['swftools_params_menu'] = array( 140 '#type' => 'checkbox', 141 '#title' => t('<strong>Full menu</strong> (menu) Displays the full menu, allowing 142 the user a variety of options to enhance or control playback.'), 143 '#default_value' => variable_get('swftools_params_menu', FALSE), 144 ); 145 146 $form['swftools_params']['swftools_params_allowfullscreen'] = array( 147 '#type' => 'checkbox', 148 '#title' => t('<strong>Allow full screen mode</strong> (allowfullscreen)'), 149 '#default_value' => variable_get('swftools_params_allowfullscreen', TRUE), 150 ); 151 152 $form['swftools_params']['swftools_params_bgcolor'] = array( 153 '#type' => 'textfield', 154 '#title' => t('Background color <span class="weight-normal">(bgcolor)</span>'), 155 '#size' => 7, 156 '#maxlength' => 7, 157 '#required' => TRUE, 158 '#default_value' => variable_get('swftools_params_bgcolor', '#FFFFFF'), 159 '#description' => t('Hexadecimal background color in the form #RRGGBB.'), 160 ); 161 162 $form['swftools_params']['swftools_params_quality'] = array( 163 '#type' => 'select', 164 '#title' => t('Quality') . ' <span class="weight-normal">(quality)</span>', 165 '#default_value' => variable_get('swftools_params_quality', 'autohigh'), 166 '#options' => $swf_options['quality'], 167 ); 168 169 $form['swftools_params']['swftools_params_scale'] = array( 170 '#type' => 'select', 171 '#title' => t('Scale') . ' <span class="weight-normal">(scale)</span>', 172 '#default_value' => variable_get('swftools_params_scale', 'showall'), 173 '#options' => $swf_options['scale'], 174 ); 175 176 $form['swftools_params']['swftools_params_wmode'] = array( 177 '#type' => 'select', 178 '#title' => t('Window mode') . ' <span class="weight-normal">(wmode)</span>', 179 '#default_value' => variable_get('swftools_params_wmode', 'opaque'), 180 '#options' => $swf_options['wmode'], 181 ); 182 183 $form['swftools_params']['swftools_params_align'] = array( 184 '#type' => 'select', 185 '#title' => t('Align') . ' <span class="weight-normal">(align)</span>', 186 '#default_value' => variable_get('swftools_params_align', 'l'), 187 '#options' => $swf_options['align'], 188 ); 189 190 $form['swftools_params']['swftools_params_salign'] = array( 191 '#type' => 'select', 192 '#title' => t('salign') . ' <span class="weight-normal">(salign)</span>', 193 '#default_value' => variable_get('swftools_params_salign', 'tl'), 194 '#options' => $swf_options['salign'], 195 ); 196 197 $form['swftools_params']['swftools_params_swliveconnect'] = array( 198 '#type' => 'select', 199 '#options' => array('true' => 'Yes', 'default' => 'No'), // 'default' setting will simple omit this value for simplicity. 200 '#title' => t('Load Java') . ' <span class="weight-normal">(swliveconnect)</span>', 201 '#default_value' => variable_get('swftools_params_swliveconnect', 'default'), 202 ); 203 204 $form['swftools_params']['swftools_params_allowscriptaccess'] = array( 205 '#type' => 'select', 206 '#options' => $swf_options['allowscriptaccess'], 207 '#title' => t('Allow script access') . ' <span class="weight-normal">(allowscriptaccess)</span>', 208 '#default_value' => variable_get('swftools_params_allowscriptaccess', 'sameDomain'), 209 ); 210 211 return system_settings_form($form); 212 213 } 214 215 function swftools_admin_handling_form() { 216 217 // Clear all caches 218 drupal_flush_all_caches(); 219 220 $playlist_path = swftools_get_playlist_path(); 221 $player_directory = swftools_get_player_path() . '/'; 222 223 $form = array(); 224 225 $form['swftools_files'] = array( 226 '#type' => 'fieldset', 227 '#title' => t('File locations'), 228 '#collapsible' => TRUE, 229 '#collapsed' => TRUE, 230 ); 231 232 $form['swftools_files']['swftools_player_path'] = array( 233 '#type' => 'textfield', 234 '#title' => t('Default flash player path'), 235 '#default_value' => variable_get('swftools_player_path', SWFTOOLS_PLAYER_PATH), 236 '#description' => t('Leave this blank to default to the shared player file 237 inside the swftools module (%default). Otherwise your options are:<ul> 238 <li>a path inside your files directory, <em>without</em> 239 a preceding slash (eg. <strong>myplayers</strong>), or</li> 240 <li>a path from the webroot <em>with</em> a preceding slash. 241 (eg <strong>/alternate_filepath</strong>)</li></ul>', 242 array('%default' => t(drupal_get_path('module', 'swftools') . '/shared')) 243 ), 244 ); 245 246 $form['swftools_files']['swftools_playlist_path'] = array( 247 '#type' => 'textfield', 248 '#title' => t('Directory in files where playlist/xml files can be cached'), 249 '#default_value' => variable_get('swftools_playlist_path', SWFTOOLS_PLAYLIST_PATH), 250 '#description' => t('A location inside your files directory 251 without preceding or trailing slashes (eg. <strong>playlists</strong>)'), 252 ); 253 254 $current_path = variable_get('swftools_media_url', $GLOBALS['base_url'] . '/' . file_create_path('')); 255 256 // Misname the variable with '_dummy' so that it is not saved! 257 $form['swftools_files']['swftools_media_url_dummy'] = array( 258 '#type' => 'textfield', 259 '#title' => t('Media directory url'), 260 '#default_value' => $current_path, 261 '#disabled' => TRUE, 262 '#description' => t("This helps swftools identify the server where your media files are located. 263 You cannot change it here, as changing it has the potential to break existing 264 content. You can set this on the $conf array in your settings.php file. 265 For example: <pre> 266 $conf = array( 267 'swftools_media_url' => 'http://anothersite.com/media', // No trailing slashes! 268 );</pre> Leaving this value unset in your settings.php file will 269 persuade SWF Tools to check for the existence of your 270 media files, as they are automatically assumed to be 271 on the local server."), 272 ); 273 274 $form['swftools_files']['swftools_check_media'] = array( 275 '#type' => 'checkbox', 276 '#title' => t('Check if local files exist'), 277 '#default_value' => variable_get('swftools_check_media', TRUE), 278 '#description' => t('This option will cause SWF Tools to check that requested local 279 media files exist, and issue a warning if they do not.'), 280 ); 281 282 $form['swftools']['handling'] = array( 283 '#type' => 'fieldset', 284 '#title' => t('File handling'), 285 '#collapsible' => TRUE, 286 '#collapsed' => TRUE, 287 '#description' => 'Choose how different file types are handled.', 288 ); 289 290 $form['swftools']['handling'][SWFTOOLS_FLV_DISPLAY] = 291 _swftools_admin_file_handling_option(SWFTOOLS_FLV_DISPLAY, $player_directory, "Default player for single FLV movies"); 292 293 $form['swftools']['handling'][SWFTOOLS_MP3_DISPLAY] = 294 _swftools_admin_file_handling_option(SWFTOOLS_MP3_DISPLAY, $player_directory, "Default player for single MP3 files"); 295 296 $form['swftools']['handling'][SWFTOOLS_SWF_DISPLAY] = 297 _swftools_admin_file_handling_option(SWFTOOLS_SWF_DISPLAY, $player_directory, "Default player for single SWF files"); 298 299 $form['swftools']['handling'][SWFTOOLS_IMAGE_DISPLAY_LIST] = 300 _swftools_admin_file_handling_option(SWFTOOLS_IMAGE_DISPLAY_LIST, $player_directory, "Default player for a list of images"); 301 302 $form['swftools']['handling'][SWFTOOLS_FLV_DISPLAY_LIST] = 303 _swftools_admin_file_handling_option(SWFTOOLS_FLV_DISPLAY_LIST, $player_directory, "Default player for a list of FLV movies"); 304 305 $form['swftools']['handling'][SWFTOOLS_MP3_DISPLAY_LIST] = 306 _swftools_admin_file_handling_option(SWFTOOLS_MP3_DISPLAY_LIST, $player_directory, "Default player for a list of MP3 music files"); 307 308 $form['swftools']['handling'][SWFTOOLS_MEDIA_DISPLAY_LIST] = 309 _swftools_admin_file_handling_option(SWFTOOLS_MEDIA_DISPLAY_LIST, $player_directory, "Default player for a list of mixed media"); 310 311 // Playlist settings 312 $form['swftools']['playlist'] = array( 313 '#type' => 'fieldset', 314 '#title' => t('Playlist caching'), 315 '#collapsible' => TRUE, 316 '#collapsed' => TRUE, 317 '#description' => 'Settings for XML files and playlists.', 318 ); 319 320 $caching = variable_get('swftools_playlist_caching', 'here'); 321 322 if ($caching == 'here') { 323 // Check the user didn't set the playlist path to their file system top level before deleting everything! 324 $playlist_path = variable_get('swftools_playlist_path', SWFTOOLS_PLAYLIST_PATH); 325 if (!empty($playlist_path)) { 326 file_scan_directory(swftools_get_playlist_path(), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE); 327 } 328 } 329 330 $form['swftools']['playlist']['swftools_playlist_caching'] = array( 331 '#type' => 'select', 332 '#title' => t('Clear playlist cache'), 333 '#default_value' => $caching, 334 '#options' => array('here' => 'Only here', 'always' => 'Every page view'), 335 '#description' => 'Select \'Only here\' to clear the playlist directory just ' . 336 'by visiting this page. It is useful to select \'Every ' . 337 'page view\' for site or module development but not ' . 338 'advisable for live sites.', 339 ); 340 341 $form['swftools_private'] = array( 342 '#type' => 'fieldset', 343 '#title' => t('Private file system'), 344 '#collapsible' => TRUE, 345 '#collapsed' => TRUE, 346 ); 347 348 // Allow SWF Tools to grant access to non-uploaded files 349 $form['swftools_private']['swftools_grant_access_to_private_files'] = array( 350 '#type' => 'checkbox', 351 '#title' => t('Allow SWF Tools to grant access to supported private files'), 352 '#default_value' => variable_get('swftools_grant_access_to_private_files', SWFTOOLS_GRANT_ACCESS_TO_PRIVATE_FILES), 353 '#description' => t('If using a private file system then SWF Tools is unable to 354 access files that are not uploaded via a file module that 355 supports a private file system. For example, SWF Tools will 356 be unable to access files that were manually uploaded via FTP. 357 Enabling this setting will allow SWF Tools to grant access 358 to files with extensions defined by the next setting. 359 Note - if another module <em>denies</em> access then access 360 to the file will not be granted. SWF Tools itself does not 361 deny access to any file. SWF Tools always allows access 362 to files in the playlists directory. 363 '), 364 ); 365 366 // Default file extensions that SWF Tools will grant access for 367 $form['swftools_private']['swftools_grant_access_extensions'] = array( 368 '#type' => 'textfield', 369 '#title' => t('Extensions that SWF Tools will allow access to'), 370 '#default_value' => variable_get('swftools_grant_access_extensions', SWFTOOLS_GRANT_ACCESS_EXTENSIONS), 371 '#maxlength' => 255, 372 '#description' => t('Under a private file system SWF Tools will grant access to files 373 with extensions in this list. Separate extensions with a space 374 and do not include the leading dot. Although any extension can be 375 added to this list, only <em>swf flv xml mp3 jpg jpeg</em> and 376 <em>png</em> will return the correct headers.'), 377 ); 378 379 return system_settings_form($form); 380 } 381 382 383 function _swftools_admin_file_handling_option($type, $player_directory, $description) { 384 385 // Initialise list of methods 386 $list = array(); 387 388 // Obtain list of available methods 389 $methods = swftools_methods_available($type); 390 if (count($methods)) { 391 foreach ($methods AS $method => $info) { 392 if (!file_exists($player_directory . $info['shared_file'])) { 393 $list[$method] = $info['title'] . ' - <span class="error">Missing '. $info['shared_file'] .'</span>'; 394 if ($info['download']) { 395 $list[$method] = $list[$method] . ' - ' . l(t('Download here'), $info['download']); 396 } 397 } 398 else { 399 $list[$method] = $info['title']; 400 } 401 } 402 } 403 404 // Sort the list of methods 405 asort($list); 406 407 // None is always an option so add this at the top of the list 408 $list = array('None') + $list; 409 410 // Determine the appropriate default based on $type 411 $default = swftools_get_player($type); 412 413 // swftools_get_player() returns FALSE for nothing configured, change to 0 414 if (!$default) { 415 $default = 0; 416 } 417 418 return array( 419 '#type' => 'radios', 420 '#title' => t($description), 421 '#default_value' => $default, 422 '#options' => $list, 423 ); 424 425 } 426 427 428 /** 429 * flashvar and param option arrays. These are used for options settings in the 430 * configuration screen and also as a lookup (particularly 'bool') to output the correct value for to html. 431 * 432 */ 433 function _swftools_options() { 434 // cache output each request 435 static $swf_options = array(); 436 if (!count($swf_options)) { 437 $swf_options['quality'] = array('low' => 'low', 'autolow' => 'autolow', 'medium' => 'medium', 'high' => 'high', 'autohigh' => 'autohigh', 'best' => 'best', ); 438 $swf_options['wmode'] = array('window' => 'window', 'opaque' => 'opaque', 'transparent' => 'transparent', ); 439 $swf_options['scale'] = array('showall' => 'showall', 'noborder' => 'noborder', 'exactfit' => 'exactfit', ); 440 $swf_options['align'] = array('default' => 'centered', 'l' => 'left', 'r' => 'right', 't' => 'top', 'b' => 'bottom', ); 441 $swf_options['salign'] = array('l' => 'left', 'r' => 'right', 't' => 'top', 'b' => 'bottom', 'tl' => 'top left', 'tr' => 'top right', 'bl' => 'bottom left', 'br' => 'bottom right', ); 442 $swf_options['bool'] = array('default' => 'default', 'true' => 'true', 'false' => 'false'); 443 $swf_options['allowscriptaccess'] = array('always' => 'always', 'sameDomain' => 'sameDomain', 'never' => 'never'); 444 } 445 return $swf_options; 446 } 447 448 449 /** 450 * Menu callback: Settings form for configuring CCK playlist fallbacks. 451 */ 452 function swftools_admin_cck_form() { 453 454 // Get a list of all content types in use 455 $content_types = content_types(); 456 457 // Get a list of all the CCK fields that are in use 458 $fields = content_fields(); 459 460 // If filefield isn't in the list of fields then stop now 461 if (!isset($field_types['filefield'])) { 462 $form['description'] = array( 463 '#value' => '<p>' . t('No filefields have been created.') . '</p>', 464 ); 465 } 466 467 // Get a list of all field types (this contains the list of formatters 468 $field_types = _content_field_types(); 469 470 // Put a description on the page 471 $form['description'] = array( 472 '#value' => '<p>' . t('For content that is being formatted as an SWF Tools playlist you can specify an alternate format that should be used if a 473 single file is passed to the playlist function. For example, display a single image as a regular image instead of placing 474 it in a slideshow.') . '</p><p>' . t('Content types that contain fields that have been configured to be formatted as an 475 SWF Tools playlist are listed below.') . '</p>', 476 ); 477 478 // Get the filefield formatters as a list of options 479 $options = array(); 480 foreach ($field_types['filefield']['formatters'] as $formatter_name => $formatter_info) { 481 $options[$formatter_name] = $formatter_info['label']; 482 } 483 $options['hidden'] = t('<Hidden>'); 484 485 // Cycle through each content type 486 foreach ($content_types as $type => $type_info) { 487 488 // See if fields are in use on this type 489 if (isset($type_info['fields'])) { 490 491 // If fields are in use then cycle through them 492 foreach ($type_info['fields'] as $field => $field_info) { 493 494 // If field is a filefield type then we might be interested in it 495 if ($field_info['type'] == 'filefield') { 496 497 // Check if something is trying to use a playlist 498 // At the moment not sure we can distinguish between teaser and full view since we only make this check during the theming stage 499 // if ($field_info['display_settings']['teaser']['format'] == 'swftools_playlist') { 500 // 501 // $form['swftools_' . $type . '_' . $field . '_teaser'] = array( 502 // '#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']) . ' - ' . t('teaser'), 503 // '#type' => 'select', 504 // '#options' => $options, 505 // '#default_value' => variable_get('swftools_' . $type . '_' . $field . '_teaser' ,'swftools_playlist'), 506 // ); 507 // } 508 // 509 // // Check full view next 510 // if ($field_info['display_settings']['full']['format'] == 'swftools_playlist') { 511 // $form['swftools_' . $type . '_' . $field . '_full'] = array( 512 // '#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']) . ' - ' . t('full node'), 513 // '#type' => 'select', 514 // '#options' => $options, 515 // '#default_value' => variable_get('swftools_' . $type . '_' . $field . '_full' ,'swftools_playlist'), 516 // ); 517 // } 518 519 // See if either of the teaser or body are set to be a playlist 520 if ($field_info['display_settings']['teaser']['format'] == 'swftools_playlist' || $field_info['display_settings']['full']['format'] == 'swftools_playlist') { 521 522 // If they are then create a form entry in the form swftools_{type}_{field} 523 $form['swftools_' . $type . '_' . $field] = array( 524 '#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']), 525 '#type' => 'select', 526 '#options' => $options, 527 '#default_value' => variable_get('swftools_' . $type . '_' . $field ,'swftools_playlist'), 528 ); 529 530 } 531 } 532 } 533 } 534 } 535 536 // Return a system settings form 537 return system_settings_form($form); 538 539 }
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 |