HOR-2933-B

update
This commit is contained in:
hjonathan
2017-08-07 08:51:02 -04:00
parent 56ef252e99
commit c5a63873b4
6 changed files with 56 additions and 17 deletions

View File

@@ -52,16 +52,18 @@ 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;
@@ -96,7 +98,7 @@ class Common
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];
@@ -107,6 +109,29 @@ class Common
return $maxVersion; return $maxVersion;
} }
/**
* 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 getLastVersionSpecialCharacters($dir, $pattern, $extension, $flag = 0)
{
$files = glob($dir . quotemeta($pattern) . "-*." . $extension, $flag);
$maxVersion = 0;
$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;
}
public static function parseIniFile($filename) public static function parseIniFile($filename)
{ {
$data = @parse_ini_file($filename, true); $data = @parse_ini_file($filename, true);
@@ -141,8 +166,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);
} }
} }

View File

@@ -3221,20 +3221,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);
} }
/** /**

View File

@@ -42,7 +42,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 = ProcessMaker\Util\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);
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/

View File

@@ -64,7 +64,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 = \ProcessMaker\Util\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(

View File

@@ -771,7 +771,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 = \ProcessMaker\Util\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);

View File

@@ -182,7 +182,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 = \ProcessMaker\Util\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);