? .video.module.swp ? patches Index: video.module =================================================================== --- video.module.orig 2007-05-07 16:27:55.000000000 -0700 +++ video.module 2007-05-08 10:08:48.000000000 -0700 @@ -109,7 +109,7 @@ $menu_type = MENU_LOCAL_TASK; } else { - $menu_type = MENU_CALLBACK; + $menu_type = MENU_CALLBACK; } $items[] = array('path' => 'node/'. arg(1) .'/play', 'title' => t('play'), @@ -141,17 +141,6 @@ /** - * Implementation of hook_init() - * Currently just does a check for whether the views module exists and, - * if it does loads the video views module. - */ -function video_init() { - if (module_exists('views')) { - include(drupal_get_path('module', 'video') .'/views_video.inc'); - } -} - -/** * Internal Drupal links hook * * @param $type @@ -199,7 +188,7 @@ ); } - } + } if ($display_download_link == 1) { $link['video_download'] = array( 'title' => t('download'), @@ -660,13 +649,11 @@ if (isset($node->videoy) && $node->videoy <= 0) { form_set_error('videoy', t('You have to insert a valid vertical pixel size for this video')); } + //Make sure file size is valid. + if ((!isset($node->size) || !is_numeric($node->size) || $node->size < 0) && !$node->video_upload_file_path) { //If the file is not local or not a valid number then set error. + form_set_error('size', t('You have to insert a valid file size for this video.')); + } } - //Make sure file size is valid. - $path = getcwd() . '/' . $node->vidfile; //Local path to video file. - if ((!isset($node->size) || !is_numeric($node->size) || $node->size < 0) && !$_SESSION['video_upload_file']) { //If the file is not local or not a valid number then set error. $_SESSION check needed for video_upload functionality - form_set_error('size', t('You have to insert a valid file size for this video.')); - } - //Makes sure the total playtime is greater than 0. $time = $node->playtime_seconds + $node->playtime_minutes + $node->playtime_hours; if ((isset($node->playtime_minutes) and isset($node->playtime_hours) and isset($node->playtime_seconds)) and $time == 0) { @@ -713,19 +700,19 @@ // if we are viewing the page, run the body through the theme if ($page) { $output = ''; - if (variable_get('video_playinbody', 0)) { - if (user_access('play video')) { + if (variable_get('video_playinbody', 0)) { + if (user_access('play video')) { $output .= theme('video_player', $node); } - else { - $output .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account'))); + else { + $output .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account'))); $output .= ' ' . t('or') . ' '; $output .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account'))); $output .= t(' to play video'); } - } + } $output .= theme('video_view', $node, $teaser, $page); - $node->content['body'] = array('#value' => $output); + $node->content['body'] = array('#value' => $output); } return $node; @@ -882,7 +869,7 @@ function video_play() { if ($node = node_load(arg(1))) { drupal_set_title(t('Playing') . ' ' . theme('placeholder', $node->title)); - $output = theme('video_player', $node); + $output = theme('video_player', $node); if($output == ''){ drupal_goto("node/$node->nid"); } @@ -1127,12 +1114,12 @@ $output = ' '. "\n"; - // this will be executed by not Internet Explorer browsers + // this will be executed by not Internet Explorer browsers $output = ' '."\n"; - - $output .= ''."\n"; + + $output .= ''."\n"; $output .= ''."\n"; $output .= ''; $output = _theme_video_format_play($output,t('http://www.divx.com/divx/webplayer/'), @@ -1689,3 +1676,9 @@ } return $output; } + +/* include the views info if view module is enabled */ +if (module_exists('views')) { + include(drupal_get_path('module', 'video') .'/views_video.inc'); +} + Index: plugins/video_ffmpeg_helper/video_ffmpeg_helper.module =================================================================== --- plugins/video_ffmpeg_helper/video_ffmpeg_helper.module.orig 2007-05-07 16:27:55.000000000 -0700 +++ plugins/video_ffmpeg_helper/video_ffmpeg_helper.module 2007-05-07 16:28:03.000000000 -0700 @@ -61,10 +61,10 @@ if (!is_numeric($form_values['video_ffmpeg_helper_auto_thumbnail_seek'])) { form_set_error('video_ffmpeg_helper_auto_thumbnail_seek', t('Seek time must be an integer')); } - $options = $form_values['video_ffmpeg_helper_thumbnailer_options']; - if (!strstr($options, '%videofile') || !strstr($options, '%thumbfile')) { - form_set_error('video_ffmpeg_helper_thumbnailer_options', t('Thumbnail options must contain mandatory arguments %videofile and %thumbfile')); - } + $options = $form_values['video_ffmpeg_helper_thumbnailer_options']; + if (!strstr($options, '%videofile') || !strstr($options, '%thumbfile')) { + form_set_error('video_ffmpeg_helper_thumbnailer_options', t('Thumbnail options must contain mandatory arguments %videofile and %thumbfile')); + } } } @@ -282,7 +282,7 @@ * Add a video conversion rendering process to the queue */ function _video_ffmpeg_helper_add_rendering(&$node) { - $file = $_SESSION['video_upload_file_stored']->filepath; + $file = $node->video_upload_file_path; //print_r($node); die; db_query('INSERT INTO {video_rendering} (vid, nid, origfile, pid, status, started, completed) VALUES (%d, %d, "%s", %d, %d, %d, %d)', $node->vid, $node->nid, $file, 0, VIDEO_RENDERING_PENDING, 0, 0); @@ -300,7 +300,7 @@ function _video_ffmpeg_helper_get_video_info(&$node) { // escape file name for safety - $file = escapeshellarg($_SESSION['video_upload_file']->filepath); + $file = escapeshellarg($node->video_upload_file_path); // create the full command to execute $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $file; @@ -361,18 +361,20 @@ * a drupal file object */ function _video_ffmpeg_helper_auto_thumbnail(&$node) { - if(empty($_SESSION['video_upload_file']) || - !$_SESSION['video_upload_file']->newfile || - $node->iid || $_SESSION['video_upload_file']->iid || - $_SESSION['video_upload_file']->thumbnailed) { - if (variable_get('video_image_auto_thumbnail_debug', false)) { - if (empty($_SESSION['video_upload_file'])) + $debug = variable_get('video_ffmpeg_helper_auto_thumbnail_debug', false); + if(empty($node->video_upload_file_path) || + $node->thumbnailed || !$node->new_vidfile) { + if ($debug) { + if (empty($node->video_upload_file_path)) drupal_set_message(t('no video has been uploaded: make sure that video_image weight is greater than video_upload weight; make sure that the video file is not too large to be uploaded.')); + else if ($node->thumbnailed) + drupal_set_message(t('not thumbnailing: video has already been thumbnailed')); + else if (!$node->new_vidfile) + drupal_set_message(t('not thumbnailing: video file was not newly uploaded')); } return null; } - $debug = variable_get('video_image_auto_thumbnail_debug', false); - $videofile = escapeshellarg($_SESSION['video_upload_file']->filepath); + $videofile = escapeshellarg($node->video_upload_file_path); $thumbfile = tempnam(file_directory_temp(), 'tnail-thumb'); $seek = variable_get('video_image_auto_thumbnail_seek', 2); $tnail = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg'); @@ -392,13 +394,13 @@ drupal_set_message(t('video_image_auto_thumbnail: file %file does not exist', array('%file' => $thumbfile)), 'error'); } $file = array( - 'filename' => $_SESSION['video_upload_file']->filename . ".video-thumb.jpg", + 'filename' => basename($node->video_upload_file_path) . ".video-thumb.jpg", 'filemime' => 'image/jpeg', 'filesize' => filesize($thumbfile), 'filepath' => $thumbfile, 'nid' => $node->nid, ); - $_SESSION['video_upload_file']->thumbnailed = TRUE; + $node->thumbnailed = true; if ($debug) { if ($tnail_return) { drupal_set_message(t('Failed to thumbnail video')); Index: plugins/video_image/video_image.module =================================================================== --- plugins/video_image/video_image.module.orig 2007-05-07 16:27:55.000000000 -0700 +++ plugins/video_image/video_image.module 2007-05-07 21:04:57.000000000 -0700 @@ -100,50 +100,47 @@ case 'load': $output['iid'] = $node->serial_data['iid']; return $output; - case 'submit': - if (variable_get('video_image_auto_thumbnail_debug', false) && variable_get('video_image_auto_thumbnail', false)) { - drupal_set_message(t('video_image_nodeapi: prepare: ready to thumbnail image')); - } - $field_name = file_check_upload('image'); - $image->uid = $node->uid; - $image->name = $node->name; - $image->created = $node->created; - $image->type = 'image'; - //$image->status = _video_image_publish_thumbnails(); - //$image->promote = _video_image_promote_thumbnails(); - if (!$field_name && module_exists('video_ffmpeg_helper') && variable_get('video_ffmpeg_helper_auto_thumbnail', false)) { - $image->title = $_SESSION['video_upload_file']->filename; - $field_name = _video_ffmpeg_helper_auto_thumbnail($node); - } - else { - $image->title = $_POST['edit']['image_title']; - $field_name = 'image'; - } - image_prepare($image, $field_name); - if ($image->images) { - node_validate($image); - if (!form_get_errors()) { - $image = node_submit($image); - node_save($image); - - // needed to set the correct status and promote values if the user does not have enought permissions. Is there a better solution??? - db_query('UPDATE {node} SET status = %d, promote = %d WHERE nid = %d AND vid = %d', _video_image_publish_thumbnails(), _video_image_promote_thumbnails(), $image->nid, $image->vid); - - $node->iid = $node->serial_data['iid'] = $image->nid; - $_SESSION['video_upload_file']->iid = $image->nid; - $node->new_image = TRUE; - } - } - else if (isset($_SESSION['video_upload_file']->iid)) { - $node->iid = $_SESSION['video_upload_file']->iid; - } - - $node->serial_data['iid'] = $node->iid; - break; case 'prepare': - ; + if ((variable_get('video_ffmpeg_helper_auto_thumbnail', false) && $node->new_vidfile) + || $field_name = file_check_upload('image')) { + if (variable_get('video_ffmpeg_helper_auto_thumbnail_debug', false) && variable_get('video_ffmpeg_helper_auto_thumbnail', false)) { + drupal_set_message(t('video_image_nodeapi: prepare: ready to thumbnail video')); + } + $image->uid = $node->uid; + $image->name = $node->name; + $image->created = $node->created; + $image->type = 'image'; + //$image->status = _video_image_publish_thumbnails(); + //$image->promote = _video_image_promote_thumbnails(); + if (!$field_name && module_exists('video_ffmpeg_helper') && variable_get('video_ffmpeg_helper_auto_thumbnail', false)) { + $image->title = basename($node->video_upload_file_path); + $field_name = _video_ffmpeg_helper_auto_thumbnail($node); + } + else { + $image->title = $_POST['edit']['image_title']; + $field_name = 'image'; + } + image_prepare($image, $field_name); + if ($image->images) { + node_validate($image); + if (!form_get_errors()) { + $image = node_submit($image); + node_save($image); + + // needed to set the correct status and promote values if the user does not have enought permissions. Is there a better solution??? + db_query('UPDATE {node} SET status = %d, promote = %d WHERE nid = %d AND vid = %d', _video_image_publish_thumbnails(), _video_image_promote_thumbnails(), $image->nid, $image->vid); + + $node->iid = $image->nid; + $node->new_image = TRUE; + } + } + } break; + case 'submit': + $node->serial_data['iid'] = $node->iid; + break; + case 'view': if ($node->iid) { if($teaser) { Index: plugins/video_upload/video_upload.module =================================================================== --- plugins/video_upload/video_upload.module.orig 2007-05-07 16:27:55.000000000 -0700 +++ plugins/video_upload/video_upload.module 2007-05-08 10:10:22.000000000 -0700 @@ -1,5 +1,6 @@ type == 'video') { switch ($op) { @@ -89,7 +90,7 @@ return $output; case 'prepare': - _video_upload_prepare($node); + _video_upload_prepare($node, $arg); break; case 'validate': @@ -184,61 +185,45 @@ * Validate video file */ function _video_upload_validate(&$node) { - // if we override the default video module vidfile field and we don't have a file uploaded set error - if (user_access('upload video files') && variable_get('video_upload_override_vidfile', false) && !isset($node->video_upload_file) && !isset($_SESSION['video_upload_file'])) { - form_set_error('video_upload_file', t('A file must be provided.')); - return; - } } function _video_upload_submit(&$node) { - ; } -function _video_upload_prepare(&$node) { - // clear video file informations - if(count($_POST) == 0) { - if (!empty($_SESSION['video_upload_file'])) { - file_delete($_SESSION['video_upload_file']->filepath); - } - unset($_SESSION['video_upload_file']); +function _video_upload_prepare(&$node, $field_name=null) { + if (is_null($field_name)) { + $field_name = 'video_upload_file'; } - - - if ($file = file_check_upload('video_upload_file')) { + if ($file = file_check_upload($field_name)) { $temppath = file_directory_temp() . '/video/'; file_check_directory($temppath, TRUE); $node->video_upload_file = file_save_upload($file, $temppath .'/'. $file->filename, FILE_EXISTS_REPLACE); - $node->video_upload_file->newfile = TRUE; + $node->new_vidfile = true; + $node->video_upload_file_path = $node->video_upload_file->filepath; // set video size $node->size = $node->video_upload_file->filesize; - - $_SESSION['video_upload_file'] = $node->video_upload_file; - } - else if (!empty($_SESSION['video_upload_file'])) { - $node->video_upload_file = $_SESSION['video_upload_file']; - // set video size - $node->size = $node->video_upload_file->filesize; - - } else { - $_SESSION['video_upload_file'] = $node->video_upload_file; } } function _video_upload_store(&$node) { - if(!empty($_SESSION['video_upload_file'])) { - $file = $_SESSION['video_upload_file']; + if(!empty($node->video_upload_file_path)) { + $file = new stdClass(); + $file->filepath = $node->video_upload_file_path; + $file->filename = basename($file->filepath); + $file->filesize = filesize($file->filepath); + $file->vidfile = $file->filepath; + $file->filemime = _video_get_mime_type($file); + $node->video_upload_file = $file; $dest_dir = variable_get('video_upload_default_path', 'videos') .'/'; if ($file = file_save_upload($file, $dest_dir . $file->filename)) { $file->fid = db_next_id('{files}_fid'); db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize); db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $node->vid, $file->list, $file->description); - $_SESSION['video_upload_file_stored'] = $file; - unset($_SESSION['video_upload_file']); + $node->video_upload_file_stored = $file; } else { drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error'); @@ -264,7 +249,7 @@ /** * Create video upload specific form fields */ -function _video_upload_form($node) { +function _video_upload_form(&$node) { _video_upload_check_settings(); $form = array(); @@ -277,14 +262,24 @@ '#description' => t('The uploaded file will be used as video file for this node.
NOTE: The max upload size is') . ' ' . format_size(_video_upload_get_max_upload_size()) . '.', ); - if (isset($node->video_upload_file)) { - $form['video_upload_file']['#prefix'] = theme('video_upload_file_info_form', $node); - $form['video_upload_file']['#title'] = t('Replace with'); + $form['video_upload_file_info']['#after_build'][] = 'video_upload_add_info'; + if ($node->new_vidfile) { + $form['video_upload_file_path'] = array('#type' => 'hidden', '#value' => $node->video_upload_file->filepath); + } + else { + $form['video_upload_file_path'] = array('#type' => 'hidden', '#default_value' => $node->video_upload_file->filepath); } return $form; } +function video_upload_add_info($form_id, $edit) { + if ($edit['video_upload_file_path']) { + $node = (object)($edit); + $form = array('#type' => 'item', '#title' => t('Video information:'), '#value' => theme('video_upload_file_info_form', $node), '#weight' => -10); + } + return $form; +} /** * Display informations about already uploaded file