/[drupal]/contributions/modules/image/contrib/image_attach/image_attach_views_handler_field_attached_images.inc
ViewVC logotype

Diff of /contributions/modules/image/contrib/image_attach/image_attach_views_handler_field_attached_images.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Sat Sep 5 15:33:18 2009 UTC revision 1.3, Sat Oct 3 07:39:08 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: image_attach_views_handler_field_attached_images.inc,v 1.1 2009/09/05 11:29:37 joachim Exp $  // $Id: image_attach_views_handler_field_attached_images.inc,v 1.2 2009/09/05 15:33:18 joachim Exp $
3    
4  /**  /**
5   * Field handler to display the attached images on a node.   * Field handler to display the attached images on a node.
# Line 62  class image_attach_views_handler_field_a Line 62  class image_attach_views_handler_field_a
62     * multiple fields.     * multiple fields.
63     */     */
64    function pre_render(&$values) {    function pre_render(&$values) {
65        $nids = array();
66      foreach ($values as $v) {      foreach ($values as $v) {
67        if (isset($v->{$this->aliases['image_attach_nid']})) {        if (isset($v->{$this->aliases['image_attach_nid']})) {
68          // Make the nid safe.          // Make the nid safe.
# Line 70  class image_attach_views_handler_field_a Line 71  class image_attach_views_handler_field_a
71          $nids[$nid] = $nid;          $nids[$nid] = $nid;
72        }        }
73      }      }
     $nids_string = implode(',', $nids);  
     $result = db_query("SELECT nid, iid FROM {image_attach} WHERE nid IN (" . $nids_string . ") ORDER BY weight");  
     while ($data = db_fetch_object($result)) {  
       // Store all the attached image nids (iid) keyed by attaching nid.  
       $attached_images[$data->nid][] = $data->iid;  
     }  
74    
75      // Place the data into the $values array for each result.      if (count($nids)) {
76      foreach ($values as $id => $v) {        $nids_string = implode(',', $nids);
77        if (isset($attached_images[$v->{$this->aliases['image_attach_nid']}])) {        $result = db_query("SELECT nid, iid FROM {image_attach} WHERE nid IN (" . $nids_string . ") ORDER BY weight");
78          $values[$id]->image_attach_iids = $attached_images[$v->{$this->aliases['image_attach_nid']}];        while ($data = db_fetch_object($result)) {
79            // Store all the attached image nids (iid) keyed by attaching nid.
80            $attached_images[$data->nid][] = $data->iid;
81          }
82    
83          // Place the data into the $values array for each result.
84          foreach ($values as $id => $v) {
85            if (isset($attached_images[$v->{$this->aliases['image_attach_nid']}])) {
86              $values[$id]->image_attach_iids = $attached_images[$v->{$this->aliases['image_attach_nid']}];
87            }
88        }        }
89      }      }
90    }    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2