function swftools_simpleviewer_swftools_playlist_simpleviewer in SWF Tools 6.3
Implementation of hook_swftools_playlist().
File
- simpleviewer/
swftools_simpleviewer.module, line 78 - Enables SWF Tools support for SimpleViewer.
Code
function swftools_simpleviewer_swftools_playlist_simpleviewer(&$data) {
// Get array of simpleviewer settings
$saved_settings = _swftools_simpleviewer_vars($data['othervars']['profile']);
// Extract any relevant xml settings from the $data['othervars'] array
$user_xml = array_intersect_key($data['othervars'], $saved_settings['xml']);
// Merge user defined xml parameters with default parameters
$xml_vars = array_merge($saved_settings['xml'], $user_xml);
// Extract any relevant flickr settings from the $data['othervars'] array
$user_flickr = array_intersect_key($data['othervars'], $saved_settings['flickr']);
// Merge user defined flickr parameters with default parameters
$flickr_vars = array_merge($saved_settings['flickr'], $user_flickr);
// If useFlickr is true then add the flickr settings to the array of xml parameters
if ($flickr_vars['useFlickr'] == 'true' || $flickr_vars['useFlickr'] == 1) {
// Set useFlickr 'true'
$xml_vars['useFlickr'] = 'true';
// If a username was specified include this as flickrUserName
if ($flickr_vars['flickrUserName']) {
$xml_vars['flickrUserName'] = $flickr_vars['flickrUserName'];
}
// If flickrTags is not set, but tags is, then use tags
if (!$flickr_vars['flickrTags'] && isset($data['othervars']['tags']) && $data['othervars']['tags']) {
$flickr_vars['flickrTags'] = $data['othervars']['tags'];
}
// TODO: Could we convert user_id to flickrUserName?
// If tags were specified include them as flickrTags
if ($flickr_vars['flickrTags']) {
$xml_vars['flickrTags'] = $flickr_vars['flickrTags'];
}
}
// Put xml_vars and base in to the header array so the xml themer can access them
$data['othervars']['playlist_data']['header']['xml_vars'] = $xml_vars;
$data['othervars']['playlist_data']['header']['base'] = $data['params']['base'];
// Initialise a string to contain the elements
$xml = '';
// Iterate over the playlist to build elements xml
if ($data['othervars']['playlist_data']['playlist']) {
foreach ($data['othervars']['playlist_data']['playlist'] as $track => $details) {
$xml .= theme('swftools_simpleviewer_playlist_element', $details, $saved_settings['imagecache']['imagecache'] == SWFTOOLS_UNDEFINED ? '' : $saved_settings['imagecache']['imagecache']);
}
}
// Add xml wrapper around the elements
$xml = theme('swftools_simpleviewer_playlist_wrapper', $data['othervars']['playlist_data']['header'], $xml);
// Return the resulting xml
return $xml;
}