function theme_flashnode_markup in Flash Node 6.2
Same name and namespace in other branches
- 5.6 flashnode.module \theme_flashnode_markup()
- 5.3 flashnode.module \theme_flashnode_markup()
- 6.3 flashnode.module \theme_flashnode_markup()
Generate HTML mark for flash content, using SWF Tools if it is available
Flash node uses SWF Tools to handle JavaScript replacement but this isn't always easy to set up. To assist users flash node will fall back to direct HTML embedding if it can't find SWF Tools. This means flash node will work 'out of the box' in a basic fashion, and is extended when SWF Tools is available rather than being entirely dependent upon it.
This function is called with an array of parameters that define a flashnode and an optional array of parameters for swf tools.
See the description of theme_flashnode for details.
1 theme call to theme_flashnode_markup()
- theme_flashnode in ./
flashnode.module - Create the HTML for insertion of Flash This theme function will constrain the size of the content according to the limits set on the configuration page. It then calls a secondary theme function to produce the actual HTML markup.
File
- ./
flashnode.module, line 1029
Code
function theme_flashnode_markup($flashnode, $options = array()) {
// Generate HTML markup, using SWF Tools if available, fallback if not
if (defined('SWFTOOLS_INSTALLED')) {
// Add width, height and base to $params for SWF Tools, rounding width and height to integers
$params = array(
'width' => round($flashnode['width']),
'height' => round($flashnode['height']),
'base' => $flashnode['base'],
);
// Create additional parameters if any are provided, and merge
$params = array_merge($params, flashnode_get_params($flashnode['params']));
// Retrieve default substitution content if required
// Note we are bypassing the filters here, so we assume the administrator
// created valid mark-up that everyone else can use!
$preview = t($flashnode['substitution'], array(
'!default' => variable_get('flashnode_default_html_alt', FLASHNODE_DEFAULT_HTML_ALT),
));
$othervars = array_merge($options, array(
'html_alt' => $preview,
));
// Get HTML from SWF Tools
$options = array(
'params' => $params,
'flashvars' => $flashnode['flashvars'],
'othervars' => $othervars,
);
$file = $flashnode['filepath'];
// If using public download then encoding spaces that the upload module may have allowed
// Private downloads will do this for us
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
$file = str_replace(' ', '%20', $file);
}
$output .= swf(file_create_url($file), $options);
// Return result
return $output;
}
// Initialise variable to ensure we only show error once if trying to render mp3 or flv with basic embedding
static $markup_error_shown = false;
// If file type is flv or mp3 we can't show it without SWF Tools
if (preg_match('@flv|mp3$@i', $flashnode['filepath'])) {
if (!$markup_error_shown) {
drupal_set_message(t('Flash node needs <a href="@swftools">SWF Tools</a> in order to play mp3 or flv files.', array(
'@swftools' => 'http://drupal.org/project/swftools',
)), 'warning');
$markup_error_shown = true;
}
return;
}
// Use t() to substitute parameters in to basic Flash markup
$output = t('<div class="flashnode"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="!width" height="!height" id="myMovieName"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><param name="movie" value="!filepath" /><param name="quality" value="high" /><param name="flashvars" value="!flashvars" /><param name="base" value="!base" /><embed src="!filepath" allowScriptAccess="sameDomain" allowFullScreen="true" quality="high" width="!width" height="!height" flashvars="!flashvars" name="myMovieName" align="" type="application/x-shockwave-flash" base="!base" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>', array(
'!height' => $flashnode['height'],
'!width' => $flashnode['width'],
'!filepath' => file_create_url($flashnode['filepath']),
'!flashvars' => $flashnode['flashvars'],
'!base' => $flashnode['base'],
));
return $output;
}