$count_years = count($years);
for ($i = 0; $i < $count_years; $i++) {
    if ($years[$i] != $year) {
        continue;
    }
    $next_year = $years[$i + 1];
    $previous_year = $years[$i - 1];
    break;
}
$months = dates_utils_months();
$user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
$GLOBALS['smarty']->assign("next_year", $next_year);
$GLOBALS['smarty']->assign("previous_year", $previous_year);
if (!$previous_year) {
    $ymd = "{$year}-01-01";
    if ($previous_ymd = flickr_photos_archives_previous_date_for_user($owner, $ymd, $more)) {
        $GLOBALS['smarty']->assign("previous", explode("-", $previous_ymd));
    }
}
if (!$next_year) {
    $ymd = "{$year}-12-31";
    if ($next_ymd = flickr_photos_archives_next_date_for_user($owner, $ymd, $more)) {
        $GLOBALS['smarty']->assign("next", explode("-", $next_ymd));
    }
}
$GLOBALS['smarty']->assign("months", $months);
$GLOBALS['smarty']->assign("user_months", $user_months);
$GLOBALS['smarty']->assign_by_ref("photos", $photos);
$GLOBALS['smarty']->assign("year", $year);
$pagination_url = flickr_urls_photos_user_archives($owner, $user_context);
$pagination_url .= "{$year}/";
function flickr_photos_archives_bookends_for_user_and_date(&$user, $date, $more = array())
{
    $before = flickr_photos_archives_previous_date_for_user($user, $date, $more);
    $after = flickr_photos_archives_next_date_for_user($user, $date, $more);
    return array($before, $after);
}