You are here

function menu_minipanels_requirements in Menu Minipanels 7

Same name and namespace in other branches
  1. 6 menu_minipanels.install \menu_minipanels_requirements()

Implements hook_requirements().

2 calls to menu_minipanels_requirements()
menu_minipanels_admin in ./menu_minipanels.admin.inc
Page callback for admin/settings/menu_minipanels
menu_minipanels_install in ./menu_minipanels.install
Implements hook_install().

File

./menu_minipanels.install, line 57
Installation and update scripts for Menu_MiniPanels.

Code

function menu_minipanels_requirements($phase) {
  $t = get_t();
  $requirements = array();
  if ($phase == 'runtime') {
    $qtip_path = FALSE;
    $filename = 'jquery.qtip-1.0.0-rc3.min.js';
    $module_path = drupal_get_path('module', 'menu_minipanels');

    // An array of possible paths, in descending order of preference.
    $possible_paths = array(
      // Ideally should be stored here.
      'sites/all/libraries/qtip',
      // Legacy paths, including some possible incorrect ones, but the
      // performance hit should be negligible.
      $module_path . '/js/lib/qtip',
      $module_path . '/js/lib',
      $module_path . '/js/qtip',
      $module_path . '/js',
      $module_path . '/qtip',
      $module_path,
    );

    // Proper Libraries API support.
    if (function_exists('libraries_get_path')) {
      $lib_path = libraries_get_path('qtip');
      if (!empty($lib_path) && !in_array($lib_path, $possible_paths)) {
        array_unshift($possible_paths, $lib_path);
      }
    }

    // Check each of the paths.
    foreach ($possible_paths as $path) {

      // If the file exists, this is the one we'll use.
      if (file_exists($path . '/' . $filename)) {
        $qtip_path = $path . '/' . $filename;
        continue;
      }
    }

    // If the file was not found, leave a message for the user.
    if (empty($qtip_path)) {
      $requirements['menu_minipanels'] = array(
        'description' => $t('The module is enabled but the qTip library has not been downloaded. This module will not work without qTip! Please see README.txt in the menu_minipanels directory for instructions on how to download qTip, or use <a href="http://drupal.org/project/drush">Drush</a> to download it via the following command:<br /><pre>drush download-qtip</pre>'),
        'severity' => REQUIREMENT_ERROR,
        'title' => $t('Menu MiniPanels'),
        'value' => $t('qTip library not found'),
      );
    }
    else {
      $requirements['menu_minipanels'] = array(
        'severity' => REQUIREMENT_OK,
        'title' => $t('Menu MiniPanels'),
        'value' => $t('qTip library in use: <em>!path</em>.', array(
          '!path' => $qtip_path,
        )),
      );
      $cid = 'menu_minipanels_qtip_path';
      cache_set($cid, $qtip_path);
    }
  }
  return $requirements;
}