You are here

function set_image_form_default_values in Node Gallery 6.2

Same name and namespace in other branches
  1. 6 node_gallery.pages.inc \set_image_form_default_values()
1 call to set_image_form_default_values()
node_gallery_image_item_edit_form in ./node_gallery.pages.inc

File

./node_gallery.pages.inc, line 486
Node gallery pages.

Code

function set_image_form_default_values(&$form, $image, $config) {
  global $user;
  if (empty($form['title'])) {
    $form['title'] = array(
      '#type' => 'hidden',
      '#value' => $image->filename,
    );
  }
  else {
    $form['title']['#default_value'] = empty($form['title']['#default_value']) ? $image->filename : $form['title']['#default_value'];
  }
  if (!empty($form['body_field'])) {

    /*$tmp_item = $form['body_field']['body'];
      unset($form['body_field']);
      $form['body_field'] = $tmp_item;
      $form['body_field']['#rows'] = 3;
      $form['body_field']['#default_value'] = empty($form['body']['#default_value']) ? $image->filename : $form['body']['#default_value'];*/
    $form['body'] = $form['body_field']['body'];
    $form['body']['#rows'] = 3;
    unset($form['body_field']);
  }
  if (!empty($form['changed']) && empty($form['changed']['#value'])) {
    $form['changed']['#value'] = time();
  }

  /* This allowed admins to overwrite the username when editing an image.
   * this feature was disabled as it was unexpected behaviour #550994 */
  if (user_access('administer nodes')) {
    $form['name'] = array(
      '#type' => 'value',
      '#value' => $image->name ? $image->name : $user->name,
    );
  }

  /* if (empty($form['name']) || empty($form['name']['#value'])) {
      $form['name'] = array(
        '#type' => 'value',
        '#value' => $user->name,
      );
    } */
  if (!empty($form['uid']) && empty($form['uid']['#value'])) {
    $form['uid']['#value'] = $user->uid;
  }
  $image_comment = variable_get('comment_' . $config['image_type'], COMMENT_NODE_READ_WRITE);
  $gallery_comment = variable_get('comment_' . $config['gallery_type'], COMMENT_NODE_READ_WRITE);
  $form['comment'] = array(
    '#type' => 'value',
    '#value' => $config['image_comment'] == 'image' ? $image_comment : $gallery_comment,
  );
}