id = intval($id); $this->getData(); } /* --------------------------------------------------------------- getData() : récupération des propriétés --------------------------------------------------------------- */ public function getData() { if(!$this->id) return; $requete = 'SELECT * FROM map_echelles WHERE map_echelle_id='.$this->id; $result = @pmb_mysql_query($requete); if(!pmb_mysql_num_rows($result)) { pmb_error::get_instance(static::class)->add_message("not_found", "not_found_object"); return; } $data = pmb_mysql_fetch_object($result); $this->name = $data->map_echelle_name ; } public function get_form() { global $msg; global $admin_map_echelle_content_form; global $charset; $content_form = $admin_map_echelle_content_form; $content_form = str_replace('!!id!!', $this->id, $content_form); $interface_form = new interface_admin_form('map_echelleform'); if(!$this->id){ $interface_form->set_label($msg['admin_noti_map_echelle_ajout']); }else{ $interface_form->set_label($msg['admin_noti_map_echelle_modification']); } $content_form = str_replace('!!nom!!', htmlentities($this->name, ENT_QUOTES, $charset), $content_form); $interface_form->set_object_id($this->id) ->set_confirm_delete_msg($msg['confirm_suppr_de']." ".$this->name." ?") ->set_content_form($content_form) ->set_table_name('map_echelles') ->set_field_focus('form_nom'); return $interface_form->get_display(); } public function set_properties_from_form() { global $form_nom; $this->name = stripslashes($form_nom); } public function save() { if($this->id) { $requete = "UPDATE map_echelles SET map_echelle_name='".addslashes($this->name)."' WHERE map_echelle_id='".$this->id."' "; pmb_mysql_query($requete); } else { $requete = "SELECT count(1) FROM map_echelles WHERE map_echelle_name='".addslashes($this->name)."' LIMIT 1 "; $res = pmb_mysql_query($requete); $nbr = pmb_mysql_result($res, 0, 0); if($nbr == 0){ $requete = "INSERT INTO map_echelles (map_echelle_name) VALUES ('".addslashes($this->name)."') "; pmb_mysql_query($requete); } } } public static function check_data_from_form() { global $form_nom; if(empty($form_nom)) { return false; } return true; } public static function delete($id) { $id = intval($id); if ($id) { $requete = "DELETE FROM map_echelles WHERE map_echelle_id='$id' "; pmb_mysql_query($requete); $requete = "OPTIMIZE TABLE map_echelles "; pmb_mysql_query($requete); return true; } return true; } } /* fin de définition de la classe */