get_primaldatafrom($id); } else { $this->id = $id; $this->get_primaldata(); } $this->get_otherdata(); } // --------------------------------------------------------------- // get_primaldata() : récupération infos subcollection à partir de l'id // --------------------------------------------------------------- function get_primaldata() { global $dbh; $requete = "SELECT * FROM sub_collections WHERE sub_coll_id='".addslashes($this->id)."' "; $result = mysql_query($requete, $dbh); if(mysql_num_rows($result)) { $obj = mysql_fetch_object($result); mysql_free_result($result); $this->get_primaldatafrom($obj); } else { // pas de sous-collection avec cette clé $this->id = 0; $this->name = ''; $this->parent = ''; $this->parent_libelle = ''; $this->parent_isbd = ''; $this->publisher = ''; $this->publisher_libelle = ''; $this->publisher_isbd = ''; $this->display = ''; $this->issn = ''; $this->isbd_entry = ''; $this->comment = ''; } } // --------------------------------------------------------------- // get_primaldatafrom($obj) : récupération infos collection à partir d'un collection-objet // --------------------------------------------------------------- function get_primaldatafrom($obj) { $this->id = $obj->sub_coll_id; $this->name = $obj->sub_coll_name; $this->parent = $obj->sub_coll_parent; $this->issn = $obj->sub_coll_issn; $this->comment = $obj->subcollection_comment; } // --------------------------------------------------------------- // get_otherdata() : calcul des données n'appartenant pas à la table // --------------------------------------------------------------- function get_otherdata() { if ($this->parent) { $parentcoll = new collection($this->parent); $this->parent_libelle = $parentcoll->name; $this->parent_isbd = $parentcoll->isbd_entry; $this->publisher = $parentcoll->parent; $this->publisher_libelle = $parentcoll->publisher_libelle; $this->publisher_isbd = $parentcoll->publisher_isbd; } else { $this->parent_libelle = ""; $this->parent_isbd = ""; $this->publisher = ""; $this->publisher_libelle = ""; $this->publisher_isbd = ""; } $this->display = $this->parent_libelle.'. '.$this->name.' ('.$this->publisher_libelle.')'; $this->isbd_entry = $this->issn ? $this->parent_libelle.'. '.$this->name.', ISSN '.$this->issn : $this->parent_libelle.'. '.$this->name ; } // --------------------------------------------------------------- // print_resume($level) : affichage d'informations sur la sous-collection // --------------------------------------------------------------- function print_resume($level = 2,$css) { global $css; if(!$this->id) return; // adaptation par rapport au niveau de détail souhaité switch ($level) { // case x : case 2 : default : global $subcollection_level2_display; global $subcollection_level2_no_issn_info; $subcollection_display = $subcollection_level2_display; $subcollection_no_issn_info = $subcollection_level2_no_issn_info; break; } $print = $subcollection_display; // remplacement des champs statiques $print = str_replace("!!name!!", $this->name, $print); $print = str_replace("!!issn!!", $this->issn ? $this->issn : $subcollection_no_issn_info, $print); $print = str_replace("!!publ!!", $this->publisher_libelle, $print); $print = str_replace("!!publ_isbd!!", $this->publisher_isbd, $print); $print = str_replace("!!coll!!", $this->parent_libelle, $print); $print = str_replace("!!coll_isbd!!", $this->parent_isbd, $print); $print = str_replace("!!isbd!!", $this->isbd_entry, $print); $print = str_replace("!!comment!!", $this->comment, $print); // remplacement des champs dynamiques if (ereg("!!publisher!!", $print)) { $remplacement = "$this->publisher_libelle"; $print = str_replace("!!publisher!!", $remplacement, $print); } if (ereg("!!collection!!", $print)) { $remplacement = "$this->parent_libelle"; $print = str_replace("!!collection!!", $remplacement, $print); } return $print; } } # fin de définition de la classe subcollection } # fin de délaration