? .DS_Store
? 567226-image_attach-views-field.patch
? _PATCHES - event
? move-deriv-rebuild-226121.patch
? contrib/.DS_Store
? contrib/image_attach/.DS_Store
? contrib/image_gallery/.DS_Store
? tests/.DS_Store
Index: contrib/image_attach/image_attach.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.module,v
retrieving revision 1.55
diff -u -p -r1.55 image_attach.module
--- contrib/image_attach/image_attach.module	2 Sep 2009 14:49:41 -0000	1.55
+++ contrib/image_attach/image_attach.module	3 Sep 2009 12:34:48 -0000
@@ -403,16 +403,18 @@ return array(
 );
 }
 
-
+/**
+ * Implementation of hook_views_handlers().
+ */
 function image_attach_views_handlers() {
   return array(
-  'info' => array(
-    'path' => drupal_get_path('module', 'image_attach'),
-    ),
-  'handlers' => array(
-    'image_attach_views_handler_field_iid' => array(
-     'parent' => 'views_handler_field',
-     ),
+    'info' => array(
+      'path' => drupal_get_path('module', 'image_attach'),
+      ),
+    'handlers' => array(
+      'image_attach_views_handler_field_attached_images' => array(
+        'parent' => 'image_handler_field_image_node_image',
+      ),
     ),
   );
 }
Index: contrib/image_attach/image_attach.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.views.inc,v
retrieving revision 1.3
diff -u -p -r1.3 image_attach.views.inc
--- contrib/image_attach/image_attach.views.inc	20 Oct 2008 23:52:48 -0000	1.3
+++ contrib/image_attach/image_attach.views.inc	3 Sep 2009 12:34:48 -0000
@@ -4,6 +4,10 @@
 /**
  * Implementation of hook_views_data().
  */
+/* 
+// The field is defined in hook_views_data_alter below.
+// But this code is likely to be needed for relationships or filters
+// So commenting out for now.
 function image_attach_views_data() {
   // Basic table information.
   $data = array();
@@ -25,6 +29,9 @@ function image_attach_views_data() {
   // changed field
   $data['image_attach']['iid'] = array(
     'title' => t('Attached image'), // The item it appears as on the UI,
+    // TODO: relationship to attached image nodes.
+    
+    // WILL DIE!
     'field' => array(
       'handler' => 'image_attach_views_handler_field_iid',
       'click sortable' => TRUE,
@@ -34,4 +41,20 @@ function image_attach_views_data() {
 
   return $data;
 }
+*/
 
+/**
+ * Implementation of hook_views_data_alter().
+ */
+function image_attach_views_data_alter(&$data) {
+  // {node} table, prefixed with 'image_attach' to avoid potential clashes.
+  // The images for attached image nodes.
+  $data['node']['image_attach_images'] = array(
+    'group' => t('Image attach'),
+    'field' => array(
+      'title' => t('Attached images'),
+      'help' => t('The attached images, shown at a chosen size. This field can be added without a relationship.'),
+      'handler' => 'image_attach_views_handler_field_attached_images',
+    ),
+  );
+}
\ No newline at end of file
Index: contrib/image_attach/image_attach_views_handler_field_attached_images.inc
===================================================================
RCS file: contrib/image_attach/image_attach_views_handler_field_attached_images.inc
diff -N contrib/image_attach/image_attach_views_handler_field_attached_images.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/image_attach/image_attach_views_handler_field_attached_images.inc	3 Sep 2009 12:34:48 -0000
@@ -0,0 +1,118 @@
+<?php
+// $Id$
+
+/**
+ * Field handler to display the attached images on a node.
+ *
+ * This is a fake field: it does not add to the view query but runs its own
+ * to get data. This is to avoid getting multiple rows for one node when
+ * there are multiple attached image nodes.
+ *
+ * Inherit from image_handler_field_image_node_image so we get image sizes.
+ */
+class image_attach_views_handler_field_attached_images 
+  extends image_handler_field_image_node_image {
+
+  /**
+   * Constructor to provide additional fields to add.
+   *
+   * Add the nid field for our query later on.
+   */
+  function construct() {
+    parent::construct();
+
+    $this->additional_fields['image_attach_nid'] = array(
+      'table' => 'node',
+      'field' => 'nid',
+    );
+  }
+  
+  /**
+   * Define default values for options.
+   * 
+   * We inherit the image size option.
+   */
+  function option_definition() {
+    $options = parent::option_definition();
+
+    $options['as_link'] = array('default' => 'none');
+
+    return $options;
+  }
+
+  /**
+   * Extend the field's basic options with more image specific options.
+   *
+   * TODO: hide the 'link to node' option?
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    $form['as_link'] = array(
+      '#type' => 'select',
+      '#title' => t('Link'),
+      '#options' => array('none' => t('No link'), 'node' => t('Node'), 'image' => t('Image node')),
+      '#default_value' => $this->options['as_link'],
+    );
+  }
+  
+  /**
+   * We don't add to the query (see the parent class).
+   * Instead, run our own query on pre-render. This is the same approach as CCK 
+   * multiple fields.
+   */
+  function pre_render(&$values) {
+    foreach ($values as $v) {
+      if (isset($v->{$this->aliases['image_attach_nid']})) {
+        // Use the nid as the key to make the values unique.
+        $nids[$v->{$this->aliases['image_attach_nid']}] = $v->{$this->aliases['image_attach_nid']};
+      }
+    }
+    $nids_string = implode(',', $nids);
+    $result = db_query("SELECT nid, iid FROM {image_attach} WHERE nid IN (%s) ORDER BY weight", $nids_string);
+    while ($data = db_fetch_object($result)) {
+      // Store all the attached image nids (iid) keyed by attaching nid.
+      $attached_images[$data->nid][] = $data->iid;
+    }
+    
+    // Place the data into the $values array for each result.
+    foreach ($values as $id => $v) {
+      if (isset($attached_images[$v->{$this->aliases['image_attach_nid']}])) {
+        $values[$id]->image_attach_iids = $attached_images[$v->{$this->aliases['image_attach_nid']}];
+      }
+    }
+  }
+
+  /**
+   * Render the field.
+   */
+  function render($values) {
+    if (isset($values->image_attach_iids)) {
+      $derivative = $this->options['image_derivative'];
+      foreach ($values->image_attach_iids as $iid) {
+        // Create fake nodes suitable for image_display().
+        $node = new stdClass();
+        $node->nid = $iid;
+        
+        // image_load() will load the files for all derivatives. Derivatives larger
+        // than the original fall back to the original. Stale derivatives will be
+        // regenerated.
+        image_load($node);
+        $image_img = image_display($node, $derivative);
+        
+        switch($this->options['as_link']) {
+          case 'node':
+            $output .= l($image_img, 'node/' . $values->{$this->aliases['nid']}, array('html' => true));
+            break;
+          case 'image':
+            $output .= l($image_img, 'node/' . $node->nid, array('html' => true));
+            break;
+          default:
+            $output .= $image_img;
+            break;
+        }
+      }
+      return $output;
+    }
+  }
+}
Index: contrib/image_attach/image_attach_views_handler_field_iid.inc
===================================================================
RCS file: contrib/image_attach/image_attach_views_handler_field_iid.inc
diff -N contrib/image_attach/image_attach_views_handler_field_iid.inc
--- contrib/image_attach/image_attach_views_handler_field_iid.inc	8 Aug 2009 16:40:58 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<?php
-// $Id: image_attach_views_handler_field_iid.inc,v 1.4 2009/08/08 16:40:58 joachim Exp $
-
-/**
- * Render an Image Attach field with options to control the size of the image
- * and the style of the link.
- */
-class image_attach_views_handler_field_iid extends views_handler_field {
-  /**
-   * Constructor to provide additional field to add.
-   */
-  function construct() {
-    parent::construct();
-    $this->additional_fields['nid'] = 'nid';
-  }
-
-  function option_definition() {
-    $options = parent::option_definition();
-
-    $options['size'] = array('default' => IMAGE_THUMBNAIL);
-    $options['as_link'] = array('default' => 'none');
-
-    return $options;
-  }
-
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-    $sizes = image_get_sizes();
-    $options = array();
-    foreach($sizes as $name => $data) {
-      $options[$name] = $data['label'] . '('. $data['width'] . 'x' . $data['height'] . ')';
-    }
-    $form['size'] = array(
-      '#type' => 'select',
-      '#title' => t('Image size'),
-      '#options' => $options,
-      '#default_value' => $this->options['size'],
-    );
-
-    $form['as_link'] = array(
-      '#type' => 'select',
-      '#title' => t('Link'),
-      '#options' => array('none' => t('No link'), 'node' => t('Node'), 'image' => t('Image node')),
-      '#default_value' => $this->options['as_link'],
-    );
-  }
-
-  function render($values) {
-    $image_node = node_load($values->{$this->field_alias});
-
-    if (!$image_node && node_access('view', $image_node)) {
-      return '';
-    }
-
-    switch($this->options['as_link']) {
-      case 'node':
-        return l(image_display($image_node, $this->options['size']), 'node/' . $values->{$this->aliases['nid']}, array('html' => true));
-
-      case 'image':
-        return l(image_display($image_node, $this->options['size']), 'node/' . $image_node->nid, array('html' => true));
-
-      default:
-        return image_display($image_node, $this->options['size']);
-    }
-  }
-}
