You are here

function theme_node_gallery_api_sort_items_form in Node Gallery 7

Theme function for item sort form.

File

theme/theme.inc, line 215
Node gallery theme functions

Code

function theme_node_gallery_api_sort_items_form($variables) {
  $form = $variables['form'];
  $output = '';
  $rows = array();
  $header = array(
    '↑↓',
    t('Preview'),
    t('Title'),
    t('Post date'),
    t('Updated date'),
    t('Published'),
    t('Weight'),
  );
  if (variable_get('node_gallery_api_display_exif_creation_date', FALSE)) {
    array_splice($header, 3, 0, t('Creation date'));
  }
  $i = 0;
  foreach ($form['#images'] as $image) {
    $published = $image['status'] ? t('Yes') : t('No');
    if (!empty($image['file_object'])) {
      $file_object = (object) $image['file_object'];
      $file_view = file_view($file_object, 'node_gallery_api_admin_thumbnail');
    }
    else {
      $file_view = '';
    }
    $row = array(
      // The placeholder for the tabledrag icon.
      '',
      drupal_render($file_view),
      $image['title'],
      format_date($image['created'], 'short'),
      format_date($image['changed'], 'short'),
      $published,
      // The weight drop down.
      drupal_render($form['images-sort-' . $i]),
    );
    if (variable_get('node_gallery_api_display_exif_creation_date', FALSE)) {
      $exif_created = isset($image['exif_created']) ? format_date($image['exif_created']
        ->getTimestamp(), 'short') : t('Unavailable');
      array_splice($row, 3, 0, $exif_created);
    }
    $rows[] = array(
      'data' => $row,
      'class' => array(
        'draggable',
      ),
    );
    $i++;
  }

  // This will replace the weight drop downs with drag&drop when javascript
  // is available.
  drupal_add_tabledrag('sort-images-table', 'order', 'sibling', 'sort');
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'sort-images-table',
    ),
  ));

  // Render the left over elements, if any.
  $output .= drupal_render_children($form);
  return $output;
}