Class Calendar

Description

Calendar

We define a class called 'Calendar' which renders a nice-looking graphical calendar 'widget' in the page and allows the user to click on dates and submit them to choose a date and 'do' something which is application-specific. The class contains various properties and methods to allow the user to find the current date that the calendar is set to, and acquire this date as a timestamp, nicely-formatted string or a DB-compliant value.

Located in /calendar-defs.php (line 40)

RenderableObject
   |
   --Calendar
Variable Summary
 mixed $dayname
 mixed $days
 mixed $daysinmonth
 mixed $DD
 mixed $endyear
 mixed $formname
 mixed $initDD
 mixed $initMM
 mixed $initYY
 mixed $MM
 mixed $months
 mixed $posturl
 mixed $render_form
 mixed $startyear
 mixed $weeks
 mixed $YY
Method Summary
 Calendar Calendar ([mixed $today = ""])
 string get_DB_datetime ()
 string get_DDstr ()
 string get_displaydate (mixed $displayformat)
 string get_MMstr ()
 integer get_timestamp ()
 string get_YYstr ()
 string html ()
 boolean is_valid ()
 void POSTprocess ()
 void post_to (string $posturl)
 void render_as_subform ([boolean $mode = true])
 void render_days_clickable ([boolean $mode = true])
 void render_in_form ([boolean $mode = true])
 void set_today ([mixed $today = ""])
 void set_year_limits (integer $startyear, integer $endyear)
Variables
mixed $dayname (line 47)
mixed $days = 7 (line 55)
mixed $daysinmonth (line 48)
mixed $days_clickable = true (line 52)
mixed $DD (line 44)
mixed $endyear = 9999 (line 59)
mixed $formname = "fm_calendar" (line 53)
mixed $initDD = 1 (line 41)
mixed $initMM = 1 (line 42)
mixed $initYY = 1970 (line 43)
mixed $MM (line 45)
mixed $months = 12 (line 57)
mixed $posturl = "" (line 49)
mixed $render_form = true (line 50)
mixed $render_subform = false (line 51)
mixed $startyear = 1970 (line 58)
mixed $weeks = 6 (line 56)
mixed $YY (line 46)
Methods
Constructor Calendar (line 67)

Constructor. Create a new Calendar object with optional centre date (defaults to 'today'). This date is the one we return to when the 'today' button is clicked on the calendar & is the starting point.

Calendar Calendar ([mixed $today = ""])
  • mixed $today: Today's date, either int timestamp or date string
get_DB_datetime (line 328)

Return the currently stored calendar date as a string which will be formatted so as to go into a database field nicely. This normally means ISO format (YYYY-MM-DD).

  • return: The current calendar date in DB-compatible format.
string get_DB_datetime ()
get_DDstr (line 335)

Return the currently stored day-date as a two-digit string

  • return: Set date in '99' format
string get_DDstr ()
get_displaydate (line 319)

Return the currently stored calendar date as a string in a given date format (see Axyl datetime-defs.php for pre-defined formats).

The format is comprised of format characters as per the standard Php function 'date()' (see Php manual entry).

  • return: The current calendar date as a formatted date string.
string get_displaydate (mixed $displayformat)
get_MMstr (line 342)

Return the currently stored month as a two-digit string

  • return: Set month in '99' format
string get_MMstr ()
get_timestamp (line 309)

Return the current calendar date as a timestamp. This will return the timestamp at 00:00:00 (hh:mm:ss) ie. at the beginning of that day.

  • return: Return current calendar date as a timestamp.
integer get_timestamp ()
get_YYstr (line 349)

Return the currently stored year as a two-digit string

  • return: Set year in '9999' format
string get_YYstr ()
html (line 365)

Return the calendar HTML

  • return: The calendar HTML.
string html ()

Redefinition of:
RenderableObject::html()
Return output suitable for normal HTML-capable device. This method must be over-ridden by a method of the same name in the descendant class which renders output to web browsers.
is_valid (line 357)

Check that currently stored Month, Day and Year make a correct date. Returns true if so.

  • return: True if current date is valid
boolean is_valid ()
POSTprocess (line 164)

Process GET/POST from form.

The form works in a GET mode, therefore new date settings are as if passed in on the URL. This method processes these, and sets the internal calendar date values accordingly.

void POSTprocess ()
post_to (line 126)

Set the URL of script to POST the calendar form to.

void post_to (string $posturl)
  • string $posturl: URL to post the calendar to.
render_as_subform (line 152)

Set the calendar to be rendered in a sub-form. This is just the same as rendering in a form, except we miss off the form tags.

void render_as_subform ([boolean $mode = true])
  • boolean $mode: If true, then render as a sub-form.
render_days_clickable (line 135)

Render calendar dates (the individual days) as clickable. This will cause a form submit, with the details of the date clicked on and the calendar will be set to that date.

void render_days_clickable ([boolean $mode = true])
  • boolean $mode: If true, then render days as clickable links
render_in_form (line 144)

Set the calendar to be rendered in its own form. If your calendar sits in an existing form, then call this method with 'false' to prevent it rendering its own form.

void render_in_form ([boolean $mode = true])
  • boolean $mode: If true, then render form, else just the calendar.
set_today (line 89)

Set the 'today' date for the calendar. This is the date that is reset to when the user clicks on the 'TODAY' button. Of course it defaults to the current date when the calendar object is created, but this method allows for customised 'today' settings.

NB: If you call this with no paramters, it sets it to 'today'

void set_today ([mixed $today = ""])
  • mixed $today: Today's date, either int timestamp or date string
set_year_limits (line 110)

Set the starting and finishing year for the calendar - the range of operation. This defaults to +/-10 years around the current year.

void set_year_limits (integer $startyear, integer $endyear)
  • integer $startyear: Starting year for calendar (>= 1970)
  • integer $endyear: Ending year for calendar

Inherited Methods

Inherited From RenderableObject

 RenderableObject::RenderableObject()
 RenderableObject::html()
 RenderableObject::render()
 RenderableObject::wml()
 RenderableObject::wmlup()
 RenderableObject::xml()

Documentation generated by phpDocumentor 1.3.0RC3