/** * Retourne les concepts composés qui utilisent un élément * @param int $element_id Identifiant de l'élément * @param string $element_type Type de l'élément (Disponible dans vedette.xml) * @return skos_concept Tableau de concepts composés */ public function set_composed_concepts_built_with_element($element_id, $element_type) { // On va chercher les vedettes construites avec l'élément $vedettes_ids = vedette_composee::get_vedettes_built_with_element($element_id, $element_type); foreach ($vedettes_ids as $vedette_id) { // On va chercher les concepts correspondant à chaque vedette if ($concept_id = vedette_composee::get_object_id_from_vedette_id($vedette_id, TYPE_CONCEPT_PREFLABEL)) { $this->concepts[] = new skos_concept($concept_id); } } if (!count($this->concepts)) { return false; } return true; }
/** * Renvoie le tableau des identifiants de concepts composés utilisant cette autorité * @return array */ public function get_concepts_ids() { if (!isset($this->concepts_ids)) { $this->concepts_ids = array(); $vedette_composee_found = vedette_composee::get_vedettes_built_with_element($this->get_num_object(), $this->get_string_type_object()); foreach ($vedette_composee_found as $vedette_id) { $this->concepts_ids[] = vedette_composee::get_object_id_from_vedette_id($vedette_id, TYPE_CONCEPT_PREFLABEL); } } return $this->concepts_ids; }
/** * Méthode permettant de récupérer les autorités indexées avec un concept utilisant cette autorité * @return authority_tab Onglet */ protected function get_tab_authorities_indexed_with_concept() { global $dbh, $msg; $tab = new elements_list_tab('records_authorities_indexed', $msg['record_tabs_authorities_indexed'], 'authorities'); $types_needed = array(TYPE_AUTHOR, TYPE_CATEGORY, TYPE_PUBLISHER, TYPE_COLLECTION, TYPE_SUBCOLLECTION, TYPE_SERIE, TYPE_TITRE_UNIFORME, TYPE_INDEXINT, TYPE_AUTHPERSO); $vedette_composee_found = vedette_composee::get_vedettes_built_with_element($this->record->id, 'records'); if (count($vedette_composee_found)) { foreach ($vedette_composee_found as $vedette_id) { $concept_ids[] = vedette_composee::get_object_id_from_vedette_id($vedette_id, TYPE_CONCEPT_PREFLABEL); } $query = 'select count(distinct num_object, type_object) from index_concept where num_concept in (' . implode(',', $concept_ids) . ') and type_object in (' . implode(',', $types_needed) . ')'; $nb_results = pmb_mysql_result(pmb_mysql_query($query, $dbh), 0, 0); $tab->set_nb_results($nb_results); if (!$quoi && $nb_results) { // Si $quoi n'est pas valorisé et qu'on a des résultats, on valorise $quoi avec cet onglet $quoi = $tab->get_name(); } if ($nb_results && $quoi == $tab->get_name()) { // On définit les filtres $filter = array('name' => 'records_authorities_indexed_by_types', 'label' => $msg['authority_tabs_common_indexed_authorities_by_types']); $tab->set_filters(array($filter)); $groups = array(); $query = 'select count(distinct num_object) as nb, type_object, id_authperso, authperso_name from index_concept left join authperso_authorities on num_object = id_authperso_authority and type_object = ' . TYPE_AUTHPERSO . ' left join authperso on id_authperso = authperso_authority_authperso_num where num_concept in (' . implode(',', $concept_ids) . ') and type_object in (' . implode(',', $types_needed) . ') group by type_object, id_authperso'; $result = pmb_mysql_query($query, $dbh); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { if ($row->type_object == TYPE_AUTHPERSO && !isset($groups[1000 + $row->id_authperso])) { $groups[1000 + $row->id_authperso] = array('label' => $row->authperso_name, 'nb_results' => $row->nb); } else { if (!isset($groups[$row->type_object])) { $groups[$row->type_object] = array('label' => authority::get_type_label_from_type_id(index_concept::get_aut_table_type_from_type($row->type_object)), 'nb_results' => $row->nb); } } $nb_results += $row->nb; } } if (count($groups)) { // On trie le tableau uasort($groups, array($this, '_sort_groups_by_label')); $tab->add_groups($filter['name'], array('label' => $filter['label'], 'elements' => $groups)); $filter_values = $tab->get_filter_values($filter['name']); $authpersos_needed = array(); if ($filter_values && count($filter_values)) { $types_needed = array(); foreach ($filter_values as $value) { if ($value > 1000) { if (!in_array(TYPE_AUTHPERSO, $types_needed)) { $types_needed[] = TYPE_AUTHPERSO; } $authpersos_needed[] = $value - 1000; } else { $types_needed[] = $value; } } } $query = 'select SQL_CALC_FOUND_ROWS num_object, type_object, authperso_authority_authperso_num'; $query .= ' from index_concept left join authperso_authorities on num_object = id_authperso_authority and type_object = ' . TYPE_AUTHPERSO; $query .= ' where num_concept in (' . implode(',', $concept_ids) . ') and type_object in (' . implode(',', $types_needed) . ')'; // si on a des filtres sur des authorités persos if (count($authpersos_needed)) { $query .= ' and (authperso_authority_authperso_num is null or authperso_authority_authperso_num in (' . implode(',', $authpersos_needed) . '))'; } $query .= $this->get_authorities_sort(); $query .= $this->get_limit(); // on lance la requête $result = pmb_mysql_query($query, $dbh); $records_ids = array(); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { $authority = new authority(0, $row->num_object, index_concept::get_aut_table_type_from_type($row->type_object)); $records_ids[] = $authority->get_id(); } } $nb_filtered_results = pmb_mysql_result(pmb_mysql_query('select FOUND_ROWS()'), 0, 0); $tab->set_nb_filtered_results($nb_filtered_results); $tab->set_contents($records_ids); } } } return $tab; }