Esempio n. 1
0
 /**
  * Retourn la classe d'affichage des éléments des onglets
  * @return elements_list_ui
  */
 public function get_authority_list_ui()
 {
     global $quoi;
     if (!$this->authority_list_ui) {
         $tab = null;
         foreach ($this->authority_tabs->get_tabs() as $current_tab) {
             if (!$tab && $current_tab->get_nb_results()) {
                 $tab = $current_tab;
             }
             if ($current_tab->get_name() == $quoi && $current_tab->get_nb_results()) {
                 $tab = $current_tab;
                 break;
             }
         }
         if ($tab) {
             $quoi = $tab->get_name();
             switch ($tab->get_content_type()) {
                 case 'records':
                     $this->authority_list_ui = new elements_records_list_ui($tab->get_contents(), $tab->get_nb_results(), $tab->is_mixed(), $tab->get_groups(), $tab->get_nb_filtered_results());
                     break;
                 case 'authorities':
                     $this->authority_list_ui = new elements_authorities_list_ui($tab->get_contents(), $tab->get_nb_results(), $tab->is_mixed(), $tab->get_groups(), $tab->get_nb_filtered_results());
                     break;
             }
         }
     }
     return $this->authority_list_ui;
 }
 /**
  * Méthode permettant de récupérer les autorités indexées avec un concept utilisant cette autorité
  * @param elements_list_tab $tab
  * @param authority_tabs $authority_tabs
  * @return authority_tab Onglet
  */
 protected static function get_tab_authorities_indexed_with_concept($tab, $authority)
 {
     global $dbh, $msg;
     $types_needed = array(TYPE_AUTHOR, TYPE_CATEGORY, TYPE_PUBLISHER, TYPE_COLLECTION, TYPE_SUBCOLLECTION, TYPE_SERIE, TYPE_TITRE_UNIFORME, TYPE_INDEXINT, TYPE_AUTHPERSO);
     $concepts_ids = $authority->get_concepts_ids();
     $nb_result = 0;
     if (count($concepts_ids)) {
         $query = 'select count(distinct num_object, type_object) from index_concept where num_concept in (' . implode(',', $concepts_ids) . ') and type_object in (' . implode(',', $types_needed) . ')';
         $nb_result = pmb_mysql_result(pmb_mysql_query($query, $dbh), 0, 0);
     }
     $tab->set_nb_results($nb_result);
     if (!$quoi && $nb_result) {
         // 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_result && $quoi == $tab->get_name()) {
         // On définit les filtres
         $filter = array('name' => 'common_indexed_authorities_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(',', $concepts_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);
                     }
                 }
             }
         }
         if (count($groups)) {
             // On trie le tableau
             uasort($groups, array('authority_tabs', '_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(',', $concepts_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 .= authority_tabs::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);
         }
     }
 }
 /**
  * Constructeur
  * @param authority $authority
  */
 public function __construct($authority)
 {
     parent::__construct($authority);
 }