1
|
<?php
|
2
|
require_once('class/site_point.class.php');
|
3
|
?>
|
4
|
|
5
|
<!DOCTYPE html>
|
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
|
7
|
<head>
|
8
|
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
|
9
|
<link rel="stylesheet" media="screen" href="css/base.css" />
|
10
|
<title>Positionnerment dun panoramique</title>
|
11
|
|
12
|
<?php
|
13
|
|
14
|
$params = array('title' => array('name' => 'titre',
|
15
|
'pattern' => '^.{1,50}$',
|
16
|
'required' => true),
|
17
|
'latitude' => array('name' => 'latitude',
|
18
|
'type' => 'numeric',
|
19
|
'min' => -180,
|
20
|
'max' => 180,
|
21
|
'required' => true),
|
22
|
'longitude' => array('name' => 'longitude',
|
23
|
'type' => 'numeric',
|
24
|
'min' => -180,
|
25
|
'max' => 180,
|
26
|
'required' => true),
|
27
|
'altitude' => array('name' => 'altitude',
|
28
|
'type' => 'numeric',
|
29
|
'min' => -400,
|
30
|
'required' => true),
|
31
|
'loop' => array('name' => 'image_loop',
|
32
|
'type' => 'boolean',
|
33
|
'required' => false),
|
34
|
'dir' => array('required' => true),
|
35
|
'panorama' => array('required' => true));
|
36
|
$wrong = array();
|
37
|
$values = array();
|
38
|
|
39
|
foreach($params as $param => $check) {
|
40
|
if (isset($_REQUEST['param_'.$param])) {
|
41
|
$tst = $_REQUEST['param_'.$param];
|
42
|
if ((isset($check['min']) || isset($check['max'])) && ! is_numeric($tst)) $wrong[$param] = "<em>$tst</em> ne correspond pas à une valeur numérique";
|
43
|
else if (isset($check['min']) && $tst < $check['min']) $wrong[$param] = "<em>$tst</em> trop bas";
|
44
|
else if (isset($check['max']) && $tst > $check['max']) $wrong[$param] = "<em>$tst</em> trop haut";
|
45
|
else if (isset($check['pattern']) && preg_match('/'.preg_quote($check['pattern']).'/', $tst)) $wrong[$param] = "<em>$tst</em> non conforme";
|
46
|
else $values[$param] = $tst;
|
47
|
} else if (isset($check['required']) && $check['required']) {
|
48
|
$wrong[$param] = '<em>$tst</em> est un paramètre manquant';
|
49
|
}
|
50
|
}
|
51
|
|
52
|
|
53
|
if (count($wrong) == 0) {
|
54
|
$pano = site_point::get($values['panorama']);
|
55
|
|
56
|
|
57
|
echo '<p>Les valeurs suivantes sont utilisées.</p>'."\n";
|
58
|
echo "<dl>\n";
|
59
|
foreach ($values as $k => $v) {
|
60
|
if (isset($params[$k]['name'])) {
|
61
|
$nm = $params[$k]['name'];
|
62
|
if (isset($params[$k]['type']) && $params[$k]['type'] == 'numeric') {
|
63
|
$vf = $v;
|
64
|
} else if (isset($params[$k]['type']) && $params[$k]['type'] == 'boolean') {
|
65
|
$vf = $v ? "true" : "false";
|
66
|
} else {
|
67
|
$vf = "\"$v\"";
|
68
|
}
|
69
|
$pano->set_param($nm, $vf);
|
70
|
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $nm, $vf);
|
71
|
}
|
72
|
}
|
73
|
$pano->save_params();
|
74
|
|
75
|
echo "</dl>\n";
|
76
|
echo '<p class="succes">Paramétrage terminé.</p>'."\n";
|
77
|
printf('<a href="%s">Retour au panorama</a></p>'."\n", $panorama->get_url());
|
78
|
|
79
|
|
80
|
} else {
|
81
|
echo '<p class="error">Les valeurs suivantes sont incorrectes.</p>'."\n";
|
82
|
echo "<dl>\n";
|
83
|
foreach ($wrong as $k => $v) {
|
84
|
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $k, $v);
|
85
|
}
|
86
|
echo "</dl>\n";
|
87
|
}
|
88
|
?>
|
89
|
</html>
|