You are here

function swftools_nodeapi in SWF Tools 6.3

Implementation of hook_nodeapi().

File

upload/swftools_upload.module, line 11
Enables simple integration of SWF Tools with the upload module.

Code

function swftools_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'view':
      if ($node->files && variable_get('swftools_upload_integration', 0)) {
        $extensions = variable_get('swftools_upload_extensions', array(
          'swf',
          'mp3',
          'flv',
        ));
        $swf = '';
        if (count($node->files) == 1) {
          $files = $node->files;
          $file = array_shift($files);
          $extension = strtolower(pathinfo($file->filepath, PATHINFO_EXTENSION));
          if (in_array($extension, $extensions)) {
            $swf = swf($file->filepath);
          }
        }
        else {
          $files = array();
          foreach ($node->files as $key => $file) {
            $extension = strtolower(pathinfo($file->filepath, PATHINFO_EXTENSION));
            if (in_array($extension, $extensions)) {
              $files[$key] = $file;
            }
          }
          if ($files) {
            $swf = swf($files);
          }
        }
        if ($swf) {
          $node->content['swftools_upload_integration']['#value'] = $swf;
          $node->swftools['upload_integration'] = $swf;
        }
      }
  }
}