Projet

Général

Profil

Révision 70a4c29b

Ajouté par Assos Assos il y a environ 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media_youtube/CHANGELOG.txt
1

  
2
Changelog for the Media: YouTube module.
3
========================================
4

  
5
by aaron: Add overlay to media browser library thumbnails.
6
by aaron: Begin framework for pager support.
7
by aaron: Add an empty message.
8
by aaron: Remove old tab from browser.
9
by aaron: Begin work on adding 'All/My Youtubes' vertical tabs.
10
by aaron: Add 'YouTube Library' tab to browser w/ all youtube videos.
11
by aaron: Allow parsing of url's like youtube.com/watch#v=...
12
by aaron: Fix incorrect parse to youtube from flickr.
13
by aaron: Implement hook_media_parse().
14
by aaron: Remove link behavior for the moment.
15
by aaron: Change tab behavior to new required format.
16
by aaron: Allow w/h overrides.
17
by aaron: Add wysiwyg tab for youtube url.
18
by aaron: Add style presets for youtube.
19
by aaron: Add action link to add youtube video from media content admin.
20
by aaron: Add alt/title to embed thumbnails theme.
21
by aaron: Refactor styles containers to match new API.
22
by aaron: Add preview on parsing new youtube.
23
by aaron: Add media_youtube.js.
24
by aaron: Add a weight to style containers.
25
by aaron: Add JS behavior to url text field.
26
by aaron: Browse user + all youtube videos.
27
by aaron: New themes for styles.
28
by aaron: Begin browser forms for YouTube.
29
by aaron: Embed themes & style callbacks.
30
by aaron: Define filter callbacks.
31
by aaron: Fix return value for hook_styles_presets().
32
by aaron: Implement hook_styles_presets().
33
by aaron: Add variables to preview theme.
34
by aaron: Integrate with Styles.
35
by aaron: Add preview theme.
36
by aaron: Add test default media styles.
37
by aaron: Parse URL correctly.
38
by aaron: Register the stream wrapper.
39
by aaron: Include stream wrapper w/ module load.
40
by aaron: Rename stream wrapper implementation to MediaYouTubeStreamWrapper.
41
by aaron: Upgrade module to DRUPAL-7.
42

  
43
=============
44
 DRUPAL-7--1
45
=============
46

  
47
by aaron: Create ResourceYouTubeStreamWrapper.inc.
48
by RobW: Please read the Commit Log for further changes:
49
  http://drupal.org/node/365186/commits
drupal7/sites/all/modules/media_youtube/README.txt
1
# Media: YouTube
1
CONTENTS OF THIS FILE
2
---------------------
2 3

  
3
Media: YouTube integrates with the Media module to make YouTube videos
4
available as file entities. Users can insert YouTube videos with file fields
5
 or directly into into WYSIWYG text areas with the Media module insert button.
4
 * Introduction
5
 * Requirements
6
 * Installation
7
 * Usage
6 8

  
9
INTRODUCTION
10
------------
7 11

  
8
## File fields
12
Current Maintainers:
9 13

  
10
- Add a new "file" type field to your content type or entity. Choose the widget
11
  type "Multimedia browser". You can also select an existing file field.
12
- While setting up the field (or after selecting "edit" on an existing field)
13
  enable:
14
    - Enabled browser plugins: "Web"
15
    - Allowed remote media types: "Video"
16
    - Allowed URI schemes: "youtube:// (YouTube videos)"
14
 * Devin Carlson <http://drupal.org/user/290182>
17 15

  
18
- On "Manage display" for the file field's content or entity type, choose
19
  "Rendered file" and a view mode.
20
- Set up YouTube video formatter options for each view mode in Structure ->
21
  File types -> Manage file display. This is where you can choose size, autoplay,
22
  appearance, and special JS API integration options.
23
- When using the file field while creating or editing content, paste a YouTube
24
  video url into the Web tab.
16
Media: YouTube adds YouTube as a supported media provider.
25 17

  
26
ProTip: You can use multiple providers (e.g., Media: YouTube and Media: Vimeo)
27
on the same file field.
18
REQUIREMENTS
19
------------
28 20

  
21
Media: YouTube has one dependency.
29 22

  
30
## WYSIWYG inserts
23
Contributed modules
24
 * Media Internet - A submodule of the Media module.
31 25

  
32
- Enable the Media module "Media insert" button on your WYSIWYG profile.
33
- Enable "Convert Media tags to markup" filter in the appropriate text formats.
34
- Configure any desired settings in Configuration -> Media -> "Media browser
35
  settings"
36
- Set up YouTube video formatter options in Structure -> File types -> Manage
37
  file display. **Note:** for any view mode that will be used in a WYSIWYG,
38
  enable both the YouTube video and preview image formatter. Arrange the Video
39
  formatter on top. This allows the video to be used when the content is viewed,
40
  and the preview when the content is being edited.
26
INSTALLATION
27
------------
41 28

  
42
- When editing a text area with your WYSIWYG, click the "Media insert" button,
43
  and paste a YouTube video url into the Web tab of the media browser.
29
Media: YouTube can be installed via the standard Drupal installation process
30
(http://drupal.org/node/895232).
44 31

  
32
USAGE
33
-----
45 34

  
46
## Upgrading from 7.x-1.x or 7.x-2.0-alpha-2 to 7.x-2.0
35
Media: YouTube integrates the YouTube video-sharing service with the Media
36
module to allow users to add and manage YouTube videos as they would any other
37
piece of media.
47 38

  
48
There are some important changes between the older recommended versions of
49
Media: YouTube and the new stable release that may require manual updating.
50

  
51
- 2.0 uses the YouTube iframe embed with the currently supported player
52
  parameters. If you were relying on parameters that no longer work with
53
  the iframe player, you may see some minor differences in player appearance.
54
  Please review your formatter settings after you update.
55

  
56
- **The markup for the player embed has changed.** The 2.0 and 2.x-dev versions
57
  use simplified and updated markup that integrates better with responsive
58
  video techniques. There is a tpl provided at /includes/themes/media-youtube-
59
  video.legacy-example.tpl.php that duplicates the old markup. To use it, copy
60
  it to your theme folder and rename it to media-youtube-video.tpl.php. It is
61
  recommended that you revise any css or javascript that requires the old
62
  markup and then delete the legacy markup tpl file.
63

  
64

  
65
## Further Reading
66

  
67
- Media 2.x Overview, including file entities and view modes:
68
  http://drupal.stackexchange.com/questions/40229/how-to-set-media-styles-in-media-7-1-2-media-7-2-x/40685#40685
69
- Media 2.x Walkthrough: http://drupal.org/node/1699054
70
- YouTube player parameters and explanation. Media: YouTube uses only iframe
71
  player parameters:
72
  https://developers.google.com/youtube/player_parameters#Parameters
73
- YouTube JS API example:
74
  http://stackoverflow.com/questions/7443578/youtube-iframe-api-how-do-i-control-a-iframe-player-thats-already-in-the-html/7513356#7513356
39
Internet media can be added on the Web tab of the Add file page (file/add/web).
40
With Media: YouTube enabled, users can add a YouTube video by entering its URL
41
or embed code.
drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc
1 1
<?php
2 2

  
3 3
/**
4
 * @file media_youtube/includes/MediaInterenetYouTubeHandler.inc
5
 *
6
 * Contains MediaInternetYouTubeHandler.
4
 * @file
5
 * Extends the MediaInternetBaseHandler class to handle YouTube videos.
7 6
 */
8 7

  
9 8
/**
......
12 11
 * @see hook_media_internet_providers().
13 12
 */
14 13
class MediaInternetYouTubeHandler extends MediaInternetBaseHandler {
15
  /**
16
   * Check if a YouTube video id is valid.
17
   *
18
   * Check against the oembed stream instead of the gdata api site to
19
   * avoid "yt:quota too_many_recent_calls" errors.
20
   *
21
   * @return
22
   *   Boolean.
23
   */
24
  static public function validId($id) {
25
    $url = 'http://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3D'. $id;
26
    $response = drupal_http_request($url, array('method' => 'HEAD'));
27
    if ($response->code == 401) {
28
      throw new MediaInternetValidationException("Embedding has been disabled for this video.");
29
    }
30
    elseif ($response->code != 200) {
31
      throw new MediaInternetValidationException("The YouTube video ID is invalid or the video was deleted.");
32
    }
33
    return TRUE;
34
  }
35

  
36 14
  public function parse($embedCode) {
15
    // http://youtube.com/watch/*
16
    // http://youtube.com/embed/*
17
    // http://youtube.com/v/*
18
    // http://youtube.com/?v=*
19
    // http://youtu.be/*
20
    // http://gdata.youtube.com/feeds/api/videos/*
37 21
    $patterns = array(
38 22
      '@youtube\.com/watch[#\?].*?v=([^"\& ]+)@i',
39 23
      '@youtube\.com/embed/([^"\&\? ]+)@i',
......
42 26
      '@youtu\.be/([^"\&\? ]+)@i',
43 27
      '@gdata\.youtube\.com/feeds/api/videos/([^"\&\? ]+)@i',
44 28
    );
29

  
45 30
    foreach ($patterns as $pattern) {
46 31
      preg_match($pattern, $embedCode, $matches);
47 32
      // @TODO: Parse is called often. Refactor so that valid ID is checked
......
62 47
    $uri = $this->parse($this->embedCode);
63 48
    $file = file_uri_to_object($uri, TRUE);
64 49

  
50
    // Try to default the file name to the video's title.
65 51
    if (empty($file->fid) && $info = $this->getOEmbed()) {
66 52
      $file->filename = truncate_utf8($info['title'], 255);
67 53
    }
......
70 56
  }
71 57

  
72 58
  /**
73
   * Returns information about the media. See http://video.search.yahoo.com/mrss.
59
   * Returns information about the media.
74 60
   *
75
   * @return
76
   *   If ATOM+MRSS information is available, a SimpleXML element containing
77
   *   ATOM and MRSS elements, as per those respective specifications.
78
   *
79
   * @todo Would be better for the return value to be an array rather than a
80
   *   SimpleXML element, but media_retrieve_xml() needs to be upgraded to
81
   *   handle namespaces first.
82
   */
83
  public function getMRSS() {
84
    $uri = $this->parse($this->embedCode);
85
    $video_id = arg(1, file_uri_target($uri));
86
    $rss_url = url('http://gdata.youtube.com/feeds/api/videos/' . $video_id, array('query' => array('v' => '2')));
87
    // @todo Use media_retrieve_xml() once it's upgraded to include elements
88
    //   from all namespaces, not just the document default namespace.
89
    $request = drupal_http_request($rss_url);
90
    if (!isset($request->error)) {
91
      $entry = simplexml_load_string($request->data);
92
    }
93
    else {
94
      throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
95

  
96
      //if request wasn't successful, create object for return to avoid errors
97
      $entry = new SimpleXMLElement();
98
    }
99
    return $entry;
100
  }
101

  
102
  /**
103
   * Returns information about the media. See http://www.oembed.com/.
61
   * See http://www.oembed.com.
104 62
   *
105 63
   * @return
106 64
   *   If oEmbed information is available, an array containing 'title', 'type',
......
112 70
    $external_url = file_create_url($uri);
113 71
    $oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
114 72
    $response = drupal_http_request($oembed_url);
73

  
115 74
    if (!isset($response->error)) {
116 75
      return drupal_json_decode($response->data);
117 76
    }
......
120 79
      return;
121 80
    }
122 81
  }
82

  
83
  /**
84
   * Check if a YouTube video ID is valid.
85
   *
86
   * @return boolean
87
   *   TRUE if the video ID is valid, or throws a
88
   *   MediaInternetValidationException otherwise.
89
   */
90
  static public function validId($id) {
91
    $uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($id));
92
    $external_url = file_create_url($uri);
93
    $oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
94
    $response = drupal_http_request($oembed_url, array('method' => 'HEAD'));
95

  
96
    if ($response->code == 401) {
97
      throw new MediaInternetValidationException('Embedding has been disabled for this YouTube video.');
98
    }
99
    elseif ($response->code != 200) {
100
      throw new MediaInternetValidationException('The YouTube video ID is invalid or the video was deleted.');
101
    }
102

  
103
    return TRUE;
104
  }
123 105
}
drupal7/sites/all/modules/media_youtube/includes/MediaYouTubeBrowser.inc
14 14
   * Implements MediaBrowserPluginInterface::access().
15 15
   */
16 16
  public function access($account = NULL) {
17
    // @TODO: media_access() is a wrapper for file_entity_access(). Switch to the
18
    // new function when Media 1.x is deprecated.
19
    return media_access('create', $account);
17
    return media_internet_access($account);
20 18
  }
21 19

  
22 20
  /**
23 21
   * Implements MediaBrowserPlugin::view().
24 22
   */
25 23
  public function view() {
26
    // Check if the user is able to add remote media.
27
    if (user_access('add media from remote sources')) {
28
      $build['form'] = drupal_get_form('media_youtube_add', $this->params['types'], $this->params['multiselect']);
29
      return $build;
30
    }
24
    $build = array();
25
    $params = $this->params;
26
    $build['form'] = drupal_get_form('media_youtube_add', $params);
27

  
28
    return $build;
31 29
  }
32 30
}
drupal7/sites/all/modules/media_youtube/includes/MediaYouTubeStreamWrapper.inc
1 1
<?php
2 2

  
3 3
/**
4
 *  @file media_youtube/includes/MediaYouTubeStreamWrapper.inc
5
 *
6
 *  Create a YouTube Stream Wrapper class for the Media/Resource module.
4
 *  @file
5
 *  Extends the MediaReadOnlyStreamWrapper class to handle YouTube videos.
7 6
 */
8 7

  
9 8
/**
......
11 10
 *  $youtube = new MediaYouTubeStreamWrapper('youtube://v/[video-code]');
12 11
 */
13 12
class MediaYouTubeStreamWrapper extends MediaReadOnlyStreamWrapper {
14

  
15
  // Overrides $base_url defined in MediaReadOnlyStreamWrapper.
16 13
  protected $base_url = 'http://www.youtube.com/watch';
17 14

  
18
  /**
19
   * Returns a url in the format "http://www.youtube.com/watch?v=qsPQN4MiTeE".
20
   *
21
   * Overrides interpolateUrl() defined in MediaReadOnlyStreamWrapper.
22
   * This is an exact copy of the function in MediaReadOnlyStreamWrapper,
23
   * here in case that example is redefined or removed.
24
   */
25
  function interpolateUrl() {
26
    if ($parameters = $this->get_parameters()) {
27
      return $this->base_url . '?' . http_build_query($parameters);
28
    }
29
  }
30

  
31 15
  static function getMimeType($uri, $mapping = NULL) {
32 16
    return 'video/youtube';
33 17
  }
34 18

  
35
  function getTarget($f) {
36
    return FALSE;
37
  }
38

  
39 19
  function getOriginalThumbnailPath() {
40 20
    $parts = $this->get_parameters();
41
    return 'http://img.youtube.com/vi/' . check_plain($parts['v']) . '/0.jpg';
21
    $v = check_plain($parts['v']);
22
    //  Attempt to pull a HD thumbnail from YouTube. If it exists pass it on
23
    //  otherwise pass on the smaller one.
24
    $thumbname = drupal_tempnam('temporary://', 'youtube');
25
    $response = drupal_http_request('http://img.youtube.com/vi/' . $v . '/maxresdefault.jpg');
26
    if (!isset($response->error)) {
27
      file_unmanaged_save_data($response->data, $thumbname, $replace = FILE_EXISTS_REPLACE);
28
    }
29
    if ((filesize($thumbname)) == 0) {
30
      return 'http://img.youtube.com/vi/' . $v . '/0.jpg';
31
    }
32
    else {
33
      return 'http://img.youtube.com/vi/' . $v . '/maxresdefault.jpg';
34
    }
42 35
  }
43 36

  
44 37
  function getLocalThumbnailPath() {
45 38
    $parts = $this->get_parameters();
46
    $local_path = file_default_scheme() . '://media-youtube/' . check_plain($parts['v']) . '.jpg';
39
    // There's no need to hide thumbnails, always use the public system rather
40
    // than file_default_scheme().
41
    $local_path = 'public://media-youtube/' . check_plain($parts['v']) . '.jpg';
42

  
47 43
    if (!file_exists($local_path)) {
48 44
      $dirname = drupal_dirname($local_path);
49 45
      file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
50 46
      $response = drupal_http_request($this->getOriginalThumbnailPath());
47

  
51 48
      if (!isset($response->error)) {
52 49
        file_unmanaged_save_data($response->data, $local_path, TRUE);
53 50
      }
......
55 52
        @copy($this->getOriginalThumbnailPath(), $local_path);
56 53
      }
57 54
    }
55

  
58 56
    return $local_path;
59 57
  }
60 58
}
drupal7/sites/all/modules/media_youtube/includes/media_youtube.formatters.inc
1 1
<?php
2 2

  
3 3
/**
4
 * @file media_youtube/includes/media_youtube.formatters.inc
5
 *
6
 * Formatters for Media: YouTube.
4
 * @file
5
 * File formatters for YouTube videos.
7 6
 */
8 7

  
9 8
/**
......
13 12
  $formatters['media_youtube_video'] = array(
14 13
    'label' => t('YouTube Video'),
15 14
    'file types' => array('video'),
16
    'default settings' => array(),
15
    'default settings' => array(
16
      'width' => 640,
17
      'height' => 390,
18
      'autohide' => 2,
19
      'autoplay' => FALSE,
20
      'color' => 'red',
21
      'enablejsapi' => FALSE,
22
      'loop' => FALSE,
23
      'modestbranding' => FALSE,
24
      'nocookie' => FALSE,
25
      'origin' => '',
26
      'protocol' => 'https:',
27
      'protocol_specify' => FALSE,
28
      'rel' => TRUE,
29
      'showinfo' => TRUE,
30
      'theme' => 'dark',
31
      'captions' => FALSE,
32
    ),
17 33
    'view callback' => 'media_youtube_file_formatter_video_view',
18 34
    'settings callback' => 'media_youtube_file_formatter_video_settings',
19 35
    'mime types' => array('video/youtube'),
20 36
  );
21 37

  
22
  $formatters['media_youtube_video']['default settings'] = array(
23
    'width' => 640,
24
    'height' => 390,
25
    'autohide' => 2,
26
    'autoplay' => FALSE,
27
    'color' => 'red',
28
    'enablejsapi' => FALSE,
29
    'loop' => FALSE,
30
    'modestbranding' => FALSE,
31
    'nocookie' => FALSE,
32
    'origin' => '',
33
    'protocol' => 'https:',
34
    'protocol_specify' => FALSE,
35
    'rel' => TRUE,
36
    'showinfo' => TRUE,
37
    'theme' => 'dark',
38
  );
39

  
40 38
  $formatters['media_youtube_image'] = array(
41 39
    'label' => t('YouTube Preview Image'),
42 40
    'file types' => array('video'),
......
56 54
 */
57 55
function media_youtube_file_formatter_video_view($file, $display, $langcode) {
58 56
  $scheme = file_uri_scheme($file->uri);
57

  
59 58
  // WYSIWYG does not yet support video inside a running editor instance.
60 59
  if ($scheme == 'youtube' && empty($file->override['wysiwyg'])) {
61 60
    $element = array(
......
67 66
    // Fake a default for attributes so the ternary doesn't choke.
68 67
    $display['settings']['attributes'] = array();
69 68

  
70
    foreach (array('width', 'height', 'autohide', 'autoplay', 'color', 'enablejsapi', 'loop', 'modestbranding', 'nocookie', 'origin', 'protocol', 'protocol_specify', 'rel', 'showinfo', 'theme', 'attributes') as $setting) {
69
    foreach (array('width', 'height', 'autohide', 'autoplay', 'color', 'enablejsapi', 'loop', 'modestbranding', 'nocookie', 'origin', 'protocol', 'protocol_specify', 'rel', 'showinfo', 'theme', 'attributes', 'captions') as $setting) {
71 70
      $element['#options'][$setting] = isset($file->override[$setting]) ? $file->override[$setting] : $display['settings'][$setting];
72 71
    }
72

  
73 73
    return $element;
74 74
  }
75 75
}
......
124 124
    ),
125 125
    '#default_value' => $settings['autohide'],
126 126
  );
127
  $element['captions'] = array(
128
    '#title' => t('Captions displaying options'),
129
    '#type' => 'radios',
130
    '#options' => array(
131
      '0' => t('Turns captions off by default'),
132
      '1' => t('Turns captions on by default'),
133
      '2' => t('Turns captions on and set the caption language for the video by default'),
134
    ),
135
    '#default_value' => $settings['captions'],
136
  );
127 137

  
128 138
  // Single Options.
129 139
  $element['autoplay'] = array(
......
207 217
 * Validation for width and height.
208 218
 */
209 219
function _youtube_validate_video_width_and_height($element, &$form_state, $form) {
210

  
211 220
  // Check if the value is a number with an optional decimal or percentage sign, or "auto".
212 221
  if (!empty($element['#value']) && !preg_match('/^(auto|([0-9]*(\.[0-9]+)?%?))$/', $element['#value'])) {
213 222
    form_error($element, t("The value entered for @dimension is invalid. Please insert a unitless integer for pixels, a percent, or \"auto\". Note that percent and auto may not function correctly depending on the browser and doctype.", array('@dimension' => $element['#title'])));
......
218 227
 * Validation for Js API Origin.
219 228
 */
220 229
function _youtube_validate_jsapi_domain ($element, &$form_state, $form) {
221

  
222 230
  // Check if the value is a url with http/s and no trailing directories.
223 231
  if (!empty($element['#value']) && !preg_match('/^https?\:\/\/[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}){1,2}$/', $element['#value'])) {
224 232
    form_error($element, t('Please insert a valid domain in the format http://www.yourdomain.com'));
......
234 242
    $wrapper = file_stream_wrapper_get_instance_by_uri($file->uri);
235 243
    $image_style = $display['settings']['image_style'];
236 244
    $valid_image_styles = image_style_options(FALSE);
237
    // @TODO: If autosubmit is removed and we allow view modes that insert
238
    // images in the WYSIWYG, add file->overrides handling.
245

  
239 246
    if (empty($image_style) || !isset($valid_image_styles[$image_style])) {
240 247
      $element = array(
241 248
        '#theme' => 'image',
242
        '#path' => $wrapper->getOriginalThumbnailPath(),
249
        '#path' => str_replace('http:', '', $wrapper->getOriginalThumbnailPath()),
243 250
        '#alt' => isset($file->override['attributes']['alt']) ? $file->override['attributes']['alt'] : $file->filename,
244 251
      );
245 252
    }
......
261 268
 */
262 269
function media_youtube_file_formatter_image_settings($form, &$form_state, $settings) {
263 270
  $element = array();
271

  
264 272
  $element['image_style'] = array(
265 273
    '#title' => t('Image style'),
266 274
    '#type' => 'select',
......
268 276
    '#default_value' => $settings['image_style'],
269 277
    '#empty_option' => t('None (original image)'),
270 278
  );
271
  return $element;
272
}
273

  
274
/**
275
 * Implements hook_file_default_displays_alter().
276
 */
277
function media_youtube_file_default_displays_alter(&$file_displays) {
278
  // Video previews should be displayed using a large filetype icon.
279
  $file_display = new stdClass();
280
  $file_display->api_version = 1;
281
  $file_display->name = 'video__default__media_youtube_video';
282
  $file_display->weight = 0;
283
  $file_display->status = TRUE;
284
  $file_display->settings = array(
285
    'width' => '640',
286
    'height' => '390',
287
    'theme' => 'dark',
288
    'color' => 'red',
289
    'autohide' => '2',
290
    'autoplay' => 0,
291
    'loop' => 0,
292
    'showinfo' => 1,
293
    'modestbranding' => 0,
294
    'rel' => 1,
295
    'nocookie' => 0,
296
    'protocol_specify' => 0,
297
    'protocol' => 'https:',
298
    'enablejsapi' => 0,
299
    'origin' => '',
300
  );
301
  $file_displays['video__default__media_youtube_video'] = $file_display;
302

  
303
  $file_display = new stdClass();
304
  $file_display->api_version = 1;
305
  $file_display->name = 'video__preview__media_youtube_image';
306
  $file_display->weight = 0;
307
  $file_display->status = TRUE;
308
  $file_display->settings = array(
309
    'image_style' => 'media_thumbnail',
310
  );
311
  $file_displays['video__preview__media_youtube_image'] = $file_display;
312 279

  
313
  $file_display = new stdClass();
314
  $file_display->api_version = 1;
315
  $file_display->name = 'video__teaser__media_youtube_video';
316
  $file_display->weight = 0;
317
  $file_display->status = TRUE;
318
  $file_display->settings = array(
319
    'width' => '560',
320
    'height' => '340',
321
    'theme' => 'dark',
322
    'color' => 'red',
323
    'autohide' => '2',
324
    'autoplay' => 0,
325
    'loop' => 0,
326
    'showinfo' => 1,
327
    'modestbranding' => 0,
328
    'rel' => 1,
329
    'nocookie' => 0,
330
    'protocol_specify' => 0,
331
    'protocol' => 'https:',
332
    'enablejsapi' => 0,
333
    'origin' => '',
334
  );
335
  $file_displays['video__teaser__media_youtube_video'] = $file_display;
280
  return $element;
336 281
}
drupal7/sites/all/modules/media_youtube/js/media-youtube.browser.js
25 25
        // Set the current item to active
26 26
        $(this).addClass('selected');
27 27
        // Add this FID to the array of selected files
28
        var uri = $(this).parent('a[data-uri]').attr('data-uri');
28
        var uri = $(this).parent('li.media-youtube-wrapper[data-uri]').attr('data-uri');
29 29
        // Get the file from the settings which was stored in
30 30
        // template_preprocess_media_views_view_media_browser()
31 31
        var file = Drupal.settings.media.files[uri];
drupal7/sites/all/modules/media_youtube/media_youtube.file_default_displays.inc
1
<?php
2

  
3
/**
4
 * @file
5
 * Default display configuration for the default file types.
6
 */
7

  
8
/**
9
 * Implements hook_file_default_displays().
10
 */
11
function media_youtube_file_default_displays() {
12
  $file_displays = array();
13

  
14
  // Media: YouTube 7.x-2.x.
15
  $file_display = new stdClass();
16
  $file_display->api_version = 1;
17
  $file_display->name = 'video__default__media_youtube_video';
18
  $file_display->weight = 0;
19
  $file_display->status = TRUE;
20
  $file_display->settings = array(
21
    'width' => '640',
22
    'height' => '390',
23
    'theme' => 'dark',
24
    'color' => 'red',
25
    'autohide' => '2',
26
    'autoplay' => 0,
27
    'loop' => 0,
28
    'showinfo' => 1,
29
    'modestbranding' => 0,
30
    'rel' => 1,
31
    'nocookie' => 0,
32
    'protocol_specify' => 0,
33
    'protocol' => 'https:',
34
    'enablejsapi' => 0,
35
    'origin' => '',
36
  );
37
  $file_displays['video__default__media_youtube_video'] = $file_display;
38

  
39
  $file_display = new stdClass();
40
  $file_display->api_version = 1;
41
  $file_display->name = 'video__preview__media_youtube_image';
42
  $file_display->weight = 0;
43
  $file_display->status = TRUE;
44
  $file_display->settings = array(
45
    'image_style' => 'media_thumbnail',
46
  );
47
  $file_displays['video__preview__media_youtube_image'] = $file_display;
48

  
49
  $file_display = new stdClass();
50
  $file_display->api_version = 1;
51
  $file_display->name = 'video__teaser__media_youtube_video';
52
  $file_display->weight = 0;
53
  $file_display->status = TRUE;
54
  $file_display->settings = array(
55
    'width' => '560',
56
    'height' => '340',
57
    'theme' => 'dark',
58
    'color' => 'red',
59
    'autohide' => '2',
60
    'autoplay' => 0,
61
    'loop' => 0,
62
    'showinfo' => 1,
63
    'modestbranding' => 0,
64
    'rel' => 1,
65
    'nocookie' => 0,
66
    'protocol_specify' => 0,
67
    'protocol' => 'https:',
68
    'enablejsapi' => 0,
69
    'origin' => '',
70
  );
71
  $file_displays['video__teaser__media_youtube_video'] = $file_display;
72

  
73
  // Media: YouTube 7.x-1.x.
74
  $file_display = new stdClass();
75
  $file_display->api_version = 1;
76
  $file_display->name = 'video__media_original__media_youtube_video';
77
  $file_display->weight = 0;
78
  $file_display->status = TRUE;
79
  $file_display->settings = array(
80
    'width' => '640',
81
    'height' => '390',
82
    'theme' => 'dark',
83
    'color' => 'red',
84
    'autohide' => '2',
85
    'autoplay' => 0,
86
    'loop' => 0,
87
    'showinfo' => 1,
88
    'modestbranding' => 0,
89
    'rel' => 1,
90
    'nocookie' => 0,
91
    'protocol_specify' => 0,
92
    'protocol' => 'https:',
93
    'enablejsapi' => 0,
94
    'origin' => '',
95
  );
96
  $file_displays['video__media_original__media_youtube_video'] = $file_display;
97

  
98
  $file_display = new stdClass();
99
  $file_display->api_version = 1;
100
  $file_display->name = 'video__media_large__media_youtube_video';
101
  $file_display->weight = 0;
102
  $file_display->status = TRUE;
103
  $file_display->settings = array(
104
    'width' => '640',
105
    'height' => '390',
106
    'theme' => 'dark',
107
    'color' => 'red',
108
    'autohide' => '2',
109
    'autoplay' => 0,
110
    'loop' => 0,
111
    'showinfo' => 1,
112
    'modestbranding' => 0,
113
    'rel' => 1,
114
    'nocookie' => 0,
115
    'protocol_specify' => 0,
116
    'protocol' => 'https:',
117
    'enablejsapi' => 0,
118
    'origin' => '',
119
  );
120
  $file_displays['video__media_large__media_youtube_video'] = $file_display;
121

  
122
  $file_display = new stdClass();
123
  $file_display->api_version = 1;
124
  $file_display->name = 'video__media_small__media_youtube_video';
125
  $file_display->weight = 0;
126
  $file_display->status = TRUE;
127
  $file_display->settings = array(
128
    'width' => '560',
129
    'height' => '340',
130
    'theme' => 'dark',
131
    'color' => 'red',
132
    'autohide' => '2',
133
    'autoplay' => 0,
134
    'loop' => 0,
135
    'showinfo' => 1,
136
    'modestbranding' => 0,
137
    'rel' => 1,
138
    'nocookie' => 0,
139
    'protocol_specify' => 0,
140
    'protocol' => 'https:',
141
    'enablejsapi' => 0,
142
    'origin' => '',
143
  );
144
  $file_displays['video__media_small__media_youtube_video'] = $file_display;
145

  
146
  $file_display = new stdClass();
147
  $file_display->api_version = 1;
148
  $file_display->name = 'video__media_preview__media_youtube_image';
149
  $file_display->weight = 0;
150
  $file_display->status = TRUE;
151
  $file_display->settings = array(
152
    'image_style' => 'square_thumbnail',
153
  );
154
  $file_displays['video__media_preview__media_youtube_image'] = $file_display;
155

  
156
  $file_display = new stdClass();
157
  $file_display->api_version = 1;
158
  $file_display->name = 'video__media_link__file_field_file_default';
159
  $file_display->weight = 0;
160
  $file_display->status = TRUE;
161
  $file_display->settings = '';
162
  $file_displays['video__media_link__file_field_file_default'] = $file_display;
163

  
164
  return $file_displays;
165
}
drupal7/sites/all/modules/media_youtube/media_youtube.info
1 1
name = Media: YouTube
2
description = Provides YouTube support for File Entity and the Media module.
3
package = "Media"
2
description = Adds YouTube as a supported media provider.
3
package = Media
4 4
core = 7.x
5
files[] = includes/MediaInternetYouTubeHandler.inc
5

  
6
dependencies[] = media_internet
7

  
6 8
files[] = includes/MediaYouTubeStreamWrapper.inc
9
files[] = includes/MediaInternetYouTubeHandler.inc
7 10
files[] = includes/MediaYouTubeBrowser.inc
8
dependencies[] = media_internet
9 11

  
10
; Information added by drupal.org packaging script on 2013-10-26
11
version = "7.x-2.0-rc4"
12
; Information added by Drupal.org packaging script on 2015-03-23
13
version = "7.x-2.0-rc5"
12 14
core = "7.x"
13 15
project = "media_youtube"
14
datestamp = "1382761825"
16
datestamp = "1427094782"
15 17

  
drupal7/sites/all/modules/media_youtube/media_youtube.install
156 156
    variable_del("media_youtube__{$setting}");
157 157
  }
158 158
}
159

  
160
/**
161
 * Update the Media YouTube browser's access check.
162
 *
163
 * Check your permissions; after this update the Media YouTube browser will be
164
 * available to users with the "administer files" or "add media from remote
165
 * sources" permissions only.
166
 */
167
function media_youtube_update_7204() {
168
}
drupal7/sites/all/modules/media_youtube/media_youtube.module
1 1
<?php
2 2

  
3 3
/**
4
 * @file media_youtube/media_youtube.module
5
 *
6
 * Media: YouTube provides a stream wrapper and formatters for videos provided
7
 * by YouTube, available at http://youtube.com/.
8
 *
9
 * @TODO:
10
 * Get the YouTube tab working.
11
 *  - Search by video name, user name, and channel.
12
 *  - Default to user's channel videos.
13
 * Review all code and remove cruft.
14
 * Assess if M:YT 3.x could be formatters added on to the OEmbed module.
4
 * @file
5
 * Provides a stream wrapper and formatters appropriate for accessing and
6
 * displaying YouTube videos.
15 7
 */
16 8

  
17 9
/**
......
22 14
 */
23 15
define('MEDIA_YOUTUBE_REST_API', 'https://gdata.youtube.com/feeds/api/videos');
24 16

  
25
// Hooks and callbacks for integrating with File Entity module for display.
17
// Load all YouTube file formatters.
26 18
require_once dirname(__FILE__) . '/includes/media_youtube.formatters.inc';
27 19

  
28 20
/**
29 21
 * Implements hook_media_internet_providers().
30 22
 */
31 23
function media_youtube_media_internet_providers() {
32
  $info['MediaInternetYouTubeHandler'] = array(
33
    'title' => t('YouTube'),
24
  return array(
25
    'MediaInternetYouTubeHandler' => array(
26
      'title' => t('YouTube'),
27
    ),
34 28
  );
35

  
36
  return $info;
37 29
}
38 30

  
39 31
/**
......
44 36
    'youtube' => array(
45 37
      'name' => t('YouTube videos'),
46 38
      'class' => 'MediaYouTubeStreamWrapper',
47
      'description' => t('Videos provided by YouTube.'),
39
      'description' => t('Remote videos hosted on the YouTube video-sharing website.'),
48 40
      'type' => STREAM_WRAPPERS_READ_VISIBLE,
49 41
    ),
50 42
  );
......
78 70

  
79 71
/**
80 72
 * Implements hook_file_mimetype_mapping_alter().
81
 *
82
 * Register the video/youtube mimetype.
83 73
 */
84 74
function media_youtube_file_mimetype_mapping_alter(&$mapping) {
85 75
  $mapping['mimetypes'][] = 'video/youtube';
86 76
}
87 77

  
78
/**
79
 * Implements hook_ctools_plugin_api().
80
 */
81
function media_youtube_ctools_plugin_api($module, $api) {
82
  if ($module == 'file_entity' && $api == 'file_default_displays') {
83
    return array('version' => 1);
84
  }
85
}
86

  
88 87
/**
89 88
 * YouTube search tab for the Media browser.
90 89
 */
......
142 141
    $empty = TRUE;
143 142
  }
144 143
  else {
145
    foreach ($search['entry'] as $video) {
144
    // $search['entry'] is different depending on whether there is a single
145
    // result or multiple results. So normalise it.
146
    $videos = isset($search['entry']['id']) ? array($search['entry']) : $search['entry'];
147
    foreach ($videos as $video) {
146 148
      try {
147 149
        $uri = media_parse_to_uri($video['link'][0]['@attributes']['href']);
148 150
      }
......
157 159
        $file->fid = 0;
158 160
      }
159 161
      media_browser_build_media_item($file);
160
      $file->preview = l($file->preview, 'media/browser', array(
161
        'html' => TRUE,
162
        'attributes' => array(
163
          'data-uri' => $uri,
164
        ),
165
        'query' => array('render' => 'media-popup', 'uri' => $uri),
166
      ));
162
      $attributes = array(
163
        'data-uri' => $uri,
164
        'class' => array('media-youtube-wrapper'),
165
      );
167 166
      $form['videos'][$uri] = array(
168 167
        '#markup' => $file->preview,
169
        '#prefix' => '<li>',
168
        '#prefix' => '<li' . drupal_attributes($attributes) . '>',
170 169
        '#suffix' => '</li>',
171 170
      );
172 171
      $files[$uri] = $file;
......
253 252
    return;
254 253
  }
255 254

  
256
  $validators = $form['#validators'];
255
  $validators = isset($form['#validators']) ? $form['#validators'] : array();
257 256
  if ($validators) {
258 257
    // Check for errors. @see media_add_upload_validate calls file_save_upload().
259 258
    // this code is ripped from file_save_upload because we just want the validation part.
......
308 307
  }
309 308

  
310 309
  // Redirect to the file edit page after submission.
311
  // @TODO: media_access() is a wrapper for file_entity_access(). Switch to the
312
  // new function when Media 1.x is deprecated.
313
  if (media_access('update', $file)) {
310
  if (media_youtube_access('update', $file)) {
314 311
    $destination = array('destination' => 'admin/content/file');
315 312
    if (isset($_GET['destination'])) {
316 313
      $destination = drupal_get_destination();
......
323 320
  }
324 321
}
325 322

  
323
/**
324
 * Determine if a user may perform the given operation on the specified file.
325
 *
326
 * Enables compatibility with Media 1.x and 2.x by providing a wrapper around
327
 * both media_access() and file_entity_access().
328
 *
329
 * @return boolean
330
 *   TRUE if the operation may be performed, FALSE otherwise.
331
 *
332
 * @see media_access()
333
 * @see file_entity_access()
334
 */
335
function media_youtube_access($op, $file = NULL, $account = NULL) {
336
  if (function_exists('file_entity_access')) {
337
    $access = file_entity_access($op, $file, $account);
338
  }
339
  elseif (function_exists('media_access')) {
340
    $access = media_access($op, $account);
341
  }
342
  else {
343
    $access = FALSE;
344
  }
345

  
346
  return $access;
347
}
348

  
326 349
/**
327 350
 * @TODO: Document this function.
328 351
 */
drupal7/sites/all/modules/media_youtube/themes/media-youtube-video.legacy-example.tpl.php
1
<?php
1
<?php
2 2

  
3 3
/**
4 4
 * @file media_youtube/themes/media-youtube-video-legacy.tpl.php
drupal7/sites/all/modules/media_youtube/themes/media_youtube.theme.inc
10 10
 * Preprocess function for theme('media_youtube_video').
11 11
 */
12 12
function media_youtube_preprocess_media_youtube_video(&$variables) {
13

  
14 13
  // Build the URI.
15 14
  $wrapper = file_stream_wrapper_get_instance_by_uri($variables['uri']);
16 15
  $parts = $wrapper->get_parameters();
......
39 38
    $query['playerapiid'] = drupal_html_id('media-youtube-' . $variables['video_id']);
40 39
    $variables['api_id_attribute'] = 'id="' . $query['playerapiid'] . '" ';
41 40

  
42
    //Add the origin for improved security
41
    // Add the origin for improved security
43 42
    $variables['options']['origin'] ? $query['origin'] = $variables['options']['origin'] : '';
44 43
  }
45 44
  else {
......
74 73
  if ($variables['options']['autohide'] != '2') {
75 74
    $query['autohide'] = $variables['options']['autohide'];
76 75
  }
76
  if ($variables['options']['captions'] > '0') {
77
    // Add captions parameters to the query.
78
    $query['cc_load_policy'] = '1';
79
    if ($variables['options']['captions'] > '1') {
80
      global $language;
81
      // We can specify a default language for captions.
82
      if ($language->language != LANGUAGE_NONE) {
83
        $query['cc_lang_pref'] = $language->language;
84
      }
85
    }
86
  }
77 87

  
78 88
  // Non-query options.
79 89
  if ($variables['options']['nocookie']) {
drupal7/sites/all/themes/mayo/js/mayo-fontsize.js
2 2
 * @file
3 3
 * Adds javascript functions for font resizing.
4 4
 */
5
jQuery(document).ready(function() {
6
  var originalFontSize = jQuery('body').css('font-size');
5
(function ($) {
6
$(document).ready(function() {
7
  var originalFontSize = $('body').css('font-size');
7 8

  
8 9
  // Reset font size
9
  jQuery(".resetFont").click(function() {
10
  $(".resetFont").click(function() {
10 11
    mayoColumnsResetHeight();
11
    jQuery('body').css('font-size', originalFontSize);
12
    $('body').css('font-size', originalFontSize);
12 13
    mayoColumnsAdjustHeight();
13 14
    return false;
14 15
  });
15 16

  
16 17
  // Increase font size
17
  jQuery(".increaseFont").click(function() {
18
    var currentFontSize = jQuery('body').css('font-size');
18
  $(".increaseFont").click(function() {
19
    var currentFontSize = $('body').css('font-size');
19 20
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
20 21
    var newFontSizeNum = currentFontSizeNum + 1;
21 22
    if (20 >= newFontSizeNum) { /* max 20px */
22 23
      var newFontSize = newFontSizeNum + 'px';
23 24
      mayoColumnsResetHeight();
24
      jQuery('body').css('font-size', newFontSize);
25
      $('body').css('font-size', newFontSize);
25 26
      mayoColumnsAdjustHeight();
26 27
    }
27 28
    return false;
28 29
  });
29 30

  
30 31
  // Decrease font size
31
  jQuery(".decreaseFont").click(function() {
32
    var currentFontSize = jQuery('body').css('font-size');
32
  $(".decreaseFont").click(function() {
33
    var currentFontSize = $('body').css('font-size');
33 34
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
34 35
    var newFontSizeNum = currentFontSizeNum - 1;
35 36
    if (10 <= newFontSizeNum) { /* min 10px */
36 37
      var newFontSize = newFontSizeNum + 'px';
37 38
      mayoColumnsResetHeight();
38
      jQuery('body').css('font-size', newFontSize);
39
      $('body').css('font-size', newFontSize);
39 40
      mayoColumnsAdjustHeight();
40 41
    }
41 42
    return false;
42 43
  });
43 44
});
45
})(jQuery);
46

  
47
function mayoEqualHeight(group) {
48
  var tallest = 0;
49
  group.each(function() {
50
    var thisHeight = jQuery(this).height();
51
    if (thisHeight > tallest) {
52
      tallest = thisHeight;
53
    }
54
  });
55
  group.height(tallest);
56
}
44 57

  
45 58
function mayoColumnsResetHeight() {
46 59
  // reset height of column blocks to 'auto' before chaning font size
drupal7/sites/all/themes/mayo/mayo.info
146 146
  settings[global_default_layout]         = 'smalltouch-portrait'
147 147
  settings[global_default_layout_toggle]  = 0
148 148
  settings[global_files_path]             = 'public_files'
149
; Information added by Drupal.org packaging script on 2015-02-10
150
version = "7.x-2.4"
149
; Information added by Drupal.org packaging script on 2015-03-21
150
version = "7.x-2.5"
151 151
core = "7.x"
152 152
project = "mayo"
153
datestamp = "1423533204"
153
datestamp = "1426955288"
154 154

  
drupal7/sites/all/themes/mayo/templates/page.tpl.php
107 107
  $header_watermark_style = '';
108 108
  $header_watermark = theme_get_setting('header_watermark');
109 109
  if($header_watermark) {
110
    $header_watermark_style = 'background-image: url(' . url(drupal_get_path('theme', 'mayo') . '/images/pat-' . $header_watermark . '.png') . ');';
110
    $header_watermark_style = 'background-image: url(' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/pat-' . $header_watermark . '.png') . ');';
111 111
  }
112 112

  
113 113
  $logo_style = '';
drupal7/sites/all/themes/mayo/theme-settings.php
126 126
    '#size' => 12,
127 127
    '#maxlength' => 8,
128 128
    '#description' => t('Specify the base vertical (top/bottom) margin which is vertical spaces between page edge and browser screen in px.'),
129
    '#prefix' => '<img src="' . url(drupal_get_path('theme', 'mayo') . '/images/base-layout.png') . '" /><br />',
129
    '#prefix' => '<img src="' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/base-layout.png') . '" /><br />',
130 130
  );
131 131
  $form['layout']['page_margin'] = array(
132 132
    '#type' => 'textfield',
......
144 144
      1 => t('1. Apply page margin to all (header, footer and main contents).'),
145 145
      2 => t('2. Apply page margin to main contents only.'),
146 146
    ),
147
    '#description' => '<img src="' . url(drupal_get_path('theme', 'mayo') . '/images/page-layout.png') . '" /><br />' . t('When the layout 2 is selected, or header background image is selected, header borders are not drawn to make it look better.'),
147
    '#description' => '<img src="' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/page-layout.png') . '" /><br />' . t('When the layout 2 is selected, or header background image is selected, header borders are not drawn to make it look better.'),
148 148
  );
149 149

  
150 150
  /* --------------- Responsive sidebar layout settings -------------- */
......
763 763
      'rc-2' => t('Node only'),
764 764
      'rc-3' => t('Both sidebar block and node'),
765 765
    ),
766
    '#suffix' => '<img src="' . url(drupal_get_path('theme', 'mayo') . '/images/round-corners.png') . '" /><br />',
766
    '#suffix' => '<img src="' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/round-corners.png') . '" /><br />',
767 767
  );
768 768

  
769 769
  $form['style']['menubar_style'] = array(
......
774 774
      1 => t('1. Normal (based on the colors specified by the color set)'),
775 775
      2 => t('2. Gloss black image background.'),
776 776
    ),
777
    '#suffix' => '<img src="' . url(drupal_get_path('theme', 'mayo') . '/images/menubar-type.png') . '" />',
777
    '#suffix' => '<img src="' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/menubar-type.png') . '" />',
778 778
  );
779 779
  $form['style']['note'] = array(
780 780
    '#type' => 'item',
......
824 824
    '#size' => 12,
825 825
    '#maxlength' => 8,
826 826
    '#description' => t('Specify the header height in px.'),
827
    '#prefix' => '<img src="' . url(drupal_get_path('theme', 'mayo') . '/images/header-layout.png') . '" /><br />',
827
    '#prefix' => '<img src="' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/header-layout.png') . '" /><br />',
828 828
  );
829 829
  $form['adv_header']['header_border_width'] = array(
830 830
    '#type' => 'textfield',
......
937 937
      5 => t('Star'),
938 938
      6 => t('Metal'),
939 939
    ),
940
    '#suffix' => '<img src="' . url(drupal_get_path('theme', 'mayo') . '/images/watermark-sample.png') . '" /><br />',
940
    '#suffix' => '<img src="' . file_create_url(drupal_get_path('theme', 'mayo') . '/images/watermark-sample.png') . '" /><br />',
941 941
  );
942 942

  
943 943
  /* --------------- Misellanenous settings -------------- */

Formats disponibles : Unified diff