function _designkit_form_alter in DesignKit 6
Same name and namespace in other branches
- 7 designkit.admin.inc \_designkit_form_alter()
Implementation of hook_form_alter() for spaces_features_form, system_theme_settings.
2 calls to _designkit_form_alter()
- designkit_form_spaces_features_form_alter in ./
designkit.module - Spaces integration. Implementation of hook_form_alter() for spaces_features_form.
- designkit_form_system_theme_settings_alter in ./
designkit.module - Theme integration. Implementation of hook_form_alter() for system_theme_settings.
File
- ./
designkit.admin.inc, line 6
Code
function _designkit_form_alter(&$form, &$form_state) {
$info = designkit_get_info();
// Allow uploads
$form['#attributes'] = array(
'enctype' => 'multipart/form-data',
);
// Images
if (!empty($info['designkit']['image'])) {
$image = variable_get('designkit_image', array());
$form['designkit_image'] = array(
'#title' => t('Images'),
'#description' => t('Upload an image. It will be resized to better fit the design of this site.'),
'#type' => 'fieldset',
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => empty($image),
);
foreach ($info['designkit']['image'] as $name => $image_info) {
$form['designkit_image'][$name] = array(
'#tree' => TRUE,
);
if (!empty($image[$name]) && ($file = db_fetch_object(db_query('SELECT * FROM {files} f WHERE f.fid = %d', $image[$name])))) {
$form['designkit_image'][$name][$name] = array(
'#type' => 'value',
'#value' => $file,
'#element_validate' => array(
'designkit_upload_delete',
),
);
$form['designkit_image'][$name]['display'] = array(
'#title' => isset($image_info['title']) ? t($image_info['title']) : check_plain($name),
'#description' => isset($image_info['description']) ? t($image_info['description']) : '',
'#type' => 'item',
'#value' => theme('imagecache', "designkit-image-{$name}", $file->filepath),
);
$form['designkit_image'][$name]['delete'] = array(
'#type' => 'checkbox',
'#title' => t('Delete current image'),
);
}
else {
$form['designkit_image'][$name][$name] = array(
'#title' => isset($image_info['title']) ? t($image_info['title']) : check_plain($name),
'#description' => isset($image_info['description']) ? t($image_info['description']) : t('Upload a new image.'),
'#type' => 'file',
'#tree' => FALSE,
// Uploads may not be nested.
'#size' => 30,
'#element_validate' => array(
'designkit_upload_validate',
),
);
$form['designkit_image'][$name]['fid'] = array(
'#type' => 'value',
'#value' => !empty($image[$name]) ? $image[$name] : 0,
);
}
}
}
// Color
if (!empty($info['designkit']['color'])) {
$color = variable_get('designkit_color', array());
$form['designkit_color'] = array(
'#title' => t('Colors'),
'#description' => t('Enter an RGB hexidecimal value like <strong>#ffffff</strong>. Leave blank to use default colors.'),
'#collapsible' => TRUE,
'#collapsed' => empty($color) || $color == $info['designkit']['color'],
'#type' => 'fieldset',
'#tree' => TRUE,
);
foreach ($info['designkit']['color'] as $name => $color_info) {
if (isset($color[$name]) && designkit_valid_color($color[$name])) {
$default = $color[$name];
}
else {
$default = isset($color_info['default']) ? $color_info['default'] : '#888888';
}
$form['designkit_color'][$name] = array(
'#title' => isset($color_info['title']) ? t($color_info['title']) : check_plain($name),
'#description' => isset($color_info['description']) ? t($color_info['description']) : '',
'#attributes' => array(
'class' => 'designkit-colorpicker',
),
'#element_validate' => array(
'designkit_validate_color',
),
'#theme' => 'designkit_colorpicker',
'#type' => 'textfield',
'#size' => '7',
'#maxlength' => '7',
'#default_value' => $default,
);
}
}
}