^Status|First Draft| ^Todo|Expand on Start-of-week-day, add all methods| ====== Calendar Library ====== ===== Overview ===== Provides methods for generating and working with a calendar. The library outputs a calendar month in HTML, for use in the system view ''system/views/kohana_calendar.php'' ===== Loading the calendar library ===== The Calendar class is loaded into your controller using: $this->calendar = new Calendar(); Access to the library is available through $this->calendar The parameters of this constructor are: * [integer] month * [integer] year * [boolean] put this argument on TRUE if you want weeks to start on monday (depends of your localization) ==== Example ==== $cal = new Calendar(1,2008); // January, 2008. The default is current month and year echo $cal->render(); // the view is automatically rendered from the library Produces an HTML calendar
January 2008
Sun Mon Tue Wed Thu Fri Sat
28 29 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
==== Adjusting the calendar ==== The layout of the calendar can be adjusted by creating the following file: ''application/views/kohana_calendar.php'' The native Kohana calendar file can be copied from ''system/views/kohana_calendar.php'' to have template to start working from. ===== Adding events to calendar ===== Kohana Calendar allow us to add events. ====Example==== $calendar = new Calendar(); $calendar -> attach($calendar -> event() -> condition('year', '2008') -> condition('month', '5') -> condition('day', '23') -> output(html::anchor('http://kohanaphp.com', 'Click here!'))); $calendar -> render(); ====Condition syntax==== function condition($key, $value) * @chainable * @param string condition key * @param mixed condition value * @return object ====List of conditions==== * timestamp - UNIX timestamp * day - day number (1-31) * week - week number (1-5) * month - month number (1-12) * year - year number (4 digits) * day_of_week - day of week (1-7) * current - active month (boolean) (only show data for the month being rendered) * weekend - weekend day (boolean) * first_day - first day of month (boolean) * last_day - last day of month (boolean) * occurrence - occurrence of the week day (1-5) (use with "day_of_week") * last_occurrence - last occurrence of week day (boolean) (use with "day_of_week") * easter - Easter day (boolean) * callback - callback test (boolean)