? sites/all/modules/coder
? sites/all/modules/testmod
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.981
diff -u -p -r1.981 common.inc
--- includes/common.inc	31 Aug 2009 18:43:12 -0000	1.981
+++ includes/common.inc	31 Aug 2009 22:50:33 -0000
@@ -4646,6 +4646,15 @@ function drupal_common_theme() {
     'vertical_tabs' => array(
       'arguments' => array('element' => NULL),
     ),
+    'tableform' => array(
+      'arguments' => array('element' => NULL),
+    ),
+    'tableform_row' => array(
+      'arguments' => array('element' => NULL, 'tabledrag' => NULL),
+    ),
+    'tableform_cell' => array(
+      'arguments' => array('element' => NULL, 'tabledrag' => NULL),
+    ),
   );
 }
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.368
diff -u -p -r1.368 form.inc
--- includes/form.inc	29 Aug 2009 16:30:14 -0000	1.368
+++ includes/form.inc	31 Aug 2009 22:50:33 -0000
@@ -2196,6 +2196,268 @@ function form_process_tableselect($eleme
 }
 
 /**
+ * Formats a table based on a form element
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   tableform element.
+ *   Each child is a row containing form elements to be displayed as row cells.
+ *   @see theme_table()
+ *   Properties used: header, tabledrag, caption, sticky.
+ * @return
+ *   A themed HTML string representing the table.
+ * @ingroup themeable
+ */
+function theme_tableform($element) {
+  $rows = array();
+  $header = array();
+  $attributes = $element['#attributes'];
+  $caption = isset($element['#caption']) ? $element['#caption'] : NULL;
+  $colgroups = array(); // Not supported yet.
+  $sticky = $element['#sticky'];
+
+  // If the header was provided as an array, use it.
+  if (is_array($element['#header'])) {
+    $header = $element['#header'];
+  }
+  // Use one of the rows as the header
+  elseif (isset($element[$element['#header']])) {
+    $header = theme_tableform_row($element[$element['#header']]);
+    #$header = theme('tableform_row', $element[$element['#header']]);
+    $header = $header['data'];
+
+    // Remove the header element from the rest of the children.
+    unset($element[$element['#header']]);
+  }
+
+  // Process the rows.
+  foreach (element_children($element) as $rowname) {
+    $rows[$rowname] = theme_tableform_row($element[$rowname], $element['#tabledrag']);
+    #$rows[$rowname] = theme('tableform_row', $element[$rowname], $element['#tabledrag']);
+  }
+
+  // Initialize the tabledrag.
+  if ($element['#tabledrag']['enabled']) {
+    drupal_add_tabledrag(
+      $element['#tabledrag']['id'],
+      $element['#tabledrag']['action'],
+      $element['#tabledrag']['relationship'],
+      $element['#tabledrag']['group'],
+      $element['#tabledrag']['subgroup'],
+      $element['#tabledrag']['source'],
+      $element['#tabledrag']['hidden'],
+      $element['#tabledrag']['limit']
+    );
+  }
+
+  return theme('table', $header, $rows, $attributes, $caption, $colgroups, $sticky);
+}
+
+/**
+ * Prepares a formtable and its rows to be themed.
+ *
+ * Sets up the tableform element for theming, configures tabledrag and
+ * setting tableform_row types as such.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   tableform element.
+ *   Each child is a row containing form elements to be displayed as row cells.
+ * @return
+ *   The processed element.
+ */
+function form_process_tableform($element) {
+  $element['#tree'] = TRUE;
+  $element['#caption'] = isset($element['#caption']) ? $element['#caption'] : NULL;
+
+  // Set the table's header stickiness.
+  if (!isset($element['#sticky'])) {
+    $element['#sticky'] = TRUE;
+  }
+  if ($element['#sticky'] !== FALSE) {
+    $element['#sticky'] = TRUE;
+  }
+
+  // Set the table's attributes.
+  if (!isset($element['#attributes']) || !is_array($element['#attributes'])) {
+    $element['#attributes'] = array();
+  }
+  if (!isset($element['#attributes']['id'])) {
+    $element['#attributes']['id'] = $element['#id'];
+  }
+
+  // Ensure that the children are tableform_row types.
+  foreach (element_children($element) as $rowname) {
+    if (!isset($element[$rowname]['#type'])) {
+      $element[$rowname]['#type'] = 'tableform_row';
+    }
+    if ($element[$rowname]['#type'] != 'tableform_row') {
+      unset($element[$rowname]);
+    }
+  }
+
+  // Set the tabledrag defaults.
+  if (!isset($element['#tabledrag']) || !is_array($element['#tabledrag'])) {
+    $element['#tabledrag'] = array();
+  }
+
+  // Configure the tabledrag.
+  $element['#tabledrag']['enabled'] = FALSE;
+  if (isset($element['#tabledrag']['action']) &&
+      isset($element['#tabledrag']['relationship']) &&
+      isset($element['#tabledrag']['group'])) {
+
+    $element['#tabledrag']['id'] = $element['#attributes']['id'];
+    $element['#tabledrag']['enabled'] = TRUE;
+
+    if (!is_array($element['#tabledrag']['group'])) {
+      $element['#tabledrag']['group'] = array($element['#tabledrag']['group']);
+    }
+
+    // Handle the other extra arguements.
+    $element['#tabledrag']['subgroup'] = isset($element['#tabledrag']['subgroup']) ? $element['#tabledrag']['subgroup']:NULL;
+    $element['#tabledrag']['source'] = isset($element['#tabledrag']['source']) ? $element['#tabledrag']['source']:NULL;
+    $element['#tabledrag']['hidden'] = isset($element['#tabledrag']['hidden']) ? $element['#tabledrag']['hidden']:TRUE;
+    $element['#tabledrag']['limit'] = isset($element['#tabledrag']['limit']) ? $element['#tabledrag']['limit']:0;
+
+    // If column indexes were provided, generate the necessary class.
+    if (is_int($element['#tabledrag']['group'][0])) {
+      $element['#tabledrag']['group-cellnum'] = $element['#tabledrag']['group'];
+      $element['#tabledrag']['group'] = 'tabledrag_weight_field_'. rand(100, 999);
+      $element['#tabledrag']['auto_config_group'] = TRUE;
+    }
+  }
+  return $element;
+}
+
+/**
+ * Converts the FAPI row into a form_table ready row array.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   row.
+ * @return
+ *   A theme_table array representing the rendered row.
+ *
+ * @ingroup themeable
+ */
+function theme_tableform_row($element, $tabledrag=NULL) {
+  $row = array();
+
+  // If tabledrag is enabled, make this row draggable.
+  if ($tabledrag && $tabledrag['enabled'] && $element['#draggable']) {
+    $element['#attributes']['class'][] = 'draggable';
+  }
+
+  // Apply the element attributes to the row.
+  $row = $row + $element['#attributes'];
+
+  // Get the column structure.
+  $loopcount = 0;
+  $row['data'] = array();
+  foreach (element_children($element) as $colname) {
+    // If this cell contains the weight element, then pass the tabledrag data.
+    $dragcol = FALSE;
+    if ($tabledrag && $tabledrag['auto_config_group'] && $loopcount == $tabledrag['group-cellnum'][0]) {
+      $dragcol = TRUE;
+    }
+    $row['data'][$colname] = theme_tableform_cell($element[$colname], ($dragcol) ? $tabledrag : NULL);
+    $loopcount++;
+  }
+
+  return $row;
+}
+
+/**
+ * Prepares a formtable_row and its cells to be themed.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   tableform_row element.
+ *   Each child is a cell consisting of a formtable_cell and children elements
+ *   or containing form elements to be displayed as row cells.
+ * @return
+ *  The processed element.
+ */
+function form_process_tableform_row($element) {
+  $element['#tree'] = TRUE;
+
+  // Set the attributes of the row.
+  if (!isset($element['#attributes']) || !is_array($element['#attributes'])) {
+    $element['#attributes'] = array();
+  }
+
+  // Set the draggable flag for this row.
+  if (!isset($element['#draggable'])) {
+    $element['#draggable'] = TRUE;
+  }
+  if ($element['#draggable'] != FALSE) {
+    $element['#draggable'] = TRUE;
+  }
+
+  // Set the #type for cell if it was not provided.
+  foreach (element_children($element) as $colname) {
+    if (!isset($element[$colname]['#type']) && !isset($element[$colname]['#value'])) {
+      $element[$colname]['#type'] = 'tableform_cell';
+    }
+  }
+  return $element;
+}
+
+/**
+ * Converts the FAPI row into a form_table ready cell array.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   cell or an FAPI element.
+ * @return
+ *   A theme_table array representing the rendered cell.
+ *
+ * @ingroup themeable
+ */
+function theme_tableform_cell($element, $tabledrag=NULL) {
+  $cell = array();
+  $element_children = element_children($element);
+
+  // A child element is targeted to have tabledrag class set.
+  if ($tabledrag['auto_config_group'] && count($tabledrag['group-cellnum']) > 1) {
+      // Apply the class to the appropriate child element.
+      if ($elname = $element_children[$tabledrag['group-cellnum'][1]]) {
+        $element[$elname]['#attributes']['class'][] = $tabledrag['group'];
+      }
+  }
+  // The tabledrag class is intented to be set on the cell element.
+  elseif ($tabledrag['auto_config_group']) {
+    $element['#attributes']['class'][] = $tabledrag['group'];
+  }
+
+  // This is a tableform_cell, apply its attributes and render the children.
+  if (isset($element['#type']) && $element['#type'] == 'tableform_cell') {
+    $cell = $cell + $element['#attributes'];
+    $cell['data'] = drupal_render_children($element, $element_children);
+  }
+  // This cell is just a FAPI element, render it.
+  else {
+    $cell['data'] = drupal_render($element);
+  }
+
+  return $cell;
+}
+
+/**
+ * Processes a formtable_cell.
+ *
+ * @param $element
+ * @return
+ *  The processed element.
+ */
+function form_process_tableform_cell($element) {
+  $element['#tree'] = TRUE;
+  return $element;
+}
+
+
+/**
  * Adds fieldsets to the specified group or adds group members to this
  * fieldset.
  *
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.783
diff -u -p -r1.783 system.module
--- modules/system/system.module	31 Aug 2009 17:06:10 -0000	1.783
+++ modules/system/system.module	31 Aug 2009 22:50:33 -0000
@@ -486,6 +486,27 @@ function system_elements() {
     '#theme' => array('hidden'),
   );
 
+  $type['tableform'] = array(
+    '#input' => TRUE,
+    '#tree' => TRUE,
+    '#process' => array('form_process_tableform'),
+    '#theme' => array('tableform'),
+  );
+
+  $type['tableform_row'] = array(
+    '#input' => TRUE,
+    '#tree' => TRUE,
+    '#process' => array('form_process_tableform_row'),
+    '#theme' => array('tableform_row'),
+  );
+
+  $type['tableform_cell'] = array(
+    '#input' => TRUE,
+    '#tree' => TRUE,
+    '#process' => array('form_process_tableform_cell'),
+    '#theme' => array('tableform_cell'),
+  );
+
   return $type;
 }
 
