Index: CHANGELOG.txt
===================================================================
--- CHANGELOG.txt	(revision 4305)
+++ CHANGELOG.txt	(working copy)
@@ -1,5 +1,15 @@
-$Id: CHANGELOG.txt,v 1.1.2.1 2010/07/27 15:10:08 yvmarques Exp $
+$Id: CHANGELOG.txt,v 1.1.2.2 2010/08/26 08:28:52 yvmarques Exp $
 
+EPSA Crop 6.x-1.0, 2010-08-09
+-----------------------------
+Fixed by mrfelton, dboulet: Compatibility with jQuery 1.3
+Added creation of thumbs for cropping
+Fixed #837014 by pelicani: The Init function limits user profiles.
+Fixed #822678 by Odd Hill: Failed to load resource: unsupported URL.
+Added #725310 by mrfelton: Add support Libraries for Jcrop
+Added #859870 by mathieu: Add action crops on URL call instead of theme function
+Added #793722 by pkej, yan_nick: Support for rounded corners and all other modules wich interact with imagecache
+
 EPSA Crop 6.x-0.1-beta2, 2010-02-24
 -----------------------------------
 Fixed #665242 by valic: Multilingual site
Index: epsacrop.info
===================================================================
--- epsacrop.info	(revision 4305)
+++ epsacrop.info	(working copy)
@@ -7,9 +7,9 @@
 dependencies[] = imagefield
 dependencies[] = imagecache
 
-; Information added by drupal.org packaging script on 2010-08-09
-version = "6.x-1.0"
+; Information added by drupal.org packaging script on 2010-08-26
+version = "6.x-1.x-dev"
 core = "6.x"
 project = "epsacrop"
-datestamp = "1281343275"
+datestamp = "1282824466"
 
Index: epsacrop.module
===================================================================
--- epsacrop.module	(revision 4305)
+++ epsacrop.module	(working copy)
@@ -1,5 +1,5 @@
 <?php
-// $Id: epsacrop.module,v 1.2.2.2 2010/07/27 15:10:08 yvmarques Exp $
+// $Id: epsacrop.module,v 1.2.2.4 2010/08/26 08:42:24 yvmarques Exp $
 /**
  * @file
  * The main file of module
@@ -33,9 +33,10 @@
  */
 function epsacrop_menu() {
   $items = array();
-  $items['crop/dialog'] = array(
+  $items['crop/dialog/%/%'] = array(
     'title' => 'Dialog Crop',
     'page callback' => 'epsacrop_dialog',
+    'page arguments' => array(2, 3),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK
   );
@@ -72,9 +73,14 @@
 
 /**
  * Callback function for Dialog popup.
+ *
+ * @param string $type_name
+ *   Content type machine name, e.g. 'page'.
+ * @param string $field_name
+ *   CCK imagefield name, e.g. 'field_image'.
  * 
  */
-function epsacrop_dialog() {
+function epsacrop_dialog($type_name, $field_name) {
   $args = func_get_args();
   $out ='<div class="epsacrop-global">'."\n";
   $out .='<div class="epsacrop-image-crop">'."\n";
@@ -82,11 +88,10 @@
   $out .='</div>'."\n";
   $out .='<div class="epsacrop-presets-menu">'."\n";
   $out .='<ul class="epsacrop-presers-menu-ul">'."\n";
-  $query = db_query("SELECT p.presetname, a.data FROM {imagecache_action} a RIGHT JOIN {imagecache_preset} p ON p.presetid = a.presetid WHERE a.action LIKE '%crop';");
   $i = 0;
-  while ($res = db_fetch_array($query)) {
-    $data = unserialize($res['data']);
-    $out .='<li class="epsacrop-presers-menu-li"><a href="javascript:EPSACrop.crop(\''. $data['width'] .'x'. $data['height'] .'\');" rel="'. $data['width'] .'x'. $data['height'] .'"'. ($i == 0 ? ' class="selected"' : '') .'>'. $res['presetname'] .'</a></li>';
+  $crop_actions = _epsacrop_get_field_actions($type_name, $field_name);
+  foreach ($crop_actions as $action) {
+    $out .='<li class="epsacrop-presers-menu-li"><a href="javascript:EPSACrop.crop(\''. $action['width'] .'x'. $action['height'] .'\');" rel="'. $action['width'] .'x'. $action['height'] .'"'. ($i == 0 ? ' class="selected"' : '') .'>'. $action['presetname'] .'</a></li>';
     $i++; 
   }
   $out .='</ul>'."\n";
@@ -314,6 +319,8 @@
  */
 function theme_epsacrop_widget_item($element) {
   if ((int) $element['fid']['#value'] > 0) {
+    $type_name = $element['#type_name'];
+    $field_name = $element['#field_name'];
     $fid = (int) $element['fid']['#value'];
     $filepath = _epsacrop_get_path_from_fid($fid);
     if (!empty($filepath)) {
@@ -322,7 +329,7 @@
       $filepath = _epsacrop_thumb_filepath($filepath);
       $element['epsacrop'] = array(
         '#type' => 'markup',
-        '#value' => '[<a rel="nozoom" href="javascript:EPSACrop.dialog(\''. $element['fid']['#value'] .'\', \''. $base_root . base_path() . $filepath .'\', ['. $info[0] .', '. $info[1] .']);">'. t("Manage image crops") .'</a>]'
+        '#value' => '[<a rel="nozoom" href="javascript:EPSACrop.dialog(\''. $type_name .'\', \''. $field_name .'\', \''. $element['fid']['#value'] .'\', \''. $base_root . base_path() . addslashes($filepath) .'\', ['. $info[0] .', '. $info[1] .']);">'. t("Manage image crops") .'</a>]'
       );
     }
   }
@@ -457,3 +464,102 @@
   header("HTTP/1.0 500 Internal Server Error");
   exit;
 }
+
+/**
+ *Helper function for returning only imagecache preset actions with croping.
+ */
+function _epsacrop_get_crop_actions() {
+  $actions = array();
+
+  $presets = imagecache_presets();
+  foreach ($presets as $preset) {
+    foreach($preset['actions'] as $action) {
+      if (strpos($action['action'], 'crop') !== FALSE) {
+        $actions[] = array('presetname' => $preset['presetname'], 'width' => $action['data']['width'], 'height' => $action['data']['height']);
+      }
+    }
+  }
+
+  return $actions;
+}
+
+/**
+ *Helper function for returning simple array with only imagecache preset actions with croping.
+ */
+function _epsacrop_get_crop_presets() {
+  $actions = _epsacrop_get_crop_actions();
+  $presets =  array();
+  foreach ($actions as $preset) {
+    $presets[$preset['presetname']] = $preset['presetname'];
+  }
+
+  return $presets;
+}
+
+
+/**
+ * Helper function for returning only imagecache preset actions with croping that was enabled for specific field.
+ *
+ * @param string $type_name
+ *   Content type machine name, e.g. 'page'.
+ * @param string $field_name
+ *   CCK imagefield name, e.g. 'field_image'.
+ *
+ * @return Structured array, e.g.:
+ *   array(
+ *      0 => array(
+ *        'presetname' => 'presetname',
+ *        'width'      => 400,
+ *        'height'     => 300,
+ *      ),
+ *      1 => ...
+ *   )
+ */
+function _epsacrop_get_field_actions($type_name, $field_name) {
+  $actions = _epsacrop_get_crop_actions();
+  $content_type = content_types($type_name);
+  $presets = $content_type['fields'][$field_name]['widget']['epsacrop_presets'];
+  $presets = array_flip($presets);
+  foreach ($actions as $key => $action) {
+    if (!array_key_exists($action['presetname'], $presets)) {
+      unset($actions[$key]);
+    }
+  }
+  return $actions;
+}
+
+/**
+ * Implementation of hook_widget_settings_alter().
+ */
+function epsacrop_widget_settings_alter(&$settings, $op, $widget) {
+  $widget_type = isset($widget['widget_type']) ? $widget['widget_type'] : $widget['type'];
+  // Alter only imagefied_widget
+  if ($widget_type != 'imagefield_widget') {
+    return;
+  }
+
+  // Add our new options to the list of settings to be saved.
+  if ($op == 'save') {
+    $settings = array_merge($settings, array('epsacrop_presets'));
+  }
+
+  // Add the additional settings to the form.
+  $presets = _epsacrop_get_crop_presets(); 
+  if ($op == 'form') {
+    $settings['epsacrop'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('EPSA Crop'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#description' => t('These options allow the user to pick imagecache presets that would be available to crop.'),
+      '#weight' => 15,
+    );
+    $settings['epsacrop']['epsacrop_presets'] = array(
+      '#title' => t('Imagecache presets'),
+      '#type' => 'checkboxes',
+      '#default_value' => $widget['epsacrop_presets'],
+      '#options' => $presets,
+      '#description' => t('Only presets utilising crop filter are available'),
+    );
+  }
+}
Index: js/epsacrop.js
===================================================================
--- js/epsacrop.js	(revision 4305)
+++ js/epsacrop.js	(working copy)
@@ -4,7 +4,7 @@
  delta: null,
  presets: {},
  init: false,
- dialog: function(delta, img, trueSize) {
+ dialog: function(type_name, field_name, delta, img, trueSize) {
     $('body').find('#EPSACropDialog').remove().end().append('<div title="Cropping Image" id="EPSACropDialog"><img src="'+Drupal.settings.epsacrop.base+Drupal.settings.epsacrop.path+'/img/loading.gif" /></div>');
     $('#EPSACropDialog').dialog({
        bgiframe: true,
@@ -31,7 +31,7 @@
        close: function() {
           $('#EPSACropDialog').remove();
        }
-    }).load(Drupal.settings.epsacrop.base+'?q=crop/dialog', function(){
+    }).load(Drupal.settings.epsacrop.base+'?q=crop/dialog/' + type_name + '/' + field_name, function(){
        try{
 	       var preset = $('.epsacrop-presets-menu a[class=selected]').attr('rel'); 
 	       var coords = preset.split('x');
