You are here

function textimage_settings_form in Textimage 5

Same name and namespace in other branches
  1. 5.2 textimage_admin.inc \textimage_settings_form()
  2. 6.2 textimage_admin.inc \textimage_settings_form()
  3. 7.2 textimage.admin.inc \textimage_settings_form()
1 string reference to 'textimage_settings_form'
textimage_menu in ./textimage.module
Implementation of hook_menu().

File

./textimage.module, line 181

Code

function textimage_settings_form() {
  $form = array();
  $fonts_path = variable_get("textimage_fonts_path", "");
  $images_path = variable_get("textimage_images_path", "");

  //check for GD
  if (!function_exists(imagecreate)) {
    drupal_set_message(t('Image library not available. Textimage needs the GD library extension to be installed. Please install GD.'), 'error');
  }

  //check for TTF support
  if (!function_exists(imagettftext)) {
    drupal_set_message(t('Your image library does not seem to have TrueType font support. Textimage will work, but will use the default inbuilt font.'), 'error');
  }

  //check for clean URL support
  if (!variable_get('clean_url', false)) {
    drupal_set_message(t('Textimage requires <a href="!path">clean URLs</a> be enabled. Without clean URL support Textimage is unable to cache images and can cause serious performance problems.', array(
      '!path' => url('admin/settings/clean-urls'),
    )), 'error');
  }

  //check for valid font path
  if ($fonts_path != '' && !is_dir(rtrim($fonts_path, '\\/'))) {
    drupal_set_message(t('The current font path is invalid. The default font will be used.'), 'error');
  }

  //check for valid image path
  if ($images_path != '' && !is_dir(rtrim($images_path, '\\/'))) {
    drupal_set_message(t('The current images path is invalid. No images will be used.'), 'error');
  }
  if (isset($fonts_path)) {
    $imagefontinfo .= t('Number of fonts found: ') . count(_textimage_font_list($fonts_path));
  }
  if (isset($images_path)) {
    $imagefontinfo .= '<br />' . t('Number of background images found: ') . count(_textimage_image_list($images_path));
  }
  $gdinfo = gd_info();
  $imagefontinfo .= '<br />' . t('GD Version: ') . $gdinfo["GD Version"];
  $imagefontinfo .= '<br />' . t(' FreeType Support: ');
  $imagefontinfo .= $gdinfo["FreeType Support"] == true ? t('True') : t('False');
  $imagefontinfo .= '<br />';
  if (!$gdinfo["FreeType Support"]) {
    drupal_set_message(t("This server's installation of GD does not have FreeType support. Textimage requires FreeType support for proper functionality."), 'error');
  }
  $form['info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Image and font information'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['info']['textimage_info'] = array(
    '#type' => 'item',
    '#value' => $imagefontinfo,
  );

  //Fonts settings
  $form['settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Text image settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['settings']['textimage_fonts_path'] = array(
    '#type' => 'textfield',
    '#title' => t('TrueType Fonts Path'),
    '#default_value' => $fonts_path,
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('Location of the directory where the Truetype (.ttf) fonts are stored. If you do not provide any fonts, the module will use the default font for text. Relative paths will be resolved relative to the Drupal installation directory.'),
  );
  $form['settings']['textimage_images_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Background Image Path'),
    '#default_value' => $images_path,
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('Location of the directory where the background images are stored. Images in this directory can be overlaid with dynamic text in a preset. Relative paths will be resolved relative to the Drupal installation directory.'),
  );
  return system_settings_form($form);
}