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
@@ -52,58 +52,43 @@ class Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
$files = glob("$path/$singlePattern", $flags);
|
$files = glob("$path/$singlePattern", $flags);
|
||||||
$dirs = glob("$path/*", GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
|
$dirs = glob("$path/*", GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
|
||||||
|
|
||||||
if(is_array($dirs)){
|
if (is_array($dirs)) {
|
||||||
foreach ($dirs as $dir) {
|
foreach ($dirs as $dir) {
|
||||||
$files = array_merge($files, self::rglob("$dir/$singlePattern", $flags));
|
$files = array_merge($files, self::rglob("$dir/$singlePattern", $flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($onlyFiles) {
|
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;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last version given a pattern of file name
|
* This method get the last version of file when exists a special characters
|
||||||
*
|
* @param $pattern
|
||||||
* @param string $pattern a valid pattern for glob(...) native function
|
* @param $extension
|
||||||
* @param int $flag php flags for glob(...) native function
|
* @param int $flag
|
||||||
* @return int|string
|
* @return int
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
*/
|
||||||
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;
|
$maxVersion = 0;
|
||||||
|
$pattern = preg_quote(basename($pattern)) . '-([0-9\.]+)pmx';
|
||||||
$pattern = str_replace("*", '([0-9\.]+)', basename($pattern));
|
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$filename = basename($file);
|
$filename = basename($file);
|
||||||
|
if (preg_match('/' . $pattern . '/', $filename, $match)) {
|
||||||
if (preg_match('/'.$pattern.'/', $filename, $match)) {
|
|
||||||
|
|
||||||
if ($maxVersion < $match[1]) {
|
if ($maxVersion < $match[1]) {
|
||||||
$maxVersion = $match[1];
|
$maxVersion = $match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $maxVersion;
|
return $maxVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,8 +126,8 @@ class Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ($parent_folder_path = array_pop($folder_path)) {
|
while ($parent_folder_path = array_pop($folder_path)) {
|
||||||
if (! @is_dir($parent_folder_path)) {
|
if (!@is_dir($parent_folder_path)) {
|
||||||
if (! @mkdir($parent_folder_path, $rights)) {
|
if (!@mkdir($parent_folder_path, $rights)) {
|
||||||
umask($oldumask);
|
umask($oldumask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3238,20 +3238,34 @@ class G
|
|||||||
* @param (array) additional characteres map
|
* @param (array) additional characteres map
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function inflect ($string, $replacement = '_', $map = array())
|
public function inflect($string, $replacement = '_', $map = array())
|
||||||
{
|
{
|
||||||
if (is_array( $replacement )) {
|
if (is_array($replacement)) {
|
||||||
$map = $replacement;
|
$map = $replacement;
|
||||||
$replacement = '_';
|
$replacement = '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
$quotedReplacement = preg_quote( $replacement, '/' );
|
$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 );
|
$map = array_merge($default, $map);
|
||||||
return preg_replace( array_keys( $map ), array_values( $map ), $string );
|
return preg_replace(array_keys($map), array_values($map), $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*/
|
*/
|
||||||
|
use ProcessMaker\Util\Common;
|
||||||
|
|
||||||
$response = new StdClass();
|
$response = new StdClass();
|
||||||
$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;
|
||||||
@@ -42,7 +43,7 @@ try {
|
|||||||
$projectName = $exporter->getProjectName();
|
$projectName = $exporter->getProjectName();
|
||||||
$getProjectName = $exporter->truncateName($projectName, false);
|
$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 = sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||||
$outputFilename = $exporter->saveExport($outputDir . $outputFilename);
|
$outputFilename = $exporter->saveExport($outputDir . $outputFilename);
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace ProcessMaker\BusinessModel\Migrator;
|
namespace ProcessMaker\BusinessModel\Migrator;
|
||||||
|
|
||||||
use ProcessMaker\Project;
|
use ProcessMaker\Project;
|
||||||
|
use ProcessMaker\Util\Common;
|
||||||
|
|
||||||
class GranularExporter
|
class GranularExporter
|
||||||
{
|
{
|
||||||
@@ -64,7 +65,7 @@ class GranularExporter
|
|||||||
$this->prjName = $projectData['PRJ_NAME'];
|
$this->prjName = $projectData['PRJ_NAME'];
|
||||||
$getProjectName = $this->publisher->truncateName($projectData['PRJ_NAME'], false);
|
$getProjectName = $this->publisher->truncateName($projectData['PRJ_NAME'], 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 . $getProjectName . "-*.pmx2") + 1;
|
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx2") + 1;
|
||||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx2");
|
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx2");
|
||||||
|
|
||||||
$bpnmDefinition = array(
|
$bpnmDefinition = array(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use ProcessMaker\Project;
|
|||||||
use ProcessMaker\Project\Adapter;
|
use ProcessMaker\Project\Adapter;
|
||||||
use ProcessMaker\BusinessModel\Migrator;
|
use ProcessMaker\BusinessModel\Migrator;
|
||||||
use ProcessMaker\BusinessModel\Migrator\ImportException;
|
use ProcessMaker\BusinessModel\Migrator\ImportException;
|
||||||
|
use ProcessMaker\Util\Common;
|
||||||
|
|
||||||
abstract class Importer
|
abstract class Importer
|
||||||
{
|
{
|
||||||
@@ -771,7 +772,7 @@ abstract class Importer
|
|||||||
$getProjectName = $exporter->truncateName($exporter->getProjectName(), false);
|
$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 . $getProjectName . "-*.pmx") + 1;
|
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
|
||||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||||
|
|
||||||
$exporter->setMetadata("export_version", $version);
|
$exporter->setMetadata("export_version", $version);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use \ProcessMaker\BusinessModel\Validator;
|
|||||||
use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
|
use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
|
||||||
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
|
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
|
||||||
use \ProcessMaker\Util\IO\HttpStream;
|
use \ProcessMaker\Util\IO\HttpStream;
|
||||||
|
use \ProcessMaker\Util\Common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Project
|
* Class Project
|
||||||
@@ -182,7 +183,7 @@ class Project extends Api
|
|||||||
$getProjectName = $exporter->truncateName($exporter->getProjectName(), false);
|
$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 . $getProjectName . "-*.pmx") + 1;
|
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
|
||||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||||
|
|
||||||
$exporter->setMetadata("export_version", $version);
|
$exporter->setMetadata("export_version", $version);
|
||||||
|
|||||||
Reference in New Issue
Block a user