You are here

function ctools_requirements in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 ctools.install \ctools_requirements()

Use requirements to ensure that the CTools CSS cache directory can be created and that the PHP version requirement is met.

File

./ctools.install, line 12
Contains install and update functions for ctools.

Code

function ctools_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $path = file_create_path('ctools/css');
    if (!file_check_directory($path)) {
      $path = file_directory_path() . '/ctools';
      file_check_directory($path, FILE_CREATE_DIRECTORY);
      $path .= '/css';
      file_check_directory($path, FILE_CREATE_DIRECTORY);
    }
    $requirements['ctools_css_cache'] = array(
      'title' => t('CTools CSS Cache'),
      'severity' => REQUIREMENT_OK,
      'value' => t('Exists'),
    );
    if (!file_check_directory($path)) {
      $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array(
        '%path' => $path,
      ));
      $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
      $requirements['ctools_css_cache']['value'] = t('Unable to create');
    }
    if (!function_exists('error_get_last')) {
      $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
      $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
      $requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
      $requirements['ctools_php_52']['value'] = t('PHP !version', array(
        '!version' => phpversion(),
      ));
    }
  }
  return $requirements;
}