get_source_params($source_id);
if ($params["PARAMETERS"]) {
$vars=unserialize($params["PARAMETERS"]);
$params["PARAMETERS"]=$vars;
}
return $params;
}
function get_libelle($message) {
if (substr($message,0,4)=="msg:") return $this->msg[substr($message,4)]; else return $message;
}
function source_get_property_form($source_id) {
return "";
}
function make_serialized_source_properties($source_id) {
$this->sources[$source_id]["PARAMETERS"]=serialize(array());
}
//Récupération des proriétés globales par défaut du connecteur (timeout, retry, repository, parameters)
function fetch_default_global_values() {
$this->timeout=5;
$this->repository=2;
$this->retry=3;
$this->ttl=1800;
$this->parameters="";
}
//Formulaire des propriétés générales
function get_property_form() {
return "";
}
function make_serialized_properties() {
global $accesskey, $secretkey;
//Mise en forme des paramètres à partir de variables globales (mettre le résultat dans $this->parameters)
$keys = array();
$this->parameters = serialize($keys);
}
function enrichment_is_allow(){
return true;
}
function getEnrichmentHeader(){
$header= array();
$header[]= "";
return $header;
}
function getTypeOfEnrichment($source_id){
$type['type'] = array(
array(
'code' => "youtube",
'label' => $this->msg['youtube']
)
);
$type['source_id'] = $source_id;
return $type;
}
function getEnrichment($notice_id,$source_id,$type="",$enrich_params=array(),$page=1){
global $lang;
$this->noticeToEnrich= $notice_id;
$params=$this->get_source_params($source_id);
if ($params["PARAMETERS"]) {
//Affichage du formulaire avec $params["PARAMETERS"]
$vars=unserialize($params["PARAMETERS"]);
foreach ($vars as $key=>$val) {
global $$key;
$$key=$val;
}
}
$enrichment= array();
$infos = $this->get_notice_infos();
//on renvoi ce qui est demandé... si on demande rien, on renvoi tout..
switch ($type){
case "youtube" :
$api = new youtube_api();
$vars = array(
"q" => utf8_encode($infos['title']." ".$infos['author'])
);
$result = $api->search_videos($vars);
if($result->feed->{'openSearch$totalResults'}->{'$t'} >= $result->feed->{'openSearch$itemsPerPage'}->{'$t'}){
$aff_result = sprintf($this->msg['youtube_partial_results'],$result->feed->{'openSearch$itemsPerPage'}->{'$t'},$result->feed->{'openSearch$totalResults'}->{'$t'});
$aff_result.= "
".$this->msg['youtube_go_to_result_page']."";
}else{
$aff_result = sprintf($this->msg['youtube_all_results'],$result->feed->{'openSearch$totalResults'}->{'$t'});
}
$enrichment['youtube']['content']= "
".$aff_result."
"; foreach($result->feed->entry as $elem){ $enrichment['youtube']['content'].= " "; if(!$elem->{'yt$noembed'}){ $enrichment['youtube']['content'].= " "; }else{ $enrichment['youtube']['content'].= " {'media$player'}[0]->url."'>{'media$thumbnail'}[0]->url."'/>"; } $enrichment['youtube']['content'].= " "; } break; } $enrichment['source_label']=$this->msg['youtube_enrichment_source']; return $enrichment; } function get_notice_infos(){ $infos = array(); //on va chercher le titre de la notice... $query = "select tit1 from notices where notice_id = ".$this->noticeToEnrich; $result = mysql_query($query); if(mysql_num_rows($result)){ $infos['title'] = mysql_result($result,0,0); } //on va chercher l'auteur principal... $query = "select responsability_author from responsability where responsability_notice =".$this->noticeToEnrich." and responsability_type=0"; $result = mysql_query($query); if(mysql_num_rows($result)){ $author_id = mysql_result($result,0,0); $author = new auteur($author_id); $infos['author'] = $author->isbd_entry; } return $infos; } } ?>