You are here

function swftools_swftools_embed in SWF Tools 6

Same name and namespace in other branches
  1. 5 swftools.module \swftools_swftools_embed()
  2. 6.2 swftools.module \swftools_swftools_embed()

Implementation of swftools_embed hook Returns the markup for the page. This method generates standards compliant HTML

File

./swftools.module, line 1283

Code

function swftools_swftools_embed($action = 'add_js', $methods = FALSE, $vars = FALSE, $html_alt = '') {
  if ($action == 'add_js') {

    // No javascript stuff for this embed method to do.
    return;
  }

  // IE6 says the page has error when using Wijering 4 media player and if the object isn't given an id
  // The id must be unique for each player, and must start with letters - it cannot be only numbers
  // So let's generate a unique id in the same way we do with SWF Object, and assign it to our object
  $wijering_fix = '';

  // Initialise a counter to give each div a unique id
  static $unique_id = 0;
  $unique_id++;

  // Construct a unique id for each div by using time() combined with $unique_id
  // This is necessary to prevent clashes between cached content
  $id = time() . $unique_id;
  $wijering_fix = ' id="swf' . $id . '"';
  $P = $vars->params;

  // For legibility.
  $width_attr = $P['width'] ? ' width="' . $P['width'] . '"' : '';
  $height_attr = $P['height'] ? ' height="' . $P['height'] . '"' : '';
  $loop = _swftools_tf($P['loop']);
  $menu = _swftools_tf($P['menu']);
  $play = _swftools_tf($P['play']);
  $fullscreen = _swftools_tf($P['allowfullscreen']);
  $flashvars = str_replace('&', '&', $P['flashvars']);
  $id = !empty($vars->othervars['id']) ? ' id="' . $vars->othervars['id'] . '"' : '';
  $name = !empty($vars->othervars['id']) ? ' name="' . $vars->othervars['id'] . '"' : '';
  $swliveconnect = $P['swliveconnect'] ? ' swliveconnect="' . $P['swliveconnect'] . '"' : '';
  $params = $id;
  $params .= '<param name="allowScriptAccess" value="sameDomain" />' . "\n";
  $params .= '<param name="wmode"             value="' . $P['wmode'] . '" />' . "\n";
  $params .= '<param name="bgcolor"           value="' . $P['bgcolor'] . '" />' . "\n";
  $params .= '<param name="scale"             value="' . $P['scale'] . '" />' . "\n";
  $params .= '<param name="quality"           value="' . $P['quality'] . '" />' . "\n";
  $params .= '<param name="align"             value="' . $P['align'] . '" />' . "\n";
  $params .= '<param name="allowfullscreen"   value="' . $P['allowfullscreen'] . '" />' . "\n";
  $params .= '<param name="base"              value="' . $P['base'] . '" />' . "\n";
  $params .= '<param name="play"              value="' . $play . '" />' . "\n";
  $params .= '<param name="menu"              value="' . $menu . '" />' . "\n";
  $params .= '<param name="loop"              value="' . $loop . '" />' . "\n";
  $params .= $flashvars ? '<param name="flashvars"  value="' . $flashvars . '" />' . "\n" : '';
  $html = '<div class="swftools">' . "\n";
  $html .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' . $width_attr . $height_attr . $wijering_fix . '>' . "\n";
  $html .= '<param name="movie" value="' . $P['src'] . '" />' . "\n";
  $html .= $params;
  $html .= '<!--[if gte IE 7]>-->' . "\n";
  $html .= '<object type="application/x-shockwave-flash" data="' . $P['src'] . '"' . $width_attr . $height_attr . '>' . "\n";
  $html .= $params;
  $html .= '<!--<![endif]-->' . "\n";
  $html .= $html_alt . "\n";
  $html .= '<!--[if gte IE 7]>-->' . "\n";
  $html .= '</object>' . "\n";
  $html .= '<!--<![endif]-->' . "\n";
  $html .= '</object>' . "\n";
  $html .= '</div>' . "\n";
  return $html;
}