1 |
58344a8d
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* File hooks implemented by the Media: YouTube module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_file_operations().
|
10 |
|
|
*/
|
11 |
|
|
function media_youtube_file_operations() {
|
12 |
|
|
$operations = array(
|
13 |
|
|
'media_youtube_refresh' => array(
|
14 |
|
|
'label' => t('Refresh YouTube information from source'),
|
15 |
|
|
'callback' => 'media_youtube_cache_clear',
|
16 |
|
|
),
|
17 |
|
|
);
|
18 |
|
|
|
19 |
|
|
return $operations;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
/**
|
23 |
|
|
* Clear the cached YouTube content for the selected files.
|
24 |
|
|
*/
|
25 |
|
|
function media_youtube_cache_clear($fids) {
|
26 |
|
|
$fids = array_keys($fids);
|
27 |
|
|
|
28 |
|
|
$query = new EntityFieldQuery();
|
29 |
|
|
$results = $query
|
30 |
|
|
->entityCondition('entity_type', 'file')
|
31 |
|
|
->propertyCondition('uri', 'youtube:', 'STARTS_WITH')
|
32 |
|
|
->propertyCondition('fid', $fids)
|
33 |
|
|
->execute();
|
34 |
|
|
|
35 |
|
|
$files = file_load_multiple(array_keys($results['file']));
|
36 |
|
|
|
37 |
|
|
foreach ($files as $file) {
|
38 |
|
|
$wrapper = file_stream_wrapper_get_instance_by_uri($file->uri);
|
39 |
|
|
$local_path = $wrapper->getLocalThumbnailPath();
|
40 |
|
|
file_unmanaged_delete($local_path);
|
41 |
|
|
}
|
42 |
|
|
} |