Index: teaser_block.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/teaser_block/teaser_block.info,v
retrieving revision 1.1
diff -u -p -r1.1 teaser_block.info
--- teaser_block.info	9 Apr 2008 19:34:18 -0000	1.1
+++ teaser_block.info	11 Sep 2008 11:45:27 -0000
@@ -1,3 +1,4 @@
 ; $Id: teaser_block.info,v 1.1 2008/04/09 19:34:18 sun Exp $
 name = Teaser block
 description = Allows to create teaser blocks for nodes.
+core = 6.x
Index: teaser_block.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/teaser_block/teaser_block.install,v
retrieving revision 1.2
diff -u -p -r1.2 teaser_block.install
--- teaser_block.install	10 Apr 2008 00:34:02 -0000	1.2
+++ teaser_block.install	11 Sep 2008 12:03:54 -0000
@@ -1,69 +1,52 @@
 <?php
 // $Id: teaser_block.install,v 1.2 2008/04/10 00:34:02 sun Exp $
 
-function teaser_block_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {teaser_block} (
-        bid int(10) unsigned NOT NULL default '0',
-        nid int(10) unsigned NOT NULL default '0',
-        title varchar(64) NOT NULL default '',
-        body longtext,
-        info varchar(128) NOT NULL default '',
-        format tinyint(3) unsigned NOT NULL default '0',
-        PRIMARY KEY (bid),
-        UNIQUE KEY info (info)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
-      break;
-
-    case 'pgsql':
-      db_query("CREATE TABLE {teaser_block} (
-        bid integer NOT NULL default '0',
-        nid integer NOT NULL default '0',
-        title varchar(64) NOT NULL default '',
-        body text,
-        info varchar(128) NOT NULL default '',
-        format smallint NOT NULL default '0',
-        PRIMARY KEY (bid),
-        UNIQUE (info)
-      )");
-      break;
-  }
+/**
+ * Implementation of hook_schema().
+ */
+function teaser_block_schema() {
+  $schema['teaser_block'] = array(
+    'description' => t('Stores user generated teaser blocks for nodes.'),
+    'fields' => array(
+      'bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,
+        'description' => t('The primary identifier for a teaser block.'),
+      ),
+      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,
+        'description' => t('The linked node id of a teaser block.'),
+      ),
+      'title' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '',
+        'description' => t('The title of a teaser block.'),
+      ),
+      'body' => array('type' => 'text', 'size' => 'big',
+        'description' => t('The content of a teaser block.'),
+      ),
+      'info' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '',
+        'description' => t('The administrative description of a teaser block.'),
+      ),
+      'format' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,
+        'description' => t('The input format of a teaser block.'),
+      ),
+    ),
+    'primary key' => array('bid'),
+    'unique keys' => array(
+      'info' => array('info'),
+    ),
+  );
+  return $schema;
 }
 
-function teaser_block_uninstall() {
-  db_query("DROP TABLE {teaser_block}");
-}
- 
 /**
- * Use Drupal sequence teaser_block_id.
+ * Implementation of hook_install().
  */
-function teaser_block_update_5001() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      $ret[] = update_sql("ALTER TABLE {teaser_block} CHANGE bid bid int(10) unsigned NOT NULL default '0'");
-      break;
-
-    case 'pgsql':
-      db_change_column($ret, 'teaser_block', 'bid', 'bid', 'integer', array('not null' => TRUE, 'default' => '0'));
-      break;
-  }
-  return $ret;
+function teaser_block_install() {
+  drupal_install_schema('teaser_block');
 }
 
 /**
- * Changed form properties to actual block properties.
+ * Implementation of hook_uninstall().
  */
-function teaser_block_update_5002() {
-  $ret = array();
-  if (module_exists('translatable')) {
-    $ret[] = update_sql("UPDATE {translatable_object} SET object_field = 'body' WHERE object_field = 'teaser_block_body'");
-    $ret[] = update_sql("UPDATE {translatable_object} SET object_field = 'format' WHERE object_field = 'teaser_block_format'");
-    $ret[] = update_sql("UPDATE {translatable_object} SET object_field = 'nid' WHERE object_field = 'teaser_block_node'");
-  }
-  return $ret;
+function teaser_block_uninstall() {
+  drupal_uninstall_schema('teaser_block');
+  db_query("DELETE FROM {variable} WHERE name LIKE 'teaser_block_%%'");
 }
-
+ 
Index: teaser_block.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/teaser_block/teaser_block.module,v
retrieving revision 1.4
diff -u -p -r1.4 teaser_block.module
--- teaser_block.module	8 Aug 2008 19:59:03 -0000	1.4
+++ teaser_block.module	11 Sep 2008 11:52:35 -0000
@@ -16,22 +16,30 @@ function teaser_block_perm() {
 /**
  * Implementation of hook_menu().
  */
-function teaser_block_menu($may_cache) {
+function teaser_block_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/build/block/add-teaser',
-      'title' => t('Add teaser block'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('teaser_block_form'),
-      'access' => user_access('create teaser blocks'),
-      'type' => MENU_LOCAL_TASK,
-    );
-  }
+  $items['admin/build/block/add-teaser'] = array(
+    'title' => 'Add teaser block',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('teaser_block_form'),
+    'access arguments' => array('create teaser blocks'),
+    'type' => MENU_LOCAL_TASK,
+  );
   return $items;
 }
 
 /**
+ * Implementation of hook_theme().
+ */
+function teaser_block_theme() {
+  return array(
+    'teaser_block_read_more_link' => array(
+      'arguments' => array('data' => NULL),
+    )
+  );
+}
+
+/**
  * Implementation of hook_block().
  */
 function teaser_block_block($op = 'list', $delta = 0, $edit = array()) {
@@ -87,7 +95,7 @@ function teaser_block_view($bid) {
 function theme_teaser_block_read_more_link($data) {
   $content = trim(check_markup($data->body, $data->format, FALSE));
   $link    = '<span class="teaser_block-more-link">';
-  $link   .= l(t('Read more'), 'node/'. $data->nid, array('title' => t('Read the rest of this posting.')), NULL, NULL, FALSE, TRUE);
+  $link   .= l(t('Read more'), 'node/'. $data->nid, array('attributes' => array('title' => t('Read the rest of this posting.'))), 'html' => TRUE);
   $link   .= '</span>';
   
   // Insert read more link before an image at the end of block content.
@@ -113,7 +121,7 @@ function theme_teaser_block_read_more_li
  *
  * Allows to enable/disable content-types for teaser blocks.
  */
-function teaser_block_form_alter($form_id, &$form) {
+function teaser_block_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
     $types = variable_get('teaser_block_types', array());
     $form['workflow']['teaser_block'] = array(
@@ -123,26 +131,26 @@ function teaser_block_form_alter($form_i
       '#options' => array(t('Disabled'), t('Enabled')),
       '#description' => t('Enables teaser blocks for this content-type.'),
     );
-    $form['#submit'] = array('teaser_block_node_type_submit' => array()) + (array)$form['#submit'];
+    $form['#submit'] = array('teaser_block_node_type_submit') + (array)$form['#submit'];
   }
 }
 
 /**
  * Submit handler for node type form.
  */
-function teaser_block_node_type_submit($form_id, &$form_values) {
+function teaser_block_node_type_submit($form, &$form_state) {
   $types = variable_get('teaser_block_types', array());
-  if ($form_values['teaser_block']) {
-    $types = array_merge($types, array($form_values['type'] => $form_values['teaser_block']));
+  if ($form_state['values']['teaser_block']) {
+    $types = array_merge($types, array($form_state['values']['type'] => $form_state['values']['teaser_block']));
   }
   else {
-    unset($types[$form_values['type']]);
+    unset($types[$form_state['values']['type']]);
   }
   variable_set('teaser_block_types', $types);
-  unset($form_values['teaser_block']);
+  unset($form_state['values']['teaser_block']);
 }
 
-function teaser_block_form($delta = 0) {
+function teaser_block_form(&$form_state, $delta = 0) {
   $teaser_block = db_fetch_array(db_query('SELECT bid, nid, title, body, format FROM {teaser_block} WHERE bid = %d', $delta));
 
   $form['delta'] = array(
@@ -196,35 +204,35 @@ function teaser_block_form($delta = 0) {
   return $form;
 }
 
-function teaser_block_form_submit($form_id, $form_values) {
-  if ($form_values['op'] == t('Save')) {
+function teaser_block_form_submit($form, &$form_state) {
+  if ($form_state['values']['op'] == t('Save')) {
     // Insert node title if teaser block title was left empty.
-    if (trim($form_values['title']) == '') {
-      $node = node_load($form_values['nid']);
-      $form_values['title'] = $node->title;
+    if (trim($form_state['values']['title']) == '') {
+      $node = node_load($form_state['values']['nid']);
+      $form_state['values']['title'] = $node->title;
     }
     // Insert node teaser if teaser block body was left empty.
-    if (trim($form_values['body']) == '') {
-      $node = node_load($form_values['nid']);
-      $form_values['body'] = node_teaser($node->body);
+    if (trim($form_state['values']['body']) == '') {
+      $node = node_load($form_state['values']['nid']);
+      $form_state['values']['body'] = node_teaser($node->body);
     }
   }
 
   // Update teaser block in the database.
   $block = new stdClass;
-  $block->delta = $form_values['delta'];
-  $block->title = $form_values['title'];
-  $block->nid = $form_values['nid'];
-  $block->body = $form_values['body'];
-  $block->format = $form_values['format'];
-  if ($form_values['op'] == t('Save')) {
+  $block->delta = $form_state['values']['delta'];
+  $block->title = $form_state['values']['title'];
+  $block->nid = $form_state['values']['nid'];
+  $block->body = $form_state['values']['body'];
+  $block->format = $form_state['values']['format'];
+  if ($form_state['values']['op'] == t('Save')) {
     teaser_block_update($block->delta ? 'update' : 'insert', $block);
   }
-  else if ($form_values['op'] == t('Delete')) {
+  else if ($form_state['values']['op'] == t('Delete')) {
     teaser_block_update('delete', $block);
   }
 
-  return 'admin/build/block';
+  $form_state['redirect'] = 'admin/build/block';
 }
 
 /**
@@ -272,9 +280,10 @@ function teaser_block_update($op, $block
     case 'insert':
       $block->delta = db_next_id('{teaser_block}_bid');
     
-      $sql = "INSERT INTO {teaser_block} (bid, nid, title, body, info, format) VALUES (%d, %d, '%s', '%s', '%s', %d)";
-      db_query($sql, $block->delta, $block->nid, $block->title, $block->body, _teaser_block_info($block->title, 0), $block->format);
+      $sql = "INSERT INTO {teaser_block} (nid, title, body, info, format) VALUES (%d, %d, '%s', '%s', '%s', %d)";
+      db_query($sql, $block->nid, $block->title, $block->body, _teaser_block_info($block->title, 0), $block->format);
     
+      $block->delta = db_last_insert_id('teaser_block', 'bid');
       $sql = "INSERT INTO {blocks} (module, delta, theme) VALUES ('%s', %d, '%s')";
       db_query($sql, 'teaser_block', $block->delta, $theme_key);
   
@@ -309,7 +318,7 @@ function _teaser_block_info($title, $bid
   $x = 0;
   $info = t('Teaser: @title', array('@title' => $title));
   // Append block counter.
-  while (db_num_rows(db_query("SELECT info FROM {boxes} WHERE bid != %d AND info = '%s'", $bid, $info))) {
+  while (db_result(db_query("SELECT info FROM {boxes} WHERE bid != %d AND info = '%s'", $bid, $info))) {
     $info = ($x == 0 ? $info : substr($info, 0, strrpos($info, '#') - 1)) .' #'. ++$x;
   }
   return $info;
