You are here

function theme_draggableviews_ui_style_plugin_draggabletable in DraggableViews 6

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

Theme the form for the table style plugin

File

./draggableviews_plugin_style_draggabletable.inc, line 404

Code

function theme_draggableviews_ui_style_plugin_draggabletable($form) {
  $output = drupal_render($form['description_markup']);
  $header = array(
    t('Field'),
    t('Column'),
    t('Separator'),
    array(
      'data' => t('Sortable'),
      'align' => 'center',
    ),
    array(
      'data' => t('Default sort'),
      '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']);
    if (!empty($form['info'][$id]['sortable'])) {
      $row[] = array(
        'data' => drupal_render($form['info'][$id]['sortable']),
        'align' => 'center',
      );
      $row[] = array(
        'data' => drupal_render($form['default'][$id]),
        'align' => 'center',
      );
    }
    else {
      $row[] = '';
      $row[] = '';
    }
    $rows[] = $row;
  }

  // Add the special 'None' row.
  $rows[] = array(
    t('None'),
    '',
    '',
    '',
    array(
      'align' => 'center',
      'data' => drupal_render($form['default'][-1]),
    ),
  );
  $output .= theme('table', $header, $rows);

  /* Render Draggable view settings
   ********************************
   */

  // set labels
  $labels = array(
    t('Action'),
    t('Relationship'),
    /*t('Group'), t('Subgroup'),*/
    t('Source'),
    ' ',
  );
  $labels_types = array(
    t('Content type'),
    t('Tabledrag type'),
    ' ',
  );
  $labels_orderfields = array(
    t('Save order in..'),
  );

  // initialize table rows
  $rows = array();
  $rows_types = array();
  $rows_orderfields = array();
  $submit_button = drupal_render($form['tabledrag_action_add_button']);

  // render submit button
  $add_type_button = drupal_render($form['tabledrag_type_add_button']);

  // render add type button
  $set_depth_button = drupal_render($form['tabledrag_set_depth_button']);

  // render set depth button
  $set_depth_select = drupal_render($form['tabledrag_depth']);

  // render depth select element
  $tabledrag_expand = drupal_render($form['tabledrag_expand']);

  // render expand link checkbox
  $tabledrag_visible = drupal_render($form['tabledrag_visible']);
  $description_content_type = drupal_render($form['description_draggabletable_content_type']);

  // prepare table data:
  // assign tabledrag options to an array
  foreach (element_children($form['tabledrag_options']) as $id) {
    $columns =& $form['tabledrag_options'][$id];

    // get columns
    $tmpRow = array();
    foreach (element_children($columns) as $el_id) {

      // build row
      $tmpRow[] = drupal_render($columns[$el_id]);
    }
    $rows[] = $tmpRow;

    // append row to array
  }

  // assing tabledrag types to an array
  foreach (element_children($form['tabledrag_types']) as $id) {
    $columns =& $form['tabledrag_types'][$id];

    // get columns
    $tmpRow = array();
    foreach (element_children($columns) as $el_id) {
      $tmpRow[] = drupal_render($columns[$el_id]);
    }
    $rows_types[] = $tmpRow;

    // append row to array
  }

  // assing tabledrag depth fields to an array
  foreach (element_children($form['tabledrag_depth_fields']) as $id) {
    $column =& $form['tabledrag_depth_fields'][$id];

    // get column
    $rows_orderfields[] = array(
      drupal_render($column),
    );

    // append row to array
  }

  /* IMPLEMENTATION OF REALTIMEEDIT MODULE */

  //check if realtimeedit module exists
  if (module_exists('realtimeedit')) {
    $add_realtimeedit_button = drupal_render($form['realtimeedit_add_button']);

    // render set depth button

    //set label
    $labels_realtimeeditfields = array(
      t('Enabled Fields'),
      ' ',
    );

    // assing tabledrag depth fields to an array
    foreach (element_children($form['realtimeedit_enabled_fields']) as $id) {
      $columns =& $form['realtimeedit_enabled_fields'][$id];

      // get columns
      $tmpRow = array();
      foreach (element_children($columns) as $el_id) {
        $tmpRow[] = drupal_render($columns[$el_id]);
      }
      $rows_realtimeedit_fields[] = $tmpRow;

      // append row to array
    }
  }

  // add form data left to output
  $output .= drupal_render($form);

  // add tabledrags to output
  $output .= theme('table', $labels, $rows);
  $output .= $submit_button;

  // add tabledrag types to output (choose if type = leaf|root)
  $output .= theme('table', $labels_types, $rows_types);
  $output .= $add_type_button;
  $output .= $description_content_type;

  // add tabledrag order depth table to output
  $output .= theme('table', $labels_orderfields, $rows_orderfields);
  $output .= theme('table', array(
    "",
    "",
  ), array(
    array(
      $set_depth_select,
      $set_depth_button,
    ),
  ));

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

  // add visible yes/no checkbox to output
  $output .= $tabledrag_visible;

  /* IMPLEMENTATION OF REALTIMEEDIT MODULE */

  //check if realtimeedit module exists
  if (module_exists('realtimeedit')) {

    // add editable fields table to output
    $output .= theme('table', $labels_realtimeeditfields, $rows_realtimeedit_fields);

    // add button
    $output .= $add_realtimeedit_button;
  }

  // return output
  return $output;
}