fields_list =array( * array( * 'field'=>1, * 'subfields' => array( * 2,3 * ) * ) * @var array * @access protected */ protected $fields_list = array( array( 'field'=>1, 'subfields'=>array(0), ), array( 'field'=>14, 'subfields'=>array(0), ) ); public function __construct() { $this->collection = new autoindex_documents_collection($this->fields_list); } /** * fonction de test */ public function test($raw_text='', $lang='fr_FR', $id_thesaurus=0) { $this->raw_text=$raw_text; $this->lang=$lang; $this->id_thesaurus=$id_thesaurus; } public function process() { $this->get_raw_text(); $this->get_lang(); $this->get_thesaurus(); $this->find_revelants_words(); $this->get_relevants_terms(); $this->calc_total_terms_relevancy(); $this->calc_document_terms_distances(); $this->sort_terms(); } /** * Récupère le contenu des champs de la notice à indexer * * @global autoindex * json array( * array ( * [name]=nom de la zone, * [field]=nom du champ dans le formulaire, * [pond]=ponderation, * [value]=contenu de la zone * ) * ) * * @return array(string) * @access public */ public function get_raw_text() { global $autoindex_txt,$charset; $this->raw_text = json_decode(stripslashes($autoindex_txt),true); if(is_array($this->raw_text) && count($this->raw_text)) { foreach($this->raw_text as $k=>$v) { if(!is_null($v['value']) && $v['value']!=='') { $this->raw_text[$k]['value']=rawurldecode($v['value']); if($charset!='utf-8') { $this->raw_text[$k]['value'] = utf8_decode($this->raw_text[$k]['value']); } } else { unset($this->raw_text[$k]); } } } //TODO // echo "Eléments postés =
"; // print $autoindex_txt."
"; // highlight_string(print_r($this->raw_text,true)); // echo "
"; return $this->raw_text; } /** * Récupère la langue de l'interface * * @return string * @access public */ public function get_lang() { global $user_lang, $lang; if(!$user_lang){ $user_lang=$lang; } if(!$user_lang) { $user_lang="fr_FR"; } $this->lang=$user_lang; //TODO // echo "Langue de la notice = ".$user_lang."
"; // echo "Langue utilisateur = ".$lang."
"; // echo "Langue indexation = ".$this->lang."
"; // echo "
"; return $this->lang; } /** * Récupère l'identifiant du thésaurus à utiliser pour la recherche de termes. * * @return integer * @access public */ public function get_thesaurus() { global $id_thes; $this->id_thesaurus=$id_thes; if($this->id_thesaurus < 0 ) { $this->id_thesaurus=0; } return $id_thes; } public function get_form() { global $charset; global $msg; global $caller,$thesaurus_auto_index_notice_fields,$lang,$include_path,$search_type,$user_lang; global $htmlfieldstype; if(!$htmlfieldstype) { $htmlfieldstype="html"; } $tpl_index_auto=""; if ($caller=='notice' && $thesaurus_auto_index_notice_fields) { $fields=explode(';',$thesaurus_auto_index_notice_fields); $notice_fields=new notice_doublon(); $tpl_field = array(); $tpl_selector_field=''; $j=0; $i=0; foreach($fields as $k=>$field){ $pos = stripos($field,'='); if($pos!==false) { $field_name = trim(substr($field,0,$pos)); $field_pond = trim(substr($field,$pos+1)); $field_pond = (float) str_replace(',','.',$field_pond); if($field_pond > 1 && $field_pond <=100) { $field_pond = $field_pond / 100; $field_pond = round($field_pond,2); } } else { $field_name = trim($field); $field_pond = 1; } if ($field_name) { if($notice_fields->fields[$field_name][$htmlfieldstype]){ $tpl_field[$i]['name'] = $field_name; $tpl_field[$i]['field'] = $notice_fields->fields[$field_name][$htmlfieldstype]; $tpl_field[$i]['pond'] = $field_pond; if($field_name=="tit1"){ // cas du formulaire de bulletin ou le titre = bul_titre au lieu de tit1 $i++; $tpl_field[$i]['name'] = $field_name; $tpl_field[$i]['field'] = 'bul_titre'; $tpl_field[$i]['pond'] = $field_pond; } }else{ // champ perso $tpl_field[$i]['name'] = $field_name; $tpl_field[$i]['field'] = $field_name; $tpl_field[$i]['pond'] = $field_pond; } $checked = ''; if( ($search_type!='autoindex') || (isset($_POST['chk_'.$tpl_field[$i]['name']])) ) { $checked="checked='checked'"; } if($j%3==0) { $tpl_selector_field.= ''; } $tpl_selector_field.= ""; $j++; $i++; } } while($j%3) { $tpl_selector_field.=""; $j++; } $tpl_selector_field.='
 "; $tpl_selector_field.= "
'; $langues = new XMLlist("$include_path/messages/languages.xml"); $langues->analyser(); $clang = $langues->table; $display=''; if($search_type!='autoindex') { $display="style='display:none'"; } $combo = "
".$msg["autoindex_selector_lang"]. "
"; $combo.= "
$tpl_selector_field
"; $combo.= ""; $combo.= "
"; $tpl_index_auto="    ".$msg["autoindex_selector_search"]." 
$combo "; } return $tpl_index_auto; } function index_list(){ global $charset,$base_path,$base_url; global $categ_browser_autoindex; global $thesaurus_mode_pmb; global $include_path,$caller; global $msg; $this->process(); $categ_list=$this->terms; $browser_content="

".$msg["autoindex_selector_title"]."

"; foreach($this->terms as $categ_obj){ if($categ_obj->see)$categ_id=$categ_obj->see; else $categ_id=$categ_obj->id; $tcateg = new category($categ_id); $browser_content .= ""; if($id_thes == -1 && $thesaurus_mode_pmb){ $display = '['.htmlentities($tcateg->thes->libelle_thesaurus,ENT_QUOTES, $charset).']'; } else { $display = ''; } if($tcateg->voir_id) { $tcateg_voir = new category($tcateg->voir_id); $display .= "$tcateg->libelle ->".$tcateg_voir->catalog_form."@"; $id_=$tcateg->voir_id; if($libelle_partiel){ $libelle_=$tcateg_voir->libelle; }else{ $libelle_=$tcateg_voir->catalog_form; } } else { $id_=$tcateg->id; if($libelle_partiel){ $libelle_=$tcateg->libelle; }else{ $libelle_=$tcateg->catalog_form; } $display .= $tcateg->libelle; } if($tcateg->has_child) { //$browser_content .= "";//On mets le bon identifiant de thésaurus $browser_content .= ""; } else { $browser_content .= ""; } if ($tcateg->commentaire) { $zoom_comment = "" ; $java_comment = " onmouseover=\"z=document.getElementById('zoom_comment".$tcateg->id."'); z.style.display=''; \" onmouseout=\"z=document.getElementById('zoom_comment".$tcateg->id."'); z.style.display='none'; \"" ; } else { $zoom_comment = "" ; $java_comment = "" ; } if ($thesaurus_mode_pmb ) $nom_tesaurus='['.$tcateg->thes->getLibelle().'] ' ; else $nom_tesaurus='' ; $browser_content .= "thes->id_thesaurus."')\">"; $browser_content .= $display; $browser_content .= "$zoom_comment\n"; $browser_content .= ""; if($tpl_insert_all_index){ $tpl_insert_all_index.=","; $tpl_insert_all_index_name.=","; } $tpl_insert_all_index.=$id_; $tpl_insert_all_index_name.="'".htmlentities(addslashes($nom_tesaurus.$libelle_),ENT_QUOTES, $charset)."'"; } $categ_browser_autoindex = str_replace('!!browser_content!!', $browser_content, $categ_browser_autoindex); $categ_browser_autoindex = str_replace('!!base_url!!', $base_url, $categ_browser_autoindex); if(count($this->terms)) $categ_browser_autoindex.=" "; return $categ_browser_autoindex; } }