You are here

function photos_editlist in Album Photos 6.2

2 string references to 'photos_editlist'
_photos_edit_page_album in inc/photos.edit.inc
_photos_edit_page_node in inc/photos.edit.inc

File

inc/photos.edit.inc, line 201

Code

function photos_editlist(&$form_state, $images = array(), $type = 'album') {
  global $user;
  if ($type == 'album') {
    if ($user->uid != $images[0]['info']['uid']) {
      $albumUpdate = array(
        $images[0]['info']['pid'],
        $images[0]['info']['title'],
      );
    }
    $albumPid = _photos_useralbum_option($user->uid, $albumUpdate);
    $delLabel = _photos_del_checkbox(0, t('Delete'));
    $form['cover_fid'] = array(
      '#type' => 'hidden',
      '#default_value' => $images[0]['info']['cover']['fid'],
    );
    $form['oldpid'] = array(
      '#type' => 'hidden',
      '#default_value' => $images[0]['info']['pid'],
    );
    $submit = 'photos_editlist_submit';
  }
  else {
    $delLabel = _photos_del_checkbox(0, t('Move out'));
    $submit = 'photos_editlist_submit_node';
    $form['nid'] = array(
      '#type' => 'hidden',
      '#default_value' => $images[0]['info']['nid'],
    );
  }
  $form['photos']['#theme'] = 'photos_editlist_x';
  $form['photos']['#tree'] = true;
  $form['#action'] = url($_GET['q'], array(
    'query' => drupal_get_destination() . (isset($_GET['page']) ? '&page=' . intval($_GET['page']) : NULL),
  ));
  $thumb = variable_get('photos_title_0', false);
  foreach ($images as $image) {
    $form['photos'][$image['fid']]['del'] = $delLabel;
    $image['user']->uid = $image['uid'];
    $image['user']->name = $image['name'];
    $item = array();
    $item[] = theme('photos_imagehtml', $image['thumb'][$thumb], array(
      'href' => 'photos/image/' . $image['fid'],
    ));
    if ($type == 'album' && $images[0]['info']['cover']['fid'] != $image['fid']) {
      $item[] = l(t('Set to Cover'), "node/{$image['pid']}/photos/cover/{$image['fid']}");
    }
    $item[] = t('Filesize: !size KB', array(
      '!size' => round($image['filesize'] / 1024),
    ));
    if ($image['count']) {
      $item[] = t('Visits: !count', array(
        '!count' => $image['count'],
      ));
    }
    if ($image['comcount']) {
      $item[] = t('Comments: !count', array(
        '!count' => $image['comcount'],
      ));
    }
    $form['photos'][$image['fid']]['path']['#value'] = theme('item_list', $item);
    $form['photos'][$image['fid']]['des'] = array(
      '#title' => t('Image description'),
      '#type' => 'textarea',
      '#default_value' => preg_replace('/<.*?>/', '', $image['des']),
      '#cols' => 40,
      '#rows' => 4,
    );
    $form['photos'][$image['fid']]['filename'] = array(
      '#title' => t('Image title'),
      '#type' => 'textfield',
      '#default_value' => $image['filename'],
      '#required' => TRUE,
    );
    $form['photos'][$image['fid']]['wid'] = array(
      '#title' => t('Weight'),
      '#type' => 'weight',
      '#default_value' => $image['wid'],
      '#delta' => 100,
    );
    $form['photos'][$image['fid']]['filepath'] = array(
      '#type' => 'value',
      '#value' => $image['filepath'],
    );
    if ($type == 'album') {
      $uploadInfo = t('Uploaded on !time by !name', array(
        '!name' => theme('username', $image['user']),
        '!time' => format_date($image['timestamp'], 'small'),
      ));
      $form['photos'][$image['fid']]['pid'] = array(
        '#title' => t('Move to the album'),
        '#type' => 'select',
        '#options' => $albumPid,
        '#default_value' => $image['pid'],
        '#required' => TRUE,
      );
    }
    else {
      $uploadInfo = t('!name in !time upload to !title', array(
        '!name' => theme('username', $image['user']),
        '!time' => format_date($image['timestamp'], 'small'),
        '!title' => l($image['title'], 'node/' . $image['pid']),
      ));
    }
    $form['photos'][$image['fid']]['time']['#value'] = $uploadInfo;
    $form['photos'][$image['fid']]['uid'] = array(
      '#type' => 'hidden',
      '#default_value' => $image['uid'],
    );
    $form['photos'][$image['fid']]['oldfilename'] = array(
      '#type' => 'hidden',
      '#default_value' => $image['filename'],
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Confirm the change'),
    '#submit' => array(
      $submit,
    ),
  );
  return $form;
}