diff --git a/drupal/sites/all/modules/contrib/media_youtube/CHANGELOG.txt b/drupal/sites/all/modules/contrib/media_youtube/CHANGELOG.txt new file mode 100644 index 0000000..e4f30e7 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/CHANGELOG.txt @@ -0,0 +1,47 @@ + +Changelog for the Media: YouTube module. +======================================== + +by aaron: Add overlay to media browser library thumbnails. +by aaron: Begin framework for pager support. +by aaron: Add an empty message. +by aaron: Remove old tab from browser. +by aaron: Begin work on adding 'All/My Youtubes' vertical tabs. +by aaron: Add 'YouTube Library' tab to browser w/ all youtube videos. +by aaron: Allow parsing of url's like youtube.com/watch#v=... +by aaron: Fix incorrect parse to youtube from flickr. +by aaron: Implement hook_media_parse(). +by aaron: Remove link behavior for the moment. +by aaron: Change tab behavior to new required format. +by aaron: Allow w/h overrides. +by aaron: Add wysiwyg tab for youtube url. +by aaron: Add style presets for youtube. +by aaron: Add action link to add youtube video from media content admin. +by aaron: Add alt/title to embed thumbnails theme. +by aaron: Refactor styles containers to match new API. +by aaron: Add preview on parsing new youtube. +by aaron: Add media_youtube.js. +by aaron: Add a weight to style containers. +by aaron: Add JS behavior to url text field. +by aaron: Browse user + all youtube videos. +by aaron: New themes for styles. +by aaron: Begin browser forms for YouTube. +by aaron: Embed themes & style callbacks. +by aaron: Define filter callbacks. +by aaron: Fix return value for hook_styles_presets(). +by aaron: Implement hook_styles_presets(). +by aaron: Add variables to preview theme. +by aaron: Integrate with Styles. +by aaron: Add preview theme. +by aaron: Add test default media styles. +by aaron: Parse URL correctly. +by aaron: Register the stream wrapper. +by aaron: Include stream wrapper w/ module load. +by aaron: Rename stream wrapper implementation to MediaYouTubeStreamWrapper. +by aaron: Upgrade module to DRUPAL-7. + +============= + DRUPAL-7--1 +============= + +by aaron: Create ResourceYouTubeStreamWrapper.inc. diff --git a/drupal/sites/all/modules/contrib/media_youtube/LICENSE.txt b/drupal/sites/all/modules/contrib/media_youtube/LICENSE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/LICENSE.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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 + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/drupal/sites/all/modules/contrib/media_youtube/MediaYouTubeStreamWrapper.inc b/drupal/sites/all/modules/contrib/media_youtube/MediaYouTubeStreamWrapper.inc new file mode 100644 index 0000000..76d6f22 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/MediaYouTubeStreamWrapper.inc @@ -0,0 +1,8 @@ +parse($embedCode)) { + return TRUE; + } + } + + public function save() { + $file = $this->getFileObject(); + // If a user enters a duplicate YouTube URL, the object will be saved again. + // Set the timestamp to the current time, so that the media item shows up + // at the top of the media library, where they would expect to see it. + $file->timestamp = REQUEST_TIME; + file_save($file); + return $file; + } + + public function getFileObject() { + $uri = $this->parse($this->embedCode); + return file_uri_to_object($uri, TRUE); + } + + /** + * Returns information about the media. See http://video.search.yahoo.com/mrss. + * + * @return + * If ATOM+MRSS information is available, a SimpleXML element containing + * ATOM and MRSS elements, as per those respective specifications. + * + * @todo Would be better for the return value to be an array rather than a + * SimpleXML element, but media_retrieve_xml() needs to be upgraded to + * handle namespaces first. + */ + public function getMRSS() { + $uri = $this->parse($this->embedCode); + $video_id = arg(1, file_uri_target($uri)); + $rss_url = url('http://gdata.youtube.com/feeds/api/videos/' . $video_id, array('query' => array('v' => '2'))); + // @todo Use media_retrieve_xml() once it's upgraded to include elements + // from all namespaces, not just the document default namespace. + $entry = simplexml_load_file($rss_url); + return $entry; + } + + /** + * Returns information about the media. See http://www.oembed.com/. + * + * @return + * If oEmbed information is available, an array containing 'title', 'type', + * 'url', and other information as specified by the oEmbed standard. + * Otherwise, NULL. + */ + public function getOEmbed() { + $uri = $this->parse($this->embedCode); + $external_url = drupal_realpath($uri); + $oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); + $response = drupal_http_request($oembed_url); + if (!isset($response->error)) { + return drupal_json_decode($response->data); + } + } +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc b/drupal/sites/all/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc new file mode 100644 index 0000000..ad500f3 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc @@ -0,0 +1,38 @@ +get_parameters(); + return 'http://img.youtube.com/vi/'. check_plain($parts['v']) .'/0.jpg'; + } + + function getLocalThumbnailPath() { + $parts = $this->get_parameters(); + $local_path = 'public://media-youtube/' . check_plain($parts['v']) . '.jpg'; + if (!file_exists($local_path)) { + $dirname = drupal_dirname($local_path); + file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + @copy($this->getOriginalThumbnailPath(), $local_path); + } + return $local_path; + } +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/MediaYouTubeStyles.inc b/drupal/sites/all/modules/contrib/media_youtube/includes/MediaYouTubeStyles.inc new file mode 100644 index 0000000..11f565c --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/MediaYouTubeStyles.inc @@ -0,0 +1,45 @@ +get('autoplay'); + } + function setAutoplay($value) { + return $this->set('autoplay', $value); + } + function getFullscreen() { + return $this->get('fullscreen'); + } + function setFullscreen($value) { + return $this->set('fullscreen', $value); + } + + function getImageUri() { + if ($image_uri = $this->get('imageUri')) { + return $image_uri; + } + $object = $this->getObject(); + if ($object->uri) { + $wrapper = file_stream_wrapper_get_instance_by_uri($object->uri); + return $wrapper->getLocalThumbnailPath(); + } + } + function video($effect) { + $variables = array( + 'uri' => $this->getUri(), + 'width' => $this->getWidth(), + 'height' => $this->getHeight(), + 'autoplay' => $this->getAutoplay(), + 'fullscreen' => $this->getFullscreen(), + ); + $this->setOutput(theme('media_youtube_video', $variables)); + } +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.formatters.inc b/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.formatters.inc new file mode 100644 index 0000000..216e481 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.formatters.inc @@ -0,0 +1,173 @@ + t('YouTube Video'), + 'file types' => array('video'), + 'default settings' => array( + 'width' => media_youtube_variable_get('width'), + 'height' => media_youtube_variable_get('height'), + 'autoplay' => media_youtube_variable_get('autoplay'), + 'related' => media_youtube_variable_get('related'), + ), + 'view callback' => 'media_youtube_file_formatter_video_view', + 'settings callback' => 'media_youtube_file_formatter_video_settings', + ); + $formatters['media_youtube_image'] = array( + 'label' => t('YouTube Preview Image'), + 'file types' => array('video'), + 'default settings' => array( + 'image_style' => '', + ), + 'view callback' => 'media_youtube_file_formatter_image_view', + 'settings callback' => 'media_youtube_file_formatter_image_settings', + ); + return $formatters; +} + +/** + * Implements hook_file_formatter_FORMATTER_view(). + */ +function media_youtube_file_formatter_video_view($file, $display, $langcode) { + $scheme = file_uri_scheme($file->uri); + // WYSIWYG does not yet support video inside a running editor instance. + if ($scheme == 'youtube' && empty($file->override['wysiwyg'])) { + $element = array( + '#theme' => 'media_youtube_video', + '#uri' => $file->uri, + ); + foreach (array('width', 'height', 'autoplay', 'related') as $setting) { + $element['#' . $setting] = isset($file->override[$setting]) ? $file->override[$setting] : $display['settings'][$setting]; + } + return $element; + } +} + +/** + * Implements hook_file_formatter_FORMATTER_settings(). + */ +function media_youtube_file_formatter_video_settings($form, &$form_state, $settings) { + $element = array(); + $element['width'] = array( + '#title' => t('Width'), + '#type' => 'textfield', + '#default_value' => $settings['width'], + ); + $element['height'] = array( + '#title' => t('Height'), + '#type' => 'textfield', + '#default_value' => $settings['height'], + ); + $element['autoplay'] = array( + '#title' => t('Autoplay'), + '#type' => 'checkbox', + '#default_value' => $settings['autoplay'], + ); + $element['related'] = array( + '#title' => t('Show suggested videos when the video finishes'), + '#type' => 'checkbox', + '#default_value' => $settings['related'], + ); + return $element; +} + +/** + * Implements hook_file_formatter_FORMATTER_view(). + */ +function media_youtube_file_formatter_image_view($file, $display, $langcode) { + $scheme = file_uri_scheme($file->uri); + if ($scheme == 'youtube') { + $wrapper = file_stream_wrapper_get_instance_by_uri($file->uri); + $image_style = $display['settings']['image_style']; + $valid_image_styles = image_style_options(FALSE); + if (empty($image_style) || !isset($valid_image_styles[$image_style])) { + $element = array( + '#theme' => 'image', + '#path' => $wrapper->getOriginalThumbnailPath(), + ); + } + else { + $element = array( + '#theme' => 'image_style', + '#style_name' => $image_style, + '#path' => $wrapper->getLocalThumbnailPath(), + ); + } + return $element; + } +} + +/** + * Implements hook_file_formatter_FORMATTER_settings(). + */ +function media_youtube_file_formatter_image_settings($form, &$form_state, $settings) { + $element = array(); + $element['image_style'] = array( + '#title' => t('Image style'), + '#type' => 'select', + '#options' => image_style_options(FALSE), + '#default_value' => $settings['image_style'], + '#empty_option' => t('None (original image)'), + ); + return $element; +} + +/** + * Implements hook_file_default_displays(). + */ +function media_youtube_file_default_displays() { + $default_displays = array(); + + // Default settings for displaying as a video. + $default_video_settings = array( + 'media_large' => array( + 'width' => 480, + 'height' => 360, + 'autoplay' => FALSE, + ), + 'media_original' => array( + 'width' => 640, + 'height' => 480, + 'autoplay' => media_youtube_variable_get('autoplay'), + ), + ); + foreach ($default_video_settings as $view_mode => $settings) { + $display_name = 'video__' . $view_mode . '__media_youtube_video'; + $default_displays[$display_name] = (object) array( + 'api_version' => 1, + 'name' => $display_name, + 'status' => 1, + 'weight' => 1, + 'settings' => $settings, + ); + } + + // Default settings for displaying a video preview image. We enable preview + // images even for view modes that also play video, for use inside a running + // WYSIWYG editor. The higher weight ensures that the video display is used + // where possible. + $default_image_styles = array( + 'media_preview' => 'square_thumbnail', + 'media_large' => 'large', + 'media_original' => '' + ); + foreach ($default_image_styles as $view_mode => $image_style) { + $display_name = 'video__' . $view_mode . '__media_youtube_image'; + $default_displays[$display_name] = (object) array( + 'api_version' => 1, + 'name' => $display_name, + 'status' => 1, + 'weight' => 2, + 'settings' => array('image_style' => $image_style), + ); + } + + return $default_displays; +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.styles.inc b/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.styles.inc new file mode 100644 index 0000000..6b62d85 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.styles.inc @@ -0,0 +1,265 @@ + array( + 'field_types' => 'file', + 'name' => t('MediaYouTube'), + 'description' => t('Media YouTube styles.'), + 'path' => drupal_get_path('module', 'media_youtube') .'/includes', + 'file' => 'media_youtube.styles.inc', + ), + ); +} + +/** + * Implements hook_styles_containers(). (Deprecated in version 2) + */ +function media_youtube_styles_containers() { + return array( + 'file' => array( + 'containers' => array( + 'media_youtube' => array( + 'label' => t('YouTube Styles'), + 'data' => array( + 'streams' => array( + 'youtube', + ), + 'mimetypes' => array( + 'video/youtube', + ), + ), + 'weight' => 0, + 'filter callback' => 'media_youtube_formatter_filter', + 'themes' => array( + 'field_formatter_styles' => 'media_youtube_field_formatter_styles', + 'styles' => 'media_youtube_styles', + 'preview' => 'media_youtube_preview_style', + ), + 'description' => t('YouTube Styles will display embedded YouTube videos and thumbnails to your choosing, such as by resizing, setting colors, and autoplay. You can !manage.', array('!manage' => l(t('manage your YouTube styles here'), 'admin/config/media/media-youtube-styles'))), + ), + ), + ), + ); +} + +function media_youtube_formatter_filter($variables) { + if (isset($variables['object'])) { + $object = isset($variables['object']->file) ? $variables['object']->file : $variables['object']; + return (file_uri_scheme($object->uri) == 'youtube') && ($object->filemime == 'video/youtube'); + } +} + +/** + * Implementation of the File Styles module's hook_file_styles_filter(). + */ +function media_youtube_file_styles_filter($object) { + $file = isset($object->file) ? $object->file : $object; + if ((file_uri_scheme($file->uri) == 'youtube') && ($file->filemime == 'video/youtube')) { + return 'media_youtube'; + } +} + +/** + * Implements hook_styles_styles(). + */ +function media_youtube_styles_styles() { + $styles = array( + 'file' => array( + 'containers' => array( + 'media_youtube' => array( + 'styles' => array( + 'youtube_thumbnail' => array( + 'name' => 'youtube_thumbnail', + 'effects' => array( + array('label' => t('Thumbnail'), 'name' => 'thumbnail', 'data' => array('thumbnail' => 1)), + array('label' => t('Resize'), 'name' => 'resize', 'data' => array('width' => 100, 'height' => 75)), + ), + ), + 'youtube_preview' => array( + 'name' => 'youtube_preview', + 'effects' => array( + array('label' => t('Autoplay'), 'name' => 'autoplay', 'data' => array('autoplay' => 0)), + array('label' => t('Resize'), 'name' => 'resize', 'data' => array('width' => 220, 'height' => 165)), + ), + ), + 'youtube_full' => array( + 'name' => 'youtube_full', + 'effects' => array( + array('label' => t('Autoplay'), 'name' => 'autoplay', 'data' => array('autoplay' => 0)), + array('label' => t('Resize'), 'name' => 'resize', 'data' => array('width' => 640, 'height' => 480)), + array('label' => t('Full screen'), 'name' => 'fullscreen', 'data' => array('fullscreen' => 1)), + ), + ), + ), + ), + ), + ), + ); + + // Allow any image style to be applied to the thumbnail. + foreach (image_styles() as $style_name => $image_style) { + $styles['file']['containers']['media_youtube']['styles']['youtube_thumbnail_' . $style_name] = array( + 'name' => 'youtube_thumbnail_' . $style_name, + 'image_style' => $style_name, + 'effects' => array( + array('label' => t('Thumbnail'), 'name' => 'thumbnail', 'data' => array('thumbnail' => 1)), + ), + ); + } + + return $styles; +} + +/** + * Implements hook_styles_presets(). + */ +function media_youtube_styles_presets() { + $presets = array( + 'file' => array( + 'square_thumbnail' => array( + 'media_youtube' => array( + 'youtube_thumbnail_square_thumbnail', + ), + ), + 'thumbnail' => array( + 'media_youtube' => array( + 'youtube_thumbnail', + ), + ), + 'small' => array( + 'media_youtube' => array( + 'youtube_preview', + ), + ), + 'large' => array( + 'media_youtube' => array( + 'youtube_full', + ), + ), + 'original' => array( + 'media_youtube' => array( + 'youtube_full', + ), + ), + ), + ); + return $presets; +} + +/** + * Implementation of Styles module hook_styles_default_containers(). + */ +function media_youtube_styles_default_containers() { + // We append YouTube to the file containers. + return array( + 'file' => array( + 'containers' => array( + 'media_youtube' => array( + 'class' => 'MediaYouTubeStyles', + 'name' => 'media_youtube', + 'label' => t('YouTube'), + 'preview' => 'media_youtube_preview_style', + ), + ), + ), + ); +} + + +/** + * Implementation of Styles module hook_styles_default_presets(). + */ +function media_youtube_styles_default_presets() { + $presets = array( + 'file' => array( + 'containers' => array( + 'media_youtube' => array( + 'default preset' => 'unlinked_thumbnail', + 'styles' => array( + 'original' => array( + 'default preset' => 'video', + ), + 'thumbnail' => array( + 'default preset' => 'linked_thumbnail', + ), + 'square_thumbnail' => array( + 'default preset' => 'linked_square_thumbnail', + ), + 'medium' => array( + 'default preset' => 'linked_medium', + ), + 'large' => array( + 'default preset' => 'large_video', + ), + ), + 'presets' => array( + 'video' => array( + array( + 'name' => 'video', + 'settings' => array(), + ), + ), + 'large_video' => array( + array( + 'name' => 'resize', + 'settings' => array( + 'width' => 640, + 'height' => 390, + ), + ), + array( + 'name' => 'video', + 'settings' => array(), + ), + ), + ), + ), + ), + ), + ); + // Allow any image style to be applied to the thumbnail. + foreach (image_styles() as $style_name => $image_style) { + $presets['file']['containers']['media_youtube']['presets']['linked_' . $style_name] = array( + array( + 'name' => 'linkToMedia', + 'settings' => array(), + ), + array( + 'name' => 'imageStyle', + 'settings' => array( + 'image_style' => $style_name, + ), + ), + array( + 'name' => 'thumbnail', + 'settings' => array(), + ), + ); + $presets['file']['containers']['media_youtube']['presets']['unlinked_' . $style_name] = $presets['file']['containers']['media_youtube']['presets']['linked_' . $style_name]; + array_shift($presets['file']['containers']['media_youtube']['presets']['unlinked_' . $style_name]); + foreach ($image_style['effects'] as $effect) { + if (in_array($effect['name'], array('image_scale', 'image_scale_and_crop', 'image_resize', 'image_crop'))) { + $presets['file']['containers']['media_youtube']['presets']['video_' . $style_name] = array( + array( + 'name' => 'resize', + 'settings' => $effect['data'], + ), + array( + 'name' => 'video', + 'settings' => array(), + ), + ); + } + } + } + return $presets; +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.variables.inc b/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.variables.inc new file mode 100644 index 0000000..f1d35e7 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/media_youtube.variables.inc @@ -0,0 +1,133 @@ + 560, + 'height' =>340, + 'autoplay' => FALSE, + 'related' => TRUE, + 'fullscreen' => TRUE, + 'preview_uri' => 'youtube://v/-jubiv7QUco', + ); + } + + if (!isset($name)) { + return $defaults; + } + + if (isset($defaults[$name])) { + return $defaults[$name]; + } +} + +/** + * Return the fully namespace variable name. + * + * @param string $name + * The variable name to retrieve the namespaced name. + * @return string + * The fully namespace variable name, prepended with + * MEDIA_YOUTUBE_NAMESPACE. + */ +function media_youtube_variable_name($name) { + return MEDIA_YOUTUBE_NAMESPACE . $name; +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/themes/media-youtube-video.tpl.php b/drupal/sites/all/modules/contrib/media_youtube/includes/themes/media-youtube-video.tpl.php new file mode 100644 index 0000000..5e93033 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/themes/media-youtube-video.tpl.php @@ -0,0 +1,24 @@ + +
+
+ +
+
diff --git a/drupal/sites/all/modules/contrib/media_youtube/includes/themes/media_youtube.theme.inc b/drupal/sites/all/modules/contrib/media_youtube/includes/themes/media_youtube.theme.inc new file mode 100644 index 0000000..121257e --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/includes/themes/media_youtube.theme.inc @@ -0,0 +1,183 @@ +get_parameters(); + $variables['video_id'] = check_plain($parts['v']); + + $variables['width'] = isset($variables['width']) ? $variables['width'] : media_youtube_variable_get('width'); + $variables['height'] = isset($variables['height']) ? $variables['height'] : media_youtube_variable_get('height'); + $variables['autoplay'] = isset($variables['autoplay']) ? $variables['autoplay'] : media_youtube_variable_get('autoplay'); + $variables['related'] = isset($variables['related']) ? $variables['related'] : 1; + $variables['fullscreen'] = isset($variables['fullscreen']) ? $variables['fullscreen'] : media_youtube_variable_get('fullscreen'); + $variables['autoplay'] = $variables['autoplay'] ? 1 : 0; + $variables['fullscreen'] = $variables['fullscreen'] ? 'true' : 'false'; + + $variables['wrapper_id'] = 'media_youtube_' . $variables['video_id'] . '_' . $variables['id']; + + // For users with JavaScript, these object and embed tags will be replaced + // by an iframe, so that we can support users without Flash. + $variables['output'] = << + + + + + +OUTPUT; + + // Pass the settings to replace the object tag with an iframe. + $settings = array( + 'media_youtube' => array( + $variables['wrapper_id'] => array( + 'width' => $variables['width'], + 'height' => $variables['height'], + 'video_id' => $variables['video_id'], + 'fullscreen' => $variables['fullscreen'], + 'id' => $variables['wrapper_id'] .'_iframe', + ), + ), + ); + if ($variables['autoplay']) { + $settings['media_youtube'][$variables['wrapper_id']]['options'] = array( + 'autoplay' => $variables['autoplay'], + ); + } + if ($variables['related'] === 0) { + $settings['media_youtube'][$variables['wrapper_id']]['options']['rel'] = $variables['related']; + } + drupal_add_js($settings, 'setting'); + drupal_add_js(drupal_get_path('module', 'media_youtube') . '/js/media_youtube.js'); + drupal_add_css(drupal_get_path('module', 'media_youtube') . '/css/media_youtube.css'); + drupal_add_js(drupal_get_path('module', 'media_youtube') . '/js/flash_detect_min.js'); +} + +function theme_media_youtube_field_formatter_styles($variables) { + $element = $variables['element']; + $style = $variables['style']; + $variables['file'] = $element['#item']; + $variables['uri'] = $variables['file']['uri']; + $variables['style_name'] = $style['name']; + return theme('media_youtube_embed', $variables); +} + +/** + * Preview for Styles UI. + */ +function theme_media_youtube_preview_style($variables) { + $variables['uri'] = media_youtube_variable_get('preview_uri'); + $variables['field_type'] = 'file'; + $variables['object'] = file_uri_to_object($variables['uri']); + + return theme('styles', $variables); +} + +/** + * NOTE: Deprecated with Styles version 2. + */ +function theme_media_youtube_styles($variables) { + $style = $variables['style']; + $variables['file'] = $variables['object']; + $variables['uri'] = $variables['object']->uri; + $variables['style_name'] = $style['name']; + return theme('media_youtube_embed', $variables); +} + +/** + * @todo: get this working + * + * This code is for embedding videos in WYSIYWG areas, not currently working. + * NOTE: Deprecated with Styles version 2. + */ +function theme_media_youtube_embed($variables) { + $preset_name = $variables['preset_name']; + $preset = styles_containers_available_styles('file', 'media_youtube', $preset_name); + $output = ''; + if (!empty($preset)) { + // Build the URL for display. + $uri = $variables['uri']; + $wrapper = file_stream_wrapper_get_instance_by_uri($uri); + $parts = $wrapper->get_parameters(); + + $fullscreen_value = $autoplay = 'false'; + $in_browser = $thumbnail = FALSE; + + foreach ($preset['effects'] as $effect) { + switch ($effect['name']) { + case 'autoplay': + $autoplay = $effect['data']['autoplay'] ? 'true' : 'false'; + break; + case 'resize': + $width = $effect['data']['width']; + $height = $effect['data']['height']; + break; + case 'fullscreen': + $fullscreen_value = $effect['data']['fullscreen'] ? 'true' : 'false'; + break; + case 'thumbnail': + $thumbnail = $effect['data']['thumbnail']; + } + } + if (isset($variables['object']->override)) { + $override = $variables['object']->override; + if (isset($override['width'])) { + $width = $override['width']; + } + if (isset($override['height'])) { + $height = $override['height']; + } + if (isset($override['wysiwyg'])) { + $thumbnail = TRUE; + } + if (isset($override['browser']) && $override['browser']) { + $in_browser = TRUE; + $thumbnail = TRUE; + } + } + $width = isset($width) ? $width : media_youtube_variable_get('width'); + $height = isset($height) ? $height : media_youtube_variable_get('height'); + $video_id = check_plain($parts['v']); + if ($thumbnail) { + // @todo Clean this up. + $image_variables = array( + 'path' => $wrapper->getOriginalThumbnailPath(), + 'alt' => $variables['alt'], + 'title' => $variables['title'], + 'getsize' => FALSE, + ); + if (isset($preset['image_style'])) { + $image_variables['path'] = $wrapper->getLocalThumbnailPath(); + $image_variables['style_name'] = $preset['image_style']; + $output = theme('image_style', $image_variables); + } + else { + // We need to add this style attribute here so that it doesn't get lost + // If you resize a video in a node, save it, edit it, but don't adjust + // the sizing of the video while editing, the size will revert to the + // default. Adding the specific size here retains the original resizing + $WYSIWYG = isset($variables['object']->override['style']) ? $variables['object']->override['style'] : ''; + $image_variables['attributes'] = array('width' => $width, 'height' => $height, 'style' => $WYSIWYG); + $output = theme('image', $image_variables); + } + if ($in_browser) { + // Add an overlay that says 'YouTube' to media library browser thumbnails. + $output .= ''; + } + } + else { + $output = theme('media_youtube_video', array('uri' => $uri, 'width' => $width, 'height' => $height, 'autoplay' => ($autoplay == 'true' ? TRUE : NULL), 'fullscreen' => ($fullscreen_value == 'true' ? TRUE : NULL))); + } + } + return $output; +} diff --git a/drupal/sites/all/modules/contrib/media_youtube/js/flash_detect_min.js b/drupal/sites/all/modules/contrib/media_youtube/js/flash_detect_min.js new file mode 100644 index 0000000..ebdff92 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/js/flash_detect_min.js @@ -0,0 +1,5 @@ +//http://www.featureblend.com/license.txt +var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){} +return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){} +return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};} +return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i=arguments[i]){if(i+10){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i'); + that.browser = $('ul', mediaBrowser.getActivePanel()); + that.browser.addClass('clearfix'); + that.getMedia(); + } + }); + }, + + getStreams: function () { + return ['youtube://']; + }, + + getConditions: function () { + return {}; + //return this.settings.conditions; + }, + + getMedia: function() { + var that = this; + var callback = mediaBrowser.getCallbackUrl('getMedia'); + var params = { + conditions: JSON.stringify(this.getConditions()), + streams: JSON.stringify(this.getStreams()) + }; + jQuery.get( + callback, + params, + function(data, status) { + that.mediaFiles = data.media; + that.emptyMessage = data.empty; + that.pager = data.pager; + that.render(); + }, + 'json' + ); + }, + + render: function() { + var that = this; + mediaBrowser.getActivePanel().removeClass('throbber'); + if (this.mediaFiles.length < 1) { + jQuery('
').appendTo(this.browser) + .html(this.emptyMessage); + return; + } + + for (var m in this.mediaFiles) { + mediaFile = this.mediaFiles[m]; + + var listItem = jQuery('
  • ').appendTo(this.browser) + .attr('id', 'media-file-' + mediaFile.fid) + .addClass('media-file'); + + var imgLink = jQuery('').appendTo(listItem) + .html(mediaFile.preview) + .bind('click', mediaFile, function(e) { + // Notify the main browser + //this.selectedMedia = mediaFile; + $('div.media-thumbnail img').removeClass('selected'); + $('div.media-thumbnail img', $(this)).addClass('selected'); + mediaBrowser.notify('mediaSelected', {mediaFiles: [e.data]}); + //that.settings.onSelect(mediaFile); + return false; + }); + } + jQuery('
    ').appendTo(this.browser) + .html(this.pager); + } + }; +}; + + Drupal.media.browser.register('youtube_library', Drupal.media.browser.plugin.youtube_library); +})(jQuery); diff --git a/drupal/sites/all/modules/contrib/media_youtube/js/media_youtube.js b/drupal/sites/all/modules/contrib/media_youtube/js/media_youtube.js new file mode 100644 index 0000000..2d8b657 --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/js/media_youtube.js @@ -0,0 +1,107 @@ + +/** + * @file media_youtube/js/media_youtube.js + */ + +(function ($) { + +Drupal.media_youtube = {}; +Drupal.behaviors.media_youtube = { + attach: function (context, settings) { + // Check the browser to see if it supports html5 video. + var video = document.createElement('video'); + var html5 = video.canPlayType ? true : false; + + // If it has video, does it support the correct codecs? + if (html5) { + html5 = false; + if (video.canPlayType( 'video/webm; codecs="vp8, vorbis"' ) || video.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')) { + html5 = true; + } + } + + // Put a prompt in the video wrappers to let users know they need flash + if (!FlashDetect.installed && !html5){ + $('.media-youtube-preview-wrapper').each(Drupal.media_youtube.needFlash); + } + + // Replace all object tags with iframes. + if (Drupal.settings && Drupal.settings.media_youtube) { + for (video in Drupal.settings.media_youtube) { + Drupal.media_youtube.insertEmbed(video); + } + } + } +}; + +Drupal.media_youtube.needFlash = function () { + var id = $(this).attr('id'); + var wrapper = $('.media-youtube-preview-wrapper'); + var hw = Drupal.settings.media_youtube[id].height / Drupal.settings.media_youtube[id].width; + wrapper.html('
    ' + Drupal.t('You need Flash to watch this video. Get Flash', {'@flash':'http://get.adobe.com/flashplayer'}) + '
    '); + wrapper.height(wrapper.width() * hw); +}; + +Drupal.media_youtube.insertEmbed = function (embed_id) { + var videoWrapper = $('#' + embed_id + '.media-youtube-preview-wrapper'); + var settings = Drupal.settings.media_youtube[embed_id]; + + // Calculate the ratio of the dimensions of the embed. + settings.hw = settings.height / settings.width; + + // Replace the object embed with YouTube's iframe. This isn't done by the + // theme function because YouTube doesn't have a no-JS or no-Flash fallback. + var video = $(''); + var src = 'http://www.youtube.com/embed/' + settings.video_id; + + // Allow other modules to modify the video settings. + settings.options = settings.options || {}; + settings.options.wmode = 'opaque'; + $(window).trigger('media_youtube_load', settings); + + // Merge YouTube options (such as autoplay) into the source URL. + var query = $.param(settings.options); + if (query) { + src += '?' + query; + } + + // Set up the iframe with its contents and add it to the page. + video + .attr('id', settings.id) + .attr('width', settings.width) + .attr('height', settings.height) + .attr('src', src); + videoWrapper.html(video); + + // Bind a resize event to handle fluid layouts. + $(window).bind('resize', Drupal.media_youtube.resizeEmbeds); + + // For some reason Chrome does not properly size the container around the + // embed and it will just render the embed at full size unless we set this + // timeout. + if (!$('.lightbox-stack').length) { + setTimeout(Drupal.media_youtube.resizeEmbeds, 1); + } +}; + +Drupal.media_youtube.resizeEmbeds = function () { + $('.media-youtube-preview-wrapper').each(Drupal.media_youtube.resizeEmbed); +}; + +Drupal.media_youtube.resizeEmbed = function () { + var context = $(this).parent(); + var video = $(this).children(':first-child'); + var hw = Drupal.settings.media_youtube[$(this).attr('id')].hw; + // Change the height of the wrapper that was given a fixed height by the + // YouTube theming function. + $(this) + .height(context.width() * hw) + .width(context.width()); + + // Change the attributes on the embed to match the new size. + video + .height(context.width() * hw) + .width(context.width()); +}; + +})(jQuery); \ No newline at end of file diff --git a/drupal/sites/all/modules/contrib/media_youtube/media_youtube.info b/drupal/sites/all/modules/contrib/media_youtube/media_youtube.info new file mode 100644 index 0000000..3321aec --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/media_youtube.info @@ -0,0 +1,20 @@ + +name = Media: YouTube +description = Provides YouTube support to the Media module. +package = "Media" +core = 7.x +files[] = media_youtube.module +files[] = includes/MediaInternetYouTubeHandler.inc +files[] = includes/MediaYouTubeStreamWrapper.inc +files[] = includes/MediaYouTubeStyles.inc +files[] = includes/media_youtube.formatters.inc +files[] = includes/media_youtube.styles.inc +files[] = includes/media_youtube.variables.inc +dependencies[] = media_internet + +; Information added by drupal.org packaging script on 2012-01-09 +version = "7.x-1.x-dev" +core = "7.x" +project = "media_youtube" +datestamp = "1326069270" + diff --git a/drupal/sites/all/modules/contrib/media_youtube/media_youtube.install b/drupal/sites/all/modules/contrib/media_youtube/media_youtube.install new file mode 100644 index 0000000..8a413be --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/media_youtube.install @@ -0,0 +1,102 @@ + $value) { + media_youtube_variable_del($variable); + } + return array(array('success' => TRUE, 'query' => "Deleted all variables in the Media: YouTube namespace.")); +} + +/** + * Clear style and preset caches. + */ +function media_youtube_update_7001() { + // We don't do this if we're using version 1 of Styles. + if (function_exists('styles_style_flush')) { + styles_style_flush(); + } + + return array(); +} + +/** + * Add label to Media: YouTube file style. + */ +function media_youtube_update_7003() { + return array(); +} + +/** + * Rebuild themes. + */ +function media_youtube_update_7004() { + drupal_theme_rebuild(); + return array(); +} + +/** + * Add a large video preset and medium thumbnail. + */ +function media_youtube_update_7005() { + return array(); +} + +/** + * Add a square thumbnail preset. + */ +function media_youtube_update_7006() { + return array(); +} + +/** + * Rebuild the registry to locate class files in new location. + */ +function media_youtube_update_7007() { + registry_rebuild(); +} + +/** + * Rebuild styles presets to use camelCase. + */ +function media_youtube_update_7008() { + return array(); +} + +/** + * Change default styles presets. + */ +function media_youtube_update_7009() { + return array(); +} + +/** + * Change default styles presets. + */ +function media_youtube_update_7010() { + return array(); +} + +/** + * Add video presets based on Image styles. + */ +function media_youtube_update_7011() { + return array(); +} + diff --git a/drupal/sites/all/modules/contrib/media_youtube/media_youtube.module b/drupal/sites/all/modules/contrib/media_youtube/media_youtube.module new file mode 100644 index 0000000..1aee88e --- /dev/null +++ b/drupal/sites/all/modules/contrib/media_youtube/media_youtube.module @@ -0,0 +1,122 @@ + array( + 'title' => 'youtube', + 'image' => $path . '/images/stream-youtube.png' + ), + ); +} + +/** + * Implements hook_stream_wrappers(). + */ +function media_youtube_stream_wrappers() { + return array( + 'youtube' => array( + 'name' => t('YouTube videos'), + 'class' => 'MediaYouTubeStreamWrapper', + 'description' => t('Videos provided by YouTube.'), + 'type' => STREAM_WRAPPERS_READ_VISIBLE, + ), + ); +} + +/** + * Implements hook_theme(). + */ +function media_youtube_theme($existing, $type, $theme, $path) { + return array( + 'media_youtube_preview_style' => array( + 'variables' => array('style_name' => NULL), + 'file' => 'media_youtube.theme.inc', + 'path' => $path . '/includes/themes', + ), + 'media_youtube_field_formatter_styles' => array( + 'variables' => array('element' => NULL, 'style' => NULL), + 'file' => 'media_youtube.theme.inc', + 'path' => $path . '/includes/themes', + ), + 'media_youtube_video' => array( + 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'autoplay' => NULL, 'fullscreen' => NULL, 'related' => NULL), + 'file' => 'media_youtube.theme.inc', + 'path' => $path . '/includes/themes', + 'template' => 'media-youtube-video', + ), + 'media_youtube_embed' => array( + 'variables' => array('style_name' => NULL, 'uri' => NULL, 'alt' => NULL, 'title' => NULL), + 'file' => 'media_youtube.theme.inc', + 'path' => $path . '/includes/themes', + ), + 'media_youtube_styles' => array( + 'variables' => array('element' => NULL, 'style' => NULL), + 'file' => 'media_youtube.theme.inc', + 'path' => $path . '/includes/themes', + ), + ); +} + +/** + * Implements hook_media_parse(). + * + * @todo This hook should be deprecated. Refactor Media module to not call it + * any more, since media_internet should be able to automatically route to the + * appropriate handler. + */ +function media_youtube_media_parse($embed_code) { + $handler = new MediaInternetYouTubeHandler($embed_code); + return $handler->parse($embed_code); +} + +/** + * Implements hook_media_format_form_prepare_alter(). + */ +function media_youtube_media_format_form_prepare_alter(&$form, &$form_state, $media) { + $settings = array('autosubmit' => ($media->type == "video")); + drupal_add_js(array('media_format_form' => $settings), 'setting'); +} + +/** + * Implements hook_ctools_plugin_api(). + */ +function media_youtube_ctools_plugin_api($owner, $api) { + static $api_versions = array( + 'file_entity' => array( + 'file_default_displays' => 1, + ), + ); + if (isset($api_versions[$owner][$api])) { + return array('version' => $api_versions[$owner][$api]); + } +}