Skip to content
garlic.module 1.7 KiB
Newer Older
<?php

/**
 * @file
 * Adds the garlic.js library to Drupal and enable basic toggling on entities
 */

Mathew Winstone's avatar
Mathew Winstone committed
define(GARLIC_DEBUG, variable_get('garlic_debug', FALSE));

/**
 * Implements hook_libraries_info().
 */
function garlic_libraries_info() {
  // Garlic
  $libraries['garlic'] = array(
    'name' => "Garlic.js",
    'vendor url' => 'http://garlicjs.org/',
    'download url' => 'http://garlicjs.org/',
    'path' => 'garlic',
    'version arguments' => array(
      'file' => 'dist/garlic.min.js',
      'pattern' => '/(\d+\.\d+\.\d+)/',
      'lines' => 1,
    ),
    'files' => array(
      'js' => array(
        'dist/garlic.min.js'
      )
    ),
    'variants' => array(
      'minified' => array(
        'files' => array(
          'js' => array(
            'dist/garlic.min.js'
          ),
        ),
      ),
      'source' => array(
        'files' => array(
          'js' => array(
            'garlic.js'
          ),
        ),
      ),
    ),
  );
  return $libraries;
}
/**
 * Implements hook_library().
 */
function garlic_library() {
  // Garlic
  $libraries['garlic'] = array(
    'title' => 'Garlic',
    'website' => 'http://garlicjs.org',
    'version' => '1.2.0',
    'js' => array(
Mathew Winstone's avatar
Mathew Winstone committed
      libraries_get_path('garlic') . '/dist/garlic.min.js' => array(),
Mathew Winstone's avatar
Mathew Winstone committed

/**
 * Implements hook_library_alter().
 */
function garlic_library_alter(&$libraries, $module) {
  if (GARLIC_DEBUG) {
    if ($module == 'garlic' && isset($libraries['garlic'])) {
      $libraries['garlic']['js'] = array(libraries_get_path('garlic') . '/garlic.js');
    }    
  }
}

/**
 * Implements hook_uninstall().
 */
function garlic_uninstall() {
  variable_del('garlic_debug');
}


//  @todo add hook_requirements