You are here

ocupload.install in One Click Upload 7.2

Same filename and directory in other branches
  1. 7 ocupload.install

One Click Upload install file.

File

ocupload.install
View source
<?php

/**
 * @file
 * One Click Upload install file.
 */

/**
 * Implements hook_schema().
 */
function ocupload_schema() {
  $shema['ocupload_templates'] = array(
    'fields' => array(
      'tid' => array(
        'description' => 'Template ID',
        'type' => 'serial',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'mask' => array(
        'description' => 'File mask',
        'type' => 'varchar',
        'length' => 200,
        'not null' => TRUE,
        'default' => '',
      ),
      'path' => array(
        'description' => 'Upload path',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'filename' => array(
        'description' => 'Filename',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'max_filesize' => array(
        'description' => 'Max filesize in bytes',
        'type' => 'int',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'template' => array(
        'description' => 'Template',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'template_select' => array(
        'description' => 'Template for replace selected text',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'image_style' => array(
        'description' => 'Image style',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
      'image_style_original' => array(
        'description' => 'Image style for original image',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
      'link_to_original' => array(
        'description' => 'Wrap template link to original image',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'link_template' => array(
        'description' => 'Link template',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'link_only_big' => array(
        'description' => '1 - wrap template only big images, 0 - wrap all images',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'max_dimensions' => array(
        'description' => 'Maximum image resolution',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
      'transliterate' => array(
        'description' => '1 - transliterate filename, 0 - not transliterate',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'field' => array(
        'description' => 'Field name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'tid',
    ),
    'description' => 'Module templates',
  );
  return $shema;
}

/**
 * Implements hook_install().
 */
function ocupload_install() {
  module_load_include('inc', 'ocupload');
  $templates = array(
    array(
      'mask' => 'jpg,jpeg,gif,png',
      'path' => 'public://inline/images',
      'template' => '<img src="!filepath" alt="" data-fid="!filefid" />',
      'template_select' => module_exists('colorbox') ? '<a href="!filepath" class="colorbox" target="_blank" data-fid="!filefid">!text</a>' : '<a href="!filepath" target="_blank" data-fid="!filefid">!text</a>',
      'link_template' => '<a href="!filepath" target="_blank">!image</a>',
    ),
    array(
      'mask' => 'rar,zip,doc,xls',
      'path' => 'public://inline/files',
      'template' => '<a href="!filepath" data-fid="!filefid">!filename</a>',
      'template_select' => '<a href="!filepath" data-fid="!filefid">!text</a>',
    ),
    array(
      'mask' => 'webm,mp4,ogv',
      'path' => 'public://inline/video',
      'template' => '<video src="!filepath" width="480" height="390" controls data-fid="!filefid"></video>',
      'template_select' => '<a href="!filepath" data-fid="!filefid">!text</a>',
    ),
  );
  foreach ($templates as $template) {
    ocupload_template_save($template);
  }
}

/**
 * Implements hook_uninstall().
 */
function ocupload_uninstall() {
  $vars = array(
    'ocupload_textarea_dragndrop',
  );
  foreach ($vars as $var) {
    variable_del($var);
  }
  if (file_exists('temporary://ocupload')) {
    file_unmanaged_delete_recursive('temporary://ocupload');
  }
}

/**
 * Add new col {ocupload_templates}.show_in_colorbox
 */
function ocupload_update_7100() {
  db_add_field('ocupload_templates', 'show_in_colorbox', array(
    'description' => '1 - show original image in colorbox, 0 - open in new page',
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
}

/**
 * Change col length {ocupload_templates}.path
 */
function ocupload_update_7101() {
  db_change_field('ocupload_templates', 'path', 'path', array(
    'description' => 'Upload path',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
}

/**
 * Add new col {ocupload_templates}.image_style_original
 */
function ocupload_update_7102() {
  db_add_field('ocupload_templates', 'image_style_original', array(
    'description' => 'Image style for original image',
    'type' => 'varchar',
    'length' => 50,
    'not null' => TRUE,
    'default' => '',
  ));
}

/**
 * Add new col {ocupload_templates}.max_filesize
 */
function ocupload_update_7103() {
  db_add_field('ocupload_templates', 'max_filesize', array(
    'description' => 'Max filesize in bytes',
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
}

/**
 * Add new col {ocupload_templates}.max_dimensions
 */
function ocupload_update_7104() {
  db_add_field('ocupload_templates', 'max_dimensions', array(
    'description' => 'Maximum image resolution',
    'type' => 'varchar',
    'length' => 20,
    'not null' => TRUE,
    'default' => '',
  ));
}

/**
 * Add new col {ocupload_templates}.link_template
 * Update colorbox integration
 * Delete col {ocupload_templates}.show_in_colorbox
 */
function ocupload_update_7105() {

  // Add field
  db_add_field('ocupload_templates', 'link_template', array(
    'description' => 'Link template',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '<a href="!filepath" target="_blank">!image</a>',
  ));

  // Update Colorbox integration
  module_load_include('module', 'ocupload');
  module_load_include('inc', 'ocupload');
  foreach (ocupload_templates() as $template) {
    if ($template->show_in_colorbox) {
      $template->link_template = '<a href="!filepath" class="colorbox" target="_blank">!image</a>';
      ocupload_template_save($template);
    }
  }

  // Delete field
  db_drop_field('ocupload_templates', 'show_in_colorbox');
}

/**
 * Delete col {ocupload_templates}.rename_file.
 * Add new col {ocupload_templates}.transliterate
 */
function ocupload_update_7200() {

  // Delete field
  db_drop_field('ocupload_templates', 'rename_file');

  // Add field
  db_add_field('ocupload_templates', 'transliterate', array(
    'description' => '1 - transliterate filename, 0 - not transliterate',
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 1,
  ));
}

/**
 * Change {ocupload_templates}.max_filesize.
 */
function ocupload_update_7201() {

  // Add field
  db_change_field('ocupload_templates', 'max_filesize', 'max_filesize', array(
    'description' => 'Max filesize in bytes',
    'type' => 'int',
    'size' => 'big',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
}

/**
 * Add new col {ocupload_templates}.filename
 */
function ocupload_update_7202() {
  db_add_field('ocupload_templates', 'filename', array(
    'description' => 'Filename',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
}

/**
 * Add new col {ocupload_templates}.field
 */
function ocupload_update_7203() {
  db_add_field('ocupload_templates', 'field', array(
    'description' => 'Field name',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
}

/**
 * Remove unused variable.
 */
function ocupload_update_7204() {
  variable_del('ocupload_status_message');
}

Functions

Namesort descending Description
ocupload_install Implements hook_install().
ocupload_schema Implements hook_schema().
ocupload_uninstall Implements hook_uninstall().
ocupload_update_7100 Add new col {ocupload_templates}.show_in_colorbox
ocupload_update_7101 Change col length {ocupload_templates}.path
ocupload_update_7102 Add new col {ocupload_templates}.image_style_original
ocupload_update_7103 Add new col {ocupload_templates}.max_filesize
ocupload_update_7104 Add new col {ocupload_templates}.max_dimensions
ocupload_update_7105 Add new col {ocupload_templates}.link_template Update colorbox integration Delete col {ocupload_templates}.show_in_colorbox
ocupload_update_7200 Delete col {ocupload_templates}.rename_file. Add new col {ocupload_templates}.transliterate
ocupload_update_7201 Change {ocupload_templates}.max_filesize.
ocupload_update_7202 Add new col {ocupload_templates}.filename
ocupload_update_7203 Add new col {ocupload_templates}.field
ocupload_update_7204 Remove unused variable.