fetch_sources(); $this->fetch_data(); } //On récupère la liste des sources dispos pour enrichir public function fetch_sources(){ global $base_path, $msg; $this->parseType(); $connectors = connecteurs::get_instance(); $this->catalog = $connectors->catalog; foreach ($this->catalog as $id=>$prop) { $comment=$prop['COMMENT']; //Recherche du nombre de sources $n_sources=0; if($prop['ENRICHMENT'] == "yes"){ if (is_file($base_path."/admin/connecteurs/in/".$prop['PATH']."/".$prop['NAME'].".class.php")) { require_once($base_path."/admin/connecteurs/in/".$prop['PATH']."/".$prop['NAME'].".class.php"); eval("\$conn=new ".$prop['NAME']."(\"".$base_path."/admin/connecteurs/in/".$prop['PATH']."\");"); $conn->get_sources(); foreach($conn->sources as $source_id=>$s) { if($s['ENRICHMENT'] == 1){ $enrichment_types = array(); $info = $conn->getTypeOfEnrichment($source_id); for($i=0 ; $i $info['type'][$i], 'label' => $msg[substr($this->types_names[$info['type'][$i]],4)] ); }elseif(!$info['type'][$i]['label']){ $info['type'][$i]['label'] = $msg[substr($this->types_names[$info['type'][$i]],4)]; } if (!empty($s['TYPE_ENRICHEMENT_ALLOWED'])) { $enrichment_types[] = $info['type'][$i]; } } $this->enhancer[] = array( 'id' =>$s['SOURCE_ID'], 'name' =>$s['NAME'], 'enrichment_types' => $enrichment_types ); } } } } } } //Récupération des données existantes public function fetch_data(){ $rqt = "select * from sources_enrichment"; $res = pmb_mysql_query($rqt); if(pmb_mysql_num_rows($res)){ while($r= pmb_mysql_fetch_object($res)){ $this->active[$r->source_enrichment_typnotice.$r->source_enrichment_typdoc][] = $r->source_enrichment_num; $this->params[$r->source_enrichment_typnotice.$r->source_enrichment_typdoc][$r->source_enrichment_num] = unserialize($r->source_enrichment_params); } } } //Affichage du formulaire public function show_form(){ global $msg; if(count($this->enhancer)){ //création du sélecteur... $select=""; if ($default_value) $selector .=" "; foreach($this->enhancer as $source){ $selector.=" "; } $selector.=""; $selector .= "

".$msg['admin_connecteurs_enrichment_default_display']."

"; $selector .= "
"; return $selector; } protected function generateSelectorScript() { global $msg, $charset; $script = ""; return $script; } private function get_sorted_enrichments($type) { $sorted_enrichments = array(); foreach ($this->enhancer as $source) { if (isset($this->active[$type]) && in_array($source['id'],$this->active[$type])) { foreach ($source['enrichment_types'] as $enrichment_type) { $order = (isset($this->params[$type][$source['id']][$enrichment_type['code']]['order']) ? $this->params[$type][$source['id']][$enrichment_type['code']]['order'] : 0); $sorted_enrichments[$order] = array( 'source' => $source['id'], 'code' => $enrichment_type['code'], 'label' => $enrichment_type['label'] ); } } } ksort($sorted_enrichments); return $sorted_enrichments; } //retourne les éléments à rajouter dans le head, les calculs aux besoins; public function getHeaders(){ if(!$this->enrichmentsTabHeaders) $this->generateHeaders(); return implode("\n",$this->enrichmentsTabHeaders); } //Méthode qui génère les éléments à insérer dans le header pour le bon fonctionnement des enrichissements public function generateHeaders(){ global $base_path; $this->enrichmentsTabHeaders =array(); $alreadyIncluded = array(); foreach($this->active as $type => $sources){ foreach($sources as $source_id){ if(!in_array($source_id,$alreadyIncluded)){ //on récupère les infos de la source nécessaires pour l'instancier $name = connecteurs::get_class_name($source_id); foreach($this->catalog as $connector){ if($connector['NAME'] == $name){ if (is_file($base_path."/admin/connecteurs/in/".$connector['PATH']."/".$name.".class.php")){ require_once($base_path."/admin/connecteurs/in/".$connector['PATH']."/".$name.".class.php"); $conn = new $name($base_path."/admin/connecteurs/in/".$connector['PATH']); $this->enrichmentsTabHeaders = array_merge($this->enrichmentsTabHeaders,$conn->getEnrichmentHeader()); $this->enrichmentsTabHeaders = array_unique($this->enrichmentsTabHeaders); } } } $alreadyIncluded[]=$source_id; } } } } public function getEnrichment($notice_id,$tnoti,$tdoc){ global $base_path; $infos = array(); if($this->active[$tnoti.$tdoc]) $type = $tnoti.$tdoc; else $type = $tnoti; if(isset($this->active[$type])){ foreach($this->active[$type] as $source_id){ //on récupère les infos de la source nécessaires pour l'instancier $name = connecteurs::get_class_name($source_id); foreach($this->catalog as $connector){ if($connector['NAME'] == $name){ if (is_file($base_path."/admin/connecteurs/in/".$connector['PATH']."/".$name.".class.php")){ require_once($base_path."/admin/connecteurs/in/".$connector['PATH']."/".$name.".class.php"); $conn = new $name($base_path."/admin/connecteurs/in/".$connector['PATH']); $infos[] = $conn->getEnrichment($notice_id); } } } } } return $infos; } protected function parseType(){ global $include_path,$lang; $file = $include_path."/enrichment/categories.xml"; $xml = file_get_contents($file); $types= _parser_text_no_function_($xml,"XMLLIST"); foreach($types['ENTRY'] as $type){ $this->types_names[$type['CODE']] = $type['value']; } } } ?>