You are here

function theme_gallery_assist_form_current in Gallery Assist 6

Theme the item list from the "Add and edit items" form

File

./gallery_assist.module, line 1318
Drupal content type with gallery functionality.

Code

function theme_gallery_assist_form_current($form) {
  $header = array();

  //
  if (!is_numeric(variable_get('gallery_assist_editform_pager_limit', 'none'))) {
    $header[] = '';
  }
  $header[] = array(
    'data' => t('Remove'),
    'class' => 'ga-form-delete',
  );
  $header[] = array(
    'data' => t('Image'),
    'class' => 'ga-form-item',
  );
  $header[] = array(
    'data' => t('Image info'),
    'class' => 'ga-form-caption',
  );
  if (!is_numeric(variable_get('gallery_assist_editform_pager_limit', 'none'))) {
    $header[] = array(
      'data' => t('Weight'),
      'field' => 'weight',
    );
  }
  else {
    $header[] = array(
      'data' => t('Weight'),
    );
  }

  // Define the output as draggable table
  foreach (element_children($form) as $key) {
    if (!is_numeric(variable_get('gallery_assist_editform_pager_limit', 'none'))) {
      $row = array(
        '',
      );

      // Add class to group weight fields for drag and drop.
      $form[$key]['weight']['#attributes']['class'] = 'gallery-assist-weight';
    }
    else {
      $row = array();
      $form[$key]['weight']['#size'] = 5;
    }

    // Fill the table cells
    $row[] = drupal_render($form[$key]['remove']);
    $ga_cover = $form[$key]['cover']['#value'] == 1 ? 'ga-cover-bg' : '';
    $row[] = array(
      'data' => drupal_render($form[$key]['item']),
      'class' => $ga_cover,
    );
    $row[] = drupal_render($form[$key]['ptitle']) . drupal_render($form[$key]['copyright']) . drupal_render($form[$key]['pdescription']);
    $row[] = drupal_render($form[$key]['weight']);
    if (!is_numeric(variable_get('gallery_assist_editform_pager_limit', 'none'))) {
      $row[] = drupal_render($form[$key]['size']);

      // Build the row with dragable class
      $rows[] = array(
        'data' => $row,
        'class' => 'draggable',
      );
    }
    else {

      // Build the row without dragable class
      $rows[] = array(
        'data' => $row,
      );
    }
  }
  $check_all_links = count($rows) > 1 ? t('<span class="ga-check-all description">@check_all</span> | <span class="ga-uncheck-all description">@uncheck_all</span>', array(
    '@check_all' => t('check all'),
    '@uncheck_all' => t('uncheck all'),
  )) : '';
  $output = theme('table', $header, $rows, array(
    'id' => 'gallery-assist-list',
  )) . $check_all_links;
  $output .= drupal_render($form);
  return $output;
}