Skip to content
Snippets Groups Projects
Commit aa93471d authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

skelleton of export seda action

parent f1ada821
No related branches found
No related tags found
No related merge requests found
Showing
with 2167 additions and 0 deletions
......@@ -299,4 +299,8 @@
<moduleid>thesaurus</moduleid>
<comment>_THESAURUS_COMMENT</comment>
</MODULES>
<MODULES>
<moduleid>export_seda</moduleid>
<comment>_EXPORT_SEDA_COMMENT</comment>
</MODULES>
</ROOT>
......@@ -291,4 +291,15 @@ An action page is described in a ACTIONPAGE tag :
<COLL_ID>letterbox_coll</COLL_ID>
</COLLECTIONS>
</ACTIONPAGE>
<ACTIONPAGE>
<ID>export_seda</ID>
<LABEL>_EXPORT_SEDA</LABEL>
<NAME>export_seda</NAME>
<ORIGIN>module</ORIGIN>
<MODULE>export_seda</MODULE>
<FLAG_CREATE>false</FLAG_CREATE>
<COLLECTIONS>
<COLL_ID>letterbox_coll</COLL_ID>
</COLLECTIONS>
</ACTIONPAGE>
</ROOT>
<?php
/*
* Copyright 2008-2017 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
class Acknowledgement {
public function __construct()
{
}
public function send($fileName, $comments = "")
{
$xml = simplexml_load_file($fileName);
$messageObject = new stdClass();
if ($comments) {
$messageObject->comment = [];
if (is_array($comments)) {
foreach ($comments as $comment) {
$messageObject->comment[] = $comment;
}
} else {
$messageObject->comment[] = $comments;
}
}
$messageIdentifier = (string) $xml->MessageIdentifier;
$messageObject->date = date('Y-m-d h:i:s');
$messageObject->messageIdentifier = $messageIdentifier . "_Acknowledgement";
//$messageObject->signature = "";
$messageObject->messageReceivedIdentifier = $messageIdentifier;
$messageObject->sender = $xml->ArchivalAgency->Identifier;
$messageObject->receiver = $xml->TransferringAgency->Identifier;
$this->sendXml($messageObject);
}
public function sendXml($messageObject)
{
$DOMTemplate = new DOMDocument();
$DOMTemplate->load(__DIR__.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'Acknowledgement.xml');
$DOMTemplateProcessor = new DOMTemplateProcessor($DOMTemplate);
$DOMTemplateProcessor->setSource('Acknowledgement', $messageObject);
$DOMTemplateProcessor->merge();
$DOMTemplateProcessor->removeEmptyNodes();
file_put_contents(__DIR__.DIRECTORY_SEPARATOR.'seda2'.DIRECTORY_SEPARATOR.$messageObject->messageReceivedIdentifier.'_Acknowledgement.xml', $DOMTemplate->saveXML());
return $xml;
}
}
\ No newline at end of file
<?php
/*
* Copyright 2008-2017 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'core/class/class_request.php';
require_once __DIR__.'/DOMTemplateProcessor.php';
class ArchiveTransfer {
private $db;
public function __construct()
{
$this->db = new Database();
}
public function receive($listResId, $transferringAgency = "", $archivalAgency = "") {
if (!$listResId) {
return false;
}
$messageObject = new stdClass();
$messageObject = $this->initMessage($messageObject, $transferringAgency, $archivalAgency);
foreach ($listResId as $resId) {
$letterbox = $this->getCourrier($resId);
if ($letterbox->filename) {
$messageObject->dataObjectPackage->descriptiveMetadata->archiveUnit[] = $this->getArchiveUnit($letterbox);
$messageObject->dataObjectPackage->binaryDataObject[] = $this->getBinaryDataObject($letterbox);
} else {
$messageObject->dataObjectPackage->descriptiveMetadata->archiveUnit[] = $this->getArchiveUnit($letterbox);
}
}
//TODO
//$messageObject->dataObjectPackage->managementMetadata
$this->insertMessage($messageObject);
return $messageObject;
}
public function sendXml($messageObject)
{
$DOMTemplate = new DOMDocument();
$DOMTemplate->load(__DIR__.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'ArchiveTransfer.xml');
$DOMTemplateProcessor = new DOMTemplateProcessor($DOMTemplate);
$DOMTemplateProcessor->setSource('ArchiveTransfer', $messageObject);
$DOMTemplateProcessor->merge();
$DOMTemplateProcessor->removeEmptyNodes();
file_put_contents(__DIR__.DIRECTORY_SEPARATOR.'seda2'.DIRECTORY_SEPARATOR.$messageObject->messageIdentifier->value.'.xml', $DOMTemplate->saveXML());
return $xml;
}
private function initMessage($messageObject, $transferringAgency =null, $archivalAgency = null)
{
$messageObject->date = date('Y-m-d h:i:s');
$messageObject->messageIdentifier = new stdClass();
$messageObject->messageIdentifier->value = $_SESSION['user']['UserId'] . "-" . date('Ymd-His');
$messageObject->transferringAgency = new stdClass();
$messageObject->transferringAgency->identifier = new stdClass();
if ($transferringAgency) {
$messageObject->transferringAgency->identifier->value = $transferringAgency;
}else {
foreach ($_SESSION['user']['entities'] as $entitie) {
if ($entitie['ENTITY_TYPE'] == "Service") {
$entitie = $this->getEntitie($entitie['ENTITY_ID']);
if ($entitie) {
$messageObject->transferringAgency->identifier->value = $entitie->business_id;
} else {
// TODO return error;
}
}
}
}
$messageObject->archivalAgreement = new stdClass();
$messageObject->archivalAgreement->value = "A COMPLETER";
$messageObject->archivalAgency = new stdClass();
$messageObject->archivalAgency->identifier = new stdClass();
if ($archivalAgency) {
$messageObject->archivalAgency->identifier->value = $archivalAgency;
} else {
$messageObject->archivalAgency->identifier->value = "A COMPLETER";
}
$messageObject->dataObjectPackage = new stdClass();
$messageObject->dataObjectPackage->binaryDataObject = [];
$messageObject->dataObjectPackage->descriptiveMetadata = new stdClass();
$messageObject->dataObjectPackage->managementMetadata = new stdClass();
$messageObject->dataObjectPackage->descriptiveMetadata->archiveUnit = [];
return $messageObject;
}
private function getArchiveUnit($letterbox)
{
$messageArchiveUnit = new stdClass();
$messageArchiveUnit->content = new stdClass();
$messageArchiveUnit->content->receivedDate = $letterbox->admission_date;
$messageArchiveUnit->content->sentDate = $letterbox->doc_date;
$messageArchiveUnit->content->receivedDate = $letterbox->admission_date;
$messageArchiveUnit->content->receivedDate = $letterbox->admission_date;
$messageArchiveUnit->content->addressee = [];
$messageArchiveUnit->content->keyword = [];
if ($letterbox->exp_contact_id) {
$contact = $this->getContact($letterbox->exp_contact_id);
$entitie = $this->getEntitie($letterbox->destination);
$messageArchiveUnit->content->keyword[] = $this->getKeyword($contact);
$messageArchiveUnit->content->addressee[] = $this->getAddresse($entitie,"entitie");
} else if ($letterbox->dest_contact_id) {
$contact = $this->getContact($letterbox->dest_contact_id);
$entitie = $this->getEntitie($letterbox->destination);
$messageArchiveUnit->content->addressee[] = $this->getAddresse($contact);
$messageArchiveUnit->content->keyword[] = $this->getKeyword($entitie,"entitie");
} else if ($letterbox->exp_user_id) {
$user = $this->getUserInformation($letterbox->exp_user_id);
$entitie = $this->getEntitie($letterbox->initiator);
//$entitie = $this->getEntitie($letterbox->destination);
$messageArchiveUnit->content->keyword[] = $this->getKeyword($user);
$messageArchiveUnit->content->addressee[] = $this->getAddresse($entitie,"entitie");
}
$messageArchiveUnit->content->source = $_SESSION['mail_nature'][$letterbox->nature_id];
$messageArchiveUnit->content->documentType = $letterbox->type_label;
$messageArchiveUnit->content->originatingAgencyArchiveIdentifier = $letterbox->alt_identifier;
$messageArchiveUnit->content->originatingSystemId = $letterbox->res_id;
$messageArchiveUnit->content->title = [];
$messageArchiveUnit->content->title[] = $letterbox->subject;
$messageArchiveUnit->content->description = [];
$messageArchiveUnit->content->description[] = " ";
$messageArchiveUnit->content->endDate = $letterbox->process_limit_date;
$notes = $this->getNotes($letterbox->res_id);
$messageArchiveUnit->content->custodialHistory = new stdClass();
$messageArchiveUnit->content->custodialHistory->custodialHistoryItem = [];
foreach ($notes as $note) {
$messageArchiveUnit->content->custodialHistory->custodialHistoryItem[] = $this->getCustodialHistoryItem($note);
}
if ($dataObjectReferenceId) {
$messageArchiveUnit->dataObjectReference = new stdClass();
$messageArchiveUnit->dataObjectReference->dataObjectReferenceId = $letterbox->res_id;
}
return $messageArchiveUnit;
}
private function getBinaryDataObject($letterbox)
{
$binaryDataObject = new stdClass();
$binaryDataObject->id = $letterbox->res_id;
$binaryDataObject->messageDigest = new stdClass();
$binaryDataObject->messageDigest->value = $letterbox->fingerprint;
$binaryDataObject->size = new stdClass();
$binaryDataObject->size->value = $letterbox->filesize;
$uri = str_replace("##", DIRECTORY_SEPARATOR, $letterbox->path);
$uri = str_replace("#", DIRECTORY_SEPARATOR, $uri);
$uri .= $letterbox->filename;
$binaryDataObject->uri = $uri;
return $binaryDataObject;
}
private function getKeyword($informations, $type = null)
{
$keyword = new stdClass();
$keyword->keywordContent = new stdClass();
if ($type == "entitie") {
$keyword->keywordType = "corpname";
$keyword->keywordContent = $informations->business_id;
} else if ($informations->is_corporate_person == "Y") {
$keyword->keywordType = "corpname";
$keyword->keywordContent->value = $informations->society;
} else {
$keyword->keywordType = "personname";
$keyword->keywordContent->value = $informations->lastname . " " . $informations->firstname;
}
return $keyword;
}
private function getAddresse($informations, $type = null)
{
$addressee = new stdClass();
if ($type == "entitie") {
$addressee->corpname = $informations->entity_label;
$addressee->identifier = $informations->business_id;
} else if ($informations->is_corporate_person == "Y") {
$addressee->corpname = $informations->society;
$addressee->identifier = $informations->contact_id;
} else {
$addressee->firstName = $informations->firstname;
$addressee->birthName = $informations->lastname;
}
return $addressee;
}
private function getCustodialHistoryItem($note)
{
$custodialHistoryItem = new stdClass();
$custodialHistoryItem->value = $note->note_text;
$custodialHistoryItem->when = $note->date_note;
return $custodialHistoryItem;
}
private function getCourrier($resId)
{
$queryParams = [];
$queryParams[] = $resId;
$query = "SELECT * FROM res_view_letterbox WHERE res_id = ?";
$smtp = $this->db->query($query,$queryParams);
$letterbox = $smtp->fetchObject();
return $letterbox;
}
private function getUserInformation($userId)
{
$queryParams = [];
$queryParams[] = $userId;
$query = "SELECT * FROM users WHERE user_id = ?";
$smtp = $this->db->query($query,$queryParams);
$user = $smtp->fetchObject();
return $user;
}
private function getNotes($letterboxId)
{
$queryParams = [];
$queryParams[] = $letterboxId;
$query = "SELECT * FROM notes WHERE identifier = ?";
$smtp = $this->db->query($query,$queryParams);
$notes = [];
while ($res = $smtp->fetchObject()) {
$notes[] = $res;
}
return $notes;
}
private function getEntitie($entityId)
{
$queryParams = [];
$queryParams[] = $entityId;
$query = "SELECT * FROM entities WHERE entity_id = ?";
$smtp = $this->db->query($query,$queryParams);
$entitie = $smtp->fetchObject();
return $entitie;
}
private function getContact($contactId)
{
$queryParams = [];
$queryParams[] = $contactId;
$query = "SELECT * FROM contacts_v2 WHERE contact_id = ?";
$smtp = $this->db->query($query,$queryParams);
$contact = $smtp->fetchObject();
return $contact;
}
private function insertMessage($messageObject)
{
$queryParams = [];
$messageId = uniqid();
try {
$query = ("INSERT INTO seda (
message_id,
schema,
type,
status,
date,
reference,
account_id ,
sender_org_identifier_id,
sender_org_name,
recipient_org_identifier_id,
recipient_org_name,
archival_agreement_reference,
reply_code,
size,
data,
active,
archived)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$queryParams[] = $messageId; // Message Id
$queryParams[] = "2.1"; //Schema
$queryParams[] = "ArchiveTransfer"; // Type
$queryParams[] = "sent"; // Status
$queryParams[] = $messageObject->date; // Date
$queryParams[] = $messageObject->messageIdentifier->value; // Reference
$queryParams[] = $_SESSION['user']['UserId']; // Account Id
$queryParams[] = $messageObject->transferringAgency->identifier->value; // Sender org identifier id
$queryParams[] = ""; //SenderOrgNAme
$queryParams[] = $messageObject->archivalAgency->identifier->value; // Recipient org identifier id
$queryParams[] = ""; //RecipientOrgNAme
$queryParams[] = $messageObject->archivalAgreement->value; // Archival agreement reference
$queryParams[] = ""; //ReplyCode
$queryParams[] = 0; // size
$queryParams[] = ""; // Data
$queryParams[] = 1; // active
$queryParams[] = 0; // archived
$res = $this->db->query($query,$queryParams);
//var_dump($messageObject);
foreach ($messageObject->dataObjectPackage->binaryDataObject as $binaryDataObject) {
$this->insertUnitIdentifier($messageId, "res_letterbox", $binaryDataObject->id);
}
} catch (Exception $e) {
// return error
}
}
private function insertUnitIdentifier($messageId, $tableName, $resId) {
$query = ("INSERT INTO unit_identifier VALUES (?,?,?)");
$queryParams = [];
$queryParams[] = $messageId;
$queryParams[] = $tableName;
$queryParams[] = $resId;
$res = $this->db->query($query,$queryParams);
return $res;
}
}
\ No newline at end of file
<?php
/*
* Copyright 2008-2017 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'core/class/class_request.php';
class ArchiveTransfertReply {
public function __construct()
{
$this->db = new Database();
}
public function receive($fileName) {
$xml = simplexml_load_file($fileName);
$message = new stdClass();
$message->reference = $xml->MessageRequestIdentifier;
$message->status = "receive";
$message->replyCode = $xml->DataObjectPackage->ReplyCode;
$message->operationDate = (string) $xml->DataObjectPackage->GrantDate;
$message->replyReference = (string) $xml->MessageIdentifier;
$message->comment = $xml->comment;
$this->updateMessage($message);
}
private function updateMessage($message)
{
$queryParams = [];
try {
$query = ("UPDATE seda SET status = ?, reply_code = ?, operation_date = ?, reply_reference = ? WHERE reference = ?");
$queryParams[] = $message->status;
$queryParams[] = $message->replyCode;
$queryParams[] = $message->operationDate;
$queryParams[] = $message->replyReference;
$queryParams[] = $message->reference;
$this->db->query($query,$queryParams);
} catch (Exception $e) {
var_dump($e);
}
}
}
\ No newline at end of file
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of dependency xml.
*
* Dependency xml is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dependency xml is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with dependency xml. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Process DOM XML Template documents
*
* @author Cyril Vazquez <cyril.vazquez@maarch.org>
*/
class DOMTemplateProcessor
extends \DOMXPath
{
/**
* The array of parsed processing instructions
* @var array
*/
protected $parsedPis = array();
/**
* The array of parsed text instructions
* @var array
*/
protected $parsedTexts = array();
/**
* The storage of already merged nodes
* @var array
*/
protected $mergedNodes;
/**
* The storage of already merged form nodes
* @var array
*/
protected $mergedForms;
/**
* The data sources
* @var array
*/
protected $sources = array();
/**
* The variables
* @var array
*/
protected $variables = array();
/**
* Constructor
* @param DOMDocument $document
*/
public function __construct($document)
{
parent::__construct($document);
$this->xinclude();
$this->xinclude();
$this->xinclude();
$this->mergedNodes = new \SplObjectStorage();
$this->mergedForms = new \SplObjectStorage();
$this->bindVariable("_SESSION", $_SESSION);
$this->bindVariable("_SERVER", $_SERVER);
$this->bindVariable("_GET", $_GET);
$this->bindVariable("_POST", $_POST);
$this->bindVariable("_ENV", $_ENV);
$this->bindVariable("_FILES", $_FILES);
}
/**
* Process xinclude processing instructions
* @param DOMNode $node The context node. If omitted the method processes the entire document tree.
*/
protected function xinclude($node=null)
{
if ($pis = $this->query("descendant-or-self::processing-instruction('xinclude')", $node)) {
foreach ($pis as $pi) {
$includeFragment = $this->document->createDocumentFragment();
$source = file_get_contents(__DIR__.trim($pi->data));
if (!$source) {
throw new \Exception("Error including Xml fragment: fragment '$pi->data' could not be parsed");
}
$includeFragment->appendXML($source);
$pi->parentNode->replaceChild($includeFragment, $pi);
}
}
}
/**
* Bind a variable
* @param string $name The name of the variable
* @param string &$variable The reference of the value
*/
public function bindVariable($name, &$variable)
{
$this->variables[$name] = &$variable;
}
/**
* Set a source for merge
* @param string $name The name of the data source
* @param string $value The value
*/
public function setSource($name, $value)
{
$this->sources[$name] = $value;
}
/**
* Remove empty elements and attributes
* @param DOMNode $node The context node. If omitted the entire document will be processed.
*/
public function removeEmptyNodes($node=null)
{
if (!$node) {
$node = $this->document->documentElement;
}
switch($node->nodeType) {
case \XML_ELEMENT_NODE:
$childNodeList = $node->childNodes;
for ($i=0, $l=$childNodeList->length; $i<$l; $i++) {
$this->removeEmptyNodes($childNodeList->item($i));
}
$childNodeList = $node->childNodes;
if ($childNodeList->length == 0 && !$node->hasAttributes()) {
$node->parentNode->removeChild($node);
}
break;
case \XML_ATTRIBUTE_NODE:
if (empty($node->value)) {
$node->parentNode->removeChild($node);
}
break;
case \XML_TEXT_NODE:
if (ctype_space($node->nodeValue) && $node->previousSibling && $node->previousSibling->nodeType == \XML_TEXT_NODE) {
$node->nodeValue = trim($node->nodeValue);
}
break;
}
}
/* -------------------------------------------------------------------------
- MERGE processing instructions
------------------------------------------------------------------------- */
/**
* Merges the processing instructions on the given node and its chil nodes.
*
* @param string $node The context node. If omitted the entire document will be processed.
* @param string $source The data source. If omitted, all merge instruction path must be existing sources
*/
public function merge($node=null, $source=null)
{
// Avoid garbage nodes merge
if (!isset($this->mergedNodes)) {
$this->mergedNodes = new \SplObjectStorage();
}
if (!isset($this->mergedForms)) {
$this->mergedForms = new \SplObjectStorage();
}
if ($node && $this->mergedNodes->contains($node)) {
return;
}
$mergeNodes = $this->query("descendant-or-self::processing-instruction('merge') | descendant-or-self::text()[contains(., '[?merge')] | descendant-or-self::*/@*[contains(., '[?merge')]", $node);
$this->mergedObjects = array();
foreach ($mergeNodes as $i => $mergeNode) {
switch ($mergeNode->nodeType) {
case XML_PI_NODE :
if (!isset($this->parsedPis[$mergeNode->data])) {
$this->parsedPis[$mergeNode->data] = $this->parse($mergeNode->data);
}
$instr = $this->parsedPis[$mergeNode->data];
if ($merged = $this->mergePi($mergeNode, $instr, $source)) {
if ($mergeNode->parentNode) {
$mergeNode->parentNode->removeChild($mergeNode);
}
}
break;
case XML_TEXT_NODE:
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
default:
$this->mergeTextNode($mergeNode, $source);
}
}
/*$this->mergePis($node, $source);
$this->mergeTextNodes($node, $source);*/
$this->mergeForms();
if ($node) {
$this->mergedNodes->attach($node);
}
}
protected function mergePi($pi, $instr, $source=null)
{
// Get value by reference
$value = &$this->getData($instr, $source);
// Use value with selected target
if (isset($instr->params['var'])) {
$this->addVar($instr->params['var'], $value);
$pi->parentNode->removeChild($pi);
return false;
}
// Get type of value
$type = gettype($value);
//var_dump($type);
//if (isset($instr->params['source']))
// var_dump($instr->params['source']);
switch(true) {
// If value is scalar, merge text before Pi
case $type == 'string':
case $type == 'integer':
case $type == 'double':
return $this->mergeText($pi, $instr, $value);
// Value is bool, remove target sibling if false
case $type == 'boolean':
return $this->mergeBool($pi, $instr, $value);
// Value is null, no action
case $type == 'NULL':
return true;
// Value is array, merge target by iterating over array
case $type == 'array':
return $this->mergeArray($pi, $instr, $value);
case $type == 'object' :
switch (true) {
// Object merged with a form
case ($targetForm = $this->query("following-sibling::form", $pi)->item(0)) :
$this->mergedForms->attach($targetForm, array($pi, $instr, $value));
break;
// ArrayObject -> merge array
case ($value instanceof \ArrayAccess && $value instanceof \Iterator) :
return $this->mergeArray($pi, $instr, $value);
// DOMNode -> merge as xml
case $value instanceof \DOMNode :
return $this->mergeNode($pi, $instr, $value);
// If value is an object but no form : merge string version if possible
case method_exists($value, '__toString'):
return $this->mergeText($pi, $instr, (string) $value);
}
}
}
protected function addVar($name, &$var)
{
$this->variables[$name] = $var;
}
protected function mergeForms()
{
$this->mergedForms->rewind();
while ($this->mergedForms->valid()) {
$index = $this->mergedForms->key();
$targetForm = $this->mergedForms->current();
list($pi, $instr, $object) = $this->mergedForms->getInfo();
$params = $instr->params;
if (isset($params['source'])) {
$this->setSource($params['source'], $object);
}
$this->mergeObjectProperties($targetForm, $object, $params, $oname = false);
//$pi->parentNode->removeChild($pi);
$this->mergedForms->next();
}
}
protected function mergeTextNodes($node=null, $source=null)
{
$textNodes = $this->query("descendant-or-self::text()[contains(., '[?merge')] | descendant-or-self::*/@*[contains(., '[?merge')]", $node);
for ($i=0, $l=$textNodes->length; $i<$l; $i++) {
$textNode = $textNodes->item($i);
$this->mergeTextNode($textNode, $source);
}
}
protected function mergeTextNode($textNode, $source=null)
{
//$nodeXml = $this->saveXml($textNode);
$nodeValue = $textNode->nodeValue;
if (isset($this->parsedTexts[$nodeValue])) {
$instructions = $this->parsedTexts[$nodeValue];
} else {
preg_match_all("#(?<pi>\[\?merge (?<instr>(?:(?!\?\]).)*)\?\])#", $nodeValue, $pis, PREG_SET_ORDER);
$instructions = array();
foreach ($pis as $i => $pi) {
$instructions[$pi['pi']] = $this->parse($pi['instr']);
}
$this->parsedTexts[$nodeValue] = $instructions;
}
foreach ($instructions as $pi => $instr) {
$value = $this->getData($instr, $source);
if (is_scalar($value) || is_null($value) || (is_object($value) && method_exists($value, '__toString'))) {
$mergedValue = str_replace($pi, (string) $value, $textNode->nodeValue);
$mergedValue = htmlentities($mergedValue);
$textNode->nodeValue = str_replace($pi, $value, $mergedValue);
}
}
// If text is in an attribute that is empty, remove attribute
if ($textNode->nodeType == XML_ATTRIBUTE_NODE && empty($textNode->value)) {
$textNode->parentNode->removeAttribute($textNode->name);
}
}
protected function mergeText($pi, $instr, $value)
{
$params = $instr->params;
switch(true) {
case isset($params['attr']):
if (!$targetNode = $this->query("following-sibling::*", $pi)->item(0)) {
return true;
}
$targetNode->setAttribute($params['attr'], $value);
break;
case isset($params['render']):
if (!$params['render']) {
$fragment = $value;
} else {
$fragment = $params['render'];
}
if (!isset($this->fragments[$fragment])) {
return true;
}
$targetNode = $this->fragments[$fragment]->cloneNode(true);
$this->merge($targetNode);
$pi->parentNode->insertBefore($targetNode, $pi);
break;
default:
$targetNode = $this->document->createTextNode($value);
$pi->parentNode->insertBefore($targetNode, $pi);
}
return true;
}
protected function mergeArray($pi, $instr, &$array)
{
$params = $instr->params;
if (isset($params['include'])) {
$filename = $params['include'];
$source = file_get_contents($filename);
$targetNode = $this->document->createDocumentFragment();
$targetNode->appendXML($source);
} elseif (!$targetNode = $this->query("following-sibling::*", $pi)->item(0)) {
return true;
}
reset($array);
if ($count = count($array)) {
$i=0;
while ($i<$count) {
//do {
$itemNode = $targetNode->cloneNode(true);
$itemData = current($array);
if (isset($params['source'])) {
$this->setSource($params['source'], $itemData);
}
$this->merge($itemNode, $itemData);
$pi->parentNode->insertBefore($itemNode, $pi);
@next($array);
$i++;
/*} while (
@next($array) !== false
);*/
}
}
// Remove targetNode (row template)
if ($targetNode->parentNode) {
$targetNode = $targetNode->parentNode->removeChild($targetNode);
}
// Add to mergedNodes to prevent other calls to merge
$this->mergedNodes->attach($targetNode);
return true;
}
protected function mergeObject($pi, $instr, $object)
{
$params = $instr->params;
if (!$targetNode = $this->query("following-sibling::*", $pi)->item(0)) {
return true;
}
if (isset($params['source'])) {
$this->setSource($params['source'], $object);
}
$this->mergeObjectProperties($targetNode, $object, $params, $oname = false);
return true;
}
protected function mergeObjectProperties($targetNode, $object, $params, $oname=false)
{
foreach ($object as $pname => $pvalue) {
if ($oname) {
$pname = $oname . "." . $pname;
}
//var_dump("merge $pname");
if (is_scalar($pvalue) || (is_object($pvalue) && method_exists($pvalue, '__toString'))) {
$this->mergeObjectProperty($targetNode, $pvalue, $params, $pname);
}
/*elseif (is_object($pvalue))
$this->mergeObjectProperties($targetNode, $pvalue, $params, $pname);
elseif (is_array($pvalue))
foreach ($pvalue as $key => $item)
$this->mergeObjectProperties($targetNode, $pvalue, $params, $pname . "[$key]");*/
}
}
protected function mergeObjectProperty($targetNode, $value, $params, $name)
{
$elements = $this->query("descendant-or-self::*[@name='$name']", $targetNode);
for ($i=0, $l=$elements->length; $i<$l; $i++) {
$element = $elements->item($i);
switch (strtolower($element->nodeName)) {
// Form Input
case 'input':
switch($element->getAttribute('type')) {
case 'checkbox':
if (is_bool($value)) {
if ($value) {
$element->setAttribute('checked', 'true');
} else {
$element->removeAttribute('checked');
}
} else {
if ($element->getAttribute('value') == $value) {
$element->setAttribute('checked', 'true');
} else {
$element->removeAttribute('checked');
}
}
break;
case 'radio':
if ($element->getAttribute('value') == $value) {
$element->setAttribute('checked', 'true');
} else {
$element->removeAttribute('checked');
}
break;
default:
$element->setAttribute('value', $value);
}
break;
// Select
case 'select':
$value = $this->quote($value);
if ($option = $this->query(".//option[@value=".$value."]", $element)->item(0)) {
$option->setAttribute('selected', 'true');
if ($optGroup = $this->query("parent::optgroup", $option)->item(0)) {
$optGroup->removeAttribute('disabled');
}
}
break;
// Textareas
case 'textarea':
$element->nodeValue = $value;
break;
}
}
}
/**
* Merge a boolean
* @param DOMNode $pi
* @param string $instr
* @param boolean $bool
*
* @return bool
*/
protected function mergeBool($pi, $instr, $bool)
{
$params = $instr->params;
if (isset($params['include'])) {
$res = $params['include'];
$targetNode = $this->document->createDocumentFragment();
} elseif (!$targetNode = $this->query("following-sibling::*", $pi)->item(0)) {
return true;
}
if (isset($params['attr'])) {
if ($bool == false) {
$targetNode->removeAttribute($params['attr']);
} else {
$targetNode->setAttribute($params['attr'], $params['attr']);
}
} else {
if (isset($params['source'])) {
$this->setSource($params['source'], $bool);
}
if ($bool == false) {
if ($targetNode->parentNode) {
$parentNode = $targetNode->parentNode;
$targetNode = $parentNode->removeChild($targetNode);
}
// Add to mergedNodes to prevent other calls to merge
$this->mergedNodes->attach($targetNode);
}
}
return true;
}
/**
* Merge a node
* @param DOMNode $pi
* @param string $instr
* @param DOMNode $DOMNode
*
* @return bool
*/
public function mergeNode($pi, $instr, $DOMNode)
{
$pi->parentNode->insertBefore($DOMNode, $pi);
return true;
}
/* ------------------------------------------------------------------------
Data sources management
------------------------------------------------------------------------ */
protected function &getData($instr, $source=null)
{
//var_dump("getData");
//var_dump($instr);
//var_dump($source);
$value = null;
$steps = $instr->source;
// First step defines source
$type = $steps[0][0];
switch($type) {
case 'arg':
$value = &$source;
break;
case 'source':
$name = $steps[0][1];
if (isset($this->sources[$name])) {
$value = &$this->sources[$name];
} elseif (is_scalar($name)) {
if ($name[0] == '"' || $name[0] == "'") {
$value = substr($name, 1, -1);
} elseif (is_numeric($name)) {
$value = $name;
}
}
break;
case 'var':
$name = $steps[0][1];
if (isset($this->variables[$name])) {
$value = &$this->variables[$name];
}
break;
case 'method':
$route = $steps[0][1];
$methodRouter = new \core\Route\MethodRouter($route);
$serviceObject = $methodRouter->service->newInstance();
break;
}
for ($i=1, $l=count($steps); $i<$l; $i++) {
$value = &$this->stepData($steps[$i], $value);
}
return $value;
}
protected function &stepData($step, $source)
{
//var_dump("stepData");
//var_dump($step);
//var_dump("from " . gettype($source));
$value = null;
switch($step[0]) {
case 'func':
$value = &$this->stepFunc($step[1], $step[2], $source);
break;
case 'offset':
$key = &$this->getParamValue($step[1], $source);
if (is_array($source) && isset($source[$key])) {
$value = &$source[$key];
}
break;
case 'prop':
if (isset($source->{$step[1]})) {
$value = &$source->{$step[1]};
}
break;
}
return $value;
}
protected function &stepFunc($name, $params=array(), $source=null)
{
$value = null;
foreach ($params as $i => $param) {
$params[$i] = &$this->getParamValue($param, $source);
}
if (is_object($source) && method_exists($source, $name)) {
$value = call_user_func_array(array($source, $name), $params);
return $value;
}
//var_dump($params);
switch($name) {
// Callback functions
case 'func':
$func = $params[0];
if (!isset($this->functions[$func])) {
break;
}
$callback = $this->functions[$func];
array_unshift($params, $source);
array_unshift($params, $this);
$value = @call_user_func_array($callback, $params);
break;
// Array functions
case 'length':
case 'count':
$value = @count($source);
break;
case 'key':
$value = @key($source);
break;
case 'current':
$value = @current($source);
break;
case 'first':
$value = @reset($source);
break;
case 'next':
$value = @next($source);
break;
case 'prev':
$value = @prev($source);
break;
case 'end':
$value = @end($source);
break;
case 'pos':
$pos = null;
foreach ((array) $source as $key => $value) {
$pos++;
if ($key == @key($source)) {
break;
}
}
if (!is_null($pos)) {
$value = $pos;
}
break;
case 'islast':
$value = ((@key($source)+1) == @count($source));
break;
case 'slice':
$value = @array_slice($source, $params[0], $params[1]);
break;
case 'arraykeyexists':
$value = @array_key_exists($params[0], $source);
break;
case 'inarray':
$value = @in_array($params[0], $source);
break;
// Variable functions
case 'type':
$value = @gettype($source);
break;
case 'not':
$value = @!$source;
break;
case 'empty':
$value = @empty($source);
break;
case 'isset':
$value = @isset($source);
break;
case 'isarray':
$value = @is_array($source);
break;
case 'isbool':
$value = @is_bool($source);
break;
case 'isfloat':
case 'isdouble':
case 'isreal':
$value = @is_float($source);
break;
case 'isint':
case 'isinteger':
case 'islong':
$value = @is_int($source);
break;
case 'isnull':
$value = @is_null($source);
break;
case 'isnotnull':
$value = @!is_null($source);
break;
case 'isnumeric':
$value = @is_numeric($source);
break;
case 'isobject':
$value = @is_object($source);
break;
case 'isscalar':
$value = @is_scalar($source);
break;
case 'isstring':
$value = @is_string($source);
break;
case 'int':
$value = @intval($source);
break;
case 'float':
$value = @floatval($source);
break;
case 'string':
$value = @strval($source);
break;
case 'bool':
$value = @(bool) $source;
break;
case 'array':
if (!is_array($source)) {
if (is_null($source)) {
$value = [];
} else {
$value = [$source];
}
} else {
$value = $source;
}
break;
case 'attr':
if (isset($source->{$params[0]})) {
$value = @$source->{$params[0]};
}
break;
case 'in':
$value = false;
$i = 0;
while (isset($params[$i])) {
$value = $value || $source == $params[$i];
$i++;
}
break;
case 'between':
if (isset($params[2]) && $params[2]) {
$value = ($source > $params[0] && $source < $params[1]);
} else {
$value = ($source >= $params[0] && $source <= $params[1]);
}
break;
case 'ifeq':
$value = ($source == $params[0]);
break;
case 'ifne':
$value = ($source != $params[0]);
break;
case 'ifgt':
$value = ($source > $params[0]);
break;
case 'ifgte':
$value = ($source >= $params[0]);
break;
case 'iflt':
$value = ($source < $params[0]);
break;
case 'iflte':
$value = ($source <= $params[0]);
break;
case 'contains':
$value = (strpos($source, $params[0]) !== false);
break;
case 'starts-with':
$value = (strpos($source, $params[0]) === 0);
break;
case 'ends-with':
$value = (strrpos($source, $params[0]) === (strlen($source) - strlen($params[0]) + 1));
break;
case 'bit':
$value = ($source & (int) $params[0]) > 0;
break;
case 'then':
if ($source) {
$value = $params[0];
} elseif (isset($params[1])) {
$value = $params[1];
}
break;
case 'coalesce':
if (is_null($source)) {
$value = $params[0];
} else {
$value = $source;
}
break;
// String functions
case 'format':
case 'fmt':
$value = @sprintf($params[0], $source);
break;
case 'match':
$value = (bool) @preg_match($params[0], $source);
break;
case 'upper':
$value = @strtoupper($source);
break;
case 'lower':
$value = @strtolower($source);
break;
case 'ucfirst':
$value = @ucfirst($source);
break;
case 'lcfirst':
$value = @lcfirst($source);
break;
case 'ucwords':
$value = @ucwords($source);
break;
case 'split':
case 'explode':
$value = @explode($params[0], $source);
break;
case 'substr':
if (isset($params[1])) {
$value = @substr($source, $params[0], $params[1]);
} else {
$value = @substr($source, $params[0]);
}
break;
case 'join':
case 'implode':
$value = @implode($params[0], $source);
break;
case 'constant':
$value = @constant($source);
if (is_null($value) && $params[0]) {
$value = $source;
}
break;
case 'print':
$value = @print_r($source, true);
break;
case 'json':
if (isset($params[0])) {
$options = \JSON_PRETTY_PRINT;
} else {
$options = 0;
}
$value = @json_encode($source, $options);
break;
case 'parse':
if (isset($params[0])) {
$value = @json_decode($source, $params[0]);
} else {
$value = @json_decode($source);
}
break;
case 'encodehtml':
$value = @htmlentities($source);
break;
case 'decodehtml':
$value = @html_entity_decode($source);
break;
case 'base64':
$value = @base64_encode($source);
break;
case 'cat':
$value = @implode($params);
break;
case 'dump':
ob_start();
var_dump($source);
$value = @ob_get_clean();
break;
case 'translate':
if (is_string($source) && $this->translator) {
$catalog = null;
if (isset($params[0])) {
$catalog = $params[0];
}
$context = null;
if (isset($params[1])) {
$context = $params[1];
}
$value = $this->translator->getText($source, $context, $catalog);
} else {
$value = $source;
}
break;
// Number functions
case 'add':
$value = @($source + $params[0]);
break;
case 'mul':
$value = @($source * $params[0]);
break;
case 'div':
$value = @($source / $params[0]);
break;
case 'mod':
$value = @($source % $params[0]);
break;
}
return $value;
}
protected function &getParamValue($param, $source=null)
{
if ($param[0] == "'" || $param[0] == '"') {
$value = substr($param, 1, -1);
} elseif (is_numeric($param)) {
$value = $param;
} else {
$instr = $this->parse($param);
$value = &$this->getData($instr, $source);
}
return $value;
}
/* ------------------------------------------------------------------------
Merge instructions parser
------------------------------------------------------------------------ */
protected function parse($instructionString, $sep=" ")
{
$args = $this->explode(trim($instructionString), $sep);
if (!count($args)) {
throw new \Exception("Invalid Template instruction : no main argument provided in $instructionString");
}
$parser = new \StdClass();
$parser->path = array_shift($args);
$parser->source = $this->getSource($parser->path);
$parser->params = array();
if (!count($args)) {
return $parser;
}
foreach ($args as $arg) {
if (preg_match('#^(?<name>\w+)\s*(=(["\'])(?<value>(?:[^\3\\\\]|\\\\.)*)\3)$#', $arg, $pair)) {
$parser->params[$pair['name']] = isset($pair['value']) ? $pair['value'] : null;
} elseif ($arg[0]=="@") {
$parser->params["attr"] = substr($arg, 1);
} elseif ($arg[0]=="$") {
$parser->params["var"] = substr($arg, 1);
} elseif ($arg[0]=="/") {
$parser->params["include"] = substr($arg, 1);
} else {
$parser->params["source"] = $arg;
}
}
return $parser;
}
protected function getSource($data)
{
$source = array();
$steps = $this->tokenize($data);
for ($i=0, $l=count($steps); $i<$l; $i++) {
$step = $steps[$i];
switch(true) {
case $step == "" :
case $step == false :
if ($i == 0) {
$source[] = array('arg', '');
} else {
unset($step);
}
break;
//case $step[0] == ".":
// $source[] = array('prop', substr($step, 1));
// break;
case preg_match('#^\$(?<name>.*)$#', $step, $var):
$source[] = array('var', $var['name']);
break;
case preg_match('#^(?<ext>\w+):(?<name>.*)$#', $step, $ext):
$source[] = array($ext['ext'], $ext['name']);
break;
case preg_match('#^(?<name>[^(\/]+)\((?<params>.*)?\)$#', $step, $func) :
$params = $this->explode($func['params'], ",");
$source[] = array('func', $func['name'], $params);
break;
case preg_match('#^\[(?<name>(?<enc>["\'])?[^\2]*\2?)\]$#', $step, $offset):
$source[] = array('offset', $offset['name']);
break;
case preg_match('#^\/(?<name>[^(]+)\((?<params>.*)?\)$#', $step, $method) :
$params = $this->explode($method['params'], ",");
$source[] = array('method', $method['name'], $params);
break;
default:
if ($i==0) {
$source[] = array('source', $step);
} else {
$source[] = array('prop', $step);
}
}
}
return $source;
}
protected function explode($str, $sep)
{
$l = strlen($str);
$o = 0;
$esc = false;
$sq = false;
$dq = false;
$br = 0;
$sbr = 0;
$tok = array();
for ($i=0; $i<$l; $i++) {
// Add token if separator found out of enclosures and brackets
if ($str[$i] == $sep && !$dq && !$sq && !$br && !$sbr) {
$tok[] = trim(substr($str, $o, $i-$o));
$o = $i+1;
continue;
}
// Ignore character if escaped
if ($esc) {
$esc = false;
continue;
}
// Special characters that affect parsing
switch($str[$i]) {
case "'":
if (!$sq) $sq = true;
else $sq = false;
break;
case '"':
if (!$dq) $dq = true;
else $dq = false;
break;
case '(':
if (!$sq && !$dq) $br++;
break;
case ')':
if (!$sq && !$dq) $br--;
break;
case '[':
if (!$sq && !$dq) $sbr++;
break;
case ']':
if (!$sq && !$dq) $sbr--;
break;
case '\\':
$esc = true;
break;
}
}
$tail = trim(substr($str, $o, $i-$o));
if ($tail !== "") {
$tok[] = $tail;
}
if ($sq || $dq || $br || $sbr || $esc) {
throw new \Exception("Invalid string: unexpected end of string at offset $i");
}
return $tok;
}
protected function tokenize($str)
{
$l = strlen($str);
$o = 0;
$esc = false;
$sq = false;
$dq = false;
$br = 0;
$sbr = false;
$steps = array();
$step = false;
// Function
for ($i=0; $i<$l; $i++) {
// Tokenize only of out of enclosures
if (!$dq && !$sq && !$br) {
// Add token if dot found
if ($str[$i] == ".") {
$steps[] = trim(substr($str, $o, $i-$o));
$o = $i+1;
continue;
}
// Add token if opening square bracket
if ($str[$i] == "[") {
$steps[] = trim(substr($str, $o, $i-$o));
$o = $i+1;
$sbr = true;
continue;
}
// Add token enclosed by square brackets
if ($str[$i] == "]" && $sbr) {
$steps[] = trim(substr($str, $o-1, $i-$o+2));
$o = $i+1;
$sbr = false;
continue;
}
}
// Ignore character if escaped
if ($esc) {
$esc = false;
continue;
}
// Special characters that affect parsing
switch($str[$i]) {
case "'":
if (!$sq) $sq = true;
else $sq = false;
break;
case '"':
if (!$dq) $dq = true;
else $dq = false;
break;
case '(':
if (!$sq && !$dq) $br++;
break;
case ')':
if (!$sq && !$dq) $br--;
break;
case '\\':
$esc = true;
break;
}
}
$tail = trim(substr($str, $o, $i-$o));
if ($tail !== false)
$steps[] = $tail;
if ($sq || $dq || $br || $sbr || $esc)
throw new \Exception("Invalid string: unexpected end of string at offset $i");
return $steps;
}
}
\ No newline at end of file
require_once __DIR__.'/DOMTemplateProcessor.php';
$DOMTemplate = new DOMDocument();$DOMTemplate->load(__DIR__.'/test.xml');$DOMTemplateProcessor = new DOMTemplateProcessor($DOMTemplate);$DOMTemplateProcessor->setSource('bar', 'bazbull');$DOMTemplateProcessor->merge();$xml = $DOMTemplate->saveXML();
\ No newline at end of file
<?php
/*
* Copyright 2008-2017 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
require_once __DIR__.'/ArchiveTransferReply.php';
require_once __DIR__.'/ArchiveTransfer.php';
require_once __DIR__.'/Acknowledgement.php';
// Args
//ARCHIVE TRANSFER
//$listResId = ['100','101','102'];
//$archiveTransfer = new ArchiveTransfer();
//$message = $archiveTransfer->receive($listResId);
//$archiveTransfer->sendXml($message);
// ACKNOWLEDGEMENT
//$acknowledgement = new Acknowledgement();
//$acknowledgement->send(__DIR__. DIRECTORY_SEPARATOR ."seda2". DIRECTORY_SEPARATOR . $message->messageIdentifier->value .".xml");
//ARCHIVE TRANSFER REPLY
/*
$archiveTransferReply = new ArchiveTransfertReply();
$archiveTransferReply->receive(__DIR__. DIRECTORY_SEPARATOR ."seda2". DIRECTORY_SEPARATOR . "bblier-20170216-163047_reply.xml");
*/
\ No newline at end of file
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Export seda Action
* @author dev@maarch.org
* @ingroup export_seda
*/
/**
* $confirm bool true
*/
$confirm = true;
/**
* $etapes array Contains only one etap, the status modification
*/
$etapes = array('export');
function manage_export($arr_id, $history, $id_action, $label_action, $status)
{
// récupérer l'entité racine du courrier
// récupérer transferring_agency et archival_agreement
// récupérer la duration et retention_rule du type de doc du courrier
// appel fonction de transfert et génération bdx
// historisation du transfert
// modification statut -> fait automatiquement par mécanique bannette
// ensuite il y a aura une suppression logique des documents et des contacts (si plus de courriers associés)
for($i=0; $i<count($arr_id);$i++)
{
$result .= $arr_id[$i].'#';
//$db->query("UPDATE ".$ext_table. " SET closing_date = CURRENT_TIMESTAMP WHERE res_id = ?", array($arr_id[$i]));
}
return array('result' => $result, 'history_msg' => '');
}
<?php
if (!defined("_EXPORT_SEDA_COMMENT"))
define("_EXPORT_SEDA_COMMENT", "SEDA export");
if (!defined("_EXPORT_SEDA"))
define("_EXPORT_SEDA", "SEDA export");
if (!defined("_EXPORT_SEDA_VIEW"))
define("_EXPORT_SEDA_VIEW", "See SEDA export");
<?php
if (!defined("_EXPORT_SEDA_COMMENT"))
define("_EXPORT_SEDA_COMMENT", "Export SEDA");
if (!defined("_EXPORT_SEDA"))
define("_EXPORT_SEDA", "Export SEDA");
if (!defined("_EXPORT_SEDA_VIEW"))
define("_EXPORT_SEDA_VIEW", "Voir le bordereau SEDA");
<?merge $abstractRule.rule ?><Rule><?merge .value ?></Rule>
<?merge $abstractRule.startDate ?><StartDate><?merge . ?></StartDate>
<PreventInheritance><?merge $abstractRule.preventInheritance ?></PreventInheritance>
<RefNonRuleId><?merge $abstractRule.refNonRuleId ?></RefNonRuleId>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Acknowledgement xmlns="fr:gouv:culture:archivesdefrance:seda:v2.0">
<?merge Acknowledgement.comment ?><Comment><?merge .value ?></Comment>
<Date><?merge Acknowledgement.date ?></Date>
<MessagIdentifier><?merge Acknowledgement.messageIdentifier ?></MessagIdentifier>
<Signature><?merge Acknowledgement.signature ?></Signature>
<MessageReceivedIdentifier><?merge Acknowledgement.messageReceivedIdentifier ?></MessageReceivedIdentifier>
<Sender><?merge Acknowledgement.sender ?></Sender>
<Receiver><?merge Acknowledgement.receiver ?></Receiver>
</Acknowledgement>
\ No newline at end of file
<?merge $agent.firstName.bool() ?><FirstName><?merge $agent.firstName ?></FirstName>
<?merge $agent.birthName.bool() ?><BirthName><?merge $agent.birthName ?></BirthName>
<?merge $agent.givenName.bool() ?><GivenName><?merge $agent.givenName ?></GivenName>
<?merge $agent.gender.bool() ?><Gender><?merge $agent.gender ?></Gender>
<?merge $agent.birthDate.bool() ?><BirthDate><?merge $agent.birthDate ?></BirthDate>
<?merge $agent.birthPlace.bool() ?><BirthPlace><?merge $agent.birthPlace ?></BirthPlace>
<?merge $agent.deathDate.bool() ?><DeathDate><?merge $agent.deathDate ?></DeathDate>
<?merge $agent.deathPlace.bool() ?><DeathPlace><?merge $agent.deathPlace ?></DeathPlace>
<?merge $agent.nationality.bool() ?><Nationality><?merge $agent.nationality ?></Nationality>
<?merge $agent.function.bool() ?><Function><?merge $agent.function ?></Function>
<?merge $agent.activity.bool() ?><Activity><?merge $agent.activity ?></Activity>
<?merge $agent.position.bool() ?><Position><?merge $agent.position ?></Position>
<?merge $agent.role.bool() ?><Role><?merge $agent.role ?></Role>
<?merge $agent.corpname.bool() ?><CorpName><?merge $agent.corpname ?></CorpName>
<?merge $agent.identifier.bool() ?><Identifier><?merge $agent.identifier ?></Identifier>
\ No newline at end of file
<ArchivalAgreement schemeID="[?merge $archivalAgreement.schemeID ?]" schemeName="[?merge $archivalAgreement.schemeName ?]" schemeAgencyID="[?merge $archivalAgreement.schemeAgencyID ?]" schemeAgencyName="[?merge $archivalAgreement.schemeAgencyName ?]" schemeVersionID="[?merge $archivalAgreement.schemeVersionID ?]" schemeDataURI="[?merge $archivalAgreement.schemeDataURI ?]" schemeURI="[?merge $archivalAgreement.schemeURI ?]"><?merge $archivalAgreement.value ?></ArchivalAgreement>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<ArchiveTransfer xmlns="fr:gouv:culture:archivesdefrance:seda:v2.0">
<?merge ArchiveTransfer.comment ?><Comment><?merge .value ?></Comment>
<Date><?merge ArchiveTransfer.date ?></Date>
<?merge ArchiveTransfer.messageIdentifier $messageIdentifier ?><?xinclude /resources/MessageIdentifier.xml ?>
<?merge ArchiveTransfer.archivalAgreement $archivalAgreement ?><?xinclude /resources/ArchivalAgreement.xml ?>
<?xinclude /resources/CodeListVersions.xml ?>
<?merge ArchiveTransfer.dataObjectPackage $dataObjectPackage ?>
<?xinclude /resources/DataObjectPackage.xml ?>
<ArchivalAgency>
<?merge ArchiveTransfer.archivalAgency $organization ?>
<?xinclude /resources/Organization.xml ?>
</ArchivalAgency>
<TransferringAgency>
<?merge ArchiveTransfer.transferringAgency $organization ?>
<?xinclude /resources/Organization.xml ?>
</TransferringAgency>
</ArchiveTransfer>
\ No newline at end of file
<?merge $archiveUnit ?>
<ArchiveUnit>
<ArchiveUnitRefId><?merge .archiveUnitRefId ?></ArchiveUnitRefId>
<ArchiveUnitProfile schemeID="[?merge .archiveUnitProfile.schemeID ?]" schemeName="[?merge .archiveUnitProfile.schemeName ?]" schemeAgencyID="[?merge .archiveUnitProfile.schemeAgencyID ?]" schemeAgencyName="[?merge .archiveUnitProfile.schemeAgencyName ?]" schemeVersionID="[?merge .archiveUnitProfile.schemeVersionID ?]" schemeDataURI="[?merge .archiveUnitProfile.schemeDataURI ?]" schemeURI="[?merge .archiveUnitProfile.schemeURI ?]"><?merge .archiveUnitProfile ?></ArchiveUnitProfile>
<?merge .management.bool() ?>
<Management>
<StorageRule>
<?merge .management.storageRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
<FinalAction><?merge .management.storageRule.finalAction ?></FinalAction>
</StorageRule>
<AppraisalRule>
<?merge .management.appraisalRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
<FinalAction><?merge .management.appraisalRule.finalAction ?></FinalAction>
</AppraisalRule>
<AccessRule>
<?merge .management.accessRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
</AccessRule>
<DisseminationRule>
<?merge .management.disseminationRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
</DisseminationRule>
<ReuseRule>
<?merge .management.reuseRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
</ReuseRule>
<ClassificationRule>
<?merge .management.classificationRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
<ClassificationLevel><?merge .management.classificationRule.classificationLevel ?></ClassificationLevel>
<ClassificationOwner><?merge .management.classificationRule.classificationOwner ?></ClassificationOwner>
<ClassificationReassessingDate><?merge .management.classificationRule.classificationReassessingDate ?></ClassificationReassessingDate>
<NeedReassessingAuthorization><?merge .management.classificationRule.needReassessingAuthorization ?></NeedReassessingAuthorization>
</ClassificationRule>
<NeedAuthorization>
<?merge .management.needAuthorization ?>
</NeedAuthorization>
<OtherManagementAbstract>
<?merge .management.otherManagementAbstract ?>
</OtherManagementAbstract>
</Management>
<?merge .content.bool() ?>
<Content>
<DescriptionLevel listVersionID="[?merge .descriptionLevel ?]"><?merge .content.descriptionLevel ?></DescriptionLevel>
<?merge .content.title ?><Title><?merge . ?></Title>
<?merge .content.filePlanPosition ?><FilePlanPosition schemeID="[?merge .schemeID @schemeID ?]" schemeName="[?merge .schemeName @schemeName ?]" schemeAgencyID="[?merge .schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .schemeURI @schemeURI ?]"><?merge .value ?></FilePlanPosition>
<OriginatingAgencyArchiveIdentifier><?merge .content.originatingAgencyArchiveIdentifier ?></OriginatingAgencyArchiveIdentifier>
<?merge .content.description.bool() ?><Description><?merge .content.description ?></Description>
<?merge .content.custodialHistory.bool() ?><CustodialHistory>
<?merge .content.custodialHistory.custodialHistoryItem ?>
<CustodialHistoryItem when="[?merge .when ?]"><?merge .value ?></CustodialHistoryItem>
</CustodialHistory>
<Type><?merge .content.type ?></Type>
<DocumentType><?merge .content.documentType ?></DocumentType>
<Language><?merge .content.language ?></Language>
<DescriptionLanguage><?merge .content.descriptionLanguage ?></DescriptionLanguage>
<Status><?merge .content.status ?></Status>
<Version><?merge .content.version ?></Version>
<?merge .content.tag ?><Tag><?merge .value ?></Tag>
<?merge .content.keyword ?><Keyword>
<KeywordContent role="[?merge .keywordContent.role @role ?]"><?merge .keywordContent.value ?></KeywordContent>
<KeywordReference schemeID="[?merge .keywordReference.schemeID @schemeID ?]" schemeName="[?merge .keywordReference.schemeName @schemeName ?]" schemeAgencyID="[?merge .keywordReference.schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .keywordReference.schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .keywordReference.schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .keywordReference.schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .keywordReference.schemeURI @schemeURI ?]"><?merge .keywordReference.value ?></KeywordReference>
<KeywordType listVersionID="[?merge .keywordType.listVersionID @listVersionID ?]"><?merge .keywordType ?></KeywordType>
</Keyword>
<Coverage>
<SpatialCoverage><?merge .content.spatialCoverage ?></SpatialCoverage>
<TemporalCoverage><?merge .content.temporalCoverage ?></TemporalCoverage>
<JuridicationalCoverage><?merge .content.juridictionalCoverage ?></JuridicationalCoverage>
</Coverage>
<?merge .content.originatingAgency.bool() ?>
<OriginatingAgency>
<?merge .content.originatingAgency $organization ?>
<?xinclude /resources/Organization.xml ?>
</OriginatingAgency>
<?merge .content.submissionAgency.bool() ?>
<SubmissionAgency>
<?merge .content.submissionAgency $organization ?>
<?xinclude /resources/Organization.xml ?>
</SubmissionAgency>
<?merge .content.authorizedAgend.bool() ?>
<AuthorizedAgent>
<?merge .authorizedAgent $agent ?>
<?xinclude /resources/Agent.xml ?>
</AuthorizedAgent>
<?merge .content.writter.array() ?>
<Writter>
<?merge . $agent ?>
<?xinclude /resources/Agent.xml ?>
</Writter>
<?merge .content.addressee.array()?>
<Addressee>
<?merge . $agent ?>
<?xinclude /resources/Agent.xml ?>
</Addressee>
<?merge .content.recipient.array() ?>
<Recipient>
<?merge . $agent ?>
<?xinclude /resources/Agent.xml ?>
</Recipient>
<Source><?merge .content.source ?></Source>
<CreatedDate><?merge .content.createdDate ?></CreatedDate>
<TransactedDate><?merge .content.transactedDate ?></TransactedDate>
<AcquiredDate><?merge .content.acquiredDate ?></AcquiredDate>
<SentDate><?merge .content.sentDate ?></SentDate>
<ReceivedDate><?merge .content.receivedDate ?></ReceivedDate>
<RegisteredDate><?merge .content.registeredDate ?></RegisteredDate>
<StartDate><?merge .content.startDate ?></StartDate>
<EndDate><?merge .content.endDate ?></EndDate>
<?merge .content.event ?>
<Event>
<EventIdentifier><?merge .eventIdentifier ?></EventIdentifier>
<EventType><?merge .eventType ?></EventType>
<EventDateTime><?merge .eventDateTime ?></EventDateTime>
<EventDetail><?merge .eventDetail ?></EventDetail>
</Event>
</Content>
<?merge .content.archiveUnit /resources/ArchiveUnit.xml?>
<?merge .dataObjectReference.bool() ?>
<DataObjectReference>
<?merge .dataObjectReference.dataObjectReferenceId.bool() ?>
<DataObjectReferenceId><?merge .dataObjectReference.dataObjectReferenceId ?></DataObjectReferenceId>
<?merge .dataObjectReference.dataObjectGroupReferenceId.bool() ?>
<DataObjectGroupReferenceId><?merge .dataObjectReference.dataObjectGroupReferenceId ?></DataObjectGroupReferenceId>
</DataObjectReference>
</ArchiveUnit>
\ No newline at end of file
<CodeListVersions>
<ReplyCodeListVersion > </ReplyCodeListVersion>
<MessageDigestAlgorithmCodeListVersion > </MessageDigestAlgorithmCodeListVersion>
<MimeTypeCodeListVersion > </MimeTypeCodeListVersion>
<EncodingCodeListVersion > </EncodingCodeListVersion>
<FileFormatCodeListVersion > </FileFormatCodeListVersion>
<CompressionAlgorithmCodeListVersion > </CompressionAlgorithmCodeListVersion>
<DataObjectVersionCodeListVersion > </DataObjectVersionCodeListVersion>
<StorageRuleCodeListVersion > </StorageRuleCodeListVersion>
<AppraisalRuleCodeListVersion > </AppraisalRuleCodeListVersion>
<AccessRuleCodeListVersion > </AccessRuleCodeListVersion>
<DisseminationRuleCodeListVersion > </DisseminationRuleCodeListVersion>
<ReuseRuleCodeListVersion > </ReuseRuleCodeListVersion>
<ClassificationRuleCodeListVersion > </ClassificationRuleCodeListVersion>
<AuthorizationReasonCodeListVersion ></AuthorizationReasonCodeListVersion>
<RelationshipCodeListVersion ></RelationshipCodeListVersion>
<OtherCodeListAbstract ></OtherCodeListAbstract>
</CodeListVersions>
<DataObjectPackage>
<?merge $dataObjectPackage.binaryDataObject ?>
<BinaryDataObject id="[?merge .id ?]">
<Attachment filename="[?merge .attachment.filename ?]"/>
<Uri><?merge .uri ?></Uri>
<MessageDigest algorithm="[?merge .messageDigest.algorithm ?]"><?merge .messageDigest.value ?></MessageDigest>
<Size><?merge .size.value ?></Size>
<FormatIdentification>
<MimeType><?merge .formatIdentification.mimeType ?></MimeType>
<FormatId><?merge .formatIdentification.formatId ?></FormatId>
</FormatIdentification>
<?merge .fileInfo.bool() ?>
<FileInfo>
<Filename><?merge .fileInfo.filename ?></Filename>
</FileInfo>
</BinaryDataObject>
<?merge $dataObjectPackage.physicalDataObject ?>
<PhysicalDataObject>
<?merge .bool() ?>
<PhysicalId schemeID="[?merge .physicalId.schemeID ?]" schemeName="[?merge .physicalId.schemeName ?]" schemeAgencyID="[?merge .physicalId.schemeAgencyID ?]" schemeAgencyName="[?merge .physicalId.schemeAgencyName ?]" schemeVersionID="[?merge .physicalId.schemeVersionID ?]" schemeDataURI="[?merge .physicalId.schemeDataURI ?]" schemeURI="[?merge .physicalId.schemeURI ?]"><?merge .physicalId.value ?></PhysicalId>
</PhysicalDataObject>
<DescriptiveMetadata>
<?merge $dataObjectPackage.descriptiveMetadata.archiveUnit $archiveUnit?>
<?xinclude /resources/ArchiveUnit.xml ?>
</DescriptiveMetadata>
<?merge $dataObjectPackage.managementMetadata $managementMetadata ?>
<?xinclude /resources/ManagementMetadata.xml ?>
</DataObjectPackage>
\ No newline at end of file
<ManagementMetadata>
<?merge $managementMetadata.archivalProfile.bool() ?><ArchivalProfile><?merge $managementMetadata.archivalProfile.value ?></ArchivalProfile>
<?merge $managementMetadata.serviceLevel.bool() ?><ServiceLevel><?merge $managementMetadata.serviceLevel.value ?></ServiceLevel>
<?merge $managementMetadata.storageRule.bool() ?>
<StorageRule>
<?merge $managementMetadata.storageRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
<FinalAction><?merge $managementMetadata.storageRule.finalAction ?></FinalAction>
</StorageRule>
<?merge $managementMetadata.appraisalRule.bool() ?>
<AppraisalRule>
<?merge $managementMetadata.appraisalRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
<FinalAction><?merge $managementMetadata.appraisalRule.finalAction ?></FinalAction>
</AppraisalRule>
<?merge $managementMetadata.accessRule.bool() ?>
<AccessRule>
<?merge $managementMetadata.accessRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
</AccessRule>
<?merge $managementMetadata.disseminationRule.bool() ?>
<DisseminationRule>
<?merge $managementMetadata.disseminationRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
</DisseminationRule>
<?merge $managementMetadata.reuseRule.bool() ?>
<ReuseRule>
<?merge $managementMetadata.reuseRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
</ReuseRule>
<?merge $managementMetadata.classificationRule.bool() ?>
<ClassificationRule>
<?merge $managementMetadata.classificationRule $abstractRule ?>
<?xinclude /resources/AbstractRule.xml ?>
<ClassificationLevel><?merge $managementMetadata.classificationRule.classificationLevel ?></ClassificationLevel>
<ClassificationOwner><?merge $managementMetadata.classificationRule.classificationOwner ?></ClassificationOwner>
<ClassificationReassessingDate><?merge $managementMetadata.classificationRule.classificationReassessingDate ?></ClassificationReassessingDate>
<NeedReassessingAuthorization><?merge $managementMetadata.classificationRule.needReassessingAuthorization ?></NeedReassessingAuthorization>
</ClassificationRule>
<?merge $managementMetadata.needAuthorization.bool() ?>
<NeedAuthorization>
<?merge $managementMetadata.needAuthorization ?>
</NeedAuthorization>
<?merge $managementMetadata.otherManagementAbstract.bool() ?>
<OtherManagementAbstract>
<?merge $managementMetadata.otherManagementAbstract ?>
</OtherManagementAbstract>
</ManagementMetadata>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment