Merged in bugfix/HOR-2933-B (pull request #5876)
Bugfix/HOR-2933 B Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
254a9bf7b1
@@ -61,49 +61,34 @@ class Common
|
||||
}
|
||||
|
||||
if ($onlyFiles) {
|
||||
$files = array_filter($files, function($v) { return is_dir($v) ? false : true;});
|
||||
$files = array_filter($files, function ($v) {
|
||||
return is_dir($v) ? false : true;
|
||||
});
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last version given a pattern of file name
|
||||
*
|
||||
* @param string $pattern a valid pattern for glob(...) native function
|
||||
* @param int $flag php flags for glob(...) native function
|
||||
* @return int|string
|
||||
*
|
||||
* Example:
|
||||
* - Given the following files inside a directory:
|
||||
* /example/path/myApplication-v1.tar
|
||||
* /example/path/myApplication-v2.tar
|
||||
* /example/path/myApplication-v3.tar
|
||||
* /example/path/myApplication-v5.tar
|
||||
* /example/path/myApplication-v7.tar
|
||||
*
|
||||
* $lastVer = ProcessMaker\Util\Common::getLastVersion("/example/path/myApplication-*.tar");
|
||||
*
|
||||
* It will returns: 7
|
||||
* This method get the last version of file when exists a special characters
|
||||
* @param $pattern
|
||||
* @param $extension
|
||||
* @param int $flag
|
||||
* @return int
|
||||
*/
|
||||
public static function getLastVersion($pattern, $flag = 0)
|
||||
public static function getLastVersionSpecialCharacters($dir, $pattern, $extension, $flag = 0)
|
||||
{
|
||||
$files = glob($pattern, $flag);
|
||||
$files = glob($dir . quotemeta($pattern) . "-*." . $extension, $flag);
|
||||
$maxVersion = 0;
|
||||
|
||||
$pattern = str_replace("*", '([0-9\.]+)', basename($pattern));
|
||||
|
||||
$pattern = preg_quote(basename($pattern)) . '-([0-9\.]+)pmx';
|
||||
foreach ($files as $file) {
|
||||
$filename = basename($file);
|
||||
|
||||
if (preg_match('/' . $pattern . '/', $filename, $match)) {
|
||||
|
||||
if ($maxVersion < $match[1]) {
|
||||
$maxVersion = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $maxVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -3247,8 +3247,22 @@ class G
|
||||
|
||||
$quotedReplacement = preg_quote($replacement, '/');
|
||||
|
||||
$default = array ('/à|á|å|â/' => 'a','/è|é|ê|ẽ|ë/' => 'e','/ì|í|î/' => 'i','/ò|ó|ô|ø/' => 'o','/ù|ú|ů|û/' => 'u','/ç/' => 'c','/ñ/' => 'n','/ä|æ/' => 'ae','/ö/' => 'oe','/ü/' => 'ue','/Ä/' => 'Ae','/Ü/' => 'Ue','/Ö/' => 'Oe','/ß/' => 'ss','/\.|\,|\:|\-|\\|\//' => " ",'/\\s+/' => $replacement
|
||||
);
|
||||
$default = array('/à|á|å|â/' => 'a',
|
||||
'/è|é|ê|ẽ|ë/' => 'e',
|
||||
'/ì|í|î/' => 'i',
|
||||
'/ò|ó|ô|ø/' => 'o',
|
||||
'/ù|ú|ů|û/' => 'u',
|
||||
'/ç/' => 'c',
|
||||
'/ñ/' => 'n',
|
||||
'/ä|æ/' => 'ae',
|
||||
'/ö/' => 'oe',
|
||||
'/ü/' => 'ue',
|
||||
'/Ä/' => 'Ae',
|
||||
'/Ü/' => 'Ue',
|
||||
'/Ö/' => 'Oe',
|
||||
'/ß/' => 'ss',
|
||||
'/[\.|\,|\+|\"|\:|\;|\-|\\|\/]/' => " ",
|
||||
'/\\s+/' => $replacement);
|
||||
|
||||
$map = array_merge($default, $map);
|
||||
return preg_replace(array_keys($map), array_values($map), $string);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
use ProcessMaker\Util\Common;
|
||||
|
||||
$response = new StdClass();
|
||||
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||
@@ -42,7 +43,7 @@ try {
|
||||
$projectName = $exporter->getProjectName();
|
||||
$getProjectName = $exporter->truncateName($projectName, false);
|
||||
|
||||
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
|
||||
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
|
||||
$outputFilename = sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||
$outputFilename = $exporter->saveExport($outputDir . $outputFilename);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\BusinessModel\Migrator;
|
||||
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Util\Common;
|
||||
|
||||
class GranularExporter
|
||||
{
|
||||
@@ -64,7 +65,7 @@ class GranularExporter
|
||||
$this->prjName = $projectData['PRJ_NAME'];
|
||||
$getProjectName = $this->publisher->truncateName($projectData['PRJ_NAME'], false);
|
||||
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx2") + 1;
|
||||
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx2") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx2");
|
||||
|
||||
$bpnmDefinition = array(
|
||||
|
||||
@@ -6,6 +6,7 @@ use ProcessMaker\Project;
|
||||
use ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\BusinessModel\Migrator;
|
||||
use ProcessMaker\BusinessModel\Migrator\ImportException;
|
||||
use ProcessMaker\Util\Common;
|
||||
|
||||
abstract class Importer
|
||||
{
|
||||
@@ -771,7 +772,7 @@ abstract class Importer
|
||||
$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 . $getProjectName . "-*.pmx") + 1;
|
||||
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||
|
||||
$exporter->setMetadata("export_version", $version);
|
||||
|
||||
@@ -10,6 +10,7 @@ use \ProcessMaker\BusinessModel\Validator;
|
||||
use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
|
||||
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
|
||||
use \ProcessMaker\Util\IO\HttpStream;
|
||||
use \ProcessMaker\Util\Common;
|
||||
|
||||
/**
|
||||
* Class Project
|
||||
@@ -182,7 +183,7 @@ class Project extends Api
|
||||
$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 . $getProjectName . "-*.pmx") + 1;
|
||||
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||
|
||||
$exporter->setMetadata("export_version", $version);
|
||||
|
||||
Reference in New Issue
Block a user