function findArchivesCount($since = null, $lang = 'fre') { /*$cache = Cache::read('BlogCategoryList'); $cacheKey = 'BlogArchivesList-'.Configure::read('Config.language'); if(!empty($cache[$cacheKey])){ return $cache[$cacheKey]; }*/ if (!$since) { $since = strtotime("-12 months", strtotime(date("Y-m-1"))); } else { $since = strtotime($since); } $this->BlogPost = ClassRegistry::init('BlogPost'); $this->BlogPost->recursive = -1; $monthList = array(); $archiveList = array(); $bp = $this->BlogPost->find('all', array('order' => 'BlogPost.created DESC', 'conditions' => array('BlogPost.created >= ' => date('Y-m-d H:i:s', $since)))); if (!empty($bp)) { foreach ($bp as $k => $b) { $monthList[date_('Y-m', strtotime($b['BlogPost']['created']), $lang)][] = $b; } foreach ($monthList as $ym => $b) { $cb = count($b); $archiveList[$ym] = array('m' => date_('m', strtotime($b[0]['BlogPost']['created']), $lang), 'y' => date_('Y', strtotime($b[0]['BlogPost']['created']), $lang), 'date' => date_('Y-m-01', strtotime($b[0]['BlogPost']['created']), $lang), 'cb' => $cb); } } /*$cache[$cacheKey] = $monthList; Cache::write('BlogCategoryList', $cache);*/ return $archiveList; }
function date($format = "jS F Y") { return date_($format, strtotime($this->newsletter["Newsletter"]["date"]), !empty($this->newsletter['Newsletter']['lang']) ? $this->newsletter['Newsletter']['lang'] : null); }