function soundcloudfield_widget_settings in SoundCloud field 6
Implementation of hook_widget_settings().
File
- ./
soundcloudfield.module, line 152 - SoundCloud CCK field.
Code
function soundcloudfield_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form = array();
if ($widget['type'] == 'soundcloud_url') {
$width = variable_get('soundcloudfield_default_width', SOUNDCLOUDFIELD_DEFAULT_WIDTH);
$height = variable_get('soundcloudfield_default_height', SOUNDCLOUDFIELD_DEFAULT_HEIGHT);
$setheight = variable_get('soundcloudfield_default_setheight', SOUNDCLOUDFIELD_DEFAULT_HEIGHT_SETS);
$form['player'] = array(
'#type' => 'fieldset',
'#title' => t('SoundCloud settings'),
'#description' => t('SoundCloud field settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['player']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#size' => 4,
'#default_value' => isset($widget['width']) && is_numeric($widget['width']) ? $widget['width'] : $width,
'#required' => TRUE,
'#description' => t('Player width in percent. Default is @width.', array(
'@width' => $width,
)),
);
$form['player']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height for tracks'),
'#size' => 4,
'#default_value' => isset($widget['height']) && is_numeric($widget['height']) ? $widget['height'] : $height,
'#required' => TRUE,
'#description' => t('Player height for tracks. Default is @height.', array(
'@height' => $height,
)),
);
$form['player']['setheight'] = array(
'#type' => 'textfield',
'#title' => t('Height for sets'),
'#size' => 4,
'#default_value' => isset($widget['setheight']) && is_numeric($widget['setheight']) ? $widget['setheight'] : $setheight,
'#required' => TRUE,
'#description' => t('Player height for sets. Default is @height.', array(
'@height' => $setheight,
)),
);
$form['player']['showcomments'] = array(
'#type' => 'checkbox',
'#title' => t('Show comments'),
'#default_value' => isset($widget['showcomments']) ? $widget['showcomments'] : FALSE,
'#description' => t('Show comments in player.'),
);
$form['player']['autoplay'] = array(
'#type' => 'checkbox',
'#title' => t('Autoplay'),
'#default_value' => isset($widget['autoplay']) ? $widget['autoplay'] : FALSE,
'#description' => t('Player autoplay.'),
);
$form['player']['showplaycount'] = array(
'#type' => 'checkbox',
'#title' => t('Show play count'),
'#default_value' => isset($widget['showplaycount']) ? $widget['showplaycount'] : FALSE,
'#description' => t('Show play count in player.'),
);
$form['player']['showartwork'] = array(
'#type' => 'checkbox',
'#title' => t('Show artwork'),
'#default_value' => isset($widget['showartwork']) ? $widget['showartwork'] : FALSE,
'#description' => t('Show artwork in player.'),
);
$form['player']['color'] = array(
'#type' => module_exists('jquery_colorpicker') ? 'colorpicker' : 'textfield',
'#title' => t('Player color'),
'#default_value' => isset($widget['color']) ? $widget['color'] : '0678be',
'#required' => TRUE,
'#description' => t('Player color in hexadecimal format. Default is 0678be. Turn on the jQuery Colorpicker module if available.'),
);
}
return $form;
case 'validate':
if (!is_numeric($widget['width']) || intval($widget['width']) != $widget['width'] || $widget['width'] < 1 || $widget['width'] > 100) {
form_set_error('width', t('Player width must be a positive integer between 1-100'));
}
if (!is_numeric($widget['height']) || intval($widget['height']) != $widget['height'] || $widget['height'] < 1) {
form_set_error('height', t('Player height must be a positive integer.'));
}
if (!is_numeric($widget['setheight']) || intval($widget['setheight']) != $widget['setheight'] || $widget['setheight'] < 1) {
form_set_error('setheight', t('Player height for sets must be a positive integer.'));
}
case 'save':
if ($widget['widget_type'] == 'soundcloud_url') {
$settings = array(
'width',
'height',
'setheight',
'showcomments',
'autoplay',
'showplaycount',
'showartwork',
'color',
);
}
return $settings;
}
}