You are here

function theme_scs_sort_nodes in Simplenews Content Selection 6.2

Theme the node sort form into a table

1 theme call to theme_scs_sort_nodes()
theme_scs_node_selection in ./scs.theme.inc
Theme the node selection form

File

./scs.theme.inc, line 81
Select Drupal content to create a newsletter

Code

function theme_scs_sort_nodes($form) {
  $headers = array(
    t('Node title'),
    t('Weight'),
  );
  $rows = array();
  foreach ($form as $name => $field) {
    if (ereg('weight_', $name)) {
      $nid = explode('_', $name);
      $nid = $nid[1];
      if (is_numeric($nid)) {
        $title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
        unset($form[$name]['#title']);
        $row = array();
        $row[] = $title;
        $row[] = drupal_render($form[$name]);
        $rows[] = array(
          'data' => $row,
          'class' => 'draggable tabledrag-leaf',
        );
      }
    }
  }

  //Starting output
  $output = '';
  $output .= drupal_render($form['newsletter_title']);
  $output .= drupal_render($form['newsletter_toc']);
  $output .= drupal_render($form['newsletter_content_type']);
  $output .= drupal_render($form['newsletter_type']);

  //Sections
  for ($i = 0; $i < 10; $i++) {
    $caption = t('Section') . ' ' . $i + 1;
    $output .= theme('table', $headers, $sectionrows, array(
      'id' => 'scs_node_sort_table_section_' . $i + 1,
    ), $caption);
    drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'scs_weight', 'scs_weight_' . $i + 1);
  }
  $output .= theme('table', $headers, $rows, array(
    'id' => 'scs_node_sort_table',
  ));
  $output .= drupal_render($form);
  drupal_add_tabledrag('scs_node_sort_table', 'order', 'sibling', 'scs_weight');
  return $output;
}