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;
}
}
if (!isset($width))
$width = "500";
if (!isset($height))
$height = "500";
$form="
";
return $form;
}
public function make_serialized_source_properties($source_id) {
global $width,$height;
$t["width"] = (int) $width;
$t["height"] = (int) $height;
$this->sources[$source_id]["PARAMETERS"]=serialize($t);
}
public 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();
$keys['accesskey']=$accesskey;
$keys['secretkey']=$secretkey;
$this->parameters = serialize($keys);
}
public function enrichment_is_allow(){
return true;
}
public function getEnrichmentHeader(){
global $lang;
$header= array();
$header[]= "";
$header[]= "";
$header[]= "";
return $header;
}
public function getTypeOfEnrichment($source_id){
$type['type'] = array(
"books"
);
$type['source_id'] = $source_id;
return $type;
}
public function getEnrichment($notice_id,$source_id,$type="",$enrich_params=array(),$page=1){
$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();
//on renvoi ce qui est demandé... si on demande rien, on renvoi tout..
switch ($type){
case "books" :
default :
$rqt="select code from notices where notice_id = '$notice_id'";
$res=pmb_mysql_query($rqt);
if(pmb_mysql_num_rows($res)){
$code = pmb_mysql_result($res,0,0);
$code = preg_replace('/-|\.| /', '', $code);
if($code && $this->checkIfEmbeddable($code)){
$enrichment['books']['content'] = "
";
$enrichment['books']['callback'] = "
var viewer = new google.books.DefaultViewer(document.getElementById('gbook$notice_id'));
viewer.load('ISBN:$code');";
}else{
$enrichment['books']['content'] = "".$this->msg["gbook_no_preview"]."";
}
}
break;
}
$enrichment['source_label']=$this->msg['gbooks_enrichment_source'];
return $enrichment;
}
public function checkIfEmbeddable($isbn){
$identifiers = array();
$curl = new Curl();
$xmlToParse = $curl->get("http://www.google.com/books/feeds/volumes?q=ISBN".$isbn);
$xml = _parser_text_no_function_($xmlToParse,"FEED");
if($xml['ENTRY'][0]){
//on regarde quand meme si on est le bon livre...
foreach($xml['ENTRY'][0]['DC:IDENTIFIER'] as $identifier){
if(substr($identifier['value'],0,4) == "ISBN"){
$identifiers[]=substr($identifier['value'],5);
}
}
//si le feuillatage est disponible...
if(in_array($isbn,$identifiers) && substr($xml['ENTRY'][0]['GBS:EMBEDDABILITY'][0]['VALUE'],strpos($xml['ENTRY'][0]['GBS:EMBEDDABILITY'][0]['VALUE'],"#")+1) == "embeddable"){
return true;
}else return false;
}
}
}
?>