id = intval($id); $this->getData(); } /* --------------------------------------------------------------- getData() : récupération des propriétés --------------------------------------------------------------- */ public function getData() { if(!$this->id) return; $requete = 'SELECT * FROM map_refs WHERE map_ref_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_ref_name ; } public function get_form() { global $msg; global $admin_map_ref_content_form; global $charset; $content_form = $admin_map_ref_content_form; $content_form = str_replace('!!id!!', $this->id, $content_form); $interface_form = new interface_admin_form('map_refform'); if(!$this->id){ $interface_form->set_label($msg['admin_noti_map_ref_ajout']); }else{ $interface_form->set_label($msg['admin_noti_map_ref_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_refs') ->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_refs SET map_ref_name='".addslashes($this->name)."' WHERE map_ref_id='".$this->id."' "; $res = pmb_mysql_query($requete); } else { $requete = "SELECT count(1) FROM map_refs WHERE map_ref_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_refs (map_ref_name) VALUES ('".addslashes($this->name)."') "; $res = 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_refs WHERE map_ref_id='$id' "; pmb_mysql_query($requete); $requete = "OPTIMIZE TABLE map_refs "; pmb_mysql_query($requete); return true; } return true; } } /* fin de définition de la classe */