You are here

function flash_content in Flash Node 5

Function to retrive and inject flash, based on an array of arguments

1 call to flash_content()
flash_filter in ./flash.module
Implementation of hook_filter()

File

./flash.module, line 645

Code

function flash_content($args = array()) {

  // if no $args['nid'], or $arg['nid'] not numeric supplied then return
  if (!is_numeric($args['nid'])) {
    return;
  }

  // get the filepath
  $flash['_flash'] = db_result(db_query("SELECT filepath FROM {files} WHERE filename='%s' AND nid=%d", '_flash', $args['nid']));

  // retrieve parameters associated with this file from {flash}
  $result = db_query("SELECT height, width, version, build, display FROM {flash} WHERE nid=%d", $args['nid']);

  // store all the settings in to the $flash_data
  $result = db_fetch_object($result);
  foreach ($result as $parameter => $value) {
    $flash[$parameter] = $value;
  }

  // remove $args['nid'] from the array
  unset($args['nid']);

  // process scaling and sizing arguments
  if ($args) {
    foreach ($args as $parameter => $value) {
      $xscale = $yscale = 1;
      switch ($parameter) {
        case 'scalewidth':
          if (is_numeric($value)) {
            $xscale = $yscale = $value / $flash['width'];
          }
          break;
        case 'scaleheight':
          if (is_numeric($value)) {
            $xscale = $yscale = $value / $flash['height'];
          }
          break;
        case 'xscale':
          if (is_numeric($value)) {
            $xscale = $value;
          }
          break;
        case 'yscale':
          if (is_numeric($value)) {
            $yscale = $value;
          }
          break;
        case 'scale':
          if (is_numeric($value)) {
            $xscale = $yscale = $value;
          }
          break;
        case 'height':
        case 'width':
          if (is_numeric($value)) {
            $flash[$parameter] = round($value);
          }
          break;
        case 'class':
          $flash['class'] = $value;
          break;
        default:
          $options[] = $parameter . ':"' . $value . '"';
      }
      $flash['width'] = round($flash['width'] * $xscale);
      $flash['height'] = round($flash['height'] * $yscale);
    }
  }
  return flash_display($flash, $options);
}