You are here

function theme_draggableviews_ui_style_plugin_draggabletable in DraggableViews 7

Same name and namespace in other branches
  1. 6.3 draggableviews_theme.inc \theme_draggableviews_ui_style_plugin_draggabletable()
  2. 6 draggableviews_plugin_style_draggabletable.inc \theme_draggableviews_ui_style_plugin_draggabletable()
  3. 6.2 draggableviews_plugin_style_draggabletable.inc \theme_draggableviews_ui_style_plugin_draggabletable()

Theme the form for the table style plugin

File

./draggableviews_theme.inc, line 335
Theme functions.

Code

function theme_draggableviews_ui_style_plugin_draggabletable($variables) {
  $form = $variables['form'];
  unset($form['order']);
  unset($form['default']);

  // The following lines are a modification of: views/includes/admin.inc,v 1.161.2.12 2010/06/17 02:45:36 merlinofchaos. Lines 3060 - 3101.
  $output = drupal_render($form['description_markup']);
  $header = array(
    t('Field'),
    t('Column'),
    t('Separator'),
    t('Align'),
    array(
      'data' => t('Sortable'),
      'align' => 'center',
    ),
  );
  $rows = array();
  foreach (element_children($form['columns']) as $id) {
    $row = array();
    $row[] = drupal_render($form['info'][$id]['name']);
    $row[] = drupal_render($form['columns'][$id]);
    $row[] = drupal_render($form['info'][$id]['separator']);
    $row[] = drupal_render($form['info'][$id]['align']);
    if (!empty($form['info'][$id]['sortable'])) {
      $row[] = array(
        'data' => drupal_render($form['info'][$id]['sortable']),
        'align' => 'center',
      );
    }
    else {
      $row[] = '';
    }
    $rows[] = $row;
  }
  drupal_render($form['default'][-1]);

  // Add the special 'None' row.
  $rows[] = array(
    t('None'),
    '',
    '',
    '',
    '',
  );
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));

  // Copy/Modification end
  // Render Draggable view settings
  // The following lines add the new output from draggableviews
  // Build header.
  $tabledrag_header = drupal_render($form['tabledrag_header']);
  $description_tabledrag = drupal_render($form['tabledrag_description']);

  // Build order table.
  $tabledrag_order_columns = array();
  $tabledrag_order_columns[] = 'Order Field:';
  foreach (element_children($form['tabledrag_order']) as $col) {
    $tabledrag_order_columns[] = drupal_render($form['tabledrag_order'][$col]);
  }
  $tabledrag_order_visible = drupal_render($form['tabledrag_order_visible']);
  $description_order = drupal_render($form['tabledrag_description_order']);

  // Build hierarchy table.
  $tabledrag_hierarchy_columns = array();
  $tabledrag_hierarchy_columns[] = 'Parent:';
  foreach (element_children($form['tabledrag_hierarchy']) as $col) {
    $tabledrag_hierarchy_columns[] = drupal_render($form['tabledrag_hierarchy'][$col]);
  }
  $tabledrag_hierarchy_visible = drupal_render($form['tabledrag_hierarchy_visible']);
  $description_hierarchy = drupal_render($form['tabledrag_description_hierarchy']);
  $draggableviews_depth_limit = drupal_render($form['draggableviews_depth_limit']);
  $draggableviews_repair = drupal_render($form['draggableviews_repair']);
  $draggableviews_ajax = drupal_render($form['draggableviews_ajax']);

  // build types table
  $tabledrag_types_rows = array();
  foreach (element_children($form['tabledrag_types']) as $id) {
    $columns = array();
    foreach (element_children($form['tabledrag_types'][$id]) as $col) {
      $columns[] = drupal_render($form['tabledrag_types'][$id][$col]);
    }
    $tabledrag_types_rows[] = $columns;
  }
  $tabledrag_types_add = drupal_render($form['tabledrag_types_add']);
  $description_types = drupal_render($form['tabledrag_description_types']);
  $tabledrag_expand = drupal_render($form['tabledrag_expand']);
  $draggableviews_extensions = drupal_render($form['draggableviews_extensions']);
  $description_extensions = drupal_render($form['draggableviews_description_extensions']);
  $tabledrag_lock = drupal_render($form['tabledrag_lock']);
  $description_tabledrag_lock = drupal_render($form['description_tabledrag_lock']);
  $draggableviews_default_on_top = drupal_render($form['draggableviews_default_on_top']);
  $draggableviews_button_text = drupal_render($form['draggableviews_button_text']);

  // Let extension modules append to the output
  $extensions = array();
  foreach (module_implements('draggableviews_style_plugin_render') as $module) {
    $function = $module . '_draggableviews_style_plugin_render';
    $extensions[] = $function($form);
  }

  // append form data left to output
  // all items that have not been rendered until this point
  // will be rendered now. So we can seperate the settings we
  // inherited from plugin_table from plugin_draggableviews settings.
  $output .= drupal_render_children($form);

  // Append ajax options
  $output .= $draggableviews_ajax;

  // Append order settings.
  $output .= $tabledrag_header;
  $output .= $description_tabledrag;
  $output .= theme('table', array(
    'header' => array(
      ' ',
      t('Field'),
      t('Handler'),
    ),
    'rows' => array(
      $tabledrag_order_columns,
    ),
  ));
  $output .= $description_order;
  $output .= $tabledrag_order_visible;

  // Append hierarchy settings.
  $output .= theme('table', array(
    'header' => array(
      ' ',
      t('Field'),
      t('Handler'),
    ),
    'rows' => array(
      $tabledrag_hierarchy_columns,
    ),
  ));
  $output .= $description_hierarchy;
  $output .= $tabledrag_hierarchy_visible;

  // Append depth limit textfield to output.
  $output .= $draggableviews_depth_limit;

  // Append structure options.
  $output .= $draggableviews_repair;
  if (strcmp($form['#base_table'], 'node') == 0) {

    // Append tabledrag types settings.
    $output .= theme('table', array(
      'header' => array(
        t('Node type'),
        t('Type'),
        ' ',
      ),
      'rows' => $tabledrag_types_rows,
    ));
    $output .= $tabledrag_types_add;
    $output .= $description_types;
  }

  // Append expand yes/no checkbox to output.
  $output .= $tabledrag_expand;

  // Append page extensions output.
  $output .= $draggableviews_extensions;
  $output .= $description_extensions;

  // Append lock output.
  $output .= $tabledrag_lock;
  $output .= $description_tabledrag_lock;

  // Append default behaviour radios.
  $output .= $draggableviews_default_on_top;

  // Append button text.
  $output .= $draggableviews_button_text;

  // append extension modules output
  $output .= implode('', $extensions);

  // return output
  return $output;
}