You are here

beautytips_manager.install in BeautyTips 7.2

Same filename and directory in other branches
  1. 6.2 beautytips_manager.install

Code related to the installation and uninstallation of custom beautytip and style administration.

File

beautytips_manager.install
View source
<?php

/**
 * @file
 * Code related to the installation and uninstallation of
 *   custom beautytip and style administration.
 */

/**
 * Implementation of hook_schema().
 */
function beautytips_manager_schema() {
  $schema = [];
  $schema['beautytips_custom_tips'] = [
    'description' => t('Store custom defined beautytips.'),
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('The unique id for the custom beautytip.'),
      ],
      'element' => [
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => t('The element to which this beautytips will be applied.'),
      ],
      'content_type' => [
        'type' => 'varchar',
        'length' => 64,
        'description' => t('What kind of content will be grabbed for the display.'),
      ],
      'content' => [
        'type' => 'text',
        'description' => t('The content that will be displayed. Depends on content type.'),
      ],
      'disable_link' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'unsigned' => TRUE,
        'decription' => t('Whether to disable link or not.'),
      ],
      'trigger_on' => [
        'type' => 'varchar',
        'length' => 32,
        'description' => t('The event that will turn the beautytips on.'),
      ],
      'trigger_off' => [
        'type' => 'varchar',
        'length' => 32,
        'description' => t('The event that will turn the beautytips off.'),
      ],
      'style' => [
        'type' => 'varchar',
        'length' => 64,
        'description' => t('The style of the beautytip.'),
      ],
      'shrink' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'decription' => t('Whether or to shrink to fit.'),
      ],
      'positions' => [
        'type' => 'varchar',
        'length' => 64,
        'default' => '',
        'description' => t('The position order in which this beautytip should display.'),
      ],
      'animation_on' => [
        'type' => 'varchar',
        'length' => 255,
        'description' => t('The animation that will occurs when the beautytips turns on.'),
      ],
      'animation_off' => [
        'type' => 'varchar',
        'length' => 255,
        'description' => t('The animation that will occurs when the beautytips turns off.'),
      ],
      'visibility' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('Flag to indicate how to show beautytips on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)'),
      ],
      'pages' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => t('Contains a list of paths on which to include/exclude the beautytip, depending on "visibility" setting.'),
      ],
      'enabled' => [
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'description' => t('Whether or not this tip is enabled'),
      ],
    ],
    'primary key' => [
      'id',
    ],
  ];
  $schema['beautytips_custom_styles'] = [
    'description' => t('Store custom defined beautytip styles.'),
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('The unique id for the custom beautytip style.'),
      ],
      'name' => [
        'type' => 'varchar',
        'length' => 255,
        'description' => t('The unique name for this style.'),
      ],
      'fill' => [
        'description' => t('background color (string - html color)'),
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'stroke_width' => [
        'type' => 'varchar',
        'description' => t('width of border (integer)'),
        'length' => 32,
        'not null' => FALSE,
      ],
      'stroke_style' => [
        'description' => t('color of border (string - html color)'),
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'width' => [
        'description' => t('width of popup (number in px)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'padding' => [
        'description' => t('space between content and border (number in px)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'corner_radius' => [
        'description' => t('Controls roundness of corners (integer)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'spike_girth' => [
        'description' => t('thickness of spike (integer)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'spike_length' => [
        'description' => t('length of spike (integer)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'shadow' => [
        'description' => t('Whether the shadow should be on, off, or default.'),
        'type' => 'varchar',
        'length' => 16,
        'default' => 'default',
      ],
      'shadow_blur' => [
        'description' => t('Size of popup shadow (integer)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'shadow_color' => [
        'description' => t('Color of popup shadow (string - html color)'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'css_class' => [
        'description' => t('css class of beautytip popup.'),
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'css_color' => [
        'description' => t('The color of the text.'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'css_font_family' => [
        'description' => t('The font family of the text.'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'css_font_weight' => [
        'description' => t('The font weight of the text.'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'css_font_size' => [
        'description' => t('The font size of the text.'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
    ],
    'primary key' => [
      'id',
    ],
  ];
  return $schema;
}

/**
 * Update to add enabled field.
 */
function beautytips_manager_update_7000() {
  $ret = [];

  // Make sure this field doesn't already exist.
  if (db_field_exists('beautytips_custom_tips', 'enabled')) {
    return $ret;
  }
  $spec = [
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'description' => t('Whether or not this tip is enabled'),
  ];
  db_add_field('beautytips_custom_tips', 'enabled', $spec);
  return $ret;
}

/**
 * Update to add enabled field.
 */
function beautytips_manager_update_7001() {
  $ret = [];

  // Make sure this field doesn't already exist.
  if (db_field_exists('beautytips_custom_tips', 'disable_link')) {
    return $ret;
  }
  $spec = [
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'size' => 'tiny',
    'unsigned' => TRUE,
    'decription' => t('Whether to disable link or not.'),
  ];
  db_add_field('beautytips_custom_tips', 'disable_link', $spec);
  return $ret;
}

/**
 * Extend the length of the element field.
 */
function beautytips_manager_update_7002() {
  db_change_field('beautytips_custom_tips', 'element', 'element', [
    'type' => 'varchar',
    'length' => 255,
    'description' => t('The element to which this beautytips will be applied.'),
    'not null' => TRUE,
  ]);
}

Functions

Namesort descending Description
beautytips_manager_schema Implementation of hook_schema().
beautytips_manager_update_7000 Update to add enabled field.
beautytips_manager_update_7001 Update to add enabled field.
beautytips_manager_update_7002 Extend the length of the element field.