You are here

function imagecache_customactions_form in ImageCache Actions 7

Same name and namespace in other branches
  1. 8 customactions/imagecache_customactions.module \imagecache_customactions_form()
  2. 6.2 customactions/imagecache_customactions.module \imagecache_customactions_form()
  3. 6 imagecache_customactions.module \imagecache_customactions_form()

Image effect form callback for the custom action effect.

Note that this is not a complete form, it only contains the portion of the form for configuring the effect options. Therefore it does not not need to include metadata about the effect, nor a submit button.

Parameters

array $data: The current configuration for this image effect.

Return value

array The form definition for this effect.

1 string reference to 'imagecache_customactions_form'
imagecache_customactions_image_effect_info in customactions/imagecache_customactions.module
Implements hook_image_effect_info().

File

customactions/imagecache_customactions.module, line 107
Allows advanced users to code their own PHP image manipulation routines as part of image style processing.

Code

function imagecache_customactions_form(array $data) {

  // Add defaults.
  $data += array(
    'php' => 'return TRUE;',
  );

  // Note: we also need to check for the existence of the module: admin has
  //   all rights, so user_acccess(...) returns TRUE even if the module is not
  //   enabled and the permission does not exist.
  $allow_php = module_exists('php') && user_access('use PHP for settings');
  $form = array(
    'php' => array(
      '#type' => 'textarea',
      '#rows' => 12,
      '#title' => t('PHP code'),
      '#default_value' => $data['php'],
      '#disabled' => !$allow_php,
      '#description' => t("<p>A piece of PHP code that modifies the image.\nIt should return a boolean indicating success or failure.\nYou will need the '%use_php' permission, defined by the 'PHP filter' module.\nSee the help for an extensive explanation of the possibilities.</p>", array(
        '%use_php' => t('Use PHP for settings'),
      )),
      '#wysiwyg' => FALSE,
    ),
  );
  return $form;
}