/** * Generates an array with terms and hits * * @return array Tags as array with terms and hits */ protected function getFrequentSearchTerms() { $terms = array(); // Use configuration as cache identifier $identifier = 'frequentSearchesTags'; if ($this->configuration['search.']['frequentSearches.']['select.']['checkRootPageId']) { $identifier .= '_RP' . (int) $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']; } if ($this->configuration['search.']['frequentSearches.']['select.']['checkLanguage']) { $identifier .= '_L' . (int) $GLOBALS['TSFE']->sys_language_uid; } $identifier .= '_' . md5(serialize($this->configuration['search.']['frequentSearches.'])); if ($this->cacheInstance->has($identifier)) { $terms = $this->cacheInstance->get($identifier); } else { $terms = $this->getFrequentSearchTermsFromStatistics(); if ($this->configuration['search.']['frequentSearches.']['sortBy'] == 'hits') { arsort($terms); } else { ksort($terms); } $lifetime = null; if (isset($this->configuration['search.']['frequentSearches.']['cacheLifetime'])) { $lifetime = intval($this->configuration['search.']['frequentSearches.']['cacheLifetime']); } $this->cacheInstance->set($identifier, $terms, array(), $lifetime); } return $terms; }
/** * Generates an array with terms and hits * * @return array Tags as array with terms and hits */ public function getFrequentSearchTerms() { $frequentSearchConfiguration = $this->configuration->getSearchFrequentSearchesConfiguration(); $terms = array(); $identifier = $this->getCacheIdentifier($frequentSearchConfiguration); if ($this->cache->has($identifier)) { $terms = $this->cache->get($identifier); } else { $terms = $this->getFrequentSearchTermsFromStatistics($frequentSearchConfiguration); if ($frequentSearchConfiguration['sortBy'] == 'hits') { arsort($terms); } else { ksort($terms); } $lifetime = null; if (isset($frequentSearchConfiguration['cacheLifetime'])) { $lifetime = intval($frequentSearchConfiguration['cacheLifetime']); } $this->cache->set($identifier, $terms, array(), $lifetime); } return $terms; }