You are here

function ctools_requirements in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 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') {
    $t = get_t();
    $requirements['ctools_css_cache'] = array(
      'title' => $t('CTools CSS Cache'),
      'severity' => REQUIREMENT_OK,
      'value' => $t('Exists'),
    );
    $path = 'public://ctools/css';
    if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
      $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' => file_uri_target($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;
}