function _designkit_form_alter in DesignKit 7
Same name and namespace in other branches
- 6 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_select('file_managed', 'f')
->fields('f')
->condition('fid', $image[$name])
->execute()
->fetchObject();
if ($file) {
$form['designkit_image'][$name][$name] = array(
'#type' => 'value',
'#value' => $file,
'#element_validate' => array(
'designkit_upload_delete',
),
);
if (!empty($image_info['effect'])) {
$thumbnail = theme('image_style', array(
'style_name' => "designkit-image-{$name}",
'path' => $file->uri,
));
}
else {
$thumbnail = theme('image', array(
'path' => $file->uri,
));
}
$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',
'#markup' => $thumbnail,
);
$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' => array(
'designkit-colorpicker',
),
),
'#element_validate' => array(
'designkit_validate_color',
),
'#theme' => 'designkit_colorpicker',
'#type' => 'textfield',
'#size' => '7',
'#maxlength' => '7',
'#default_value' => $default,
);
}
}
}