This commit is contained in:
Paula Quispe
2019-03-28 13:00:34 -04:00
parent fcd252dfb2
commit 2929e8ac3e
5 changed files with 51 additions and 6 deletions

View File

@@ -431,6 +431,50 @@ function arrayDiffRecursive(array $array1, array $array2)
return $difference;
}
/**
* Replace all supported variables prefixes to the prefix sent
*
* @param string $outDocFilename
* @param string $prefix
*
* @return string
*
* @see cases_Step.php
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::addCasesOutputDocument()
* @link https://wiki.processmaker.com/3.2/Triggers#Typing_rules_for_Case_Variables
*/
function replacePrefixes($outDocFilename, $prefix = '@=')
{
$outDocFile = str_replace(['@@', '@#', '@=', '@%', '@?', '@$', '@&', '@Q', '@q', '@!'], $prefix, $outDocFilename);
return $outDocFile;
}
/**
* Encoding header filename used in Content-Disposition
*
* @param string $fileName
* @param string $replacement
*
* @return string
*
* @see cases_Step.php
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::addCasesOutputDocument()
*/
function fixContentDispositionFilename($fileName, $replacement = '_')
{
//(double quote) has to be removed
//(forward slash) has to replaced by underscore
//(backslash) has to replaced by underscore
$default = [
'/[\"]/' => '',
'/[\\|\/]/' => $replacement,
'/\\\\/' => $replacement
];
return preg_replace(array_keys($default), array_values($default), $fileName);
}
/**
* Get the current user CSRF token.
*