You are here

function textimage_requirements in Textimage 7.3

Same name and namespace in other branches
  1. 5.2 textimage.install \textimage_requirements()
  2. 6.2 textimage.install \textimage_requirements()
  3. 7.2 textimage.install \textimage_requirements()

Implements hook_requirements().

File

./textimage.install, line 10
Textimage - Installation scripts.

Code

function textimage_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();

  // Check a private wrapper exists and is writeable.
  $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
  if (!isset($wrappers['private'])) {
    $requirements['textimage_private_wrapper'] = array(
      'title' => $t('Private file wrapper'),
      'value' => $t('Undefined'),
      'severity' => REQUIREMENT_ERROR,
      'description' => $t('Textimage requires access to a private area for file storage. Ensure that a path is specified for "Private file system path" visiting the <a href="@url">File system</a> configuration page, or, alternatively, that a "private" writeable stream wrapper is defined elsewhere.', array(
        '@url' => url('admin/config/media/file-system'),
      )),
    );
  }

  // Check PHP GD2 library enabled and providing FreeType support.
  $requirements['textimage_gd']['title'] = $t('GD library FreeType support');
  if (function_exists('imagegd2')) {
    $info = gd_info();
    $requirements['textimage_gd']['value'] = $info['GD Version'];

    // Check for FreeType support.
    if (function_exists('imagettftext') && $info["FreeType Support"]) {
      $requirements['textimage_gd']['severity'] = REQUIREMENT_OK;
    }
    else {

      // No FreeType support, raise error.
      $requirements['textimage_gd']['severity'] = REQUIREMENT_ERROR;
      $requirements['textimage_gd']['description'] = $t('The GD Library for PHP is enabled, but was compiled without FreeType support. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="http://www.php.net/manual/book.image.php">the PHP manual</a>.');
    }
  }
  else {

    // No GD2, raise error.
    $requirements['textimage_gd']['value'] = $t('Not installed');
    $requirements['textimage_gd']['severity'] = REQUIREMENT_ERROR;
    $requirements['textimage_gd']['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',
    ));
  }

  // Check Clean URLs are set on.
  if (!variable_get('clean_url', FALSE)) {
    $requirements['textimage_clean_url'] = array(
      'title' => $t('Clean URLs'),
      'value' => $t('Disabled'),
      'severity' => REQUIREMENT_WARNING,
      'description' => $t('Textimage requires Clean URLs to be set on to provide URL-based generation of text images. Visit the <a href="@url">Clean URLs</a> configuration page to set up.', array(
        '@url' => url('admin/config/search/clean-urls'),
      )),
    );
  }
  return $requirements;
}