You are here

stringoverrides_advanced.install in String Overrides Advanced 7

File

stringoverrides_advanced.install
View source
<?php

/**
 * Implements hook_schema().
 */
function stringoverrides_advanced_schema() {
  $schema['stringoverrides_advanced_source'] = array(
    'description' => 'List of English source strings.',
    'fields' => array(
      'lid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Unique identifier of this string.',
      ),
      'location' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.',
      ),
      'textgroup' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'default',
        'description' => 'A module defined group of translations, see hook_locale().',
      ),
      'source' => array(
        'type' => 'text',
        'mysql_type' => 'blob',
        'not null' => TRUE,
        'description' => 'The original string in English.',
      ),
      'context' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The context this string applies to.',
      ),
      'version' => array(
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => 'none',
        'description' => 'Version of Drupal, where the string was last used (for locales optimization).',
      ),
    ),
    'primary key' => array(
      'lid',
    ),
    'indexes' => array(
      'source_context' => array(
        array(
          'source',
          30,
        ),
        'context',
      ),
    ),
  );
  $schema['stringoverrides_advanced_target'] = array(
    'description' => 'Stores translated versions of strings.',
    'fields' => array(
      'lid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Source string ID. References {stringoverrides_advanced_source}.lid.',
      ),
      'translation' => array(
        'type' => 'text',
        'mysql_type' => 'blob',
        'not null' => TRUE,
        'description' => 'Translation string value in this language.',
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Language code. References {languages}.language.',
      ),
      'plid' => array(
        'type' => 'int',
        'not null' => TRUE,
        // This should be NULL for no referenced string, not zero.
        'default' => 0,
        'description' => 'Parent lid (lid of the previous string in the plural chain) in case of plural strings. References {stringoverrides_advanced_source}.lid.',
      ),
      'plural' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Plural index number in case of plural strings.',
      ),
    ),
    'primary key' => array(
      'language',
      'lid',
      'plural',
    ),
    'foreign keys' => array(
      'stringoverrides_advanced_source' => array(
        'table' => 'stringoverrides_advanced_source',
        'columns' => array(
          'lid' => 'lid',
        ),
      ),
    ),
    'indexes' => array(
      'lid' => array(
        'lid',
      ),
      'plid' => array(
        'plid',
      ),
      'plural' => array(
        'plural',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_requirements().
 */
function stringoverrides_advanced_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();

  // We want this run on runtime phase, and if we're installing, and we can
  // check to see if a module exists.
  if ($phase == 'runtime' || $phase == 'install' && function_exists('module_exists')) {
    if (module_exists('stringoverrides')) {
      $requirements['stringoverrides_advanced_stringoverrides'] = array(
        'title' => $t('String Overrides Advanced'),
        'value' => $t('Not compatible with the String Overrides module. Please disable either String Overrides module or String Overrides Advanced module.'),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}

/**
 * Implements hook_install().
 */
function stringoverrides_advanced_install() {

  // Set the module weight nice and low.
  db_update('system')
    ->fields(array(
    'weight' => -10000,
  ))
    ->condition('name', 'stringoverrides_advanced')
    ->execute();
}

/**
 * Implements hook_update_N().
 */
function stringoverrides_advanced_update_7100() {

  // Set the module weight nice and low.
  db_update('system')
    ->fields(array(
    'weight' => -10000,
  ))
    ->condition('name', 'stringoverrides_advanced')
    ->execute();
}