| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Theme file for Slideshow Pro integration.
|
| 7 |
*
|
| 8 |
* Contains theme functions registered by hook_theme().
|
| 9 |
*/
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Display the XML document.
|
| 13 |
*/
|
| 14 |
function theme_slideshowpro_feed($view, $options, $type) {
|
| 15 |
global $base_url;
|
| 16 |
|
| 17 |
$title_caption = &$options['title_caption'];
|
| 18 |
$current_display = &$view->display[$view->current_display];
|
| 19 |
|
| 20 |
$size = 'preview';
|
| 21 |
|
| 22 |
/*
|
| 23 |
|
| 24 |
I cannot figure out what this is for!?
|
| 25 |
|
| 26 |
foreach ($view->filter as $filter) {
|
| 27 |
if ($filter['field'] == 'slideshowpro.tid') {
|
| 28 |
$size = $filter['options'];
|
| 29 |
}
|
| 30 |
}
|
| 31 |
|
| 32 |
*/
|
| 33 |
|
| 34 |
$album_terms = array();
|
| 35 |
$albums = array();
|
| 36 |
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
| 37 |
$output .= "<gallery>\n";
|
| 38 |
|
| 39 |
foreach ($view->result as $n) {
|
| 40 |
|
| 41 |
$node = node_load($n->nid);
|
| 42 |
$tids = array();
|
| 43 |
|
| 44 |
if (module_exists('taxonomy')) {
|
| 45 |
if ($n->tid) {
|
| 46 |
$tids = array($n->tid);
|
| 47 |
$album_terms[$n->tid] = taxonomy_get_term($n->tid);
|
| 48 |
}
|
| 49 |
// If no image gallery tid was passed in and image gallery is installed, get tids from node.
|
| 50 |
else if (module_exists('image_gallery')) {
|
| 51 |
foreach ($node->taxonomy as $term) {
|
| 52 |
if ($term->vid == _image_gallery_get_vid()) {
|
| 53 |
$album_terms[$term->tid] = $term;
|
| 54 |
$tids[] = $term->tid;
|
| 55 |
}
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}
|
| 59 |
|
| 60 |
// Stick images with no album in an album called "In no album"
|
| 61 |
if (!count($tids)) {
|
| 62 |
$tids = array(0);
|
| 63 |
$album->name = t('In no album');
|
| 64 |
$album_terms[0] = $album;
|
| 65 |
}
|
| 66 |
|
| 67 |
$image = theme('slideshowpro_xml_image', $node, $size, $title_caption);
|
| 68 |
|
| 69 |
// An image can be in more than one album.
|
| 70 |
foreach ($tids as $tid) {
|
| 71 |
$albums[$tid][] = $image;
|
| 72 |
}
|
| 73 |
|
| 74 |
}
|
| 75 |
|
| 76 |
ksort($albums);
|
| 77 |
|
| 78 |
foreach ($albums as $tid => $images) {
|
| 79 |
$output .= slideshowpro_xml_album($album_terms[$tid], $images);
|
| 80 |
}
|
| 81 |
|
| 82 |
$output .= "</gallery>\n";
|
| 83 |
|
| 84 |
drupal_set_header('Content-Type: text/xml; charset=utf-8');
|
| 85 |
print $output;
|
| 86 |
|
| 87 |
module_invoke_all('exit');
|
| 88 |
exit;
|
| 89 |
}
|
| 90 |
|
| 91 |
/**
|
| 92 |
* Format an image.
|
| 93 |
*/
|
| 94 |
function theme_slideshowpro_xml_image(&$node, $size = 'preview', $title_caption = 0) {
|
| 95 |
$output = '<img src="%src" title="%title" caption="%caption" link="%link" target="_blank" tn="%thumb" />'."\n";
|
| 96 |
$variables = array(
|
| 97 |
'%src' => slideshowpro_get_image_path() . basename($node->images[$size]),
|
| 98 |
'%title' => check_plain($node->title),
|
| 99 |
'%caption' => $title_caption ? trim(check_plain($node->title)) : trim(check_plain(truncate_utf8($node->body, 100, TRUE, TRUE))),
|
| 100 |
'%link' => url('node/'. $node->nid, array('absolute' => TRUE)),
|
| 101 |
'%thumb' => slideshowpro_get_image_path() . basename($node->images['thumbnail']),
|
| 102 |
);
|
| 103 |
return strtr($output, $variables);
|
| 104 |
}
|
| 105 |
|
| 106 |
/**
|
| 107 |
* Theme output.
|
| 108 |
*/
|
| 109 |
function theme_slideshowpro_embed($output, $id) {
|
| 110 |
return '<div class="slideshowpro" id="slideshowpro-'. $id .'">'. $output .'</div>';
|
| 111 |
}
|