You are here

function imagecache_admin_submit in ImageCache 5

File

./imagecache.module, line 448
Dynamic image resizer and image cacher.

Code

function imagecache_admin_submit($form_id, $form_values) {
  if (is_array($_POST['preset-op'])) {
    foreach ($_POST['preset-op'] as $presetid => $op) {
      $presetid = check_plain($presetid);
      switch ($op) {
        case t('Create preset'):
          _imagecache_preset_create($form_values['presets']['new']['name']);
          break;
        case t('Update preset'):

          // Add new actions
          $newaction = $form_values['presets'][$presetid]['handlers']['newaction'];
          if ($newaction) {
            $action = array();
            $action['data'] = array(
              'function' => $newaction,
            );
            $action['presetid'] = $presetid;
            $action['weight'] = 0;
            _imagecache_action_create($action);
          }

          // Update existing actions
          foreach ($form_values['presets'][$presetid]['handlers'] as $actionid => $action) {
            if ($actionid != 'newaction') {
              $action['actionid'] = $actionid;
              $action['presetid'] = $presetid;
              $remove = $action['remove'];
              unset($action['remove']);
              $remove ? _imagecache_action_delete($action) : _imagecache_action_update($action);
            }
          }

          // Update the entire preset.
          _imagecache_preset_update($presetid, $form_values['presets'][$presetid]['name']);
          break;
        case t('Delete preset'):
          _imagecache_preset_delete($presetid, $form_values['presets'][$presetid]['name']);
          break;
        case t('Flush preset images'):
          _imagecache_preset_flush($presetid);
          break;
      }
    }
  }
}