function node_gallery_form_alter in Node Gallery 6.3
Same name and namespace in other branches
- 6.2 node_gallery.module \node_gallery_form_alter()
Implements hook_form_alter().
File
- ./
node_gallery.module, line 397 - Node gallery module file.
Code
function node_gallery_form_alter(&$form, $form_state, $form_id) {
// If displaying our VBO image weight form, theme it
if (strpos($form_id, 'views_bulk_operations_form') !== FALSE && isset($form['node_gallery_change_image_weight_action']) && isset($form['#ngtheme'])) {
$form['#theme'] = $form['#ngtheme'];
unset($form['#ngtheme']);
}
elseif (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
if (in_array($form['type']['#value'], (array) node_gallery_get_types('gallery'))) {
// gallery node form
$form['buttons']['submit']['#submit'][] = 'node_gallery_create_gallery_redirect_submit';
}
elseif (in_array($form['type']['#value'], (array) node_gallery_get_types('image'))) {
// image node form
// remove group settings from image if OG is enabled
if (module_exists('og')) {
$form['og_nodeapi']['#access'] = FALSE;
}
$image = $form['#node'];
$context = array();
if (!empty($image->gid)) {
$context['gallerynid'] = $image->gid;
}
else {
$context['image_type'] = $form['type']['#value'];
}
global $user;
$uid = isset($image->uid) ? $image->uid : $user->uid;
if (!empty($image->gid)) {
node_gallery_set_breadcrumb(array(
'galleries',
'galleries/' . $uid,
'node/' . $image->gid,
), $image);
}
$menu_item = menu_get_item();
if ($menu_item['path'] == 'node/%/upload') {
// Pull the gallery object, and pre-fill in the gallery info
$form['gid'] = array(
'#type' => 'value',
'#value' => $menu_item['map'][1]->nid,
);
}
else {
// We reuse the code from our action to display the gallery choice form
$context['allow_new_gallery'] = TRUE;
$gallery_form = node_gallery_change_gallery_action_form($context);
$form = array_merge($form, $gallery_form);
$form['#submit'][] = 'node_gallery_create_new_gallery_submit';
$form['buttons']['submit']['#submit'][] = 'node_gallery_create_image_redirect_submit';
}
$form['#validate'][] = 'node_gallery_change_gallery_action_validate';
// Allow change of cover image here too
$form['is_cover'] = array(
'#title' => t('Set as Cover Image'),
'#type' => 'checkbox',
'#weight' => -3,
'#default_value' => !empty($image->is_cover) ? $image->is_cover : 0,
);
}
}
}