1 | <?php |
---|
2 | /* Configuration of Panoramas */ |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | if (!defined('IN_ADMIN') or !IN_ADMIN) die('Hacking attempt!'); |
---|
5 | load_language('plugin.lang', ASP_PATH); |
---|
6 | |
---|
7 | global $conf, $template; |
---|
8 | $errors = array(); |
---|
9 | $infos = array(); |
---|
10 | $asp = & $conf['AS_panorama']; |
---|
11 | |
---|
12 | $sub = ( isset($_POST['submit']) ) ? true : false; |
---|
13 | |
---|
14 | if ( $sub ) { |
---|
15 | // 'in_mode_360' => '_360', |
---|
16 | // Picture name substring to display in Mode 360 |
---|
17 | // 'in_mode_180' => '_180', # |
---|
18 | // Picture name substring to display in Mode 180 |
---|
19 | $nsp = array_merge($asp, $_POST); |
---|
20 | if ( $nsp['viewport_width']=='' or !is_numeric($nsp['viewport_width']) or $nsp['viewport_width'] < 50 or $nsp['viewport_width'] > 100 ) |
---|
21 | array_push($errors, l10n('Viewport width ratio is out of range (Correct range: 50-100).')); |
---|
22 | if ( $nsp['viewport_height']=='' or !is_numeric($nsp['viewport_height']) or $nsp['viewport_height'] < 500 or $nsp['viewport_height'] > 800 ) |
---|
23 | array_push($errors, l10n('Viewport height is out of range (Correct range: 500-800).')); |
---|
24 | if ( $nsp['min_viewport_width']=='' or !is_numeric($nsp['min_viewport_width']) or $nsp['min_viewport_width'] < 320 ) |
---|
25 | array_push($errors, l10n('Minimal Viewport width is out of range (Correct range: 320/+).')); |
---|
26 | if ( $nsp['max_viewport_width']=='' or !is_numeric($nsp['max_viewport_width']) or $nsp['max_viewport_width'] < $nsp['min_viewport_width'] ) |
---|
27 | array_push($errors, l10n('Maximal Viewport width is out of range (Correct range: Minimal/+).')); |
---|
28 | if ( $nsp['speed']=='' or !is_numeric($nsp['speed']) or $nsp['speed'] < 10 or $nsp['speed'] > 90 ) |
---|
29 | array_push($errors, l10n('Relative speed factor is out of range (Correct range: 10-90).')); |
---|
30 | if ( $nsp['start_position']=='' or !is_numeric($nsp['start_position']) or $nsp['start_position'] < 0 or $nsp['start_position'] > 99 ) |
---|
31 | array_push($errors, l10n('Start position ratio is out of range (Correct range: 0-99).')); |
---|
32 | if ( $nsp['start_position']=='' or !is_numeric($nsp['start_position']) or $nsp['start_position'] < 0 or $nsp['start_position'] > 99 ) |
---|
33 | array_push($errors, l10n('Start position ratio is out of range (Correct range: 0-99).')); |
---|
34 | if ( $nsp['cont_border']=='' or !is_numeric($nsp['cont_border']) or $nsp['cont_border'] < 0 or $nsp['cont_border'] > 10 ) |
---|
35 | array_push($errors, l10n('Border Width ratio is out of range (Correct range: 0-10).')); |
---|
36 | |
---|
37 | $nsp['in_mode_360'] = trim((string) $nsp['in_mode_360']); |
---|
38 | $nsp['in_mode_180'] = trim((string) $nsp['in_mode_180']); |
---|
39 | if ( $nsp['in_mode_360']=='' or $nsp['in_mode_180']=='' ) |
---|
40 | array_push($errors, l10n('Picture name substring could not be empty.')); |
---|
41 | if ( $nsp['in_mode_360'] == $nsp['in_mode_180'] ) |
---|
42 | array_push($errors, l10n('Picture name substrings must be different.')); |
---|
43 | if ( count($errors) > 0 ) |
---|
44 | array_push($errors, l10n('Your configuration is NOT saved due to above reasons.')); |
---|
45 | if ( !is_webmaster() and count($errors) == 0 ) |
---|
46 | array_push($infos, l10n('You are not authorized to change this configuration (Webmaster only).')); |
---|
47 | if ( is_webmaster() and count($errors) == 0 ) |
---|
48 | { |
---|
49 | $nsp = array_merge( $asp, $nsp ); |
---|
50 | unset($nsp['submit'], $nsp['Ver'], $nsp['Path'], $nsp['Dir']); |
---|
51 | // var_dump($nsp); |
---|
52 | $confasp = serialize($nsp); |
---|
53 | conf_update_param('AS_panorama', $confasp); |
---|
54 | array_push($infos, l10n('Your configuration is saved.')); |
---|
55 | } |
---|
56 | $asp = $nsp; |
---|
57 | } |
---|
58 | $template->set_filenames( array('AS_panorama_admin' => dirname(__FILE__).'/template/AS_Panorama_admin.tpl') ); |
---|
59 | foreach ($asp as $k => & $v) { |
---|
60 | if (is_string($v)) $asp[$k] = htmlspecialchars($v, ENT_QUOTES, 'utf-8'); |
---|
61 | else $asp[$k] = $v; |
---|
62 | } |
---|
63 | if (count($errors) != 0) $template->assign('errors', $errors); |
---|
64 | if (count($infos) != 0) $template->assign('infos', $infos); |
---|
65 | $asp['Path'] = embellish_url($template->get_template_vars('ROOT_URL').ASP_PATH); |
---|
66 | $asp = array_merge( $asp, array( |
---|
67 | 'Dir' => ASP_DIR, |
---|
68 | 'Path' => ASP_PATH, |
---|
69 | )); |
---|
70 | $template->append('head_elements', |
---|
71 | '<script type="text/javascript" src="./plugins/Panoramas/farbtastic/farbtastic.js"></script> |
---|
72 | <link rel="stylesheet" type="text/css" href="./plugins/Panoramas/farbtastic/farbtastic.css" />'); |
---|
73 | $template->assign( 'ASP', $asp ); |
---|
74 | $template->assign_var_from_handle('ADMIN_CONTENT', 'AS_panorama_admin'); |
---|
75 | ?> |
---|