You are here

imagecrop.install in Image javascript crop 5

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

Install file.

File

imagecrop.install
View source
<?php

/**
 * @file
 * Install file.
 */

/**
 * Implementation of hook_enable().
 */
function imagecrop_enable() {
  cache_clear_all('imagecache_actions', 'cache');
}

/**
 * Implementation of hook_disable().
 */
function imagecrop_disable() {
  cache_clear_all('imagecache_actions', 'cache');
}

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

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

  // Check for jquery interface or jquery ui.
  if (!module_exists('jquery_interface') && !module_exists('jquery_ui')) {
    $requirements['imagecrop_jquery_library'] = array(
      'title' => $t('Imagecrop Jquery Interface'),
      'value' => $t('No Jquery Interface available'),
      'severity' => REQUIREMENT_ERROR,
      'description' => $t('Imagecache Javascript crop requires Jquery Interface or Jquery UI to be installed.'),
    );
  }
  return $requirements;
}

/**
 * Implementation of hook_install().
 * @todo postgresql support
 * @todo add unique key on fid & presetid?
 */
function imagecrop_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = db_query("CREATE TABLE {imagecrop} (\n          fid INT UNSIGNED NOT NULL DEFAULT 0,\n          presetid INT UNSIGNED NOT NULL DEFAULT 0,\n          reference VARCHAR (40) NOT NULL DEFAULT '',\n          xoffset INT UNSIGNED NOT NULL DEFAULT 0,\n          yoffset INT UNSIGNED NOT NULL DEFAULT 0,\n          width INT UNSIGNED NOT NULL DEFAULT 0,\n          height INT UNSIGNED NOT NULL DEFAULT 0)\n          /*!40100 DEFAULT CHARACTER SET utf8 */\n    ");
      $ret[] = db_query("UPDATE {system} SET weight = 1 WHERE name = 'imagecrop'");
      $ret[] = db_query("ALTER TABLE {imagecrop} ADD scale VARCHAR( 10 ) NOT NULL DEFAULT 'original'");
      break;
    case 'pgsql':
      break;
  }
  if ($ret) {
    drupal_set_message(t('Imagecrop module installed succesfully.'));
  }
  else {
    drupal_set_message(t('Imagecrop module installation was unsuccessfull. Necessary database tables should be created by hand.', 'error'));
  }
  return $ret;
}

/**
 * Update 1 : set weight to 1
 */
function imagecrop_update_2() {
  $ret[] = db_query("UPDATE {system} SET weight = 1 WHERE name = 'imagecrop'");
  return array();
}

/**
 * Update 2 : Add extra field to imagecrop table
 */
function imagecrop_update_3() {
  $ret[] = db_query("ALTER TABLE {imagecrop} ADD scale VARCHAR( 10 ) NOT NULL DEFAULT 'original'");
  return array();
}

/**
 * Implementation of hook_uninstall().
 */
function imagecrop_uninstall() {
  db_query("DROP TABLE {imagecrop}");
  db_query("DELETE FROM {system} where name = 'imagecrop'");
  variable_del('imagecrop_modules');
  variable_del('imagecrop_fields');
}

Functions

Namesort descending Description
imagecrop_disable Implementation of hook_disable().
imagecrop_enable Implementation of hook_enable().
imagecrop_install Implementation of hook_install(). @todo postgresql support @todo add unique key on fid & presetid?
imagecrop_requirements Implementation of hook_requirements().
imagecrop_uninstall Implementation of hook_uninstall().
imagecrop_update_2 Update 1 : set weight to 1
imagecrop_update_3 Update 2 : Add extra field to imagecrop table