N°931: Fix Search when screen is refreshed (number of selected criteria for tags)

This commit is contained in:
Eric
2018-09-20 15:57:37 +02:00
parent 398d1aa820
commit a1ad7a5def
3 changed files with 14 additions and 6 deletions

View File

@@ -6729,17 +6729,25 @@ class AttributeTagSet extends AttributeDBFieldVoid
* Extract all existing tags from a string and ignore bad tags
*
* @param $sValue
* @param bool $bNoLimit : don't apply the maximum tag limit
*
* @return \ormTagSet
* @throws \CoreException
* @throws \CoreUnexpectedValue
*/
public function GetExistingTagsFromString($sValue)
public function GetExistingTagsFromString($sValue, $bNoLimit = false)
{
$aTagCodes = explode(' ', "$sValue");
$sAttCode = $this->GetCode();
$sClass = MetaModel::GetAttributeOrigin($this->GetHostClass(), $sAttCode);
$oTagSet = new ormTagSet($sClass, $sAttCode, $this->GetTagMaxNb());
if ($bNoLimit)
{
$oTagSet = new ormTagSet($sClass, $sAttCode, 0);
}
else
{
$oTagSet = new ormTagSet($sClass, $sAttCode, $this->GetTagMaxNb());
}
$aGoodTags = array();
foreach($aTagCodes as $sTagCode)
{
@@ -6750,10 +6758,10 @@ class AttributeTagSet extends AttributeDBFieldVoid
if ($oTagSet->IsValidTag($sTagCode))
{
$aGoodTags[] = $sTagCode;
if (count($aGoodTags) === $this->GetTagMaxNb())
if (!$bNoLimit && (count($aGoodTags) === $this->GetTagMaxNb()))
{
// extra and bad tags are ignored
continue;
break;
}
}
}

View File

@@ -948,7 +948,7 @@ class ScalarExpression extends UnaryExpression
$oValue = $this->GetValue();
if (is_string($oValue))
{
$oValue = $oAttDef->GetExistingTagsFromString($oValue);
$oValue = $oAttDef->GetExistingTagsFromString($oValue, true);
}
/** @var \ormTagSet $oValue */
$aTags = $oValue->GetTags();

View File

@@ -131,7 +131,7 @@ final class ormTagSet
foreach($aTagCodes as $sTagCode)
{
$iCount++;
if ($iCount > $this->iLimit)
if (($this->iLimit != 0) && ($iCount > $this->iLimit))
{
$bError = true;
continue;