protected function compileYearlyMenu()
    {
        $arrData = array();
        $time = \Date::floorToMinute();
        $newsIds = $this->getFilteredNewsIds();

        // Get the dates
        $objDates = $this->Database->query("SELECT FROM_UNIXTIME(date, '%Y') AS year, COUNT(*) AS count FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ")" . ((!BE_USER_LOGGED_IN || TL_MODE == 'BE') ? " AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1'" : "") . ((count($newsIds) > 0) ? (" AND id IN (" . implode(',', $newsIds) . ")") : "") . " GROUP BY year ORDER BY year DESC");

        while ($objDates->next())
        {
            $arrData[$objDates->year] = $objDates->count;
        }

        // Sort the data
        ($this->news_order == 'ascending') ? ksort($arrData) : krsort($arrData);

        $arrItems = array();
        $count = 0;
        $limit = count($arrData);

        // Prepare the navigation
        foreach ($arrData as $intYear=>$intCount)
        {
            $intDate = $intYear;
            $quantity = sprintf((($intCount < 2) ? $GLOBALS['TL_LANG']['MSC']['entry'] : $GLOBALS['TL_LANG']['MSC']['entries']), $intCount);

            $arrItems[$intYear]['date'] = $intDate;
            $arrItems[$intYear]['link'] = $intYear;
            $arrItems[$intYear]['href'] = $this->strUrl . '?year=' . $intDate;
            $arrItems[$intYear]['title'] = \StringUtil::specialchars($intYear . ' (' . $quantity . ')');
            $arrItems[$intYear]['class'] = trim(((++$count == 1) ? 'first ' : '') . (($count == $limit) ? 'last' : ''));
            $arrItems[$intYear]['isActive'] = (\Input::get('year') == $intDate);
            $arrItems[$intYear]['quantity'] = $quantity;
        }

        $this->Template->yearly = true;
        $this->Template->items = $arrItems;
        $this->Template->showQuantity = ($this->news_showQuantity != '');
    }