You are here

function theme_imagecache_ui_preset_actions in ImageCache 6.2

Same name and namespace in other branches
  1. 5.2 imagecache_ui.module \theme_imagecache_ui_preset_actions()
1 theme call to theme_imagecache_ui_preset_actions()
imagecache_ui_preset_form in ./imagecache_ui.pages.inc

File

./imagecache_ui.pages.inc, line 305

Code

function theme_imagecache_ui_preset_actions($form) {
  $header = array(
    t('Action'),
    t('Settings'),
  );

  // $header = array(, t('Weight'), '','');
  $rows = array();
  foreach (element_children($form) as $key) {
    if (!is_numeric($key)) {
      continue;
    }
    $row = array();
    $row[] = drupal_render($form[$key]['name']);
    $row[] = drupal_render($form[$key]['settings']);

    // Check for form access before rendering these portions of the table / header
    if (!empty($form[$key]['weight']['#access'])) {
      if (empty($header['weight'])) {
        $header['weight'] = t('Weight');
      }
      $form[$key]['weight']['#attributes']['class'] = 'imagecache-action-order-weight';
      $row[] = drupal_render($form[$key]['weight']);
    }
    if (!empty($form[$key]['configure']['#access'])) {
      if (empty($header['configure'])) {
        $header['configure'] = '';
      }
      $row[] = drupal_render($form[$key]['configure']);
    }
    if (!empty($form[$key]['remove']['#access'])) {
      if (empty($header['remove'])) {
        $header['remove'] = '';
      }
      $row[] = drupal_render($form[$key]['remove']);
    }
    $rows[] = array(
      'data' => $row,
      'class' => 'draggable',
    );
  }
  $output = '';
  if ($rows) {
    drupal_add_tabledrag('imagecache-preset-actions', 'order', 'sibling', 'imagecache-action-order-weight');
    $output = theme('table', $header, $rows, array(
      'id' => 'imagecache-preset-actions',
    ));
  }
  $output .= drupal_render($form);
  return $output;
}