root/trunk/website/blog/includes/pods/calendar.cfm @ 5

Revision 5, 4.7 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

RevLine 
[5]1<cfsetting enablecfoutputonly=true>
2<cfprocessingdirective pageencoding="utf-8">
3<!---
4        Name         : calendar
5        Author       : Raymond Camden + Paul Hastings
6        Created      : February 11, 2003
7        Last Updated : August 2, 2006
8        History      : Reset history for version 5.0
9                                 : Forgot to SES the links on first row. Thanks to Lucas for pointing it out. (rkc 7/4/06)
10                                 : Bad SES link in first row (rkc 8/2/06)
11        Purpose          : Handles blog calendar
12--->
13
14<cfset offset = application.blog.getProperty("offset")>
15<cfset now = dateAdd("h", offset, now())>
16
17<cfparam name="month" default="#month(now)#">
18<cfparam name="year" default="#year(now)#">
19
20<cfmodule template="../../tags/podlayout.cfm" title="#application.resourceBundle.getResource("calendar")#">
21
22<cfscript>                                      
23        // no idea why this was so hard to conceive     
24        function getFirstWeekPAD(firstDOW) {
25                var firstWeekPad=0;
26                var weekStartsOn=application.localeutils.weekStarts();
27                switch (weekStartsON) {
28                        case 1:
29                                firstWeekPAD=firstDOW-1;
30                        break;
31                        case 2:
32                                firstWeekPAD=firstDOW-2;
33                                if (firstWeekPAD LT 0) firstWeekPAD=firstWeekPAD+7; // handle leap years
34                        break;
35                        case 7:
36                                firstWeekPAD=7-abs(firstDOW-7);
37                                if (firstWeekPAD EQ 7) firstWeekPAD=0;
38                        break;
39                }
40                return firstWeekPAD;
41        }
42       
43        localizedDays=application.localeutils.getLocalizedDays();
44        localizedMonth=application.localeutils.getLocalizedMonth(month);
45        localizedYear=application.localeutils.getLocalizedYear(year);
46        firstDay=createDate(year,month,1);
47        firstDOW=dayOfWeek(firstDay);
48        dim=daysInMonth(firstDay);
49        firstWeekPAD=getFirstWeekPAD(firstDOW);
50        lastMonth=dateAdd("m",-1,firstDay);
51        nextMonth=dateAdd("m",1,firstDay);     
52        dayList=application.blog.getActiveDays(year,month);
53        dayCounter=1;
54        rowCounter=1;
55</cfscript>
56
57
58<!--- swap navigation buttons if BIDI is true --->
59<cfoutput>
60        <div class="header">
61        <cfif application.localeutils.isBIDI()>
62                <a href="#application.blog.getProperty("blogurl")#/#year(nextmonth)#/#month(nextmonth)#" rel="nofollow">&lt;&lt;</a>
63                <a href="#application.blog.getProperty("blogurl")#/#year#/#month#" rel="nofollow">#localizedMonth# #localizedYear#</a>
64                <a href="#application.blog.getProperty("blogurl")#/#year(lastmonth)#/#month(lastmonth)#" rel="nofollow">&gt;&gt;</a>           
65        <cfelse>
66                <a href="#application.blog.getProperty("blogurl")#/#year(lastmonth)#/#month(lastmonth)#" rel="nofollow">&lt;&lt;</a>
67                <a href="#application.blog.getProperty("blogurl")#/#year#/#month#" rel="nofollow">#localizedMonth# #localizedYear#</a>
68                <a href="#application.blog.getProperty("blogurl")#/#year(nextmonth)#/#month(nextmonth)#" rel="nofollow">&gt;&gt;</a>
69        </cfif>
70        </div>
71</cfoutput>
72<cfoutput>
73<table border=0 class="calendarTable" id="calendar">
74<thead>
75<tr>
76        <!--- emit localized days in proper week start order --->
77        <cfloop index="i" from="1" to="#arrayLen(localizedDays)#">
78        <th>#localizedDays[i]#</th>
79        </cfloop>
80</tr>
81</thead>
82<tbody>
83</cfoutput>
84<!--- loop until 1st --->
85<cfoutput><tr></cfoutput>
86<cfloop index="x" from=1 to="#firstWeekPAD#">
87        <cfoutput><td>&nbsp;</td></cfoutput>
88</cfloop>
89
90<!--- note changed loop to start w/firstWeekPAD+1 and evaluated vs dayCounter instead of X --->
91<cfloop index="x" from="#firstWeekPAD+1#" to="7">
92        <cfoutput><td <cfif month(now) eq month and dayCounter eq day(now) and year(now) eq year> class="calendarToday"</cfif>><cfif listFind(dayList,dayCounter)><a href="#application.blog.getProperty("blogurl")#/#year#/#month#/#dayCounter#" rel="nofollow">#dayCounter#</a><cfelse>#dayCounter#</cfif></td></cfoutput>
93        <cfset dayCounter = dayCounter + 1>
94</cfloop>
95<cfoutput></tr></cfoutput>
96<!--- now loop until month days --->
97<cfloop index="x" from="#dayCounter#" to="#dim#">
98        <cfif rowCounter is 1>
99                <cfoutput><tr></cfoutput>
100        </cfif>
101        <cfoutput>
102                <td <cfif month(now) eq month and x eq day(now) and year(now) eq year> class="calendarToday"</cfif>>
103                <!--- the second clause here fixes an Oracle glitch where 9 comes back as 09. Should be harmless for other DBs that aren't as 'enterprise-y' as Oracle --->
104                <cfif listFind(dayList,x) or listFind(dayList, "0" & x)><a href="#application.blog.getProperty("blogurl")#/#year#/#month#/#x#" rel="nofollow">#x#</a><cfelse>#x#</cfif>
105                </td>
106        </cfoutput>
107        <cfset rowCounter = rowCounter + 1>
108        <cfif rowCounter is 8>
109                <cfoutput></tr></cfoutput>
110                <cfset rowCounter = 1>
111        </cfif>
112</cfloop>
113<!--- now finish up last row --->
114<cfif rowCounter GT 1> <!--- test if ran out of days --->
115        <cfloop index="x" from="#rowCounter#" to=7>
116                <cfoutput><td>&nbsp;</td></cfoutput>
117        </cfloop>
118        <cfoutput></tr></cfoutput>
119</cfif>
120<cfoutput>
121</tbody>
122</table>
123</cfoutput>
124
125</cfmodule>
126
127<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.