You are here

function textactions_rendertext_form in ImageCache Actions 6

Place text on top of the current canvas

Implementation of imagecache_hook_form()

Parameters

$action array of settings for this action:

Return value

a form definition

File

./textrender.inc, line 27
Helper functions for imagecache_textactions

Code

function textactions_rendertext_form($action) {
  $defaults = array(
    'xpos' => 'left+10',
    'ypos' => 'bottom-10',
    'textstyle' => array(
      'fontfile' => drupal_get_path('module', 'imageapi_text') . '/fonts/liberation-fonts-1.04/LiberationSans-Regular.ttf',
      'style' => "font-size:12px;\nfill:#333333;\ntop:10px;\nright:10px;",
    ),
    'text' => 'Hello World!',
    'evaluate_text' => FALSE,
  );

  // Our 'textstyle' parameter is a nested array - reflecting the wiget fieldset structure
  // only because imagecache sets the form
  // #tree to true, and unsetting it doesn't work.
  $action = array_merge($defaults, (array) $action);
  $form = array(
    'textstyle' => imageapi_text_style_widget($action['textstyle']),
    'text' => array(
      '#type' => 'textarea',
      '#rows' => 7,
      '#title' => t('Text'),
      '#default_value' => $action['text'],
      '#description' => t('The text string. If you are using a WYSIWYG editor, you should disable it for this field!'),
      '#wysiwyg' => FALSE,
    ),
    'evaluate_text' => array(
      '#type' => 'checkbox',
      '#title' => t('Evaluate text as PHP code'),
      '#default_value' => $action['evaluate_text'],
      '#description' => t('If selected, the text will be treated as PHP code.'),
    ),
    'php_help' => array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('PHP code help'),
      '#value' => file_get_contents(drupal_get_path('module', 'imagecache_text') . '/help/textrender_syntax.html'),
    ),
  );
  if (!user_access('administer site configuration')) {
    $form['evaluate_text']['#disabled'] = TRUE;
    $form['text']['#disabled'] = $action['evaluate_text'];

    // lock this if an admin has enabled evaluation.
    $form['evaluate_text']['#description'] = 'requires <b>administer site configuration</b> permissions.';
  }

  #$form['#tree'] = FALSE;

  #$form['textstyle']['#tree'] = FALSE;
  return $form;
}