function swftools_onepixelout_admin_form in SWF Tools 6.3
@file Configuration settings for OnePixelOut.
1 string reference to 'swftools_onepixelout_admin_form'
- swftools_onepixelout_menu in onepixelout/
swftools_onepixelout.module - Implementation of hook_menu().
File
- onepixelout/
swftools_onepixelout.admin.inc, line 8 - Configuration settings for OnePixelOut.
Code
function swftools_onepixelout_admin_form() {
// Get saved settings
$saved = _swftools_onepixelout_settings();
// See if colorpicker 2 is loaded
$can_pick = function_exists('colorpicker_2_or_later');
// Initialise array
$form = array();
$form['swftools_onepixelout']['height'] = array(
'#type' => 'textfield',
'#default_value' => $saved['height'],
'#title' => t('Height'),
'#description' => t('The height of the player in pixels.'),
'#size' => 8,
);
$form['swftools_onepixelout']['width'] = array(
'#type' => 'textfield',
'#default_value' => $saved['width'],
'#title' => t('Width'),
'#description' => t('The width of the player in pixels.'),
'#size' => 8,
);
$form['swftools_onepixelout']['autostart'] = array(
'#type' => 'select',
'#options' => array(
'yes' => 'yes',
'no' => 'no',
),
'#default_value' => $saved['autostart'],
'#title' => t('Autostart'),
'#description' => t('Automatically start playing the MP3. (<em>autostart</em>)'),
);
$form['swftools_onepixelout']['loop'] = array(
'#type' => 'select',
'#options' => array(
'yes' => 'yes',
'no' => 'no',
),
'#default_value' => $saved['loop'],
'#title' => t('Loop'),
'#description' => t('Loop the sound file back to the beginning when done. (<em>loop</em>)'),
);
$form['swftools_onepixelout']['map'] = array(
'#value' => '<img src="http://www.1pixelout.net/wp-content/plugins/audio-player/map.gif" alt="Player Map" />',
);
// Unset the parameters that aren't used to populate colours
unset($saved['height']);
unset($saved['width']);
unset($saved['loop']);
unset($saved['autostart']);
// Iterate over remaining parameters, which are now all color settings
foreach ($saved as $key => $color) {
$form['swftools_onepixelout'][$key] = array(
'#type' => ($can_pick ? 'colorpicker_' : '') . 'textfield',
'#default_value' => $can_pick ? preg_replace('/0x/', '#', $color) : $color,
'#size' => 8,
'#maxlength' => 8,
'#title' => t($key . ' color'),
'#description' => t('Hexadecimal color of the format !prefixRRGGBB', array(
'!prefix' => $can_pick ? '#' : '0x',
)),
);
}
// Initialise tree as we want to store arrays
$form['swftools_onepixelout']['#tree'] = TRUE;
// Add custom form handler to ensure colors are coded properly
$form['#submit'][] = 'swftools_onepixelout_admin_submit';
// Add custom form handler to flush cache upon submit
$form['#submit'][] = 'swftools_admin_settings_submit';
// Return finished form
return system_settings_form($form);
}