You are here

taxonomy_edge.install in Taxonomy Edge 8

Installation file for Taxonomy Edge

File

taxonomy_edge.install
View source
<?php

/**
 * @file
 *
 * Installation file for Taxonomy Edge
 */

/**
 * Implements hook_install().
 */
function taxonomy_edge_install() {
  db_add_index('node', 'idx_taxonomy_edge', array(
    'sticky',
    'created',
    'nid',
  ));
  drupal_set_message(st('Taxonomy Edge is now installed. Add the provided patch to the core module Taxonomy module for better performance.'));
  drupal_set_message(st('Taxonomy Edge settings are available under !link', array(
    '!link' => l(st('Administer > Structure > Taxonomy'), 'admin/structure/taxonomy/edge'),
  )));
  drupal_set_message(st('Remember to build trees: !link', array(
    '!link' => l(st('Administer > Structure > Taxonomy'), 'admin/structure/taxonomy'),
  )));
}

/**
 * Implements hook_uninstall().
 */
function taxonomy_edge_uninstall() {
  db_drop_index('node', 'idx_taxonomy_edge');
  drupal_set_message(st('Taxonomy Edge is now uninstalled. You may remove the provided patch to the core module Taxonomy module if applicable.'));
}

/**
 * Implements hook_schema().
 */
function taxonomy_edge_schema() {
  $schema['taxonomy_term_edge'] = array(
    'description' => 'Stores edge list for taxonomies.',
    'fields' => array(
      'eid' => array(
        'description' => 'Edge ID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => 'Vocabulary ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'Term ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'parent' => array(
        'description' => 'Parent Term ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'distance' => array(
        'description' => 'Distance to parent (depth)',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'eid',
    ),
    'indexes' => array(
      'idx_update' => array(
        'vid',
        'distance',
        'parent',
      ),
      'idx_depth' => array(
        'parent',
        'distance',
        'vid',
      ),
      'idx_term' => array(
        'tid',
        'distance',
      ),
      'idx_tree' => array(
        'parent',
        'vid',
        'distance',
      ),
    ),
  );
  $schema['taxonomy_term_edge_order'] = array(
    'description' => 'Sequencing table for sorting taxonomies.',
    'fields' => array(
      'oid' => array(
        'description' => 'Order ID',
        'type' => 'serial',
      ),
      'vid' => array(
        'description' => 'Vocabulary ID',
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'parent' => array(
        'description' => 'Parent term ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'eid' => array(
        'description' => 'Edge ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'oid',
    ),
    'indexes' => array(
      'idx_order' => array(
        'vid',
        'parent',
      ),
      'idx_edge' => array(
        'eid',
      ),
    ),
  );
  return $schema;
}

Functions