diff options
author | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2006-06-18 14:41:32 +0000 |
---|---|---|
committer | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2006-06-18 14:41:32 +0000 |
commit | bff6fafe62a4201c99bdba20144313276d654bca (patch) | |
tree | 3f58c4adad06446274c6e842f9f9fb6155ba4b34 /plugins/video_image | |
parent | 2540b23c26f79ed8b223d6ec8b00ca4bfc76e7ef (diff) | |
download | video-bff6fafe62a4201c99bdba20144313276d654bca.tar.gz video-bff6fafe62a4201c99bdba20144313276d654bca.tar.bz2 |
List of changes:
Pluginization:
Video.module file was too big and complex.
I isolated each different feature which was not
excencial and removed from the video.module file.
Those features are now added by helper modules
called plugins under the directory "plugins".
The download has been separed from multidownload.
There is now a separated plugin called video_multidownload
which add multidownload feature.
There are also some hooks being defined.
See file hooks.php for details.
XHTML Compliace:
I worked hard to remove unvalid code from video module.
Now the code generated by the module validates on W3C validator.
This will probæbly generate some problems with uncommon browsers
we will try to solve them as soon as reported.
Thanks a lot to Karl Rudd who point me to the right direction
towards compliace.
Thumbnailing:
There is plugin called video_image.module which add thumbnails
support for the video module. Thumbnails are uploaded throught the
video creation form and a image node is created with it.
Video file Uploads:
There is a plugin called video_upload.module which add a file
upload field to the node creation form. The uploaded file is
automatically set as path of the video. Then usable for plays/downloads.
NOTE ON BUGS:
I tryed to test new features the most as possible but I can't guarantee
that all this code is bugfree. Video module is becaming too big to be
tested by only one person (me).
Hope you guys will be able to help with debugging.
Fabio
Diffstat (limited to 'plugins/video_image')
-rw-r--r-- | plugins/video_image/video_image.module | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/plugins/video_image/video_image.module b/plugins/video_image/video_image.module new file mode 100644 index 0000000..59795cf --- /dev/null +++ b/plugins/video_image/video_image.module @@ -0,0 +1,145 @@ +<?php +// $Id$ + +/** + * @file + * Enable image support for video module. + * + * @author Fabio Varesano <fvaresano at yahoo dot it> + */ + + +/** + * Implementation of hook_help(). + */ +function video_image_help($section) { + switch ($section) { + case 'admin/modules#description': + return t('Enable thumbnails support for video module.'); + } +} + + +/** + * Implementation of hook_form_alter() + */ +function video_image_form_alter($form_id, &$form) { + + if($form_id == 'video_node_form' && isset($form['video'])) { + + $form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Use this form to upload an image.')); + + + if (function_exists('_image_check_settings')) { + _image_check_settings(); + $node = $form['#node']; + $form['#attributes'] = array("enctype" => "multipart/form-data"); + + if ($node->iid) { + $image = node_load($node->iid); + $form['image']['image_thumbnail'] = array('#type' => 'item', '#title' => t('Thumbnail'), '#value' => image_display($image, 'thumbnail')); + } + $value = ($node->new_image) ? '#value' : '#default_value'; + $form['image']['iid'] = array('#type' => 'hidden' , $value => $node->iid); + $form['image']['image'] = array('#type' => 'file', '#title' => t('Image')); + $form['image']['image_title'] = array('#type' => 'textfield', '#title' => t('Image title'), '#default_value' => ''); + } + } + +} + + +/** + * Implementation of hook_nodeapi() + */ +function video_image_nodeapi(&$node, $op, $teaser) { + if($node->type == 'video') { + switch ($op) { + case 'submit': + $node->serial_data['iid'] = $node->iid; + break; + case 'prepare': + $image->title = $_POST['edit']['image_title']; + $image->uid = $node->uid; + $image->name = $node->name; + $image->created = $node->created; + $image->type = 'image'; + image_prepare($image, 'image'); + if ($image->images) { + node_validate($image); + if (!form_get_errors()) { + $image = node_submit($image); + node_save($image); + $node->iid = $image->nid; + $node->new_image = TRUE; + } + } + elseif ($_POST['edit']['iid']) { + $node->iid = $_POST['edit']['iid']; + } + break; + + case 'view': + //print_r($node); + if($teaser) { + if ($node->serial_data['image_teaser'] || $node->serial_data['iid']) { //If we are dealing with a teaser. + $node->teaser = theme('video_image_teaser', $node); + } + } + else { + if ($node->serial_data['image_view'] || $node->serial_data['iid']) { + $node->body = theme('video_image_body', $node) . $node->body; + } + } + break; + } + } +} + + +/** + * Render the output for the node teaser. + * + * @param $node + * object with node information + * + * @return + * string of content to display + */ +function theme_video_image_teaser($node) { + if($node->serial_data['iid']) { + $image = node_load($node->serial_data['iid']); + $image = image_display($image, 'thumbnail', array('class' => 'video_image_teaser')); + } + else { + $image = theme('image', $node->serial_data['image_teaser'], $node->title, $node->title, array('class' => 'video_image_teaser'), FALSE); + } + $output .= l($image, "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); //Create a link with an image in it. + $output .= $node->teaser . '<br class="video_image_clear" />'; + return $output; +} + + +/** + * Generates the image HTML displayed in the Node body. + * + * @param $node + * object with node information + * + * @return + * string of content to display + */ +function theme_video_image_body($node) { + if($node->serial_data['iid']) { + $image = node_load($node->serial_data['iid']); + $image = image_display($image, 'thumbnail'); + } + else { // only for backward compatibility + $image = theme('image', $node->serial_data['image_view'], $node->title, $node->title, array('class' => 'video_image_view'), FALSE); //Create image HTML + } + $output = l($image, "node/$node->nid/play", array('title' => t('play') . ' ' . $node->title), NULL, NULL, FALSE, TRUE); //Create link HTML with image in it. + + return $output; +} + +?> |