function imageinfo_cache_cck_widget_form in Imageinfo Cache 6.2
Same name and namespace in other branches
- 6 imageinfo_cache.admin.inc \imageinfo_cache_cck_widget_form()
Called from imageinfo_cache_form_alter().
1 call to imageinfo_cache_cck_widget_form()
- imageinfo_cache_form_alter in ./
imageinfo_cache.module - Implements hook_form_alter().
File
- ./
imageinfo_cache.admin.inc, line 124 - Configuration page for imageinfo cache module.
Code
function imageinfo_cache_cck_widget_form(&$form, $form_state, $form_id) {
$widget_settings = variable_get('imageinfo_cache_cck_widget_' . $form['#field']['type_name'] . '_' . $form['#field']['field_name'], IMAGEINFO_CACHE_CCK_WIDGET);
$all = FALSE;
if (!is_array($widget_settings) && $widget_settings == TRUE) {
$all = TRUE;
}
// Add in settings form.
$form['widget']['imageinfo_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Imageinfo Cache'),
'#collapsible' => 1,
'#collapsed' => 1,
'#weight' => 20,
);
$form['widget']['imageinfo_cache']['imageinfo_cache_settings_all'] = array(
'#type' => 'checkbox',
'#title' => t('Select all imagecache presets to pregenerate when an image is uploaded'),
'#default_value' => $all,
'#description' => t('If not selected, settings will apear below allowing one to control what presets will be pregenerated.'),
'#disabled' => variable_get('imageinfo_cache_imagecache_pregenerate', IMAGEINFO_CACHE_IMAGECACHE_PREGENERATE) ? FALSE : TRUE,
);
foreach (imagecache_presets() as $preset) {
$presets[$preset['presetid']] = $preset['presetname'];
}
$form['widget']['imageinfo_cache']['imageinfo_cache_settings'] = array(
'#type' => 'checkboxes',
'#title' => t('Select the imagecache presets to pregenerate when an image is uploaded'),
'#options' => $presets,
'#default_value' => $all ? array_flip($presets) : $widget_settings,
'#prefix' => '<div id="imageinfo-cache-settings-widget">',
'#suffix' => '</div>',
);
// Add in submit handler.
if (!in_array('imageinfo_cache_cck_widget_form_submit', $form['#submit'])) {
$form['#submit'][] = 'imageinfo_cache_cck_widget_form_submit';
}
$widget_vis = "\n\$(imageinfo_cache_update_widget_visibility);\n\$(function(){ \$('#edit-imageinfo-cache-settings-all').change(function (){imageinfo_cache_update_widget_visibility();})});\nfunction imageinfo_cache_update_widget_visibility() {\n if (\$('#edit-imageinfo-cache-settings-all:checked').val() !== undefined) {\n \$('#imageinfo-cache-settings-widget').hide();\n }\n else {\n \$('#imageinfo-cache-settings-widget').show();\n }\n}";
drupal_add_js($widget_vis, 'inline');
}