less.install 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for the less module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function less_uninstall() {
  10. variable_del('less_engine');
  11. variable_del(LESS_DEVEL);
  12. variable_del(LESS_WATCH);
  13. variable_del(LESS_SOURCE_MAPS);
  14. variable_del('less_dir');
  15. cache_clear_all('less:', 'cache', TRUE);
  16. }
  17. /**
  18. * Implements hook_requirements().
  19. */
  20. function less_requirements($phase) {
  21. $requirements = array();
  22. $t = get_t();
  23. switch ($phase) {
  24. case 'runtime':
  25. $less_engine_loaded = _less_inc();
  26. if (!empty($less_engine_loaded)) {
  27. $loaded_engine = libraries_detect($less_engine_loaded);
  28. $requirements['less_version'] = array(
  29. 'title' => $t('LESS'),
  30. 'value' => $loaded_engine['name'] . ' - v' . $loaded_engine['version'],
  31. 'description' => $t('To check for newer versions go to <a href="@vendor_url" target="_blank">@vendor_url</a>.', array('@vendor_url' => $loaded_engine['vendor url'])),
  32. 'severity' => REQUIREMENT_OK,
  33. );
  34. }
  35. else {
  36. $requirements['less_library'] = array(
  37. 'title' => $t('LESS'),
  38. 'value' => '',
  39. 'description' => $t('A LESS library was not detected. Please follow the instructions on the <a href="!url" target="_blank">LESS project page</a> to install the a LESS library.', array("!url" => url('https://drupal.org/project/less'))),
  40. 'severity' => REQUIREMENT_ERROR,
  41. );
  42. }
  43. if (variable_get(LESS_DEVEL, FALSE)) {
  44. $requirements[LESS_DEVEL] = array(
  45. 'title' => 'LESS developer mode',
  46. 'value' => $t('Enabled'),
  47. 'description' => $t('LESS files are being checked on every request. Remember to <a href="!url">turn off</a> this feature on production websites.', array("!url" => url('admin/config/development/less'))),
  48. 'severity' => REQUIREMENT_WARNING,
  49. );
  50. }
  51. break;
  52. default:
  53. break;
  54. }
  55. return $requirements;
  56. }