1 | <?php |
---|
2 | //Initialization |
---|
3 | $conf_media_icon_advanced = unserialize($conf['media_icon_advanced']); |
---|
4 | |
---|
5 | //Save config |
---|
6 | if (isset($_POST['submit'])) { |
---|
7 | $conf_media_icon_advanced = $_POST['media_icon']; |
---|
8 | $media_icon_errors = array(); |
---|
9 | |
---|
10 | // step 1 - sanitize HTML input |
---|
11 | switch ($conf_media_icon_advanced['position']) { |
---|
12 | case 'topleft': |
---|
13 | $conf_media_icon_advanced['xposition'] = 'left: 5px'; |
---|
14 | $conf_media_icon_advanced['yposition'] = 'top: 5px'; |
---|
15 | break; |
---|
16 | case 'topright': |
---|
17 | $conf_media_icon_advanced['xposition'] = 'right: 5px'; |
---|
18 | $conf_media_icon_advanced['yposition'] = 'top: 5px'; |
---|
19 | break; |
---|
20 | case 'bottomleft': |
---|
21 | $conf_media_icon_advanced['xposition'] = 'left: 5px'; |
---|
22 | $conf_media_icon_advanced['yposition'] = 'bottom: 5px'; |
---|
23 | break; |
---|
24 | case 'bottomright': |
---|
25 | $conf_media_icon_advanced['xposition'] = 'right: 5px'; |
---|
26 | $conf_media_icon_advanced['yposition'] = 'bottom: 5px'; |
---|
27 | break; |
---|
28 | } |
---|
29 | |
---|
30 | // step 2 - check validity |
---|
31 | $media_icon_test = intval($conf_media_icon_advanced['opacity']); |
---|
32 | if (is_nan($media_icon_test) or $media_icon_test <= 0 or $media_icon_test > 100) { |
---|
33 | $media_icon_errors['opacity'] = l10n('The opacity have to be a number between 0 and 100'); |
---|
34 | } |
---|
35 | |
---|
36 | // step 3 - save data |
---|
37 | if (count($media_icon_errors) == 0) { |
---|
38 | conf_update_param('media_icon_advanced', serialize($conf_media_icon_advanced)); |
---|
39 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
40 | } else { |
---|
41 | $page['errors'] = array_merge($page['errors'], $media_icon_errors); |
---|
42 | $template->assign('media_icon_advanced', $conf_media_icon_advanced); |
---|
43 | $template->assign('media_icon_errors', $media_icon_errors); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | //Parameters of the template |
---|
48 | $template->assign( |
---|
49 | 'media_icon_advanced', |
---|
50 | array( |
---|
51 | 'position' => $conf_media_icon_advanced['position'], |
---|
52 | 'opacity' => $conf_media_icon_advanced['opacity'], |
---|
53 | ) |
---|
54 | ); |
---|
55 | |
---|
56 | //Add our template to the global template |
---|
57 | $template->set_filenames( |
---|
58 | array( |
---|
59 | 'plugin_admin_content' => dirname(__FILE__).'/admin_advanced.tpl' |
---|
60 | ) |
---|
61 | ); |
---|
62 | |
---|
63 | //Assign the template contents to ADMIN_CONTENT |
---|
64 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
65 | ?> |
---|