You are here

function ufo_swftools_embed in SWF Tools 6.2

Same name and namespace in other branches
  1. 5 ufo/ufo.module \ufo_swftools_embed()
  2. 6 ufo/ufo.module \ufo_swftools_embed()

Implementation of swftools_embed hook Returns the markup for the page, plus set necessary javascript.

File

ufo/ufo.module, line 30

Code

function ufo_swftools_embed($action = 'add_js', $methods = FALSE, $vars = FALSE, $html_alt = '') {
  static $ufo_has_run;
  static $ufo_id = 0;

  // Output javascript to the header
  if (!$ufo_has_run) {

    // Add ufo.js
    drupal_add_js(swftools_get_player_path() . '/ufo/ufo.js');
    drupal_add_js(_ufo_header_js(), 'inline', 'header');
    $ufo_has_run = TRUE;
    if ($action == 'add_js') {

      // Exit early having put the javascript in the header.
      return;
    }
  }
  static $unique_id = 0;
  $unique_id++;
  $html = '<div id="ufo-id-' . time() . $unique_id . '" class="swftools ufo" ' . swftools_json_params($vars->params, 'swftools') . ' ' . ">\n" . $html_alt . '</div>';
  return $html;
}