num_segment = $num_segment; } parent::__construct($objects_ids); } protected function get_query() { return "SELECT * FROM facettes JOIN search_segments_facets ON search_segments_facets.num_facet = facettes.id_facette WHERE num_search_segment = ".$this->num_segment." ORDER BY search_segment_facet_order"; } public function set_num_segment($num_segment) { $this->num_segment = intval($num_segment); } public function get_num_segment() { if (isset($this->num_segment)) { return $this->num_segment; } return 0; } public function set_segment_search($segment_search) { $this->segment_search = $segment_search; } public function get_segment_search() { if (isset($this->segment_search)) { return $this->segment_search; } return ''; } protected function get_action_form() { return static::format_url("lvl=search_segment&action=segment_results&mode=".$this->mode."&facette_test=1&id=".$this->num_segment); } public function create_ajax_table_facettes(){ global $base_path; global $charset; global $mode; global $msg; global $universe_query; $this->create_search_environment(); $table = "
"; if(static::get_compare_notice_active()){ $facette_compare=$this->get_facette_search_compare(); //Le tableau des critères de comparaisons if(count($facette_compare->facette_compare)){ $table_compare=$facette_compare->gen_table_compare(); $table .= "

".htmlentities($msg['facette_list_compare_crit'],ENT_QUOTES,$charset)." ".htmlentities($msg[

".$table_compare."

"; //Le tableau des critères de comparaisons if(count($facette_compare->facette_groupby)){ $table_groupby=$facette_compare->gen_table_groupby(); } $table .= "

".htmlentities($msg['facette_list_groupby_crit'],ENT_QUOTES,$charset)."

".$table_groupby."

"; } //le bouton de retour if(isset($_SESSION['filtre_compare']) && $_SESSION['filtre_compare']=='compare'){ $table .= "

"; }elseif((!isset($_SESSION['filtre_compare']) || $_SESSION['filtre_compare']!='compare') && count($facette_compare->facette_compare)){ $table .= "

"; } } if(count($this->get_not_clicked())){ if(static::get_compare_notice_active()){ $table .= "
"; $table .= "

".htmlentities($msg['facette_list_compare'],ENT_QUOTES,$charset)."  ".htmlentities($msg[

".$this->get_display_not_clicked()."
"; }else{ $table .= "

".htmlentities($msg['facette_list'],ENT_QUOTES,$charset)."

".$this->get_display_not_clicked()."
"; } } $table .= "
"; $table.= ""; return $table; } public static function make_facette_search_env() { global $search; global $check_facette; //creation des globales => parametres de recherche $n = count($search); if (is_array($check_facette)) { $fields = []; foreach($check_facette as $facet){ if(!isset($fields[$facet[2]][$facet[3]])){ $facet[1] = array($facet[1]); $fields[$facet[2]][$facet[3]] = $facet; }else{ $fields[$facet[2]][$facet[3]][1][] = $facet[1]; } } $i = 0; foreach($fields as $field => $subfields){ foreach($subfields as $subfield){ $search[] = "s_3"; $fieldname = "field_".($i+$n)."_s_3"; global ${$fieldname}; ${$fieldname} = array($subfield); $op = "op_".($i+$n)."_s_3"; $op_ = "EQ"; global ${$op}; ${$op}=$op_; $inter = "inter_".($i+$n)."_s_3"; $inter_ = "and"; global ${$inter}; ${$inter} = $inter_; $i++; } } } } protected static function get_link_not_clicked($name, $label, $code_champ, $code_ss_champ, $id, $nb_result) { return ''; } protected static function get_ajax_see_more_url() { $url = parent::get_ajax_see_more_url(); $url .= "&action=segment_results"; return $url; } public static function get_session_values() { return null; } public static function set_session_values($session_values) { return; } protected function get_filter_button_action() { return ""; } protected function on_facet_click($link = '') { return ""; } public function call_facets($additional_content = "") { global $universe_query; global $base_path; $ajax_facettes = $additional_content; $ajax_facettes .= static::get_facette_wrapper(); $ajax_facettes .="
"; return $ajax_facettes; } protected function create_search_environment() { $search_class = new search(); $search_class->json_decode_search($this->get_segment_search()); } public function get_clicked() { if(!isset($this->clicked)) { global $search; $this->clicked = array(); //on reconstruit la session des facettes pour que l'affichage fonctionne comme avant if (is_array($search) && count($search)) { foreach ($search as $i => $value) { if ($value == 's_3') { $field = "field_".$i."_s_3"; global ${$field}; if (!empty(${$field})) { $this->clicked[] = ${$field}; } } } } } return $this->clicked; } protected function get_query_by_facette($id_critere, $id_ss_critere, $type = "notices") { global $lang; if($type == 'notices'){ $plural_prefix = 'notices'; $prefix = 'notice'; }else{ $plural_prefix = 'authorities'; $prefix = 'authority'; } $query = 'select value ,count(distinct id_'.$prefix.') as nb_result from (SELECT value,id_'.$prefix.' FROM '.$plural_prefix.'_fields_global_index'. gen_where_in($plural_prefix.'_fields_global_index.id_'.$prefix, $this->objects_ids).' AND code_champ = '.(intval($id_critere)).' AND code_ss_champ = '.(intval($id_ss_critere)).' AND lang in ("","'.$lang.'","'.substr($lang,0,2).'")) as sub GROUP BY value ORDER BY '; return $query; } public function get_ajax_facette() { $facettes_exists_with_or_without_results = false; if($this->exists_with_results || count($this->get_clicked())){ $facettes_exists_with_or_without_results = true; } return array( 'exists_with_results' => ($_SESSION["cms_build_activate"] ? true : $facettes_exists_with_or_without_results), 'display' => $this->create_ajax_table_facettes(), 'map_location' => $this->get_map_location() ); } public static function get_instance($objects_ids = "", $num_segment = 0) { $num_segment = intval($num_segment); if ($num_segment) { $query = "SELECT search_segment_type FROM search_segments WHERE id_search_segment = $num_segment"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_array($result); if ($row[0] == TYPE_EXTERNAL) { return new search_segment_external_facets($objects_ids, $num_segment); } } } return new search_segment_facets($objects_ids, $num_segment); } }