You are here

function imageapi_settings in ImageAPI 5

Same name and namespace in other branches
  1. 6 imageapi.module \imageapi_settings()
1 string reference to 'imageapi_settings'
imageapi_menu in ./imageapi.module
Implementation of hook_menu().

File

./imageapi.module, line 67
An ImageAPI supporting mulitple image toolkits. Image toolkits are implemented as modules. Images are objects, but have no methods

Code

function imageapi_settings() {
  $form = array();
  $toolkits = imageapi_get_available_toolkits();
  switch (count($toolkits)) {
    case 0:
      $form['imageapi_toolkits']['#value'] = t('There are no image toolkit modules enabled. Toolkit modules can be enabled from the <a href="!admin-build-modules">module configuration page</a>.', array(
        '!admin-build-modules' => url('admin/build/modules'),
      ));
      return $form;
    case 1:
      $toolkit = key($toolkits);

      // The variable needs to be manually set. Otherwise, if a user has two
      // toolkits and disables the selected one they won't be able to select the
      // remaing toolkit.
      variable_set('imageapi_image_toolkit', $toolkit);
      $form['imageapi_image_toolkit']['#value'] = t('The %toolkit module is the only enabled image toolkit. Drupal will use it for resizing, cropping and other image manipulations.', array(
        '%toolkit' => $toolkits[$toolkit]['name'],
      ));
      return $form;
    default:
      $options = array();
      foreach ($toolkits as $module => $info) {
        $options[$module] = $info['name'];
      }
      $form['imageapi_image_toolkit'] = array(
        '#type' => 'radios',
        '#title' => t('Select a default image processing toolkit'),
        '#default_value' => imageapi_default_toolkit(),
        '#options' => $options,
        '#description' => t('This setting lets you choose which toolkit Drupal uses resizing, cropping and other image manipulations.'),
      );
  }
  return system_settings_form($form);
}