You are here

taxonomy_image.install in Taxonomy Image 5

Same filename and directory in other branches
  1. 6 taxonomy_image.install
  2. 7 taxonomy_image.install

taxonomy_image.install Simple module for providing an association between taxonomy terms and images. Written by Jeremy Andrews <jeremy@kerneltrap.org>, May 2004.

File

taxonomy_image.install
View source
<?php

/**
 * @file
 *  taxonomy_image.install
 *  Simple module for providing an association between taxonomy terms and images.
 *  Written by Jeremy Andrews <jeremy@kerneltrap.org>, May 2004.
 */

/**
 * Implementation of hook_requirements().
 */
function taxonomy_image_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();

  // Check for GD support.
  $requirements['gd'] = array(
    'title' => $t('GD Library'),
  );
  if (extension_loaded('gd')) {
    $gd = gd_info();
    $requirements['gd']['value'] = $gd['GD Version'];
    unset($gd['GD Version']);
    if ($gd['FreeType Support']) {
      $gd['FreeType Support' . ' ' . $gd['FreeType Linkage']] = 1;
      unset($gd['FreeType Support'], $gd['FreeType Linkage']);
    }
    $requirements['gd']['description'] = '<small>' . implode(', ', array_keys(array_filter($gd))) . '</small>';
    $requirements['gd']['severity'] = REQUIREMENT_OK;
  }
  else {
    $requirements['gd']['value'] = $t('Disabled');
    $requirements['gd']['description'] = $t('The Taxonomy Image module requires that you configure PHP with GD support.');
    $requirements['gd']['severity'] = REQUIREMENT_ERROR;
  }
  return $requirements;
}

/**
 * Implementation of hook_schema().
 */
function taxonomy_image_schema() {
  $schema['term_image'] = array(
    'module' => 'Taxonomy Image',
    'description' => t('Mapping of term to image.'),
    'fields' => array(
      'tid' => array(
        'description' => t('Term identifier.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'disp-width' => '10',
      ),
      'path' => array(
        'description' => t('File system path to the image.'),
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
    ),
    '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;
}

/**
 * Implementation of hook_install().
 */
function taxonomy_image_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {term_image} (\n        tid int(10) unsigned NOT NULL,\n        path varchar(255) NOT NULL,\n        PRIMARY KEY (tid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {cache_tax_image} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {term_image} (\n        tid integer NOT NULL default '0',\n        path varchar(255) NOT NULL,\n        PRIMARY KEY (tid)\n        )");
      db_query("CREATE TABLE {cache_tax_image} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      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} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {cache_tax_image} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        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}');
  db_query("DELETE FROM {blocks} WHERE module='taxonomy_image'");
  variable_del('taxonomy_image_height');
  variable_del('taxonomy_image_path');
  variable_del('taxonomy_image_recursive');
  variable_del('taxonomy_image_resize');
  variable_del('taxonomy_image_width');
  variable_del('taxonomy_image_imagecache_preset');
  variable_del('taxonomy_image_link_types');
  variable_del('taxonomy_image_link_title');
  variable_del('taxonomy_image_wrapper');
  variable_del('taxonomy_image_disable');
  variable_del('taxonomy_image_admin_preset');
  variable_del('taxonomy_image_block_imagecache_preset');
  variable_del('taxonomy_image_block_max_images');
  variable_del('taxonomy_image_block_max_size');
  variable_del('taxonomy_image_block_suppress');
  variable_del('taxonomy_image_block_title');
  variable_del('taxonomy_image_default');
  variable_del('taxonomy_image_node_preset');
  variable_del('taxonomy_image_node_show_name');
  variable_del('taxonomy_image_node_view');
  variable_del('taxonomy_image_node_view_link');
  variable_del('taxonomy_image_node_view_page');
  variable_del('taxonomy_image_node_view_teaser');
  variable_del('taxonomy_image_node_view_weight');
}

Functions

Namesort descending Description
taxonomy_image_install Implementation of hook_install().
taxonomy_image_requirements Implementation of hook_requirements().
taxonomy_image_schema Implementation of hook_schema().
taxonomy_image_uninstall Implementation of hook_uninstall().
taxonomy_image_update_5100 Implementation of hook_update_N().