Lasso Soft Inc. > Home

[nCtag_Calendar]

LinknCtag_Calendar
AuthorBret Williams
CategoryCustom Tag
Version7.x
Licensehttp://opensource.org/licenses/gpl-license.php
Posted01 Feb 2006
Updated01 Feb 2006
More by this author...

Description

If you need to show one or more small calendars, this cTag can help. You can specify the start month, number of months to generate, dates to highlight, and whether you want a vertical or horizontal orientation. Output is a table using CSS class styles which you specify in your HTML page or included CSS file. If you don't specify styles for Title, Heading, Days, Weekends and Highlighted Dates, then it will use whatever default the browser reverts to. You may certainly use this, if it helps. Please drop me an e-mail if you do (bret@novusweb.com). It should work with v8.x, but haven't tested it yet. If you do find any bugs, please let me know. One note: in order for the HTML to show correctly in the browser, you should set encoding to -EncodeNone for the calendar output.

Sample Usage

nCtag_Calendar:
	-StartMonth			= '2006-01',
	-Months				= '3',
	-Orientation		= 'Vertical',
	-HighlightDates		= '2006-01-04 2006-01-14 2006-02-12 2006-03-21',
	-Table				= 'calTable',
	-Title				= 'calTitle',
	-Heading			= 'calHeading',
	-Day				= 'calDay',
	-Weekend			= 'calWeekend',
	-Highlight			= 'calHighlight';

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.


(Format: '%Y-%m'),
 				'LV_Months'				= (Integer: 1),
 				'LV_Orientation'		= 'Vertical',
 				'LV_HighlightDates'		= (Array),
 				'LV_Table'				= (String),
 				'LV_Title'				= (String),
 				'LV_Heading'			= (String),
 				'LV_Day'				= (String),
 				'LV_Weekend'			= (String),
 				'LV_Highlight'			= (String);
 				
			//	Test for StartMonth Parameter
			
			If: (Local: 'StartMonth')->(Size) > 0;
			
				Local: 'LV_TempDate' = (Date: (Local: 'StartMonth'), -Format = '%Y-%m');
				
				Select: #LV_TempDate;
				
					Case: NULL;
					
						#LV_StartMonth = #LV_StartMonth;
					
					Case;
					
						#LV_StartMonth = #LV_TempDate->(Format: '%Y-%m');
						
				/Select;
						
			/If;
						
			//	Test for Months Parameter
			
			If: (Local: 'Months')->(Size) > 0;
			
				Select: (String_IsDigit: (Local: 'Months'));
				
					Case: True;
					
						#LV_Months = (Local: 'Months');
						
				/Select;
			
			/If;
						
			//	Test for Orientation Parameter
			
			If: (Local: 'Orientation')->(Size) > 0;
			
				Select: (Local: 'Orientation')->(BeginsWith: 'Hor');
				
					Case: True;
					
						#LV_Orientation = 'Horizontal';
						
				/Select;
			
			/If;
						
			//	Test for HighlightDates Parameter
			
			If: (Local: 'HighlightDates')->(Size) > 0;
			
				Local: 'LV_TempHighlightDates' = (Local: 'HighlightDates')->(Split: ' ');
			
				#LV_HighlightDates = #LV_TempHighlightDates;
						
			/If;
						
			//	Test for Table Parameter
			
			If: (Local: 'Table')->(Size) > 0;
			
				#LV_Table = (Local: 'Table');
						
			/If;
						
			//	Test for Title Parameter
			
			If: (Local: 'Title')->(Size) > 0;
			
				#LV_Title = (Local: 'Title');
						
			/If;
						
			//	Test for Heading Parameter
			
			If: (Local: 'Heading')->(Size) > 0;
			
				#LV_Heading = (Local: 'Heading');
						
			/If;
						
			//	Test for Day Parameter
			
			If: (Local: 'Day')->(Size) > 0;
			
				#LV_Day = (Local: 'Day');
						
			/If;
						
			//	Test for Weekend Parameter
			
			If: (Local: 'Weekend')->(Size) > 0;
			
				#LV_Weekend = (Local: 'Weekend');
				
			Else;
			
				#LV_Weekend = #LV_Day;
						
			/If;
						
			//	Test for Highlight Parameter
			
			If: (Local: 'Highlight')->(Size) > 0;
			
				#LV_Highlight = (Local: 'Highlight');
						
			/If;
						
			//	Loop for number of Calendar rows
			
			Local: 'LV_CalendarRows' = (Integer),
				'LV_CalendarCols' = (Integer);
			
			Select: #LV_Orientation;
			
				Case: 'Horizontal';
				
					#LV_CalendarRows = 1;
					#LV_CalendarCols = #LV_Months;
				
				Case: 'Vertical';
				
					#LV_CalendarRows = #LV_Months;
					#LV_CalendarCols = 1;
			
			/Select;
			
			Local: 'LV_Build' = (String);
						
			//	Build Calendar Cells Array
			
			Local: 'LV_CalendarArray'		= (Array);
			Local: 'LV_CellArray' 			= (Array);
			Local: 'LV_MonthDate' 			= (Date: #LV_StartMonth);
			Local: 'LV_StartDay'			= (Integer);
			Local: 'LV_EndDate'				= (Integer);
			Local: 'LV_LoopMonth'			= (Integer);
			Local: 'LV_TestDate'			= (Date);
			Local: 'LV_CalendarRows'		= (Integer);
			Local: 'LV_MaxRows'				= (Integer);
			Local: 'LV_RowCountArray'		= (Array);
			Local: 'LV_DayCount'			= (Integer);
			Local: 'LV_RowCount'			= (Integer);
			
			Loop: #LV_Months;
			
				//	Initialize Necessary Vars
				
				#LV_CellArray		= (Array);
			
				//	Determine the first day of the month
				
				#LV_StartDay = #LV_MonthDate->(DayofWeek);
				
				//Determine last day of the month
				
				#LV_EndDate			= (Integer);
				#LV_LoopMonth		= (#LV_MonthDate->(Month));
				#LV_TestDate 		= (Date: -Year=(#LV_MonthDate->(Year)), -Month=(#LV_MonthDate->(Month)), -Day='28');
				
				Loop: -From=28, -To=31;
				
					If: (#LV_TestDate->(Month) == #LV_LoopMonth);
					
						#LV_EndDate = (Loop_Count);
						
					Else;
					
						Loop_Abort;
					
					/If;
					
					//	Add one day
					
					#LV_TestDate = (Date_Add: #LV_TestDate, -Day='1');
				
				/Loop;
				
				//	Pad beginning of Array
				
				Loop: (#LV_StartDay-1);
				
					#LV_CellArray->(Insert: (''));
						
				/Loop;
				
				//	Insert Remaining Cells
				
				Loop: #LV_EndDate;
				
					//	Set Calendar Date
					
					#LV_TestDate = (Date: -Year=(#LV_MonthDate->(Year)), -Month=(#LV_MonthDate->(Month)), -Day=(Loop_Count));
					
					If: (#LV_HighlightDates->(Find: #LV_TestDate)->(Size)) != 0;
					
						#LV_CellArray->(Insert: ('' + (Loop_Count) + ''));
					
					Else: (#LV_TestDate->(DayofWeek) == 1)
						|| (#LV_TestDate->(DayofWeek) == 7);
					
						#LV_CellArray->(Insert: ('' + (Loop_Count) + ''));
					
					Else;
					
						#LV_CellArray->(Insert: ('' + (Loop_Count) + ''));
					
					/If;
				
				/Loop;
				
				//	Pad End of Array
				
				If: #LV_CellArray->(Size)%7 > 0;
				
					Local: 'LV_LoopSize' = (Math_Sub: 7, (#LV_CellArray->(Size)%7));
				
					Loop: #LV_LoopSize;
					
						#LV_CellArray->(Insert: (''));
							
					/Loop;
					
				/If;
				
				//	Determine if month has maximum number of rows
				
				#LV_CalendarRows = #LV_CellArray->(Size)/7;
				
				If: #LV_CellArray->(Size)%7 > 0;
				
					#LV_CalendarRows += 1;
				
				/If;
				
				If: #LV_CalendarRows > #LV_MaxRows;
				
					#LV_MaxRows = #LV_CalendarRows;
				
				/If;
				
				//	Add Row Count to Array
				
				#LV_RowCountArray->(Insert: #LV_CalendarRows);
				
				//	Add Cell Array to Calendar Array
				
				#LV_CalendarArray->(Insert: #LV_CellArray);
			
				//	Add One Month
				
				#LV_MonthDate = (Date_Add: #LV_MonthDate, -Month=1);
				
			/Loop;
			
			#LV_MonthDate = (Date: #LV_StartMonth);
			
			//	Build Calendar Shell
			
			#LV_Build += (
				'\n');
				
			//	Build Calendar Core
				
			//	IF Vertical Orientation
			
			If: #LV_Orientation == 'Vertical';
			
				//	Loop Through Calendars
				
				Loop: #LV_Months;
				
					//	Build Title Row
					
					#LV_Build += (
						'\n'
						);
				
					//	Build Heading Row
					
					#LV_Build += (
						'\n'
						);
						
					//	Add Calendar Core
					
					#LV_CellArray						= #LV_CalendarArray->(Get: (Loop_Count));
					#LV_CalendarRows				= #LV_RowCountArray->(Get: (Loop_Count));
					#LV_DayCount						= 1;
					
					Loop: #LV_CalendarRows;
					
						#LV_Build += (
							''
							);
							
						Loop: -From=#LV_DayCount, -To=(#LV_DayCount + 6);
						
							#LV_Build += #LV_CellArray->(Get: (Loop_Count));
						
						/Loop;
						
						#LV_DayCount += 7;
					
						#LV_Build += (
							''
							);

					/Loop;
						
					//	Add One Month
					
					#LV_MonthDate = (Date_Add: #LV_MonthDate, -Month=1);
				
				/Loop;
			
			//	ELSE IF Horizontal Orientation
				
			Else;
			
				//	Build Table Title Row
				
				#LV_Build += (
					''
					);
					
				Loop: #LV_Months;
				
					#LV_Build += (
						''
						);
						
					#LV_MonthDate = (Date_Add: #LV_MonthDate, -Month=1);
				
				/Loop;
			
				#LV_Build += (
					'\n'
					);
					
				#LV_MonthDate = (Date: #LV_StartMonth);

				//	Build Table Heading Row
				
				#LV_Build += (
					''
					);
					
				Loop: #LV_Months;
				
					#LV_Build += (
						''
						);
						
				/Loop;
			
				#LV_Build += (
					'\n'
					);
					
				//	Build each row of dates
				
				#LV_DayCount = 1;
				
				Loop: #LV_MaxRows;
				
					#LV_Build += (
						''
						);
						
					#LV_RowCount = (Loop_Count);
						
					Loop: #LV_Months;
					
						#LV_CellArray = #LV_CalendarArray->(Get: (Loop_Count));
					
						If: #LV_RowCountArray->(Get: (Loop_Count)) >= #LV_Rowcount;
						
							Loop: -From=#LV_DayCount, -To=(#LV_DayCount + 6);
						
								#LV_Build += #LV_CellArray->(Get: (Loop_Count));
						
							/Loop;
						
						Else;
						
							#LV_Build += ('');
						
						/If;
						
					/Loop;
				
					#LV_Build += (
						'\n'
						);
					
					#LV_DayCount += 7;
					
				/Loop;
					
			/If;

			//	Build closing part of table

			#LV_Build += (
				'
' + #LV_MonthDate->(Format: '%B %Y') + '
SMTWTFS
' + #LV_MonthDate->(Format: '%B %Y') + '
SMTWTFS
\n'); // Return final build Return: #LV_Build; /Define_Tag; /If; // ] ?>

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft