Al realizar un export de un proceso (Normal/Granular) se hace un truncate del nombre sin embargo no se considera nombres de file Multibyte solo se toma en cuenta nombres de tipo Monobyte
This commit is contained in:
dheeyi william
2016-09-05 14:25:28 -04:00
parent c1b9d18a3d
commit 0efc5474ab
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;
}
}