1) {
foreach ($field['TABLE'][0]['TABLEFIELD'] as $tablefield) {
if($tablefield['ID']+0 == $id_ss_critere) {
$unimarcFields = explode(',', $tablefield['UNIMARCFIELD']);
}
}
} else {
$unimarcFields = explode(',', $field['TABLE'][0]['TABLEFIELD'][0]['UNIMARCFIELD']);
}
break;
}
}
}
$sub_query_values = '';
if(is_array($values) && count($values)) {
$sub_query_values .= ' AND (';
foreach ($values as $i=>$value) {
if ($i) {
$sub_query_values .= ' OR ';
}
$sub_query_values .= 'value ="'.addslashes($value).'"';
}
$sub_query_values .= ') ';
}
$sub_queries = array();
foreach ($unimarcFields as $unimarcField) {
$ufield = explode('$', $unimarcField);
if($ufield[1]) {
$sub_queries[] = "ufield = '".$ufield[0]."' AND usubfield = '".$ufield[1]."'".$sub_query_values;
} else {
$sub_queries[] = "ufield = '".$ufield[0]."'".$sub_query_values;
}
}
return $sub_queries;
}
protected function get_query_by_facette($id_critere, $id_ss_critere) {
$sub_queries = static::get_sub_queries($id_critere, $id_ss_critere);
$selected_sources = static::get_selected_sources();
$queries = array();
foreach ($selected_sources as $source) {
$queries [] = "SELECT value,recid FROM entrepot_source_".$source."
WHERE recid IN (".$this->objects_ids.")
AND ((".implode(') OR (', $sub_queries)."))";
}
$query = "select value ,count(distinct recid) as nb_result from ("
.implode(' UNION ', $queries).") as sub
GROUP BY value
ORDER BY";
return $query;
}
public static function get_facette_wrapper(){
$script = parent::get_facette_wrapper();
$script .= "
";
return $script;
}
public static function make_facette_search_env() {
global $search;
//Destruction des globales avant reconstruction
static::destroy_global_env(false); // false = sans destruction de la variable de session
//creation des globales => parametres de recherche
if(empty($search)) {
$search = array();
}
$nb_search = count($search);
if ($_SESSION['facettes_external']) {
for ($i=0;$i=0; $i--) {
if($search[$i] == 's_5') {
static::destroy_global_search_element($i);
}
}
if($with_session) unset($_SESSION['facettes_external']);
}
protected static function get_link_delete_clicked($indice, $facettes_nb_applied) {
$id += 0;
if ($facettes_nb_applied==1) {
$link = "facettes_external_reinit();";
} else {
$link = "facettes_external_delete_facette(".$indice.");";
}
return $link;
}
protected static function get_link_not_clicked($name, $label, $code_champ, $code_ss_champ, $id, $nb_result) {
$datas = array($name, $label, $code_champ, $code_ss_champ, $id, $nb_result);
$link = "facettes_external_valid_facette(".encoding_normalize::json_encode($datas).");";
return $link;
}
protected static function get_link_reinit_facettes() {
$link = "facettes_external_reinit();";
return $link;
}
protected static function get_link_back($reinit_compare=false) {
global $base_path;
if($reinit_compare) {
$link = "facettes_external_reinit_compare();";
} else {
$link = "document.search_form.submit();";
}
return $link;
}
public static function get_session_values() {
if(!isset($_SESSION['facettes_external'])) {
$_SESSION['facettes_external'] = '';
}
return $_SESSION['facettes_external'];
}
public static function set_session_values($session_values) {
$_SESSION['facettes_external'] = $session_values;
}
public static function delete_session_value($param_delete_facette) {
global $search;
if(isset($_SESSION['facettes_external'][$param_delete_facette])){
$unset_indice = false;
$facette_indice = 0;
foreach ($search as $key=>$value) {
if($value == 's_5') {
if($param_delete_facette == $facette_indice) {
$unset_indice = $key;
}
$facette_indice++;
}
}
if($unset_indice !== false) {
static::destroy_global_search_element($unset_indice);
}
unset($_SESSION['facettes_external'][$param_delete_facette]);
$_SESSION['facettes_external'] = array_values($_SESSION['facettes_external']);
}
}
public static function get_filter_query_by_facette($id_critere, $id_ss_critere, $values) {
$sub_queries = static::get_sub_queries($id_critere, $id_ss_critere, $values);
$queries = array();
if(is_array($_SESSION["checked_sources"])) {
foreach ($_SESSION["checked_sources"] as $source) {
$queries [] = "SELECT recid FROM entrepot_source_".$source."
WHERE ((".implode(') OR (', $sub_queries)."))";
}
}
$query = "select distinct recid as id_notice from ("
.implode(' UNION ', $queries).") as sub";
return $query;
}
public function get_facette_search_compare() {
if(!isset($this->facette_search_compare)) {
$this->facette_search_compare = new facettes_external_search_compare();
}
return $this->facette_search_compare;
}
public static function get_selected_sources() {
$selected_sources = array();
if(is_array($_SESSION["checked_sources"])) {
$selected_sources = $_SESSION["checked_sources"];
}
return $selected_sources;
}
public static function get_formatted_value($id_critere, $id_ss_critere, $value) {
$id_critere += 0;
$id_ss_critere += 0;
$fields = static::$fields['notices_externes']['FIELD'];
if(is_array($fields)) {
foreach ($fields as $field) {
if($field['ID'] == $id_critere) {
if($field['DATATYPE'] == 'marclist') {
$marctype = $field['TABLE'][0]['TABLEFIELD'][$id_ss_critere]['MARCTYPE'];
if($marctype) {
if(!isset(self::$marclist_instance[$marctype])) {
self::$marclist_instance[$marctype] = new marc_list($marctype);
}
$value = self::$marclist_instance[$marctype]->table[$value];
}
}
break;
}
}
}
return get_msg_to_display($value);
}
}// end class