Projet

Général

Profil

Paste
Télécharger (1,07 ko) Statistiques
| Branche: | Révision:

root / ajax / add_reference.php @ 329a7a3b

1
<?php
2
require_once('../class/FormValidator.class.php');
3
require_once('../class/RefPoint.class.php');
4
require_once('../class/site_point.class.php');
5

    
6
$fields_spec = array('x'         => array('required', 'numeric', 'positive'),
7
                     'y'         => array('required', 'numeric', 'positive'),
8
                     'panorama'  => array('required'),
9
                     'ref_point' => array('required'),
10
);
11

    
12

    
13
$validator = new FormValidator($fields_spec);
14
if ($validator->validate($_REQUEST)) {
15
  $vals = $validator->sane_values();
16

    
17
  // temp test code
18
  $pano = site_point::get(urldecode($vals['panorama']));
19

    
20
  $ref_point_name = urldecode($vals['ref_point']);
21
  $ref_point = RefPoint::get($ref_point_name);
22

    
23
  $pano->set_reference($ref_point, $vals['x'], $vals['y']);
24
  $pano->save_params();
25

    
26
 } else {
27
   // Set our response code
28
   http_response_code(400);
29
   echo var_dump($validator->errors());
30
 }
31

    
32
// Test url : clear ;curl 'http://localhost/~jocelyn/panorama/ajax/add_reference.php?x=42&y=42&panorama=pano_couttolenc_bords_jointifs&ref_point=%C3%89glise%20saint-jacques'
33
?>