Projet

Général

Profil

Paste
Télécharger (2,23 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / color / color.install @ c7768a53

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update and uninstall functions for the color module.
6
 */
7

    
8
/**
9
 * Implements hook_requirements().
10
 */
11
function color_requirements($phase) {
12
  $requirements = array();
13

    
14
  if ($phase == 'runtime') {
15
    // Check for the PHP GD library.
16
    if (function_exists('imagegd2')) {
17
      $info = gd_info();
18
      $requirements['color_gd'] = array(
19
        'value' => $info['GD Version'],
20
      );
21

    
22
      // Check for PNG support.
23
      if (function_exists('imagecreatefrompng')) {
24
        $requirements['color_gd']['severity'] = REQUIREMENT_OK;
25
      }
26
      else {
27
        $requirements['color_gd']['severity'] = REQUIREMENT_WARNING;
28
        $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'));
29
      }
30
    }
31
    else {
32
      $requirements['color_gd'] = array(
33
        'value' => t('Not installed'),
34
        'severity' => REQUIREMENT_ERROR,
35
        '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')),
36
      );
37
    }
38
    $requirements['color_gd']['title'] = t('GD library PNG support');
39
  }
40

    
41
  return $requirements;
42
}
43

    
44
/**
45
 * @addtogroup updates-7.x-extra
46
 * @{
47
 */
48

    
49
/**
50
 * Warn site administrator if unsafe CSS color codes are found in the database.
51
 */
52
function color_update_7001() {
53
  $theme_palettes = db_query("SELECT name FROM {variable} WHERE name LIKE 'color_%_palette'")->fetchCol();
54
  foreach ($theme_palettes as $name) {
55
    $palette = variable_get($name, array());
56
    foreach ($palette as $key => $color) {
57
      if (!preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color)) {
58
        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');
59
      }
60
    }
61
  }
62
}
63

    
64
/**
65
 * @} End of "addtogroup updates-7.x-extra".
66
 */