You are here

custom_breadcrumbs.install in Custom Breadcrumbs 7.2

Install file for the custom_breadcrumbs module.

File

custom_breadcrumbs.install
View source
<?php

/**
 * @file
 * Install file for the custom_breadcrumbs module.
 */

/**
 * Implements hook_schema().
 */
function custom_breadcrumbs_schema() {
  $schema['custom_breadcrumb'] = array(
    'description' => 'Stores custom breadcrumb trail overrides.',
    'fields' => array(
      'bid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Unique identifier for the {custom_breadcrumb}.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
        'description' => 'An optional name for the custom breadcrumb.',
      ),
      'titles' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
        'description' => 'A return-delimited list of titles for the breadcrumb links.',
      ),
      'paths' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
        'description' => 'A return-delimited list of url paths for the breadcrumb links.',
      ),
      'visibility_php' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
        'description' => 'An optional PHP snippet to control the {custom_breadcrumb} visibility.',
      ),
      'node_type' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
        'default' => 'AND',
        'description' => 'Node types the {custom_breadcrumb} should apply to.',
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The language this breadcrumb is for; if blank, the breadcrumb will be used for unknown languages.',
      ),
    ),
    'indexes' => array(
      'language' => array(
        'language',
      ),
      'node_language' => array(
        'node_type',
        'language',
      ),
    ),
    'primary key' => array(
      'bid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function custom_breadcrumbs_uninstall() {

  // Remove persistent variables.
  db_delete('variable')
    ->condition('name', 'custom_breadcrumbs_%', 'like')
    ->execute();
}

/**
 * Update old-style tokens from early versions of token.module.
 */
function custom_breadcrumbs_update_1() {
  $stuff = array(
    '%author_id' => '[author-uid]',
    '%author_name' => '[author-name]',
    '%user_id' => '[user-id]',
    '%user_name' => '[user-name]',
    '%node_id' => '[nid]',
    '%node_type' => '[type]',
    '%node_type_name' => '[type-name]',
    '%top_term' => '[term]',
    '%top_tname' => '[term-id]',
    '%created_d' => '[dd]',
    '%created_D' => '[ddd]',
    '%created_j' => '[d]',
    '%created_l' => '[day]',
    '%created_F' => '[month]',
    '%created_m' => '[mm]',
    '%created_M' => '[mon]',
    '%created_n' => '[m]',
    '%created_y' => '[yy]',
    '%created_Y' => '[yyyy]',
  );
  $search = array_keys($stuff);
  $replace = array_values($stuff);
  $result = db_query("SELECT * FROM {custom_breadcrumb}")
    ->execute();
  foreach ($result as $crumb) {
    $crumb->titles = str_replace($search, $replace, $crumb->titles);
    $crumb->paths = str_replace($search, $replace, $crumb->paths);
    _custom_breadcrumbs_save_breadcrumb('custom_breadcrumb', $crumb);
  }
  return t('Custom Breadcrumb replacement strings updated for use with Token module.');
}

/**
 * Add a visibility_php field.
 */
function custom_breadcrumbs_update_2() {
  db_add_column('custom_breadcrumb', 'visibility_php', 'text', array(
    'not null' => TRUE,
    'default' => "''",
  ));
  return t('Added a visibility_php field to the custom_breadcrumb database table.');
}

/**
 * Implements hook_update_N().
 *
 * Ensure this module's weight is larger than other modules, like views, so
 * custom breadcrumbs page callback is used.
 */
function custom_breadcrumbs_update_3() {
  db_update('system')
    ->fields(array(
    'weight' => 12,
  ))
    ->condition('type', 'module')
    ->condition('name', 'custom_breadcrumbs')
    ->execute();
  return t('Adjusted the custom_ breadcrumbs module weight.');
}

/**
 * Add the menu flag.
 */
function custom_breadcrumbs_update_6001() {
  db_add_field('custom_breadcrumb', 'set_active_menu', array(
    'type' => 'int',
    'default' => 1,
    'NOT NULL' => TRUE,
  ));
  return t('Added set_active_menu flag to custom_breadcrumb database table.');
}

/**
 * Remove the set_active_menu field because it is no longer used.
 */
function custom_breadcrumbs_update_6101() {
  db_drop_field('custom_breadcrumb', 'set_active_menu');
  return t('Removed the set_active_menu field from custom breadcrumb database table because it is no longer used.');
}

/**
 * Adds language support to breadcrumbs.
 */
function custom_breadcrumbs_update_6200() {
  db_add_field('custom_breadcrumb', 'language', array(
    'type' => 'varchar',
    'length' => 12,
    'not null' => TRUE,
    'default' => '',
  ));
  return t('Added language field to custom_breadcrumb database table.');
}

/**
 * Adds indices to custom_breadcrumb table to improve performance.
 */
function custom_breadcrumbs_update_6201() {
  db_add_index('custom_breadcrumb', 'language', array(
    'language',
  ));
  db_add_index('custom_breadcrumb', 'node_language', array(
    'node_type',
    'language',
  ));
  return t('Added indices to custom_breadcrumb table to improve performance.');
}

/**
 * Adds name field for improved organization of breadcrumbs.
 */
function custom_breadcrumbs_update_6202() {
  db_add_field('custom_breadcrumb', 'name', array(
    'type' => 'varchar',
    'length' => 128,
    'NOT NULL' => FALSE,
    'description' => 'An optional name for the custom breadcrumb.',
  ));
  return t('Added name field for improved organization of custom breadcrumbs.');
}

/**
 * Enables custom_breadcrumbs_identifiers for legacy.
 */
function custom_breadcrumbs_update_6203() {
  module_enable(array(
    'custom_breadcrumbs_identifiers',
  ));
  return t('Custom_breadcrumbs_identifiers was enabled for legacy reasons. Please disable it if you do not need special identifiers in your breadcrumb settings.');
}

/**
 * Change the titles and paths fields to fit longer text.
 */
function custom_breadcrumbs_update_7001() {
  db_change_field('custom_breadcrumb', 'titles', 'titles', array(
    'type' => 'text',
    'size' => 'medium',
    'not null' => TRUE,
    'description' => 'A return-delimited list of titles for the breadcrumb links.',
  ));
  db_change_field('custom_breadcrumb', 'paths', 'paths', array(
    'type' => 'text',
    'size' => 'medium',
    'not null' => TRUE,
    'description' => 'A return-delimited list of url paths for the breadcrumb links.',
  ));
}

Functions

Namesort descending Description
custom_breadcrumbs_schema Implements hook_schema().
custom_breadcrumbs_uninstall Implements hook_uninstall().
custom_breadcrumbs_update_1 Update old-style tokens from early versions of token.module.
custom_breadcrumbs_update_2 Add a visibility_php field.
custom_breadcrumbs_update_3 Implements hook_update_N().
custom_breadcrumbs_update_6001 Add the menu flag.
custom_breadcrumbs_update_6101 Remove the set_active_menu field because it is no longer used.
custom_breadcrumbs_update_6200 Adds language support to breadcrumbs.
custom_breadcrumbs_update_6201 Adds indices to custom_breadcrumb table to improve performance.
custom_breadcrumbs_update_6202 Adds name field for improved organization of breadcrumbs.
custom_breadcrumbs_update_6203 Enables custom_breadcrumbs_identifiers for legacy.
custom_breadcrumbs_update_7001 Change the titles and paths fields to fit longer text.