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