/** * @param int $year * @param int $month * @param int $day * @param int $currentPage */ public function archive($year, $month, $day, $currentPage = 1) { $this->loadMainData(); $perPage = 50; $offset = $currentPage > 1 ? ($currentPage - 1) * $perPage : 0; $this->data['pageType'] = 'archive'; $this->data['monthly_archive'] = true; $this->data['archive_year'] = $year; $this->data['archive_month'] = $month; $this->data['archive_day'] = $day; if ($day) { $this->data['tweets'] = $this->model->getTweetsByDay($year, $month, $day, $offset, $perPage); $this->data['tweetsTotalCount'] = $this->model->getTweetsByDayCount($year, $month, $day); $pageBaseUrl = $this->data['config']['system']['baseUrl'] . 'archive/' . $year . '/' . $month . '/' . $day . '/'; $date = str_pad($day, 2, '0', STR_PAD_LEFT) . '/' . str_pad($month, 2, '0', STR_PAD_LEFT) . '/' . $year; $this->data['title'] = $this->i18n->trans('archives_from_day', ['ucf'], ['date' => $date]); } elseif ($month) { $this->data['tweets'] = $this->model->getTweetsByMonth($year, $month, $offset, $perPage); $this->data['tweetsTotalCount'] = $this->model->getTweetsByMonthCount($year, $month); $pageBaseUrl = $this->data['config']['system']['baseUrl'] . 'archive/' . $year . '/' . $month . '/'; $this->data['title'] = $this->i18n->trans('archives_from_month', ['ucf'], ['date' => str_pad($month, 2, '0', STR_PAD_LEFT) . '/' . $year]); } else { $this->data['tweets'] = $this->model->getTweetsByYear($year, $offset, $perPage); $this->data['tweetsTotalCount'] = $this->model->getTweetsByYearCount($year); $pageBaseUrl = $this->data['config']['system']['baseUrl'] . 'archive/' . $year . '/'; $this->data['title'] = $this->i18n->trans('archives_from_year', ['ucf'], ['date' => $year]); } $this->data['pagination'] = $this->paginator->paginate($pageBaseUrl, $this->data['tweetsTotalCount'], $currentPage, $perPage); $this->render('index.php'); }