-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagecache_external.admin.inc
executable file
·59 lines (55 loc) · 1.72 KB
/
imagecache_external.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
* @file imagecache_external.admin.inc
* Admin forms for this module
* @copyright Copyright(c) 2010 Lee Rowlands
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Lee Rowlands contact at rowlandsgroup dot com
*
*/
/**
* Form builder
*/
function imagecache_external_admin_form($form_state) {
$form = array();
$form['imagecache_external_option'] = array(
'#type' => 'radios',
'#title' => t('Hosts list option'),
'#description' => t('Choose the method to filter external urls (note admin user is not affected)'),
'#options' => array(
'black' => t('Blacklist: Only deny images from the listed hosts.'),
'white' => t('Whitelist: Deny all images <b>except</b> the listed hosts.'),
),
'#default_value' => variable_get('imagecache_external_option', 'black'),
);
$form['imagecache_external_hosts'] = array(
'#type' => 'textarea',
'#title' => t('Imagecache External hosts'),
'#description' => t('Add one host per line. Ex: www.flickr.com'),
'#default_value' => variable_get('imagecache_external_hosts', ''),
);
return system_settings_form($form);
}
/**
* Form builder
*/
function imagecache_external_flush_form($form_state) {
return confirm_form($form,
t('Flush all external images?'),
'admin/settings/imagecache_external',
t('Are you sure, this cannot be undone.'),
t('Flush'),
t('Cancel')
);
}
/**
* Submit handler
*/
function imagecache_external_flush_form_submit($form, &$form_state) {
$dir = realpath(file_directory_path() .'/externals');
if (is_dir($dir)) {
_imagecache_recursive_delete($dir);
drupal_set_message(t('Flushed external images'));
$form_state['redirect'] = 'admin/settings/imagecache_external';
}
}