You are here

cck_video.module in CCK Video 6

Same filename and directory in other branches
  1. 7 cck_video.module

File

cck_video.module
View source
<?php

// $Id$

//==========================================//

// DEFINING A FORMATTER

//==========================================//

/**
 * Implementation of hook_field_formatter_info().
 * 
 * All fields should have a 'default' formatter.
 * Any number of other formatters can be defined as well.
 * It's nice for there always to be a 'plain' option
 * for the raw value, but that is not required.
 * 
 */

// CONTENT_HANDLE_CORE:   CCK will pass the formatter a single value.
// CONTENT_HANDLE_MODULE: CCK will pass the formatter an array of all the values.
// None of CCK's core formatters use multiple values, that is an option available to other modules that want it.
function cck_video_field_formatter_info() {
  $formatters = array(
    'video' => array(
      'label' => t('Video'),
      'field types' => array(
        'filefield',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
      'weight' => 20,
    ),
  );
  return $formatters;
}

/**
 * Theme function for 'default' example field formatter.
 * 
 * $element['#item']: the sanitized $delta value for the item,
 * $element['#field_name']: the field name,
 * $element['#type_name']: the $node->type,
 * $element['#formatter']: the $formatter_name,
 * $element'#node']: the $node,
 * $element['#delta']: the delta of this item, like '0',
 * 
 */

/**
 * Implementation of hook_theme().
 */
function cck_video_theme() {
  $theme = array(
    'cck_video_formatter_video' => array(
      'arguments' => array(
        'element' => NULL,
      ),
    ),
  );
  return $theme;
}

/*
function theme_cck_video_formatter_default($element) {
  return $element['#item']['safe'];
}
*/

/**
 * Theme function for 'plain' example field formatter.
 */
function theme_cck_video_formatter_video($element) {
  global $base_path;

  /*
   [fid] => 4 [uid] => 1 [filename] => How To Make A Squid Dish.flv
   [filepath] => sites/default/files/video_file/How To Make A Squid Dish.flv
   [filemime] => video/x-flv [filesize] => 6071896 [status] => 1 [timestamp] => 1330828845
   [list] => 1 [data] => [nid] => 5 [#delta] => 0 )
  */
  $player = $base_path . drupal_get_path('module', 'cck_video') . '/player/mediaplayer/player.swf';
  $file_video = file_create_url($element['#item'][filepath]);
  $output = '<div class="cck-video">';
  $output .= '<object type="application/x-shockwave-flash" width="320" height="240" wmode="transparent"
                data="' . $player . '?file=' . $file_video . '&autoStart=false">
                <param name="movie" value="' . $player . '?file=' . $file_video . '&autoStart=false" />
                <param name="wmode" value="transparent" />
              </object>';
  $output .= '</div>';
  return $output;
}

Functions

Namesort descending Description
cck_video_field_formatter_info
cck_video_theme Implementation of hook_theme().
theme_cck_video_formatter_video Theme function for 'plain' example field formatter.