'media_flickr_xspf_page', 'page arguments' => array(3), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Page callback for /media/flickr/[photoset]/xspf. * * Displays an XSPF playlist for the photoset. */ function media_flickr_xspf_page($photoset, $delay = 10, $width = 0, $height = 0, $captions = MEDIA_FLICKR_XSPF_CAPTION_TYPE_TITLE) { drupal_set_header('Content-Type: text/xml; charset=utf-8'); $output = array(); $output[] = ''; $info = media_flickr_sets_request('flickr.photosets.getInfo', array('photoset_id' => $photoset['id'])); $title = $info['photoset']['title']['_content']; $attributes = array( 'title' => t('@title', array('@title' => $title)), ); $output[] = format_xml_elements($attributes) . ''; $items = array(); $size = media_flickr_guess_size($width, $height); $photos = media_flickr_photoset_load_photos($photoset, $size); foreach ($photoset['photoset']['photo'] as $photoid => $photo) { // media_flickr_photo_load($photoid); switch ($captions) { case MEDIA_FLICKR_XSPF_CAPTION_TYPE_DESCRIPTION: $title = t('@description', array('@description' => $photo['photo']['description']['_content'])); break; case MEDIA_FLICKR_XSPF_CAPTION_TYPE_BOTH: $title = t('@title - @description', array('@title' => $photo['photo']['title']['_content'], '@description' => $photo['photo']['description']['_content'])); break; case MEDIA_FLICKR_XSPF_CAPTION_TYPE_NONE: $title = ''; break; case MEDIA_FLICKR_XSPF_CAPTION_TYPE_DESCRIPTION_FALLBACK_TO_TITLE: $title = t('@description', array('@description' => $photo['photo']['description']['_content'])); if ($title === '') { $title = t('@title', array('@title' => $photo['photo']['title']['_content'])); } break; case MEDIA_FLICKR_XSPF_CAPTION_TYPE_TITLE: default: $title = t('@title', array('@title' => $photo['photo']['title']['_content'])); break; } $url = url($photos[$photoid], array('absolute' => TRUE)); $items[] = array( 'title' => $title, 'creator' => '', 'location' => $url, 'info' => '', 'image' => $url, 'duration' => $delay, array( 'key' => 'meta', 'value' => $delay, 'attributes' => array( 'rel' => 'duration', ), ), ); } if (!empty($items)) { foreach($items as $item){ // Add another item. $output[] = media_flickr_xspf_item($item); } } $output[] = ''; $output[] = ''; print implode("\n", $output); } /** * Create a playlist item for an xml file. * * @param array $item * Keys are: * - 'key': the tag name. * - 'value': the tag value. * - 'attributes': an array of attributues, e.g., array('rel' => 'rel')) to be applied * to the tag. Will be run through drupal_attributes(). * @return * An XML string. */ function media_flickr_xspf_item($item) { $output = array(); $output[] = ''; $output[] = format_xml_elements($item) . ''; return implode("\n", $output); }