You are here

function theme_archive_navigation_months in Archive 6

Same name and namespace in other branches
  1. 5 archive.inc \theme_archive_navigation_months()
  2. 7.2 archive.pages.inc \theme_archive_navigation_months()
  3. 7 archive.pages.inc \theme_archive_navigation_months()

Theme the list of months for the archive navigation.

1 theme call to theme_archive_navigation_months()
theme_archive_navigation in ./archive.pages.inc
Theme the archive navigation with years, months and dates by default.

File

./archive.pages.inc, line 288

Code

function theme_archive_navigation_months($type, $date) {
  $output = "<ul id=\"archive-months\">\n";
  $all_count = 0;
  foreach ($date->months as $month) {
    $all_count += $month;
  }
  $output .= '<li' . ($date->month ? '' : ' class="selected"') . '>' . l(t('All'), _archive_url($type, $date->year), array(
    'attributes' => array(
      'title' => format_plural($all_count, '1 post', '@count posts'),
    ),
  )) . "</li>\n";
  $curr_month = date('n', time());
  $curr_year = date('Y', time());
  foreach (range(1, 12) as $month) {
    $posts = !empty($date->months[$month]) ? $date->months[$month] : 0;
    $class = '';
    if ($month == $date->month) {
      $class = ' class="selected"';
    }
    else {
      if ($curr_year == $date->year && $month > $curr_month) {
        $class = ' class="future"';
      }
    }
    $month_names = array(
      '',
      'Jan',
      'Feb',
      'Mar',
      'Apr',
      'May',
      'Jun',
      'Jul',
      'Aug',
      'Sep',
      'Oct',
      'Nov',
      'Dec',
    );
    $output .= "<li{$class}>" . ($posts > 0 ? l(t($month_names[$month]), _archive_url($type, $date->year, $month), array(
      'attributes' => array(
        'title' => format_plural($posts, "1 post", "@count posts"),
      ),
    )) : t($month_names[$month])) . "</li>\n";
  }
  $output .= "</ul>\n";
  return $output;
}