### Commande file
-La commande *file* permet de remplacer l'attribut *filename* de la balise sur laquelle porte l'annotation après avoir interroger le flux (ou le connecteur pour le test).
+La commande *file* permet de remplacer les attributs *filename* et *mimeCode* de la balise sur laquelle porte l'annotation
+après avoir interroger le flux (ou le connecteur pour le test).
> *Exemple:*
>
-> *{{pastell::file:pes_aller}} est remplacé par *PESALR2_20899099.xml*
+> *{{pastell::file:pes_aller}} dans l'annotation de l'attachement d'un fichier produira :
+> `<Attachment format="fmt/101" mimeCode="text/plain" filename="fichier_aller.xml">`
### Commande integrity
/** @var FluxData */
private $fluxData;
+
public function setConnecteurConfig(DonneesFormulaire $connecteurConfig) {
$this->connecteurConfig = $connecteurConfig;
}
return $the_result;
}
+ public function generateArchive(FluxData $fluxData, $archive_path){
+ $tmpFolder = new TmpFolder();
+ $tmp_folder = $tmpFolder->create();
+
+ $files_list = "";
+
+ foreach($fluxData->getFilelist() as $file_id){
+ $filename = $fluxData->getFilename($file_id);
+ copy($fluxData->getFilePath($file_id),"$tmp_folder/$filename");
+ $files_list.= escapeshellarg($filename). " ";
+ }
+
+ $command = "tar cvzf $archive_path --directory $tmp_folder $files_list 2>&1";
+ exec($command,$output,$return_var);
+
+ if ( $return_var != 0) {
+ $output = implode("\n",$output);
+ throw new Exception("Impossible de créer le fichier d'archive $archive_path - status : $return_var - output: $output");
+ }
+
+ $tmpFolder->delete($tmp_folder);
+ }
}
\ No newline at end of file
public $type;
public $string;
+ public $data;
}
/** @var AnnotationReturn $return_i */
$return_i = $this->$function($data);
$return->type = $return_i->type;
+ $return->data =$return_i->data;
+ if (is_array($return_i->string)){
+ //TODO pb des file multiple a traiter avec une commande repeat
+ $return_i->string = $return_i->string[0];
+ }
$return->string .= $return_i->string;
}
return $return;
if (empty($value)){
return $this->getAnnotationReturn(AnnotationReturn::EMPTY_RETURN);
}
- return $this->getAnnotationReturn(AnnotationReturn::ATTACHMENT_INFO,$value);
+ $annotationReturn = $this->getAnnotationReturn(AnnotationReturn::ATTACHMENT_INFO,$value);
+ $annotationReturn->data = array('content-type' => $this->fluxData->getContentType($data));
+ return $annotationReturn;
}
abstract function getFilename($key);
abstract function getFileSHA256($key);
abstract function getFilelist();
+ abstract function getFilePath($key);
+ abstract function getContentType($key);
}
\ No newline at end of file
$file_path = $this->donneesFormulaire->getFilePath($key);
return hash_file("sha256",$file_path);
}
+
+ public function getFilePath($key){
+ return $this->donneesFormulaire->getFilePath($key);
+ }
+
+ public function getContentType($key) {
+ return $this->donneesFormulaire->getContentType($key);
+ }
}
\ No newline at end of file
public function getFileSHA256($key) {
return hash('sha256',base64_encode(mt_rand(0,mt_getrandmax())));
}
+
+ public function getFilePath($key){
+ return "/dev/null";
+ }
+
+ public function getContentType($key) {
+ return "";
+ }
+
}
\ No newline at end of file
foreach($annotation_list as $annotation){
$annotationReturn = $annotationWrapper->wrap((string) $annotation->nodeValue);
+
if ($annotationReturn->type == AnnotationReturn::STRING){
$annotation->parentNode->nodeValue = $annotationReturn->string;
} elseif ($annotationReturn->type == AnnotationReturn::XML_REPLACE){
$nodeToRemove[] = $annotation;
} elseif ($annotationReturn->type == AnnotationReturn::ATTACHMENT_INFO){
$annotation->parentNode->attributes->getNamedItem('filename')->nodeValue = $annotationReturn->string;
+ if ($annotationReturn->data['content-type']) {
+ $annotation->parentNode->attributes->getNamedItem('mimeCode')->nodeValue = $annotationReturn->data['content-type'];
+ }
$nodeToRemove[] = $annotation;
} else {
throw new Exception("annotationReturn inconnu");