Merged in dheeyi/processmaker/HOR-1777 (pull request #4860)

HOR-1777
This commit is contained in:
David Callizaya
2016-09-07 17:21:16 -04:00
2 changed files with 52 additions and 10 deletions

View File

@@ -46,8 +46,7 @@ class PMXPublisher
$lastPos = strrpos($filename, '.');
$fileName = substr($filename, 0, $lastPos);
$newFileName = \G::inflect($fileName);
$excess = strlen($newFileName) - $limit;
$newFileName = substr($newFileName, 0, strlen($newFileName) - $excess - 1);
$newFileName = $this->truncateFilename($newFileName, $limit);
$newOutputFile = str_replace($fileName, $newFileName, $outputFile);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$newOutputFile = str_replace("/", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, $newOutputFile);
@@ -57,9 +56,31 @@ class PMXPublisher
setlocale(LC_CTYPE, $currentLocale);
} else {
$outputFile = \G::inflect($outputFile);
if (strlen($outputFile) >= $limit) {
$excess = strlen($outputFile) - $limit;
$newFileName = substr($outputFile, 0, strlen($outputFile) - $excess - 1);
$outputFile = $this->truncateFilename($outputFile, $limit);
}
return $outputFile;
}
/**
* @param $outputFile
* @param $limit
* @return string
*/
private function truncateFilename($outputFile, $limit)
{
$limitFile = $limit;
if (mb_strlen($outputFile) != strlen($outputFile)) {
if (strlen($outputFile) >= $limitFile) {
do {
$newFileName = mb_strimwidth($outputFile, 0, $limit);
--$limit;
} while (strlen($newFileName) > $limitFile);
$outputFile = $newFileName;
}
} else {
if (strlen($outputFile) >= $limitFile) {
$excess = strlen($outputFile) - $limitFile;
$newFileName = substr($outputFile, 0, strlen($outputFile) - $excess);
$outputFile = $newFileName;
}
}

View File

@@ -181,8 +181,7 @@ class XmlExporter extends Exporter
$lastPos = strrpos($filename, '.');
$fileName = substr($filename, 0, $lastPos);
$newFileName = \G::inflect($fileName);
$excess = strlen($newFileName) - $limit;
$newFileName = substr($newFileName, 0, strlen($newFileName) - $excess - 1);
$newFileName = $this->truncateFilename($newFileName, $limit);
$newOutputFile = str_replace($fileName, $newFileName, $outputFile);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$newOutputFile = str_replace("/", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, $newOutputFile);
@@ -192,9 +191,31 @@ class XmlExporter extends Exporter
setlocale(LC_CTYPE, $currentLocale);
} else {
$outputFile = \G::inflect($outputFile);
if (strlen($outputFile) >= $limit) {
$excess = strlen($outputFile) - $limit;
$newFileName = substr($outputFile, 0, strlen($outputFile) - $excess - 1);
$outputFile = $this->truncateFilename($outputFile, $limit);
}
return $outputFile;
}
/**
* @param $outputFile
* @param $limit
* @return string
*/
private function truncateFilename($outputFile, $limit)
{
$limitFile = $limit;
if (mb_strlen($outputFile) != strlen($outputFile)) {
if (strlen($outputFile) >= $limitFile) {
do {
$newFileName = mb_strimwidth($outputFile, 0, $limit);
--$limit;
} while (strlen($newFileName) > $limitFile);
$outputFile = $newFileName;
}
} else {
if (strlen($outputFile) >= $limitFile) {
$excess = strlen($outputFile) - $limitFile;
$newFileName = substr($outputFile, 0, strlen($outputFile) - $excess);
$outputFile = $newFileName;
}
}