Révision 18596a08
Ajouté par Assos Assos il y a presque 7 ans
drupal7/sites/all/modules/file_entity/file_entity.field.inc | ||
---|---|---|
315 | 315 |
$file->referencing_entity_type = $entity_type; |
316 | 316 |
$file->referencing_field = $field['field_name']; |
317 | 317 |
|
318 |
$element[$delta] = file_view($file, $settings['file_view_mode'], $langcode); |
|
318 |
// Untranslatable fields are rendered with no language code, fall back |
|
319 |
// to the content language in that case. |
|
320 |
$element[$delta] = file_view($file, $settings['file_view_mode'], $langcode !== LANGUAGE_NONE ? $langcode : NULL); |
|
319 | 321 |
} else { |
320 | 322 |
watchdog( |
321 | 323 |
'file_entity', |
drupal7/sites/all/modules/file_entity/file_entity.info | ||
---|---|---|
32 | 32 |
; We have to add a fake version so Git checkouts do not fail Media dependencies |
33 | 33 |
version = 7.x-2.x-dev |
34 | 34 |
|
35 |
; Information added by Drupal.org packaging script on 2017-05-22
|
|
36 |
version = "7.x-2.0"
|
|
35 |
; Information added by Drupal.org packaging script on 2017-06-03
|
|
36 |
version = "7.x-2.1"
|
|
37 | 37 |
core = "7.x" |
38 | 38 |
project = "file_entity" |
39 |
datestamp = "1495456387"
|
|
39 |
datestamp = "1496523862"
|
|
40 | 40 |
|
drupal7/sites/all/modules/file_entity/file_entity.tpl.php | ||
---|---|---|
84 | 84 |
|
85 | 85 |
<div class="content"<?php print $content_attributes; ?>> |
86 | 86 |
<?php |
87 |
// We hide the links now so that we can render them later. |
|
88 |
hide($content['links']); |
|
87 |
// We hide the links now so that we can render them later. |
|
88 |
hide($content['links']); |
|
89 |
// Check to see if the file has an external url for linking. |
|
90 |
if(!empty($content['file']['#file']->external_url)) {;?> |
|
91 |
<a href="<?php print render($content['file']['#file']->external_url);?>"><?php print render($content);?></a> |
|
92 |
<?php |
|
93 |
} else { |
|
89 | 94 |
print render($content); |
95 |
} |
|
90 | 96 |
?> |
91 | 97 |
</div> |
92 | 98 |
|
drupal7/sites/all/modules/file_entity/tests/file_entity_test.info | ||
---|---|---|
5 | 5 |
dependencies[] = file_entity |
6 | 6 |
hidden = TRUE |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2017-05-22
|
|
9 |
version = "7.x-2.0"
|
|
8 |
; Information added by Drupal.org packaging script on 2017-06-03
|
|
9 |
version = "7.x-2.1"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "file_entity" |
12 |
datestamp = "1495456387"
|
|
12 |
datestamp = "1496523862"
|
|
13 | 13 |
|
drupal7/sites/all/modules/media/includes/media.fields.inc | ||
---|---|---|
116 | 116 |
'max_filesize' => isset($field_settings['max_filesize']) ? $field_settings['max_filesize'] : 0, |
117 | 117 |
'uri_scheme' => !empty($field['settings']['uri_scheme']) ? $field['settings']['uri_scheme'] : file_default_scheme(), |
118 | 118 |
'multiselect' => $multiselect, |
119 |
'field' => $field['field_name'], |
|
119 | 120 |
), |
120 | 121 |
), |
121 | 122 |
// Allows this field to return an array instead of a single value. |
... | ... | |
137 | 138 |
} elseif ($element['#entity_type'] == 'field_collection_item' && !empty($form['#entity']) && property_exists($form['#entity'], 'language')) { |
138 | 139 |
$element['#media_parent_entity_form_langcode'] = $form['#entity']->language; |
139 | 140 |
} |
141 |
else if ($element['#entity_type'] == 'paragraphs_item' && !empty($form['#entity'])) { |
|
142 |
$host = $element['#entity']->hostEntity(); |
|
143 |
$element['#media_parent_entity_form_langcode'] = $host->language; |
|
144 |
$element['#media_parent_entity_source_langcode'] = $host->language; |
|
145 |
} |
|
140 | 146 |
|
141 | 147 |
// Add image field specific validators. |
142 | 148 |
if ($field['type'] == 'image') { |
... | ... | |
551 | 557 |
); |
552 | 558 |
} |
553 | 559 |
|
560 |
$table = array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => $table_id)); |
|
561 |
|
|
562 |
drupal_alter('media_widget_multiple', $table, $element); |
|
563 |
|
|
554 | 564 |
drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class); |
555 | 565 |
|
556 | 566 |
$output = ''; |
557 |
$output = empty($rows) ? '' : theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => $table_id)));
|
|
567 |
$output = empty($rows) ? '' : theme('table', $table);
|
|
558 | 568 |
$output .= drupal_render_children($element); |
559 | 569 |
return $output; |
560 | 570 |
} |
drupal7/sites/all/modules/media/media.info | ||
---|---|---|
24 | 24 |
; We have to add a fake version so Git checkouts do not fail Media dependencies |
25 | 25 |
version = 7.x-2.x-dev |
26 | 26 |
|
27 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
28 |
version = "7.x-2.4"
|
|
27 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
28 |
version = "7.x-2.6"
|
|
29 | 29 |
core = "7.x" |
30 | 30 |
project = "media" |
31 |
datestamp = "1495749189"
|
|
31 |
datestamp = "1496847247"
|
|
32 | 32 |
|
drupal7/sites/all/modules/media/media.media.inc | ||
---|---|---|
108 | 108 |
$query->condition($or); |
109 | 109 |
} |
110 | 110 |
} |
111 |
|
|
112 |
/** |
|
113 |
* Implements hook_form_FORM_ID_alter(). |
|
114 |
*/ |
|
115 |
function media_form_views_exposed_form_alter(&$form, &$form_state, $form_id) { |
|
116 |
$view = $form_state['view']; |
|
117 |
$display = $form_state['display']; |
|
118 |
|
|
119 |
if ($view->name == 'media_default' && $display->id == 'media_browser_1') { |
|
120 |
$params = media_get_browser_params(); |
|
121 |
|
|
122 |
// Remove any unsupported types from the 'Type' filter. |
|
123 |
if (!empty($form['type']) && !empty($params['types'])) { |
|
124 |
foreach (array_keys($form['type']['#options']) as $type) { |
|
125 |
if ($type != 'All' && !in_array($type, $params['types'])) { |
|
126 |
unset($form['type']['#options'][$type]); |
|
127 |
} |
|
128 |
} |
|
129 |
} |
|
130 |
} |
|
131 |
} |
drupal7/sites/all/modules/media/media.module | ||
---|---|---|
1137 | 1137 |
*/ |
1138 | 1138 |
function media_file_validate_types($file, $types) { |
1139 | 1139 |
$errors = array(); |
1140 |
if (!in_array(file_get_type($file), $types)) { |
|
1140 |
|
|
1141 |
$file_candidates = array_keys(file_entity_get_filetype_candidates($file)); |
|
1142 |
if (!array_intersect($file_candidates, $types)) { |
|
1141 | 1143 |
$errors[] = t('Only the following types of files are allowed to be uploaded: %types-allowed', array('%types-allowed' => implode(', ', $types))); |
1142 | 1144 |
} |
1143 | 1145 |
|
... | ... | |
1219 | 1221 |
'fid', |
1220 | 1222 |
'id', |
1221 | 1223 |
'multiselect', |
1224 |
'field', |
|
1222 | 1225 |
'options', |
1223 | 1226 |
'plugins', |
1224 | 1227 |
'render', |
... | ... | |
1227 | 1230 |
); |
1228 | 1231 |
$params = array_intersect_key($params, array_flip($safe_options)); |
1229 | 1232 |
|
1230 |
// Retrieve the security sensitive options from the cache.
|
|
1233 |
// If the cache is present, use its values instead of the GET parameters.
|
|
1231 | 1234 |
if (!empty($params['options']) && is_string($params['options']) && $options = cache_get('media_options:' . $params['options'], 'cache_form')) { |
1232 |
$params = array_merge($options->data, $params);
|
|
1235 |
$params = $options->data;
|
|
1233 | 1236 |
} |
1234 | 1237 |
|
1235 | 1238 |
// Transform text 'true' and 'false' to actual booleans. |
drupal7/sites/all/modules/media/modules/media_bulk_upload/media_bulk_upload.info | ||
---|---|---|
15 | 15 |
files[] = includes/MediaBrowserBulkUpload.inc |
16 | 16 |
files[] = tests/media_bulk_upload.test |
17 | 17 |
|
18 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
19 |
version = "7.x-2.4"
|
|
18 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
19 |
version = "7.x-2.6"
|
|
20 | 20 |
core = "7.x" |
21 | 21 |
project = "media" |
22 |
datestamp = "1495749189"
|
|
22 |
datestamp = "1496847247"
|
|
23 | 23 |
|
drupal7/sites/all/modules/media/modules/media_internet/media_internet.info | ||
---|---|---|
12 | 12 |
files[] = includes/MediaInternetValidationException.inc |
13 | 13 |
files[] = tests/media_internet.test |
14 | 14 |
|
15 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
16 |
version = "7.x-2.4"
|
|
15 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
16 |
version = "7.x-2.6"
|
|
17 | 17 |
core = "7.x" |
18 | 18 |
project = "media" |
19 |
datestamp = "1495749189"
|
|
19 |
datestamp = "1496847247"
|
|
20 | 20 |
|
drupal7/sites/all/modules/media/modules/media_internet/tests/media_internet_test.info | ||
---|---|---|
7 | 7 |
files[] = includes/MediaInternetTestStreamWrapper.inc |
8 | 8 |
files[] = includes/MediaInternetTestHandler.inc |
9 | 9 |
|
10 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
11 |
version = "7.x-2.4"
|
|
10 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
11 |
version = "7.x-2.6"
|
|
12 | 12 |
core = "7.x" |
13 | 13 |
project = "media" |
14 |
datestamp = "1495749189"
|
|
14 |
datestamp = "1496847247"
|
|
15 | 15 |
|
drupal7/sites/all/modules/media/modules/media_migrate_file_types/media_migrate_file_types.info | ||
---|---|---|
8 | 8 |
|
9 | 9 |
configure = admin/structure/file-types/upgrade |
10 | 10 |
|
11 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
12 |
version = "7.x-2.4"
|
|
11 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
12 |
version = "7.x-2.6"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "media" |
15 |
datestamp = "1495749189"
|
|
15 |
datestamp = "1496847247"
|
|
16 | 16 |
|
drupal7/sites/all/modules/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc | ||
---|---|---|
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
$tag_info = drupal_json_decode($tag); |
149 |
|
|
150 | 149 |
if (!isset($tag_info['fid'])) { |
151 | 150 |
throw new Exception('No file Id'); |
152 | 151 |
} |
... | ... | |
216 | 215 |
$attribute_whitelist = media_wysiwyg_allowed_attributes(); |
217 | 216 |
$settings['attributes'] = array_intersect_key($attributes, array_flip($attribute_whitelist)); |
218 | 217 |
$settings['fields'] = $fields; |
219 |
|
|
218 |
if (isset($tag_info['fields']['external_url'])) { |
|
219 |
$settings['fields']['external_url'] = $tag_info['fields']['external_url']; |
|
220 |
} |
|
220 | 221 |
if (!empty($tag_info['attributes']) && is_array($tag_info['attributes'])) { |
221 | 222 |
$settings['attributes'] = array_intersect_key($tag_info['attributes'], array_flip($attribute_whitelist)); |
222 | 223 |
|
drupal7/sites/all/modules/media/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc | ||
---|---|---|
104 | 104 |
'#default_value' => $align_default, |
105 | 105 |
); |
106 | 106 |
} |
107 |
|
|
108 | 107 |
// Add fields from the file, so that we can override them if necessary. |
109 | 108 |
$form['options']['fields'] = array(); |
110 | 109 |
foreach ($fields as $field_name => $field_value) { |
111 | 110 |
$file->{$field_name} = $field_value; |
112 | 111 |
} |
112 |
// Get the external url from the fid array. |
|
113 |
$external_url = empty($query_fields['external_url']) ? NULL : $query_fields['external_url']; |
|
114 |
// Field to attach external url's to files for linking. |
|
115 |
$form['options']['external_url'] = array( |
|
116 |
'#type' => 'textfield', |
|
117 |
'#title' => t('Link Image'), |
|
118 |
'#description' => t('Enter a URL to turn the image into a link.'), |
|
119 |
'#default_value' => $external_url, |
|
120 |
); |
|
113 | 121 |
field_attach_form('file', $file, $form['options']['fields'], $form_state); |
114 | 122 |
$instance = field_info_instances('file', $file->type); |
115 | 123 |
foreach ($instance as $field_name => $field_value) { |
drupal7/sites/all/modules/media/modules/media_wysiwyg/js/media_wysiwyg.filter.js | ||
---|---|---|
300 | 300 |
// Attempt to override the link_title if the user has chosen to do this. |
301 | 301 |
info.link_text = this.overrideLinkTitle(info); |
302 | 302 |
// Apply link_text if present. |
303 |
if (info.link_text) {
|
|
303 |
if ((info.link_text) && (info.fields.external_url.length === 0)) {
|
|
304 | 304 |
$('a', element).html(info.link_text); |
305 | 305 |
} |
306 | 306 |
|
... | ... | |
352 | 352 |
}); |
353 | 353 |
|
354 | 354 |
// Extract the link text, if there is any. |
355 |
file_info.link_text = (Drupal.settings.mediaDoLinkText) ? element.find('a').html() : false; |
|
356 |
|
|
355 |
file_info.link_text = (Drupal.settings.mediaDoLinkText) ? element.find('a:not(:has(img))').html() : false; |
|
357 | 356 |
// When a file is embedded, its fields can be overridden. To allow for |
358 | 357 |
// the edge case where the same file is embedded multiple times with |
359 | 358 |
// different field overrides, we look for a data-delta attribute on |
drupal7/sites/all/modules/media/modules/media_wysiwyg/media_wysiwyg.info | ||
---|---|---|
16 | 16 |
|
17 | 17 |
configure = admin/config/media/browser |
18 | 18 |
|
19 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
20 |
version = "7.x-2.4"
|
|
19 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
20 |
version = "7.x-2.6"
|
|
21 | 21 |
core = "7.x" |
22 | 22 |
project = "media" |
23 |
datestamp = "1495749189"
|
|
23 |
datestamp = "1496847247"
|
|
24 | 24 |
|
drupal7/sites/all/modules/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info | ||
---|---|---|
3 | 3 |
package = Media |
4 | 4 |
core = 7.x |
5 | 5 |
|
6 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
7 |
version = "7.x-2.4"
|
|
6 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
7 |
version = "7.x-2.6"
|
|
8 | 8 |
core = "7.x" |
9 | 9 |
project = "media" |
10 |
datestamp = "1495749189"
|
|
10 |
datestamp = "1496847247"
|
|
11 | 11 |
|
drupal7/sites/all/modules/media/modules/mediafield/mediafield.info | ||
---|---|---|
4 | 4 |
core = 7.x |
5 | 5 |
dependencies[] = media |
6 | 6 |
|
7 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
8 |
version = "7.x-2.4"
|
|
7 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
8 |
version = "7.x-2.6"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "media" |
11 |
datestamp = "1495749189"
|
|
11 |
datestamp = "1496847247"
|
|
12 | 12 |
|
drupal7/sites/all/modules/media/tests/media.test | ||
---|---|---|
1001 | 1001 |
'max_filesize' => '', |
1002 | 1002 |
'uri_scheme' => 'public', |
1003 | 1003 |
'multiselect' => $multiselect, |
1004 |
'field' => $field_name, |
|
1004 | 1005 |
), |
1005 | 1006 |
), |
1006 | 1007 |
), |
drupal7/sites/all/modules/media/tests/media_module_test.info | ||
---|---|---|
6 | 6 |
|
7 | 7 |
files[] = includes/MediaModuleTest.inc |
8 | 8 |
|
9 |
; Information added by Drupal.org packaging script on 2017-05-25
|
|
10 |
version = "7.x-2.4"
|
|
9 |
; Information added by Drupal.org packaging script on 2017-06-07
|
|
10 |
version = "7.x-2.6"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "media" |
13 |
datestamp = "1495749189"
|
|
13 |
datestamp = "1496847247"
|
|
14 | 14 |
|
drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc | ||
---|---|---|
11 | 11 |
* @see hook_media_internet_providers(). |
12 | 12 |
*/ |
13 | 13 |
class MediaInternetYouTubeHandler extends MediaInternetBaseHandler { |
14 |
|
|
14 | 15 |
public function parse($embedCode) { |
16 |
$list_patterns = array( |
|
17 |
'@youtube\.com/playlist[#\?].*?list=([^"\& ]+)@i', |
|
18 |
'@youtube\.com/view_play_list[#\?].*?p=([^"\& ]+)@i', |
|
19 |
); |
|
20 |
|
|
21 |
foreach ($list_patterns as $pattern) { |
|
22 |
preg_match($pattern, $embedCode, $matches); |
|
23 |
|
|
24 |
if (isset($matches[1]) && $this->validId($matches[1], 'l')) { |
|
25 |
return file_stream_wrapper_uri_normalize('youtube://l/' . $matches[1]); |
|
26 |
} |
|
27 |
} |
|
15 | 28 |
// http://youtube.com/watch/* |
16 | 29 |
// http://youtube.com/embed/* |
17 | 30 |
// http://youtube.com/v/* |
... | ... | |
19 | 32 |
// http://youtu.be/* |
20 | 33 |
// http://gdata.youtube.com/feeds/api/videos/* |
21 | 34 |
$patterns = array( |
35 |
'@youtube\.com/watch[#\?].*?v=([^"\& ]+).*&list=([^"\& ]+)@i', |
|
36 |
'@youtu\.be/([^"\&\? ]+)\?list=([^"\& ]+)@i', |
|
37 |
'@youtube\.com/embed/([^"\&\? ]+)\?list=([^"\& ]+)@i', |
|
22 | 38 |
'@youtube\.com/watch[#\?].*?v=([^"\& ]+)@i', |
23 | 39 |
'@youtube\.com/embed/([^"\&\? ]+)@i', |
24 | 40 |
'@youtube\.com/v/([^"\&\? ]+)@i', |
... | ... | |
28 | 44 |
); |
29 | 45 |
|
30 | 46 |
foreach ($patterns as $pattern) { |
31 |
preg_match($pattern, $embedCode, $matches); |
|
47 |
preg_match_all($pattern, $embedCode, $matches);
|
|
32 | 48 |
// @TODO: Parse is called often. Refactor so that valid ID is checked |
33 | 49 |
// when a video is added, but not every time the embedCode is parsed. |
34 |
if (isset($matches[1]) && self::validId($matches[1])) { |
|
35 |
return file_stream_wrapper_uri_normalize('youtube://v/' . $matches[1]); |
|
50 |
if (isset($matches[1][0]) && $this->validId($matches[1][0])) { |
|
51 |
$uri = 'youtube://v/' . $matches[1][0]; |
|
52 |
if (isset($matches[2][0]) && $this->validId($matches[2][0], 'l')) { |
|
53 |
$uri .= '/l/' . $matches[2][0]; |
|
54 |
} |
|
55 |
return file_stream_wrapper_uri_normalize($uri); |
|
36 | 56 |
} |
37 | 57 |
} |
38 | 58 |
} |
... | ... | |
87 | 107 |
* TRUE if the video ID is valid, or throws a |
88 | 108 |
* MediaInternetValidationException otherwise. |
89 | 109 |
*/ |
90 |
static public function validId($id) {
|
|
91 |
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($id));
|
|
110 |
public function validId($id, $type = 'v') {
|
|
111 |
$uri = file_stream_wrapper_uri_normalize('youtube://' . $type . '/' . check_plain($id));
|
|
92 | 112 |
$external_url = file_create_url($uri); |
93 | 113 |
$oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); |
94 | 114 |
$response = drupal_http_request($oembed_url, array('method' => 'HEAD')); |
drupal7/sites/all/modules/media_youtube/includes/MediaYouTubeStreamWrapper.inc | ||
---|---|---|
18 | 18 |
|
19 | 19 |
function getOriginalThumbnailPath() { |
20 | 20 |
$parts = $this->get_parameters(); |
21 |
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); |
|
22 |
$external_url = file_create_url($uri); |
|
23 |
$oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); |
|
24 |
$response = drupal_http_request($oembed_url); |
|
25 |
|
|
21 |
$thumbnail_url = 'http://img.youtube.com/vi/' . check_plain($parts['v']) . "/maxresdefault.jpg"; |
|
22 |
$response = drupal_http_request($thumbnail_url); |
|
26 | 23 |
if (!isset($response->error)) { |
27 |
$data = drupal_json_decode($response->data); |
|
28 |
return $data['thumbnail_url']; |
|
24 |
return $thumbnail_url; |
|
25 |
} |
|
26 |
elseif ($response->code == 401) { |
|
27 |
throw new MediaInternetValidationException("Embedding has been disabled for this video."); |
|
28 |
} |
|
29 |
elseif ($response->code == 404) { |
|
30 |
return "http://s.ytimg.com/yts/img/image-hh-404-vflvCykRp.png"; |
|
31 |
} |
|
32 |
elseif ($response->code != 200) { |
|
33 |
throw new MediaInternetValidationException("The YouTube video ID is invalid or the video was deleted."); |
|
29 | 34 |
} |
30 | 35 |
else { |
31 |
throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})"); |
|
32 |
return; |
|
36 |
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); |
|
37 |
$external_url = file_create_url($uri); |
|
38 |
$oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); |
|
39 |
$response = drupal_http_request($oembed_url); |
|
40 |
|
|
41 |
if (!isset($response->error)) { |
|
42 |
$data = drupal_json_decode($response->data); |
|
43 |
return $data['thumbnail_url']; |
|
44 |
} |
|
45 |
else { |
|
46 |
throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})"); |
|
47 |
return; |
|
48 |
} |
|
33 | 49 |
} |
34 | 50 |
} |
35 | 51 |
|
36 | 52 |
function getLocalThumbnailPath() { |
37 | 53 |
$parts = $this->get_parameters(); |
38 |
// There's no need to hide thumbnails, always use the public system rather |
|
39 |
// than file_default_scheme(). |
|
40 |
$local_path = 'public://media-youtube/' . check_plain($parts['v']) . '.jpg'; |
|
41 |
|
|
54 |
$id = array_pop($parts); |
|
55 |
$local_path = file_default_scheme() . '://media-youtube/' . check_plain($id) . '.jpg'; |
|
42 | 56 |
if (!file_exists($local_path)) { |
43 |
$dirname = drupal_dirname($local_path); |
|
44 |
file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); |
|
45 |
$response = drupal_http_request($this->getOriginalThumbnailPath()); |
|
57 |
// getOriginalThumbnailPath throws an exception if there are any errors |
|
58 |
// when retrieving the original thumbnail from YouTube. |
|
59 |
try { |
|
60 |
$dirname = drupal_dirname($local_path); |
|
61 |
file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); |
|
62 |
$response = drupal_http_request($this->getOriginalThumbnailPath()); |
|
46 | 63 |
|
47 |
if (!isset($response->error)) { |
|
48 |
file_unmanaged_save_data($response->data, $local_path, TRUE); |
|
64 |
if (!isset($response->error)) { |
|
65 |
file_unmanaged_save_data($response->data, $local_path, TRUE); |
|
66 |
} |
|
67 |
else { |
|
68 |
@copy($this->getOriginalThumbnailPath(), $local_path); |
|
69 |
} |
|
49 | 70 |
} |
50 |
else { |
|
51 |
@copy($this->getOriginalThumbnailPath(), $local_path); |
|
71 |
catch (Exception $e) { |
|
72 |
// In the event of an endpoint error, use the mime type icon provided |
|
73 |
// by the Media module. |
|
74 |
$file = file_uri_to_object($this->uri); |
|
75 |
$icon_dir = variable_get('media_icon_base_directory', 'public://media-icons') . '/' . variable_get('media_icon_set', 'default'); |
|
76 |
$local_path = file_icon_path($file, $icon_dir); |
|
52 | 77 |
} |
53 | 78 |
} |
54 | 79 |
|
55 | 80 |
return $local_path; |
56 | 81 |
} |
82 |
|
|
83 |
/** |
|
84 |
* Updates $base_url depending on whether the embed is a video or playlist. |
|
85 |
*/ |
|
86 |
function setBaseUrl($parameters) { |
|
87 |
if (isset($parameters['l'])) { |
|
88 |
if (!isset($parameters['v'])) { |
|
89 |
$this->base_url = 'http://youtube.com/playlist'; |
|
90 |
} |
|
91 |
$parameters['list'] = $parameters['l']; |
|
92 |
unset($parameters['l']); |
|
93 |
} |
|
94 |
return $parameters; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Returns a url in the format "http://www.youtube.com/watch?v=qsPQN4MiTeE". |
|
99 |
* |
|
100 |
* Overrides interpolateUrl() defined in MediaReadOnlyStreamWrapper. |
|
101 |
*/ |
|
102 |
function interpolateUrl() { |
|
103 |
if ($parameters = $this->get_parameters()) { |
|
104 |
$parameters = $this->setBaseUrl($parameters); |
|
105 |
return $this->base_url . '?' . http_build_query($parameters); |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
57 | 109 |
} |
drupal7/sites/all/modules/media_youtube/includes/media_youtube.formatters.inc | ||
---|---|---|
147 | 147 |
'#default_value' => $settings['loop'], |
148 | 148 |
); |
149 | 149 |
|
150 |
// Note: make sure the positive/negitive language lines up with option
|
|
150 |
// Note: make sure the positive/negative language lines up with option
|
|
151 | 151 |
// processing in media_youtube.theme.inc. |
152 | 152 |
$element['showinfo'] = array( |
153 | 153 |
'#title' => t('Display video title and uploader'), |
... | ... | |
173 | 173 |
'#title' => t('Specify an http protocol'), |
174 | 174 |
'#type' => 'checkbox', |
175 | 175 |
'#default_value' => $settings['protocol_specify'], |
176 |
'#description' => t('An explicit protocol may be neccesary for videos embedded in RSS feeds and emails. If no protocol is specified, iframes will be protocol relative.'),
|
|
176 |
'#description' => t('An explicit protocol may be necessary for videos embedded in RSS feeds and emails. If no protocol is specified, iframes will be protocol relative.'),
|
|
177 | 177 |
); |
178 | 178 |
$element['protocol'] = array( |
179 | 179 |
'#title' => t('Iframe protocol'), |
... | ... | |
246 | 246 |
if (empty($image_style) || !isset($valid_image_styles[$image_style])) { |
247 | 247 |
$element = array( |
248 | 248 |
'#theme' => 'image', |
249 |
'#path' => str_replace('http:', '', $wrapper->getOriginalThumbnailPath()),
|
|
249 |
'#path' => str_replace('http:', '', $wrapper->getLocalThumbnailPath()),
|
|
250 | 250 |
'#alt' => isset($file->override['attributes']['alt']) ? $file->override['attributes']['alt'] : $file->filename, |
251 | 251 |
); |
252 | 252 |
} |
drupal7/sites/all/modules/media_youtube/media_youtube.file_default_displays.inc | ||
---|---|---|
27 | 27 |
'loop' => 0, |
28 | 28 |
'showinfo' => 1, |
29 | 29 |
'modestbranding' => 0, |
30 |
'rel' => 1,
|
|
30 |
'rel' => 0,
|
|
31 | 31 |
'nocookie' => 0, |
32 | 32 |
'protocol_specify' => 0, |
33 | 33 |
'protocol' => 'https:', |
... | ... | |
61 | 61 |
'loop' => 0, |
62 | 62 |
'showinfo' => 1, |
63 | 63 |
'modestbranding' => 0, |
64 |
'rel' => 1,
|
|
64 |
'rel' => 0,
|
|
65 | 65 |
'nocookie' => 0, |
66 | 66 |
'protocol_specify' => 0, |
67 | 67 |
'protocol' => 'https:', |
... | ... | |
86 | 86 |
'loop' => 0, |
87 | 87 |
'showinfo' => 1, |
88 | 88 |
'modestbranding' => 0, |
89 |
'rel' => 1,
|
|
89 |
'rel' => 0,
|
|
90 | 90 |
'nocookie' => 0, |
91 | 91 |
'protocol_specify' => 0, |
92 | 92 |
'protocol' => 'https:', |
... | ... | |
110 | 110 |
'loop' => 0, |
111 | 111 |
'showinfo' => 1, |
112 | 112 |
'modestbranding' => 0, |
113 |
'rel' => 1,
|
|
113 |
'rel' => 0,
|
|
114 | 114 |
'nocookie' => 0, |
115 | 115 |
'protocol_specify' => 0, |
116 | 116 |
'protocol' => 'https:', |
... | ... | |
134 | 134 |
'loop' => 0, |
135 | 135 |
'showinfo' => 1, |
136 | 136 |
'modestbranding' => 0, |
137 |
'rel' => 1,
|
|
137 |
'rel' => 0,
|
|
138 | 138 |
'nocookie' => 0, |
139 | 139 |
'protocol_specify' => 0, |
140 | 140 |
'protocol' => 'https:', |
drupal7/sites/all/modules/media_youtube/media_youtube.info | ||
---|---|---|
5 | 5 |
|
6 | 6 |
dependencies[] = media_internet |
7 | 7 |
|
8 |
test_dependencies[] = media_internet (2.x) |
|
9 |
|
|
10 |
files[] = media_youtube.test |
|
8 | 11 |
files[] = includes/MediaYouTubeStreamWrapper.inc |
9 | 12 |
files[] = includes/MediaInternetYouTubeHandler.inc |
10 | 13 |
|
11 |
; Information added by Drupal.org packaging script on 2015-05-28
|
|
12 |
version = "7.x-3.0"
|
|
14 |
; Information added by Drupal.org packaging script on 2017-06-09
|
|
15 |
version = "7.x-3.4"
|
|
13 | 16 |
core = "7.x" |
14 | 17 |
project = "media_youtube" |
15 |
datestamp = "1432800182"
|
|
18 |
datestamp = "1497020345"
|
|
16 | 19 |
|
drupal7/sites/all/modules/media_youtube/media_youtube.test | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Tests for media_youtube.module. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Provides methods specifically for testing Media YouTube's YouTube video handling. |
|
10 |
*/ |
|
11 |
class MediaYouTubeTestHelper extends MediaInternetTestHelper { |
|
12 |
function setUp() { |
|
13 |
// Since this is a base class for many test cases, support the same |
|
14 |
// flexibility that DrupalWebTestCase::setUp() has for the modules to be |
|
15 |
// passed in as either an array or a variable number of string arguments. |
|
16 |
$modules = func_get_args(); |
|
17 |
if (isset($modules[0]) && is_array($modules[0])) { |
|
18 |
$modules = $modules[0]; |
|
19 |
} |
|
20 |
$modules[] = 'media_youtube'; |
|
21 |
parent::setUp($modules); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
/** |
|
26 |
* Test the MediaInternetYouTubeHandler provider. |
|
27 |
*/ |
|
28 |
class MediaInternetYouTubeTestCase extends MediaYouTubeTestHelper { |
|
29 |
public static function getInfo() { |
|
30 |
return array( |
|
31 |
'name' => 'YouTube file handler provider', |
|
32 |
'description' => 'Test the YouTube handler provider.', |
|
33 |
'group' => 'Media YouTube', |
|
34 |
); |
|
35 |
} |
|
36 |
|
|
37 |
function setUp() { |
|
38 |
parent::setUp('media_youtube_test'); |
|
39 |
|
|
40 |
// Disable the private file system which is automatically enabled by |
|
41 |
// DrupalTestCase so we can test the upload wizard correctly. |
|
42 |
variable_del('file_private_path'); |
|
43 |
|
|
44 |
$web_user = $this->drupalCreateUser(array('create files', 'add media from remote sources', 'edit own video files')); |
|
45 |
$this->drupalLogin($web_user); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Tests YouTube file handler. |
|
50 |
*/ |
|
51 |
function testYouTubeFileHandling() { |
|
52 |
// Step 1: Add a video file by providing a URL to the resource on YouTube. |
|
53 |
$edit = array(); |
|
54 |
$edit['embed_code'] = 'https://www.youtube.com/watch?v=9g2U12SsRns'; |
|
55 |
$this->drupalPost('file/add/web', $edit, t('Next')); |
|
56 |
|
|
57 |
// Check that the file exists in the database. |
|
58 |
$fid = $this->getLastFileId(); |
|
59 |
$file = file_load($fid); |
|
60 |
$this->assertTrue($file, t('File found in database.')); |
|
61 |
|
|
62 |
// Check that the video file has been uploaded. |
|
63 |
$this->assertRaw(t('!type %name was uploaded.', array('!type' => 'Video', '%name' => $file->filename)), t('Video file uploaded.')); |
|
64 |
|
|
65 |
// Verify that the video formatter is used to render the full video. |
|
66 |
$video_info = array( |
|
67 |
'uri' => $file->uri, |
|
68 |
'options' => array( |
|
69 |
'width' => 640, |
|
70 |
'height' => 390, |
|
71 |
'autohide' => 2, |
|
72 |
'autoplay' => FALSE, |
|
73 |
'color' => 'red', |
|
74 |
'enablejsapi' => FALSE, |
|
75 |
'loop' => FALSE, |
|
76 |
'modestbranding' => FALSE, |
|
77 |
'nocookie' => FALSE, |
|
78 |
'origin' => '', |
|
79 |
'protocol' => 'https:', |
|
80 |
'protocol_specify' => FALSE, |
|
81 |
'rel' => TRUE, |
|
82 |
'showinfo' => TRUE, |
|
83 |
'theme' => 'dark', |
|
84 |
'captions' => FALSE, |
|
85 |
), |
|
86 |
); |
|
87 |
$default_output = theme('media_youtube_video', $video_info); |
|
88 |
$this->assertRaw($default_output, 'Video displayed using the Media: YouTube Video formatter.'); |
|
89 |
|
|
90 |
// Edit the file. |
|
91 |
$this->drupalGet('file/' . $file->fid . '/edit'); |
|
92 |
|
|
93 |
// Verify that the image formatter is used to render the video preview. |
|
94 |
$wrapper = file_stream_wrapper_get_instance_by_uri($file->uri); |
|
95 |
$image_info = array( |
|
96 |
'uri' => $file->uri, |
|
97 |
'style_name' => 'media_thumbnail', |
|
98 |
'path' => $wrapper->getLocalThumbnailPath(), |
|
99 |
'alt' => isset($file->override['attributes']['alt']) ? $file->override['attributes']['alt'] : $file->filename, |
|
100 |
); |
|
101 |
$default_output = theme('image_style', $image_info); |
|
102 |
$this->assertRaw($default_output, 'Video displayed using the Media: YouTube Image formatter.'); |
|
103 |
} |
|
104 |
} |
drupal7/sites/all/modules/media_youtube/tests/includes/MediaYouTubeTestHandler.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Extends the MediaInternetYouTubeHandler class to make it suitable for local testing. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* A test handler for YouTube videos. |
|
10 |
* |
|
11 |
* @see MediaInternetYouTubeHandler(). |
|
12 |
*/ |
|
13 |
class MediaYouTubeTestHandler extends MediaInternetYouTubeHandler { |
|
14 |
public function getOEmbed() { |
|
15 |
$uri = $this->parse($this->embedCode); |
|
16 |
$external_url = file_create_url($uri); |
|
17 |
$oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE)); |
|
18 |
$response = drupal_http_request($oembed_url); |
|
19 |
|
|
20 |
if (!isset($response->error)) { |
|
21 |
return drupal_json_decode($response->data); |
|
22 |
} |
|
23 |
else { |
|
24 |
throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})"); |
|
25 |
return; |
|
26 |
} |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Check if a YouTube video ID is valid. |
|
31 |
* |
|
32 |
* @return boolean |
|
33 |
* TRUE if the video ID is valid, or throws a |
|
34 |
* MediaInternetValidationException otherwise. |
|
35 |
*/ |
|
36 |
public function validId($id, $type = 'v') { |
|
37 |
$uri = file_stream_wrapper_uri_normalize('youtube://' . $type . '/' . check_plain($id)); |
|
38 |
$external_url = file_create_url($uri); |
|
39 |
$oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE)); |
|
40 |
$response = drupal_http_request($oembed_url, array('method' => 'HEAD')); |
|
41 |
|
|
42 |
if ($response->code == 401) { |
|
43 |
throw new MediaInternetValidationException('Embedding has been disabled for this YouTube video.'); |
|
44 |
} |
|
45 |
elseif ($response->code != 200) { |
|
46 |
throw new MediaInternetValidationException('The YouTube video ID is invalid or the video was deleted.'); |
|
47 |
} |
|
48 |
|
|
49 |
return TRUE; |
|
50 |
} |
|
51 |
} |
drupal7/sites/all/modules/media_youtube/tests/includes/MediaYouTubeTestStreamWrapper.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Extends the MediaYouTubeStreamWrapper class to make it suitable for local testing. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Create an instance like this: |
|
10 |
* $youtube = new MediaYouTubeTestStreamWrapper('youtube://v/[video-code]'); |
|
11 |
*/ |
|
12 |
class MediaYouTubeTestStreamWrapper extends MediaYouTubeStreamWrapper { |
|
13 |
function getOriginalThumbnailPath() { |
|
14 |
$parts = $this->get_parameters(); |
|
15 |
$uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); |
|
16 |
$external_url = file_create_url($uri); |
|
17 |
$oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE)); |
|
18 |
$response = drupal_http_request($oembed_url); |
|
19 |
|
|
20 |
if (!isset($response->error)) { |
|
21 |
$data = drupal_json_decode($response->data); |
|
22 |
return $data['thumbnail_url']; |
|
23 |
} |
|
24 |
else { |
|
25 |
throw new Exception(t('Error Processing Request. (Error: %code, %error)', array('%code' => $response->code, '%error' => $response->error))); |
|
26 |
} |
|
27 |
} |
|
28 |
} |
drupal7/sites/all/modules/media_youtube/tests/media_youtube_test.info | ||
---|---|---|
1 |
name = Media YouTube Test |
|
2 |
description = Provides hooks for testing Media YouTube module functionality. |
|
3 |
package = Media |
|
4 |
core = 7.x |
|
5 |
dependencies[] = media_youtube |
|
6 |
hidden = TRUE |
|
7 |
|
|
8 |
files[] = includes/MediaYouTubeTestStreamWrapper.inc |
|
9 |
files[] = includes/MediaYouTubeTestHandler.inc |
|
10 |
|
|
11 |
; Information added by Drupal.org packaging script on 2017-06-09 |
|
12 |
version = "7.x-3.4" |
|
13 |
core = "7.x" |
|
14 |
project = "media_youtube" |
|
15 |
datestamp = "1497020345" |
|
16 |
|
drupal7/sites/all/modules/media_youtube/tests/media_youtube_test.module | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Alters Media: YouTube video handling to make it suitable for local testing. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Implements hook_menu(). |
|
10 |
*/ |
|
11 |
function media_youtube_test_menu() { |
|
12 |
$items['media-youtube-test/oembed'] = array( |
|
13 |
'title' => 'Drupal Goto', |
|
14 |
'page callback' => 'media_youtube_test_oembed', |
|
15 |
'access arguments' => array('access content'), |
|
16 |
'type' => MENU_CALLBACK, |
|
17 |
); |
|
18 |
|
|
19 |
return $items; |
|
20 |
} |
|
21 |
|
|
22 |
/** |
|
23 |
* Provides a fake oEmbed endpoint for local testing. |
|
24 |
*/ |
|
25 |
function media_youtube_test_oembed() { |
|
26 |
$query_parameters = drupal_get_query_parameters(); |
|
27 |
$query = parse_url($query_parameters['url'], PHP_URL_QUERY); |
|
28 |
parse_str($query, $params); |
|
29 |
|
|
30 |
$data = array( |
|
31 |
'thumbnail_url' => 'https://i.ytimg.com/vi/' . $params['v'] . '/hqdefault.jpg', |
|
32 |
'thumbnail_width' => 480, |
|
33 |
'author_name' => 'YouTube Help', |
|
34 |
'height' => 270, |
|
35 |
'provider_url' => 'http://www.youtube.com/', |
|
36 |
'html' => '<iframe width="480" height="270" src="https://www.youtube.com/embed/' . $params['v'] . '?feature=oembed" frameborder="0" allowfullscreen></iframe>', |
|
37 |
'thumbnail_height' => 360, |
|
38 |
'title' => 'YouTube Content ID', |
|
39 |
'provider_name' => 'YouTube', |
|
40 |
'type' => 'video', |
|
41 |
'width' => 480, |
|
42 |
'version' => '1.0', |
|
43 |
'author_url' => 'http://www.youtube.com/user/YouTubeHelp', |
|
44 |
); |
|
45 |
|
|
46 |
drupal_json_output($data); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Implements hook_media_internet_providers_alter(). |
|
51 |
*/ |
|
52 |
function media_youtube_test_media_internet_providers_alter(&$providers) { |
|
53 |
$provider = $providers['MediaInternetYouTubeHandler']; |
|
54 |
unset($providers['MediaInternetYouTubeHandler']); |
|
55 |
$providers['MediaYouTubeTestHandler'] = $provider; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Implements hook_stream_wrappers_alter(). |
|
60 |
*/ |
|
61 |
function media_youtube_test_stream_wrappers_alter(&$wrappers) { |
|
62 |
$wrappers['youtube']['class'] = 'MediaYouTubeTestStreamWrapper'; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Implements hook_media_parse_alter(). |
|
67 |
*/ |
|
68 |
function media_youtube_test_media_parse_alter(&$success, $context) { |
|
69 |
if ($context['module'] == 'media_youtube') { |
|
70 |
$handler = new MediaYouTubeTestHandler($context['url']); |
|
71 |
$success = $handler->parse($context['url']); |
|
72 |
} |
|
73 |
} |
drupal7/sites/all/modules/media_youtube/themes/media_youtube.theme.inc | ||
---|---|---|
13 | 13 |
// Build the URI. |
14 | 14 |
$wrapper = file_stream_wrapper_get_instance_by_uri($variables['uri']); |
15 | 15 |
$parts = $wrapper->get_parameters(); |
16 |
$variables['video_id'] = check_plain($parts['v']); |
|
16 |
if (isset($parts['v'])) { |
|
17 |
$variables['embed_type'] = 'video'; |
|
18 |
$variables['video_id'] = check_plain($parts['v']); |
|
19 |
$embed_path = '/embed/' . $variables['video_id']; |
|
20 |
} |
|
21 |
elseif (isset($parts['l'])) { |
|
22 |
$variables['embed_type'] = 'playlist'; |
|
23 |
$variables['video_id'] = check_plain($parts['l']); |
|
24 |
$embed_path = '/embed/videoseries'; |
|
25 |
} |
|
17 | 26 |
|
18 |
// Make the file object available. |
|
19 |
$file_object = file_uri_to_object($variables['uri']); |
|
27 |
// Checked existing function. |
|
28 |
if(function_exists('file_uri_to_object')) { |
|
29 |
// Make the file object available. |
|
30 |
$file_object = file_uri_to_object($variables['uri']); |
|
31 |
} |
|
32 |
else { |
|
33 |
$file_object = media_youtube_file_uri_to_object($variables['uri']); |
|
34 |
} |
|
20 | 35 |
|
21 | 36 |
// Parse options and build the query string. Only add the option to the query |
22 | 37 |
// array if the option value is not default. Be careful, depending on the |
... | ... | |
85 | 100 |
} |
86 | 101 |
} |
87 | 102 |
|
88 |
// Non-query options. |
|
89 |
if ($variables['options']['nocookie']) { |
|
90 |
$url_base = 'youtube-nocookie.com'; |
|
103 |
if ($variables['options']['protocol_specify']) { |
|
104 |
$protocol = $variables['options']['protocol']; |
|
91 | 105 |
} |
92 | 106 |
else { |
93 |
$url_base = 'youtube.com';
|
|
107 |
$protocol = 'https:';
|
|
94 | 108 |
} |
95 | 109 |
|
96 |
if ($variables['options']['protocol_specify']) { |
|
97 |
$protocol = $variables['options']['protocol']; |
|
110 |
// Non-query options. |
|
111 |
if ($variables['options']['nocookie']) { |
|
112 |
$url_base = 'youtube-nocookie.com'; |
|
98 | 113 |
} |
99 | 114 |
else { |
100 |
$protocol = '';
|
|
115 |
$url_base = 'youtube.com';
|
|
101 | 116 |
} |
102 | 117 |
|
103 | 118 |
// Add some options as their own template variables. |
... | ... | |
123 | 138 |
// to use for the alternative content. |
124 | 139 |
$variables['alternative_content'] = t('Video of @title', array('@title' => $variables['title'])); |
125 | 140 |
|
141 |
if (isset($parts['l'])) { |
|
142 |
$query['list'] = $parts['l']; |
|
143 |
} |
|
126 | 144 |
// Build the iframe URL with options query string. |
127 |
$variables['url'] = url($protocol . '//www.' . $url_base . '/embed/' . $variables['video_id'], array('query' => $query, 'external' => TRUE)); |
|
145 |
$variables['url'] = url($protocol . '//www.' . $url_base . $embed_path, array('query' => $query, 'external' => TRUE)); |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Helping function. |
|
150 |
*/ |
|
151 |
function media_youtube_file_uri_to_object($uri) { |
|
152 |
$uri = file_stream_wrapper_uri_normalize($uri); |
|
153 |
$files = entity_load('file', FALSE, array('uri' => $uri)); |
|
154 |
$file = !empty($files) ? reset($files) : FALSE; |
|
155 |
if (!$file) { |
|
156 |
global $user; |
|
157 |
$file = new stdClass(); |
|
158 |
$file->uid = $user->uid; |
|
159 |
$file->filename = basename($uri); |
|
160 |
$file->uri = $uri; |
|
161 |
$file->filemime = file_get_mimetype($uri); |
|
162 |
// This is gagged because some uris will not support it. |
|
163 |
$file->filesize = @filesize($uri); |
|
164 |
$file->timestamp = REQUEST_TIME; |
|
165 |
$file->status = FILE_STATUS_PERMANENT; |
|
166 |
} |
|
167 |
return $file; |
|
128 | 168 |
} |
drupal7/sites/all/modules/module_filter/CHANGELOG.txt | ||
---|---|---|
1 |
Module Filter 7.x-2.x, 2015-02-20
|
|
1 |
Module Filter 7.x-2.1, 2017-06-09
|
|
2 | 2 |
--------------------------------- |
3 |
Simplifying the table rows by hiding version and requirements until a |
|
4 |
particular description is clicked. |
|
3 |
Issue #2437439 by mikhail.krainiuk, greenSkin, jayhawkfan75: Module Filter does |
|
4 |
not care about anchors in permission links. |
|
5 |
Issue #2866236 by Munavijayalakshmi, dhruveshdtripathi: Typo error in |
|
6 |
README.TXT file. |
|
7 |
Issue #2452067 by Madis: Option to show description expanded as default |
|
8 |
not working. |
|
9 |
Issue #2580791 by makbul_khan8: Coding standards and few function without |
|
10 |
help comments. |
|
11 |
Issue #2153697 by annya: Disabling option "Number of enabled modules" breaks |
|
12 |
tabs functionality. |
|
13 |
Issue #1710230 by willvincent: On | Off buttons does not change state with |
|
14 |
jquery_update module active. |
|
15 |
Added option to show description as expanded by default. |
|
16 |
Improved description field so when it is open, interacting with it's contents |
|
17 |
does not make it collapse. |
|
18 |
Placed collapsed/expanded images inside of module for easier, more reliable |
|
19 |
access. |
|
20 |
Added option to place version in own column. |
|
21 |
Issue #2113191 by joelpittet: Category tabs not working. |
|
5 | 22 |
|
6 | 23 |
|
7 |
Module Filter 7.x-2.x, 2014-09-01
|
|
24 |
Module Filter 7.x-2.0, 2015-02-22
|
|
8 | 25 |
--------------------------------- |
26 |
Simplifying the table rows by hiding version and requirements until a |
|
27 |
particular description is clicked. |
|
9 | 28 |
#2235553 by greenSkin: Fixed latest jquery_update breaks module filter. |
10 | 29 |
#2304687 by mpdonadio: Fixed Remove hardcoded operations. |
11 | 30 |
#2293029 by topsitemakers: Fixed Take header offset into account when selecting |
12 | 31 |
a tab. |
13 | 32 |
#2290213 by topsitemakers: Minor typo in description - "has no affect" -> "has |
14 | 33 |
no effect". |
15 |
|
|
16 |
|
|
17 |
Module Filter 7.x-2.0-alpha2, 2013-12-06 |
|
18 |
---------------------------------------- |
|
19 | 34 |
#2141743, #2141743 by greenSkin: Fixed issues related to the new dynamically |
20 | 35 |
positioned tabs and using the dynamically positioned save button. |
21 |
|
|
22 |
|
|
23 |
Module Filter 7.x-2.0-alpha1, 2013-11-18 |
|
24 |
---------------------------------------- |
|
25 | 36 |
by greenSkin: Tabs now should always be visible while scrolling large lists of |
26 | 37 |
modules. |
27 | 38 |
#1854348 by alexweber, greenSkin: Make filter textfield wider on modules page |
drupal7/sites/all/modules/module_filter/README.txt | ||
---|---|---|
17 | 17 |
missing. |
18 | 18 |
|
19 | 19 |
The update status report filter also contains four checkboxes: Up-to-Date, |
20 |
Update availabe, Security update, and Unknown. These directly affect the |
|
21 |
visibilty of each project; whether it is up-to-date, there is an update |
|
20 |
Update available, Security update, and Unknown. These directly affect the
|
|
21 |
visibility of each project; whether it is up-to-date, there is an update
|
|
22 | 22 |
available, a security update is available, or the status is unknown. |
23 | 23 |
|
24 | 24 |
Installation |
drupal7/sites/all/modules/module_filter/css/module_filter.css | ||
---|---|---|
18 | 18 |
text-transform: uppercase; |
19 | 19 |
color: #888; |
20 | 20 |
} |
21 |
#module-filter-modules { |
|
22 |
position: relative; |
|
23 |
} |
|
24 |
#module-filter-modules table { |
|
25 |
position: absolute; |
|
26 |
} |
drupal7/sites/all/modules/module_filter/css/module_filter_tab.css | ||
---|---|---|
167 | 167 |
.admin-version { |
168 | 168 |
white-space: nowrap; |
169 | 169 |
} |
170 |
.admin-operations { |
|
171 |
float: right; |
|
172 |
} |
|
173 | 170 |
.admin-operations a.module-link { |
174 | 171 |
display: inline; |
175 | 172 |
} |
drupal7/sites/all/modules/module_filter/css/modules.css | ||
---|---|---|
7 | 7 |
#system-modules th.name { |
8 | 8 |
width: 25%; |
9 | 9 |
} |
10 |
#system-modules th.version { |
|
11 |
width: 10%; |
|
12 |
} |
|
10 | 13 |
#system-modules th.links { |
11 | 14 |
width: 15%; |
12 | 15 |
} |
... | ... | |
14 | 17 |
vertical-align: top; |
15 | 18 |
} |
16 | 19 |
#system-modules .expand.inner { |
17 |
background: transparent url(/misc/menu-collapsed.png) left 0.6em no-repeat;
|
|
20 |
background: transparent url(../images/collapsed.png) left 0.6em no-repeat;
|
|
18 | 21 |
margin-left: -12px; |
19 | 22 |
padding-left: 12px; |
20 | 23 |
} |
21 | 24 |
#system-modules .expanded.expand.inner { |
22 |
background: transparent url(/misc/menu-expanded.png) left 0.6em no-repeat;
|
|
25 |
background: transparent url(../images/expanded.png) left 0.6em no-repeat;
|
|
23 | 26 |
} |
24 | 27 |
#system-modules .description { |
25 | 28 |
cursor: pointer; |
... | ... | |
29 | 32 |
text-overflow: ellipsis; |
30 | 33 |
white-space: nowrap; |
31 | 34 |
} |
35 |
#system-modules .description .inner.expanded > * { |
|
36 |
cursor: auto; |
|
37 |
} |
|
32 | 38 |
#system-modules .description .requirements, |
33 | 39 |
#system-modules .description .links { |
34 | 40 |
display: none; |
drupal7/sites/all/modules/module_filter/js/module_filter.js | ||
---|---|---|
265 | 265 |
if (Drupal.settings.moduleFilter.setFocus) { |
266 | 266 |
filterInput.focus(); |
267 | 267 |
} |
268 |
if (Drupal.settings.moduleFilter.expandedDescription) { |
|
269 |
$('#system-modules td.description .inner.expand').addClass('expanded'); |
|
270 |
} |
|
268 | 271 |
filterInput.data('moduleFilter', new Drupal.ModuleFilter.Filter(this, selector, options)); |
269 | 272 |
}; |
270 | 273 |
|
drupal7/sites/all/modules/module_filter/js/module_filter_tab.js | ||
---|---|---|
84 | 84 |
summary += '<span>' + Drupal.t('No modules were enabled or disabled within the last week.') + '</span>'; |
85 | 85 |
} |
86 | 86 |
break; |
87 |
default:
|
|
87 |
default: |
|
88 | 88 |
var $row = $('#' + id + '-package'); |
89 | 89 |
name = $.trim($row.text()); |
90 | 90 |
$row.remove(); |
... | ... | |
242 | 242 |
if (!$(this).hasClass('disabled')) { |
243 | 243 |
if (Drupal.ModuleFilter.jQueryIsNewer()) { |
244 | 244 |
$checkbox.click(); |
245 |
$switch.toggleClass('off'); |
|
245 | 246 |
} |
246 | 247 |
else { |
247 | 248 |
$checkbox.click().change(); |
249 |
$switch.toggleClass('off'); |
|
248 | 250 |
} |
249 | 251 |
} |
250 | 252 |
}); |
251 |
$checkbox.click(function() { |
|
252 |
if (!$switch.hasClass('disabled')) { |
|
253 |
$switch.toggleClass('off'); |
|
254 |
} |
|
255 |
}); |
|
256 | 253 |
}); |
257 | 254 |
} |
258 | 255 |
|
drupal7/sites/all/modules/module_filter/js/modules.js | ||
---|---|---|
3 | 3 |
Drupal.behaviors.moduleFilter = { |
4 | 4 |
attach: function(context) { |
5 | 5 |
$('#system-modules td.description').once('description', function() { |
6 |
$('.inner.expand', $(this)).click(function() { |
|
7 |
$(this).toggleClass('expanded'); |
|
6 |
$(this).click(function() { |
|
7 |
$('.inner.expand', $(this)).toggleClass('expanded'); |
|
8 |
}); |
|
9 |
$('.inner.expand', $(this)).children().click(function(e) { |
|
10 |
if ($(this).parent().hasClass('expanded')) { |
|
11 |
e.stopPropagation(); |
|
12 |
} |
|
8 | 13 |
}); |
9 | 14 |
}); |
10 | 15 |
|
drupal7/sites/all/modules/module_filter/module_filter.admin.inc | ||
---|---|---|
25 | 25 |
'#type' => 'checkbox', |
26 | 26 |
'#title' => t('Enhance the modules page with tabs'), |
27 | 27 |
'#description' => t('Alternate tabbed theme that restructures packages into tabs.'), |
28 |
'#default_value' => variable_get('module_filter_tabs', 1) |
|
28 |
'#default_value' => variable_get('module_filter_tabs', 1),
|
|
29 | 29 |
); |
30 | 30 |
$form['tabs'] = array( |
31 | 31 |
'#type' => 'fieldset', |
32 | 32 |
'#title' => t('Tabs'), |
33 | 33 |
'#description' => t('Settings used with the tabs view of the modules page.'), |
34 | 34 |
'#collapsible' => TRUE, |
35 |
'#collapsed' => FALSE |
|
35 |
'#collapsed' => FALSE,
|
|
36 | 36 |
); |
37 | 37 |
$form['tabs']['module_filter_count_enabled'] = array( |
38 | 38 |
'#type' => 'checkbox', |
39 | 39 |
'#title' => t('Number of enabled modules'), |
40 | 40 |
'#description' => t('Display the number of enabled modules in the active tab along with the total number of modules.'), |
41 |
'#default_value' => variable_get('module_filter_count_enabled', 1) |
|
41 |
'#default_value' => variable_get('module_filter_count_enabled', 1),
|
|
42 | 42 |
); |
43 | 43 |
$form['tabs']['module_filter_visual_aid'] = array( |
44 | 44 |
'#type' => 'checkbox', |
45 | 45 |
'#title' => t('Visual aids'), |
46 | 46 |
'#description' => t('When enabling/disabling modules, the module name will display in the tab summary.<br />When filtering, a count of results for each tab will be presented.'), |
47 |
'#default_value' => variable_get('module_filter_visual_aid', 1) |
|
47 |
'#default_value' => variable_get('module_filter_visual_aid', 1),
|
|
48 | 48 |
); |
49 | 49 |
$form['tabs']['module_filter_hide_empty_tabs'] = array( |
50 | 50 |
'#type' => 'checkbox', |
51 | 51 |
'#title' => t('Hide tabs with no results'), |
52 | 52 |
'#description' => t('When a filter returns no results for a tab, the tab is hidden. This is dependent on visual aids being enabled.'), |
53 |
'#default_value' => variable_get('module_filter_hide_empty_tabs', 0) |
|
53 |
'#default_value' => variable_get('module_filter_hide_empty_tabs', 0),
|
|
54 | 54 |
); |
55 | 55 |
$form['tabs']['module_filter_dynamic_save_position'] = array( |
56 | 56 |
'#type' => 'checkbox', |
57 | 57 |
'#title' => t('Dynamically position Save button'), |
58 | 58 |
'#description' => t("For sites with lots of tabs, enable to help keep the 'Save configuration' button more accessible."), |
59 |
'#default_value' => variable_get('module_filter_dynamic_save_position', 1) |
|
59 |
'#default_value' => variable_get('module_filter_dynamic_save_position', 1),
|
|
60 | 60 |
); |
61 | 61 |
$form['tabs']['module_filter_use_url_fragment'] = array( |
62 | 62 |
'#type' => 'checkbox', |
63 | 63 |
'#title' => t('Use URL fragment'), |
64 | 64 |
'#description' => t('Use URL fragment when navigating between tabs. This lets you use the browsers back/forward buttons to navigate through the tabs you selected.') . '<br />' . t('When the Overlay module is enabled this functionality will not be used since overlay relies on the URL fragment.'), |
65 |
'#default_value' => variable_get('module_filter_use_url_fragment', 1) |
|
65 |
'#default_value' => variable_get('module_filter_use_url_fragment', 1),
|
|
66 | 66 |
); |
67 | 67 |
$form['tabs']['module_filter_use_switch'] = array( |
68 | 68 |
'#type' => 'checkbox', |
... | ... | |
82 | 82 |
'#description' => t('When enabled, the active tab will be remembered.'), |
83 | 83 |
'#default_value' => variable_get('module_filter_remember_active_tab', 1), |
84 | 84 |
); |
85 |
$form['tabs']['module_filter_version_column'] = array( |
|
86 |
'#type' => 'checkbox', |
|
87 |
'#title' => t('Place version in own column'), |
|
88 |
'#description' => t("Moves the version out of the description and into it's own column"), |
|
89 |
'#default_value' => variable_get('module_filter_version_column', 0), |
|
90 |
); |
|
91 |
$form['tabs']['module_filter_expanded_description'] = array( |
|
92 |
'#type' => 'checkbox', |
|
93 |
'#title' => t('Expand description by default'), |
|
94 |
'#description' => t('When enabled, the description will be expanded by default.'), |
|
95 |
'#default_value' => variable_get('module_filter_expanded_description', 0), |
|
96 |
); |
|
85 | 97 |
|
86 | 98 |
$form['update'] = array( |
87 | 99 |
'#type' => 'fieldset', |
drupal7/sites/all/modules/module_filter/module_filter.info | ||
---|---|---|
4 | 4 |
package = Administration |
5 | 5 |
|
6 | 6 |
files[] = module_filter.install |
7 |
files[] = module_filter.js |
|
8 | 7 |
files[] = module_filter.module |
9 | 8 |
files[] = module_filter.admin.inc |
10 | 9 |
files[] = module_filter.theme.inc |
... | ... | |
17 | 16 |
|
18 | 17 |
configure = admin/config/user-interface/modulefilter |
19 | 18 |
|
20 |
; Information added by Drupal.org packaging script on 2015-02-22
|
|
21 |
version = "7.x-2.0"
|
|
19 |
; Information added by Drupal.org packaging script on 2017-06-09
|
|
20 |
version = "7.x-2.1"
|
|
22 | 21 |
core = "7.x" |
23 | 22 |
project = "module_filter" |
24 |
datestamp = "1424631189"
|
|
23 |
datestamp = "1497029349"
|
|
25 | 24 |
|
drupal7/sites/all/modules/module_filter/module_filter.install | ||
---|---|---|
19 | 19 |
variable_del('module_filter_track_recent_modules'); |
20 | 20 |
variable_del('module_filter_remember_active_tab'); |
21 | 21 |
variable_del('module_filter_remember_update_state'); |
22 |
variable_del('module_filter_version_column'); |
|
23 |
variable_del('module_filter_expanded_description'); |
|
22 | 24 |
} |
23 | 25 |
|
24 | 26 |
/** |
drupal7/sites/all/modules/module_filter/module_filter.module | ||
---|---|---|
18 | 18 |
return array( |
19 | 19 |
'administer module filter' => array( |
20 | 20 |
'title' => t('Administer Module Filter'), |
21 |
'description' => t('Configure how Module Filter performs.') |
|
22 |
) |
|
21 |
'description' => t('Configure how Module Filter performs.'),
|
|
22 |
),
|
|
23 | 23 |
); |
24 | 24 |
} |
25 | 25 |
|
... | ... | |
33 | 33 |
'access arguments' => array('administer module filter'), |
34 | 34 |
'page callback' => 'drupal_get_form', |
35 | 35 |
'page arguments' => array('module_filter_settings'), |
36 |
'file' => 'module_filter.admin.inc' |
|
36 |
'file' => 'module_filter.admin.inc',
|
|
37 | 37 |
); |
38 | 38 |
return $items; |
39 | 39 |
} |
... | ... | |
63 | 63 |
'#type' => 'module_filter', |
64 | 64 |
'#attached' => array( |
65 | 65 |
'js' => array( |
66 |
drupal_get_path('module', 'module_filter') . '/js/modules.js' |
|
67 |
) |
|
68 |
) |
|
66 |
drupal_get_path('module', 'module_filter') . '/js/modules.js' => array('weight' => 1),
|
|
67 |
),
|
|
68 |
),
|
|
69 | 69 |
); |
70 | 70 |
$checkbox_defaults = array( |
71 | 71 |
((isset($_GET['enabled'])) ? $_GET['enabled'] : 1) ? 'enabled' : '', |
72 | 72 |
((isset($_GET['disabled'])) ? $_GET['disabled'] : 1) ? 'disabled' : '', |
73 | 73 |
((isset($_GET['required'])) ? $_GET['required'] : 1) ? 'required' : '', |
74 |
((isset($_GET['unavailable'])) ? $_GET['unavailable'] : 1) ? 'unavailable' : '' |
|
74 |
((isset($_GET['unavailable'])) ? $_GET['unavailable'] : 1) ? 'unavailable' : '',
|
|
75 | 75 |
); |
76 | 76 |
$form['module_filter']['show'] = array( |
77 | 77 |
'#type' => 'checkboxes', |
78 | 78 |
'#default_value' => array_filter($checkbox_defaults), |
79 | 79 |
'#options' => array('enabled' => t('Enabled'), 'disabled' => t('Disabled'), 'required' => t('Required'), 'unavailable' => t('Unavailable')), |
80 | 80 |
'#prefix' => '<div id="module-filter-show-wrapper">', |
81 |
'#suffix' => '</div>' |
|
81 |
'#suffix' => '</div>',
|
|
82 | 82 |
); |
83 | 83 |
|
84 | 84 |
if (variable_get('module_filter_tabs', 1)) { |
85 |
$form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') .'/css/module_filter_tab.css'; |
|
85 |
$form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') . '/css/module_filter_tab.css';
|
|
86 | 86 |
$form['module_filter']['#attached']['library'][] = array('system', 'jquery.bbq'); |
87 |
$form['module_filter']['#attached']['js'][] = drupal_get_path('module', 'module_filter') .'/js/module_filter_tab.js';
|
|
87 |
$form['module_filter']['#attached']['js'][drupal_get_path('module', 'module_filter') . '/js/module_filter_tab.js'] = array('weight' => 2);
|
|
88 | 88 |
|
89 | 89 |
if (!module_exists('page_actions') && variable_get('module_filter_dynamic_save_position', 1)) { |
90 |
$form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') .'/css/dynamic_position.css'; |
|
91 |
$form['module_filter']['#attached']['js'][] = drupal_get_path('module', 'module_filter') .'/js/dynamic_position.js';
|
|
90 |
$form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') . '/css/dynamic_position.css';
|
|
91 |
$form['module_filter']['#attached']['js'][drupal_get_path('module', 'module_filter') . '/js/dynamic_position.js'] = array('weight' => 3);
|
|
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
$form['#attached']['css'][] = drupal_get_path('module', 'module_filter') . '/css/modules.css'; |
... | ... | |
128 | 128 |
'#process' => array('form_process_module_filter', 'ajax_process_form'), |
129 | 129 |
'#weight' => -1, |
130 | 130 |
'#tree' => TRUE, |
131 |
'#theme' => 'module_filter' |
|
131 |
'#theme' => 'module_filter',
|
|
132 | 132 |
); |
133 | 133 |
return $types; |
134 | 134 |
} |
... | ... | |
153 | 153 |
); |
154 | 154 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules