function theme_swftools_formatter_playlist in SWF Tools 6.3
Same name and namespace in other branches
- 6.2 swftools.module \theme_swftools_formatter_playlist()
Themes multiple value CCK content in to a playlist.
Parameters
array $element: The element to render.
array $profile: (optional) Array of profile data for the profile that is being used.
Return value
string Markup to produce the flash content, or nothing if the element was empty.
Related topics
1 string reference to 'theme_swftools_formatter_playlist'
- swftools_theme in ./
swftools.module - Implementation of hook_theme().
File
- includes/
swftools.theme.inc, line 82 - Implements SWF Tools theme functions.
Code
function theme_swftools_formatter_playlist($element, $profile = array()) {
// 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')) {
// We can work out the theme name from the formatter information
$theme = $formatter['module'] . '_formatter_' . $formatter_name;
// Construct a modified element that mimics a single element
$element['#formatter'] = $formatter_name;
$element['#theme'] = $theme;
$element += $element[$child];
$element['#item']['#delta'] = 0;
unset($element[$child]);
// Theme this new element according to the alternate formatter
return theme($theme, $element);
}
}
}
// Retrieve images
$images = theme_swftools_formatter_thumbnail('', TRUE);
// Cycle through the file elements
foreach ($children as $key) {
// Is this a filefield?
if (isset($element[$key]['#item']['filepath'])) {
$files[$key] = array(
'filepath' => $element[$key]['#item']['filepath'],
'title' => $element[$key]['#item']['data']['description'],
);
}
// Is this a link field?
if (isset($element[$key]['#item']['url'])) {
$files[$key] = array(
'filepath' => $element[$key]['#item']['url'],
'title' => $element[$key]['#item']['title'],
);
}
// Is this a text field?
// TODO: How to handle streams in a playlist
if (isset($element[$key]['#item']['value'])) {
$files[$key] = array(
'filepath' => $element[$key]['#item']['value'],
'title' => '',
);
}
// Is there an image?
if (isset($images[$key]) && $images[$key]) {
// Get the path to the image
$source = swftools_get_url_and_path($images[$key]);
// If $source returned a result then use it
if ($source) {
$files[$key]['image'] = $source['fileurl'];
}
}
}
// If files array is empty then there is nothing to be rendered
if (empty($files)) {
return;
}
// Pass element to the swf tools processor by attaching it in othervars
$data['othervars']['cck'] = $element;
// Assign the profile
$data['othervars']['profile'] = $profile ? $profile['profile'] : '';
// But if we got something then we can call swf() now to render it
return swf($files, $data);
}