? TODO.txt
? patches
? views_defaults.inc
? contrib/image_attach/patches
? contrib/image_gallery/views_defaults.inc
Index: image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/image.module,v
retrieving revision 1.259
diff -u -r1.259 image.module
--- image.module	13 Nov 2007 03:21:53 -0000	1.259
+++ image.module	1 Dec 2007 15:32:16 -0000
@@ -11,6 +11,7 @@
 
 if (module_exists('views')) {
   include(drupal_get_path('module', 'image') .'/views.inc');
+  include(drupal_get_path('module', 'image') .'/views_defaults.inc');
 }
 
 /**
@@ -472,9 +473,13 @@
 /**
  * Implementation of hook_block.
  *
- * Offers 2 blocks: latest image and random image
+ * Offers 2 blocks: latest image and random image. Skip if Views module is enabled
  */
 function image_block($op = 'list', $delta = 0) {
+  if(module_exists('views')){
+    return;
+  }
+
   switch ($op) {
     case 'list':
       $block[0]['info'] = t('Latest image');
Index: views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/views.inc,v
retrieving revision 1.4
diff -u -r1.4 views.inc
--- views.inc	27 Aug 2007 22:50:39 -0000	1.4
+++ views.inc	1 Dec 2007 15:03:06 -0000
@@ -112,3 +112,58 @@
   return $a;
 }
 
+/**
+ * Implementation of hook_views_style_plugins()
+ */
+function image_views_style_plugins() {
+  $items['image_gallery'] = array(
+    'name' => t('Image: Gallery'),
+    'theme' => 'image_gallery_view',
+    'validate' => 'views_ui_plugin_validate_list',
+    'needs_fields' => true,
+  );
+  return $items;
+}
+
+/**
+ * Display the nodes of a view as an image gallery.
+ */
+function theme_image_gallery_view($view, $nodes, $type) {
+  drupal_add_css(drupal_get_path('module', 'image_gallery') .'/image_gallery.css');
+  
+  $fields = _views_get_fields();
+
+  // get the size of images
+  // NB: in the ulikely event thath user adds more than one image field with different sizes... this breaks
+  foreach ($view->field as $field) {
+    if ($field['tablename'] == 'image_node') {
+      $size = image_get_sizes($field['options']);
+    }
+  }
+  $width = $size['width'];
+  // We'll add height to keep thumbnails lined up.
+  $height = $size['height'] + 25;
+   
+  $content .= '<ul class="images clear-block">'; 
+
+  foreach ($nodes as $node) {
+    $item = '';
+   
+    foreach ($view->field as $field) {
+     //$item = dprint_r($field, 1);
+     if ($fields[$field['id']]['visible'] !== FALSE) {
+        if ($field['label']) {
+          $item .= "<div class='view-label view-label-$field[queryname]'>" . $field['label'] . "</div>";
+        }
+        $item .= "<div class='view-field view-data-$field[queryname]'>" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "</div>";
+      }
+    }
+    $content .= "<li class='' style='height : {$height}px; width : {$width}px;'><div class='view-item view-item-$view->name'>$item</div></li>\n"; 
+
+  }
+  $content .= "</ul>\n";
+  
+  if ($content) {
+    return $content;
+  }
+}
Index: contrib/image_gallery/image_gallery.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.css,v
retrieving revision 1.7
diff -u -r1.7 image_gallery.css
--- contrib/image_gallery/image_gallery.css	18 Jul 2007 17:04:31 -0000	1.7
+++ contrib/image_gallery/image_gallery.css	16 Nov 2007 21:36:12 -0000
@@ -44,6 +44,13 @@
 
 ul.images li {
   float : left;
-  margin : 1em;
+  margin: 1em;
+  margin-left:0;
+  margin-right:2em;
+  padding:0;
   background: transparent;
 }
+/* gallery view in a block */
+.block ul.images li {
+  margin-top:0;
+}
\ No newline at end of file
Index: contrib/image_gallery/image_gallery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.module,v
retrieving revision 1.20
diff -u -r1.20 image_gallery.module
--- contrib/image_gallery/image_gallery.module	7 Sep 2007 19:26:24 -0000	1.20
+++ contrib/image_gallery/image_gallery.module	1 Dec 2007 15:26:34 -0000
@@ -1,6 +1,11 @@
 <?php
 // $Id: image_gallery.module,v 1.20 2007/09/07 19:26:24 drewish Exp $
 
+if (module_exists('views')) {
+  include(drupal_get_path('module', 'image_gallery') .'/views_defaults.inc');
+}
+
+
 function image_gallery_help($section) {
   switch ($section) {
     case 'admin/image':
@@ -153,10 +158,18 @@
   }
 
   $images = array();
-  if ($tid) {
-    $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid=n.nid WHERE n.status=1 AND n.type='image' AND t.tid=%d ORDER BY n.sticky DESC, n.created DESC"), variable_get('image_images_per_page', 6), 0, NULL, $tid);
-    while ($node = db_fetch_object($result)) {
-      $images[] = node_load(array('nid' => $node->nid));
+  if ($tid) {   
+    // Depending on whether the Views module is enabled, either:
+    // - build (and theme) the image gallery ourselves 
+    // - embed a view to show the image gallery, appending it to the themed child gallery list
+    if (module_exists('views')) {
+      $view = views_get_view('image_gallery');
+    }
+    else {
+      $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid=n.nid WHERE n.status=1 AND n.type='image' AND t.tid=%d ORDER BY n.sticky DESC, n.created DESC"), variable_get('image_images_per_page', 6), 0, NULL, $tid);
+      while ($node = db_fetch_object($result)) {
+        $images[] = node_load(array('nid' => $node->nid));
+      }
     }
 
     $gallery = taxonomy_get_term($tid);
@@ -172,6 +185,11 @@
   $breadcrumb[] = array('path' => $_GET['q']);
   menu_set_location($breadcrumb);
   $content = theme('image_gallery', $galleries, $images);
+  
+  if ($view) {
+   $content .= views_build_view('embed', $view, array($tid), $view->use_pager, $view->nodes_per_page, 0, 0);
+  }
+  
   return $content;
 }
 
@@ -352,8 +370,8 @@
     $content .= "</ul>\n";
   }
 
-  if (!empty($images)) {
-    $content .= '<ul class="images">';
+  if (!empty($images)) {  
+    $content .= '<ul class="images clear-block">';
     foreach ($images as $image) {
       $content .= theme('image_gallery_img', $image, $size);
     }
@@ -364,7 +382,8 @@
     $content .= $pager;
   }
 
-  If (count($images) + count($galleries) == 0) {
+  // skip this if using Views, as $images is always empty
+  If (!module_exists('views') && count($images) + count($galleries) == 0) {
       $content .= '<p class="count">'. format_plural(0, 'There is 1 image in this gallery', 'There are @count images in this gallery') ."</p>\n";
   }
 
--- contrib/image_gallery/views_defaults.inc
+++ contrib/image_gallery/views_defaults.inc
@@ -0,0 +1,104 @@
+<?php
+
+// $Id$
+
+/**
+ * Implementation of hook_views_default_views().
+ */
+function  image_gallery_views_default_views() {
+
+  /**
+   * Image gallery with taxonomy argument
+   */
+  $view = new stdClass();
+  $view->name = 'image_gallery';
+  $view->description = t('Basic image gallery. Embedded by the image_gallery module.');
+  $view->access = array (
+);
+  $view->view_args_php = '';
+  $view->page = TRUE;
+  $view->page_title = '';
+  $view->page_header = '';
+  $view->page_header_format = '1';
+  $view->page_footer = '';
+  $view->page_footer_format = '1';
+  $view->page_empty = t('There are no images in this gallery.');
+  $view->page_empty_format = '1';
+  $view->page_type = 'image_gallery';
+  $view->use_pager = TRUE;
+  $view->nodes_per_page = '6';
+  $view->sort = array (
+    array (
+      'tablename' => 'node',
+      'field' => 'sticky',
+      'sortorder' => 'DESC',
+      'options' => '',
+    ),
+    array (
+      'tablename' => 'node',
+      'field' => 'created',
+      'sortorder' => 'DESC',
+      'options' => 'normal',
+    ),
+  );
+  $view->argument = array (
+    array (
+      'type' => 'taxid',
+      'argdefault' => '7',
+      'title' => '%1',
+      'options' => '',
+      'wildcard' => '',
+      'wildcard_substitution' => '',
+    ),
+  );
+  $view->field = array (
+    array (
+      'tablename' => 'image_node',
+      'field' => 'nid',
+      'label' => '',
+      'handler' => 'image_views_handler_image_img_link',
+      'options' => 'thumbnail',
+    ),
+    array (
+      'tablename' => 'node',
+      'field' => 'title',
+      'label' => '',
+      'handler' => 'views_handler_field_nodelink',
+      'options' => 'link',
+    ),
+  );
+  $view->filter = array (
+    array (
+      'tablename' => 'node',
+      'field' => 'status',
+      'operator' => '=',
+      'options' => '',
+      'value' => '1',
+    ),
+    array (
+      'tablename' => 'node',
+      'field' => 'type',
+      'operator' => 'OR',
+      'options' => '',
+      'value' => array (
+  0 => 'image',
+),
+    ),
+    array (
+      'tablename' => 'term_data',
+      'field' => 'vid',
+      'operator' => 'AND',
+      'options' => '',
+      'value' => array (
+  0 => '1',
+),
+    ),
+  );
+  $view->exposed_filter = array (
+  );
+  $view->requires = array(node, image_node, term_data);
+  $views[$view->name] = $view;
+
+
+  return $views;
+}

--- views_defaults.inc
+++ views_defaults.inc
@@ -0,0 +1,189 @@
+<?php
+
+// $Id$
+
+/**
+ * Implementation of hook_views_default_views().
+ */
+function  image_views_default_views() {
+
+  /**
+   * Latest image block & page
+   */
+  $view = new stdClass();
+  $view->name = 'image_recent';
+  $view->description = t('Block and gallery page of recent images');
+  $view->access = array ();
+  $view->view_args_php = '';
+  $view->page = TRUE;
+  $view->page_title = t('Latest images');
+  $view->page_header = '';
+  $view->page_header_format = '1';
+  $view->page_footer = '';
+  $view->page_footer_format = '1';
+  $view->page_empty = '';
+  $view->page_empty_format = '1';
+  $view->page_type = 'image_gallery';
+  $view->url = 'image/recent';
+  $view->use_pager = TRUE;
+  $view->nodes_per_page = '6';
+  $view->menu = TRUE;
+  $view->menu_title = t('Latest images');
+  $view->menu_tab = FALSE;
+  $view->menu_tab_weight = '0';
+  $view->menu_tab_default = FALSE;
+  $view->menu_tab_default_parent = NULL;
+  $view->menu_tab_default_parent_type = 'tab';
+  $view->menu_parent_tab_weight = '0';
+  $view->menu_parent_title = '';
+  $view->block = TRUE;
+  $view->block_title = t('Latest image');
+  $view->block_header = '';
+  $view->block_header_format = '1';
+  $view->block_footer = '';
+  $view->block_footer_format = '1';
+  $view->block_empty = '';
+  $view->block_empty_format = '1';
+  $view->block_type = 'image_gallery';
+  $view->nodes_per_block = '1';
+  $view->block_more = TRUE;
+  $view->block_use_page_header = FALSE;
+  $view->block_use_page_footer = FALSE;
+  $view->block_use_page_empty = FALSE;
+  $view->sort = array (
+    array (
+      'tablename' => 'node',
+      'field' => 'created',
+      'sortorder' => 'DESC',
+      'options' => 'normal',
+    ),
+  );
+  $view->argument = array (
+  );
+  $view->field = array (
+    array (
+      'tablename' => 'image_node',
+      'field' => 'nid',
+      'label' => '',
+      'handler' => 'image_views_handler_image_img_link',
+      'options' => 'thumbnail',
+    ),
+    array (
+      'tablename' => 'node',
+      'field' => 'title',
+      'label' => '',
+      'handler' => 'views_handler_field_nodelink',
+      'options' => 'link',
+    ),
+  );
+  $view->filter = array (
+    array (
+      'tablename' => 'node',
+      'field' => 'status',
+      'operator' => '=',
+      'options' => '',
+      'value' => '1',
+    ),  
+    array (
+      'tablename' => 'node',
+      'field' => 'type',
+      'operator' => 'OR',
+      'options' => '',
+      'value' => array (
+        0 => 'image',
+      ),
+    ),
+  );
+  $view->exposed_filter = array (
+  );
+  $view->requires = array(node, image_node);
+  $views[$view->name] = $view;
+
+  /**
+   * Random image block
+   */
+  $view = new stdClass();
+  $view->name = 'image_random';
+  $view->description = t('Random image');
+  $view->access = array (
+);
+  $view->view_args_php = '';
+  $view->page = FALSE;
+  $view->page_title = '';
+  $view->page_header = '';
+  $view->page_header_format = '1';
+  $view->page_footer = '';
+  $view->page_footer_format = '1';
+  $view->page_empty = '';
+  $view->page_empty_format = '1';
+  $view->page_type = 'image_gallery';
+  $view->url = '';
+  $view->use_pager = TRUE;
+  $view->nodes_per_page = '10';
+  $view->block = TRUE;
+  $view->block_title = t('Random image');
+  $view->block_header = '';
+  $view->block_header_format = '1';
+  $view->block_footer = '';
+  $view->block_footer_format = '1';
+  $view->block_empty = '';
+  $view->block_empty_format = '1';
+  $view->block_type = 'image_gallery';
+  $view->nodes_per_block = '1';
+  $view->block_more = FALSE;
+  $view->block_use_page_header = FALSE;
+  $view->block_use_page_footer = FALSE;
+  $view->block_use_page_empty = FALSE;
+  $view->sort = array (
+    array (
+      'tablename' => 'node',
+      'field' => 'random',
+      'sortorder' => 'ASC',
+      'options' => '',
+    ),
+  );
+  $view->argument = array (
+  );
+  $view->field = array (
+    array (
+      'tablename' => 'image_node',
+      'field' => 'nid',
+      'label' => '',
+      'handler' => 'image_views_handler_image_img_link',
+      'options' => 'thumbnail',
+    ),
+    array (
+      'tablename' => 'node',
+      'field' => 'title',
+      'label' => '',
+      'handler' => 'views_handler_field_nodelink',
+      'options' => 'link',
+    ),
+  );
+  $view->filter = array (
+    array (
+      'tablename' => 'node',
+      'field' => 'status',
+      'operator' => '=',
+      'options' => '',
+      'value' => '1',
+    ),
+    array (
+    
+      'tablename' => 'node',
+      'field' => 'type',
+      'operator' => 'OR',
+      'options' => '',
+      'value' => array (
+  0 => 'image',
+),
+    ),
+  );
+  $view->exposed_filter = array (
+  );
+  $view->requires = array(node, image_node);
+  $views[$view->name] = $view;
+
+
+  return $views;
+}

