function theme_swftools_formatter_playlist in SWF Tools 6.2
Same name and namespace in other branches
- 6.3 includes/swftools.theme.inc \theme_swftools_formatter_playlist()
Theme function to turn multiple value CCK filefield in to a playlist.
Parameters
$element: The element to render.
Return value
A string of markup to produce the flash content, or nothing if the element was empty.
1 string reference to 'theme_swftools_formatter_playlist'
- swftools_theme in ./
swftools.module - Implementation of hook_theme
File
- ./
swftools.module, line 1863
Code
function theme_swftools_formatter_playlist($element) {
// Initialise an array for results
$files = array();
// Get the children
$children = element_children($element);
// If there is only one child then maybe we don't want a playlist
if (count($children) == 1) {
// Pop the first value of the children array
$_children = $children;
$child = array_pop($_children);
// Get the name of the alternate formatter for this content type
$formatter_name = variable_get('swftools_' . $element['#type_name'] . '_' . $element['#field_name'], 'swftools_playlist');
// What happens next depends on the formatter name
switch ($formatter_name) {
case 'hidden':
// If the format is set to hidden then return nothing
if ($formatter_name == 'hidden') {
return;
}
case 'swftools_playlist':
// If swftools_playlist don't do anything different
break;
default:
// Find out what the alternate formatter should be
if ($formatter = _content_get_formatter($formatter_name, 'filefield')) {
$theme = $formatter['module'] . '_formatter_' . $formatter_name;
// Theme the element according to the alternate formatter
return theme($theme, $element[$child]);
}
}
}
// Cycle through the file elements
foreach ($children as $key) {
// If nothing has been uploaded then there are items, but they are empty, so check they are set
if (isset($element[$key]['#item']['filepath'])) {
$files[] = $element[$key]['#item']['filepath'];
}
}
// If files array is empty then there is nothing to be rendered
if (empty($files)) {
return;
}
// But if we got something then we can call swf() now to render it
return swf($files);
}