From 8cd94d3aabb438fc8efa275c1b57e44d33e2fac5 Mon Sep 17 00:00:00 2001 From: Heshan Wanigasooriya Date: Wed, 27 May 2009 01:48:29 +0000 Subject: updating 6--2 dev --- LICENSE.txt | 275 ++++++++++++++++++++ hooks.php | 1 + includes/apiclient.inc | 1 + includes/common.inc | 2 +- .../video_ffmpeg_helper/video_ffmpeg_helper.info | 4 +- .../video_ffmpeg_helper.install | 43 ++- .../video_ffmpeg_helper/video_ffmpeg_helper.module | 5 +- plugins/video_ffmpeg_helper/video_render.php | 2 +- plugins/video_ffmpeg_helper/video_scheduler.php | 2 +- plugins/video_image/video_image.info | 4 +- plugins/video_image/video_image.module | 46 ++-- .../video_multidownload/video_multidownload.info | 3 +- .../video_multidownload/video_multidownload.module | 1 + plugins/video_optmetadata/video_optmetadata.info | 4 +- plugins/video_optmetadata/video_optmetadata.module | 2 +- plugins/video_params/video_params.info | 4 +- plugins/video_params/video_params.module | 1 + types/video_google/video_google.info | 4 +- types/video_google/video_google.module | 1 + types/video_upload/video_upload.info | 2 +- types/video_upload/video_upload.install | 65 +++++ types/video_upload/video_upload.module | 288 +++++---------------- types/video_url/video_url.info | 3 +- types/video_url/video_url.module | 1 + types/video_youtube/video_youtube.info | 3 +- types/video_youtube/video_youtube.module | 1 + video.css | 1 + video.info | 4 +- video.install | 237 ++++------------- video.module | 129 +++++---- views_video.inc | 1 + 31 files changed, 615 insertions(+), 525 deletions(-) create mode 100644 LICENSE.txt create mode 100644 types/video_upload/video_upload.install diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b1102a4 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,275 @@ +//$Id$ +GNU GENERAL PUBLIC LICENSE + + Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, +Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute +verbatim copies of this license document, but changing it is not allowed. + + Preamble + +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free software--to +make sure the software is free for all its users. This General Public License +applies to most of the Free Software Foundation's software and to any other +program whose authors commit to using it. (Some other Free Software +Foundation software is covered by the GNU Library General Public License +instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the +freedom to distribute copies of free software (and charge for this service if +you wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must make +sure that they, too, receive or can get the source code. And you must show +them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients +to know that what they have is not the original, so that any problems +introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND + MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such +program or work, and a "work based on the Program" means either the +Program or any derivative work under copyright law: that is to say, a work +containing the Program or a portion of it, either verbatim or with +modifications and/or translated into another language. (Hereinafter, translation +is included without limitation in the term "modification".) Each licensee is +addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program is +not restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made +by running the Program). Whether that is true depends on what the Program +does. + +1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that you +also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in +part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. + +c) If the modified program normally reads commands interactively when run, +you must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print such +an announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be +reasonably considered independent and separate works in themselves, then +this License, and its terms, do not apply to those sections when you distribute +them as separate works. But when you distribute the same sections as part +of a whole which is a work based on the Program, the distribution of the +whole must be on the terms of this License, whose permissions for other +licensees extend to the entire whole, and thus to each and every part +regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to +work written entirely by you; rather, the intent is to exercise the right to +control the distribution of derivative or collective works based on the +Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of a +storage or distribution medium does not bring the other work under the scope +of this License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 +and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source +code, which must be distributed under the terms of Sections 1 and 2 above +on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on +a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for +noncommercial distribution and only if you received the program in object +code or executable form with such an offer, in accord with Subsection b +above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source code +means all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation and +installation of the executable. However, as a special exception, the source +code distributed need not include anything that is normally distributed (in +either source or binary form) with the major components (compiler, kernel, +and so on) of the operating system on which the executable runs, unless that +component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source along with the +object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, +modify, sublicense or distribute the Program is void, and will automatically +terminate your rights under this License. However, parties who have received +copies, or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the +Program (or any work based on the Program), you indicate your acceptance +of this License to do so, and all its terms and conditions for copying, +distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these terms and +conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In such +case, this License incorporates the limitation as if written in the body of this +License. + +9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will be +similar in spirit to the present version, but may differ in detail to address new +problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that +version or of any later version published by the Free Software Foundation. If +the Program does not specify a version number of this License, you may +choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make +exceptions for this. Our decision will be guided by the two goals of +preserving the free status of all derivatives of our free software and of +promoting the sharing and reuse of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT +PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR +AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR +ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, +SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES +SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE +PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN +IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/hooks.php b/hooks.php index af33b82..951ec62 100644 --- a/hooks.php +++ b/hooks.php @@ -1,4 +1,5 @@ - * porting to Drupal 6 - * @author Heshan Wanigasooriya + * @author Heshan Wanigasooriya + * * @todo */ @@ -14,64 +14,83 @@ */ function video_ffmpeg_helper_schema() { $schema['video_rendering'] = array( - 'description' => t('TODO'), + 'description' => t('Store video transcoding queue'), 'fields' => array( 'vid' => array( - 'description' => t('TODO'), + 'description' => t('video id : primary key'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'nid' => array( - 'description' => t('TODO'), + 'description' => t('Node id : index of the {node}.nid'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'fid' => array( + 'description' => t('FIle id, index to the {files}.fid'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'origfile' => array( - 'description' => t('TODO'), + 'description' => t('original file path'), 'type' => 'text', 'not null' => TRUE, 'default' => '', ), 'pid' => array( - 'description' => t('TODO'), + 'description' => t('Pid'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'status' => array( - 'description' => t('TODO'), + 'description' => t('status of the transcoding'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'started' => array( - 'description' => t('TODO'), + 'description' => t('Started transcodings'), 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), 'completed' => array( - 'description' => t('TODO'), + 'description' => t('Transcoding completed'), 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), ), + 'indexes' => array( + 'fid' => array('fid'), + 'nid' => array('nid'), + ), 'primary key' => array('vid'), ); return $schema; } - +/** + * Implementation of hook_install(). + */ function video_ffmpeg_helper_install() { // Create tables. drupal_install_schema('video_ffmpeg_helper'); } +/** + * Implementation of hook_uninstall(). + */ +function video_ffmpeg_helper_uninstall() { + drupal_uninstall_schema('video_ffmpeg_helper'); +} \ No newline at end of file diff --git a/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module b/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module index 446058d..b22a0f4 100644 --- a/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module +++ b/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module @@ -1,5 +1,5 @@ new_video_upload_file && !$node->new_video_upload_file_fid) { // no new files uploaded. skipping auto resolution process - return null; - } if(variable_get('video_ffmpeg_helper_auto_resolution', false)) { diff --git a/plugins/video_ffmpeg_helper/video_render.php b/plugins/video_ffmpeg_helper/video_render.php index bba9220..83bae31 100644 --- a/plugins/video_ffmpeg_helper/video_render.php +++ b/plugins/video_ffmpeg_helper/video_render.php @@ -1,5 +1,5 @@ - * porting to Drupal 6 - * @author Heshan Wanigasooriya + * @author Heshan Wanigasooriya + * * @todo + * implement the help of the video upload (Implement the internal hook for the help video_upload_v_help()). */ @@ -179,6 +178,7 @@ function video_image_form_alter(&$form, &$form_state, $form_id) { function video_image_nodeapi(&$node, $op, $teaser) { //print_r($op); //exit; + //db_query("INSERT INTO {op} (id, name) VALUES (%d, '%s')", NULL, $op); if($node->type == 'video') { switch ($op) { case 'load': @@ -192,7 +192,7 @@ function video_image_nodeapi(&$node, $op, $teaser) { case 'presave': //exit; - _video_image_submit($node); + _video_image_presave($node); break; case 'view': @@ -273,11 +273,9 @@ function _video_image_prepare(&$node) { } } -function _video_image_submit(&$node) { - //print_r($node); - //exit; - // ############# PREPARE ####################### - // ------------- MOVED ------------------------- +function _video_image_presave(&$node) { + + // ############# PREPARE ####################### if (count($_POST)) { $validators = array( @@ -295,19 +293,7 @@ function _video_image_submit(&$node) { } if ($field_name) { - /* - if($node->iid){ - - // Remove all the existing images. - $result = db_query("SELECT f.fid, f.filepath FROM {image} i INNER JOIN {files} f ON i.fid = f.fid WHERE i.nid = %d", $node->iid); - while ($file = db_fetch_object($result)) { - file_delete(file_create_path($file->filepath)); - db_query("DELETE FROM {files} WHERE fid = %d", $file->fid); - } - //db_query("DELETE FROM {image} WHERE nid = %d", $node->iid); - } - * - */ + $node->tempimage = _video_image_temp_image_store($field_name); $node->new_image = TRUE; //print_r($node); @@ -430,8 +416,11 @@ function _video_image_thumbnail_debug($msg) { } function _video_image_temp_image_store(&$file) { + // Update the node to reflect the actual filename, it may have been changed + $image = new stdClass(); $image->images[IMAGE_ORIGINAL] = $file->filepath; + //using image module $image->images =_image_build_derivatives($image); $image->type = 'image'; $image->uid = 1; @@ -451,11 +440,12 @@ function _video_image_temp_image_store(&$file) { // save the images in the files table foreach ($image->images as $l => $f) { $info = image_get_info($f); - $file->fid = db_last_insert_id('files','fid'); - if($l=="_original"){ + $original_path = $node->images[IMAGE_ORIGINAL]; + if (file_move($file->filepath, _image_filename($original_path, $size))) { + $file->fid = db_last_insert_id('files','fid'); db_query("INSERT INTO {files} (fid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', '%s')", $fid, "video_image_temp.$l", $f, $info['mime_type'], $info['file_size']); - } + } $image->fids[$l] = $file->fid; } } diff --git a/plugins/video_multidownload/video_multidownload.info b/plugins/video_multidownload/video_multidownload.info index eac3f33..5c87e9c 100644 --- a/plugins/video_multidownload/video_multidownload.info +++ b/plugins/video_multidownload/video_multidownload.info @@ -1,5 +1,6 @@ +;$Id$ name = Video Multidownload description = Enable multiple file download in video module. dependencies[] = video package = "Video" -core = 6.x \ No newline at end of file +core = 6.x diff --git a/plugins/video_multidownload/video_multidownload.module b/plugins/video_multidownload/video_multidownload.module index 1d3a245..682caba 100644 --- a/plugins/video_multidownload/video_multidownload.module +++ b/plugins/video_multidownload/video_multidownload.module @@ -1,4 +1,5 @@ + * + * @todo + */ + +/** + * Implementation of hook_schema(). + */ +function video_upload_schema() { + $schema['video_upload'] = array( + 'description' => t('Store video upload files'), + 'fields' => array( + 'vid' => array( + 'description' => t('video id : primary key'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'nid' => array( + 'description' => t('Node id : index of the {node}.nid'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'fid' => array( + 'description' => t('FIle id, index to the {files}.fid'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'indexes' => array( + 'fid' => array('fid'), + 'nid' => array('nid'), + ), + 'primary key' => array('vid'), + ); + + return $schema; +} + +/** + * Implementation of hook_install(). + */ +function video_upload_install() { + // Create tables. + drupal_install_schema('video_upload'); + // add video_upload_allowed_extensions variable mpeg, avi, wmv etc +} + +/** + * Implementation of hook_uninstall(). + */ +function video_upload_uninstall() { + drupal_uninstall_schema('video_upload'); +} \ No newline at end of file diff --git a/types/video_upload/video_upload.module b/types/video_upload/video_upload.module index 4dc0630..9ed5310 100644 --- a/types/video_upload/video_upload.module +++ b/types/video_upload/video_upload.module @@ -1,14 +1,12 @@ - * @contributor Vernon Mauery - * porting to Drupal 6 - * @author Heshan Wanigasooriya + * @author Heshan Wanigasooriya + * * @todo + * implement the help of the video upload (Implement the internal hook for the help video_upload_v_help()). */ @@ -17,22 +15,19 @@ */ function video_upload_menu() { $items = array(); - $maycache = true; - if($maycache) { - $items['node/add/video/upload'] = array( - 'title' => 'Upload', - 'access arguments' => array('create video') - ); - $items['admin/settings/video/upload'] = array( - 'title' => 'Upload', - 'description' => 'Configure various settings of the video upload plugin.', - 'access arguments' => array('administer site configuration'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('video_upload_admin_settings'), - 'type' => MENU_NORMAL_ITEM, - ); - } + $items['node/add/video/upload'] = array( + 'title' => 'Upload', + 'access arguments' => array('create video') + ); + $items['admin/settings/video/upload'] = array( + 'title' => 'Upload', + 'description' => 'Configure various settings of the video upload plugin.', + 'access arguments' => array('administer site configuration'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('video_upload_admin_settings'), + 'type' => MENU_NORMAL_ITEM, + ); return $items; } @@ -252,7 +247,8 @@ function video_upload_v_form(&$node, &$form) { /** * Implementation of hook_nodeapi() */ -function video_upload_nodeapi(&$node, $op) { +function video_upload_nodeapi(&$node, $op, $teaser, $page) { + if($node->type == 'video' && $node->vtype == 'upload') { switch ($op) { @@ -262,6 +258,7 @@ function video_upload_nodeapi(&$node, $op) { //print_r($node); //exit; return _video_upload_load($node); + break; case 'prepare': //exit; @@ -275,22 +272,13 @@ function video_upload_nodeapi(&$node, $op) { case 'presave': //exit; - //_video_upload_submit($node); - break; - - case 'submit': - // exit; - - //_video_upload_submit($node); + _video_upload_presave($node); break; case 'insert': - //exit; - //print_r($node); - //exit; - //_video_upload_submit($node); - //_video_upload_insert($node); - _video_upload_validate($node); + + _video_upload_insert($node); + ////_video_upload_validate($node); break; case 'update': @@ -318,10 +306,8 @@ function video_upload_nodeapi(&$node, $op) { function _video_upload_load(&$node) { - //print 'load'; - //print_r($node); - //exit; - $fileBuf = db_fetch_object(db_query('SELECT fid FROM {upload} WHERE nid = %d', $node->nid)); + + $fileBuf = db_fetch_object(db_query('SELECT fid FROM {video_upload} WHERE nid = %d', $node->nid)); $output = array(); $output['video_fid'] = $fileBuf->fid; $file = _video_upload_get_file($output['video_fid']); @@ -342,50 +328,9 @@ for some hints */ function _video_upload_prepare(&$node) { - //print 'prepare'; - //exit; + if (!count($_POST)) return; - //print 'prepare'; - //print_r($node); - //exit; - if (is_object($node->video_upload_file)) { - $file_field = $node->video_upload_file; - } else { - $file_field = 'video_upload_file'; - } - -/* TODO Modify the validators array to suit your needs. - This array is used in the revised file_save_upload */ - $validators = array( - 'file_validate_is_image' => array(), - 'file_validate_image_resolution' => array('85x85'), - 'file_validate_size' => array(30 * 1024), - ); - - if (count($_POST) && $file = file_save_upload($file_field , $validators) ){ // a file has been uploaded - // this is the temp directory to store files - $temppath = file_directory_temp() . '/video/'; - // let's check that the directory is good - file_check_directory($temppath, TRUE); - // let's save the uploaded file to the temp directory - $file = file_save_upload($file, $temppath . '/' . $file->filename, FILE_EXISTS_REPLACE); - - // let's store the temp file into the DB - $file->fid = db_last_insert_id('files','fid'); - db_query("INSERT INTO {files} (fid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', %d)", $file->fid, 'video_upload_temp.'.$file->filename, $file->filepath, $file->filemime, $file->filesize); - - // TODO: delete here the previous $node->new_video_upload_file - - $node->new_video_upload_file = $file; - } - else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Submit') { - $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - } - else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Preview') { - $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - - } } /** @@ -403,7 +348,7 @@ function _video_upload_form(&$node) { $we_have_video = true; } else { - $form['new_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => 0); + //$form['new_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => 0); if($node->current_video_upload_file) { // we don't have a new file $form['current_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => $node->current_video_upload_file->fid); $form['current_video_upload_file_info'] = array('#type' => 'item', '#value' => theme('video_upload_file_info_form', $node->current_video_upload_file, $node), '#weight' => -10); @@ -411,6 +356,7 @@ function _video_upload_form(&$node) { $we_have_video = true; } } + $form['new_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => 0); $form['video_upload_file'] = array( '#type' => 'file', '#title' => $we_have_video ? t('Replace with') : t('Upload video file'), @@ -427,97 +373,49 @@ function _video_upload_form(&$node) { /** * Validate video file */ -function _video_upload_validate(&$node) { - //print 'validate'; +function video_upload_v_validate(&$node) { + // in Drupal 6 version all file size and the type validations are done by the file API's +} + + +function _video_upload_presave(&$node) { + //print 'submit'; + //print_r($node); die; - //##################### PREPARE ########################## - + // ####### Prepare by moving file to the temp location and then checking the validations of fields + if (is_object($node->video_upload_file)) { $file_field = $node->video_upload_file; } else { $file_field = 'video_upload_file'; } -/* TODO Modify the validators array to suit your needs. - This array is used in the revised file_save_upload - $validators = array( - 'file_validate_is_image' => array(), - 'file_validate_image_resolution' => array('85x85'), - 'file_validate_size' => array(30 * 1024), - ); -*/ - // get extention list + // get extention array $extentions = explode(",",variable_get('video_upload_allowed_extensions', 'mov,flv,wmv')); $validators = array( - 'file_validate_extensions' => array(variable_get('video_upload_allowed_extensions', 'mov,flv,wmv')) + 'file_validate_extensions' => array( 'csv' ), ); - // TODO : add file sixe validation + // TODO : add file size validation // 'file_validate_size' => array($limits['file_size'], $limits['user_size']), - - if (count($_POST) && $file = file_save_upload($file_field , $validators) ){ // a file has been uploaded - - // this is the temp directory to store files - //$temppath = file_directory_temp() . '/video/'; - // let's check that the directory is good - //file_check_directory($temppath, TRUE); - // let's save the uploaded file to the temp directory - //$file = file_save_upload($file, $validators, $temppath . '/' . $file->filename, FILE_EXISTS_REPLACE); - - //TODO : set status value - //$status=0; - // let's store the temp file into the DB - //$file->fid = db_last_insert_id('files','fid'); - //db_query("INSERT INTO {files} (fid, filename, filepath, filemime, filesize,status) VALUES (%d, '%s', '%s', '%s', %d, %d)", $file->fid, 'video_upload_temp.'.$file->filename, $file->filepath, $file->filemime, $file->filesize, $file->status); - - // TODO: delete here the previous $node->new_video_upload_file - //print_r($file); - //exit; - $node->new_video_upload_file = $file->fid; + + if (count($_POST) && $file = file_save_upload($file_field , array('file_validate_extensions' => array('zip')))) { // a file has been uploaded + $node->new_video_upload_file = $file; $node->new_video_upload_file_fid = $file->fid; + //print_r($file); + //exit; } else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Submit') { $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); } else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Preview') { $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - } - //print_r($node); - //exit; - //######################################################### + //$node->new_video_upload_file_fid = $file->fid; - if(!($node->new_file_uploaded || $node->new_video_upload_file_fid > 0 || $node->new_video_upload_file_fid > 0 || $node->current_video_upload_file_fid > 0)) { // - form_set_error('video_upload_file', t('You have not provided any video file. Please upload one.
If you uploaded a video but the system did not received it, please check that it is smaller than') . ' ' . format_size(file_upload_max_size()).'.'); - } - else if($node->new_file_uploaded || $node->new_video_upload_file_fid > 0 || $node->new_video_upload_file_fid > 0){ - if($node->new_file_uploaded) { // only if the user oploaded a new file - $file = $node->new_file_uploaded; - } - else { - $file = _video_upload_get_file($node->new_video_upload_file_fid); - } - - // let's check file extension - $extensions = variable_get('video_upload_allowed_extensions', 'mov,flv,wmv'); - $regex = '/\.('. ereg_replace(',+', '|', preg_quote($extensions)) .')$/i'; - if (!preg_match($regex, $file->filename)) { - //set an error message and delete the the file - form_set_error('audio', t('The selected file %name can not be uploaded, because it is only possible to upload files with the following extensions: %files-allowed.', array('%name' => $file->filename, '%files-allowed' => $extensions))); - _video_upload_delete_file($file); - } - } - //call to submit function - //print_r($node); - //exit; - _video_upload_submit($file,$node); -} - - -function _video_upload_submit(&$file,&$node) { - //print 'submit'; + // - //print_r($node); die; + // ####### Start Perpare to save ############### if($node->new_video_upload_file_fid) { $fid = $node->new_video_upload_file_fid; } @@ -525,90 +423,31 @@ function _video_upload_submit(&$file,&$node) { $fid = $node->current_video_upload_file_fid; } $node->serial_data['video_fid'] = $fid; - _video_upload_insert($file,$node); + $node->vidfile = $node->new_video_upload_file->path; + $node->size = $node->new_video_upload_file->filesize; + // _video_upload_insert($file,$node); } -function _video_upload_insert(&$file,&$node) { - // global $file; - //print 'insert'; - //print_r($node); die; - // if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path); need to store in the final directory +function _video_upload_insert(&$node) { + //print "insert"; //print_r($node); //exit; + if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path); need to store in the final directory + _video_upload_store_file($file, $node); - //} + } } function _video_upload_update(&$node) { - //##################### PREPARE ########################## - - if (is_object($node->video_upload_file)) { - $file_field = $node->video_upload_file; - } else { - $file_field = 'video_upload_file'; - } - -/* TODO Modify the validators array to suit your needs. - This array is used in the revised file_save_upload - $validators = array( - 'file_validate_is_image' => array(), - 'file_validate_image_resolution' => array('85x85'), - 'file_validate_size' => array(30 * 1024), - ); -*/ - // get extention list - $extentions = explode(",",variable_get('video_upload_allowed_extensions', 'mov,flv,wmv')); - - $validators = array( - 'file_validate_extensions' => array(variable_get('video_upload_allowed_extensions', 'mov,flv,wmv')) - ); - // TODO : add file sixe validation - // 'file_validate_size' => array($limits['file_size'], $limits['user_size']), - - if (count($_POST) && $file = file_save_upload($file_field , $validators) ){ // a file has been uploaded - - // this is the temp directory to store files - //$temppath = file_directory_temp() . '/video/'; - // let's check that the directory is good - //file_check_directory($temppath, TRUE); - // let's save the uploaded file to the temp directory - //$file = file_save_upload($file, $validators, $temppath . '/' . $file->filename, FILE_EXISTS_REPLACE); - - //TODO : set status value - //$status=0; - // let's store the temp file into the DB - //$file->fid = db_last_insert_id('files','fid'); - //db_query("INSERT INTO {files} (fid, filename, filepath, filemime, filesize,status) VALUES (%d, '%s', '%s', '%s', %d, %d)", $file->fid, 'video_upload_temp.'.$file->filename, $file->filepath, $file->filemime, $file->filesize, $file->status); - - // TODO: delete here the previous $node->new_video_upload_file - //print_r($file); - //exit; - $node->new_video_upload_file = $file->fid; - $node->new_video_upload_file_fid = $file->fid; - } - else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Submit') { - $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - } - else if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Preview') { - $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']); - - } - //print_r($node); - //exit; - //######################################################### - if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path) //need to store in the final directory //exit; - _video_upload_store_file($file, $node); - ///print_r($node); - //exit; - //$node = _video_upload_load($node); if($node->current_video_upload_file_fid) { // let's delete the old video _video_upload_delete_file($node->current_video_upload_file_fid); } + _video_upload_store_file($file, $node); } } @@ -640,10 +479,7 @@ function _video_upload_view(&$node) { * Move a temp file into the final directory associating it with the node */ function _video_upload_store_file(&$file, &$node) { - //global $file; - // $file->filename is video_upload_temp.realfile.ext : let's restore original filename -//print_r($file); -//exit; + $file->filename = _video_get_original_filename($file->filename); _video_upload_get_path($file, $node); @@ -653,7 +489,7 @@ function _video_upload_store_file(&$file, &$node) { // update the file db entry db_query("UPDATE {files} SET filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE fid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid); // add an entry in the file_revisions table - db_query("INSERT INTO {upload} (fid, nid, vid, list, description) VALUES (%d, %d, %d, %d, '%s')", $file->fid, $node->nid, $node->vid, $file->list, $file->description); + db_query("INSERT INTO {video_upload} (vid, nid, fid) VALUES (%d, %d, %d)", $node->vid, $node->nid, $file->fid); // update the file db entry //db_query("UPDATE {video} SET serialized_data = '%s' WHERE vid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid); @@ -712,7 +548,7 @@ function _video_upload_delete_file($file) { file_delete($file->path); // delete file information from database - db_query('DELETE FROM {upload} WHERE fid = %d', $file); + db_query('DELETE FROM {video_upload} WHERE fid = %d', $file); db_query('DELETE FROM {files} WHERE fid = %d', $file); } diff --git a/types/video_url/video_url.info b/types/video_url/video_url.info index a45f8a6..474719f 100644 --- a/types/video_url/video_url.info +++ b/types/video_url/video_url.info @@ -1,5 +1,6 @@ +;$Id$ name = URL Video description = Enable URL video support for Video module. dependencies[] = video package = "Video" -core = 6.x \ No newline at end of file +core = 6.x diff --git a/types/video_url/video_url.module b/types/video_url/video_url.module index 1eaae16..6b83091 100644 --- a/types/video_url/video_url.module +++ b/types/video_url/video_url.module @@ -1,4 +1,5 @@ * @todo + * @version : $Id$ */ .video_image_teaser { diff --git a/video.info b/video.info index 72f2934..93c9aaa 100644 --- a/video.info +++ b/video.info @@ -1,4 +1,6 @@ +;$Id$ name = Video description = Allows video nodes. package = "Video" -core = 6.x \ No newline at end of file +core = 6.x + diff --git a/video.install b/video.install index b640bc9..b52b78a 100644 --- a/video.install +++ b/video.install @@ -1,40 +1,50 @@ + * + * @todo + */ + /** * Implementation of hook_schema(). */ function video_schema() { $schema['video'] = array( - 'description' => t('TODO'), + 'description' => t('Store video files informations'), 'fields' => array( 'vid' => array( - 'description' => t('TODO'), + 'description' => t('Prmary Key: {video}.vid of the video node'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'nid' => array( - 'description' => t('TODO'), + 'description' => t('Node id, index to the {node}.nid'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), + ), 'vtype' => array( - 'description' => t('TODO'), + 'description' => t('The type of the video'), 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '', ), 'vidfile' => array( - 'description' => t('TODO'), + 'description' => t('Video file name / path'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'default' => '', ), 'videox' => array( - 'description' => t('TODO'), + 'description' => t('resolution : x'), 'type' => 'int', 'size' => 'small', 'unsigned' => TRUE, @@ -42,7 +52,7 @@ function video_schema() { 'default' => 0, ), 'videoy' => array( - 'description' => t('TODO'), + 'description' => t('resolution : y'), 'type' => 'int', 'size' => 'small', 'unsigned' => TRUE, @@ -50,63 +60,63 @@ function video_schema() { 'default' => 0, ), 'size' => array( - 'description' => t('TODO'), + 'description' => t('size of the video file'), 'type' => 'int', 'size' => 'big', 'unsigned' => TRUE, 'not null' => FALSE, ), 'download_counter' => array( - 'description' => t('TODO'), + 'description' => t('No. of downloads of the video'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'play_counter' => array( - 'description' => t('TODO'), + 'description' => t('No. of play times per video'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'video_bitrate' => array( - 'description' => t('TODO'), + 'description' => t('Bit rate of the video'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, ), 'audio_bitrate' => array( - 'description' => t('TODO'), + 'description' => t('Bit rate of the audio'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, ), 'audio_sampling_rate' => array( - 'description' => t('TODO'), + 'description' => t('Sampling rate of the video'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, ), 'audio_channels' => array( - 'description' => t('TODO'), - 'type' => 'unknown', + 'description' => t('Chenells of the audio'), + 'type' => 'text', 'not null' => FALSE, ), 'playtime_seconds' => array( - 'description' => t('TODO'), + 'description' => t('Play time of the video'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, ), 'download_folder' => array( - 'description' => t('TODO'), + 'description' => t('download folder'), 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, ), 'disable_multidownload' => array( - 'description' => t('TODO'), + 'description' => t('enable/disable multi download'), 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, @@ -114,52 +124,21 @@ function video_schema() { 'default' => 0, ), 'use_play_folder' => array( - 'description' => t('TODO'), + 'description' => t('use play folder'), 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), - 'custom_field_1' => array( - 'description' => t('TODO'), - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ), - 'custom_field_2' => array( - 'description' => t('TODO'), - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ), - 'custom_field_3' => array( - 'description' => t('TODO'), - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ), - 'custom_field_4' => array( - 'description' => t('TODO'), - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ), - 'custom_field_5' => array( - 'description' => t('TODO'), - 'type' => 'text', - 'not null' => FALSE, - ), - 'custom_field_6' => array( - 'description' => t('TODO'), - 'type' => 'text', - 'not null' => FALSE, - ), 'serialized_data' => array( - 'description' => t('TODO'), + 'description' => t('Informations related to the videos'), 'type' => 'text', 'not null' => FALSE, ), + ), + 'indexes' => array( + 'nid' => array('nid'), ), 'primary key' => array('vid'), ); @@ -167,140 +146,26 @@ function video_schema() { return $schema; } -// ex: set syntax=php tabstop=2 expandtab shiftwidth=2 softtabstop=2: - +/** + * Implementation of hook_install(). + */ function video_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {video} ( - vid int(10) unsigned NOT NULL default '0', - nid int(10) unsigned NOT NULL default '0', - vtype varchar(32) NOT NULL default '', - vidfile text NOT NULL default '', - videox smallint(4) unsigned NOT NULL default '0', - videoy smallint(4) unsigned NOT NULL default '0', - size bigint(13) unsigned default NULL, - download_counter int(10) unsigned NOT NULL default '0', - play_counter int(10) unsigned NOT NULL default '0', - video_bitrate int(10) unsigned default NULL, - audio_bitrate int(10) unsigned default NULL, - audio_sampling_rate int(10) unsigned default NULL, - audio_channels enum('','5.1','stereo','mono') default NULL, - playtime_seconds int(10) unsigned default NULL, - download_folder varchar(255) NULL default NULL, - disable_multidownload tinyint(1) unsigned NOT NULL default '0', - use_play_folder tinyint(1) unsigned NOT NULL default '0', - custom_field_1 varchar(255) NULL default NULL, - custom_field_2 varchar(255) NULL default NULL, - custom_field_3 varchar(255) NULL default NULL, - custom_field_4 varchar(255) NULL default NULL, - custom_field_5 text NULL default NULL, - custom_field_6 text NULL default NULL, - serialized_data text NULL default NULL, - PRIMARY KEY (vid) - ) TYPE=MyISAM COMMENT='size is in bytes' /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; - case 'pgsql': - db_query("CREATE TABLE {video} ( - vid integer NOT NULL default '0', - nid integer NOT NULL default '0', - vtype varchar(32) NOT NULL default '', - vidfile text NOT NULL default '', - videox smallint NOT NULL default '0', - videoy smallint NOT NULL default '0', - size bigint default NULL, - download_counter integer NOT NULL default '0', - play_counter integer NOT NULL default '0', - video_bitrate integer default NULL, - audio_bitrate integer default NULL, - audio_sampling_rate integer default NULL, - audio_channels varchar(10) default NULL, - playtime_seconds integer default NULL, - download_folder varchar(255) NULL default NULL, - disable_multidownload smallint NOT NULL default '0', - use_play_folder smallint NOT NULL default '0', - custom_field_1 varchar(255) NULL default NULL, - custom_field_2 varchar(255) NULL default NULL, - custom_field_3 varchar(255) NULL default NULL, - custom_field_4 varchar(255) NULL default NULL, - custom_field_5 text NULL default NULL, - custom_field_6 text NULL default NULL, - serialized_data text NULL default NULL, - PRIMARY KEY (vid) - );"); - - } + drupal_install_schema('video'); // default values for some variables use for resolution stuff - variable_set('video_resolution_1_name', '4:3 - Television'); - variable_set('video_resolution_1_value', '400x300'); - variable_set('video_resolution_2_name', '16:9 - Widescreen'); - variable_set('video_resolution_2_value', '400x226'); -} - -/** - * Add audio details - * - * @return array - */ -/** - * Rename counter, add custom fields, for video.module version 1.9 - * - * @return array - */ -/** - * Add unsigned to all int fields - * - * @return array - */ -/** - * Start of Drupal 4.7 support in video.module issue #40005, version 1.25 - * updated revisions, db schema, forms api, form validation, permissions, added .swf and image support - * - * @return array - */ -/** - * Add the vtype field for video module subtypes - * - * @return array - */ -function _video_update_6_get_vtype($node) { - $file_type = ''; - $vidfile = $node->vidfile; - //If the filename doesn't contain a ".", "/", or "\" and is exactly 11 characters then consider it a youtube video ID. - if (!strpos($vidfile, '.') and !strpos($vidfile, '/') and !strpos($vidfile, '\\') and strlen($vidfile) == 11) { - $file_type = 'youtube'; - } - else if (strpos($vidfile, 'google:') === 0) { - $file_type = 'google'; - } - else if(db_result(db_query("SELECT count(fid) FROM {files} WHERE nid=%d", $node->nid)) > 0) { - $file_type = 'upload'; - } - else if ($vidfile != '' ) { // enable absolute urls and relative paths - $file_type = 'url'; - } - else { - drupal_set_message(t('Could not determine video type of node %nid', array('%nid' => $node->nid)), 'error'); - } - return $file_type; + variable_set('video_resolution_1_name', '16:9 - Widescreen'); + variable_set('video_resolution_1_value', '400x226'); + variable_set('video_resolution_2_name', '4:3 - Television'); + variable_set('video_resolution_2_value', '400x300'); } /** - * Set vtype for all the videos -*/ -/** - * Set default values of resolutions -*/ -/** - * Video_upload changes from relying on files table to locate - * video file to saving it in serialized_data as video_fid -*/ -/** - * Update the vidfile for youtube videos so they will work again - */ -/** - * Update vidfile for google videos -- they play, but they are not editable - * in the current form because validation fails upon submit + * Implementation of hook_uninstall(). */ +function video_uninstall() { + drupal_uninstall_schema('video'); + variable_del('video_resolution_1_name'); + variable_del('video_resolution_1_value'); + variable_del('video_resolution_2_name'); + variable_del('video_resolution_2_value'); +} \ No newline at end of file diff --git a/video.module b/video.module index 8276d82..d8a93e7 100644 --- a/video.module +++ b/video.module @@ -1,12 +1,10 @@ - * @contributor Vernon Mauery - * porting to Drupal 6 - * @author Heshan Wanigasooriya + * @author Heshan Wanigasooriya + * * @todo */ /** @@ -22,13 +20,22 @@ if (module_exists('views')) { /** * Help hook - * + * Implementation of hook_help * @param $section * string of the area of Drupal where help was requested * * @return * string of help information */ + +function video_help($path, $arg) { + switch ($path) { + case 'admin/help#video': + $output = '

'. t('The Video Module is used to create and administrator Video nodes for Drupal') .'

'; + return $output; + } +} + /** * Implementation of hook_menu(). * @@ -39,11 +46,9 @@ if (module_exists('views')) { * array of menu information */ function video_menu() { - global $user; - + global $user; $items = array(); - $may_cache=true; - if ($may_cache) { + $items['video'] = array( 'title' => 'videos', 'page callback' => 'drupal_get_form', @@ -73,8 +78,7 @@ function video_menu() { 'access arguments' => array('administer video'), 'type' => MENU_NORMAL_ITEM, ); - } - else { //If $may_cache is false. + if (arg(0) == 'node' && is_numeric(arg(1))) { if ($node = node_load(arg(1)) and $node->type == 'video') { @@ -92,7 +96,6 @@ function video_menu() { } } } - } return $items; } @@ -221,7 +224,6 @@ function video_perm() { function video_settings_form() { global $base_url; - $form = array(); $form['menu'] = array( @@ -230,7 +232,9 @@ function video_settings_form() { '#collapsible' => TRUE, '#collapsed' => TRUE ); + $vtypes = video_get_types_infos(); + if ($vtypes) { // no vtype available $video_types = array(); foreach ($vtypes as $vtype => $info) { @@ -245,6 +249,7 @@ function video_settings_form() { '#options' => $video_types, ); } + $form['menu']['video_displaydownloadmenutab'] = array( '#type' => 'checkbox', '#title' => t('Display download menu tab'), @@ -478,22 +483,18 @@ function video_nodeapi($node, $op, $arg) { function video_add() { global $user; - $edit = isset($_POST['edit']) ? $_POST['edit'] : ''; // If a video type has been specified, validate its existence. $vtypes = video_get_types(); - //print_r($vtypes); - // exit; + if (arg(3) && in_array(arg(3), $vtypes)) { // is a valid video type $type = arg(3); // Initialize settings: module_load_include('inc', 'node', 'node.pages'); $node = (object) array('uid' => $user->uid, 'name' => $user->name, 'type' => 'video', 'vtype' => $type); - //print_r($node); - //exit; $output = drupal_get_form('video_node_form', $node); drupal_set_title(t('Submit %name video', array('%name' => $type))); } @@ -502,8 +503,6 @@ function video_add() { $node = (object) array('uid' => $user->uid, 'name' => $user->name, 'type' => 'video', 'vtype' => $vtypes[0]); module_load_include('inc', 'node', 'node.pages'); $output = drupal_get_form('video_node_form', $node); - //print_r($output); - //exit; drupal_set_title(t('Submit %name video', array('%name' => $vtypes[0]))); } else if ($vtype = variable_get('video_default_video_type', 0)) { @@ -516,9 +515,6 @@ function video_add() { else { $output = video_types_page(); } - //$output ="
Prefs :test
";; - //print_r($output); - //exit; return $output; } @@ -537,11 +533,7 @@ function video_types_page() { else { $items = array(); foreach ($vtypes as $vtype => $infos) { - $out = '
'. /* TODO - Please manually fix the parameters on the l() or url() function on the next line. - Typically, this was not changed because of a function call inside an array call like - array('title' => t('View user profile.')).*/ -l($infos['#name'], "node/add/video/$vtype", array('title' => t('Add a !s.', array('!s' => $infos['#name'])))) .'
'; + $out = '
'. l($infos['#name'], "node/add/video/$vtype", array('HTML'=>TRUE, 'attributes' => array('title' => 'Add a '. $infos['#name']))) .'
'; $out .= '
'. $infos['#description'] .'
'; $items[$vtype] = $out; } @@ -650,6 +642,13 @@ function video_form($node) { '#required' => true, ); } + else { + // set an hidden field to store video resolution + $form['hvresolution'] = array( + '#type' => 'hidden', + '#value' => $node->videox . 'x' . $node->videoy + ); + } if(!video_support_autoplaytime($node)) { // this vtype doesn't support autoplaytime $form['video']['playtime'] = array( @@ -682,6 +681,18 @@ function video_form($node) { '#default_value' => $playtime['seconds'], ); } + else { + // set an hidden field to store video length + $form['playtime_seconds'] = array( + '#type' => 'hidden', + '#value' => $node->playtime_seconds + ); + // we need to store file size too + $form['hsize'] = array( + '#type' => 'hidden', + '#value' => $node->size + ); + } // Get the video-type-specific bits. $form = module_invoke('video_' . $node->vtype, 'v_form', $node, $form); @@ -693,49 +704,52 @@ function video_form($node) { /** * Implementation of hook_validate */ -function video_validate($node) { - +function video_validate($node, $form = array()) { if(!video_support_autoresolution($node) || $node->vresolution) { // we have some resolution value // form api checked for good values of vresolution if(variable_get("video_{$node->vresolution}_value", '') == '') { } } - + module_invoke('video_'.$node->vtype, 'v_validate', $node); - } /** * Implementation of hook submit */ -function video_submit(&$node) { - - if(video_support_autoresolution($node)) { // vtype support autoresolution getting - $xy = module_invoke('video_' . $form_state['values']['vtype'], 'v_auto_resolution', $node); +function video_presave(&$node) { + if(video_support_autoresolution($node) && ($node->new_video_upload_file_fid)) { // vtype support autoresolution getting + $xy = module_invoke('video_' . $node->vtype, 'v_auto_resolution', $node); if ($xy) { - $form_state['values']['videox'] = $xy[0]; - $form_state['values']['videoy'] = $xy[1]; + $node->videox = $xy[0]; + $node->videoy = $xy[1]; } } else { + // if you have a existing value from hidden field + if($node->hvresolution) { + $res = explode('x', $node->hvresolution); + $node->videox = $res[0]; + $node->videoy = $res[1]; + $node->size = $node->hsize; + } // we should have a good value (checked by Form API) - if($form_state['values']['vresolution']) { - $res = explode('x', variable_get('video_resolution_' . $form_state['values']['vresolution'] . '_value', '')); - $form_state['values']['videox'] = $res[0]; - $form_state['values']['videoy'] = $res[1]; + else { + $res = explode('x', variable_get('video_resolution_' . $node->vresolution . '_value', '')); + $node->videox = $res[0]; + $node->videoy = $res[1]; } - } - - if(video_support_autoplaytime($node)) { // vtype support auto playtime - $form_state['values']['playtime_seconds'] = module_invoke('video_' . $form_state['values']['vtype'], 'v_auto_playtime', $node); + } + + if(video_support_autoplaytime($node) && ($node->new_video_upload_file_fid)) { // vtype support auto playtime + $node->playtime_seconds = module_invoke('video_' . $node->vtype, 'v_auto_playtime', $node); } else { // vtype does not support auto_playtime - $form_state['values']['playtime_seconds'] += ($form_state['values']['playtime_hours'] * 3600) + ($form_state['values']['playtime_minutes'] * 60); + $node->playtime_seconds += ($node->playtime_hours * 3600) + ($node->playtime_minutes * 60); } - } /** @@ -746,11 +760,12 @@ function video_submit(&$node) { * TRUE on success, FALSE on error */ function video_insert($node) { - + // set the required properties of the video node + video_presave($node); $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database. - return db_query("INSERT INTO {video} (vid, nid, vtype, vidfile, size, videox, videoy, video_bitrate, audio_bitrate, audio_sampling_rate, audio_channels, playtime_seconds, disable_multidownload, download_folder, use_play_folder, custom_field_1, custom_field_2, custom_field_3, custom_field_4, custom_field_5, custom_field_6, serialized_data) VALUES (%d, %d, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", - $node->vid, $node->nid, $node->vtype, $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->custom_field_1, $node->custom_field_2, $node->custom_field_3, $node->custom_field_4, $node->custom_field_5, $node->custom_field_6, $node->serialized_data); + return db_query("INSERT INTO {video} (vid, nid, vtype, vidfile, size, videox, videoy, video_bitrate, audio_bitrate, audio_sampling_rate, audio_channels, playtime_seconds, disable_multidownload, download_folder, use_play_folder, serialized_data) VALUES (%d, %d, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s')", + $node->vid, $node->nid, $node->vtype, $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->serialized_data); } @@ -765,10 +780,12 @@ function video_update($node) { return video_insert($node); } else { + // set the required properties of the video node + video_presave($node); $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database. - return db_query("UPDATE {video} SET vidfile='%s', size=%d, videox=%d, videoy=%d, video_bitrate=%d, audio_bitrate=%d, audio_sampling_rate=%d, audio_channels='%s', playtime_seconds=%d, disable_multidownload=%d, download_folder='%s', use_play_folder=%d, custom_field_1='%s', custom_field_2='%s', custom_field_3='%s', custom_field_4='%s', custom_field_5='%s', custom_field_6='%s', serialized_data='%s' WHERE vid = %d", - $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->custom_field_1, $node->custom_field_2, $node->custom_field_3, $node->custom_field_4, $node->custom_field_5, $node->custom_field_6, $node->serialized_data, $node->vid); + return db_query("UPDATE {video} SET vidfile='%s', size=%d, videox=%d, videoy=%d, video_bitrate=%d, audio_bitrate=%d, audio_sampling_rate=%d, audio_channels='%s', playtime_seconds=%d, disable_multidownload=%d, download_folder='%s', use_play_folder=%d, serialized_data='%s' WHERE vid = %d", + $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->serialized_data, $node->vid); } } @@ -790,11 +807,13 @@ function video_delete($node) { * object or boolean FALSE on error */ function video_load($node) { + if (is_numeric($node->vid)) { $node = db_fetch_object(db_query("SELECT * FROM {video} WHERE vid = %d", $node->vid)); // load serialized data for plug-ins $node->serial_data = unserialize($node->serialized_data); + return $node; } else { diff --git a/views_video.inc b/views_video.inc index 26ece40..088a1c2 100644 --- a/views_video.inc +++ b/views_video.inc @@ -1,4 +1,5 @@