You are here

function js_injector_schema in JS injector 7.2

Same name and namespace in other branches
  1. 6.2 js_injector.install \js_injector_schema()
  2. 6 js_injector.install \js_injector_schema()
  3. 7 js_injector.install \js_injector_schema()

Implements hook_schema().

File

./js_injector.install, line 12
js_injector.install

Code

function js_injector_schema() {
  $schema['js_injector_rule'] = array(
    'description' => t('Table storing JS injector rule definitions.'),
    'export' => array(
      'key' => 'name',
      'primary key' => 'crid',
      'identifier' => 'rule',
      // Exports will be defined as $rule
      'default hook' => 'js_injector_rule',
      'save callback' => 'js_injector_rule_save',
      'delete callback' => 'js_injector_rule_delete',
      'api' => array(
        'owner' => 'js_injector',
        'api' => 'js_injector_rules',
        // Base name for api include files.
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'name' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'Unique ID for rules. Used to identify them programmatically.',
      ),
      'crid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The primary identifier for the JS injection rule',
        'no export' => TRUE,
      ),
      // Changed to 'admin_description' in an update hook.
      'admin_description' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'A human readable name of a rule.',
      ),
      'js' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'The actual JavaScript code.',
      ),
      'position' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'The scope of the JavaScript on the page (e.g. header or footer).',
      ),
      'preprocess' => array(
        'description' => 'Boolean indicating whether the rule should be aggregated into other JS files.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'inline' => array(
        'description' => 'Boolean indicating whether the rules should be inline (cannot be aggregated).',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'page_visibility' => array(
        'description' => 'Boolean indicating whether the rule has a white or black list for page visibility.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'page_visibility_pages' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'A list of pages to either hide or show the JavaScript.',
      ),
      'noscript_regions' => array(
        'type' => 'text',
        'serialize' => TRUE,
        'description' => 'A serialized array of theme regions where the noscript tag is injected.',
      ),
      'noscript' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'The noscript code.',
      ),
    ),
    'primary key' => array(
      'crid',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  return $schema;
}