Same filename and directory in other branches
  1. 2.0.x fitvids.install 1 comment
  2. 7.x-1.x fitvids.install 1 comment
  3. 8.x-1.x fitvids.install 1 comment

Install, update and uninstall functions for the Fitvids module.

File

./fitvids.install

View source
<?php


/**
 * @file
 * Install, update and uninstall functions for the Fitvids module.
 */
// Constants
define("PLUGIN_URL", 'https://github.com/davatron5000/FitVids.js');
define("PLUGIN_FILENAME", 'jquery.fitvids.js');

/**
 * If the plugin doesn't exist, show a warning on the status page
 */
function fitvids_requirements($phase) {
    $requirements = array();
    switch ($phase) {
        case 'runtime':
            $path = libraries_get_path('fitvids') . '/jquery.fitvids.js';
            $installed = file_exists($path);
            $requirements[] = array(
                'title' => t('Fitvids library'),
                'value' => $installed ? t('Installed') : t('Missing'),
                'description' => t('Fitvids Javascript Library. Download it from !fitvids-site, copy it to the !fitvids-library directory, and rename it to !fitvids-filename.', array(
                    '!fitvids-site' => l(t('here'), PLUGIN_URL),
                    '!fitvids-library' => libraries_get_path('fitvids'),
                    '!fitvids-filename' => PLUGIN_FILENAME,
                )),
                'severity' => $installed ? REQUIREMENT_OK : REQUIREMENT_ERROR,
            );
            break;
    }
    return $requirements;
}

/**
 * Enable the module
 */
function fitvids_enable() {
    $path = libraries_get_path('fitvids') . '/jquery.fitvids.js';
    $installed = file_exists($path);
    if (!$installed) {
        $message = t('You need to download the FitVids.js jQuery plugin to use this module. Download it from !fitvids-site, copy it to the !fitvids-library directory, and rename it to !fitvids-filename.', array(
            '!fitvids-site' => l(t('here'), PLUGIN_URL),
            '!fitvids-library' => libraries_get_path('fitvids'),
            '!fitvids-filename' => PLUGIN_FILENAME,
        ));
        drupal_set_message(filter_xss_admin($message), $type = 'warning');
    }
    else {
        $message = t('You already have the FitVids.js jQuery plugin installed. Configure the module !fitvids-configuration', array(
            '!fitvids-configuration' => l(t('here'), 'admin/config/media/fitvids'),
        ));
        drupal_set_message(filter_xss_admin($message));
    }
}

/**
 * Uninstall the module
 */
function fitvids_uninstall() {
    // Delete module variables
    variable_del('fitvids_selectors');
}

Functions

Title Deprecated Summary
fitvids_enable Enable the module
fitvids_requirements If the plugin doesn't exist, show a warning on the status page
fitvids_uninstall Uninstall the module

Constants

Title Deprecated Summary
PLUGIN_FILENAME
PLUGIN_URL