/** * Количество топиков по фильтру * * @param array $aFilter Фильтр * * @return int */ public function GetCountTopicsByFilter($aFilter) { $sTmpCacheKey = 'get_count_topics_by_' . serialize($aFilter) . '_' . E::UserId(); if (FALSE === ($iResult = E::ModuleCache()->GetTmp($sTmpCacheKey))) { $iResult = 0; if (isset($aFilter['blog_type'])) { $aBlogsType = (array) $aFilter['blog_type']; unset($aFilter['blog_type']); if (isset($aBlogsType['*'])) { $aBlogsId = $aBlogsType['*']; unset($aBlogsType['*']); } else { $aBlogsId = array(); } $sCacheKey = 'topic_count_by_blog_type_' . serialize($aFilter); if (false === ($aData = E::ModuleCache()->Get($sCacheKey))) { $aData = $this->oMapper->GetCountTopicsByBlogtype($aFilter); E::ModuleCache()->Set($aData, $sCacheKey, array('topic_update', 'topic_new', 'blog_update', 'blog_new'), 'P1D'); } if ($aData) { foreach ($aBlogsType as $sBlogType) { if (isset($aData[$sBlogType])) { $iResult += $aData[$sBlogType]; } } } if ($aBlogsId) { $aFilter['blog_id'] = $aBlogsId; $aFilter['blog_type_exclude'] = $aBlogsType; $iCount = $this->GetCountTopicsByFilter($aFilter); $iResult += $iCount; } return $iResult; } else { $sCacheKey = 'topic_count_' . serialize($aFilter); if (false === ($iResult = E::ModuleCache()->Get($sCacheKey))) { $iResult = $this->oMapper->GetCountTopics($aFilter); E::ModuleCache()->Set($iResult, $sCacheKey, array('topic_update', 'topic_new'), 'P1D'); } } E::ModuleCache()->SetTmp($iResult, $sTmpCacheKey); } return $iResult ? $iResult : 0; }