? .cvsignore
? .str_vs_preg.php.swp
? str_vs_preg.php.txt
? working.patch
Index: imagecache_actions.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache_actions.inc,v
retrieving revision 1.23
diff -u -p -r1.23 imagecache_actions.inc
--- imagecache_actions.inc	3 May 2009 14:38:49 -0000	1.23
+++ imagecache_actions.inc	3 May 2009 17:26:53 -0000
@@ -33,7 +33,7 @@ function theme_imagecache_resize($elemen
 /**
  * ImageCache Scale
  */
-function imagecache_scale_form($data) {
+function imagecache_scale_form($data = array()) {
   $form = imagecache_resize_form($data);
   $form['upscale'] = array(
     '#type' => 'checkbox',
@@ -65,7 +65,7 @@ function imagecache_scale_image(&$image,
 /**
  * ImageCache Scale and Crop
  */
-function imagecache_scale_and_crop_form($data) {
+function imagecache_scale_and_crop_form($data = array()) {
   return imagecache_resize_form($data);
 }
 
@@ -88,7 +88,7 @@ function imagecache_scale_and_crop_image
  * ImageCache Deprecated Scale.
  * This will be removed in imagecache 2.1
  */
-function imagecache_deprecated_scale_form($data) {
+function imagecache_deprecated_scale_form($data = array()) {
   $helptext = array();
   $helptext['inside'] = t('<strong>Inside dimensions</strong>: Final dimensions will be less than or equal to the entered width and height. Useful for ensuring a maximum height and/or width.');
   $helptext['outside'] = t('<strong>Outside dimensions</strong>: Final dimensions will be greater than or equal to the entered width and height. Ideal for cropping the result to a square.');
@@ -145,7 +145,7 @@ function imagecache_deprecated_scale_ima
 /**
  * ImageCache Crop
  */
-function imagecache_crop_form($data) {
+function imagecache_crop_form($data = array()) {
   $data += array(
     'width' => '',
     'height' => '',
@@ -196,7 +196,7 @@ function imagecache_crop_image(&$image, 
 /**
  * ImageCache Desaturate
  */
-function imagecache_desaturate_form($data) {
+function imagecache_desaturate_form($data = array()) {
   return array();
 }
 
@@ -218,7 +218,7 @@ function imagecache_desaturate_image(&$i
 /**
  * ImageCache Rotate
  */
-function imagecache_rotate_form($data) {
+function imagecache_rotate_form($data = array()) {
   $form['degrees'] = array(
     '#type' => 'textfield',
     '#default_value' => (isset($data['degrees'])) ? $data['degrees'] : 0,
Index: imagecache_ui.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache_ui.pages.inc,v
retrieving revision 1.5
diff -u -p -r1.5 imagecache_ui.pages.inc
--- imagecache_ui.pages.inc	3 May 2009 16:31:43 -0000	1.5
+++ imagecache_ui.pages.inc	3 May 2009 17:26:53 -0000
@@ -351,51 +351,76 @@ function theme_imagecache_ui_preset_acti
 }
 
 
-function imagecache_ui_action_form($form_state, $preset, $action) {
-  $definitions = imagecache_action_definitions();
-
-  if (empty($action)) {
-    drupal_set_message(t('Unknown Action.'), 'error');
-    drupal_goto('admin/build/imagecache');
+/**
+ * Page with form for adding a new action to add to a preset.
+ */
+function imagecache_ui_action_add_page($preset, $actionname) {
+  // Make sure the name is valid.
+  if (!$definition = imagecache_action_definition($actionname)) {
+    drupal_set_message(t('Unknown action.'), 'error');
+    drupal_goto('admin/build/imagecache/'. $preset['presetid']);
   }
+  $action = array(
+    'presetid' => $preset['presetid'],
+    'action' => $actionname,
+    'data' => array(),
+  );
+  return drupal_get_form('imagecache_ui_action_form', $preset, $action);
+}
 
-  if (empty($preset)) {
-    drupal_set_message(t('Unknown Preset.'), 'error');
+
+function imagecache_ui_action_form($form_state, $preset, $action) {
+  // Do some error checking.
+  if (empty($preset['presetid'])) {
+    drupal_set_message(t('Unknown preset.'), 'error');
     drupal_goto('admin/build/imagecache');
   }
+  if (empty($action['action']) || !$definition = imagecache_action_definition($action['action'])) {
+    drupal_set_message(t('Unknown action.'), 'error');
+    drupal_goto('admin/build/imagecache/'. $preset['presetid']);
+  }
+  if ($action['presetid'] != $preset['presetid']) {
+    drupal_set_message(t('This %action action is not associated %preset preset.', array('%action' => $action['action'], '%preset' => $preset['presetname'])), 'error');
+    drupal_goto('admin/build/imagecache/'. $preset['presetid']);
+  }
 
-  $form = array(
-    '#tree' => TRUE,
+  $form['#tree'] = TRUE;
+  $form['presetid'] = array(
+    '#type' => 'value',
+    '#value' => $action['presetid'],
   );
-
   $form['actionid'] = array(
     '#type' => 'value',
     '#value' => $action['actionid'],
   );
+  $form['action'] = array(
+    '#type' => 'value',
+    '#value' => $action['action'],
+  );
 
-
-  if (!empty($definitions[$action['action']]['file'])) {
-    require_once($definitions[$action['action']]['file']);
+  if (!empty($definition['file'])) {
+    require_once($definition['file']);
   }
-  $form['data'] = call_user_func($action['action'] .'_form', $action['data']);
+  if (function_exists($action['action'] .'_form')) {
+    $form['data'] = call_user_func($action['action'] .'_form', $action['data']);
+  }
+
   $form['submit'] = array(
     '#type' => 'submit',
-    '#value' => t('Update Action'),
+    '#value' => empty($action['actionid']) ? t('Create Action') : t('Update Action'),
   );
   return $form;
 }
 
 function imagecache_ui_action_form_submit($form, &$form_state) {
-  if ($action = imagecache_action($form_state['values']['actionid'])) {
-    $action = array_merge($action, $form_state['values']);
-    imagecache_action_save($action);
-    drupal_set_message(t('The action was succesfully updated.'));
-    $form_state['redirect'] = 'admin/build/imagecache/'. $action['presetid'];
+  imagecache_action_save($form_state['values']);
+  if (empty($form_state['values']['presetid'])) {
+    drupal_set_message(t('The action was succesfully created.'));
   }
   else {
-    drupal_set_message(t('Unknown Action: @action_id', array('@action_id' => $form_state['values']['actionid'])));
-    $form_state['redirect'] = 'admin/build/imagecache';
+    drupal_set_message(t('The action was succesfully updated.'));
   }
+  $form_state['redirect'] = 'admin/build/imagecache/'. $form_state['values']['presetid'];
 }
 
 
@@ -428,14 +453,3 @@ function imagecache_ui_action_delete_for
   drupal_set_message(t('The action has been deleted.'));
   $form_state['redirect'] = 'admin/build/imagecache/'. $action['presetid'];
 }
-
-/**
- * Create a new action object to add to a preset.
- */
-function imagecache_ui_action_add_page($preset, $actionname) {
-  $action = array(
-    'presetid' => $preset['presetid'],
-    'action' => $actionname,
-  );
-  return drupal_get_form('imagecache_ui_action_form', $preset, $action);
-}
