function swftools_admin_cck_form in SWF Tools 6.3
Same name and namespace in other branches
- 6.2 swftools.admin.inc \swftools_admin_cck_form()
Menu callback: Settings form for configuring CCK playlist fallbacks.
1 string reference to 'swftools_admin_cck_form'
- swftools_menu in ./
swftools.module - Implementation of hook_menu().
File
- includes/
swftools.admin.inc, line 588 - Configuration settings for SWF Tools.
Code
function swftools_admin_cck_form() {
// Get a list of all content types in use
$content_types = content_types();
// Get a list of all the CCK fields that are in use
$fields = content_fields();
// Get a list of all field types (this contains the list of formatters)
$field_types = _content_field_types();
// Put a description on the page
$form['description'] = array(
'#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
single file is passed to the playlist function. For example, display a single image as a regular image instead of placing
it in a slideshow.') . '</p>',
);
// Initialise an empty array
$swftools_types = array();
// Discover what field types are supporting SWF Tools formatters
foreach ($field_types as $type => $data) {
if (isset($data['formatters']['swftools_playlist'])) {
$swftools_types[] = $type;
}
}
// Sort the list of types ready for output
asort($swftools_types);
// If the array is empty no field type is supporting the playlist formatter
if (!$swftools_types) {
// Just return an informative message
$form['no fields'] = array(
'#value' => '<p>' . t('No CCK fields that support SWF Tools playlists have been created.') . '</p>',
);
}
else {
// Iterate over types that support SWF Tools formatters
foreach ($swftools_types as $swftools_type) {
// Add descriptive message
$form['filefields'] = array(
'#value' => '<p>' . t('Content types that contain fields that have been configured to be formatted as an
SWF Tools playlist are listed below.') . '</p>',
);
// Initialise an array to hold formatters
$options = array();
// Collect all the available formatters
foreach ($field_types[$swftools_type]['formatters'] as $formatter_name => $formatter_info) {
$options[$formatter_name] = $formatter_info['label'];
}
// Add hidden as an optional formatter
$options['hidden'] = t('<Hidden>');
// Cycle through each content type
foreach ($content_types as $type => $type_info) {
// See if fields are in use on this type
if (isset($type_info['fields'])) {
// If fields are in use then cycle through them
foreach ($type_info['fields'] as $field => $field_info) {
// If field is a filefield type then we might be interested in it
if ($field_info['type'] == $swftools_type) {
// See if either of the teaser or body are set to be a playlist
if ($field_info['display_settings']['teaser']['format'] == 'swftools_playlist' || $field_info['display_settings']['full']['format'] == 'swftools_playlist') {
// If they are then create a form entry in the form swftools_{type}_{field}
$form['swftools_' . $type . '_' . $field] = array(
'#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']),
'#type' => 'select',
'#options' => $options,
'#default_value' => variable_get('swftools_' . $type . '_' . $field, 'swftools_playlist'),
);
}
}
}
}
}
}
}
// Add custom form handler to flush cache upon submit
$form['#submit'][] = 'swftools_admin_settings_submit';
// Return a system settings form
return system_settings_form($form);
}