You are here

function imagecrop_settings in Image javascript crop 6

Same name and namespace in other branches
  1. 5 imagecrop.module \imagecrop_settings()

Imagecrop settings page

1 string reference to 'imagecrop_settings'
imagecrop_menu in ./imagecrop.module
Implementation of hook_menu().

File

./imagecrop.admin.inc, line 14
Administration functions for Imagecrop

Code

function imagecrop_settings() {

  // hook into image module
  if (module_exists('image')) {
    $options_modules['image'] = t('Hook into image module');
  }

  // hook into taxonomy_image module
  if (module_exists('taxonomy_image')) {
    $options_modules['taxonomy_image'] = t('Hook into taxonomy image module');
  }
  if (variable_get('user_pictures', 0)) {
    $options_modules['profile_picture'] = t('Hook into profile picture');
  }

  // hook into node_images module
  if (module_exists('node_images')) {
    $result = db_query("SELECT name,value FROM {variable} WHERE name LIKE 'node_images_position_%'");
    if ($result) {
      drupal_set_message(t('When you want to enable support for the node_images module, please read the README that comes with the imagecrop module.'));
      while ($row = db_fetch_object($result)) {
        if (variable_get($row->name, 'hide') != 'hide') {
          $explode = explode('_', $row->name);
          $options_modules[$row->name] = t('Hook into node_images module for <em>content type @type</em>', array(
            '@type' => $explode[3],
          ));
        }
      }
    }
  }

  // show checkboxes if options are not empty
  if (!empty($options_modules)) {
    $form['imagecrop_modules'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Hook into modules'),
      '#default_value' => variable_get('imagecrop_modules', array()),
      '#options' => $options_modules,
    );
    $form['array_filter'] = array(
      '#type' => 'hidden',
    );
  }
  else {
    $form['no_modules_fields'] = array(
      '#type' => 'item',
      '#value' => t('No supported modules were found to hook into.'),
    );
  }
  if (module_exists('imagefield')) {
    $form['imagefield'] = array(
      '#type' => 'item',
      '#value' => t('Imagecrop settings for CCK Imagefields are found on the field configuration pages.'),
    );
  }
  $all_popups = array(
    'basic' => t('Basic popup window'),
  );
  foreach (module_implements('imagecrop_popups') as $module_name) {
    $function = $module_name . '_imagecrop_popups';
    $popups = $function();
    if (is_array($popups)) {
      $all_popups += $popups;
    }
  }
  $form['imagecrop_popup'] = array(
    '#type' => 'radios',
    '#title' => t('Popup window type'),
    '#default_value' => variable_get('imagecrop_popup', 'basic'),
    '#options' => $all_popups,
  );
  $form['imagecrop_popup_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Popup window width'),
    '#default_value' => variable_get('imagecrop_popup_width', 700),
    '#size' => 4,
    '#field_suffix' => 'pixels',
  );
  $form['imagecrop_popup_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Popup window height'),
    '#default_value' => variable_get('imagecrop_popup_height', 600),
    '#size' => 4,
    '#field_suffix' => 'pixels',
  );
  $form['imagecrop_scale_step'] = array(
    '#type' => 'textfield',
    '#title' => t('Step size for scale dropdown'),
    '#default_value' => variable_get('imagecrop_scale_step', 50),
    '#size' => 4,
    '#field_suffix' => 'pixels',
    '#description' => t('Setting the step to 0, will hide the dropdown'),
  );

  // drupal message if no action is found with javascript_crop
  if (count(imagecrop_presets_list()) == 0) {
    drupal_set_message(t('No preset is found with the javascript_crop action so far. If you want to take advantage of this module, you will need to create at least one preset with that action.'));
  }
  return system_settings_form($form);
}