You are here

function theme_node_gallery_sort_images_form in Node Gallery 6.3

File

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

Code

function theme_node_gallery_sort_images_form($form) {
  $output = '';
  if ($form['jquery_ui_integration']['#value']) {
    jquery_ui_add(array(
      'ui.draggable',
      'ui.droppable',
      'ui.sortable',
    ));
    drupal_add_js(drupal_get_path('module', 'node_gallery') . '/js/ng_sort_jqueryui.js');
    $settings = array(
      'node_gallery' => array(
        'gid' => $form['gid']['#value'],
        'url_prefix' => variable_get('clean_url', 0) > 0 ? '' : '?q=',
      ),
    );
    drupal_add_js($settings, 'setting');
    $output .= theme('node_gallery_sort_images_grid', $form['#images']);
  }
  else {
    $rows = array();
    $header = array(
      '↑↓',
      t('Preview'),
      t('Title'),
      t('Post date'),
      t('Updated date'),
      t('Published'),
      t('Weight'),
    );
    $i = 0;
    foreach ($form['#images'] as $image) {
      $published = $image['status'] ? t('Yes') : t('No');
      $row = array(
        // The placeholder for the tabledrag icon
        '',
        $image['admin_thumb'],
        $image['title'],
        format_date($image['created'], 'small'),
        format_date($image['changed'], 'small'),
        $published,
        // the weight drop down
        drupal_render($form['images-sort-' . $i]),
      );
      $rows[] = array(
        'data' => $row,
        'class' => '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', $header, $rows, array(
      'id' => 'sort-images-table',
    ));
  }

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