You are here

views_sexy_throbber.install in Views Sexy Throbber 7.2

Views Sexy Throbber installation file.

File

views_sexy_throbber.install
View source
<?php

/**
 * @file
 * Views Sexy Throbber installation file.
 */

/**
 * Implements hook_requirements().
 */
function views_sexy_throbber_requirements($phase) {

  // Create an array to hold Views Sexy Throbber requirements.
  $requirements = array();

  // Get language.
  $t = get_t();

  // Check requirements during the runtime phase.
  if ($phase == 'runtime') {

    // Check if the Views Sexy Throbber plugin library is available.
    if (!module_exists('css3pie')) {
      $requirements['views_sexy_throbber_css3pie'] = array(
        'title' => $t('Views Sexy Throbber IE7 and IE8 Support'),
        'value' => $t('Download and enable the !css3pie module to properly render the "Views Sexy Throber" styles under Microsoft Internet Explorer version 7 and 8. Internet Explorer 9 and newer browsers dont need this.', array(
          '!css3pie' => l($t('CSS3PIE'), 'http://drupal.org/project/css3pie', array(
            'attributes' => array(
              'target' => '_blank',
            ),
          )),
        )),
        'severity' => REQUIREMENT_WARNING,
      );
    }
  }
  return $requirements;
}

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

  // Include the views sexy throbber variables.
  include 'variables.inc';

  // Check if the custom throbber directory exist and if not create it.
  if (!file_prepare_directory($user_directory, $options = FILE_CREATE_DIRECTORY)) {
    drupal_set_message(get_t('Fatal Error: There was a problem creating the views sexy throbber directory. Please make sure your public folder is writable by Drupal and reinstall the module. If you need more help please use the module issue page or read the documentation.'), 'error', TRUE);
  }

  // Copy the default thobber images to the user directory.
  foreach ($throbber_images_default as $throbber_image) {
    $throbber_copy_source = $throbber_image->uri;
    $throbber_copy_target = $user_directory . '/' . $throbber_image->filename;
    file_unmanaged_copy($throbber_copy_source, $throbber_copy_target, FILE_EXISTS_REPLACE);
  }

  // Create the user css file if not exists.
  if (!file_exists($user_css_uri)) {

    // Create the user css file by cloning the original.
    file_unmanaged_copy($default_css_uri, $user_css_uri, FILE_EXISTS_REPLACE);
  }

  // Make the user css file writable.
  drupal_chmod($user_css_uri, $mode = 664);
}

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

  // Remove the configuration tables from the database.
  variable_del('views_sexy_throbber_append_important');
  variable_del('views_sexy_throbber_background');
  variable_del('views_sexy_throbber_image');
  variable_del('views_sexy_throbber_image_background');
  variable_del('views_sexy_throbber_image_background_border_radius');
  variable_del('views_sexy_throbber_image_background_use_border_radius');
  variable_del('views_sexy_throbber_opacity');
  variable_del('views_sexy_throbber_use_in_other_modules');
}

/**
 * Move throbber images and user css to the same public folder.
 */
function views_sexy_throbber_update_7200() {

  // Run the update file.
  include 'updates/update_7200.php';
}

/**
 * Add "CSS3PIE" module compatibility to support Internet Explorer 7 and above.
 */
function views_sexy_throbber_update_7201() {

  // Re-generate the css file.
  include 'updates/generate_css.php';
}

Functions

Namesort descending Description
views_sexy_throbber_install Implements hook_install().
views_sexy_throbber_requirements Implements hook_requirements().
views_sexy_throbber_uninstall Implements hook_uninstall().
views_sexy_throbber_update_7200 Move throbber images and user css to the same public folder.
views_sexy_throbber_update_7201 Add "CSS3PIE" module compatibility to support Internet Explorer 7 and above.