You are here

shrinktheweb.install in ShrinkTheWeb 8

Same filename and directory in other branches
  1. 6 shrinktheweb.install
  2. 7 shrinktheweb.install

File

shrinktheweb.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function shrinktheweb_schema() {
  $schema['shrinktheweb_log'] = array(
    'description' => 'Stores the STW requests',
    'fields' => array(
      'stw_siteid' => array(
        'description' => '',
        'type' => 'serial',
        'unsigned' => TRUE,
        'size' => 'normal',
        'not null' => TRUE,
      ),
      'stw_domain' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'stw_hash' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '32',
        'not null' => TRUE,
      ),
      'stw_timestamp' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '12',
        'not null' => TRUE,
        'default' => '',
      ),
      'stw_capturedon' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '12',
        'not null' => TRUE,
      ),
      'stw_quality' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 90,
      ),
      'stw_full' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'stw_xmax' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 200,
      ),
      'stw_ymax' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 150,
      ),
      'stw_nrx' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 1024,
      ),
      'stw_nry' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 768,
      ),
      'stw_invalid' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'stw_stwerrcode' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '50',
        'not null' => TRUE,
      ),
      'stw_error' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'stw_errcode' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '50',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'stw_siteid',
    ),
    'unique keys' => array(
      'key' => array(
        'stw_hash',
      ),
    ),
  );
  $schema['shrinktheweb_fields'] = array(
    'description' => 'Stores field ids for which stw formatter is enabled',
    'fields' => array(
      'stw_field_id' => array(
        'description' => '',
        'type' => 'serial',
        'unsigned' => TRUE,
        'size' => 'normal',
        'not null' => TRUE,
      ),
      'stw_field_name' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'default' => '',
      ),
      'stw_entity_bundle' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'stw_field_id',
    ),
    'unique keys' => array(
      'key' => array(
        'stw_field_name',
      ),
    ),
  );
  return $schema;
}
function shrinktheweb_uninstall() {
  entity_render_cache_clear();
}

/**
 * Implements hook_install
 */
function shrinktheweb_install() {
  $config = \Drupal::config('shrinktheweb.settings');
  $directory = file_default_scheme() . '://' . $config
    ->get('shrinktheweb_thumbs_folder');
  file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  \Drupal\shrinktheweb\Controller\ShrinkTheWebSettingsPageController::shrinktheweb_check_scheme_options();

  //  shrinktheweb_check_scheme_options();
}

///**

// * Check https function
// */

//function shrinktheweb_is_ssl() {

//  if (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') != 0) {
//    return TRUE;
//  }
//  elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
//    return TRUE;
//  }
//  elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') == 0) {
//    return TRUE;
//  }
//  return FALSE;

//}

//

///**

// * Check scheme function
// */

//function shrinktheweb_check_scheme_options() {

//  $config = \Drupal::service('config.factory')->getEditable('shrinktheweb.settings');
//  if (shrinktheweb_is_ssl()) {
//    $config->set('shrinktheweb_enable_https', 1);
//    $config->set('shrinktheweb_enable_https_set_automatically', 1);
//  }
//  else {
//    if ($config->get('shrinktheweb_enable_https_set_automatically') == 1) {
//      $config->set('shrinktheweb_enable_https', 0);
//      $config->set('shrinktheweb_enable_https_set_automatically', 0);
//    }
//  }
//  $config->save();

//}

//

///**

// * Implementation of hook_enable().
// */

//function shrinktheweb_enable() {

//  shrinktheweb_check_scheme_options();

//}

Functions

Namesort descending Description
shrinktheweb_install Implements hook_install
shrinktheweb_schema Implementation of hook_schema().
shrinktheweb_uninstall