less.install 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Implements HOOK_enable().
  4. */
  5. function less_enable() {
  6. drupal_theme_rebuild();
  7. }
  8. function less_uninstall() {
  9. variable_del('less_devel');
  10. variable_del('less_dir');
  11. }
  12. /**
  13. * Implementation of hook_requirements().
  14. *
  15. * @param $phase The phase in which hook_requirements is run: install or runtime.
  16. */
  17. function less_requirements($phase) {
  18. $requirements = array();
  19. $lessc_exists = FALSE;
  20. module_load_include('module', 'less');
  21. if (function_exists('_less_inc')) {
  22. $lessc_exists = _less_inc();
  23. }
  24. switch ($phase) {
  25. case 'runtime':
  26. if ($lessc_exists) {
  27. $requirements['less_version'] = array(
  28. 'title' => t('LESS'),
  29. 'value' => isset(lessc::$VERSION) ? preg_replace('/([^0-9\.-])+/i', '', lessc::$VERSION) : '(less than v0.3.2)',
  30. 'description' => t('To check for newer versions of lessphp, go to <a href="!url" target="_blank">http://leafo.net/lessphp/</a>', array("!url" => url('http://leafo.net/lessphp/'))),
  31. 'severity' => REQUIREMENT_OK,
  32. );
  33. }
  34. if (variable_get('less_devel', FALSE)) {
  35. $requirements['less_devel'] = array(
  36. 'title' => 'LESS developer mode',
  37. 'value' => t('Enabled'),
  38. 'description' => t('LESS files are being regenerated on every request. Remember to <a href="!url">turn off</a> this feature on production websites.', array("!url" => url('admin/config/development/less'))),
  39. 'severity' => REQUIREMENT_WARNING,
  40. );
  41. }
  42. if (!$lessc_exists) {
  43. $requirements['less_library'] = array(
  44. 'title' => 'LESS',
  45. 'description' => t('The lessphp library was not detected. Please follow the instructions on the <a href="!url" target="_blank">LESS project page</a> to install the lessphp library.', array("!url" => url('http://drupal.org/project/less'))),
  46. 'severity' => REQUIREMENT_ERROR,
  47. );
  48. }
  49. break;
  50. default:
  51. break;
  52. }
  53. return $requirements;
  54. }