pm-2731
This commit is contained in:
@@ -127,9 +127,13 @@ class XmlExporter extends Exporter
|
||||
if (! is_dir($parentDir)) {
|
||||
Util\Common::mk_dir($parentDir, 0775);
|
||||
}
|
||||
|
||||
|
||||
$outputFile = $this->Truncatename($outputFile);
|
||||
|
||||
file_put_contents($outputFile, $this->export());
|
||||
chmod($outputFile, 0755);
|
||||
|
||||
return basename($outputFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,4 +153,36 @@ class XmlExporter extends Exporter
|
||||
return $this->dom->createCDATASection($value);
|
||||
}
|
||||
}
|
||||
|
||||
public function truncateName($outputFile,$dirName = true)
|
||||
{
|
||||
$limit = 200;
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
$limit = 150;
|
||||
}
|
||||
if($dirName) {
|
||||
if (strlen(basename($outputFile)) >= $limit) {
|
||||
$lastPos = strrpos(basename($outputFile),'.');
|
||||
$fileName = substr(basename($outputFile),0,$lastPos);
|
||||
$newFileName = str_replace(".","_",$fileName);
|
||||
$newFileName = str_replace(" ","_",$fileName);
|
||||
$excess = strlen($newFileName) - $limit;
|
||||
$newFileName = substr($newFileName,0,strlen($newFileName)-$excess);
|
||||
$newOutputFile = str_replace($fileName,$newFileName,$outputFile);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
$newOutputFile = str_replace("/", DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, $newOutputFile);
|
||||
}
|
||||
$outputFile = $newOutputFile;
|
||||
}
|
||||
} else {
|
||||
$outputFile = str_replace(".","_",$outputFile);
|
||||
$outputFile = str_replace(" ","_",$outputFile);
|
||||
if (strlen($outputFile) >= $limit) {
|
||||
$excess = strlen($outputFile) - $limit;
|
||||
$newFileName = substr($outputFile,0,strlen($outputFile)-$excess);
|
||||
$outputFile = $newFileName;
|
||||
}
|
||||
}
|
||||
return $outputFile;
|
||||
}
|
||||
}
|
||||
@@ -108,13 +108,14 @@ class Project extends Api
|
||||
public function export($prj_uid)
|
||||
{
|
||||
$exporter = new \ProcessMaker\Exporter\XmlExporter($prj_uid);
|
||||
$getProjectName = $exporter->truncateName($exporter->getProjectName(),false);
|
||||
|
||||
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() . "-*.pmx") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $exporter->getProjectName()), $version, "pmx");
|
||||
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||
|
||||
$exporter->setMetadata("export_version", $version);
|
||||
$exporter->saveExport($outputFilename);
|
||||
$outputFilename = $exporter->saveExport($outputFilename);
|
||||
|
||||
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
||||
$fileExtension = pathinfo($outputFilename, PATHINFO_EXTENSION);
|
||||
|
||||
Reference in New Issue
Block a user