function swftools_playlist_from_image_gallery in SWF Tools 5
image_gallery.module helper This function ported from image_gallery.
User-friendly function to convert image gallery files into a structured $playlist_data array ready to pass to swf_list().
Parameters
$tid: Pass a specific tid (term id representing an image gallery.
File
- ./
swftools_integrate.module, line 87
Code
function swftools_playlist_from_image_gallery($tid, $derivative = 'preview') {
$galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1);
for ($i = 0; $i < count($galleries); $i++) {
$galleries[$i]->count = taxonomy_term_count_nodes($galleries[$i]->tid, 'image');
$tree = taxonomy_get_tree(_image_gallery_get_vid(), $galleries[$i]->tid, -1);
$descendant_tids = array_merge(array(
$galleries[$i]->tid,
), array_map('_taxonomy_get_tid_from_term', $tree));
$last = db_fetch_object(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN (%s) AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), implode(',', $descendant_tids), 0, 1));
$galleries[$i]->latest = node_load(array(
'nid' => $last->nid,
));
}
$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 ($nid = db_fetch_object($result)) {
$node = node_load(array(
'nid' => $nid->nid,
));
foreach ($node->files as $fid => $file_data) {
if ($file_data->filename == $derivative) {
$files[$fid] = (array) $file_data;
$files[$fid]['title'] = $node->title;
}
}
}
}
$playlist_data = swftools_prepare_playlist_data($files);
return $playlist_data;
}