FIX substitution in ODT of thirdparties documents

This commit is contained in:
Laurent Destailleur 2017-10-22 01:25:59 +02:00
parent f7556e7ad2
commit cad44ee68a

View File

@ -272,53 +272,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc
} }
//print $odfHandler->__toString()."\n"; //print $odfHandler->__toString()."\n";
// Make substitutions into odt of user info
$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
//var_dump($tmparray); exit;
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
//print $key.' '.$value;exit;
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
// setVars failed, probably because key not found
}
}
// Make substitutions into odt of mysoc info
$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
//var_dump($tmparray); exit;
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
// setVars failed, probably because key not found
}
}
// Replace tags of lines for contacts // Replace tags of lines for contacts
$contact_arrray=array(); $contact_arrray=array();
@ -380,13 +333,18 @@ class doc_generic_odt extends ModeleThirdPartyDoc
} }
} }
// Make substitutions into odt of thirdparty + external modules // Make substitutions into odt
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs); $array_user=$this->get_substitutionarray_user($user,$outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook // Call the ODTSubstitution hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Replace variables into document // Replace variables into document
foreach($tmparray as $key=>$value) foreach($tmparray as $key=>$value)