dt_navbar_year (private)

 dt_navbar_year view base_url date

Defined in packages/acs-datetime/tcl/acs-calendar-procs.tcl

If this is a month or year view, returns the current year with links to previous and next. Otherwise it just returns the empty string.

Parameters:
view
base_url
date

Partial Call Graph (max 5 caller/called nodes):
%3 dt_widget_calendar_navigation dt_widget_calendar_navigation (public, deprecated) dt_navbar_year dt_navbar_year dt_widget_calendar_navigation->dt_navbar_year dt_left_arrow dt_left_arrow (private) dt_navbar_year->dt_left_arrow dt_right_arrow dt_right_arrow (private) dt_navbar_year->dt_right_arrow

Testcases:
No testcase defined.
Source code:
    # Return immediately of the current view isn't month or year
    if {$view ni [list month year]} {
        return ""
    }

    # Convert the given data into current calendar time
    set now [clock scan $date]

    # Compute formatted strings for curr, prev, and next

    # Check that links to prev/next year don't lead to illegal dates that would bomb
    if {[catch {set prev_year [clock format [clock scan "1 year ago" -base $now] -format "%Y-%m-%d"]} err]} {
        set prev_year_legal_p 0
    } else {
        if {[catch {clock scan $prev_year}]} {
            set prev_year_legal_p 0
        } else {
            set prev_year_legal_p 1
        }
    }

    if {[catch {set next_year [clock format [clock scan "1 year" -base $now] -format "%Y-%m-%d"]} err]} {
        set next_year_legal_p 0
    } else {
        if {[catch {clock scan $next_year}]} {
            set next_year_legal_p 0
        } else {
            set next_year_legal_p 1
        }
    }

    set curr_year [clock format $now -format "%Y"]

    append result [subst {
    <tr>
    <td nowrap align="center" colspan="5" class="no-border">
    <table cellspacing="0" cellpadding="1" border="0">
    <tr><td nowrap valign="middle">
    }]

    # Serve arrow link to prev year if it leads to legal date
    if {$prev_year_legal_p != 0} {
        append result [subst {
            <a href="[ns_quotehtml ${base_url}view=$view&date=[ns_urlencode $prev_year]]">
            <img alt="left arrow" src="[dt_left_arrow]"></a>
        }]
    }

    append result "
    <b>$curr_year</b>"

    # Serve arrow to next year if it leads to a legal date
    if {$next_year_legal_p != 0} {
        append result [subst {
            <a href="[ns_quotehtml ${base_url}view=$view&date=[ns_urlencode $next_year]]">
            <img alt="right arrow" src="[dt_right_arrow]"></a>
        }]
    }

    append result "
        </td>
        </tr>
        </table>
        </td>
        </tr>\n"

    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ]
Show another procedure: