You are here

stringoverrides.install in String Overrides 7

Stringoverride install.

File

stringoverrides.install
View source
<?php

/**
 * @file
 * Stringoverride install.
 */

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

  // Remove all stored string replacements.
  $or = db_or()
    ->condition('name', 'locale_custom_strings_%', 'LIKE')
    ->condition('name', 'locale_custom_disabled_strings_%', 'LIKE');
  db_delete('variable')
    ->condition($or)
    ->execute();
}

/**
 * Update to Drupal 7. This will add the context support to custom strings.
 */
function stringoverrides_update_7000() {
  $ret = array();

  // Retrieve all existing overrides.
  $or = db_or()
    ->condition('name', 'locale_custom_strings_%', 'LIKE')
    ->condition('name', 'locale_custom_disabled_strings_%', 'LIKE');
  $result = db_select('variable', 'v')
    ->fields('v')
    ->condition($or)
    ->execute();

  // Push the overrides one level deeper for context support.
  foreach ($result as $variable) {

    // Retrieve the value using variable_get so that it's unserialized.
    $overrides = variable_get($variable->name, array());

    // Save the value back into the variables table with the context support.
    variable_set($variable->name, array(
      '' => $overrides,
    ));
  }
}

Functions

Namesort descending Description
stringoverrides_uninstall Implements hook_uninstall().
stringoverrides_update_7000 Update to Drupal 7. This will add the context support to custom strings.