1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Common pages for the Media module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* CTools modal callback for editing a file.
|
10
|
*/
|
11
|
function media_file_edit_modal($form, &$form_state, $file, $js) {
|
12
|
ctools_include('modal');
|
13
|
ctools_include('ajax');
|
14
|
|
15
|
$form_state['ajax'] = $js;
|
16
|
form_load_include($form_state, 'inc', 'file_entity', 'file_entity.pages');
|
17
|
|
18
|
$output = ctools_modal_form_wrapper('file_entity_edit', $form_state);
|
19
|
|
20
|
if ($js) {
|
21
|
$commands = $output;
|
22
|
|
23
|
if ($form_state['executed']) {
|
24
|
$commands = array(ctools_modal_command_dismiss(t('File saved')));
|
25
|
$preview = media_get_thumbnail_preview($file);
|
26
|
$commands[] = ajax_command_replace('.media-item[data-fid=' . $file->fid . ']', render($preview));
|
27
|
}
|
28
|
|
29
|
print ajax_render($commands);
|
30
|
exit();
|
31
|
}
|
32
|
|
33
|
// Otherwise, just return the output.
|
34
|
return $output;
|
35
|
}
|