Index: CREDITS
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tables/CREDITS,v
retrieving revision 1.2
diff -u -p -r1.2 CREDITS
--- CREDITS	18 Jun 2009 11:13:57 -0000	1.2
+++ CREDITS	2 Jan 2011 09:45:17 -0000
@@ -1,4 +1,6 @@
 $Id: CREDITS,v 1.2 2009/06/18 11:13:57 realityloop Exp $
 
 Drupal 4.7 version by James Blake <james at webgeer.com>
+Drupal 5 upgrade by Brian Gilbert <brian at realityloop.com>
 Drupal 6 upgrade by Brian Gilbert <brian at realityloop.com>
+Drupal 7 release by Brian Gilbert <brian at realityloop.com>
\ No newline at end of file
Index: tables.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tables/tables.info,v
retrieving revision 1.3
diff -u -p -r1.3 tables.info
--- tables.info	10 Sep 2009 06:10:27 -0000	1.3
+++ tables.info	2 Jan 2011 09:45:17 -0000
@@ -3,4 +3,11 @@ name = Tables Filter
 description = Provides a filter that converts a [table  ] macro into HTML encoded table.
 dependencies[] = filter
 package = Input filters
-core = 6.x
+core = 7.x
+
+files[] = tables.install
+files[] = tables.module
+
+files[] = tables.css
+
+configure = admin/config/content/formats
\ No newline at end of file
Index: tables.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tables/tables.install,v
retrieving revision 1.1
diff -u -p -r1.1 tables.install
--- tables.install	1 Jan 2011 06:25:00 -0000	1.1
+++ tables.install	2 Jan 2011 09:45:17 -0000
@@ -1,17 +1,16 @@
 <?php
-// $Id: tables.install,v 1.1 2011/01/01 06:25:00 realityloop Exp $
+// $Id$
 
 /**
- * Implementation of hook_install().
+ * @file
+ *
+ * @author realityloop
  */
-function tables_install() {
-  drupal_set_message(t('The tables filter has been installed. Before this does anything, the tables filter needs to be added to one or more input formats. Visit the <a href="!url">input format administration</a> to set up this filter.', array('!url' => url('admin/settings/filters'))), 'warning');
-}
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function tables_uninstall() {
-  db_query("DELETE FROM {filters} WHERE module = 'tables'");
+  db_query("DELETE FROM {filter} WHERE module = 'tables'");
   cache_clear_all('*', 'cache_filter');
 }
Index: tables.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tables/tables.module,v
retrieving revision 1.16
diff -u -p -r1.16 tables.module
--- tables.module	1 Jan 2011 06:30:12 -0000	1.16
+++ tables.module	2 Jan 2011 09:45:18 -0000
@@ -15,14 +15,14 @@
 function tables_help($path, $arg) {
   switch ($path) {
     case 'admin/help#tables':
-      return t('<p>This filter module makes it easy and safe insert tables into the text of a node. '.
-               '<p>A table always starts with "[table".  To set a custom class for the table next put in "=class" '.
-               'there must not be any space between the "[table" and the "=".  You can set the class to be what '.
-               'ever you want.  A few useful classes are already included in the style sheet provided. '.
-               'Next you separate the cells by a "|" and separate the rows by a new line.  Cells can span multiple '.
-               'columns or rows simply by inserting a "{" to merge the cell with the cell to the left and a "^" to '.
-               'merge with the cell above. Currently, the only way to insert a literal "]" into the table is to use "'.
-               htmlentities('&#93;').'". If a "!" is the first charecter for a cell, the cell is set to be a header cell.');
+      return t('<p>This filter module makes it easy and safe insert tables into the text of a node. ' .
+               '<p>A table always starts with "[table".  To set a custom class for the table next put in "=class" ' .
+               'there must not be any space between the "[table" and the "=".  You can set the class to be what ' .
+               'ever you want.  A few useful classes are already included in the style sheet provided. ' .
+               'Next you separate the cells by a "|" and separate the rows by a new line.  Cells can span multiple ' .
+               'columns or rows simply by inserting a "{" to merge the cell with the cell to the left and a "^" to ' .
+               'merge with the cell above. Currently, the only way to insert a literal "]" into the table is to use "' .
+        htmlentities('&#93;') . '". If a "!" is the first charecter for a cell, the cell is set to be a header cell.');
       break;
   }
 }
@@ -41,179 +41,188 @@ function tables_help($path, $arg) {
  */
 
 function _tables_prepare($intext) {
-  $out=FALSE;
+  $out = FALSE;
   $tableexp = '/\[table([^\[\]]+ )* \] /x';
   preg_match_all($tableexp, $intext, $matches);
-  $i=0;
-
+  $i = 0;
   while (isset($matches[1][$i])) {
     $out[0][$i] = $matches[0][$i];
     $tablein = $matches[1][$i];
-    $rowspan=$colspan=array();    
-    if ($tablein[0] == '=') {  //class is set
-      preg_match('/^=([a-zA-Z0-9-]*)/',$tablein, $cmatches);
+    $rowspan = $colspan = array();
+    if ($tablein[0] == '=') { //class is set
+      preg_match('/^=([a-zA-Z0-9-]*)/', $tablein, $cmatches);
       $classlen = strlen($cmatches[0]);
-      $class=$cmatches[1];
-      $tablein=trim(substr($tablein,$classlen));
+      $class = $cmatches[1];
+      $tablein = trim(substr($tablein, $classlen));
     }
     else {
-      $class=variable_get('tables_default_style', 'tables-elegant');
+      $class = variable_get('tables_default_style', 'tables-elegant');
     }
     //check for summary
- 	$summaryexp = '/summary=".*"/';
- 	if (preg_match($summaryexp, $tablein, $cmatches)) {
- 	  //get summary content
- 	  $summary = $cmatches[0];
- 	  // cut summary out of definition
- 	  $summaryexp = '/".*"/';
- 	  preg_match($summaryexp, $summary, $cmatches);
- 	  $summary_text = str_replace('"', '', $cmatches[0]);
- 	  $attributes = array('summary' => $summary_text);
- 	  $tablein = str_replace($summary, '', $tablein);
- 	} else {
- 		$summary = 'summary=""';
- 		$attributes = array('summary' => '');
- 	}
+    $summaryexp = '/summary=".*"/';
+    if (preg_match($summaryexp, $tablein, $cmatches)) {
+      //get summary content
+      $summary = $cmatches[0];
+      // cut summary out of definition
+      $summaryexp = '/".*"/';
+      preg_match($summaryexp, $summary, $cmatches);
+      $summary_text = str_replace('"', '', $cmatches[0]);
+      $attributes = array('summary' => $summary_text);
+      $tablein = str_replace($summary, '', $tablein);
+    }
+    else {
+      $summary = 'summary=""';
+      $attributes = array('summary' => '');
+    }
     //end check for summary
-    $rows=explode("\n", $tablein);
-    $j=0;
-    $num_rows=count($rows);
-    $num_cols=0;
+    $rows = explode("\n", $tablein);
+    $j = 0;
+    $num_rows = count($rows);
+    $num_cols = 0;
     $cells = array();
 
     while (isset($rows[$j])) {
-      $cells[$j]=explode('|', $rows[$j]);
-      $cells[$j]=array_map('trim', $cells[$j]);
-      if (count($cells[$j])>$num_cols) {
-        $num_cols=count($cells[$j]);
+      $cells[$j] = explode('|', $rows[$j]);
+      $cells[$j] = array_map('trim', $cells[$j]);
+      if (count($cells[$j]) > $num_cols) {
+        $num_cols = count($cells[$j]);
       }
       $j++;
     }
-    for ($j=$num_rows-1; $j>=0; $j--) {   // find any cols rows that span  row=j, col=k
-      for ($k=$num_cols-1; $k>=0; $k--) {
-        if ($cells[$j][$k][0]=='{') {
-          if (isset($colspan[$j][$k]) && $k>0) {
-            $colspan[$j][$k-1] = $colspan[$j][$k]+1;
+    for ($j = $num_rows -1; $j >= 0; $j--) { // find any cols rows that span  row=j, col=k
+      for ($k = $num_cols -1; $k >= 0; $k--) {
+        if ($cells[$j][$k][0] == '{') {
+          if (isset($colspan[$j][$k]) && $k > 0) {
+            $colspan[$j][$k -1] = $colspan[$j][$k] + 1;
           }
-          elseif ($k>0) {
-            $colspan[$j][$k-1]=2;
+          elseif ($k > 0) {
+            $colspan[$j][$k -1] = 2;
           }
         }
         elseif ($cells[$j][$k][0] == '^') {
-          if (isset($rowspan[$j][$k]) && $j>0) {
-            $rowspan[$j-1][$k] = $rowspan[$j][$k]+1;
+          if (isset($rowspan[$j][$k]) && $j > 0) {
+            $rowspan[$j -1][$k] = $rowspan[$j][$k] + 1;
           }
-          elseif ($j>0) {
-            $rowspan[$j-1][$k]=2;
+          elseif ($j > 0) {
+            $rowspan[$j -1][$k] = 2;
           }
         }
       }
     }
-    if (isset($class) && strtolower($class)=='theme') {
+    if (isset($class) && strtolower($class) == 'theme') {
       //create a table themed using Drupal Themed table function
-       $outtext=theme_table(array_shift($cells), $cells, $attributes);
+      $outtext = theme_table(array_shift($cells), $cells, $attributes);
     }
     else {
-      if (isset($class) && strlen($class)>0) {
-        $outtext= '<table class="'.$class.'" '.$summary.'>'."\n";
+      if (isset($class) && strlen($class) > 0) {
+        $outtext = '<table class="' . $class . '" ' . $summary . '>' . "\n";
       }
       else {
-        $outtext= '<table>'."\n";
+        $outtext = '<table>' . "\n";
       }
-      for ($j=0; $j<$num_rows; $j++) {   // create the output
-        if ($j==0) $outtext .= '<tr class="firstrow">';
-        elseif ($j % 2 == 0) $outtext.= '<tr class="oddrow">';
-        else $outtext.= '<tr class="evenrow">';
-        for ($k=0; $k<$num_cols; $k++) {
-          if ($cells[$j][$k][0]=='!') {
-            $cell_type='th';
-            $cells[$j][$k]=substr($cells[$j][$k],1);
+      for ($j = 0; $j < $num_rows; $j++) { // create the output
+        if ($j == 0) {
+          $outtext .= '<tr class="firstrow">';
+        }
+        elseif ($j % 2 == 0) {
+          $outtext .= '<tr class="oddrow">';
+        }
+        else {
+          $outtext .= '<tr class="evenrow">';
+        }
+        for ($k = 0; $k < $num_cols; $k++) {
+          if ($cells[$j][$k][0] == '!') {
+            $cell_type = 'th';
+            $cells[$j][$k] = substr($cells[$j][$k], 1);
           }
           else {
-            $cell_type='td';
+            $cell_type = 'td';
           }
 
           if ($cells[$j][$k][0] != '^' && $cells[$j][$k][0] != '{') {
-            $outtext.="<$cell_type";
-            if (isset($rowspan[$j][$k])) $outtext .= ' ROWSPAN='.$rowspan[$j][$k];
-            if (isset($colspan[$j][$k])) $outtext .= ' COLSPAN='.$colspan[$j][$k];
-            if ($k==0) $outtext .= ' class="firstcol">';
-            elseif ($k % 2 == 0) $outtext.= ' class="oddcol">';
-            else $outtext.= ' class="evencol">';
-            if (strlen($cells[$j][$k])>0) $outtext .=$cells[$j][$k]."</$cell_type>";
-            else $outtext .= "&nbsp;</$cell_type>";
+            $outtext .= "<$cell_type";
+            if (isset($rowspan[$j][$k])) {
+              $outtext .= ' ROWSPAN=' . $rowspan[$j][$k];
+            }
+            if (isset($colspan[$j][$k])) {
+              $outtext .= ' COLSPAN=' . $colspan[$j][$k];
+            }
+            if ($k == 0) {
+              $outtext .= ' class="firstcol">';
+            }
+            elseif ($k % 2 == 0) {
+              $outtext .= ' class="oddcol">';
+            }
+            else {
+              $outtext .= ' class="evencol">';
+            }
+            if (strlen($cells[$j][$k]) > 0) {
+              $outtext .= $cells[$j][$k] . "</$cell_type>";
+            }
+            else {
+              $outtext .= "&nbsp;</$cell_type>";
+            }
           }
         }
         $outtext .= "</tr>\n";
       }
       $outtext .= "</table>\n ";
     }
-    $out[1][$i]=$outtext;
+    $out[1][$i] = $outtext;
     $i++;
   } // endwhile process macro
   return $out;
 }
 
 /**
- *  Implementation of hook_filter
+ * Implements hook_filter_info().
  */
 
-function tables_filter($op, $delta = 0, $format = -1, $text = '') {
-  switch ($op) {
-    case 'list':
-      return (array(0 => t('Tables filter')));
-
-    case 'name':
-      return t('tables filter');
-
-    case 'description':
-      return t('converts [table ...] macros into HTML tables.');
-      
-    case 'process':
-      $tables=_tables_prepare($text);   //returns an array of $tables[0] = table macro $table[1]= table html
-      if ($tables) {                    // there are table macros in this node
-        return str_replace($tables[0], $tables[1], $text);
-      }
-      else {
-        return $text;
-      }
-
-    case 'prepare':
-      return $text;
-    
-    case 'settings':
-      return tables_filter_settings_form();  
+function tables_filter_info() {
+  $filters['filter_markdown'] = array(
+  'title' => t('Tables filter'),
+  'description' => t('converts [table ...] macros into HTML tables.'),
+  'process callback' => '_filter_tables',
+  'settings callback' => '_filter_tables_settings',
+  'tips callback'  => '_filter_tables_tips'
+  );
 
-  }
+  return $filters;
 }
 
-function tables_filter_tips($delta, $format, $long = false) {
+function _filter_tables_tips($format, $long = FALSE) {
   return t('Insert an html table from [table | cell 2 ...]. Use "|" between cells and a new line between rows.');
 }
 
+/**
+	* Filter process callback.
+	*/
+function _filter_tables($text, $format) {
+  $tables=_tables_prepare($text); //returns an array of $tables[0] = table macro $table[1]= table html
+  $text =  str_replace($tables[0], $tables[1], $text);
+
+  return $text;
+}
 
 function tables_init() {
-  $css = variable_get('tables_css', drupal_get_path('module','tables').'/tables.css');
+  $css = variable_get('tables_css', drupal_get_path('module', 'tables') . '/tables.css');
   drupal_add_css($css);
 }
 
-
-
-
-function tables_filter_settings_form() {
-
-  $form['tables_filter'] = array(
+function _filter_tables_settings($form, &$form_state, $filter, $format, $defaults) {
+  $settings['tables_filter'] = array(
     '#type' => 'fieldset',
     '#title' => t('Tables filter'),
     '#collapsible' => TRUE,
   );
-  $form['tables_filter']['tables_default_style'] = array(
+  $settings['tables_filter']['tables_default_style'] = array(
     '#type' => 'textfield',
     '#title' => t('Default style'),
     '#default_value' => variable_get('tables_default_style', 'tables-elegant'),
     '#size' => 70,
     '#maxlength' => 255,
-    '#description' => t("Set the default style sheet to use if no style sheet is set in the specific table. "),
+    '#description' => t("Set the default style sheet to use if no style sheet is set in the specific table."),
   );
-  return $form;
+
+  return $settings;
 }
