id = $id+0; $this->getData($data); } // --------------------------------------------------------------- // getData() : récupération infos // --------------------------------------------------------------- public function getData($data) { global $dbh; $this->name = ''; $this->comment = ''; $this->code =array(); if($this->id) { $requete = "SELECT * FROM notice_tpl WHERE notpl_id='".$this->id."' LIMIT 1 "; $result = @pmb_mysql_query($requete, $dbh); if(pmb_mysql_num_rows($result)) { $temp = pmb_mysql_fetch_object($result); $this->name = $temp->notpl_name; $this->comment = $temp->notpl_comment ; // récup code $requete = "SELECT * FROM notice_tplcode WHERE num_notpl='".$this->id."' "; $result_code = @pmb_mysql_query($requete, $dbh); if(pmb_mysql_num_rows($result_code)) { while(($temp_code= pmb_mysql_fetch_object($result_code))) { $this->code[$temp_code->notplcode_localisation][$temp_code->notplcode_niveau_biblio] [$temp_code->notplcode_typdoc]=$temp_code->nottplcode_code; } } } else { // pas trouvé avec cette clé $this->id = 0; } }elseif(sizeof($data)){ //en provenance du selecteur de mode d'affichage $this->name = $data['NAME']; $this->comment = $data['COMMENT'] ; foreach($data['CODE'] as $code){ $this->code[$code['LOCALISATION']][$code['NIVEAU_BIBLIO']][$code['TYPDOC']]=$code['value']; } } } public function build_notice($id_notice,$location=0,$in_relation=false, $id_bannette = 0){ global $dbh,$parser_environnement; $parser_environnement['id_template'] = $this->id; $parser=parse_format::get_instance('notice_tpl.inc.php', $in_relation); $requete = "SELECT typdoc, niveau_biblio FROM notices WHERE notice_id='".$id_notice."' LIMIT 1 "; $result = @pmb_mysql_query($requete, $dbh); if(pmb_mysql_num_rows($result)) { $temp = pmb_mysql_fetch_object($result); $typdoc = $temp->typdoc; $niveau_biblio = $temp->niveau_biblio; //$niveau_hierar = $temp->niveau_hierar; } else return ""; // Recherche du code à appliquer (du particulier au général) if(!empty($this->code[$location][$niveau_biblio][$typdoc])) { $code=$this->code[$location][$niveau_biblio][$typdoc]; } elseif (!empty($this->code[$location][$niveau_biblio][0])) { $code=$this->code[$location][$niveau_biblio][0]; } elseif (!empty($this->code[0][$niveau_biblio][$typdoc])) { $code=$this->code[0][$niveau_biblio][$typdoc]; } elseif (!empty($this->code[0][$niveau_biblio][0])) { $code=$this->code[0][$niveau_biblio][0]; } elseif (!empty($this->code[0][0][$typdoc])) { $code=$this->code[0][0][$typdoc]; } elseif (!empty($this->code[0][0][0])) { $code=$this->code[0][0][0]; } else return ""; $temp = pmb_mysql_fetch_object($result); $parser->cmd = $code; $parser_environnement['id_notice']=$id_notice; $parser_environnement['id_bannette']=$id_bannette; return $parser->exec_cmd(); } public function get_print_css_style() { $css_style = " "; return $css_style; } public static function gen_tpl_select($select_name="notice_tpl", $selected_id=0, $onchange="",$no_affempty=0,$no_aff_defaut=0) { global $msg,$dbh; // $requete = "SELECT notpl_id, if(notpl_comment!='',concat(notpl_name,'. ',notpl_comment),notpl_name) as nom FROM notice_tpl where notpl_show_opac=1 ORDER BY notpl_name "; $result = pmb_mysql_query($requete, $dbh); if(!pmb_mysql_num_rows($result) && !$no_affempty) return ''; if(!$no_aff_defaut) return gen_liste ($requete, "notpl_id", "nom", $select_name, $onchange, $selected_id, 0, $msg["notice_tpl_list_default"], 0,$msg["notice_tpl_list_default"], 0) ; else return gen_liste ($requete, "notpl_id", "nom", $select_name, $onchange, $selected_id, 0, '', 0,'', 0) ; } public static function get_instance($id=0) { $id += 0; if(!isset(static::$instances[$id])) { static::$instances[$id] = new notice_tpl_gen($id); } return static::$instances[$id]; } } // fin class