function swftools_admin_embed_form in SWF Tools 6.3
Same name and namespace in other branches
- 5 swftools.module \swftools_admin_embed_form()
- 6 swftools.admin.inc \swftools_admin_embed_form()
- 6.2 swftools.admin.inc \swftools_admin_embed_form()
Form definition for embedding settings.
2 string references to 'swftools_admin_embed_form'
- swftools_api_menu in api/
swftools_api.module - Implementation of hook_menu().
- swftools_menu in ./
swftools.module - Implementation of hook_menu().
File
- includes/
swftools.admin.inc, line 15 - Configuration settings for SWF Tools.
Code
function swftools_admin_embed_form() {
// Get array of options that will be used for form elements
$swf_options = _swftools_options();
// See if colorpicker 2 is loaded
$colorfield = function_exists('colorpicker_2_or_later') ? 'colorpicker_textfield' : 'textfield';
// Add admin css
drupal_add_css(drupal_get_path('module', 'swftools') . '/swftools.admin.css', 'module', 'all', FALSE);
// Initialise array to hold the form
$form = array();
// Start a fieldset to hold the embedding methods
$form['swftools_method'] = array(
'#type' => 'fieldset',
'#title' => t('Embedding'),
'#description' => t('Flash content can be embedded on a page directly, using <object> tags, or
JavaScript can be used to dynamically replace content on the page with the Flash
movie. SWF Tools supports direct embedding without installing any additional
modules, but JavaScript methods require that the supporting module is enabled, and
may require a JavaScript library to be downloaded. JavaScript interaction between
the page and the Flash movie is possible with both direct embedding and
JavaScript methods. Note that the direct embedding method does not support the Flash
express install feature.'),
);
// Get the available embedding methods
$methods = swftools_get_methods('swftools_embed_method');
// Build array of options ready for the selector
if (count($methods)) {
foreach ($methods as $method => $info) {
// Assume method is not private and that it has no accompanying library
$info += array(
'private' => FALSE,
'library' => '',
);
// Only show this method as an embedding method if it is not a private method
if (!$info['private']) {
// Start with the name of the player
$swf_embed_methods[$method] = $info['title'];
// If the required shared file is missing add a message explaining
if ($info['library'] && !file_exists($info['library'])) {
// Only set a form error if the error is OTHER THAN SWF Object2 as
// the SWF Object 2 module can access the remote library
if ($info['name'] != 'swftools_swfobject2') {
// Set an error on the form so the field set expands and highlights the error
form_set_error('swftools_embed_method', t('The shared file for @method is missing.', array(
'@method' => $info['title'],
)));
}
// Add missing message to the form
// TODO: Could make a customised message for SWF Object 2 missing
$swf_embed_methods[$method] = $swf_embed_methods[$method] . ' - <span class="error">Missing ' . $info['library'] . '</span>';
// If download data is available then add a download link
if ($info['download']) {
$swf_embed_methods[$method] = $swf_embed_methods[$method] . ' - ' . l(t('Download here'), $info['download']);
}
}
}
}
}
$form['swftools_method']['swftools_embed_method'] = array(
'#type' => 'radios',
'#title' => t('Embedding method'),
'#default_value' => variable_get('swftools_embed_method', 'swftools_direct'),
'#options' => $swf_embed_methods,
);
$form['swftools_method']['swftools_always_add_js'] = array(
'#type' => 'radios',
'#title' => t('Add JavaScript to all pages'),
'#default_value' => variable_get('swftools_always_add_js', SWFTOOLS_ALWAYS_ADD_JS),
'#options' => array(
0 => t('Disabled'),
1 => t('Enabled (recommended)'),
),
'#description' => t('Modules such as filters result in caching of the mark up generated
to display Flash content. In these cases SWF Tools will not be
triggered to add the necessary JavaScript to the page and the Flash
content will not display. Normally you should leave this setting
enabled. Setting it to disabled may prevent content from appearing.
'),
);
$form['swftools_method']['swftools_javascript_location'] = array(
'#type' => 'radios',
'#title' => t('JavaScript placement'),
'#default_value' => variable_get('swftools_javascript_location', SWFTOOLS_JAVASCRIPT_INLINE),
'#options' => array(
SWFTOOLS_JAVASCRIPT_INLINE => t('Body'),
SWFTOOLS_JAVASCRIPT_HEADER => t('Header'),
SWFTOOLS_JAVASCRIPT_FOOTER => t('Footer'),
),
'#description' => t('Scripts to activate JavaScript embedding can be placed in line with
the page markup, or placed in the page header or footer. If you are
using the input filter to generate content you should <em>not</em>
put the JavaScript in the header or footer as it will not be cached
and the content will not display. If you are using CCK then script
can safely be placed in the header or footer if you prefer to avoid
mixing JavaScript within the page body.'),
);
// Text area to define the alternate HTML content
$form['swftools_method']['swftools_html_alt'] = array(
'#type' => 'textarea',
'#title' => t('HTML alternative'),
'#default_value' => variable_get('swftools_html_alt', SWFTOOLS_DEFAULT_HTML_ALT),
'#description' => t('Enter the default HTML that will appear if the Flash
content cannot be embedded.'),
);
// Put an input format selector on the form
$form['swftools_method']['swftools_html_alt_format'] = filter_form(variable_get('swftools_html_alt_format', FILTER_FORMAT_DEFAULT), NULL, array(
'swftools_html_alt_format',
));
// Choose whether over-riding of alternate HTML will be allowed
$form['swftools_method']['swftools_override_html_alt'] = array(
'#type' => 'radios',
'#title' => t('Override of HTML alternative via the input filter'),
'#default_value' => variable_get('swftools_override_html_alt', 0),
'#options' => array(
0 => t('Disabled (recommended)'),
1 => t('Enabled'),
),
'#description' => t('When enabled then the alternate HTML string can be
overridden via the input filter. When disabled the
default alternate HTML is enforced. Note that users
with access to PHP are always able to override the
HTML alternative irrespective of this setting.
'),
);
// Only display parameters if main SWF Tools module is present
if (defined('SWFTOOLS_INSTALLED')) {
// Get current params defaults
$params = _swftools_params();
// Convert true/false back to 1/0
swftools_admin_boolean_settings($params, SWFTOOLS_ADMIN_RETRIEVE);
$form['swftools_params'] = array(
'#type' => 'fieldset',
'#title' => t('Embedding parameters'),
'#description' => t('<p>These parameters determine various aspects of how the embedded Flash movie will be displayed, and how
the page can interact with it. These are the default settings that will be used if specific settings are
not provided when the content is being rendered.</p>
<p>Refer to !technote for more details about each setting.</p>', array(
'!technote' => l('Adobe technote 12701', 'http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701'),
)),
'#tree' => TRUE,
);
$form['swftools_params']['version'] = array(
'#type' => 'textfield',
'#size' => '8',
'#title' => 'Minimum Flash version',
'#default_value' => $params['version'],
);
$form['swftools_params']['play'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Play immediately</strong> (play)'),
'#default_value' => $params['play'],
);
$form['swftools_params']['loop'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Loop movie</strong> (loop)'),
'#default_value' => $params['loop'],
);
$form['swftools_params']['menu'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Full menu</strong> (menu)'),
'#default_value' => $params['menu'],
);
$form['swftools_params']['allowfullscreen'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Allow full screen mode</strong> (allowfullscreen)'),
'#default_value' => $params['allowfullscreen'],
);
$form['swftools_params']['swliveconnect'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Load Java</strong> (swliveconnect)'),
'#default_value' => $params['swliveconnect'],
);
$form['swftools_params']['bgcolor'] = array(
'#type' => $colorfield,
'#title' => t('Background color <span class="weight-normal">(bgcolor)</span>'),
'#size' => 7,
'#maxlength' => 7,
'#default_value' => $params['bgcolor'],
'#description' => t('Hexadecimal background color in the form #RRGGBB.'),
);
$form['swftools_params']['quality'] = array(
'#type' => 'select',
'#title' => t('Quality') . ' <span class="weight-normal">(quality)</span>',
'#default_value' => $params['quality'],
'#options' => $swf_options['quality'],
);
$form['swftools_params']['scale'] = array(
'#type' => 'select',
'#title' => t('Scale') . ' <span class="weight-normal">(scale)</span>',
'#default_value' => $params['scale'],
'#options' => $swf_options['scale'],
);
$form['swftools_params']['wmode'] = array(
'#type' => 'select',
'#title' => t('Window mode') . ' <span class="weight-normal">(wmode)</span>',
'#default_value' => $params['wmode'],
'#options' => $swf_options['wmode'],
);
$form['swftools_params']['align'] = array(
'#type' => 'select',
'#title' => t('Align') . ' <span class="weight-normal">(align)</span>',
'#default_value' => $params['align'],
'#options' => $swf_options['align'],
);
$form['swftools_params']['salign'] = array(
'#type' => 'select',
'#title' => t('salign') . ' <span class="weight-normal">(salign)</span>',
'#default_value' => $params['salign'],
'#options' => $swf_options['salign'],
);
$form['swftools_params']['allowscriptaccess'] = array(
'#type' => 'select',
'#options' => $swf_options['allowscriptaccess'],
'#title' => t('Allow script access') . ' <span class="weight-normal">(allowscriptaccess)</span>',
'#default_value' => $params['allowscriptaccess'],
);
// Add custom form handler to convert 1/0 to true/false
$form['#submit'][] = 'swftools_admin_embed_submit';
}
// Add custom form handler to flush cache upon submit
$form['#submit'][] = 'swftools_admin_settings_submit';
// Return the form
return system_settings_form($form);
}