diff -up ../imceimage-orig/imceimage.js ./imceimage.js
--- ../imceimage-orig/imceimage.js	2008-04-09 14:59:57.000000000 -0400
+++ ./imceimage.js	2009-07-06 12:00:52.000000000 -0400
@@ -11,7 +11,7 @@ imceImage.open = function (url, field) {
    imceImage.target = field;
    imceImage.pop = window.open(url, '', 'width=760,height=560,resizable=1');
    imceImage.pop['imceOnLoad'] = function (win) {
-      win.imce.setSendTo(Drupal.t('Add image to @app', {'@app': Drupal.t('imceimage')}), imceImage.insert);
+      win.imce.setSendTo(Drupal.t('Use this file'), imceImage.insert);
    }
 
    imceImage.pop.focus();
@@ -22,21 +22,72 @@ imceImage.insert = function (file, win) 
 	
 	fld = imceImage.target;
 	var img = '#imceimagearea-' + fld;
-	$(img).attr('src', file.url);
-	$(img).attr('width', file.width);
-	$(img).attr('height', file.height);
-
-	/* form elements here. */
-	$('#imceimagepath-' + fld).val(file.url);
-	$('#imceimagewidth-' + fld).val(file.width);
-	$('#imceimageheight-' + fld).val(file.height);
+	var generic = '#imcegenericarea-' + fld;
+	var actions = '#imceimage-actions-' + fld;
+	
+	var browse_url = Drupal.settings.basePath + 'imce/browse';
+	var browse_js = "javascript:imceImage.open('" + browse_url + "', '" + fld + "')";
+	var remove_js = "javascript:imceImage.remove('" + fld + "')";
+
+  var change_img_action = '[<a href="' + browse_js + '" class="imceimage-add">' + Drupal.t('Change Image') + '</a>]';
+  var remove_img_action = '[<a href="' + remove_js + '" class="imceimage-remove">' + Drupal.t('Remove Image') + '</a>]';
+
+  var change_file_action = '[<a href="' + browse_js + '" class="imceimage-add">' + Drupal.t('Change File') + '</a>]';
+  var remove_file_action = '[<a href="' + remove_js + '" class="imceimage-remove">' + Drupal.t('Remove File') + '</a>]';
+	
+	//depending on the widget used, either img or generic will exist
+	if ($(img).length > 0) {
+	  //img exists - fill in form elements related to an image file
+  	$(img).attr('src', file.url);
+  	$(img).attr('width', file.width);
+  	$(img).attr('height', file.height);
+  	
+  	//replace "Add Image" with "Change Image" and "Remove Image" actions
+  	$(actions).html(change_img_action + remove_img_action);
+  
+  	/* form elements here. */
+  	$('#imceimagepath-' + fld).val(file.url);
+  	$('#imceimagewidth-' + fld).val(file.width);
+  	$('#imceimageheight-' + fld).val(file.height);
+	} else if ($(generic).length > 0) {
+	  //generic exists - fill in form elements related to a generic file
+	  $(generic).attr('style','visibility: visible;');
+	  $(generic + ' a.imcegeneric-filename').text(file.name).attr('href', file.url);
+	  $('#imceimagepath-' + fld).val(file.url);
+	  
+    //replace "Add File" with "Change File" and "Remove File" actions
+    $(actions).html(change_file_action + remove_file_action);
+	}
 }
 
 
 imceImage.remove = function(fld) {
-	$('#imceimagepath-' + fld).val('');
-	$('#imceimagewidth-' + fld).val(0);
-	$('#imceimageheight-' + fld).val(0);
-	$('#imceimagearea-' + fld).attr('src', 'blank.jpg');
+  //depending on the widget used, either img or generic will exist
+  var img = '#imceimagearea-' + fld;
+  var generic = '#imcegenericarea-' + fld;
+  var actions = '#imceimage-actions-' + fld;
+  
+  var browse_url = Drupal.settings.basePath + 'imce/browse';
+  var browse_js = "javascript:imceImage.open('" + browse_url + "', '" + fld + "')";
+
+  var add_img_action = '[<a href="' + browse_js + '" class="imceimage-add">' + Drupal.t('Add Image') + '</a>]';
+  var add_file_action = '[<a href="' + browse_js + '" class="imceimage-add">' + Drupal.t('Add File') + '</a>]';
+
+  if ($(img).length > 0) {
+  	$('#imceimagepath-' + fld).val('');
+  	$('#imceimagewidth-' + fld).val(0);
+  	$('#imceimageheight-' + fld).val(0);
+  	$('#imceimagearea-' + fld).attr('src', 'blank.jpg');
+  	
+  	//Replace change/remove with add
+  	$(actions).html(add_img_action);
+  } else if ($(generic).length > 0) {
+    $('#imceimagepath-' + fld).val('');
+    $(generic).attr('style','visibility: hidden;');
+    $(generic + ' a.imcegeneric-filename').text('').attr('href', '');
+    
+    //Replace change/remove with add
+    $(actions).html(add_file_action);
+  }
 }
 
diff -up ../imceimage-orig/imceimage.module ./imceimage.module
--- ../imceimage-orig/imceimage.module	2009-03-27 13:30:14.000000000 -0400
+++ ./imceimage.module	2009-07-06 15:00:39.000000000 -0400
@@ -164,6 +164,14 @@ function imceimage_widget_info() {
           'default value' => CONTENT_CALLBACK_DEFAULT,
       ),
     ),
+    'imceimage_generic' => array(
+      'label' => 'IMCE Generic File',
+      'field types' => array('imceimage'),
+      'multiple values' => CONTENT_HANDLE_CORE,
+      'callbacks' => array(
+          'default value' => CONTENT_CALLBACK_DEFAULT,
+      ),
+    ),
   );
 }
 
@@ -232,7 +240,7 @@ function imceimage_widget(&$form, &$form
       }
 
       $element = array(
-        '#type' => 'imceimage',
+        '#type' => $field['widget']['type'],
         '#default_value' => isset($items[$delta])? $items[$delta] : '',
       );
       return $element;
@@ -256,6 +264,17 @@ function theme_imceimage_image($s, $w=''
     return '<img '. $s . $a . $w . $h . $id .'/>';
 }
 
+/**
+ * theme a generic file
+ */
+function theme_imceimage_generic_display($path, $id='') {
+    $filename = substr($path, strrpos($path,'/')+1,strlen($path)-strrpos($path,'/'));
+    $label = t('Selected file') . ':';
+    $id = !empty($id)? 'id="'. $id .'" ':'';
+    $visibility = 'style="visibility: ' . (empty($path) ? 'hidden' : 'visible') . ';"';
+    return "<div $id $visibility><b>$label</b> <a class=\"imcegeneric-filename\" href=\"$path\">$filename</a></div>";
+}
+
 
 function _imceimage_get_thumb($image) {
   $thumb_prefix = 'thumb_';
@@ -402,6 +421,10 @@ function theme_imceimage($element) {
   return $element['#children'];
 }
 
+function theme_imceimage_generic($element) {
+  return $element['#children'];
+}
+
 /**
  * hook_theme - that works together with hook_formatter and hook_elements
  * to provide the default theme and also a theme to display the
@@ -412,6 +435,9 @@ function imceimage_theme() {
     'imceimage' => array(
        'arguments' => array('element' => NULL),
     ),
+    'imceimage_generic' => array(
+       'arguments' => array('element' => NULL),
+    ),
     'imceimage_formatter_default' => array(
        'arguments' => array('element' => NULL),
     ),
@@ -466,6 +492,13 @@ function imceimage_elements() {
      '#process' => array('imceimage_process'),
      '#theme' => 'imceimage_override', //not used
   );
+  $el['imceimage_generic'] = array(
+     '#input' => TRUE,
+     '#columns' => array('imceimage_path'),
+     '#delta' => 1,
+     '#process' => array('imceimage_generic_process'),
+     '#theme' => 'imceimage_override', //not used
+  );
   return $el;
 }
 
@@ -480,24 +513,25 @@ function imceimage_process($element, $ed
   $link = url('imce/browse');
   $field_id = $field['field_name'];
 
+  $links = '<span id="' . "imceimage-actions-$delta-$field_id" . '">[<a href="' . 
+    "javascript:imceImage.open('$link', '$delta-$field_id')" .'" class="imceimage-add">';
+
   if (trim($element['#value']['imceimage_path']) != '') {
-    $links = t('Change Image') . '</a>]'
+    $links .= t('Change Image') . '</a>]'
            .'[<a class="imceimage-remove" href="javascript:'
            . "imceImage.remove('$delta-$field_id')"
            . '">' . t('Remove') . '</a>]';
   } 
   else {
-    $links = t('Add Image') . '</a>]';
+    $links .= t('Add Image') . '</a>]';
   }
-
+  $links .= '</span>';
+  
   $element['imce_add'] = array(
     '#type' => 'item',
-    '#value' => $field['widget']['label'] 
-               .' [<a href="'
-               ."javascript:imceImage.open('$link', '$delta-$field_id')"
-               .'" class="imceimage-add">'. $links );
-
-
+    '#value' => $field['widget']['label'] . ' ' . $links 
+  );
+  
   $element['imceimage_path'] = array(
     '#type' => 'hidden',
     '#id' => "imceimagepath-$delta-$field_id",
@@ -541,3 +575,48 @@ function imceimage_process($element, $ed
 
   return $element;
 }
+
+/**
+ * process handler for hook_elements renders the form element for
+ * imceimage_generic.
+ */
+function imceimage_generic_process($element, $edit, $form_state, $form) {
+  $field = $form['#field_info'][$element['#field_name']];
+  $delta = $element['#delta'];
+
+  $link = url('imce/browse');
+  $field_id = $field['field_name'];
+  
+  $links = '<span id="' . "imceimage-actions-$delta-$field_id" . '">[<a href="' . 
+    "javascript:imceImage.open('$link', '$delta-$field_id')" .'" class="imceimage-add">';
+
+  if (trim($element['#value']['imceimage_path']) != '') {
+    $links .= t('Change File') . '</a>]'
+           .'[<a class="imceimage-remove" href="javascript:'
+           . "imceImage.remove('$delta-$field_id')"
+           . '">' . t('Remove') . '</a>]';
+  } 
+  else {
+    $links .= t('Add File') . '</a>]';
+  }
+  $links .= '</span>';
+
+  $element['imce_add'] = array(
+    '#type' => 'item',
+    '#value' => $field['widget']['label'] . ' ' . $links );
+
+
+  $element['imceimage_path'] = array(
+    '#type' => 'hidden',
+    '#id' => "imceimagepath-$delta-$field_id",
+    '#default_value' => $element['#value']['imceimage_path'],
+  );
+
+  $element['imce_view'] = array(
+    '#type' => 'item',
+    '#value' => theme_imceimage_generic_display($element['#value']['imceimage_path'], "imcegenericarea-$delta-$field_id")
+  );
+
+
+  return $element;
+}
\ No newline at end of file
Only in .: .svn
Common subdirectories: ../imceimage-orig/translations and ./translations
