| 1 |
<?php
|
| 2 |
/* $Id: class_video.inc,v 1.36 2007/05/05 21:32:48 vhmauery Exp $ */
|
| 3 |
|
| 4 |
/*
|
| 5 |
Acidfree Photo Albums for Drupal
|
| 6 |
Copyright (C) 2005 Vernon Mauery
|
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify
|
| 9 |
it under the terms of the GNU General Public License as published by
|
| 10 |
the Free Software Foundation; either version 2 of the License, or
|
| 11 |
(at your option) any later version.
|
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful,
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
GNU General Public License for more details.
|
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License
|
| 19 |
along with this program; if not, write to the Free Software
|
| 20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
| 21 |
*/
|
| 22 |
|
| 23 |
/**
|
| 24 |
* @file
|
| 25 |
* The is the class implementation of the photo. All the acidfree elements
|
| 26 |
* must be defined in this same manner, which makes creating a new class
|
| 27 |
* relatively simple -- copy one of the existing classes and modify the
|
| 28 |
* relevant functions.
|
| 29 |
*/
|
| 30 |
|
| 31 |
require_once('image_manip.inc');
|
| 32 |
|
| 33 |
function class_video_register() {
|
| 34 |
$class = new stdClass();
|
| 35 |
if (!module_exists('video')) {
|
| 36 |
return $class;
|
| 37 |
}
|
| 38 |
$class->class = 'video';
|
| 39 |
$class->name = t('video');
|
| 40 |
$class->addme = t('Add a video');
|
| 41 |
$class->max_size = 4*(1 << 20);
|
| 42 |
$class->mime_ext = Array(
|
| 43 |
'video/x-msvideo'=>'avi',
|
| 44 |
'video/mpeg'=>'mpg',
|
| 45 |
'video/mp4'=>'mp4',
|
| 46 |
'video/quicktime'=>'mov',
|
| 47 |
'audio/x-pn-realaudio'=>'rm',
|
| 48 |
'audio/x-realaudio'=>'rm',
|
| 49 |
'application/vnd.rn-realmedia'=>'rm',
|
| 50 |
'video/x-ms-wmv'=>'wmv',
|
| 51 |
'video/x-ms-asf'=>'asf',
|
| 52 |
'video/3gpp'=>'3gp',
|
| 53 |
);
|
| 54 |
$class->form_alter = '_class_video_form_alter';
|
| 55 |
$class->nodeapi = '_class_video_nodeapi';
|
| 56 |
$class->access = 'create video';
|
| 57 |
return $class;
|
| 58 |
}
|
| 59 |
|
| 60 |
function theme_acidfree_print_thumb_video(&$node, $parent=null) {
|
| 61 |
$vid = acidfree_get_vocab_id();
|
| 62 |
if (count($node->taxonomy[$vid]) > 1 && $parent) {
|
| 63 |
$p = "pid={$parent->tid}";
|
| 64 |
}
|
| 65 |
$image_node = acidfree_get_node_by_id($node->iid);
|
| 66 |
$info = image_get_info(file_create_path($image_node->images['thumbnail']));
|
| 67 |
|
| 68 |
$image = _acidfree_image_display($image_node, 'thumbnail', array('width' => $info['width'], 'height' => $info['height']));
|
| 69 |
|
| 70 |
$h = $info['height'] + variable_get('acidfree_extra_length',12);
|
| 71 |
$w = $info['width'] + variable_get('acidfree_extra_length',12);
|
| 72 |
|
| 73 |
$overlay = l('', "node/{$node->nid}", array('title' => $node->title), $p, NULL, true, true);
|
| 74 |
$image = l($image, "node/{$node->nid}", array('title' => $node->title), $p, NULL, true, true);
|
| 75 |
$title = l($node->title, "node/{$node->nid}", array('title' => $node->title), $p, NULL, true, true);
|
| 76 |
|
| 77 |
$videodiv = '<div class="acidfree-cell"><div class="acidfree-item acidfree-video">';
|
| 78 |
$videodiv .= "<div class='acidfree-thumbnail' style='width: {$w}px; height: {$h}px;'>";
|
| 79 |
$videodiv .= $image . '<div class="acidfree-overlay">' . $overlay . '</div></div>';
|
| 80 |
$videodiv .= "<p>$title</p></div></div>";
|
| 81 |
return $videodiv;
|
| 82 |
}
|
| 83 |
|
| 84 |
function _class_video_form_alter($form_id, &$form) {
|
| 85 |
$form['taxonomy']['#weight'] = -19;
|
| 86 |
$vid = acidfree_get_vocab_id();
|
| 87 |
if (($arg = _path_match('node', 'add', 'video', '%d'))) {
|
| 88 |
$album = acidfree_get_node_by_id($arg[0]);
|
| 89 |
$form['taxonomy'][$vid]['#default_value'] = array($album->tid);
|
| 90 |
}
|
| 91 |
_acidfree_filter_taxonomy($form['taxonomy'][$vid]);
|
| 92 |
unset($form['log']);
|
| 93 |
if (_path_match('album', '%d', 'contents')) {
|
| 94 |
$form['video']['#collapsible'] = true;
|
| 95 |
$form['video']['#collapsed'] = true;
|
| 96 |
}
|
| 97 |
$form['body_filter']['body']['#rows'] = 5;
|
| 98 |
$attributes = array('onchange' => 'set_title(this.value);');
|
| 99 |
if (isset($form['video']['video_upload_file'])) {
|
| 100 |
$form['video']['video_upload_file']['#attributes'] =
|
| 101 |
is_array($form['video']['video_upload_file']['#attributes']) ?
|
| 102 |
array_merge($attributes, $form['video']['video_upload_file']['#attributes']):$attributes;
|
| 103 |
} else if(isset($form['video']['video_upload']['video_upload_file'])) {
|
| 104 |
$form['video']['video_upload']['video_upload_file']['#attributes'] =
|
| 105 |
is_array($form['video']['video_upload']['video_upload_file']['#attributes']) ?
|
| 106 |
array_merge($attributes, $form['video']['video_upload']['video_upload_file']['#attributes']):$attributes;
|
| 107 |
} else {
|
| 108 |
//dump_msg($form);
|
| 109 |
}
|
| 110 |
if (($arg = _path_match('album', '%d', 'contents'))) {
|
| 111 |
$form['body'] = $form['body_filter']['body'];
|
| 112 |
unset($form['body_filter']);
|
| 113 |
unset($form['video_upload_file']);
|
| 114 |
unset($form['preview']);
|
| 115 |
unset($form['image']);
|
| 116 |
}
|
| 117 |
|
| 118 |
}
|
| 119 |
|
| 120 |
function theme_acidfree_view_video($node) {
|
| 121 |
$image_node = acidfree_get_node_by_id($node->iid);
|
| 122 |
$info = image_get_info(file_create_path($image_node->images['preview']));
|
| 123 |
|
| 124 |
$image = _acidfree_image_display($image_node, 'preview', array('width' => $info['width'], 'height' => $info['height']));
|
| 125 |
|
| 126 |
$h = $info['height'] + variable_get('acidfree_extra_length',12);
|
| 127 |
$w = $info['width'] + variable_get('acidfree_extra_length',12);
|
| 128 |
|
| 129 |
$path = "node/{$node->nid}/play";
|
| 130 |
$overlay = l('', $path, array('title' => $node->title), $p, NULL, true, true);
|
| 131 |
$image = l($image, $path, array('title' => $node->title), $p, NULL, true, true);
|
| 132 |
$title = l($node->title, $path, array('title' => $node->title), $p, NULL, true, true);
|
| 133 |
|
| 134 |
$videodiv = '<div class="acidfree-item acidfree-video">';
|
| 135 |
$videodiv .= "<div class='acidfree-preview' style='width: {$w}px; height: {$h}px;'>";
|
| 136 |
$videodiv .= $image . '<div class="acidfree-overlay">' . $overlay . '</div></div>';
|
| 137 |
$videodiv .= "<p>$title</p></div>";
|
| 138 |
return $videodiv;
|
| 139 |
}
|
| 140 |
|
| 141 |
function _class_video_view_alter(&$node) {
|
| 142 |
// dump_msg($node->content);
|
| 143 |
if (isset($node->content['video_image_thumbnail']) && !variable_get('video_playinbody',0)) {
|
| 144 |
$new_image = theme('acidfree_view_video', $node);
|
| 145 |
$node->content['video_image_thumbnail']['#value'] = $new_image;
|
| 146 |
}
|
| 147 |
}
|
| 148 |
?>
|