id = $id; $this->get_uri(); $this->get_display_label(); } else { $this->uri = $uri; $this->get_id(); $this->get_display_label(); } if($this->id) { $authority = new authority(0, $this->id, AUT_TABLE_CONCEPT); $this->p_perso = $authority->get_p_perso(); } } /** * Retourne l'URI du concept */ public function get_uri() { if (!$this->uri) { $this->uri = onto_common_uri::get_uri($this->id); } return $this->uri; } /** * Retourne l'identifiant du concept * @return int */ public function get_id() { if (!$this->id) { $this->id = onto_common_uri::get_id($this->uri); } return $this->id; } /** * Retourne le libellé à afficher * @return string */ public function get_display_label() { if (!$this->display_label) { global $lang; $this->check_display_label_in_index(); if(!$this->display_label){ $query = "select * where { <".$this->uri."> ?label }"; skos_datastore::query($query); if(skos_datastore::num_rows()){ $results = skos_datastore::get_result(); foreach($results as $key=>$result){ if($result->label_lang==substr($lang,0,2)){ $this->display_label = $result->label; break; } } //pas de langue de l'interface trouvée if (!$this->display_label){ $this->display_label = $result->label; } } } } return $this->display_label; } private function check_display_label_in_index(){ $query = 'select value from skos_fields_global_index where id_item = '.$this->id.' and code_champ = code_ss_champ and code_champ = 1'; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ $this->display_label = pmb_mysql_result($result, 0, 0); } } /** * Retourne les schémas du concept * @return string */ public function get_schemes() { global $dbh, $lang; if (!isset($this->schemes)) { $this->schemes = array(); $query = "select value, lang, authority_num from skos_fields_global_index where id_item = ".$this->id." and code_champ = 4 and code_ss_champ = 1"; $last_values = array(); $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { if ($row->lang == substr($lang,0,2)) { $this->schemes[$row->authority_num] = $row->value; break; } $last_values[$row->authority_num] = $row->value; } //pas de langue de l'interface trouvée foreach ($last_values as $scheme_id => $last_value) { if (!isset($this->schemes[$scheme_id])) { $this->schemes[$scheme_id] = $last_value; } } } } return $this->schemes; } /** * Retourne la vedette composée associée au concept * @return vedette_composee */ public function get_vedette() { if (!$this->vedette) { if ($vedette_id = vedette_link::get_vedette_id_from_object($this->id, TYPE_CONCEPT_PREFLABEL)) { $this->vedette = new vedette_composee($vedette_id); } } return $this->vedette; } /** * Retourne les enfants du concept * @return skos_concepts_list Liste des enfants du concept */ public function get_narrowers() { if (!$this->narrowers) { $this->narrowers = new skos_concepts_list(); $query = "select * where { <".$this->uri."> ?narrower }"; skos_datastore::query($query); if(skos_datastore::num_rows()){ $results = skos_datastore::get_result(); foreach($results as $result){ $this->narrowers->add_concept(new skos_concept(0, $result->narrower)); } } } return $this->narrowers; } /** * Retourne le rendu HTML des enfants du concept */ public function get_narrowers_list() { return skos_view_concepts::get_narrowers_list($this->get_narrowers()); } /** * Retourne les parents du concept * @return skos_concepts_list Liste des parents du concept */ public function get_broaders() { if (!$this->broaders) { $this->broaders = new skos_concepts_list(); $query = "select * where { <".$this->uri."> ?broader }"; skos_datastore::query($query); if(skos_datastore::num_rows()){ $results = skos_datastore::get_result(); foreach($results as $result){ $this->broaders->add_concept(new skos_concept(0, $result->broader)); } } } return $this->broaders; } /** * Retourne le rendu HTML des enfants du concept */ public function get_broaders_list() { return skos_view_concepts::get_broaders_list($this->get_broaders()); } /** * Retourne les identifiants des notices indexées par le concept * @return array Tableau des notices indexées par le concept */ public function get_indexed_notices() { global $dbh; if (!$this->indexed_notices) { $this->indexed_notices = array(); $query = "select num_object from index_concept where num_concept = ".$this->id." and type_object = ".TYPE_NOTICE; $result = pmb_mysql_query($query, $dbh); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { $this->indexed_notices[] = $row->num_object; } } $filter = new filter_results($this->indexed_notices); $this->indexed_notices = explode(",",$filter->get_results()); } return $this->indexed_notices; } /** * Retourne les autorités indexées par le concept * @return array Tableau associatif de tableaux d'autorités indexées par le concept */ public function get_indexed_authorities() { global $dbh; if (!$this->indexed_authorities) { $this->indexed_authorities = array(); $query = "select num_object, type_object from index_concept where num_concept = ".$this->id." and type_object != ".TYPE_NOTICE; $result = pmb_mysql_query($query, $dbh); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { switch ($row->type_object) { case TYPE_AUTHOR : $this->indexed_authorities['author'][] = new auteur($row->num_object); break; case TYPE_CATEGORY : $this->indexed_authorities['category'][] = new category($row->num_object); break; case TYPE_PUBLISHER : $this->indexed_authorities['publisher'][] = new publisher($row->num_object); break; case TYPE_COLLECTION : $this->indexed_authorities['collection'][] = new collection($row->num_object); break; case TYPE_SUBCOLLECTION : $this->indexed_authorities['subcollection'][] = new subcollection($row->num_object); break; case TYPE_SERIE : $this->indexed_authorities['serie'][] = new serie($row->num_object); break; case TYPE_TITRE_UNIFORME : $this->indexed_authorities['titre_uniforme'][] = new titre_uniforme($row->num_object); break; case TYPE_INDEXINT : $this->indexed_authorities['indexint'][] = new indexint($row->num_object); break; case TYPE_EXPL : //TODO Quelle classe utiliser ? // $this->indexed_authorities['expl'][] = new auteur($row->num_object); break; case TYPE_EXPLNUM : $this->indexed_authorities['explnum'][] = new explnum($row->num_object); break; case TYPE_AUTHPERSO : $this->indexed_authorities['authperso'][] = new authperso_authority($row->num_object); break; default: break; } } } } return $this->indexed_authorities; } /** * Retourne les concepts composés qui utilisent le concept * @return skos_concepts_list Liste des concepts composés qui utilisent le concept */ public function get_composed_concepts() { if (!$this->composed_concepts) { $this->composed_concepts = new skos_concepts_list(); $this->composed_concepts->set_composed_concepts_built_with_element($this->id, "concept"); } return $this->composed_concepts; } /** * Retourne le détail d'un concept * @return array Tableau des différentes propriétés du concept */ public function get_details() { global $lang; $details = array(); $query = "select * where { <".$this->uri."> rdf:type skos:Concept . <".$this->uri."> skos:prefLabel ?label . optional { <".$this->uri."> skos:altLabel ?altlabel } . optional { <".$this->uri."> skos:note ?note } . optional { <".$this->uri."> ?notebnf } . optional { <".$this->uri."> skos:related ?related . optional { ?related skos:prefLabel ?relatedlabel } } . optional { <".$this->uri."> skos:related ?related . optional { ?related skos:prefLabel ?relatedlabel } } . optional { <".$this->uri."> owl:sameAs ?sameas . optional { ?sameas skos:prefLabel ?sameaslabel } } . optional { <".$this->uri."> rdfs:seeAlso ?seealso . optional { ?seealso skos:prefLabel ?seealsolabel } } . optional { <".$this->uri."> skos:exactMatch ?exactmatch . optional { ?exactmatch skos:prefLabel ?exactmatchlabel } } . optional { <".$this->uri."> skos:closeMatch ?closematch . optional { ?closematch skos:prefLabel ?closematchlabel } } }"; skos_datastore::query($query); if(skos_datastore::num_rows()){ $results = skos_datastore::get_result(); foreach($results as $result){ foreach($result as $property => $value){ switch($property){ //cas des literaux case "altlabel" : if(!isset($details['http://www.w3.org/2004/02/skos/core#altLabel'])){ $details['http://www.w3.org/2004/02/skos/core#altLabel'] = array(); } if(isset($result->{$propery."_lang"}) == substr($lang,0,2)){ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#altLabel'])){ $details['http://www.w3.org/2004/02/skos/core#altLabel'][] = $value; } break; }else{ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#altLabel'])){ $details['http://www.w3.org/2004/02/skos/core#altLabel'][] = $value; } } break; case "hiddenlabel" : if(!isset($details['http://www.w3.org/2004/02/skos/core#hiddenLabel'])){ $details['http://www.w3.org/2004/02/skos/core#hiddenLabel'] = array(); } if(isset($result->hiddenlabel_lang) == substr($lang,0,2)){ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#hiddenLabel'])){ $details['http://www.w3.org/2004/02/skos/core#hiddenLabel'][] = $value; } break; }else{ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#altLabel'])){ $details['http://www.w3.org/2004/02/skos/core#altLabel'][] = $value; } } break; case "related" : if(!isset($details['http://www.w3.org/2004/02/skos/core#related'])){ $details['http://www.w3.org/2004/02/skos/core#related'] = array(); } if($result->related_type == "uri"){ //on cherche si l'URI est connu dans notre système $id = onto_common_uri::get_id($value); $detail = array( 'uri' => $value ); if(isset($result->relatedlabel)){ $detail['label'] = $result->relatedlabel; } if($id){ $detail['id'] = $id; } if(!in_array($detail,$details['http://www.w3.org/2004/02/skos/core#related'])){ $details['http://www.w3.org/2004/02/skos/core#related'][] = $detail; } } break; case "sameas" : if(!isset($details['http://www.w3.org/2002/07/owl#sameAs'])){ $details['http://www.w3.org/2002/07/owl#sameAs'] = array(); } if($result->sameas_type == "uri"){ //on cherche si l'URI est connu dans notre système $id = onto_common_uri::get_id($value); $detail = array( 'uri' => $value ); if(isset($result->sameaslabel)){ $detail['label'] = $result->sameaslabel; } if($id){ $detail['id'] = $id; } if(!in_array($detail,$details['http://www.w3.org/2002/07/owl#sameAs'])){ $details['http://www.w3.org/2002/07/owl#sameAs'][] = $detail; } } break; case "note" : if(!isset($details['http://www.w3.org/2004/02/skos/core#note'])){ $details['http://www.w3.org/2004/02/skos/core#note'] = array(); } if(isset($result->note_lang) == substr($lang,0,2)){ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#note'])){ $details['http://www.w3.org/2004/02/skos/core#note'][] = $value; } break; }else{ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#note'])){ $details['http://www.w3.org/2004/02/skos/core#note'][] = $value; } } break; case "notebnf" : if(!isset($details['http://www.w3.org/2004/02/skos/core#note'])){ $details['http://www.w3.org/2004/02/skos/core#note'] = array(); } if(isset($result->notebnf_lang) == substr($lang,0,2)){ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#note'])){ $details['http://www.w3.org/2004/02/skos/core#note'][] = $value; } break; }else{ if(!in_array($value,$details['http://www.w3.org/2004/02/skos/core#note'])){ $details['http://www.w3.org/2004/02/skos/core#note'][] = $value; } } break; case "seealso" : if(!isset($details['http://www.w3.org/2000/01/rdf-schema#seeAlso'])){ $details['http://www.w3.org/2000/01/rdf-schema#seeAlso'] = array(); } if($result->seealso_type == "uri"){ //on cherche si l'URI est connu dans notre système $id = onto_common_uri::get_id($value); $detail = array( 'uri' => $value ); if(isset($result->seealsolabel)){ $detail['label'] = $result->seealsolabel; } if($id){ $detail['id'] = $id; } if(!in_array($detail,$details['http://www.w3.org/2000/01/rdf-schema#seeAlso'])){ $details['http://www.w3.org/2000/01/rdf-schema#seeAlso'][] = $detail; } } break; case "exactmatch" : if(!isset($details['http://www.w3.org/2004/02/skos/core#exactMatch'])){ $details['http://www.w3.org/2004/02/skos/core#exactMatch'] = array(); } if($result->exactmatch_type == "uri"){ //on cherche si l'URI est connu dans notre système $id = onto_common_uri::get_id($value); $detail = array( 'uri' => $value ); if(isset($result->exactmatchlabel)){ $detail['label'] = $result->exactmatchlabel; } if($id){ $detail['id'] = $id; } if(!in_array($detail,$details['http://www.w3.org/2004/02/skos/core#exactMatch'])){ $details['http://www.w3.org/2004/02/skos/core#exactMatch'][] = $detail; } } break; case "closematch" : if(!isset($details['http://www.w3.org/2004/02/skos/core#closeMatch'])){ $details['http://www.w3.org/2004/02/skos/core#closeMatch'] = array(); } if($result->closematch_type == "uri"){ //on cherche si l'URI est connu dans notre système $id = onto_common_uri::get_id($value); $detail = array( 'uri' => $value ); if(isset($result->closematchlabel)){ $detail['label'] = $result->closematchlabel; } if($id){ $detail['id'] = $id; } if(!in_array($detail,$details['http://www.w3.org/2004/02/skos/core#closeMatch'])){ $details['http://www.w3.org/2004/02/skos/core#closeMatch'][] = $detail; } } break; } } } } return $details; } public function get_details_list() { return skos_view_concept::get_detail_concept($this); } public function get_db_id() { return $this->get_id(); } public function get_isbd() { return $this->get_display_label(); } public function get_header() { return $this->get_display_label(); } public function get_permalink() { global $liens_opac; return str_replace('!!id!!', $this->get_id(), $liens_opac['lien_rech_concept']); } public function get_comment() { return ''; } public function get_authoritieslist() { return skos_view_concept::get_authorities_indexed_with_concept($this); } public function format_datas($antiloop = false){ $formatted_data = array( 'id' => $this->get_id(), 'uri' => $this->get_uri(), 'permalink' => $this->get_permalink(), 'label' => $this->get_isbd(), 'note' => $this->get_note(), 'schemes' => $this->get_schemes(), 'broaders_list' => $this->get_broaders_list(), 'narrowers_list' => $this->get_narrowers_list() ); // $authority = new authority(0, $this->id, AUT_TABLE_CONCEPT); // $formatted_data = array_merge($authority->format_datas(), $formatted_data); return $formatted_data; } /** * Retourne les champs perso du concept */ public function get_p_perso() { return $this->p_perso; } /** * Retourne la note * @return string */ public function get_note() { global $lang; if (!$this->note) { $query = "select * where { <".$this->uri."> ?note }"; skos_datastore::query($query); if(skos_datastore::num_rows()){ $results = skos_datastore::get_result(); foreach($results as $key=>$result){ if($result->note_lang==substr($lang,0,2)){ $this->note = $result->note; break; } } //pas de langue de l'interface trouvée if (!$this->note){ $this->note = $result->note; } } } return $this->note; } }