You are here

function theme_swftools in SWF Tools 6.3

Themes an swftools element by passing it on to the appropriate theme function.

This theme function implements the swftools Form API element.

If the incoming element is not an array someone is calling to place a simple swf on the page and they're using the API, so hand it to theme_swftools_api()

If the incoming element is an array, and SWF Tools main module is present then hand the element to swf() as it provides more power, such as auto-detection of sizes and automatic rendering of media in to players.

If the incoming element is an array, and SWF Tools main module is not avaiable then assume we have a simple swf, so call theme_swftools_api() with just $element['#value']

Parameters

mixed $content: A string, or an array, that defines the SWF Tools output required.

string $options: Optional array of other data to pass to SWF Tools.

Return value

string Markup to render the object.

Related topics

File

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

Code

function theme_swftools($content, $options = array()) {

  // If the incoming element is a Forms API element remap it
  if (is_array($content) && isset($content['#value'])) {
    $options = array(
      'params' => $content['#params'],
      'othervars' => $content['#othervars'],
      'flashvars' => $content['#flashvars'],
      'methods' => $content['#methods'],
    );
    $content = $content['#value'];
  }

  // Is the full version of SWF Tools installed?
  if (defined('SWFTOOLS_INSTALLED')) {

    // Hand over to swf() and return the result
    return $content ? swf($content, $options) : '';
  }

  // Hand over to theme_swftools_api and return the result
  return $content ? theme('swftools_api', $content, $options) : '';
}