--- ./sidecontent.info.orig	2007-07-04 04:50:13.000000000 -0700
+++ ./sidecontent.info	2008-07-22 16:34:35.000000000 -0700
@@ -1,9 +1,10 @@
-; $Id: sidecontent.info,v 1.1.2.1 2007/07/03 22:55:25 MegaGrunt Exp $
-name = "Side Content"
-description = "Displays page (node) content in a block."
-version = "5.x-1.x-dev"
-; Information added by drupal.org packaging script on 2007-07-04
-version = "5.x-1.0"
+; $Id: $
+name = "Side Content"
+description = "Displays page (node) content in a block."
+package = Other
+core = 6.x
+
+version = "6.x-0.x-dev"
 project = "sidecontent"
 datestamp = "1183549813"
 
--- sidecontent.install.orig	2008-07-23 13:56:51.000000000 -0700
+++ sidecontent.install	2008-07-23 16:51:49.000000000 -0700
@@ -12,41 +12,64 @@
   
   drupal_set_message('Installing sidecontent');
   
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $success = db_query("CREATE TABLE IF NOT EXISTS {sidecontent} (
-                        `nid` int(10) NOT NULL default '0',
-                        `format` int(4) NOT NULL default '0',
-                        `sidetitle` varchar(128) NOT NULL default '',
-                        `sidecontent` longtext NOT NULL,
-                        PRIMARY KEY  (nid) 
-                         ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-
-    case 'pgsql':
-      
-       $success = db_query("CREATE TABLE {sidecontent} (
-                            nid int4 NOT NULL default '0',
-                            format int4 NOT NULL default '0',
-                            sidetitle varchar(128) NOT NULL default '',
-                            sidecontent text NOT NULL,
-                            PRIMARY KEY  (nid) 
-                            );");
-      break;
+  $ret = drupal_install_schema('sidecontent');
+
+  $failed = array();
+  foreach ($ret as $query) {
+    if (!$query['success']) {
+      $failed[] = $query['query'];
+    }
   }
-  
-  if ($success) {
+  if (empty($failed)) {
     drupal_set_message(t('Sidecontent module installed tables successfully.'));
   }
   else {
-    drupal_set_message(t('The installation of the sidecontent module database tables failed.'), 'error');
+    drupal_set_message(t('The installation of the sidecontent module database tables failed. The following queries failed: !queries', array('!queries' => theme('item_list', $failed))), 'error');
   }
   
   return;
 }
 
 /*
+ * New for Drupal 6: database schema
+ */
+
+function sidecontent_schema() {
+  $schema['sidecontent'] = array(
+    'description' => t('The base table for sidecontent module.'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('The primary identifier for sidecontent.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'size' => 'normal',
+        'not null' => TRUE,
+        'default' => 0),
+      'format' => array(
+        'description' => t('The format specification.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'size' => 'normal',
+        'not null' => TRUE,
+        'default' => 0),
+      'sidetitle' => array(
+        'description' => t('Title of sidecontent.'),
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => ''),
+      'sidecontent' => array(
+        'description' => t('The content of side content.'),
+        'type' => 'text',
+        'size' => 'medium',
+        'not null' => TRUE),
+      ),
+      'primary key' => array('nid'),
+    );
+  return $schema;
+}
+
+/*
  * update module for UTF.
  */
 function sidecontent_update_1() {
@@ -59,18 +82,9 @@
  */
 function sidecontent_update_2() {
   $ret = array();
-  
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default '' AFTER format");
-      $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (  `nid`  )");      
-      break;
-    case 'pgsql':
-      $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default ''");
-      $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (  nid  )"); 
-      break;
-  }
+
+  db_add_field($ret, 'sidecontent', 'sidetitle', array('description' => t('Title of sidecontent.'), 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), array('primary key' => array('nid')));
+  //db_add_primary_key($ret, 'sidecontent', array('nid'));
   return $ret;
 }
 
@@ -102,10 +116,10 @@
 * Implementation of hook_uninstall().
 */
 function sidecontent_uninstall() {
-  db_query('DROP TABLE {sidecontent}');
+  drupal_uninstall_schema('sidecontent');
   variable_del('sidecontent_title');
   variable_del('sidecontent_print');
   variable_del('sidecontent_show_input_format');
   variable_del('sidecontent_show_in_group');
   variable_del('sidecontent_group_description');
-}
\ No newline at end of file
+}
--- sidecontent.module.orig	2008-07-23 13:44:30.000000000 -0700
+++ sidecontent.module	2008-07-23 14:32:18.000000000 -0700
@@ -1,5 +1,9 @@
 <?php
 // $Id: sidecontent.module,v 1.13.2.2 2007/07/03 22:55:25 MegaGrunt Exp $
+/**
+ * @file
+ * Implementation file for the sidecontent module.
+ */
 
 /**
  * Implementation of hook_perm().
@@ -29,7 +33,7 @@
       $form['sidecontent_print'] = array(
         '#type' => 'checkbox',
         '#title' => t('Print view include'),
-        '#default_value' => variable_get('sidecontent_print', false),
+        '#default_value' => variable_get('sidecontent_print', FALSE),
         '#description' => t('Show content in print view (requires Print Friendly Pages module).'),
       );
       
@@ -42,14 +46,14 @@
       $form['sidecontent_show_input_format'] = array(
         '#type' => 'checkbox',
         '#title' => t('Show input format'),
-        '#default_value' => variable_get('sidecontent_show_input_format', true),
+        '#default_value' => variable_get('sidecontent_show_input_format', TRUE),
         '#description' => t('If this box is not checked, the default input format will be used when formatting the block content.'),
       );
       
       $form['sidecontent_show_in_group'] = array(
         '#type' => 'checkbox',
         '#title' => t('Show in form group'),
-        '#default_value' => variable_get('sidecontent_show_in_group', true),
+        '#default_value' => variable_get('sidecontent_show_in_group', TRUE),
         '#description' => t('Show textarea and form filters formatted as a form group.'),
       );
 
@@ -68,8 +72,8 @@
         
         if (!user_access('create side content')) break;
         variable_set('sidecontent_print', !empty($edit['sidecontent_print']));
-		    variable_set('sidecontent_show_input_format', !empty($edit['sidecontent_show_input_format']));
-		    variable_set('sidecontent_show_in_group', !empty($edit['sidecontent_show_in_group']));
+        variable_set('sidecontent_show_input_format', !empty($edit['sidecontent_show_input_format']));
+        variable_set('sidecontent_show_in_group', !empty($edit['sidecontent_show_in_group']));
         variable_set('sidecontent_group_description', trim($edit['sidecontent_group_description']));
         return;
 
@@ -87,14 +91,15 @@
         
         if (is_numeric(arg(1))) {
         
-            $node = node_load(arg(1));
+            $node = menu_get_object();
             $type = $node->type;
-        } else {
+        }
+        else {
             $type = arg(2);
         }
         
         // is sidecontent enabled for this node type?
-        if (!variable_get('sidecontent_' . $type, 1)) break;
+        if (!variable_get('sidecontent_'. $type, 1)) break;
         
         // Preview
         $node_form = $_POST['edit'];
@@ -106,7 +111,8 @@
             $sidecontent->sidecontent = $node_form['sidecontent'];
             $sidecontent->format = $node_form['sidecontent_format'];       
 
-        } else {
+        }
+        else {
         
             $sidecontent = db_fetch_object(db_query("SELECT s.format, s.sidetitle, s.sidecontent FROM {sidecontent} s WHERE nid = %d", $node->nid));
         }
@@ -127,32 +133,32 @@
 /**
 * Implementation of hook_form_alter.
 */
-function sidecontent_form_alter($form_id, &$form) {
+function sidecontent_form_alter(&$form, &$form_state, $form_id) {
   
   // Alter the settings form.
   if ($form_id == 'node_type_form') {
-  	$node_type = $form['old_type']['#value'];
-  	
+    $node_type = $form['old_type']['#value'];
+ 
     $form['submission']['sidecontent'] = array(
       '#type' => 'radios',
       '#title' => t('Enable side content'),
-      '#default_value' => variable_get('sidecontent_' . $node_type, 0),
+      '#default_value' => variable_get('sidecontent_'. $node_type, 0),
       '#options' => array(t('Disabled'), t('Enabled')),
     );
   }
   
   // Add stuff to the node submit form.
-  if (isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id) {
+  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
   
     if (!user_access('create side content' )) return;
 
     $node = $form['#node'];
 
-    $type = variable_get('sidecontent_' . $node->type, 1);
+    $type = variable_get('sidecontent_'. $node->type, 1);
     
     if (!empty($type)) {
             
-      if (variable_get('sidecontent_show_in_group', true)) {
+      if (variable_get('sidecontent_show_in_group', TRUE)) {
 
           $form['sidecontent'] = array(
             '#type' => 'fieldset',
@@ -186,7 +192,7 @@
         '#rows' => 20,
       );
       
-      if (variable_get('sidecontent_show_input_format', true)) {
+      if (variable_get('sidecontent_show_input_format', TRUE)) {
         $form['sidecontent']['sidecontent_format'] = filter_form($node->sidecontent_format, NULL, array('sidecontent_format'));
       }
       
@@ -228,7 +234,7 @@
             if (empty($node->sidecontent)) return;
             if (!user_access('create side content' )) break;
             
-            if (!variable_get('sidecontent_show_input_format', true)) $node->sidecontent_format = FILTER_FORMAT_DEFAULT;
+            if (!variable_get('sidecontent_show_input_format', TRUE)) $node->sidecontent_format = FILTER_FORMAT_DEFAULT;
             
             db_query("DELETE FROM {sidecontent} WHERE nid = %d", $node->nid);
             db_query("INSERT INTO {sidecontent} (nid, format, sidetitle, sidecontent) VALUES (%d, %d, '%s', '%s')", $node->nid, $node->sidecontent_format, $node->sidecontent_title, $node->sidecontent);
@@ -242,7 +248,7 @@
             
             if (empty($node->sidecontent)) return;
             
-            if (!variable_get('sidecontent_show_input_format', true)) $node->sidecontent_format = FILTER_FORMAT_DEFAULT;
+            if (!variable_get('sidecontent_show_input_format', TRUE)) $node->sidecontent_format = FILTER_FORMAT_DEFAULT;
             db_query("INSERT INTO {sidecontent} (nid, format, sidetitle, sidecontent) VALUES (%d, %d, '%s', '%s')", $node->nid, $node->sidecontent_format, $node->sidecontent_title, $node->sidecontent);
             break;
            
@@ -251,7 +257,7 @@
             // add sidecontent into print view pages
             if (arg(2) == 'print' && !empty($node->sidecontent)) {
 
-                $print = variable_get('sidecontent_print', false);
+                $print = variable_get('sidecontent_print', FALSE);
                 if (empty($print)) break;
                 
                 // does user have access to view sidecontent?
@@ -261,8 +267,8 @@
                 
                 // note: print module disregards theme, so we have to include our markup here - yuuk!
                 $node->content['sidecontent'] = array(
-                                                      '#value' => '<div class="sidecontent-print">' . $sidecontent . '</div>',
-			                                                '#weight' => -10,
+                                                      '#value' => '<div class="sidecontent-print">'. $sidecontent .'</div>',
+                                                      '#weight' => -10,
                 );
             }
              
@@ -279,7 +285,7 @@
         
             if (!variable_get('sidecontent_'. $node->type, 1)) break;
             if (!user_access('create side content' )) break;
-            if (!variable_get('sidecontent_show_input_format', true)) $node->sidecontent_format = FILTER_FORMAT_DEFAULT;
+            if (!variable_get('sidecontent_show_input_format', TRUE)) $node->sidecontent_format = FILTER_FORMAT_DEFAULT;
             $text = check_markup($node->sidecontent, $node->sidecontent_format);
             return $text;
     }
