function getNewsCountForCategory($catID) { $sum = false; if (isset($this->categoryCountCache[$catID])) { $sum = $this->categoryCountCache[$catID]; } if ($sum !== false) { // t3lib_div::devLog('CACHE HIT (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', - 1, array()); } else { if ($this->tt_news_obj->cache_categoryCount) { $hash = t3lib_div::shortMD5(serialize($catID . $this->newsSelConf['pidInList'] . $this->newsSelConf['where'] . $this->tt_news_obj->enableFields . $this->clause), 30); $sum = $this->tt_news_obj->cache->get($hash); } if ($sum === false) { if ($this->tt_news_obj->writeCachingInfoToDevlog) { t3lib_div::devLog('CACHE MISS (single count) (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', 2, array()); } $result = array(); $result['sum'] = 0; $news_clause = ''; if (is_object($this->tt_news_obj)) { $news_clause .= ' AND ' . $this->newsSelConf['where'] . $this->tt_news_obj->enableFields; if ($this->newsSelConf['pidInList']) { $news_clause .= ' AND tt_news.pid IN (' . $this->newsSelConf['pidInList'] . ') '; } } tx_ttnews_div::getNewsCountForSubcategory($result, $catID, $news_clause, $this->clause); $sum = $result['sum']; } $this->categoryCountCache[$catID] = (int) $sum; if ($this->tt_news_obj->cache_categoryCount) { $this->tt_news_obj->cache->set($hash, (string) $sum, 'categoryCounts'); } } return $sum; }
function getNewsCountForSubcategory(&$result, $cat, $news_clause, $catclause) { // count news in current category $select_fields = 'COUNT(DISTINCT tt_news.uid)'; $from_table = ' tt_news_cat, tt_news_cat_mm, tt_news '; $where_clause = ' tt_news_cat.uid=' . $cat . ' AND tt_news_cat.uid=tt_news_cat_mm.uid_foreign AND tt_news_cat_mm.uid_local=tt_news.uid '; $where_clause .= $news_clause; $where_clause .= $catclause; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause); $cRow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); // debug($cRow, ' ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3); $GLOBALS['TYPO3_DB']->sql_free_result($res); $result['sum'] += $cRow[0]; // $result[$cat] = $cRow[0]; // get subcategories $select_fields = 'tt_news_cat.uid'; $from_table = ' tt_news_cat'; $where_clause = ' tt_news_cat.parent_category=' . $cat . ' AND tt_news_cat.deleted=0 AND tt_news_cat.hidden=0 '; $where_clause .= $catclause; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { tx_ttnews_div::getNewsCountForSubcategory($result, $row['uid'], $news_clause, $catclause); // debug($result, '$result cat: '.$row['uid'].' ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3); } $GLOBALS['TYPO3_DB']->sql_free_result($res); }