color.install 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the color module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function color_requirements($phase) {
  10. $requirements = array();
  11. if ($phase == 'runtime') {
  12. // Check for the PHP GD library.
  13. if (function_exists('imagegd2')) {
  14. $info = gd_info();
  15. $requirements['color_gd'] = array(
  16. 'value' => $info['GD Version'],
  17. );
  18. // Check for PNG support.
  19. if (function_exists('imagecreatefrompng')) {
  20. $requirements['color_gd']['severity'] = REQUIREMENT_OK;
  21. }
  22. else {
  23. $requirements['color_gd']['severity'] = REQUIREMENT_WARNING;
  24. $requirements['color_gd']['description'] = t('The GD library for PHP is enabled, but was compiled without PNG support. Check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/ref.image.php'));
  25. }
  26. }
  27. else {
  28. $requirements['color_gd'] = array(
  29. 'value' => t('Not installed'),
  30. 'severity' => REQUIREMENT_ERROR,
  31. 'description' => t('The GD library for PHP is missing or outdated. Check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/book.image.php')),
  32. );
  33. }
  34. $requirements['color_gd']['title'] = t('GD library PNG support');
  35. }
  36. return $requirements;
  37. }
  38. /**
  39. * @addtogroup updates-7.x-extra
  40. * @{
  41. */
  42. /**
  43. * Warn site administrator if unsafe CSS color codes are found in the database.
  44. */
  45. function color_update_7001() {
  46. $theme_palettes = db_query("SELECT name FROM {variable} WHERE name LIKE 'color_%_palette'")->fetchCol();
  47. foreach ($theme_palettes as $name) {
  48. $palette = variable_get($name, array());
  49. foreach ($palette as $key => $color) {
  50. if (!preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color)) {
  51. drupal_set_message('Some of the custom CSS color codes specified via the color module are invalid. Please examine the themes which are making use of the color module at the <a href="'. url('admin/appearance/settings') .'">Appearance settings</a> page to verify their CSS color values.', 'warning');
  52. }
  53. }
  54. }
  55. }
  56. /**
  57. * @} End of "addtogroup updates-7.x-extra".
  58. */