dt_widget_calendar_navigation (public, deprecated)

 dt_widget_calendar_navigation [ base_url ] [ view ] [ date ] \
    [ pass_in_vars ]

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

Deprecated. Invoking this procedure generates a warning.

This proc creates a mini calendar useful for navigating various calendar views. It takes a base url, which is the url to which this mini calendar will navigate. pass_in_vars, if defined, can be url variables to be set in base_url. They should be in the format returned by export_url_vars This proc will set 2 variables in that url's environment: the view and the date. Valid views are list, day, week, month, and year. (ben) for now I am disabling year, which doesn't work. The date must be formatted YYYY-MM-DD. DEPRECATED: this api is never used in upstream code. One historical usage was in the calendar package, that has its own caldar UI since many years. Having such widgets in the api makes it also difficult to style them.

Parameters:
base_url (optional)
view (optional, defaults to "week")
date (optional)
pass_in_vars (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) dt_ansi_to_pretty dt_ansi_to_pretty (public) dt_get_info dt_get_info (public) dt_julian_to_ansi dt_julian_to_ansi (public) dt_month_names dt_month_names (public) dt_widget_calendar_navigation dt_widget_calendar_navigation dt_widget_calendar_navigation->ad_log_deprecated dt_widget_calendar_navigation->dt_ansi_to_pretty dt_widget_calendar_navigation->dt_get_info dt_widget_calendar_navigation->dt_julian_to_ansi dt_widget_calendar_navigation->dt_month_names

Testcases:
No testcase defined.
Source code:
ad_log_deprecated proc dt_widget_calendar_navigation

    # valid views are "list" "day" "week" "month" "year"

    if {$base_url eq ""} {
        set base_url [ns_conn url]
    }

    if {$pass_in_vars ne ""} {
        append base_url "?$pass_in_vars&"
    } else {
        append base_url "?"
    }

    if {$date eq ""} {
        set date [dt_sysdate]
    }

    set list_of_vars [list]

    # Ben: some annoying stuff to do here since we are passing in things in GET format already
    foreach {key value} [ns_set array [ns_parsequery $pass_in_vars]] {
        lappend list_of_vars [list $key $value]
    }

    # Get the current month, day, and the first day of the month

    dt_get_info $date

    set output "
    <center><table class=\"table-display\" border='1' cellpadding='1' cellspacing='0' width='160'>

    [dt_navbar_view $view $base_url $date]

    [dt_navbar_year $view $base_url $date]\n"

    if {$view eq "month"} {
        # month view
        append output [subst {
            <tr>
            <td class="no-borders" colspan="5">
            <table bgcolor="ffffff" cellspacing="3" cellpadding="1" border="0">
            <tr>
        }]

        set months_list [dt_month_names]
        set now         [clock scan $date]
        set curr_month  [expr {[util::trim_leading_zeros [clock format $now -format "%m"]] - 1}]

        for {set i 0} {$i < 12} {incr i} {

            set month [lindex $months_list $i]

            # show 3 months in a row

            if {$i != 0 && $i % 3 == 0} {
                append output "</tr><tr>"
            }

            if {$i == $curr_month} {
                append output "
                <td>
                <span style=\"font-size: smaller; color: red\">$month</span>
                </td>\n"
            } else {
                set target_date [clock format  [clock scan "[expr {$i-$curr_month}] month" -base $now]  -format "%Y-%m-%d"]

                append output [subst {
                    <td>
                    <a href="[ns_quotehtml ${base_url}view=month&date=[ns_urlencode $target_date]]">
                    <span style="font-size: smaller; color: blue;">$month</span></a>
                    </td>
                }]
            }
        }

        append output "</tr>"

    } elseif {$view eq "year"} {

    # year view

        append output "
        <tr>
        <td colspan='5'>
        <table bgcolor='ffffff' cellspacing='3' cellpadding='1' border='0'>
        <tr>\n"

        set now       [clock scan $date]
        set curr_year $year
        set end_year  [expr {$year + 2}]
        set monthday  [clock format $now -format "%m-%d"]

        for {set year [expr {$curr_year - 2}]} {$year <= $end_year} {incr year} {
            if {$year == $curr_year} {
                append output "
                <td><span style=\"font-size: smaller; color: red\">$year</span></td>\n"
            } else {
                append output [subst {
                    <td>
                    <a href="[ns_quotehtml ${base_url}view=year&date=[ns_urlencode $year-$monthday]]">
                    <span style="font-size: smaller; color: blue;">$year</span></a>
                    </td>
                }]
            }
        }

        append output "</tr>"

    } else {

        append output "
            [dt_navbar_month $view $base_url $date]
            </table>
            </td>
            </tr>

            <tr><td class='bottom-border' colspan='5'>
            <table cellspacing='3' cellpadding='1'>
            <tr>
        "

        set days_of_week [list S M T W T F S]

        foreach day_of_week $days_of_week {
            append output [subst {
                <td align="right"><span style="font-size: smaller; font-weight: bold;">$day_of_week</span>
                </td>
            }]
        }
        append output "</tr><tr><td colspan='7'><hr></td></tr>"

        set day_of_week 1
        set julian_date $first_julian_date
        set day_number  $first_day

        while {1} {

            if {$julian_date < $first_julian_date_of_month} {
                set before_month_p 1
                set after_month_p  0
            } elseif {$julian_date > $last_julian_date_in_month} {
                set before_month_p 0
                set after_month_p  1
            } else {
                set before_month_p 0
                set after_month_p  0
            }

            set ansi_date [dt_julian_to_ansi $julian_date]

            if {$julian_date == $first_julian_date_of_month} {
                set day_number 1
            } elseif {$julian_date > $last_julian_date} {
                break
            } elseif {$julian_date == $last_julian_date_in_month + 1} {
                set day_number 1
            }

            if { $day_of_week == 1} {
                append output "<tr>\n"
            }

            if {$before_month_p || $after_month_p} {
                append output [subst {
                    <td align="right">
                    <a href="[ns_quotehtml ${base_url}view=$view&date=[ns_urlencode $ansi_date]]">
                    <span style="color: gray">$day_number</span></a>
                    </td>
                }]
            } elseif {$julian_date == $julian_date_today} {
                append output "
                <td align='right'>
                <strong>$day_number</strong>
                </td>"
            } else {
                append output [subst {
                    <td align="right">
                    <a href="[ns_quotehtml ${base_url}view=$view&date=[ns_urlencode $ansi_date]]">
                    <span style="color: blue">$day_number</span></a>
                    </td>
                }]
            }

            incr day_of_week
            incr julian_date
            incr day_number

            if { $day_of_week > 7 } {
                set day_of_week 1
                append output "</tr>\n"
            }
        }
    }

    append today_url "$base_url" "view=day&date=[ns_urlencode [dt_sysdate]]"

    append output "
        <tr><td align='center' colspan='7'>
        <table cellspacing='0' cellpadding='1' border='0'>
        <tr><td></td></tr>
        </table>
        </td>
        </tr>
        </table>
        </td>
        </tr>
        <tr class=\"table-header\"><td align='center' colspan='5'>
        <table cellspacing='0' cellpadding='0' border='0'>
        <tr><td nowrap>
        <span style=\"font-size: smaller\">"

    if { $view eq "day" && [dt_sysdate] == $date } {
        append output "<strong>Today</strong>"
    } else {
        append output [subst {<a href="[ns_quotehtml $today_url]"><strong>Today</strong></a> }]
    }

    append output [subst {
        is [dt_ansi_to_pretty]</span></td></tr>
        <tr><td align="center"><br>
        <form method='get' action="[ns_quotehtml $base_url]">
        <div>
        <input type="text" name="date" size="10">
        <input type="image" src="/resources/acs-subsite/go.gif" alt="Go" border="0"><br>
        <span style="font-size:smaller">Date as YYYYMMDD</span>
        <input type="hidden" name="view" value="day">
            </div>
    }]

    foreach var $list_of_vars {
        append output "<input type='hidden' name='[lindex $var 0]' value='[lindex $var 1]'>"
    }

    append output "
        </form>
        </td>
        </tr>
        </table>
        </td>
        </tr>
        </table>\n"

    return $output
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: