mysite_icon_form($type = NULL, $type_id = NULL, $icon = NULL, $name = 'mysite_icon')
mysite_icon/mysite_icon.module, line 491
Form builder function
An internal function to re-use common form elements
$type The MySite content type
$type_id The MySite content type id
$icon An object of data from {mysite_icon}
$name The name of the form this will be inserted into
function mysite_icon_form($type = NULL, $type_id = NULL, $icon = NULL, $name = 'mysite_icon') {
$form = array();
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['#redirect'] = referer_uri();
if ($type == 'blog' || $type == 'user') {
$form['blog'] = array('#value' => t('<p>Blog and user icons are set to be user pictures by default. If the user has no picture, or you wish to override the user picture, upload a new icon here. Changing the MySite icon will not change the user picture.</p>'));
}
$form['type'] =array('#type' => 'value', '#value' => $type);
$form['type_id'] =array('#type' => 'value', '#value' => $type_id);
list($maxwidth, $maxheight) = explode('x', variable_get('mysite_icon_dimensions', '120x60'));
if (empty($icon)) {
$default = 'icon.png';
if (!empty($type)) {
$default = 'icon-'. $type .'.png';
}
$path = drupal_get_path('module', 'mysite') .'/plugins/icons';
$image = $path .'/'. $default;
if (!file_exists(file_check_location($image, $path))) {
$image = $path .'/icon.png';
}
$image_div = theme_mysite_icon_default($image, $edit['title'], $maxwidth, $maxheight);
}
else {
$image = file_directory_path() .'/'. variable_get('mysite_icon_path', 'mysite') .'/'. $icon;
$image_div = theme_mysite_icon_custom($image, $edit['title'], $maxwidth, $maxheight);
}
$form[$name]['image'] = array(
'#value' => $image_div
);
$form[$name]['icon'] = array(
'#type' => 'file',
'#title' => t('Icon'),
'#size' => 40,
'#description' => t('Must be a .GIF, .JPG or .PNG and should be %width x %height pixels. Maximum size is %size kB.', array('%width' => $maxwidth, '%height' => $maxheight, '%size' => variable_get('mysite_icon_file_size', 32)))
);
$form[$name]['submit'] = array('#type' => 'submit', '#value' => t('Save Icon'));
return $form;
}