/** * List all of the blog posts for a given year * @param string $year * @route blog/{year} */ public function listYear(string $year) { list($offset, $limit) = $this->getOffsetAndLimit(); $count = $this->blog->countByYear($year); $blogRoll = $this->blog->listByYear($year, $limit, $offset); $mathJAX = false; foreach ($blogRoll as $i => $blog) { $blogRoll[$i] = $this->blog->getSnippet($blog); if (Binary::safeStrlen($blogRoll[$i]['snippet']) !== Binary::safeStrlen($blog['body'])) { $blogRoll[$i]['snippet'] = \rtrim($blogRoll[$i]['snippet'], "\n"); } $mathJAX = $mathJAX || \strpos($blog['body'], '$$') !== false; } $dt = new \DateTime("{$year}-01-01"); $page = (int) \ceil($offset / ($limit ?? 1)) + 1; $args = ['blogroll' => $blogRoll, 'mathjax' => $mathJAX, 'pageTitle' => \__('Blog Posts in the Year %s (Page %d)', 'default', Util::noHTML($dt->format('Y')), $page), 'pagination' => ['base' => \Airship\LensFunctions\cabin_url() . 'blog/' . $year, 'suffix' => '/?page=', 'count' => $count, 'page' => $page, 'per_page' => $limit]]; $this->config('blog.cachelists') ? $this->stasis('blog/list', $args) : $this->lens('blog/list', $args); }