| 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. |
| 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. |
| 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 |
} |
} |