PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Class: DateHelper

Source Location: /vendor/trax/action_view/helpers/date_helper.php

Class Overview

Helpers
   |
   --DateHelper

Utility to help build HTML pulldown menus for date and time


Variables

Methods


Child classes:

ExDateHelper
Extend the DateHelper class so we can access protected stuff

Inherited Variables

Inherited Methods

Class: Helpers

Helpers::__construct()
Construct a Helpers object
Helpers::boolean_attribute()
Convert an attribute to proper XML boolean form
Helpers::cdata_section()
Wrap CDATA begin and end tags around argument
Helpers::content_tag()
Generate an open/close pair of tags with optional attributes and content between
Helpers::convert_options()
Convert selected attributes to proper XML boolean form
Helpers::object()
Given the name of an ActiveRecord subclass, find an instance
Helpers::tag()
Generate an HTML or XML tag with optional attributes and self-ending
Helpers::tag_options()
Convert array of tag attribute names and values to string
Helpers::to_content_tag()
Helpers::value()
Get value of current attribute in the current ActiveRecord object

Class Details

[line 34]
Utility to help build HTML pulldown menus for date and time



[ Top ]


Class Variables

$request_days =

[line 67]

Day of month values parsed from $_REQUEST

Set by check_request_for_value(). An array whose keys are the names of attributes of the ActiveRecord subclass named by $object_name, and whose values are the strings parsed from $_REQUEST.




Tags:


Type:   string[]


[ Top ]

$request_hours =

[line 78]

Hour values parsed from $_REQUEST

Set by check_request_for_value(). An array whose keys are the names of attributes of the ActiveRecord subclass named by $object_name, and whose values are the strings parsed from $_REQUEST.




Tags:


Type:   string[]


[ Top ]

$request_minutes =

[line 89]

Minute values parsed from $_REQUEST

Set by check_request_for_value(). An array whose keys are the names of attributes of the ActiveRecord subclass named by $object_name, and whose values are the strings parsed from $_REQUEST.




Tags:


Type:   string[]


[ Top ]

$request_months = array()

[line 56]

Month values parsed from $_REQUEST

Set by check_request_for_value(). An array whose keys are the names of attributes of the ActiveRecord subclass named by $object_name, and whose values are the strings parsed from $_REQUEST.




Tags:


Type:   string[]


[ Top ]

$request_seconds =

[line 100]

Second values parsed from $_REQUEST

Set by check_request_for_value(). An array whose keys are the names of attributes of the ActiveRecord subclass named by $object_name, and whose values are the strings parsed from $_REQUEST.




Tags:


Type:   string[]


[ Top ]

$request_years =

[line 45]

Year values parsed from $_REQUEST

Set by check_request_for_value(). An array whose keys are the names of attributes of the ActiveRecord subclass named by $object_name, and whose values are the strings parsed from $_REQUEST.




Tags:


Type:   string[]


[ Top ]

$selected_years = array()

[line 105]

FIXME: Dead code?



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 114]

DateHelper __construct( [string $object_name = null], [string $attribute_name = null])

Constructor

Construct an instance of Helpers with the same arguments




Overrides Helpers::__construct() (Construct a Helpers object)

Parameters:

string   $object_name   Name of an ActiveRecord subclass
string   $attribute_name   Name of an attribute of $object

[ Top ]

method check_request_for_value [line 136]

mixed check_request_for_value( )

Check whether $_REQUEST holds value for this attribute

Called with the name of an ActiveRecord subclass in $this->object_name and the name of one of its attributes in $this->attribute_name. Check whether $_REQUEST contains a value for this attribute; if so return it.




Tags:

return:  String value if attribute was found in $_REQUEST, otherwise false
uses:  DateHelper::$request_minutes
uses:  DateHelper::$request_seconds
access:  private
usedby:  DateHelper::value()
uses:  DateHelper::$request_hours
uses:  DateHelper::$request_days
uses:  Helpers::$object_name
uses:  DateHelper::$request_years
uses:  DateHelper::$request_months
uses:  Helpers::$attribute_name


[ Top ]

method datetime_select [line 310]

string datetime_select( [mixed[] $options = array()])

Call to_datetime_select_tag()

Alias for to_datetime_select_tag()




Tags:

return:  Generated HTML
usedby:  datetime_select()
uses:  DateHelper::to_datetime_select_tag()


Parameters:

mixed[]   $options   Output format options

[ Top ]

method date_select [line 322]

string date_select( [mixed[] $options = array()])

Call to_date_select_tag()

Alias for to_date_select_tag()




Tags:

return:  Generated HTML
usedby:  date_select()
uses:  DateHelper::to_date_select_tag()


Parameters:

mixed[]   $options   Output format options

[ Top ]

method expiration_date_select [line 298]

string expiration_date_select( [mixed[] $options = array()])

Call to_expiration_date_select_tag()

Alias for to_expiration_date_select_tag()




Tags:

return:  Generated HTML
usedby:  expiration_date_select()
uses:  DateHelper::to_expiration_date_select_tag()


Parameters:

mixed[]   $options   Output format options

[ Top ]

method leading_zero_on_single_digits [line 247]

string leading_zero_on_single_digits( string $number)

Prefix a leading zero to single digit numbers



Tags:

return:  Number with zero prefix if value <= 9
usedby:  DateHelper::select_day()
usedby:  DateHelper::select_month()
usedby:  DateHelper::select_hour()
usedby:  DateHelper::select_minute()
usedby:  DateHelper::select_second()
access:  private


Parameters:

string   $number   A number

[ Top ]

method select_date [line 443]

string select_date( [string $date = null], [mixed[] $options = array()])

Generate HTML/XML for year, month and day selector pull-down menus

Returns <select>...</select> HTML with options for a number of years, months and days. The first argument, if present, specifies the initially selected date. The second argument controls the format of the generated HTML.

Examples:

  • select_date();
    Generates a group of three pulldown menus in the order year, month and day with the current date initially selected.
  • select_date('August 4, 1998');
    Generates a group of three pulldown menus in the order year, month and day with the date August 4, 1998 initially selected.




Tags:

return:  Generated HTML
usedby:  select_date()
uses:  DateHelper::select_year()
uses:  DateHelper::select_month()
uses:  DateHelper::select_day()


Parameters:

string   $date   Date to display as initially selected if none was found in $request_years[$attribute_name], $request_months[$attribute_name] and $request_days[$attribute_name]. Character string is any US English date representation supported by http://www.php.net/strtotime. If omitted, the current date is initially selected.
mixed[]   $options   Output format options are all of the options of select_year(), select_month() and select_day().

[ Top ]

method select_datetime [line 488]

string select_datetime( [string $datetime = null], [mixed[] $options = array()])

Generate HTML/XML for year-month-day-hour-minute selector pulldowns

Returns <select>...</select> HTML with options for a number of years, months, days, hours and minutes. The first argument, if present, specifies the initially selected date. The second argument controls the format of the generated HTML.

Examples:

  • select_datetime();
    Generates a group of five pulldown menus in the order year, month, day, hour and minute with the current date and time initially selected.
  • select_datetime('1998-04-08 13:21:17');
    Generates a group of five pulldown menus in the order year, month, day, hour and minute with the date/time 1998 August 4 13:21 initially selected.




Tags:



Parameters:

string   $datetime   Date/time to display as initially selected. Character string is any US English date representation supported by http://www.php.net/strtotime. If omitted, the current date/time is initially selected.
mixed[]   $options   Output format options are all of the options of select_year(), select_month(), select_day(), select_hour() and select_minute().

[ Top ]

method select_day [line 838]

string select_day( [string $datetime = null], [mixed[] $options = array()])

Generate HTML/XML for day selector pull-down menu

Returns <select>...</select> HTML with an option for each of the thirty-one days. The first argument, if present, specifies the initially selected day. The second argument controls the format of the generated HTML.

Examples:

  • select_day();
    Generates menu '01', '02', ..., '31'. Initially selected day is the day in $request_days[$attribute_name], or if that is not defined, the current calendar day.
  • select_day(null,array('include_blank' => true));
    Generates menu ' ', '01', '02',..., '31'. Initially selected day same as above.




Tags:



Parameters:

string   $datetime   Initially selected day as two-digit number. If a value for this field is specified in $request_days[$attribute_name], then that day is initially selected regardless of the value of this argument. Otherwise, if the first argument is present and is a character string of two decimal digits with a value in the range '01'..'31' then that day is initially selected. Otherwise, if the first argument is a date in some US English date format, the day of the month from that date is initially selected. If this argument is absent or invalid, the current calendar day is initially selected.
mixed[]   $options   Output format options:
  • 'include_blank' => true Show a blank as the first option.
  • 'field_name' => 'somestring' Generate output
    <select name="somestring">...</select> .
    If absent, generate output
    <select name="day">...</select>.
  • 'discard_type' => ??? FIXME
  • 'prefix' => ??? FIXME

[ Top ]

method select_expiration_date [line 366]

string select_expiration_date( [string $date = null], [mixed[] $options = array()])

Generate HTML/XML for expiration month and year selector pulldowns

Generates HTML for a month and year pulldown. The year pulldown has a range of years from the initially selected year to seven years after.

When called, $_REQUEST[] may have initial date values in fields with default names of 'expiration_month' and 'expiration_year'. If these values exist they override the first parameter.




Tags:

return:  Generated HTML
usedby:  select_expiration_date()
uses:  DateHelper::select_year()
uses:  DateHelper::select_month()
uses:  DateHelper::select_html()


Parameters:

string   $date   Date to display as initially selected if none was found in $_REQUEST[]. If omitted, default value is the current calendar date.FIXME: this doesn't work
mixed[]   $options   Output format options:
  • 'field_separator' => 'somestring'
    String to insert between the month and year selectors. If none is specified, default value is ' / '
  • 'month_before_year' => 'false'<br /> Output year selector first, then month selector. If option not specified, the month selector will be output first.</li> <li><samp>'month_name' =>'somestring'
    Set the name of the generated month selector to somestring. If option not specified, default name is expiration_month
  • 'year_name' => 'somestring'
    Set the name of the generated year selector to somestring. If option not specified, default name is expiration_year

[ Top ]

method select_hour [line 744]

string select_hour( [string $datetime = null], [mixed[] $options = array()])

Generate HTML/XML for hour selector pull-down menu

Returns <select>...</select> HTML with an option for each of the twenty-four hours. The first argument, if present, specifies the initially selected hour. The second argument controls the format of the generated HTML.

Examples:

  • select_hour();
    Generates menu '00', '01', ..., '23'. Initially selected hour is the hour in $request_hours[$attribute_name], or if that is not defined, the current hour.
  • select_hour(null,array('include_blank' => true));
    Generates menu ' ', '00', '01',..., '23'. Initially selected hour same as above.




Tags:



Parameters:

string   $datetime   Initially selected hour as two-digit number. If a value for this field is specified in $request_hours[$attribute_name], then that hour is initially selected regardless of the value of this argument. Otherwise, if the first argument is present and is a character string of two decimal digits with a value in the range '00'..'23' then that hour is initially selected. If this argument is absent or invalid, the current hour is initially selected.
mixed[]   $options   Output format options:
  • 'include_blank' => true Show a blank as the first option.
  • 'field_name' => 'somestring' Generate output
    <select name="somestring">...</select> .
    If absent, generate output
    <select name="hour">...</select>.
  • 'discard_type' => ??? FIXME
  • 'prefix' => ??? FIXME

[ Top ]

method select_html [line 226]

string select_html( string $type, string $options, [string $prefix = null], [boolean $include_blank = false], [boolean $discard_type = false])

Generate HTML/XML for select to enclose option list



Tags:

return:  Generated HTML
usedby:  DateHelper::select_day()
usedby:  DateHelper::select_month()
usedby:  DateHelper::select_year()
usedby:  DateHelper::select_hour()
usedby:  DateHelper::select_minute()
usedby:  DateHelper::select_expiration_date()
usedby:  DateHelper::select_second()
access:  private


Parameters:

string   $type   Name attribute for <select name=... >
string   $options  
string   $prefix   Prefix of name attribute, to be enclosed in square brackets
boolean   $include_blank   Whether to include a blank in the list of select options
boolean   $discard_type   Whether to discard the type

[ Top ]

method select_minute [line 668]

string select_minute( [string $datetime = null], [mixed[] $options = array()])

Generate HTML/XML for minute selector pull-down menu

Returns <select>...</select> HTML with an option for each of the sixty minutes. The first argument, if present, specifies the initially selected minute. The second argument controls the format of the generated HTML.

Examples:

  • select_minute();
    Generates menu '00', '01', ..., '59'. Initially selected minute is the minute in $request_minutes[$attribute_name], or if that is not defined, the current minute.
  • select_minute(null,array('include_blank' => true));
    Generates menu ' ', '00', '01',..., '59'. Initially selected minute same as above.




Tags:



Parameters:

string   $datetime   Initially selected minute as two-digit number. If a value for this field is specified in $request_minutes[$attribute_name], then that minute is initially selected regardless of the value of this argument. Otherwise, if the first argument is present and is a character string of two decimal digits with a value in the range '00'..'59' then that minute is initially selected. If this argument is absent or invalid, the current minute is initially selected.
mixed[]   $options   Output format options:
  • 'include_blank' => true Show a blank as the first option.
  • 'field_name' => 'somestring' Generate output
    <select name="somestring">...</select> .
    If absent, generate output
    <select name="minute">...</select>.
  • 'discard_type' => ??? FIXME
  • 'prefix' => ??? FIXME

[ Top ]

method select_month [line 935]

string select_month( [string $date = null], [mixed[] $options = array()])

Generate HTML/XML for month selector pull-down menu

Returns <select>...</select> HTML with an option for each of the twelve months. The first argument, if present, specifies the initially selected month. The second argument controls the format of the generated HTML.

Examples:

  • select_month(); Generates menu January, February etc.
  • select_month(null,array('use_month_number' => true)); Generates menu 1, 2 etc.
  • select_month(null,array('add_month_number' => true)); Generates menu 1 - January, 2 - February etc.




Tags:



Parameters:

string   $date   Initially selected month as two-digit number. If a value for this field is specified in $request_months[$attribute_name], then that month is initially selected regardless of the value of this argument. Otherwise, if the first argument is present and is a character string of two decimal digits with a value in the range '01'..'12' then that month is initially selected. Otherwise, if the first argument is a date in some US English date format, the month from that date is initially selected. If this argument is absent or invalid, the current calendar month is initially selected.
mixed[]   $options   Output format options:
  • 'include_blank' => true Show a blank as the first option.
  • 'use_month_number' => true Show months in the menu by their month number (1, 2 ...). Default is to show English month name (January, February ...).
  • 'add_month_number' => true Show both month number and month name in the menu.
  • 'field_name' => 'somestring' Generate output
    <select name="somestring">...</select> .
    If absent, generate output
    <select name="month">...</select>.
  • 'discard_type' => ??? FIXME
  • 'prefix' => ??? FIXME
In all cases the value sent to the server is the two digit month number in the range '01'..'12'.

[ Top ]

method select_second [line 590]

string select_second( [string $datetime = null], [mixed[] $options = array()])

Generate HTML/XML for second selector pull-down menu

Returns <select>...</select> HTML with an option for each of the sixty seconds. The first argument, if present, specifies the initially selected second. The second argument controls the format of the generated HTML.

Examples:

  • select_second();
    Generates menu '00', '01', ..., '59'. Initially selected second is the second in $request_seconds[$attribute_name], or if that is not defined, the current second.
  • select_second(null,array('include_blank' => true));
    Generates menu ' ', '00', '01',..., '59'. Initially selected second same as above.




Tags:



Parameters:

string   $datetime   Initially selected second as two-digit number. If a value for this field is specified in $request_seconds[$attribute_name], then that second is initially selected regardless of the value of this argument. Otherwise, if the first argument is present and is a character string of two decimal digits with a value in the range '00'..'59' then that second is initially selected. If this argument is absent or invalid, the current second is initially selected.
mixed[]   $options   Output format options:
  • 'include_blank' => true Show a blank as the first option.
  • 'field_name' => 'somestring' Generate output
    <select name="somestring">...</select> .
    If absent, generate output
    <select name="second">...</select>.
  • 'discard_type' => ??? FIXME
  • 'prefix' => ??? FIXME

[ Top ]

method select_time [line 533]

string select_time( [string $datetime = null], [mixed[] $options = array()])

Generate HTML/XML for hour, minute and second selector pull-down menus

Returns <select>...</select> HTML with options for a number of hours, minutes and seconds. The first argument, if present, specifies the initially selected time. The second argument controls the format of the generated HTML.

Examples:

  • select_time();
    Generates two pulldown menus in the order hour : minute with the current time initially selected.
  • select_time('August 4, 1998 8:12');
    Generates two pulldown menus in the order hour : minute with the time 8:12 initially selected.




Tags:

return:  Generated HTML
usedby:  time_select()
usedby:  DateHelper::time_select()
uses:  DateHelper::select_second()
uses:  DateHelper::select_minute()
uses:  DateHelper::select_hour()


Parameters:

string   $datetime   Time to display as initially selected if none was found in $request_hours[$attribute_name], $request_minutes[$attribute_name] and $request_seconds[$attribute_name]. Character string is any US English date/time representation supported by http://www.php.net/strtotime. If omitted, the current time is initially selected.
mixed[]   $options   Output format options are all of the options of select_hour(), select_minute() and select_second().

[ Top ]

method select_year [line 1049]

string select_year( [string $date = null], [mixed[] $options = array()])

Generate HTML/XML for year selector pull-down menu

Returns <select>...</select> HTML with options for a number of years. The first argument, if present, specifies the initially selected year. The second argument controls the format of the generated HTML.

Examples:

  • select_year();
    Generates a pulldown menu with with a range of +/- five years. If a year is specified in $request_years[$attribute_name] then it is selected initially, otherwise the current calendar year is selected.
  • select_year(null,array('start_year' => '1900));
    Generates year options from 1900 to five years after the initially selected year, which is chosen as in the previous example.
  • select_year(null,array('start_year'=>date('Y')+5, 'end_year'=>date('Y')-5);
    Generates year options starting five years after the current year, ending five years before the current year.




Tags:



Parameters:

string   $date   Year to display as initially selected if none was found in $request_years[$attribute_name]. Character string is either exactly four decimal digits or some English date representation. If omitted, the current year is initially selected.
mixed[]   $options   Output format options:
  • 'start_year'=>'startyear' If specified, startyear will be the first year in the output menu, otherwise the first year in the menu will be five years before the initially selected year.
  • 'end_year'=>'endyear' If specified, endyear will be the last year in the output menu, otherwise the last year in the menu will be five years after the initially selected year.
  • 'field_name' => 'somestring' Generate output
    <select name="somestring">...</select> .
    If absent, generate output
    <select name="year">...</select>.
  • 'discard_type' => ??? FIXME
  • 'prefix' => ??? FIXME
To generate a list with most recent year first, define that year as the start year and the oldest year as the end year.

[ Top ]

method time_select [line 1421]

string time_select( [mixed[] $options = array()])

Generate HTML/XML for time pulldown

When called, $object_name describes the ActiveRecord subclass and $attribute_name describes the attribute whose value will be set by the generated pull-down menu. The value to be displayed initially is from $_REQUEST if present, otherwise from the database.




Tags:



Parameters:

mixed[]   $options   Output format options

[ Top ]

method to_datetime_select_tag [line 1319]

string to_datetime_select_tag( [string $options = array()], mixed[] 1)

Generate HTML/XML for date/time pulldown menus

Returns <select>...</select> HTML with options for a number of years, months, days, hours and minutes. The first argument, if present, specifies the initially selected date. The second argument controls the format of the generated HTML.

Examples:

  • to_datetime_select_tag();
    Generates a group of five pulldown menus in the order year, month, day, hour and minute with the current date and time initially selected.
  • to_datetime_select_tag(array('discard_second' => false);
    Generates a group of six pulldown menus in the order year, month, day, hour, minute and second with the current date and time initially selected.
  • to_datetime_select_tag('1998-04-08 13:21:17');
    Generates a group of five pulldown menus in the order year, month, day, hour and minute with the date/time 1998 August 4 13:21 initially selected.




Tags:



Parameters:

mixed[]   1   Output format options:
  • 'discard_month' => true
    Output selector for only the year.
  • 'discard_day' => true
    Output selector for only the year and month.
  • 'discard_hour' => true
    Output selector for only the year, month and day.
  • 'discard_minute' => true
    Output selector for only the year, month, day and hour.
  • 'discard_second' => false
    Output selector for year, month, day, hour, minute and second.
string   $options   Date/time to display as initially selected. Character string is any US English date representation supported by http://www.php.net/strtotime. If omitted, the current date/time is initially selected.

[ Top ]

method to_date_select_tag [line 1169]

string to_date_select_tag( [mixed[] $options = array()])

Generate HTML/XML for day/month/year selector pull-down menus

When called, $object_name describes the ActiveRecord subclass and $attribute_name describes the attribute whose value will be set by the generated pull-down menus. The value to be displayed initially in each menu is from $_REQUEST if present, otherwise from the database.




Tags:



Parameters:

mixed[]   $options   Output format options
  • 'discard_day' => true Don't show a day of month menu. If absent or false, day menu will be output.
  • 'discard_month' => true Don't show a month or day of the month menu. If absent or false, month menu will be output.
  • 'discard_type' => true (true is the default) Don't show name of individual field, for example [year], as part of the name value of the generated <select ...>. The information to identify the field is available as a suffix (ni) of the attribute name.
  • 'discard_year' => true Don't show a year menu. If absent or false, year menu will be output.
  • 'field_separator' => 'string' String to insert between the submenus in the output. If absent, one blank will be inserted.
  • 'include_blank' => true Initially show a blank selection in the menu. If absent or false, the current date will be shown as the initial selection. If a value was parsed from $_REQUEST, it will be used for the initial selection regardless of this option.
  • 'month_before_year' => true Equivalent to 'order' => array('month', 'day', 'year')
  • 'order' => array(elements) A list of the elements 'month', 'day' and 'year' in the order in which the menus should appear in the output. Default is 'year', 'month', 'day'
  • Also: options provided by select_month(), select_day() and select_year()

[ Top ]

method to_expiration_date_select_tag [line 1394]

string to_expiration_date_select_tag( [mixed[] $options = array()])

Generate HTML/XML for expiration month and year pulldown.

Calls to_date_select_tag() with options for month with number, followed by year starting this year and going seven years in the future.




Tags:

return:  Generated HTML
usedby:  DateHelper::expiration_date_select()
uses:  DateHelper::to_date_select_tag()


Parameters:

mixed[]   $options   Output format options

[ Top ]

method value [line 272]

mixed value( )

Get attribute value from $_REQUEST if there, otherwise from database

When called, $object_name describes the ActiveRecord subclass and $attribute_name describes the attribute whose value is desired.

An attempt is made to find the value in $_REQUEST, where it would be found after the browser POSTed a form. If no value is found there, then the database is accessed for the value. When accessing the database, the assumption is made that the ActionController object refers to a single ActiveRecord subclass object which correctly identifies the table and record containing the attribute value.




Tags:

return:  Attribute value if found
usedby:  DateHelper::to_datetime_select_tag()
usedby:  DateHelper::time_select()
usedby:  DateHelper::year_select()
usedby:  DateHelper::to_date_select_tag()
access:  protected
uses:  Helpers::$attribute_name
uses:  Helpers::object()
uses:  ActiveRecord::send()
uses:  DateHelper::check_request_for_value()


Overridden in child classes as:

ExDateHelper::value()

Overrides Helpers::value() (Get value of current attribute in the current ActiveRecord object)

[ Top ]

method year_option [line 1113]

string year_option( integer $year, integer $date_year)

Return one HTML/XML year option, selected if so specified



Tags:

return:  HTML for one year option
usedby:  DateHelper::select_year()


Parameters:

integer   $year   Year to put in the option
integer   $date_year   Year that should be selected

[ Top ]

method year_select [line 1470]

string year_select( [mixed[] $options = array()])

Generate HTML/XML for year pulldown

When called, $object_name describes the ActiveRecord subclass and $attribute_name describes the attribute whose value will be set by the generated pull-down menu. The value to be displayed initially is from $_REQUEST if present, otherwise from the database.




Tags:

return:  Generated HTML
usedby:  year_select()
uses:  DateHelper::value()
uses:  DateHelper::select_year()


Parameters:

mixed[]   $options   Output format options

[ Top ]


Documentation generated on Thu, 04 May 2006 19:47:26 -0600 by phpDocumentor 1.3.0RC4