function textactions_text2canvas_form in ImageCache Actions 5.2
Same name and namespace in other branches
- 5.3 textactions.inc \textactions_text2canvas_form()
- 6 textactions.inc \textactions_text2canvas_form()
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
- ./
textactions.inc, line 26
Code
function textactions_text2canvas_form($action) {
$defaults = array(
'size' => 12,
'angle' => 0,
'xpos' => 'left-10',
'ypos' => 'bottom-10',
'RGB' => array(
'red' => 51,
'green' => 51,
'blue' => 51,
'HEX' => '#333333',
),
'fontfile' => 'MgOpenModernaBold.ttf',
'text' => 'Hello World!',
);
$action = array_merge($defaults, (array) $action);
$form = array(
'size' => array(
'#type' => 'textfield',
'#title' => t('Size'),
'#default_value' => $action['size'],
'#description' => t('Size: The font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2).'),
'#size' => 3,
),
'angle' => array(
'#type' => 'textfield',
'#title' => t('Angle'),
'#default_value' => $action['angle'],
'#description' => t('Angle: The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.'),
'#size' => 3,
),
'alpha' => array(
'#type' => 'textfield',
'#title' => t('Opacity'),
'#default_value' => $action['alpha'] ? $action['alpha'] : 100,
'#size' => 3,
'#description' => t('Opacity: 1-100.'),
),
'xpos' => array(
'#type' => 'textfield',
'#title' => t('X offset'),
'#default_value' => $action['xpos'],
'#description' => t('Enter an offset in pixels or use a keyword: <em>left</em>, <em>center</em>, or <em>right</em>. Syntax like <em>right-20</em> is also valid.'),
'#size' => 10,
),
'ypos' => array(
'#type' => 'textfield',
'#title' => t('Y offset'),
'#default_value' => $action['ypos'],
'#description' => t('Enter an offset in pixels or use a keyword: <em>top</em>, <em>center</em>, or <em>bottom</em>. Syntax like <em>bottom-20</em> is also valid.'),
'#size' => 10,
),
'RGB' => imagecache_rgb_form($action['RGB']),
'fontfile' => array(
'#type' => 'textfield',
'#title' => t('Font file name'),
'#default_value' => $action['fontfile'],
'#description' => t('Font file is either the full system path (eg <code>/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf</code>), a font file inside the in the module dir "%moduledir" or the files "%filedir" folder). Example: "arial.ttf". You <em>might</em> find a list of fonts available at !helplink if your system supports it.', array(
'%moduledir' => drupal_get_path('module', 'imagecache_textactions'),
'%filedir' => file_directory_path(),
'!helplink' => l('fonts help', 'admin/help/imagecache_textactions'),
)),
),
'text' => array(
'#type' => 'textarea',
'#rows' => 7,
'#title' => t('Text'),
'#default_value' => $action['text'],
'#description' => t('The text string.'),
),
'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.
<p>Enter PHP code that will <b>return</b> your dynamic text. Do not use %php tags.
<br />EG <code>return format_date(time());</code>
</p><p>Note that executing incorrect PHP-code can break your Drupal site.
</p><p>You can access the $caption array which contains:<br />
<b>$caption[\'path\']</b> Name of file, e.g. image.jpg<br />
<!--
If the image is a cck imagefield, you will also have access to:<br />
<b>$caption[\'title\']</b> optional imagefield \'title\' text<br />
<b>$caption[\'alt\']</b> optional imagefield \'alt\' text<br />
<b>$caption[\'node\']</b> the complete node variable that the image is attached to.
-->
</p>', array(
'%php' => '<?php ?>',
)),
),
);
#$form['#validate'][] = 'textactions_text2canvas_validate';
return $form;
}