1 | <?php |
---|
2 | // +-------------------------------------------------+ |
---|
3 | // � 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) |
---|
4 | // +-------------------------------------------------+ |
---|
5 | // $Id: artevod.class.php,v 1.4.2.1 2015-09-15 14:32:56 apetithomme Exp $ |
---|
6 | |
---|
7 | if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access"); |
---|
8 | |
---|
9 | global $class_path,$base_path, $include_path; |
---|
10 | require_once($class_path."/connecteurs.class.php"); |
---|
11 | require_once("$class_path/curl.class.php"); |
---|
12 | if (version_compare(PHP_VERSION,'5','>=') && extension_loaded('xsl')) { |
---|
13 | if (substr(phpversion(), 0, 1) == "5") @ini_set("zend.ze1_compatibility_mode", "0"); |
---|
14 | require_once($include_path.'/xslt-php4-to-php5.inc.php'); |
---|
15 | } |
---|
16 | |
---|
17 | class artevod extends connector { |
---|
18 | //Variables internes pour la progression de la récupération des notices |
---|
19 | var $callback_progress; //Nom de la fonction de callback progression passée par l'appellant |
---|
20 | var $source_id; //Numéro de la source en cours de synchro |
---|
21 | var $n_recu; //Nombre de notices reçues |
---|
22 | var $xslt_transform; //Feuille xslt transmise |
---|
23 | var $del_old; //Supression ou non des notices dejà existantes |
---|
24 | |
---|
25 | //Résultat de la synchro |
---|
26 | var $error; //Y-a-t-il eu une erreur |
---|
27 | var $error_message; //Si oui, message correspondant |
---|
28 | |
---|
29 | protected $default_enrichment_template; // Template par défaut de l'enrichissement |
---|
30 | |
---|
31 | function artevod($connector_path="") { |
---|
32 | parent::connector($connector_path); |
---|
33 | $xml=file_get_contents($connector_path."/profil.xml"); |
---|
34 | $this->profile=_parser_text_no_function_($xml,"ARTEVODCONFIG"); |
---|
35 | $this->set_default_enrichment_template(); |
---|
36 | } |
---|
37 | |
---|
38 | function get_id() { |
---|
39 | return "artevod"; |
---|
40 | } |
---|
41 | |
---|
42 | //Est-ce un entrepot ? |
---|
43 | function is_repository() { |
---|
44 | return 1; |
---|
45 | } |
---|
46 | |
---|
47 | function unserialize_source_params($source_id) { |
---|
48 | $params=$this->get_source_params($source_id); |
---|
49 | if ($params["PARAMETERS"]) { |
---|
50 | $vars=unserialize($params["PARAMETERS"]); |
---|
51 | $params["PARAMETERS"]=$vars; |
---|
52 | } |
---|
53 | return $params; |
---|
54 | } |
---|
55 | |
---|
56 | function get_libelle($message) { |
---|
57 | if (substr($message,0,4)=="msg:") return $this->msg[substr($message,4)]; else return $message; |
---|
58 | } |
---|
59 | |
---|
60 | function source_get_property_form($source_id) { |
---|
61 | global $charset, $dbh; |
---|
62 | |
---|
63 | $params=$this->get_source_params($source_id); |
---|
64 | if ($params["PARAMETERS"]) { |
---|
65 | //Affichage du formulaire avec $params["PARAMETERS"] |
---|
66 | $vars=unserialize($params["PARAMETERS"]); |
---|
67 | foreach ($vars as $key=>$val) { |
---|
68 | global $$key; |
---|
69 | $$key=$val; |
---|
70 | } |
---|
71 | } |
---|
72 | $searchindexes=$this->profile["SEARCHINDEXES"][0]["SEARCHINDEX"]; |
---|
73 | if (!$url) $url=$searchindexes[0]["URL"]; |
---|
74 | $form = ""; |
---|
75 | if (count($searchindexes) > 1) { |
---|
76 | $form .= " |
---|
77 | <div class='row'> |
---|
78 | <div class='colonne3'> |
---|
79 | <label for='search_indexes'>".$this->msg["artevod_search_in"]."</label> |
---|
80 | </div> |
---|
81 | <div class='colonne_suite'> |
---|
82 | <select name='url' id='url' >"; |
---|
83 | for ($i=0; $i<count($searchindexes); $i++) { |
---|
84 | $form.="<option value='".$searchindexes[$i]["URL"]."' ".($url==$searchindexes[$i]["URL"]?"selected":"").">".$this->get_libelle($searchindexes[$i]["COMMENT"])."</option>\n"; |
---|
85 | } |
---|
86 | $form.=" |
---|
87 | </select> |
---|
88 | </div> |
---|
89 | </div>"; |
---|
90 | } else { |
---|
91 | $form .= " |
---|
92 | <input type='hidden' id='url' name='url' value='".$searchindexes[0]["URL"]."' /> |
---|
93 | "; |
---|
94 | } |
---|
95 | $form .= "<div class='row'> |
---|
96 | <div class='colonne3'> |
---|
97 | <label for='xslt_file'>".$this->msg["artevod_xslt_file"]."</label> |
---|
98 | </div> |
---|
99 | <div class='colonne_suite'> |
---|
100 | <input name='xslt_file' type='file'/>"; |
---|
101 | if ($xsl_transform) $form.="<br /><i>".sprintf($this->msg["artevod_xslt_file_linked"],$xsl_transform["name"])."</i> : ".$this->msg["artevod_del_xslt_file"]." <input type='checkbox' name='del_xsl_transform' value='1'/>"; |
---|
102 | $form.="</div> |
---|
103 | </div>"; |
---|
104 | |
---|
105 | // Champ perso de notice à utiliser |
---|
106 | $form .= "<div class='row'> |
---|
107 | <div class='colonne3'><label for='source_name'>".$this->msg["artevod_source_field"]."</label></div> |
---|
108 | <div class='colonne-suite'> |
---|
109 | <select name='cp_field'>"; |
---|
110 | $query = "select idchamp, titre from notices_custom where datatype='integer'"; |
---|
111 | $result = pmb_mysql_query($query, $dbh); |
---|
112 | if($result && pmb_mysql_num_rows($result)){ |
---|
113 | while($row = pmb_mysql_fetch_object($result)){ |
---|
114 | $form.=" |
---|
115 | <option value='".$row->idchamp."' ".($row->idchamp == $cp_field ? "selected='selected'" : "").">".htmlentities($row->titre,ENT_QUOTES,$charset)."</option>"; |
---|
116 | } |
---|
117 | }else{ |
---|
118 | $form.=" |
---|
119 | <option value='0'>".$this->msg["artevod_no_field"]."</option>"; |
---|
120 | } |
---|
121 | $form.=" |
---|
122 | </select> |
---|
123 | </div> |
---|
124 | </div>"; |
---|
125 | |
---|
126 | // Template de l'enrichissement |
---|
127 | $form .= "<div class='row'> |
---|
128 | <div class='colonne3'><label for='source_name'>".$this->msg["artevod_enrichment_template"]."</label></div> |
---|
129 | <div class='colonne-suite'> |
---|
130 | <textarea name='enrichment_template'>".($enrichment_template ? stripslashes($enrichment_template) : stripslashes($this->default_enrichment_template))."</textarea> |
---|
131 | </div> |
---|
132 | </div>"; |
---|
133 | |
---|
134 | $form .= "<div class='row'></div>"; |
---|
135 | return $form; |
---|
136 | } |
---|
137 | |
---|
138 | function make_serialized_source_properties($source_id) { |
---|
139 | global $url, $cp_field, $enrichment_template; |
---|
140 | global $del_xsl_transform; |
---|
141 | |
---|
142 | $t["url"]=$url; |
---|
143 | |
---|
144 | //Vérification du fichier |
---|
145 | if (($_FILES["xslt_file"])&&(!$_FILES["xslt_file"]["error"])) { |
---|
146 | $xslt_file_content=array(); |
---|
147 | $xslt_file_content["name"]=$_FILES["xslt_file"]["name"]; |
---|
148 | $xslt_file_content["code"]=file_get_contents($_FILES["xslt_file"]["tmp_name"]); |
---|
149 | $t["xsl_transform"]=$xslt_file_content; |
---|
150 | } else if ($del_xsl_transform) { |
---|
151 | $t["xsl_transform"]=""; |
---|
152 | } else { |
---|
153 | $oldparams=$this->get_source_params($source_id); |
---|
154 | if ($oldparams["PARAMETERS"]) { |
---|
155 | //Anciens paramètres |
---|
156 | $oldvars=unserialize($oldparams["PARAMETERS"]); |
---|
157 | } |
---|
158 | $t["xsl_transform"] = $oldvars["xsl_transform"]; |
---|
159 | } |
---|
160 | $t["cp_field"] = $cp_field; |
---|
161 | $t['enrichment_template'] = ($enrichment_template ? $enrichment_template : addslashes($this->default_enrichment_template)); |
---|
162 | |
---|
163 | $this->sources[$source_id]["PARAMETERS"]=serialize($t); |
---|
164 | } |
---|
165 | |
---|
166 | //Récupération des proriétés globales par défaut du connecteur (timeout, retry, repository, parameters) |
---|
167 | function fetch_default_global_values() { |
---|
168 | $this->timeout=5; |
---|
169 | $this->repository=2; |
---|
170 | $this->retry=3; |
---|
171 | $this->ttl=1800; |
---|
172 | $this->parameters=""; |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | * Formulaire des propriétés générales |
---|
177 | */ |
---|
178 | function get_property_form() { |
---|
179 | global $charset; |
---|
180 | $this->fetch_global_properties(); |
---|
181 | //Affichage du formulaire en fonction de $this->parameters |
---|
182 | if ($this->parameters) { |
---|
183 | $keys = unserialize($this->parameters); |
---|
184 | $accesskey= $keys['accesskey']; |
---|
185 | $secretkey=$keys['secretkey']; |
---|
186 | $privatekey=$keys['privatekey']; |
---|
187 | } else { |
---|
188 | $accesskey=""; |
---|
189 | $secretkey=""; |
---|
190 | $privatekey=""; |
---|
191 | } |
---|
192 | $r="<div class='row'> |
---|
193 | <div class='colonne3'><label for='accesskey'>".$this->msg["artevod_key"]."</label></div> |
---|
194 | <div class='colonne-suite'><input type='text' id='accesskey' name='accesskey' value='".htmlentities($accesskey,ENT_QUOTES,$charset)."'/></div> |
---|
195 | </div> |
---|
196 | <div class='row'> |
---|
197 | <div class='colonne3'><label for='secretkey'>".$this->msg["artevod_secret_key"]."</label></div> |
---|
198 | <div class='colonne-suite'><input type='password' class='saisie-50em' id='secretkey' name='secretkey' value='".htmlentities($secretkey,ENT_QUOTES,$charset)."'/></div> |
---|
199 | </div> |
---|
200 | <div class='row'> |
---|
201 | <div class='colonne3'><label for='privatekey'>".$this->msg["artevod_private_key"]."</label></div> |
---|
202 | <div class='colonne-suite'><input type='text' class='saisie-50em' id='privatekey' name='privatekey' value='".htmlentities($privatekey,ENT_QUOTES,$charset)."'/></div> |
---|
203 | </div>"; |
---|
204 | return $r; |
---|
205 | } |
---|
206 | |
---|
207 | function make_serialized_properties() { |
---|
208 | global $accesskey, $secretkey, $privatekey; |
---|
209 | //Mise en forme des paramètres à partir de variables globales (mettre le résultat dans $this->parameters) |
---|
210 | $keys = array(); |
---|
211 | |
---|
212 | $keys['accesskey']=$accesskey; |
---|
213 | $keys['secretkey']=$secretkey; |
---|
214 | $keys['privatekey']=$privatekey; |
---|
215 | $this->parameters = serialize($keys); |
---|
216 | } |
---|
217 | |
---|
218 | function apply_xsl_to_xml($xml, $xsl, $parameters = array()) { |
---|
219 | global $charset; |
---|
220 | |
---|
221 | $xh = xslt_create(); |
---|
222 | xslt_set_encoding($xh, $charset); |
---|
223 | $arguments = array( |
---|
224 | '/_xml' => $xml, |
---|
225 | '/_xsl' => $xsl |
---|
226 | ); |
---|
227 | $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments, $parameters); |
---|
228 | xslt_free($xh); |
---|
229 | return $result; |
---|
230 | } |
---|
231 | |
---|
232 | function maj_entrepot($source_id,$callback_progress="",$recover=false,$recover_env="") { |
---|
233 | global $charset,$base_path, $dbh; |
---|
234 | |
---|
235 | $this->fetch_global_properties(); |
---|
236 | $keys = unserialize($this->parameters); |
---|
237 | |
---|
238 | $this->callback_progress=$callback_progress; |
---|
239 | $params=$this->unserialize_source_params($source_id); |
---|
240 | $p=$params["PARAMETERS"]; |
---|
241 | $this->source_id=$source_id; |
---|
242 | $this->n_recu=0; |
---|
243 | |
---|
244 | //Récupération du fichier XML distant en cURL |
---|
245 | $xml=""; |
---|
246 | if(strpos($p["url"],"?")) { |
---|
247 | $url = substr($p["url"],0,strpos($p["url"],"?")); |
---|
248 | } else { |
---|
249 | $url = $p["url"]; |
---|
250 | } |
---|
251 | |
---|
252 | $aCurl = new Curl(); |
---|
253 | $aCurl->timeout=60; |
---|
254 | @mysql_set_wait_timeout(); |
---|
255 | |
---|
256 | //Authentification Basic |
---|
257 | if (substr($url,0,7) == "http://") { |
---|
258 | $auth_basic = "http://".$keys["accesskey"].":".$keys["secretkey"]."@".substr($url,7); |
---|
259 | } elseif (substr($url,0,8) == "https://") { |
---|
260 | $auth_basic = "https://".$keys["accesskey"].":".$keys["secretkey"]."@".substr($url,8); |
---|
261 | } else { |
---|
262 | $auth_basic = $keys["accesskey"].":".$keys["secretkey"]."@".$url; |
---|
263 | } |
---|
264 | |
---|
265 | //On fait un premier appel pour récupérer le nombre total de documents |
---|
266 | $url_temp_auth_basic = $auth_basic."?partial=0&page_size=0"; |
---|
267 | $content = $aCurl->get($url_temp_auth_basic); |
---|
268 | $xml_content=$content->body; |
---|
269 | |
---|
270 | if($xml_content && $content->headers['Status-Code'] == 200){ |
---|
271 | $xsl_transform=$p["xsl_transform"]["code"]; |
---|
272 | if($xsl_transform){ |
---|
273 | if($xsl_transform['code']) |
---|
274 | $xsl_transform_content = $xsl_transform['code']; |
---|
275 | else $xsl_transform_content = ""; |
---|
276 | } |
---|
277 | if($xsl_transform_content == "") { |
---|
278 | // $xsl_transform_content = file_get_contents($base_path."/admin/connecteurs/in/artevod/xslt/artevod_to_pmbxmlunimarc.xsl"); |
---|
279 | $xsl_transform_content = file_get_contents($base_path."/admin/connecteurs/in/artevod/xslt/artevod2uni.xsl"); |
---|
280 | } |
---|
281 | $params = _parser_text_no_function_($xml_content,"WSOBJECTLISTQUERY"); |
---|
282 | if($params["TOTAL_COUNT"]) { |
---|
283 | $this->n_total = $params["TOTAL_COUNT"]; |
---|
284 | $nb = 0; |
---|
285 | $nb_per_pass = 50; |
---|
286 | $page_nb = 1; |
---|
287 | |
---|
288 | $query = "select name from notices_custom where idchamp = ".$p['cp_field']; |
---|
289 | $result = pmb_mysql_query($query, $dbh); |
---|
290 | if ($row = pmb_mysql_fetch_object($result)) { |
---|
291 | $cp_artevod = array('cp_artevod' => $row->name); |
---|
292 | } else { |
---|
293 | $cp_artevod = array(); |
---|
294 | } |
---|
295 | |
---|
296 | while ($nb <= $params["TOTAL_COUNT"]) { |
---|
297 | $url_temp_auth_basic = $auth_basic."?partial=0&page_size=".$nb_per_pass."&page_nb=".$page_nb; |
---|
298 | $content = $aCurl->get($url_temp_auth_basic); |
---|
299 | $xml_content=$content->body; |
---|
300 | if($xml_content && $content->headers['Status-Code'] == 200){ |
---|
301 | $pmbxmlunimarc = $this->apply_xsl_to_xml($xml_content, $xsl_transform_content, $cp_artevod); |
---|
302 | $this->rec_records($pmbxmlunimarc, $this->source_id,''); |
---|
303 | } |
---|
304 | $page_nb++; |
---|
305 | $nb = $nb + $nb_per_pass; |
---|
306 | } |
---|
307 | } |
---|
308 | } else { |
---|
309 | $this->error=true; |
---|
310 | $this->error_message=$this->msg["artevod_error_auth"]; |
---|
311 | } |
---|
312 | |
---|
313 | return $this->n_recu; |
---|
314 | } |
---|
315 | |
---|
316 | function progress() { |
---|
317 | $callback_progress=$this->callback_progress; |
---|
318 | if ($this->n_total) { |
---|
319 | $percent =($this->n_recu / $this->n_total); |
---|
320 | $nlu = $this->n_recu; |
---|
321 | $ntotal = $this->n_total; |
---|
322 | } else { |
---|
323 | $percent=0; |
---|
324 | $nlu = $this->n_recu; |
---|
325 | $ntotal = "inconnu"; |
---|
326 | } |
---|
327 | call_user_func($callback_progress,$percent,$nlu,$ntotal); |
---|
328 | } |
---|
329 | |
---|
330 | function rec_records($noticesxml, $source_id, $search_id) { |
---|
331 | global $charset,$base_path; |
---|
332 | if (!trim($noticesxml)) |
---|
333 | return; |
---|
334 | |
---|
335 | $rec_uni_dom=new xml_dom($noticesxml,$charset); |
---|
336 | $notices=$rec_uni_dom->get_nodes("unimarc/notice"); |
---|
337 | foreach ($notices as $anotice) { |
---|
338 | $this->rec_record($rec_uni_dom, $anotice, $source_id, $search_id); |
---|
339 | } |
---|
340 | } |
---|
341 | |
---|
342 | function rec_record($rec_uni_dom, $noticenode, $source_id, $search_id) { |
---|
343 | global $charset,$base_path,$dbh; |
---|
344 | |
---|
345 | if (!$rec_uni_dom->error) { |
---|
346 | //Initialisation |
---|
347 | $ref=""; |
---|
348 | $ufield=""; |
---|
349 | $usubfield=""; |
---|
350 | $field_order=0; |
---|
351 | $subfield_order=0; |
---|
352 | $value=""; |
---|
353 | $date_import=date("Y-m-d H:i:s",time()); |
---|
354 | |
---|
355 | $fs=$rec_uni_dom->get_nodes("f", $noticenode); |
---|
356 | |
---|
357 | $fs[] = array("NAME" => "f", "ATTRIBS" => array("c" => "1000"), 'TYPE' => 1, "CHILDS" => array(array("DATA" => $search_term, "TYPE" => 2))); |
---|
358 | |
---|
359 | //Pas de 001 |
---|
360 | $ref = md5(serialize($noticenode)); |
---|
361 | //Mise à jour |
---|
362 | if ($ref) { |
---|
363 | //Si conservation des anciennes notices, on regarde si elle existe |
---|
364 | if (!$this->del_old) { |
---|
365 | $requete="select count(*) from entrepot_source_".$source_id." where ref='".addslashes($ref)."'"; |
---|
366 | $rref=pmb_mysql_query($requete,$dbh); |
---|
367 | if ($rref) $ref_exists=pmb_mysql_result($rref,0,0); |
---|
368 | } |
---|
369 | //Si pas de conservation des anciennes notices, on supprime |
---|
370 | if ($this->del_old) { |
---|
371 | $requete="delete from entrepot_source_".$source_id." where ref='".addslashes($ref)."'"; |
---|
372 | pmb_mysql_query($requete,$dbh); |
---|
373 | $this->delete_from_external_count($source_id, $ref); |
---|
374 | } |
---|
375 | $ref_exists = false; |
---|
376 | //Si pas de conservation ou reférence inexistante |
---|
377 | if (($this->del_old)||((!$this->del_old)&&(!$ref_exists))) { |
---|
378 | //Insertion de l'entête |
---|
379 | $n_header["rs"]=$rec_uni_dom->get_value("unimarc/notice/rs"); |
---|
380 | $n_header["ru"]=$rec_uni_dom->get_value("unimarc/notice/ru"); |
---|
381 | $n_header["el"]=$rec_uni_dom->get_value("unimarc/notice/el"); |
---|
382 | $n_header["bl"]=$rec_uni_dom->get_value("unimarc/notice/bl"); |
---|
383 | $n_header["hl"]=$rec_uni_dom->get_value("unimarc/notice/hl"); |
---|
384 | $n_header["dt"]=$rec_uni_dom->get_value("unimarc/notice/dt"); |
---|
385 | |
---|
386 | //Récupération d'un ID |
---|
387 | $requete="insert into external_count (recid, source_id) values('".addslashes($this->get_id()." ".$source_id." ".$ref)."', ".$source_id.")"; |
---|
388 | $rid=pmb_mysql_query($requete,$dbh); |
---|
389 | if ($rid) $recid=pmb_mysql_insert_id(); |
---|
390 | |
---|
391 | foreach($n_header as $hc=>$code) { |
---|
392 | $requete="insert into entrepot_source_".$source_id." (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values( |
---|
393 | '".addslashes($this->get_id())."',".$source_id.",'".addslashes($ref)."','".addslashes($date_import)."', |
---|
394 | '".$hc."','',-1,0,'".addslashes($code)."','',$recid, '$search_id')"; |
---|
395 | pmb_mysql_query($requete,$dbh); |
---|
396 | } |
---|
397 | if ($fs) |
---|
398 | for ($i=0; $i<count($fs); $i++) { |
---|
399 | $ufield=$fs[$i]["ATTRIBS"]["c"]; |
---|
400 | $field_order=$i; |
---|
401 | $ss=$rec_uni_dom->get_nodes("s",$fs[$i]); |
---|
402 | if (is_array($ss)) { |
---|
403 | for ($j=0; $j<count($ss); $j++) { |
---|
404 | $usubfield=$ss[$j]["ATTRIBS"]["c"]; |
---|
405 | $value=$rec_uni_dom->get_datas($ss[$j]); |
---|
406 | $subfield_order=$j; |
---|
407 | $requete="insert into entrepot_source_".$source_id." (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values( |
---|
408 | '".addslashes($this->get_id())."',".$source_id.",'".addslashes($ref)."','".addslashes($date_import)."', |
---|
409 | '".addslashes($ufield)."','".addslashes($usubfield)."',".$field_order.",".$subfield_order.",'".addslashes($value)."', |
---|
410 | ' ".addslashes(strip_empty_words($value))." ',$recid, '$search_id')"; |
---|
411 | pmb_mysql_query($requete,$dbh); |
---|
412 | } |
---|
413 | } else { |
---|
414 | $value=$rec_uni_dom->get_datas($fs[$i]); |
---|
415 | $requete="insert into entrepot_source_".$source_id." (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values( |
---|
416 | '".addslashes($this->get_id())."',".$source_id.",'".addslashes($ref)."','".addslashes($date_import)."', |
---|
417 | '".addslashes($ufield)."','".addslashes($usubfield)."',".$field_order.",".$subfield_order.",'".addslashes($value)."', |
---|
418 | ' ".addslashes(strip_empty_words($value))." ',$recid, '$search_id')"; |
---|
419 | pmb_mysql_query($requete,$dbh); |
---|
420 | } |
---|
421 | } |
---|
422 | } |
---|
423 | $this->n_recu++; |
---|
424 | $this->progress(); |
---|
425 | } |
---|
426 | } |
---|
427 | } |
---|
428 | |
---|
429 | function enrichment_is_allow(){ |
---|
430 | return true; |
---|
431 | } |
---|
432 | |
---|
433 | function getTypeOfEnrichment($source_id){ |
---|
434 | $type['type'] = array( |
---|
435 | array( |
---|
436 | "code" => "artevod", |
---|
437 | "label" => $this->msg['artevod_vod'] |
---|
438 | ) |
---|
439 | ); |
---|
440 | $type['source_id'] = $source_id; |
---|
441 | return $type; |
---|
442 | } |
---|
443 | |
---|
444 | function getEnrichment($notice_id,$source_id,$type="",$enrich_params=array()){ |
---|
445 | $enrichment= array(); |
---|
446 | return $enrichment; |
---|
447 | } |
---|
448 | |
---|
449 | function getEnrichmentHeader(){ |
---|
450 | $header= array(); |
---|
451 | return $header; |
---|
452 | } |
---|
453 | |
---|
454 | /** |
---|
455 | * Définit le template par défaut de l'enrichissement |
---|
456 | */ |
---|
457 | private function set_default_enrichment_template() { |
---|
458 | $this->default_enrichment_template = "{* Template par défaut *} |
---|
459 | <div class='enrichment_artevod_container' style='width:400px;'> |
---|
460 | |
---|
461 | <div class='enrichment_artevod_mediatheque_numerique' style='text-align:center;'> |
---|
462 | <img src='./images/mediatheque_numerique.png' style='margin:5px;' title='Médiathèque numérique' /> |
---|
463 | </div> |
---|
464 | |
---|
465 | {* titre *} |
---|
466 | {% if film.title %} |
---|
467 | <h3 class='enrichment_artevod_title'>{{ film.title }} |
---|
468 | {% if film.original_title %} |
---|
469 | ({{ film.original_title }}) |
---|
470 | {% endif %} |
---|
471 | </h3> |
---|
472 | {% else %} |
---|
473 | {% if film.original_title %} |
---|
474 | <h3 class='enrichment_artevod_title'>{{ film.original_title }}</h3> |
---|
475 | {% endif %} |
---|
476 | {% endif %} |
---|
477 | |
---|
478 | {* lien vers la ressource *} |
---|
479 | {% if film.externaluri %} |
---|
480 | <p class='enrichment_artevod_externaluri'> |
---|
481 | <a href='{{ film.externaluri }}' target='_BLANK'>Voir le programme</a> |
---|
482 | </p> |
---|
483 | {% endif %} |
---|
484 | |
---|
485 | {* genres *} |
---|
486 | {% for genre in film.genres %} |
---|
487 | {% if loop.first %}<p class='enrichment_artevod_genres'>{% endif %} |
---|
488 | {{ genre }}{%if !loop.last %}, {% endif %} |
---|
489 | |
---|
490 | {* sous-genres *} |
---|
491 | {% for subgenre in film.subgenres %} |
---|
492 | {% if loop.first %}/{% endif %} |
---|
493 | {{ subgenre }}{%if !loop.last %}, {% else %}</p>{% endif %} |
---|
494 | {% endfor %} |
---|
495 | {% endfor %} |
---|
496 | |
---|
497 | {* auteurs *} |
---|
498 | {% for author in film.authors %} |
---|
499 | {% if loop.first %}<p class='enrichment_artevod_authors'>De {% endif %} |
---|
500 | {{ author }}{%if !loop.last %}, {% else %}</p>{% endif %} |
---|
501 | {% endfor %} |
---|
502 | |
---|
503 | {* acteurs *} |
---|
504 | {% for actor in film.actors %} |
---|
505 | {% if loop.first %}<p class='enrichment_artevod_actors'>Avec {% endif %} |
---|
506 | {{ actor }}{%if !loop.last %}, {% else %}</p>{% endif %} |
---|
507 | {% endfor %} |
---|
508 | |
---|
509 | {* infos *} |
---|
510 | <p class='enrichment_artevod_infos'> |
---|
511 | {% if film.production_year %}<strong>Année :</strong> {{ film.production_year }}.{% endif %} |
---|
512 | {% if film.production_countries %} <strong>Pays :</strong> {{ film.production_countries }}.{% endif %} |
---|
513 | {% if film.languages %} <strong>Langue :</strong> {{ film.languages }}.{% endif %} |
---|
514 | {% if film.target_audience %} <strong>Public :</strong> {{ film.target_audience }}.{% endif %} |
---|
515 | </p> |
---|
516 | |
---|
517 | {* description *} |
---|
518 | {% if film.description %} |
---|
519 | <p class='enrichment_artevod_description' style='font-weight:bold;font-size:1.2em;'>{{ film.description }}</p> |
---|
520 | {% endif %} |
---|
521 | |
---|
522 | {* résumé *} |
---|
523 | {% if film.body %} |
---|
524 | <p class='enrichment_artevod_body'>{{ film.body }}</p> |
---|
525 | {% endif %} |
---|
526 | |
---|
527 | {* durée *} |
---|
528 | {% if film.duration.format_value %} |
---|
529 | <p class='enrichment_artevod_duration'><strong>Durée :</strong> {{ film.duration.format_value }}</p> |
---|
530 | {% endif %} |
---|
531 | |
---|
532 | {* extrait *} |
---|
533 | {% for trailer in film.trailers %} |
---|
534 | <video class='enrichment_artevod_trailer' width='400px' controls src='{{ trailer }}' style='margin-top:5px;margin-bottom:5px;'>{{ 'Voir l\'extrait' |links_to film.externaluri }}</video> |
---|
535 | {% endfor %} |
---|
536 | |
---|
537 | {* photos *} |
---|
538 | {% for photo in film.photos %} |
---|
539 | {% if loop.first %}<div class='enrichment_artevod_photos'>{% endif %} |
---|
540 | <div style='height:110px;width:49%;float:left;clear:none;margin-right:1%;margin-bottom:2px;text-align:center;'> |
---|
541 | <img style='max-height:110px;max-width:100%;' src='{{ photo }}' title='photo' class='enrichment_artevod_photo' /> |
---|
542 | </div> |
---|
543 | {% if loop.last %}</div>{% endif %} |
---|
544 | {% endfor %} |
---|
545 | |
---|
546 | <div class='row'></div> |
---|
547 | </div>"; |
---|
548 | } |
---|
549 | }// class end |
---|