? taxonomy_image_old.install
? taxonomy_image_old.module
Index: taxonomy_image.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_image/taxonomy_image.install,v
retrieving revision 1.1.4.8
diff -u -r1.1.4.8 taxonomy_image.install
--- taxonomy_image.install	8 Apr 2008 15:15:42 -0000	1.1.4.8
+++ taxonomy_image.install	8 Apr 2008 15:54:24 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: taxonomy_image.install,v 1.1.4.8 2008/04/08 15:15:42 nancyw Exp $
+// $Id: taxonomy_image.install,v 1.1.4.7 2008/03/23 15:24:02 nancyw Exp $
 
 /**
  * Implementation of hook_requirements().
@@ -55,6 +55,19 @@
     'primary key' => array('tid'),
     );
 
+  $schema['cache_tax_image'] = array(
+    'module' => 'Taxonomy Image',
+    'fields' => array(
+      'cid' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+      'data' => array('type' => 'blob', 'size' => 'big', 'not null' => FALSE),
+      'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'headers' => array('type' => 'text', 'not null' => FALSE)),
+    'primary key' => array('cid'),
+    'indexes' => array(
+      'expire' => array('expire')),
+    );
+  
   return $schema;
 }
 
@@ -70,6 +83,15 @@
         path varchar(255) NOT NULL,
         PRIMARY KEY (tid)
         ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
+      db_query("CREATE TABLE {cache_tax_image} (
+        cid varchar(255) NOT NULL default '',
+        data longblob,
+        expire int NOT NULL default '0',
+        created int NOT NULL default '0',
+        headers text,
+        PRIMARY KEY (cid),
+        INDEX expire (expire)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
       break;
     case 'pgsql':
       db_query("CREATE TABLE {term_image} (
@@ -77,15 +99,56 @@
         path varchar(255) NOT NULL,
 	      PRIMARY KEY (tid)
         )");
+
+      db_query("CREATE TABLE {cache_tax_image} (
+        cid varchar(255) NOT NULL default '',
+        data bytea,
+        expire int NOT NULL default '0',
+        created int NOT NULL default '0',
+        headers text,
+        PRIMARY KEY (cid)
+      )");
+      break;
   }
   drupal_set_message(t('The Taxonomy Image module was installed. You may want to go to the <a href="!settings">settings page now</a>.', array('!settings' => url('admin/settings/taxonomy_image'))));
 }
 
 /**
+ * Implementation of hook_update_N().
+ */
+function taxonomy_image_update_5100() {
+  switch($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+    $ret[] = update_sql("CREATE TABLE {cache_tax_image} (
+        cid varchar(255) NOT NULL default '',
+        data longblob,
+        expire int NOT NULL default '0',
+        created int NOT NULL default '0',
+        headers text,
+        PRIMARY KEY (cid),
+        INDEX expire (expire)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
+      break;
+    case 'pgsql':
+      $ret[] = update_sql("CREATE TABLE {cache_tax_image} (
+        cid varchar(255) NOT NULL default '',
+        data bytea,
+        expire int NOT NULL default '0',
+        created int NOT NULL default '0',
+        headers text,
+        PRIMARY KEY (cid))");
+      break;
+  }
+  return $ret;
+}
+
+/**
  * Implementation of hook_uninstall().
  */
 function taxonomy_image_uninstall() {
   db_query('DROP TABLE {term_image}');
+  db_query('DROP TABLE {cache_tax_image}');
   variable_del('taxonomy_image_height');
   variable_del('taxonomy_image_path');
   variable_del('taxonomy_image_recursive');
Index: taxonomy_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_image/taxonomy_image.module,v
retrieving revision 1.12.4.22
diff -u -r1.12.4.22 taxonomy_image.module
--- taxonomy_image.module	8 Apr 2008 15:15:42 -0000	1.12.4.22
+++ taxonomy_image.module	8 Apr 2008 15:59:10 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: taxonomy_image.module,v 1.12.4.22 2008/04/08 15:15:42 nancyw Exp $
+// $Id: taxonomy_image.module,v 1.12.4.21 2008/03/23 15:24:02 nancyw Exp $
 
 /**
  * taxonomy_image.module:
@@ -197,10 +197,16 @@
 
   if (user_access('access taxonomy images') && !$user->taxonomy_image_disable_images) {
     // Is the data statically cached?
+//    if (!$image[$tid]->url) {
     if (isset($image[$tid])) {
       return $image[$tid];
     }
     else {
+      $cache_obj = cache_get("taxonomy_image:$tid", 'cache_tax_image');
+      if ($cache_obj) {
+        $image[$tid] = unserialize($cache_obj->data);
+        return $image[$tid];
+      }
       if ($image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name, d.description FROM {term_image} i INNER JOIN {term_data} d USING(tid) WHERE i.tid=%d', $tid))) {
         $image[$tid]->url = file_create_url($image[$tid]->path);
       }
@@ -245,6 +251,7 @@
         .'title="'. check_plain(($image[$tid]->description ? $image[$tid]->description : $image[$tid]->name))  .'" '
         .'>';
     }
+    cache_set("taxonomy_image:$tid", 'cache_tax_image', serialize($image[$tid]));
     return $image[$tid];
   }
   return null;
@@ -813,6 +820,9 @@
 }
 
 function taxonomy_image_delete($tid) {
+  // Delete the cached version.
+  cache_clear_all("taxonomy_image:$tid", 'cache_tax_image');
+
   $old_path = db_result(db_query('SELECT path FROM {term_image} WHERE tid=%d', $tid));
   $how_many = db_result(db_query("SELECT COUNT(path) FROM {term_image} WHERE path='%s'", $old_path));
   if ($how_many == 1) {
