1,17 → 1,21 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* PHP Version 5 |
* |
* @category PHP |
* @package jrest |
* @author David Delon <david.delon@clapas.net> |
* @copyright 2010 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @version SVN: <svn_id> |
* @link /doc/jrest/ |
*/ |
* Service générant un PDF d'export des observations pour réaliser des étiquettes d'herbier. |
* |
* @internal Mininum PHP version : 5.2 |
* @category CEL |
* @package Services |
* @subpackage Export |
* @version 0.1 |
* @author Mathias CHOUET <mathias@tela-botanica.org> |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @author Aurelien PERONNET <aurelien@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt> |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org> |
*/ |
|
|
/** Constante stockant l'URL de la page d'accueil de Photoflora.*/ |
define('EF_URL_PHOTOFLORA', 'http://photoflora.free.fr/'); |
/** Constante stockant l'URL de la page de Photoflora affichant toutes les images d'un taxon donn.es.*/ |
25,23 → 29,14 |
/** Constante stockant l'URL du service XML de Photoflora.*/ |
define('EF_URL_PHOTOFLORA_SERVICE', EF_URL_PHOTOFLORA.'ef_photoflora.php?nt=%s'); |
|
/** |
* InventoryPDF.php |
* |
* in : utf8 |
* out : iso8859 |
* |
* Formatage pdf d'un releve (a revoir) |
*/ |
class InventoryPDF extends Cel { |
|
var $extendPDFProductor; |
|
function InventoryPDF($config) { |
|
public function __construct($config) { |
parent::__construct($config); |
|
$this->config=$config; |
$this->config = $config; |
// Pas d'heritage multiple en php :( |
$this->extendPDFProductor = new PDFProductor(); |
$this->extendPDFProductor->initPDF(); |
54,61 → 49,57 |
* uid[3] : si absent : valeur 'all' (recherche libre) |
* uid[4] : si absent : valeur 'all' (station) |
*/ |
function getElement($uid){ |
|
// Controle detournement utilisateur |
public function getElement($uid){ |
// Controle detournement utilisateur |
$this->controleUtilisateur($uid[0]); |
|
if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) { |
$uid[1]="all"; |
$requete_location=""; |
if (!isset($uid[1]) || $uid[1] == '' || $uid[1] == 'all' ) { |
$uid[1] = 'all'; |
$requete_location = ''; |
} else { |
$requete_location = ' AND location= '.Cel::db()->proteger($uid[1]).' '; |
} |
else { |
$requete_location=" AND location= ".Cel::db()->proteger($uid[1])." "; |
} |
|
if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all") { |
$uid[2]="all"; |
$requete_date=""; |
if (!isset($uid[2]) || $uid[2] == '' || $uid[2] == 'all') { |
$uid[2] = 'all'; |
$requete_date = ''; |
} else { |
$requete_date = ' AND date_observation= '.Cel::db()->proteger($uid[2]).' '; |
} |
else { |
$requete_date=" AND date_observation= ".Cel::db()->proteger($uid[2])." "; |
} |
|
if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all") { |
$uid[3]="all"; |
$requete_libre=""; |
if (!isset($uid[3]) || $uid[3] == '' || $uid[3] == 'all') { |
$uid[3] = 'all'; |
$requete_libre = ''; |
} else { |
$requete_libre = ' AND (nom_sel LIKE '.Cel::db()->proteger('%'.$uid[3].'%'). |
' OR nom_ret LIKE '.Cel::db()->proteger('%'.$uid[3].'%'). |
' OR station LIKE '.Cel::db()->proteger('%'.$uid[3].'%'). |
' OR commentaire LIKE '.Cel::db()->proteger('%'.$uid[3].'%'); |
} |
else { |
$requete_libre=" AND (nom_sel LIKE ".Cel::db()->proteger('%'.$uid[3].'%'). |
" OR nom_ret LIKE ".Cel::db()->proteger('%'.$uid[3].'%'). |
" OR station LIKE ".Cel::db()->proteger('%'.$uid[3].'%'). |
" OR commentaire LIKE ".Cel::db()->proteger('%'.$uid[3].'%'); |
} |
|
if (!isset($uid[4]) || $uid[4]=="" || $uid[4]=="all") { |
$uid[4]="all"; |
$requete_station=""; |
if (!isset($uid[4]) || $uid[4] == '' || $uid[4] == 'all') { |
$uid[4] = 'all'; |
$requete_station =''; |
} else { |
$requete_station = ' AND station= '.Cel::db()->proteger($uid[4]).' '; |
} |
else { |
$requete_station=" AND station= ".Cel::db()->proteger($uid[4])." "; |
} |
|
$value=array(); |
$value = array(); |
$requete = 'SELECT ce_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation, '. |
'station, commentaire, transmission '. |
'FROM cel_obs '. |
'WHERE ce_utilisateur = '.Cel::db()->proteger($uid[0]).' '. |
$requete_location. |
$requete_date. |
$requete_libre. |
$requete_station.' '. |
'ORDER BY ordre '. |
' -- '.__FILE__.':'.__LINE__; |
$resultat = Cel::db()->requeter($requete); |
|
$requete="SELECT ce_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation, " . |
"station, commentaire, transmission FROM cel_obs WHERE ce_utilisateur = ".Cel::db()->proteger($uid[0])." " . |
$requete_location. |
$requete_date. |
$requete_libre. |
$requete_station. |
" ORDER BY ordre "; |
|
$resultat_requete = Cel::db()->requeter($requete); |
|
$observations = array();; |
if(is_array($resultat_requete)) { |
$observations = $resultat_requete; |
if (is_array($resultat)) { |
$observations = $resultat; |
} |
|
// Set up the pdf object. |
124,50 → 115,43 |
$pdf->addPage(); |
$pdf->setFont('Times', '' , 12); |
|
$i=1; |
$tempfn = tempnam("",""); |
$i = 1; |
$tempfn = tempnam('', ''); |
|
foreach ($observations as $obs) { |
|
// Denullifiage |
// Denullifiage |
foreach($obs as $k=>$v) { |
if (($v=="null") || ($v=="000null")) { |
$obs[$k]=""; |
if (($v == 'null') || ($v == '000null')) { |
$obs[$k] = ''; |
} else { |
$obs[$k] = utf8_decode($v); |
} |
else { |
$obs[$k]=utf8_decode($v); |
} |
} |
|
if ($obs['date_observation']!="0000-00-00 00:00:00") { |
list($year,$month,$day)= explode('-',$obs['date_observation']); |
list($day)= explode(' ',$day); |
$obs['date_observation']=$day."/".$month."/".$year; |
} |
else { |
$obs['date_observation']="00/00/0000"; |
} |
if ($obs['date_observation'] != '0000-00-00 00:00:00') { |
list($year,$month,$day)= explode('-', $obs['date_observation']); |
list($day)= explode(' ', $day); |
$obs['date_observation'] = "$day/$month/$year"; |
} else { |
$obs['date_observation'] = '00/00/0000'; |
} |
|
$text= $obs['nom_sel']." ".$obs['nom_sel_nn']." ".$obs['nom_ret']." ".$obs['nom_ret_nn']." ".$obs['nt']." ". |
$obs['famille']." ".$obs['zone_geo']." ".$obs['ce_zone_geo']." ".$obs['date_observation']." ".$obs['station']; |
$obs['commentaire']; |
$text = $obs['nom_sel']." ".$obs['nom_sel_nn']." ".$obs['nom_ret']." ".$obs['nom_ret_nn']." ".$obs['nt']." ". |
$obs['famille']." ".$obs['zone_geo']." ".$obs['ce_zone_geo']." ".$obs['date_observation']." ".$obs['station']; |
$obs['commentaire']; |
|
$pdf->write(10, $text."\n"); |
|
$projet_photo = 'photoflora'; |
|
$tab_retour[$projet_photo]=chercherIllustrationsServiceXml(sprintf(EF_URL_PHOTOFLORA_SERVICE, $obs['nt'])); |
|
|
$url_miniature =''; |
|
$tab_retour[$projet_photo] = $this->analyserRdf(sprintf(EF_URL_PHOTOFLORA_SERVICE, $obs['nt'])); |
$url_miniature = ''; |
foreach ($tab_retour[$projet_photo] as $cle => $illustration) { |
if (preg_match(EF_URL_PHOTOFLORA_REGEXP, $illustration['about'], $match)) { |
$abreviation = $match[1]; |
$fichier = $match[2]; |
$url_miniature = sprintf(EF_URL_PHOTOFLORA_IMG_MIN, $abreviation, $fichier);; |
$abreviation = $match[1]; |
$fichier = $match[2]; |
$url_miniature = sprintf(EF_URL_PHOTOFLORA_IMG_MIN, $abreviation, $fichier);; |
|
// Priorite aux images en png |
// Priorite aux images en png |
if (strstr($fichier, '.png')) { |
break; |
} |
174,29 → 158,20 |
} |
} |
|
if ($url_miniature!='') { |
list($debut,$ext)=explode("\.",basename($url_miniature)); |
$temp = fopen($tempfn, "w"); |
if ($url_miniature != '') { |
list($debut,$ext)=explode('\.',basename($url_miniature)); |
$temp = fopen($tempfn, 'w'); |
$buf=file_get_contents($url_miniature); |
fwrite($temp,$buf); |
fclose($temp); |
$pdf->image($tempfn,10,($i*10),0,0,$ext); |
fclose($temp); |
$pdf->image($tempfn, 10, ($i*10), 0, 0, $ext); |
} |
|
$i++; |
} |
|
echo $pdf->output("Rapport"); |
$i++; |
} |
echo $pdf->output('Rapport'); |
} |
} |
|
function chercherIllustrationsServiceXml($url) |
{ |
return analyserFichierRdf($url); |
} |
|
function analyserFichierRdf($chemin) |
{ |
private function analyserRdf($chemin) { |
$aso_info = array(); |
$dom = new DOMDocument(); |
$dom->validateOnParse = true; |
229,20 → 204,6 |
$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence')); |
$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info; |
} |
|
return $tab_infos; |
} |
|
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.2 2008-01-30 08:57:28 ddelon |
* fin mise en place mygwt |
* |
* Revision 1.1 2007-06-06 13:31:16 ddelon |
* v0.09 |
* |
* Revision 1.4 2007-05-22 12:54:09 ddelon |
* Securisation acces utilisateur |
* |
*/ |
?> |
} |
} |