You are here

function theme_emfield_swfobject in Embedded Media Field 6.2

Same name and namespace in other branches
  1. 6.3 deprecated/emfield-deprecated.themes.inc \theme_emfield_swfobject()
  2. 6 includes/themes/emfield.themes.inc \theme_emfield_swfobject()

Theme function to add a flash file to the page.

The actual returned HTML from this function is minimal. Its main purpose is to setup the Javascript properly on content which is cached by input filters

Parameters

$url: A web accessible url to the flash file.

$params: An associative array of parameters that describe the SWF.

$vars: An associative array of variables to pass through to the SWF flashvars value.

$id: An id to appened to the so object.

$attributes: Associative array of attributes to apply to the resulting flash tag (embed, object, etc.)

File

includes/themes/emfield.themes.inc, line 26
Basic theme functions for Embedded Media Field.

Code

function theme_emfield_swfobject($url, $params = array(), $vars = array(), $id = NULL, $attributes = array()) {

  // Defer to the SWFObject API module.
  if (module_exists('swfobject_api')) {
    return theme('swfobject_api', $url, $params, $vars, $id, $attributes);
  }

  // We're in trouble if we don't have swfobject.js installed at this point.
  if (!variable_get('emfield_swfobject_location', '')) {
    return '';
  }

  // keep track of each div ID
  static $swfobject_id = 1;

  // Build the base params.
  $base_params = array(
    'width' => '100%',
    'height' => '100%',
    'no_flash' => t('Sorry, you need to install flash to see this content.'),
    'version' => variable_get('swfoa_settings_version', '6'),
    'type' => 'movie',
    'bgcolor' => '#FFFFFF',
    'express_redirect' => FALSE,
    //     'express_redirect' => variable_get('swfoa_settings_express', TRUE) ? drupal_get_path('module', 'swfobject_api') .'/expressinstall.swf' : 'false',
    'class' => '',
  );

  // Merge in default parameters.
  $params += $base_params;

  // Increment the div id to allow for multiple players on the page
  $div_id = empty($id) ? 'emfield-swfobject-' . $swfobject_id++ : $id;

  // are the no_flash parameters being passed with a filter?
  if (is_array($params['no_flash'])) {
    $params['no_flash'] = check_markup($params['no_flash']['text'], $params['no_flash']['filter']);
  }

  // assign param data to the specific parameters
  $height = $params['height'];
  $width = $params['width'];
  $express_redirect = $params['express_redirect'];
  $version = $params['version'];
  $bgcolor = $params['bgcolor'];
  $no_flash = $params['no_flash'];
  $class = implode(' ', array(
    $params['class'],
    'swfobject',
  ));
  unset($params['height'], $params['width'], $params['express_redirect'], $params['version'], $params['bg_color'], $params['no_flash'], $params['class']);
  $settings['swfobject_api']['files'][$div_id] = array(
    'url' => $url,
    'params' => $params,
    'flashVars' => $vars,
    'attributes' => $attributes,
    'height' => $height,
    'width' => $width,
    'express_redirect' => $express_redirect,
    'version' => $version,
    'bgcolor' => $bg_color,
  );

  // add the JS to the page
  _emfield_swfobject_api_ensure_swfobject($settings);

  // Return the placeholder HTML that will normally get
  // replaced with flash content.
  return "<div id=\"{$div_id}\" class=\"{$class}\">{$no_flash}</div>\n";
}