Merged in mcuiza/processmaker/pm2731_bk (pull request #2259)
pm-2731 - Cuando el nombre de proceso es muy grande no se puede exportar el proceso
This commit is contained in:
@@ -968,7 +968,7 @@ class Processes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($oData->taskExtraProperties)) {
|
if (isset($oData->taskExtraProperties)) {
|
||||||
foreach ($oData->taskExtraProperties as $key => $value) {
|
foreach ($oData->taskExtraProperties as $key => $value) {
|
||||||
$record = $value;
|
$record = $value;
|
||||||
@@ -3642,8 +3642,12 @@ class Processes
|
|||||||
//Calculating the maximum length of file name
|
//Calculating the maximum length of file name
|
||||||
$pathLength = strlen( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP );
|
$pathLength = strlen( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP );
|
||||||
$length = strlen( $proTitle ) + $pathLength;
|
$length = strlen( $proTitle ) + $pathLength;
|
||||||
if ($length >= 250) {
|
$limit = 200;
|
||||||
$proTitle = myTruncate( $proTitle, 250 - $pathLength, '_', '' );
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
$limit = 150;
|
||||||
|
}
|
||||||
|
if ($length >= $limit) {
|
||||||
|
$proTitle = $this->truncateName($proTitle);
|
||||||
}
|
}
|
||||||
$index = '';
|
$index = '';
|
||||||
|
|
||||||
@@ -3751,9 +3755,9 @@ class Processes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//For public files
|
// for public files
|
||||||
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP . $data->process['PRO_UID'];
|
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP . $data->process['PRO_UID'];
|
||||||
|
|
||||||
//Get WebEntry file names
|
//Get WebEntry file names
|
||||||
$arrayWebEntryFile = array();
|
$arrayWebEntryFile = array();
|
||||||
|
|
||||||
@@ -4126,6 +4130,7 @@ class Processes
|
|||||||
$fsData = intval( fread( $fp, 9 ) ); //reading the size of $oData
|
$fsData = intval( fread( $fp, 9 ) ); //reading the size of $oData
|
||||||
$contents = fread( $fp, $fsData ); //reading string $oData
|
$contents = fread( $fp, $fsData ); //reading string $oData
|
||||||
|
|
||||||
|
|
||||||
$path = PATH_DYNAFORM . $oData->process['PRO_UID'] . PATH_SEP;
|
$path = PATH_DYNAFORM . $oData->process['PRO_UID'] . PATH_SEP;
|
||||||
if (! is_dir( $path )) {
|
if (! is_dir( $path )) {
|
||||||
G::verifyPath( $path, true );
|
G::verifyPath( $path, true );
|
||||||
@@ -4245,7 +4250,7 @@ class Processes
|
|||||||
if ($fsContent > 0) {
|
if ($fsContent > 0) {
|
||||||
$fileContent = fread( $fp, $fsContent ); //reading string $XmlContent
|
$fileContent = fread( $fp, $fsContent ); //reading string $XmlContent
|
||||||
$newFileName = $pathPublic . $sFileName;
|
$newFileName = $pathPublic . $sFileName;
|
||||||
|
|
||||||
if (in_array($sFileName, $arrayWebEntryFile)) {
|
if (in_array($sFileName, $arrayWebEntryFile)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -4262,6 +4267,7 @@ class Processes
|
|||||||
fclose( $fp );
|
fclose( $fp );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5161,6 +5167,18 @@ class Processes
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function truncateName($proTitle)
|
||||||
|
{
|
||||||
|
$proTitle = str_replace(".","_",$proTitle);
|
||||||
|
$limit = 200;
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
$limit = 150;
|
||||||
|
}
|
||||||
|
$excess = strlen($proTitle) - $limit;
|
||||||
|
$proTitle = substr($proTitle,0,strlen($proTitle)-$excess);
|
||||||
|
return $proTitle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//end class processes
|
//end class processes
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,11 @@ try {
|
|||||||
}
|
}
|
||||||
if (\BpmnProject::exists($_GET["pro_uid"])) {
|
if (\BpmnProject::exists($_GET["pro_uid"])) {
|
||||||
$exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]);
|
$exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]);
|
||||||
|
$getProjectName = $exporter->truncateName($exporter->getProjectName(),false);
|
||||||
|
|
||||||
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() . "-*.pmx") + 1;
|
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
|
||||||
$outputFilename = sprintf("%s-%s.%s", str_replace(" ", "_", $exporter->getProjectName()), $version, "pmx");
|
$outputFilename = sprintf("%s-%s.%s", str_replace(" ","_",$getProjectName), $version, "pmx");
|
||||||
$exporter->saveExport($outputDir . $outputFilename);
|
$outputFilename = $exporter->saveExport($outputDir . $outputFilename);
|
||||||
} else {
|
} else {
|
||||||
$oProcess = new Processes();
|
$oProcess = new Processes();
|
||||||
$proFields = $oProcess->serializeProcess($_GET["pro_uid"]);
|
$proFields = $oProcess->serializeProcess($_GET["pro_uid"]);
|
||||||
@@ -47,15 +48,15 @@ try {
|
|||||||
$response->file_hash = base64_encode($outputFilename);
|
$response->file_hash = base64_encode($outputFilename);
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
|
|
||||||
/* Render page */
|
/* Render page */
|
||||||
if (isset( $_REQUEST["processMap"] ) && $_REQUEST["processMap"] == 1) {
|
if (isset( $_REQUEST["processMap"] ) && $_REQUEST["processMap"] == 1) {
|
||||||
$link = parse_url($result['FILENAME_LINK']);
|
$link = parse_url($result['FILENAME_LINK']);
|
||||||
$result['FILENAME_LINK'] = $link['path'] . '?file_hash=' . $response->file_hash;
|
$result['FILENAME_LINK'] = $link['path'] . '?file_hash=' . $response->file_hash;
|
||||||
|
|
||||||
$G_PUBLISH = new Publisher();
|
$G_PUBLISH = new Publisher();
|
||||||
$G_PUBLISH->AddContent( "xmlform", "xmlform", "processes/processes_Export", "", $result );
|
$G_PUBLISH->AddContent( "xmlform", "xmlform", "processes/processes_Export", "", $result );
|
||||||
|
|
||||||
G::RenderPage( "publish", "raw" );
|
G::RenderPage( "publish", "raw" );
|
||||||
} else{
|
} else{
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,13 @@ class XmlExporter extends Exporter
|
|||||||
if (! is_dir($parentDir)) {
|
if (! is_dir($parentDir)) {
|
||||||
Util\Common::mk_dir($parentDir, 0775);
|
Util\Common::mk_dir($parentDir, 0775);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$outputFile = $this->Truncatename($outputFile);
|
||||||
|
|
||||||
file_put_contents($outputFile, $this->export());
|
file_put_contents($outputFile, $this->export());
|
||||||
chmod($outputFile, 0755);
|
chmod($outputFile, 0755);
|
||||||
|
|
||||||
|
return basename($outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,4 +153,36 @@ class XmlExporter extends Exporter
|
|||||||
return $this->dom->createCDATASection($value);
|
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)
|
public function export($prj_uid)
|
||||||
{
|
{
|
||||||
$exporter = new \ProcessMaker\Exporter\XmlExporter($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;
|
$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;
|
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
|
||||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $exporter->getProjectName()), $version, "pmx");
|
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||||
|
|
||||||
$exporter->setMetadata("export_version", $version);
|
$exporter->setMetadata("export_version", $version);
|
||||||
$exporter->saveExport($outputFilename);
|
$outputFilename = $exporter->saveExport($outputFilename);
|
||||||
|
|
||||||
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
||||||
$fileExtension = pathinfo($outputFilename, PATHINFO_EXTENSION);
|
$fileExtension = pathinfo($outputFilename, PATHINFO_EXTENSION);
|
||||||
|
|||||||
@@ -558,7 +558,14 @@ function newProcess(params)
|
|||||||
width: 260,
|
width: 260,
|
||||||
maskRe: /^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\...*)(\..+)?$)[^\x00-\x1f\\?*\";|/]+$/i,
|
maskRe: /^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\...*)(\..+)?$)[^\x00-\x1f\\?*\";|/]+$/i,
|
||||||
allowBlank: false,
|
allowBlank: false,
|
||||||
vtype: "textWithoutTags"
|
vtype: "textWithoutTags",
|
||||||
|
listeners: {
|
||||||
|
'focus' : function(value){
|
||||||
|
document.getElementById("PRO_TITLE").onpaste = function() {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
id: 'PRO_DESCRIPTION',
|
id: 'PRO_DESCRIPTION',
|
||||||
fieldLabel: _('ID_DESCRIPTION'),
|
fieldLabel: _('ID_DESCRIPTION'),
|
||||||
|
|||||||
Reference in New Issue
Block a user