BUG 0000 'Fix the dynaforms path and date search' SOLVED
This commit is contained in:
@@ -1171,30 +1171,27 @@ class AppSolr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate phrase in case of date
|
// validate phrase in case of date
|
||||||
if (($searchText [1] == "["))
|
if (($searchText [1] == "[")) {
|
||||||
{
|
|
||||||
// validate date range format
|
// validate date range format
|
||||||
// use regular expresion to validate it [yyyy-mm-dd TO yyyy-mm-dd]
|
// use regular expresion to validate it [yyyy-mm-dd TO yyyy-mm-dd]
|
||||||
$result1 = strpos($searchText, '-');
|
$result1 = strpos($searchText, '-');
|
||||||
if ($result1 !== false)
|
if ($result1 !== false) {
|
||||||
{
|
$result2 = strpos($searchText, 'TO');
|
||||||
|
if ($result2 !== false) {
|
||||||
$reg = "/:\[(\d\d\d\d-\d\d-\d\d|\*)\sTO\s(\d\d\d\d-\d\d-\d\d|\*)\]/";
|
$reg = "/:\[(\d\d\d\d-\d\d-\d\d|\*)\sTO\s(\d\d\d\d-\d\d-\d\d|\*)\]/";
|
||||||
// convert date to utc
|
// convert date to utc
|
||||||
$matched = preg_match ($reg, $searchText, $matches);
|
$matched = preg_match ($reg, $searchText, $matches);
|
||||||
if ($matched == 1)
|
if ($matched == 1) {
|
||||||
{
|
|
||||||
// the date interval is valid
|
// the date interval is valid
|
||||||
// convert to SOlr format
|
// convert to SOlr format
|
||||||
$fromDateOriginal = $matches [1];
|
$fromDateOriginal = $matches [1];
|
||||||
$fromDate = $matches [1];
|
$fromDate = $matches [1];
|
||||||
$toDateOriginal = $matches [2];
|
$toDateOriginal = $matches [2];
|
||||||
$toDate = $matches [2];
|
$toDate = $matches [2];
|
||||||
if ($fromDateOriginal != '*')
|
if ($fromDateOriginal != '*') {
|
||||||
{
|
|
||||||
$fromDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
|
$fromDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
|
||||||
}
|
}
|
||||||
if ($toDateOriginal != '*')
|
if ($toDateOriginal != '*') {
|
||||||
{
|
|
||||||
// list($year, $month, $day) = sscanf($fromDateOriginal,
|
// list($year, $month, $day) = sscanf($fromDateOriginal,
|
||||||
// '%04d/%02d/%02d');
|
// '%04d/%02d/%02d');
|
||||||
// $toDateDatetime = new DateTime($toDateOriginal);
|
// $toDateDatetime = new DateTime($toDateOriginal);
|
||||||
@@ -1204,23 +1201,25 @@ class AppSolr
|
|||||||
}
|
}
|
||||||
$searchText = ":[" . $fromDate . " TO " . $toDate . "]";
|
$searchText = ":[" . $fromDate . " TO " . $toDate . "]";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$searchText = str_replace( "[", "", $searchText );
|
||||||
|
$searchText = str_replace( "]", "", $searchText );
|
||||||
|
$searchText = str_replace( ":", "", $searchText );
|
||||||
|
$searchText = ":[" . $searchText . "T00:00:00Z TO " . $searchText . "T23:59:59.999Z]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate phrase in case of < and <=
|
// validate phrase in case of < and <=
|
||||||
$result1 = strpos($searchText, '<');
|
$result1 = strpos($searchText, '<');
|
||||||
if($result1 !== false)
|
if($result1 !== false) {
|
||||||
{
|
|
||||||
$result = strpos($searchText, '<=');
|
$result = strpos($searchText, '<=');
|
||||||
if($result !== false)
|
if($result !== false) {
|
||||||
{
|
|
||||||
$v1 = str_replace( '<=', '', $searchText );
|
$v1 = str_replace( '<=', '', $searchText );
|
||||||
$v2 = str_replace( ':', '', $v1);
|
$v2 = str_replace( ':', '', $v1);
|
||||||
$v3 = str_replace( '<','' ,':[* TO '.$v2.']' );
|
$v3 = str_replace( '<','' ,':[* TO '.$v2.']' );
|
||||||
$searchText = $v3;
|
$searchText = $v3;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$v1 = str_replace( '<', '', $searchText );
|
$v1 = str_replace( '<', '', $searchText );
|
||||||
$v2 = str_replace( ':', '', $v1);
|
$v2 = str_replace( ':', '', $v1);
|
||||||
$v3 = (int) $v2-1;
|
$v3 = (int) $v2-1;
|
||||||
@@ -1230,18 +1229,14 @@ class AppSolr
|
|||||||
}
|
}
|
||||||
// validate phrase in case of > and >=
|
// validate phrase in case of > and >=
|
||||||
$result2 = strpos($searchText, '>');
|
$result2 = strpos($searchText, '>');
|
||||||
if($result2 !== false)
|
if($result2 !== false) {
|
||||||
{
|
|
||||||
$result = strpos($searchText, '>=');
|
$result = strpos($searchText, '>=');
|
||||||
if($result !== false)
|
if($result !== false) {
|
||||||
{
|
|
||||||
$v1 = str_replace( '>=', '', $searchText );
|
$v1 = str_replace( '>=', '', $searchText );
|
||||||
$v2 = str_replace( ':', '', $v1);
|
$v2 = str_replace( ':', '', $v1);
|
||||||
$v3 = str_replace( '>','' ,':['.$v2.' TO *]' );
|
$v3 = str_replace( '>','' ,':['.$v2.' TO *]' );
|
||||||
$searchText = $v3;
|
$searchText = $v3;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$v1 = str_replace( '>', '', $searchText );
|
$v1 = str_replace( '>', '', $searchText );
|
||||||
$v2 = str_replace( ':', '', $v1 );
|
$v2 = str_replace( ':', '', $v1 );
|
||||||
$v3 = (int) $v2+1;
|
$v3 = (int) $v2+1;
|
||||||
@@ -1259,6 +1254,7 @@ class AppSolr
|
|||||||
// next token
|
// next token
|
||||||
$tok = strtok (" ");
|
$tok = strtok (" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove last AND
|
// remove last AND
|
||||||
$formattedSearchText = substr_replace ($formattedSearchText, "", - 5);
|
$formattedSearchText = substr_replace ($formattedSearchText, "", - 5);
|
||||||
return $formattedSearchText;
|
return $formattedSearchText;
|
||||||
@@ -2323,14 +2319,13 @@ class AppSolr
|
|||||||
$dynaformFileNames = $this->getProcessDynaformFileNames ($documentInformation ['PRO_UID']);
|
$dynaformFileNames = $this->getProcessDynaformFileNames ($documentInformation ['PRO_UID']);
|
||||||
$dynaformFields = array ();
|
$dynaformFields = array ();
|
||||||
foreach ($dynaformFileNames as $dynaformFileName) {
|
foreach ($dynaformFileNames as $dynaformFileName) {
|
||||||
if (is_file(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
|
if (is_file(PATH_DYNAFORM . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
|
||||||
filesize(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') >0 ) {
|
filesize(PATH_DYNAFORM . $dynaformFileName ['DYN_FILENAME'] . '.xml') >0 ) {
|
||||||
$dyn = new dynaFormHandler (PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml');
|
$dyn = new dynaFormHandler (PATH_DYNAFORM . $dynaformFileName ['DYN_FILENAME'] . '.xml');
|
||||||
$dynaformFields [] = $dyn->getFields ();
|
$dynaformFields [] = $dyn->getFields ();
|
||||||
}
|
}
|
||||||
if (is_file(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
|
if (is_file(PATH_DYNAFORM . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
|
||||||
filesize(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') == 0 ) {
|
filesize(PATH_DYNAFORM . $dynaformFileName ['DYN_FILENAME'] . '.xml') == 0 ) {
|
||||||
|
|
||||||
throw new ApplicationWithCorruptDynaformException(date('Y-m-d H:i:s:u') . "Application with corrupt dynaform. APP_UID: " . $AppUID . "\n");
|
throw new ApplicationWithCorruptDynaformException(date('Y-m-d H:i:s:u') . "Application with corrupt dynaform. APP_UID: " . $AppUID . "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user