video_cck.module

Tracking 5.x-1.x branch
  1. drupal
    1. 5 contributions/emfield/contrib/video_cck/video_cck.module

Functions & methods

NameDescription
theme_video_cck_default
theme_video_cck_thickbox
theme_video_cck_video_embed
theme_video_cck_video_preview
theme_video_cck_video_thumbnailThis will return a provided thumbnail image for a video.
theme_video_cck_video_video
video_cck_embed_form
video_cck_emfield_infoImplement hook_emfield_info
video_cck_emfield_rssproviders may supply an enclosure for rss feeds. this expects something in a file format, so would be an object in the format of $file->filepath, $file->filesize, and $file->filemime. calls the providers hook video_cck_PROVIDER_rss($item,…
video_cck_emfield_settingsImplement hook_settings
video_cck_field
video_cck_field_formatterImplementation of hook_field_formatter *
video_cck_field_formatter_infoImplementation of hook_field_formatter_info *
video_cck_field_info
video_cck_field_settings
video_cck_handler_arg_provider
video_cck_menuImplementation of hook_menu().
video_cck_thickboxPage callback for video-cck/thickbox/%node.
video_cck_widget
video_cck_widget_infoImplementation of hook_widget_info *
video_cck_widget_settings

Constants

NameDescription
VIDEO_CCK_DEFAULT_PREVIEW_HEIGHT
VIDEO_CCK_DEFAULT_PREVIEW_WIDTH
VIDEO_CCK_DEFAULT_THUMBNAIL_HEIGHT
VIDEO_CCK_DEFAULT_THUMBNAIL_WIDTH
VIDEO_CCK_DEFAULT_VIDEO_HEIGHT
VIDEO_CCK_DEFAULT_VIDEO_WIDTH

File

View source
  1. <?php
  2. define('VIDEO_CCK_DEFAULT_VIDEO_WIDTH', 425);
  3. define('VIDEO_CCK_DEFAULT_VIDEO_HEIGHT', 350);
  4. define('VIDEO_CCK_DEFAULT_PREVIEW_WIDTH', 425);
  5. define('VIDEO_CCK_DEFAULT_PREVIEW_HEIGHT', 350);
  6. define('VIDEO_CCK_DEFAULT_THUMBNAIL_WIDTH', 120);
  7. define('VIDEO_CCK_DEFAULT_THUMBNAIL_HEIGHT', 90);
  8. /**
  9. * Implement hook_emfield_info
  10. */
  11. function video_cck_emfield_info() {
  12. $name = t('Embedded Video Field');
  13. return array(
  14. '#name' => $name,
  15. '#settings_description' => t('The following settings configure content with any fields controlled by @name.', array('@name' => $name)),
  16. );
  17. }
  18. /**
  19. * Implement hook_settings
  20. */
  21. function video_cck_emfield_settings() {
  22. $form = array();
  23. return $form;
  24. }
  25. /**Implementation of hook_field_info **/
  26. function video_cck_field_info() {
  27. $fields = array(
  28. 'video_cck' => array('label' => t('Embedded Video')),
  29. );
  30. return $fields;
  31. }
  32. /** Implementation of hook_field_settings **/
  33. function video_cck_field_settings($op, $field) {
  34. switch ($op) {
  35. case 'database columns':
  36. $columns = array(
  37. 'embed' => array('type' => 'longtext', 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
  38. 'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
  39. 'provider' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
  40. 'data' => array('type' => 'longtext', 'not null' => TRUE, 'default' => "''", 'sortable' => false),
  41. );
  42. switch ($field['type']) {
  43. case 'video_cck':
  44. break;
  45. }
  46. return $columns;
  47. break;
  48. case 'filters':
  49. return array(
  50. 'not null' => array(
  51. 'name' => t('Has Embedded Video'),
  52. 'operator' => array('=' => t('Has Embedded Video')),
  53. 'list' => 'views_handler_operator_yesno',
  54. 'list-type' => 'select',
  55. 'handler' => 'emfield_views_handler_filter_is_not_null',
  56. 'help' => t('Selecting yes will choose only nodes with this field that successfully provide an embedded video.'),
  57. ),
  58. 'provider' => array(
  59. 'name' => t('Video Provider'),
  60. 'list' => 'emfield_views_handler_filter_provider_list',
  61. 'list-type' => 'list',
  62. 'operator' => 'views_handler_operator_or',
  63. 'value-type' => 'array',
  64. 'handler' => 'emfield_views_handler_filter_provider',
  65. 'help' => t('Include or exclude videos from the selected provider.'),
  66. ),
  67. );
  68. break;
  69. case 'arguments':
  70. return array(
  71. 'content: '. $field['field_name'] => array(
  72. 'name' => t('Embedded Video: @widget (@field)', array('@widget' => $field['widget']['label'], '@field' => $field['field_name'])),
  73. 'handler' => 'content_views_argument_handler',
  74. 'help' => t('This is the default argument handler provided by CCK. It uses the original embed code or URL pasted into the field.'),
  75. ),
  76. 'provider: '. $field['field_name'] => array(
  77. 'name' => t('Embedded Video Provider: @widget (@field)', array('@widget' => $field['widget']['label'], '@field' => $field['field_name'])),
  78. 'handler' => 'video_cck_handler_arg_provider',
  79. 'help' => t('The Embedded Video Provider argument allows users to filter a view by specifying the video provider.'),
  80. ),
  81. );
  82. break;
  83. }
  84. }
  85. //** Implementation of hook_field **/
  86. function video_cck_field($op, &$node, $field, &$items, $teaser, $page) {
  87. if (module_hook('emfield', 'emfield_field')) {
  88. return emfield_emfield_field($op, $node, $field, $items, $teaser, $page, 'video_cck');
  89. }
  90. }
  91. /** Implementation of hook_field_formatter_info **/
  92. function video_cck_field_formatter_info() {
  93. $types = array('video_cck', );
  94. $formats = array(
  95. 'default' => array(
  96. 'label' => t('Default'),
  97. 'field types' => $types,
  98. ),
  99. 'video_video' => array(
  100. 'label' => t('Full Size Video'),
  101. 'field types' => $types,
  102. ),
  103. 'video_preview' => array(
  104. 'label' => t('Preview Video'),
  105. 'field types' => $types,
  106. ),
  107. 'video_thumbnail' => array(
  108. 'label' => t('Image Thumbnail'),
  109. 'field types' => $types,
  110. ),
  111. 'video_embed' => array(
  112. 'label' => t('Embed Code'),
  113. 'field types' => $types,
  114. ),
  115. );
  116. // add thickbox formatter if thickbox module exists
  117. if (module_exists('thickbox')) {
  118. $formats['thickbox'] = array(
  119. 'label' => t('Thickbox: Image Thumbnail -> Full Size Video'),
  120. 'field types' => $types,
  121. );
  122. }
  123. return $formats;
  124. }
  125. /** Implementation of hook_field_formatter **/
  126. function video_cck_field_formatter($field, $item, $formatter, $node) {
  127. return module_invoke('emfield', 'emfield_field_formatter', $field, $item, $formatter, $node, 'video_cck');
  128. }
  129. /** Widgets **/
  130. /** Implementation of hook_widget_info **/
  131. function video_cck_widget_info() {
  132. return array(
  133. 'video_cck_textfields' => array(
  134. 'label' => t('3rd Party Video'),
  135. 'field types' => array('video_cck', ),
  136. ),
  137. );
  138. }
  139. function video_cck_widget_settings($op, $widget) {
  140. switch ($op) {
  141. case 'form':
  142. if ($widget['type'] == 'video_cck_textfields') {
  143. $form = (array)module_invoke('emfield', 'emfield_widget_settings', 'form', $widget, 'video_cck');
  144. $width = variable_get('video_cck_default_video_width', VIDEO_CCK_DEFAULT_VIDEO_WIDTH);
  145. $height = variable_get('video_cck_default_video_height', VIDEO_CCK_DEFAULT_VIDEO_HEIGHT);
  146. $form['video'] = array(
  147. '#type' => 'fieldset',
  148. '#title' => t('Video Display Settings'),
  149. '#description' => t('These settings control how this video is displayed in its full size, which defaults to @widthx@height.', array('@width' => $width, '@height' => $height)),
  150. '#collapsible' => true,
  151. '#collapsed' => false,
  152. );
  153. $form['video']['video_width'] = array(
  154. '#type' => 'textfield',
  155. '#title' => t('Video display width'),
  156. '#default_value' => $widget['video_width'] ? $widget['video_width'] : $width,
  157. '#required' => true,
  158. '#description' => t('The width of the video. It defaults to @width.', array('@width' => $width)),
  159. );
  160. $form['video']['video_height'] = array(
  161. '#type' => 'textfield',
  162. '#title' => t('Video display height'),
  163. '#default_value' => $widget['video_height'] ? $widget['video_height'] : $height,
  164. '#required' => true,
  165. '#description' => t('The height of the video. It defaults to @height.', array('@height' => $height)),
  166. );
  167. $form['video']['video_autoplay'] = array(
  168. '#type' => 'checkbox',
  169. '#title' => t('Autoplay'),
  170. '#default_value' => $widget['video_autoplay'] ? $widget['video_autoplay'] : false,
  171. '#description' => t('If supported by the provider, checking this box will cause the video to automatically begin after the video loads when in its full size.'),
  172. );
  173. $width = variable_get('video_cck_default_preview_width', VIDEO_CCK_DEFAULT_PREVIEW_WIDTH);
  174. $height = variable_get('video_cck_default_preview_height', VIDEO_CCK_DEFAULT_PREVIEW_HEIGHT);
  175. $form['preview'] = array(
  176. '#type' => 'fieldset',
  177. '#title' => t('Video Preview Settings'),
  178. '#description' => t('These settings control how this video is displayed in its preview size, which defaults to @widthx@height.', array('@width' => $width, '@height' => $height)),
  179. '#collapsible' => true,
  180. '#collapsed' => false,
  181. );
  182. $form['preview']['preview_width'] = array(
  183. '#type' => 'textfield',
  184. '#title' => t('Video preview width'),
  185. '#default_value' => $widget['preview_width'] ? $widget['preview_width'] : variable_get('video_cck_default_preview_width', VIDEO_CCK_DEFAULT_PREVIEW_WIDTH),
  186. '#required' => true,
  187. '#description' => t('The width of the preview video. It defaults to @width.', array('@width' => $width)),
  188. );
  189. $form['preview']['preview_height'] = array(
  190. '#type' => 'textfield',
  191. '#title' => t('Video preview height'),
  192. '#default_value' => $widget['preview_height'] ? $widget['preview_height'] : variable_get('video_cck_default_preview_height', VIDEO_CCK_DEFAULT_PREVIEW_HEIGHT),
  193. '#required' => true,
  194. '#description' => t('The height of the preview video. It defaults to @height.', array('@height' => $height)),
  195. );
  196. $form['preview']['preview_autoplay'] = array(
  197. '#type' => 'checkbox',
  198. '#title' => t('Autoplay'),
  199. '#default_value' => $widget['preview_autoplay'] ? $widget['preview_autoplay'] : false,
  200. '#description' => t('If supported by the provider, checking this box will cause the video to automatically begin after the video loads when in its preview size.'),
  201. );
  202. $width = variable_get('video_cck_default_thumbnail_width', VIDEO_CCK_DEFAULT_THUMBNAIL_WIDTH);
  203. $height = variable_get('video_cck_default_thumbnail_height', VIDEO_CCK_DEFAULT_THUMBNAIL_HEIGHT);
  204. $form['tn'] = array(
  205. '#type' => 'fieldset',
  206. '#title' => t('Thumbnail'),
  207. '#description' => t('When displayed as a thumbnail, these settings control the image returned. Note that not all 3rd party video content providers offer thumbnails, and others may require an API key or other requirements. More information from the !settings. The default size for thumbnails is @widthx@height.', array('!settings' => l(t('settings page'), 'admin/content/emfield'), '@width' => $width, '@height' => $height)),
  208. '#collapsible' => true,
  209. '#collapsed' => false,
  210. );
  211. $form['tn']['thumbnail_width'] = array(
  212. '#type' => 'textfield',
  213. '#title' => t('Thumbnail width'),
  214. '#default_value' => $widget['thumbnail_width'] ? $widget['thumbnail_width'] : variable_get('video_cck_default_thumbnail_width', VIDEO_CCK_DEFAULT_THUMBNAIL_WIDTH),
  215. '#required' => true,
  216. '#description' => t('The width of the thumbnail. It defaults to @width.', array('@width' => $width)),
  217. );
  218. $form['tn']['thumbnail_height'] = array(
  219. '#type' => 'textfield',
  220. '#title' => t('Thumbnail height'),
  221. '#default_value' => $widget['thumbnail_height'] ? $widget['thumbnail_height'] : variable_get('video_cck_default_thumbnail_height', VIDEO_CCK_DEFAULT_THUMBNAIL_HEIGHT),
  222. '#required' => true,
  223. '#description' => t('The height of the thumbnail. It defaults to @height.', array('@height' => $height)),
  224. );
  225. if (!module_exists('emthumb')) {
  226. $tn_desc = t(' You may be interested in activating the Embedded Media Thumbnails module as well, which will allow you to specify custom thumbnails on a per-node basis.');
  227. }
  228. $form['tn']['thumbnail_default_path'] = array(
  229. '#type' => 'textfield',
  230. '#title' => t('Default thumbnail path'),
  231. '#default_value' => $widget['thumbnail_default_path'] ? $widget['thumbnail_default_path'] : variable_get('video_cck_default_thumbnail_path', ''),
  232. '#description' => t('Path to a local default thumbnail image for cases when a thumbnail can\'t be found. For example, you might have a default thumbnail at %files.', array('%files' => 'files/thumbnail.png')) . $tn_desc,
  233. );
  234. }
  235. return $form;
  236. case 'validate':
  237. if ($widget['type'] == 'video_cck_textfields') {
  238. if (!is_numeric($widget['video_width']) || intval($widget['video_width']) != $widget['video_width'] || $widget['video_width'] < 1) {
  239. form_set_error('video_width', t('"Video width" must be a positive integer.'));
  240. }
  241. if (!is_numeric($widget['video_height']) || intval($widget['video_height']) != $widget['video_height'] || $widget['video_height'] < 1) {
  242. form_set_error('video_height', t('"Video height" must be a positive integer.'));
  243. }
  244. if (!is_numeric($widget['preview_width']) || intval($widget['preview_width']) != $widget['preview_width'] || $widget['preview_width'] < 1) {
  245. form_set_error('preview_width', t('"Preview width" must be a positive integer.'));
  246. }
  247. if (!is_numeric($widget['preview_height']) || intval($widget['preview_height']) != $widget['preview_height'] || $widget['preview_height'] < 1) {
  248. form_set_error('preview_height', t('"Preview height" must be a positive integer.'));
  249. }
  250. if (!is_numeric($widget['thumbnail_width']) || intval($widget['thumbnail_width']) != $widget['thumbnail_width'] || $widget['thumbnail_width'] < 1) {
  251. form_set_error('thumbnail_width', t('"Thumbnail width" must be a positive integer.'));
  252. }
  253. if (!is_numeric($widget['thumbnail_height']) || intval($widget['thumbnail_height']) != $widget['thumbnail_height'] || $widget['thumbnail_height'] < 1) {
  254. form_set_error('thumbnail_height', t('"Thumbnail height" must be a positive integer.'));
  255. }
  256. }
  257. break;
  258. case 'save':
  259. if ($widget['widget']['type'] == 'video_cck_textfields') {
  260. $columns = array('video_width', 'video_height', 'video_autoplay', 'preview_width', 'preview_height', 'preview_autoplay', 'thumbnail_width', 'thumbnail_height', 'thumbnail_default_path', );
  261. $columns = array_merge($columns, module_invoke('emfield', 'emfield_widget_settings', 'save', $widget, 'video_cck'));
  262. return $columns;
  263. }
  264. break;
  265. }
  266. }
  267. /** Implementation of hook_widget **/
  268. function video_cck_widget($op, &$node, $field, &$node_field) {
  269. if (module_hook('emfield', 'emfield_widget')) {
  270. return emfield_emfield_widget($op, $node, $field, $node_field, 'video_cck');
  271. }
  272. }
  273. function video_cck_embed_form($field, $item, $formatter, $node, $options = array()) {
  274. $embed = $item['value'];
  275. $width = $options['width'] ? $options['width'] : $field['widget']['video_width'];
  276. $height = $options['height'] ? $options['height'] : $field['widget']['video_height'];
  277. $autoplay = $options['autoplay'] ? $options['autoplay'] : $field['widget']['video_autoplay'];
  278. $text = module_invoke('emfield', 'include_invoke', 'video_cck', $item['provider'], 'video', $embed, $width, $height, $field, $item, $autoplay);
  279. $form = array();
  280. $form['video_cck_embed'] = array(
  281. '#type' => 'textarea',
  282. '#title' => t('Embed Code'),
  283. '#description' => t('To embed this video on your own site, simply copy and paste the html code from this text area.'),
  284. '#default_value' => $text,
  285. );
  286. return $form;
  287. }
  288. /**
  289. * providers may supply an enclosure for rss feeds. this expects something in a file format, so would be an object
  290. * in the format of $file->filepath, $file->filesize, and $file->filemime.
  291. * calls the providers hook video_cck_PROVIDER_rss($item, $teaser)
  292. */
  293. function video_cck_emfield_rss($node, $items = array(), $teaser = NULL) {
  294. $rss_data = array();
  295. foreach ($items as $item) {
  296. // note only the first $item will get an RSS enclosure, other items may have media: data in the feed however
  297. if ($item['value'] && $item['provider']) {
  298. $rss_data[] = module_invoke('emfield', 'include_invoke', 'video_cck', $item['provider'], 'rss', $item, $teaser);
  299. }
  300. }
  301. return $rss_data;
  302. }
  303. function theme_video_cck_video_embed($field, $item, $formatter, $node, $options = array()) {
  304. /*
  305. Note you can use this in node.tpl.php, substituting the proper field type:
  306. $field_type = 'field_video';
  307. $system_types = _content_type_info();
  308. $field = $system_types['fields'][$field_type];
  309. $field['widget'] = $system_types['content types'][$node->type]['fields'][$field_type]['widget'];
  310. print theme('video_cck_video_embed', $field, $node->{$field_type}[0], 'video_cck_embed', $node);
  311. or you can set $field to NULL and just use the options array
  312. */
  313. if ($item['value'] && $item['provider']) {
  314. $output = drupal_get_form('video_cck_embed_form', $field, $item, $formatter, $node, $options);
  315. }
  316. return $output;
  317. }
  318. /**
  319. * This will return a provided thumbnail image for a video.
  320. *
  321. * @param $field
  322. * This is the field providing settings for the video thumbnail.
  323. * @param $item
  324. * This is the data returned by the field. It requires at the least to be an array with 'value' and 'provider'.
  325. * $item['value'] will be the video code, and $item['provider'] will be the provider, such as youtube.
  326. * @param $formatter
  327. * This is the formatter for the view. This will nearly always be video_thumbnail.
  328. * @param $node
  329. * This is the node object containing the field.
  330. * @param $no_link
  331. * optional. if FALSE, then we provide a link to the node. (In retrospect, this should have been $link, defaulting to TRUE. TODO: fix? problem though is that this goes deeper up the tree.)
  332. * @param $options
  333. * optional array. this is to pass optional overrides. currently:
  334. * $options['width'] and $options['height'], if provided, will override any field settings for the thumbnail w/h.
  335. * $options['link_url'], if provided, will cause the thumbnail link to go to another URL other than node/nid. $no_link must be FALSE.
  336. * $options['link_title'], if provided, will set the title of the link when no image is provided. otherwise, it defaults to 'See video'.
  337. * $options['image_title'], if provided, will set the title attribute of the href link, defaulting to $options['link_title'].
  338. * $options['image_alt'], if provided, will set the alt attribute of the href link, defaulting to $options['link_title'].
  339. * $options['thumbnail_url'], if provided, will completely override the thumbnail image entirely.
  340. */
  341. function theme_video_cck_video_thumbnail($field, $item, $formatter, $node, $no_link = FALSE, $options = array()) {
  342. // Sometime in the past, we added the $no_link argument before $options.
  343. // However, emfield.module attempts to call this w/o $no_link at line 341.
  344. if (is_array($no_link) && empty($options)) {
  345. $options = $no_link;
  346. }
  347. if (is_array($no_link)) {
  348. $no_link = FALSE;
  349. }
  350. $options['node'] = $node;
  351. if ($item['value'] && $item['provider']) {
  352. // if we've set $options['thumbnail_url'], then we'll just use that.
  353. // otherwise, if we have emthumb installed, then give it a chance to override our thumbnail
  354. $thumbnail_url = $options['thumbnail_url'] ? $options['thumbnail_url'] : module_invoke('emthumb', 'thumbnail_url', $item);
  355. // if we don't have a custom thumbnail, then see if the provider gives us a thumbnail
  356. $thumbnail_url = $thumbnail_url ? $thumbnail_url : module_invoke('emfield', 'include_invoke', 'video_cck', $item['provider'], 'thumbnail', $field, $item, $formatter, $node, $width, $height, $options);
  357. // if we still don't have a thumbnail, then apply a default thumbnail, if it exists
  358. if (!$thumbnail_url) {
  359. $default_thumbnail_url = $field['widget']['thumbnail_default_path'] ? $field['widget']['thumbnail_default_path'] : variable_get('video_cck_default_thumbnail_path', NULL);
  360. if ($default_thumbnail_url) {
  361. $thumbnail_url = base_path() . $default_thumbnail_url;
  362. }
  363. }
  364. }
  365. else {
  366. // seems to be an unknown video
  367. // apply a default thumbnail, if it exists
  368. if (!$thumbnail_url) {
  369. $default_thumbnail_url = $field['widget']['thumbnail_default_path'] ? $field['widget']['thumbnail_default_path'] : variable_get('video_cck_default_thumbnail_path', NULL);
  370. if ($default_thumbnail_url) {
  371. $thumbnail_url = base_path() . $default_thumbnail_url;
  372. }
  373. }
  374. }
  375. $link_url = isset($options['link_url']) ? $options['link_url'] : 'node/'. $node->nid;
  376. $link_title = isset($options['link_title']) ? $options['link_title'] : t('See video');
  377. $image_title = isset($options['image_title']) ? $options['image_title'] : $link_title;
  378. $image_alt = isset($options['image_alt']) ? $options['image_alt'] : $link_title;
  379. if ($thumbnail_url) {
  380. $width = isset($options['width']) ? $options['width'] : NULL;
  381. $width = isset($width) ? $width : ($field['widget']['thumbnail_width'] ? $field['widget']['thumbnail_width'] : variable_get('video_cck_default_thumbnail_width', VIDEO_CCK_DEFAULT_THUMBNAIL_WIDTH));
  382. $height = isset($options['height']) ? $options['height'] : NULL;
  383. $height = isset($height) ? $height : ($field['widget']['thumbnail_height'] ? $field['widget']['thumbnail_height'] : variable_get('video_cck_default_thumbnail_height', VIDEO_CCK_DEFAULT_THUMBNAIL_HEIGHT));
  384. if ($no_link) { //thickbox requires the thumbnail returned without the link
  385. $output = '<img src="'. $thumbnail_url .'" width="'. $width .'" height="'. $height .'" alt="'. $image_alt .'" title="'. $image_title .'" />';
  386. }
  387. else {
  388. $output = l('<img src="'. $thumbnail_url .'" width="'. $width .'" height="'. $height .'" alt="'. $image_alt .'" title="'. $image_title .'" />', $link_url, array(), NULL, NULL, false, true);
  389. }
  390. }
  391. else {
  392. // if all else fails, then just print a 'see video' link.
  393. if ($no_link) {
  394. $output = ''; //thickbox won't work without a thumbnail
  395. }
  396. else if ($item['value'] && $item['provider']) {
  397. $output = l($link_title, $link_url);
  398. }
  399. else {
  400. $output = '';
  401. }
  402. }
  403. return $output;
  404. }
  405. function theme_video_cck_video_video($field, $item, $formatter, $node, $options = array()) {
  406. if ($item['value'] && $item['provider']) {
  407. $embed = $item['value'];
  408. $width = isset($options['width']) ? $options['width'] : (isset($field['widget']['video_width']) ? $field['widget']['video_width'] : variable_get('video_cck_default_video_width', VIDEO_CCK_DEFAULT_VIDEO_WIDTH));
  409. $height = isset($options['height']) ? $options['height'] : (isset($field['widget']['video_height']) ? $field['widget']['video_height'] : variable_get('video_cck_default_video_height', VIDEO_CCK_DEFAULT_VIDEO_HEIGHT));
  410. $autoplay = isset($options['autoplay']) ? $options['autoplay'] : $field['widget']['video_autoplay'];
  411. $options['node'] = $node;
  412. $output = module_invoke('emfield', 'include_invoke', 'video_cck', $item['provider'], 'video', $embed, $width, $height, $field, $item, $autoplay, $options);
  413. }
  414. return $output;
  415. }
  416. function theme_video_cck_default($field, $item, $formatter, $node, $options = array()) {
  417. return theme('video_cck_video_video', $field, $item, $formatter, $node, $options);
  418. }
  419. function theme_video_cck_video_preview($field, $item, $formatter, $node, $options = array()) {
  420. if ($item['value'] && $item['provider']) {
  421. $embed = $item['value'];
  422. $width = isset($options['width']) ? $options['width'] : (isset($field['widget']['preview_width']) ? $field['widget']['preview_width'] : variable_get('video_cck_default_preview_width', VIDEO_CCK_DEFAULT_PREVIEW_WIDTH));
  423. $height = isset($options['height']) ? $options['height'] : (isset($field['widget']['preview_height']) ? $field['widget']['preview_height'] : variable_get('video_cck_default_preview_height', VIDEO_CCK_DEFAULT_PREVIEW_HEIGHT));
  424. $autoplay = isset($options['autoplay']) ? $options['autoplay'] : $field['widget']['preview_autoplay'];
  425. $options['node'] = $node;
  426. $output = module_invoke('emfield', 'include_invoke', 'video_cck', $item['provider'], 'preview', $embed, $width, $height, $field, $item, $autoplay, $options);
  427. }
  428. return $output;
  429. }
  430. function theme_video_cck_thickbox($field, $item, $formatter, $node, $options = array()) {
  431. $thumbnail = theme('video_cck_video_thumbnail', $field, $item, 'video_thumbnail', $node, true, $options);
  432. $width = isset($options['width']) ? $options['width'] : (isset($field['widget']['video_width']) ? $field['widget']['video_width'] : variable_get('video_cck_default_video_width', VIDEO_CCK_DEFAULT_VIDEO_WIDTH));
  433. $height = isset($options['height']) ? $options['height'] : (isset($field['widget']['video_height']) ? $field['widget']['video_height'] : variable_get('video_cck_default_video_height', VIDEO_CCK_DEFAULT_VIDEO_HEIGHT));
  434. $field_name = isset($options['field_name']) ? $options['field_name'] : $field['field_name'];
  435. $type_name = isset($options['type_name']) ? $options['type_name'] : $field['type_name'];
  436. $title = isset($options['title']) ? $options['title'] : $node->title;
  437. $destination = 'video-cck/thickbox/'. $node->nid .'/'. $width .'/'. $height .'/'. $field_name;
  438. $output = l($thumbnail, $destination, array('title' => $title, 'class' => 'thickbox', 'rel' => $type_name), NULL, NULL, FALSE, TRUE);
  439. return $output;
  440. }
  441. function video_cck_handler_arg_provider($op, &$query, $argtype, $arg = '') {
  442. return _emfield_handler_arg_provider($op, $query, $argtype, $arg, 'video_cck');
  443. }
  444. /**
  445. * Implementation of hook_menu().
  446. */
  447. function video_cck_menu($may_cache) {
  448. $items = array();
  449. if (module_exists('thickbox')) {
  450. if (!$may_cache) {
  451. if (arg(0) == 'video-cck' && arg(1) == 'thickbox' && is_numeric(arg(2))) {
  452. $node = node_load(arg(2));
  453. if ($node->nid) {
  454. $items[] = array(
  455. 'path' => 'video-cck/thickbox/'. arg(2),
  456. 'callback' => 'video_cck_thickbox',
  457. 'callback arguments' => array($node),
  458. 'access' => node_access('view', $node),
  459. 'type' => MENU_CALLBACK,
  460. );
  461. }
  462. }
  463. }
  464. }
  465. return $items;
  466. }
  467. /**
  468. * Page callback for video-cck/thickbox/%node.
  469. */
  470. function video_cck_thickbox($node, $width, $height, $field_name) {
  471. $field = array();
  472. $field['widget']['video_width'] = $width;
  473. $field['widget']['video_height'] = $height;
  474. $field['widget']['video_autoplay'] = 1;
  475. $field['field_name'] = $field_name;
  476. $items = $node->$field_name;
  477. $item = $items[0];
  478. $type = $node->type;
  479. // Respect any field access permissions.
  480. if (module_exists('cck_field_perms') && $types = variable_get('cfp_types', null)) {
  481. if ($types[$type]) {
  482. $disallowed_fields = unserialize(variable_get('cfp_values', null));
  483. if ($disallowed_fields && $disallowed_fields[$type][$field_name] != 0) {
  484. if (!(user_access(_cfp_content_to_readable($type, $disallowed_field, 'view')))) {
  485. drupal_access_denied();
  486. return;
  487. }
  488. }
  489. }
  490. }
  491. print theme('video_cck_video_video', $field, $item, 'video_video', $node);
  492. }