You are here

function theme_swftools_direct in SWF Tools 6.3

Turns an SWF Tools data array in to markup for inclusion on the page, using W3C compliant HTML.

Parameters

string $file: The path to the file to be displayed.

array $data: An array of additional parameters associated with this item.

Return value

string A markup string.

Related topics

File

includes/swftools.core.inc, line 63
Implements SWF Tools core functions that are common to the main module and the API module.

Code

function theme_swftools_direct($file, $data) {

  // Strip out unset values, e.g. bgcolor
  $data['params'] = array_filter($data['params']);

  // Build parameters string
  $params = '';
  foreach ($data['params'] as $key => $value) {
    $params .= '<param name="' . check_plain($key) . '" value="' . check_plain($value) . '" />';
  }

  // Attach flashvars parameter, if flashvars are present
  // drupal_query_string_encode() implodes with & which breaks XHTML validation. See #1011402.
  //  $params .= $data['flashvars'] ? '<param name="flashvars" value="' . drupal_query_string_encode($data['flashvars']) . '" />' : '';
  $params .= $data['flashvars'] ? '<param name="flashvars" value="' . swftools_query_string_encode($data['flashvars']) . '" />' : '';

  // Construct embedding markup
  $html = '<object id="' . $data['othervars']['id'] . '" name="' . $data['othervars']['id'] . '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' . $data['othervars']['width'] . '" height="' . $data['othervars']['height'] . '">';
  $html .= '<param name="movie" value="' . $file . '" />';
  $html .= $params;
  $html .= '<!--[if gte IE 7]>-->';
  $html .= '<object name="' . $data['othervars']['id'] . '" type="application/x-shockwave-flash" data="' . $file . '" width="' . $data['othervars']['width'] . '" height="' . $data['othervars']['height'] . '">';
  $html .= $params;
  $html .= '<!--<![endif]-->';
  $html .= theme('swftools_html_alt', $data);
  $html .= '<!--[if gte IE 7]>-->';
  $html .= '</object>';
  $html .= '<!--<![endif]-->';
  $html .= '</object>';

  // Return the result
  return $html;
}