? 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.977
diff -u -p -r1.977 common.inc
--- includes/common.inc	26 Aug 2009 15:00:17 -0000	1.977
+++ includes/common.inc	28 Aug 2009 20:42:46 -0000
@@ -4425,6 +4425,9 @@ function drupal_common_theme() {
     'vertical_tabs' => array(
       'arguments' => array('element' => NULL),
     ),
+    'tableform' => array(
+      'arguments' => array('element' => NULL),
+    ),
   );
 }
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.367
diff -u -p -r1.367 form.inc
--- includes/form.inc	27 Aug 2009 04:40:12 -0000	1.367
+++ includes/form.inc	28 Aug 2009 20:42:46 -0000
@@ -2197,6 +2197,224 @@ function form_process_tableselect($eleme
 }
 
 /**
+ * Format 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.
+ * @return
+ *   A themed HTML string representing the table.
+ *
+ * Example:
+ *
+ * @code
+ * $form = array(
+ *   'table' => array(
+ *     '#type' => 'tableform',
+ *     '#header' => array('col1', 'col2', 'col3'),
+ *     '#caption' => 'Hello',
+ *     '#tabledrag' => array(
+ *       'action' => 'order',
+ *       'relationship' => 'sibling',
+ *       'group' => 2,
+ *       'hidden' => FALSE,
+ *     ),
+ *     'row1' => array(
+ *       'col1' => array(
+ *         '#type' => 'checkbox',
+ *         '#default_value' => rand(0,1),
+ *       ),
+ *       'col2' => array(
+ *         '#type' => 'checkbox',
+ *         '#default_value' => rand(0,1),
+ *       ),
+ *       'col3' => array(
+ *         '#type' => 'select',
+ *         '#default_value' => 0,
+ *         '#options' => array_combine(range(0,10),range(0,10)),
+ *       ),
+ *     ),
+ *   ),
+ * );
+ * @ingroup themeable
+ */
+
+function theme_tableform($element) {
+  $rows = array();
+  $header = array();
+  $attributes = is_array($element['#attributes']) ? $element['#attributes'] : array();
+  $caption = !is_array($element['#caption']) ? $element['#caption'] : NULL;
+  $tabledrag = is_array($element['#tabledrag']) ? $element['#tabledrag'] : array();
+  $tabledrag_enabled = FALSE;
+
+  // For tabledrag, if a column index was provided, generate the necessary class.
+  if (is_int($tabledrag['group'])) {
+    $tabledrag['group-cellnum'] = $tabledrag['group'];
+    $tabledrag['group'] = 'tabledrag_weight_field_'. rand(100, 999);
+    $tabledrag['auto_config_group'] = TRUE;
+  }
+
+  // Set the id of the table.
+  if (!isset($attributes['id'])) {
+    $attributes['id'] = $element['#id'];
+  }
+
+  // Determine if tabledrag should be set.
+  if ($tabledrag && $attributes['id'] && $tabledrag['action'] && $tabledrag['relationship'] && $tabledrag['group']) {
+    $tabledrag_enabled = TRUE;
+  }
+
+  // If the header was provided, process it.
+  if (is_array($element['#header'])) {
+    $header = _theme_tableform_row($element['#header']);
+    $header = $header['data'];
+  }
+  $headercount = count($header);
+
+  // Process the rows.
+  $row_names = element_children($element);
+  if (count($row_names)) {
+    foreach (element_children($element) as $rowname) {
+      $rows[$rowname] = _theme_tableform_row($element[$rowname], $tabledrag);
+      if (!isset($rows[$rowname]['class'])) {
+        $rows[$rowname]['class'] = array();
+      }
+
+      // Make this row draggable.
+      if ($tabledrag_enabled && $element[$rowname]['#draggable'] !== FALSE) {
+        $rows[$rowname]['class'][] = ' draggable';
+      }
+
+      // Fill in the rest of the cells to match the table
+      for ($i = count($rows[$rowname]['data']); $i < $headercount; $i++) {
+        $rows[$rowname][] = array(
+          'data' => ' ',
+        );
+      }
+    }
+  }
+  // There are not any rows provided, add one row with a full colspan.
+  else {
+    $rows[] = array(
+      'data' => array(
+        array(
+          'data' => ' ',
+          'colspan' => $headercount,
+        ),
+    ));
+  }
+
+  // Configure the tabledrag.
+  if ($tabledrag_enabled) {
+    drupal_add_tabledrag(
+      $attributes['id'],
+      $tabledrag['action'],
+      $tabledrag['relationship'],
+      $tabledrag['group'],
+      isset($tabledrag['subgroup']) ? $tabledrag['subgroup']:NULL,
+      isset($tabledrag['source']) ? $tabledrag['source']:NULL,
+      isset($tabledrag['hidden']) ? $tabledrag['hidden']:TRUE,
+      isset($tabledrag['limit']) ? $tabledrag['limit']:0
+    );
+  }
+
+  return theme('table', $header, $rows, $attributes, $caption);
+}
+
+/**
+ * Set the "tree" option on all the rows.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   tableform element.
+ * @param $tabledrag
+ *   An associative array with the tabledrag configuration
+ * @see drupal_add_tabledrag()
+ * @return
+ *   A theme_table style associative array.
+ */
+function _theme_tableform_row($row, $tabledrag=array()) {
+  $newrow = array(
+    'data' => array(),
+  );
+  if (isset($row['#attributes']) && is_array($row['#attributes'])) {
+    foreach ($row['#attributes'] as $key => $value) {
+      if (!is_array($value)) {
+        $newrow[$key] = $value;
+      }
+    }
+  }
+
+  $loopcount = 0;
+  foreach (element_children($row) as $colname) {
+    $cell = $row[$colname];
+    if (!is_array($cell)) {
+      $cell = array(
+        'data' => $cell,
+      );
+    }
+
+    // If this is a form element.
+    if (element_properties($cell)) {
+      if (!isset($cell['#attributes']) || !is_array($cell['#attributes'])) {
+        $cell['#attributes'] = array();
+      }
+
+      if (!isset($cell['#attributes']['class'])) {
+        $cell['#attributes']['class'] = array();
+      }
+
+      // If this is the autodraggable column, set it accordingly.
+      if ($tabledrag['auto_config_group'] && $loopcount == $tabledrag['group-cellnum']) {
+        $cell['#attributes']['class'][] = $tabledrag['group'];
+      }
+
+      unset($cell['#printed']);
+      $newrow['data'][$colname] = array(
+        'data' => drupal_render($cell),
+      );
+
+      // Apply the cell_attributes to the cell
+      if (array_key_exists('#cell_attributes', $cell) && is_array($cell['#cell_attributes'])) {
+        unset($cell['#cell_attributes']['data']);
+        foreach ($cell['#cell_attributes'] as $key => $val) {
+          $newrow['data'][$colname][$key] = $val;
+        }
+      }
+    }
+    //A form_table associataive array.
+    else {
+      $newrow['data'][$colname] = $cell;
+    }
+    $loopcount++;
+  }
+  return $newrow;
+}
+
+/**
+ * Set the "tree" option on all the rows.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   tableform element.
+ * @return
+ *   The processed element.
+ */
+function form_process_tableform($element) {
+  $element['#tree'] = TRUE;
+  foreach (element_children($element) as $rowname) {
+    $element[$rowname]['#tree'] = TRUE;
+    if (!isset($element[$rowname]['#draggable'])) {
+      $element[$rowname]['#draggable'] = NULL;
+    }
+  }
+  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.779
diff -u -p -r1.779 system.module
--- modules/system/system.module	28 Aug 2009 16:23:05 -0000	1.779
+++ modules/system/system.module	28 Aug 2009 20:42:47 -0000
@@ -486,6 +486,12 @@ function system_elements() {
     '#theme' => array('hidden'),
   );
 
+  $type['tableform'] = array(
+    '#input' => TRUE,
+    '#tree' => TRUE,
+    '#process' => array('form_process_tableform'),
+    '#theme' => array('tableform'),
+  );
   return $type;
 }
 
