You are here

function photos_upload_form in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.edit.inc \photos_upload_form()
3 string references to 'photos_upload_form'
photos_edit_page in inc/photos.edit.inc
photos_edit_upload in inc/photos.edit.inc
photos_swfu_form_alter in photos_swfu/photos_swfu.module

File

inc/photos.edit.inc, line 33

Code

function photos_upload_form(&$form_state, $node = false, $edit = array()) {
  global $user;
  $form['new'] = array(
    '#title' => t('Image upload'),
    '#weight' => -4,
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#description' => t('Allow the type:') . ' jpg gif png jpeg ' . (variable_get('photos_upzip', 0) && $_SESSION['photos_swfu_switch'] ? ' zip' : NULL),
  );
  if ($node->type == 'photos' || photos_get_count('user_album', $user->uid)) {
    for ($i = 0; $i < variable_get('photos_num', 5); ++$i) {
      $form['new']['images_' . $i] = array(
        '#type' => 'file',
      );
      $form['new']['title_' . $i] = array(
        '#type' => 'textfield',
        '#title' => t('Image title'),
      );
      $form['new']['des_' . $i] = array(
        '#type' => 'textarea',
        '#title' => t('Image description'),
        '#cols' => 40,
        '#rows' => 3,
      );
    }
  }
  else {
    drupal_set_message(t('You must first !create an album to upload images.', array(
      '!create' => l(t('create'), 'node/add/photos', array(
        'query' => drupal_get_destination(),
      )),
    )));
    return $form;
  }
  if ($node->type == 'photos') {
    $form['new']['pid'] = array(
      '#type' => 'value',
      '#value' => $node->nid,
    );
  }
  else {
    $form['new']['pid'] = array(
      '#title' => t('Upload to album'),
      '#type' => 'select',
      '#options' => _photos_useralbum_option($user->uid),
      '#default_value' => $_GET['pid'],
      '#required' => TRUE,
      '#prefix' => '<div id="photos-pid">',
      '#suffix' => '</div>',
      '#weight' => -5,
    );
    $form['new']['nid'] = array(
      '#type' => 'value',
      '#value' => $node->nid,
    );
  }
  if ($edit['submit']) {
    $form['new']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Confirm upload'),
      '#weight' => 10,
      '#submit' => array(
        'photos_upload_form_submit',
      ),
    );
    $form['#action'] = url($_GET['q'], array(
      'query' => drupal_get_destination(),
    ));
    $form['#attributes']['enctype'] = 'multipart/form-data';
  }
  return $form;
}