You are here

lingotek.install in Lingotek Translation 6

Installation for Lingotek Community Translation Module

File

lingotek.install
View source
<?php

/**
 * @file
 * Installation for Lingotek Community Translation Module
 */

/*
 * Install the Lingotek module
 */
function lingotek_install() {
  drupal_install_schema('lingotek');
}

/*
 * Uninstall the Lingotek module
 */
function lingotek_uninstall() {
  drupal_uninstall_schema('lingotek');
  variable_del('lingotek_login_id');
  variable_del('lingotek_login_key');
  variable_del('lingotek_url');
  variable_del('lingotek_community');
  variable_del('lingotek_project');
  variable_del('lingotek_project');
  variable_del('lingotek_vault');
  variable_del('lingotek_vault');
  variable_del('lingotek_neutral_language');
  variable_del('lingotek_menu_overwrite');
  variable_del('lingotek_use_lightbox');
  variable_del('lingotek_phase_template');
  variable_del('lingotek_publish_with_mt');
  variable_del('lingotek_available_mt_options');
  variable_del('lingotek_error_log');
}

/*
 * Install the database schema for the Lingotek module
 */
function lingotek_schema() {
  $schema['lingotek'] = array(
    'description' => 'Table for storing node related data.',
    'fields' => array(
      'nid' => array(
        'description' => 'The primary identifier for a node',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'lingokey' => array(
        'description' => 'Key in key/value pairs',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'lingovalue' => array(
        'description' => 'Value of the specified key',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'nid',
      'lingokey',
    ),
  );
  $schema['lingotek_mt_queue'] = array(
    'description' => 'Table for storing a Machine Translation queue.',
    'fields' => array(
      'uid' => array(
        'description' => 'The primary identifier for a user.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => 'The primary identifier for a node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'description' => 'Language to machine translate',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'engine' => array(
        'description' => 'Engine used to machine translate',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
  );
  return $schema;
}

/*
 * Update
 * 1. Create the mt-queue
 * 2. delete the reference variable that was stored in lingotek_languages
 */
function lingotek_update_6200() {
  variable_del('lingotek_languages');
  $schema['lingotek_mt_queue'] = array(
    'description' => 'Table for storing a Machine Translation queue.',
    'fields' => array(
      'uid' => array(
        'description' => 'The primary identifier for a user.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => 'The primary identifier for a node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'description' => 'Language to machine translate',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'engine' => array(
        'description' => 'Engine used to machine translate',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
  );
  $ret = array();
  db_create_table($ret, 'lingotek_mt_queue', $schema['lingotek_mt_queue']);
  return $ret;
}

/*
 * Update documents to using the new html embedded in xml structure utilizing CDATA
 */
function lingotek_update_6201() {
  $result = db_query("SELECT n.nid FROM {lingotek} n WHERE n.lingokey = 'document_id'");
  while ($row = db_fetch_object($result)) {
    $node = node_load(array(
      'nid' => $row->nid,
    ));
    lingotek_node_update($node);
  }
  return array();
}