You are here

fitvids.install in FitVids 8

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

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 - see fitvids.module

/**
 * If the plugin doesn't exist, show a warning on the status page
 */
function fitvids_requirements($phase) {
  $requirements = [];

  // Check if plugin exists
  if ($phase == 'install') {
    $path = DRUPAL_ROOT . '/libraries/fitvids/jquery.fitvids.js';
    $installed = file_exists($path);
    if (!$installed) {

      // just a message will do here...
      // returning a $requirements array seems to crash drupal...
      \Drupal::messenger()
        ->addWarning(t('The FitVids.js jQuery plugin is missing. <a href="https://raw.github.com/davatron5000/FitVids.js/master/jquery.fitvids.js" rel="external">Download the plugin</a> and copy it to /libraries/fitvids/jquery.fitvids.js'));
    }
  }
  else {
    if ($phase == 'runtime') {
      $path = DRUPAL_ROOT . '/libraries/fitvids/jquery.fitvids.js';
      $installed = file_exists($path);
      if (!$installed) {
        $requirements['fitvids'] = [
          'title' => t('FitVids.js jQuery plugin'),
          'value' => t('Missing'),
          'description' => t('<a href=":url" rel="external">Download the plugin</a> and copy it to :library', [
            ':url' => FITVIDS_PLUGIN_URL,
            ':library' => FITVIDS_LIBRARY_PATH,
          ]),
          'severity' => REQUIREMENT_WARNING,
        ];
      }
      else {
        $requirements['fitvids'] = [
          'title' => t('FitVids.js jQuery plugin'),
          'value' => t('Installed'),
          'severity' => REQUIREMENT_OK,
        ];
      }
    }
  }
  return $requirements;
}

/**
 * Enable the module
 * hook_enable doesn't exist in drupal 8...

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.', [
      '!fitvids-site' => l(t('here'), FITVIDS_PLUGIN_URL),
      '!fitvids-library' => libraries_get_path('fitvids'),
      '!fitvids-filename' => FITVIDS_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', [
      '!fitvids-configuration' => l(t('here'), 'admin/config/media/fitvids'),
    ]);
    drupal_set_message(filter_xss_admin($message));
  }
} */

Functions

Namesort descending Description
fitvids_requirements If the plugin doesn't exist, show a warning on the status page