Enrich the frequentSearches

@param array Frequent search terms as array with terms as keys and hits as the value
@param integer $minimumSize
@param integer $maximumSize
@return array An array with content for the frequent terms markers
171207
protected function enrichFrequentSearchesInfo(array $frequentSearchTerms, $minimumSize, $maximumSize)
    {
        $frequentSearches = [];
        if (count($frequentSearchTerms)) {
            $maximumHits = max(array_values($frequentSearchTerms));
            $minimumHits = min(array_values($frequentSearchTerms));
            $spread = $maximumHits - $minimumHits;
            $step = ($spread == 0) ? 1 : ($maximumSize - $minimumSize) / $spread;

            foreach ($frequentSearchTerms as $term => $hits) {
                $size = round($minimumSize + (($hits - $minimumHits) * $step));
                $frequentSearches[] = ['q' => htmlspecialchars_decode($term), 'hits' => $hits, 'style' => 'font-size: ' . $size . 'px', 'class' => 'tx-solr-frequent-term-' . $size, 'size' => $size];
            }
        }

        return $frequentSearches;
    }
1294124
public function getSuggestions(SearchRequest $searchRequest, array $additionalFilters = []) : array
    {
        $requestId = (int)$this->tsfe->getRequestedId();
        $groupList = (string)$this->tsfe->gr_list;

        $suggestQuery = $this->queryBuilder->buildSuggestQuery($searchRequest->getRawUserQuery(), $additionalFilters, $requestId, $groupList);
        $solrSuggestions = $this->getSolrSuggestions($suggestQuery);

        if ($solrSuggestions === []) {
            return ['status' => false];
        }

        $maxSuggestions = $this->typoScriptConfiguration->getSuggestNumberOfSuggestions();
        $showTopResults = $this->typoScriptConfiguration->getSuggestShowTopResults();
        $suggestions    = $this->getSuggestionArray($suggestQuery, $solrSuggestions, $maxSuggestions);

        if (!$showTopResults) {
            return $this->getResultArray($searchRequest, $suggestions, [], false);
        }

        return $this->addTopResultsToSuggestions($searchRequest, $suggestions, $additionalFilters);
    }
168508
public function autoSize($minRows = false, $maxRows = null)
    {

        $this->props['autosize'] = $maxRows === null ? boolval($minRows) : compact('minRows', 'maxRows');
        return $this;
    }
831111
protected function searchWithPagination(ModelCriteria $search, &$pagination)
    {
        $page  = (int) $this->getArgValue('page');
        $limit = (int) $this->getArgValue('limit');

        $pagination = $search->paginate($page, $limit);

        if ($page > $pagination->getLastPage()) {
            return [];
        } else {
            return $pagination;
        }
    }
351589
public function isBetween($minSize, $maxSize, $format = 'B', $inclusive = false)
    {
        $this->addCondition(
            __METHOD__,
            [$minSize, $maxSize, $format, $inclusive],
            [
                'min'    => $minSize,
                'max'    => $maxSize,
                'format' => (\strtoupper($format[0]) == 'B') ? '' : \strtoupper($format[0])
            ]
        );

        return $this;
    }
1254831
public static function getMaxUploadSize($maxSize = null)
    {
        $maxUpload = (int)(ini_get('upload_max_filesize'));
        $maxPost = (int)(ini_get('post_max_size'));
        $memoryLimit = (int)(ini_get('memory_limit'));
        $min = min($maxUpload, $maxPost, $memoryLimit);
        if ($maxSize) {
            $maxSize = (int)$maxSize;
            return min($maxSize, $min);
        }
        return $min;
    }
295301
private static function calculateMeanMicroAmount($min, $max)
    {
        if ($min === null || $max === null) {
            return null;
        }
        if ($min->getMicroAmount() === null
            || $max->getMicroAmount() === null) {
            return null;
        }

        return ($min->getMicroAmount() + $max->getMicroAmount()) / 2;
    }
1159304
public function md5($maxsize = 5)
    {
        if ($maxsize === true) {
            return md5_file($this->path);
        }

        $size = $this->size();
        if ($size && $size < ($maxsize * 1024) * 1024) {
            return md5_file($this->path);
        }

        return false;
    }
640627
public function whereBetween($field, $min, $max)
    {
        foreach ($this->queries as $query) {
            $query->whereBetween($field, $min, $max);
        }

        return $this;
    }
15512
protected function setMaxSize($maxSize)
    {
        $this->maxSize = $this->toBytes($maxSize);
        $this->maxSizeString = $this->fromBytes($this->maxSize);
        return $this;
    }
985719
public static function getMostFrequentValues(array $data, $mostFrequentQuantity = NULL, $allocationPeriod = NULL)
    {
        $mostFrequentValues = [];

        $allocatedData = self::allocateInfo($data, $allocationPeriod);

        usort($allocatedData, function ($a, $b) {

            if ($a->getValueQuantity() === $b->getValueQuantity()) {
                if ($a->getValue() === $b->getValueQuantity()) {
                    return 0;
                }
                return ($a->getValue() < $b->getValue()) ? -1 : 1;
            } else {
                return ($a->getValueQuantity() > $b->getValueQuantity()) ? -1 : 1;
            }
        });

        if (!$mostFrequentQuantity) {
            $mostFrequentQuantity = self::MOST_FREQUENT_QUANTITY;
        }

        for ($i = 0; $i < $mostFrequentQuantity; $i++) {

            $frequentValue = new SortData();
            $frequentValue->setValue($allocatedData[$i]->getValue());
            $frequentValue->setValueQuantity($allocatedData[$i]->getValueQuantity());

            $valueExamples = ($allocatedData[$i]->getValueExamples() !== "")
                ? substr($allocatedData[$i]->getValueExamples(), 0, -2)
                : $allocatedData[$i]->getValueExamples();

            $frequentValue->setValueExamples($valueExamples);

            if ($mostFrequentQuantity === 1) {
                $mostFrequentValues = $frequentValue;
            } else {
                $mostFrequentValues[] = $frequentValue;
            }
        }

        return $mostFrequentValues;
    }
1277532
public static function getPageLimitRuleForDefaultAndMaxSizes(int $defaultSize, int $maxSize): RuleInterface
    {
        assert($maxSize > 1 && $defaultSize <= $maxSize);

        // if not given (`null` as an input) then default value otherwise input should be integer 1 <= value <= max
        return r::ifX(
            r::IS_NULL_CALLABLE,
            r::value($defaultSize),
            r::stringToInt(r::between(1, $maxSize))
        );
    }
1016598
public function matchQuantity($min, $max = null)
	{
		$match = '{'.$min;

		if ($max !== null)
		{
			$match .= ',' . $max;
		}

		$match .= '}';

		$this->value($match);

		return $this;
	}
501373
protected function sizeMin($key, $lengthValue, $min, $not = true)
    {
        if ($lengthValue < $min && $not) {
            $this->addReturn($key, 'must', [ ':min' => $min ]);
        } elseif (!($lengthValue < $min) && !$not) {
            $this->addReturn($key, 'not', [ ':min' => $min ]);
        }
    }
95797
public function setMinSizeMessage($minSizeMessage)
    {
        if (!is_string($minSizeMessage)) {
            throw new \InvalidArgumentException('The attribute minSizeMessage on the class Attribute has to be string (' . gettype($minSizeMessage) . ('object' === gettype($minSizeMessage) ? ' ' . get_class($minSizeMessage) : '') . ' given).');
        }

        $this->minSizeMessage = $minSizeMessage;

        return $this;
    }
1080136
public function indexSearch($searchText, $maxResults)
    {
        // split the phrase into words
        $words = SearchAnalyser::analyse($searchText);
        if (!$words) {
            return [];
        }

        $query = $this->_em->createQueryBuilder()
            ->select('o')
            ->from($this->_entityName, 'o')
            ->setMaxResults($maxResults);

        $parameters = [];
        foreach ($words as $k => $word) {
            $subquery = $this->_em->createQueryBuilder()
                ->select("i$k.keyword")
                ->from($this->getSearchIndexClass(), "i$k")
                ->where("i$k.object = o")
                ->andWhere("i$k.keyword ILIKE :search$k");
            $query->andWhere($query->expr()->exists($subquery->getDql()));
            $parameters["search$k"] = '%' . $word . '%';
        }
        $query->setParameters($parameters);

        $results = $query->getQuery()->execute();

        return $results;
    }
759223
function size($min = null, $max = null) {
        $size = [];
        if ($min) $size['min'] = $min;
        if ($max) $size['max'] = $max;
        if (count($size)) $this->data['size'] = $size;
        return $this;
    }