2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
9 private $imgpath = null;
10 private $title = null;
11 private $description = null;
14 const err_lonlat_invalid = 1;
16 function __construct ($id, $lon, $lat, $imgpath, $title, $description, $date) {
17 $this->imgpath = $imgpath;
25 $this->title = $title;
28 $this->description = $description;
34 if (!isset ($lon) || !is_numeric ($lon) ||
35 ($lon < -180) || ($lon > 180)) {
36 throw new Exception ($this->err_lonlat_invalid);
41 if (!isset ($lat) || !is_numeric ($lat) ||
42 ($lat < -90) || ($lat > 90)) {
43 throw new Exception ($this->err_lonlat_invalid);
48 public function __get ($attr) {
49 if (isset ($this->$attr)) return $this->$attr;
50 else throw new Exception ('Unknow attribute '.$attr);
53 public function __set ($attr,$value) {
54 throw new Exception ('properties can only be set in constructor');
59 interface anydbConnection {
60 const err_driver_unavailable = 1;
61 const err_connection = 2;
62 const err_unknown_database = 3;
66 * connect to database; That method may be called multiple times.
68 public function connect($host, $user, $pwd, $dbname, $dbprefix);
71 * return true if users table already exists
73 public function users_table_exists();
77 * throws an err_query error in case users table already exists.
79 public function create_users_table();
82 * return true if items table already exists
84 public function items_table_exists();
88 * throws an err_query error in case items table already exists.
90 public function create_items_table();
93 * set password $pwd for user $usrname. If $usrname does not exist, create
96 public function setpwd($usrname, $pwd);
99 * check that $pwd_md5 is md5 for $username password.
101 public function checkpwdmd5($usrname, $pwd_md5);
104 * saves feature in database. If feature has an id, feature will be updated
105 * in database; otherwise it will be created. Returns saved feature
107 public function save_feature($feature);
110 * delete feature from database. Returns true in case of success, even if
111 * image was not referenced in the database.
113 public function delete_feature($feature);
116 * Returns feature with given id. If none exists, returns null.
118 public function getfeature($id);
121 * returns an array of available features
123 public function listfeatures();
126 * returns the most recent features sorted by date. If $num_features is not
127 * defined or is null, returns all features sorted by date.
129 public function mostrecentfeatures($num_features);
132 * returns true if a feature with imgpath exists
134 public function imgpath_exists($imgpath);
137 * returns Minimum Bounding Rectangle containing all feature locations.
138 * That function must return a result even if database is not functional.
139 * Minimum Bounding Rectangle is presented as an Array:
140 * [bottom, left, top, right]
142 public function mbr();
145 * get name of database backend
147 public function getdbname();