silverorange Code


Swat.SwatDateEntry
/Swat/SwatDateEntry.php at line 20

Class SwatDateEntry

SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatInputControl
└─SwatDateEntry

public class SwatDateEntry
extends SwatInputControl

A date entry widget

Copyright:
2004-2007 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1

Field Summary
final mixed

CALENDAR

final mixed

DAY

final mixed

MONTH

final mixed

TIME

final mixed

YEAR

integer

$display_parts

Displayed date parts.

integer

$required_parts

Required date parts.

boolean

$show_month_number

Whether the numeric month code is displayed in the month flydown.

boolean

$use_current_date

Whether or not this time entry should auto-complete to the current date.

Date

$valid_range_end

End date of the valid range (exclusive).

Date

$valid_range_start

Start date of the valid range (inclusive).

Date

$value

Date of this date entry widget.

Fields inherited from Swat.SwatInputControl
required
Constructor Summary

SwatDateEntry(string id)

Creates a new date entry widget.

Method Summary
private SwatCalendar

createCalendar()

Creates the calendar widget for this date entry.

protected void

createCompositeWidgets()

Creates the composite widgets used by this date entry.

private SwatFlydown

createDayFlydown()

Creates the day flydown for this date entry.

private SwatFlydown

createMonthFlydown()

Creates the month flydown for this date entry.

private SwatTimeEntry

createTimeEntry()

Creates the time entry widget for this date entry.

private SwatFlydown

createYearFlydown()

Creates the year flydown for this date entry.

void

display()

Displays this date entry.

protected array

getCSSClassNames()

Gets the array of CSS classes that are applied to this date entry widget.

private array

getDatePartOrder()

Gets the order of date parts for the current locale.

private string

getFormattedDate(Date date)

Formats a date for this date entry.

protected string

getInlineJavaScript()

Gets the inline JavaScript required for this control.

private string

getMonthOptionText(integer month)

Gets the title of a month flydown option.

boolean

getState()

Gets the current state of this date entry widget.

protected boolean

isEndDateValid()

Checks if the entered date is valid with respect to the valid end date.

protected boolean

isStartDateValid()

Checks if the entered date is valid with respect to the valid start date.

boolean

isValid()

Checks if the entered date is within the valid range.

void

process()

Processes this date entry.

void

setState(boolean state)

Sets the current state of this date entry widget.

void

setValidRange(integer start_offset, integer end_offset)

Set the valid date range.

protected void

validateRanges()

Makes sure the date the user entered is within the valid range.

Methods inherited from Swat.SwatInputControl
getForm, init
Methods inherited from Swat.SwatControl
addMessage, getNote, printWidgetTree
Methods inherited from Swat.SwatWidget
addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer
Methods inherited from Swat.SwatUIObject
addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible

Field Detail

/Swat/SwatDateEntry.php at line 28

CALENDAR

public final mixed CALENDAR = 16

/Swat/SwatDateEntry.php at line 26

DAY

public final mixed DAY = 4

/Swat/SwatDateEntry.php at line 25

MONTH

public final mixed MONTH = 2

/Swat/SwatDateEntry.php at line 27

TIME

public final mixed TIME = 8

/Swat/SwatDateEntry.php at line 24

YEAR

public final mixed YEAR = 1

/Swat/SwatDateEntry.php at line 74

display_parts

public integer $display_parts

Displayed date parts

Bitwise combination of SwatDateEntry::YEAR, SwatDateEntry::MONTH, SwatDateEntry::DAY, SwatDateEntry::TIME and SwatDateEntry::CALENDAR.

For example, to show a date selector widget with just the month and year use the following:

<?php
$date
->display_parts SwatDateEntry::YEAR SwatDateEntry::MONTH;
?>


/Swat/SwatDateEntry.php at line 56

required_parts

public integer $required_parts

Required date parts

Bitwise combination of SwatDateEntry::YEAR, SwatDateEntry::MONTH, SwatDateEntry::DAY and SwatDateEntry::TIME.

For example, to require the month and day to be entered in a date selector widget use the following:

<?php
$date
->required_parts SwatDateEntry::MONTH SwatDateEntry::DAY;
?>


/Swat/SwatDateEntry.php at line 101

show_month_number

public boolean $show_month_number = false

Whether the numeric month code is displayed in the month flydown

This is useful for credit card date entry


/Swat/SwatDateEntry.php at line 108

use_current_date

public boolean $use_current_date = true

Whether or not this time entry should auto-complete to the current date


/Swat/SwatDateEntry.php at line 92

valid_range_end

public Date $valid_range_end

End date of the valid range (exclusive)

Defaults to 20 years in the future.


/Swat/SwatDateEntry.php at line 83

valid_range_start

public Date $valid_range_start

Start date of the valid range (inclusive)

Defaults to 20 years in the past.


/Swat/SwatDateEntry.php at line 38

value

public Date $value = null

Date of this date entry widget


Constructor Detail

/Swat/SwatDateEntry.php at line 123

SwatDateEntry

public SwatDateEntry(string id)

Creates a new date entry widget

Sets default required and display parts and sets default valid range for this date entry.

Parameters:
id - a non-visible unique id for this widget.
See Also:
SwatWidget::__construct()

Method Detail

/Swat/SwatDateEntry.php at line 777

createCalendar

private SwatCalendar createCalendar()

Creates the calendar widget for this date entry

Returns:
the calendar widget for this date entry.

/Swat/SwatDateEntry.php at line 588

createCompositeWidgets

protected void createCompositeWidgets()

Creates the composite widgets used by this date entry

See Also:
SwatWidget::createCompositeWidgets()

/Swat/SwatDateEntry.php at line 710

createDayFlydown

private SwatFlydown createDayFlydown()

Creates the day flydown for this date entry

Returns:
the day flydown for this date entry.

/Swat/SwatDateEntry.php at line 643

createMonthFlydown

private SwatFlydown createMonthFlydown()

Creates the month flydown for this date entry

Returns:
the month flydown for this date entry.

/Swat/SwatDateEntry.php at line 762

createTimeEntry

private SwatTimeEntry createTimeEntry()

Creates the time entry widget for this date entry

Returns:
the time entry widget for this date entry.

/Swat/SwatDateEntry.php at line 619

createYearFlydown

private SwatFlydown createYearFlydown()

Creates the year flydown for this date entry

Returns:
the year flydown for this date entry.

/Swat/SwatDateEntry.php at line 195

display

public void display()

Displays this date entry

Creates internal widgets if they do not exits then displays required JavaScript, then displays internal widgets.


/Swat/SwatDateEntry.php at line 511

getCSSClassNames

protected array getCSSClassNames()

Gets the array of CSS classes that are applied to this date entry widget

Returns:
the array of CSS classes that are applied to this date entry widget.
See Also:
SwatUIObject::getCSSClassString()

/Swat/SwatDateEntry.php at line 837

getDatePartOrder

private array getDatePartOrder()

Gets the order of date parts for the current locale

Note: The technique used within this method does not work correcty for RTL languages that display month names, month abbreviations or weekday names. Since we're displaying months textually these locales may have date parts incorrectly ordered.

Returns:
an array containg the values 'd', 'm' and 'y' in the correct order for the current locale.

/Swat/SwatDateEntry.php at line 801

getFormattedDate

private string getFormattedDate(Date date)

Formats a date for this date entry

Returns a date string formatted according to the properties of this date entry widget. This is used primarily for returning formatted valid start and valid end dates for user error messages.

Parameters:
date - the date object to format.
Returns:
a date formatted according to the properties of this date entry.

/Swat/SwatDateEntry.php at line 445

getInlineJavaScript

protected string getInlineJavaScript()

Gets the inline JavaScript required for this control

Returns:
the inline JavaScript required for this control.

/Swat/SwatDateEntry.php at line 690

getMonthOptionText

private string getMonthOptionText(integer month)

Gets the title of a month flydown option

Parameters:
month - the numeric identifier of the month.
Returns:
the option text of the month.

/Swat/SwatDateEntry.php at line 400

getState

public boolean getState()

Gets the current state of this date entry widget

Returns:
the current state of this date entry widget.
See Also:
SwatState::getState()

/Swat/SwatDateEntry.php at line 546

isEndDateValid

protected boolean isEndDateValid()

Checks if the entered date is valid with respect to the valid end date

Returns:
true if the entered date is before the valid end date and false if the entered date is on or after the valid end date.

/Swat/SwatDateEntry.php at line 529

isStartDateValid

protected boolean isStartDateValid()

Checks if the entered date is valid with respect to the valid start date

Returns:
true if the entered date is on or after the valid start date and false if the entered date is before the valid start date.

/Swat/SwatDateEntry.php at line 432

isValid

public boolean isValid()

Checks if the entered date is within the valid range

Returns:
true if the entered date is within the valid range and false if the entered date is not within the valid range.

/Swat/SwatDateEntry.php at line 277

process

public void process()

Processes this date entry

Creates internal widgets if they do not exist and then assigns their values based on the date entered by the user. If the date is not valid, an error message is attached to this date entry.


/Swat/SwatDateEntry.php at line 418

setState

public void setState(boolean state)

Sets the current state of this date entry widget

Parameters:
state - the new state of this date entry widget.
See Also:
SwatState::setState()

/Swat/SwatDateEntry.php at line 167

setValidRange

public void setValidRange(integer start_offset, integer end_offset)

Set the valid date range

Convenience method to set the valid date range by year offsets.

Parameters:
start_offset - offset from the current year in years used to set the starting year of the valid range.
end_offset - offset from the current year in years used to set the ending year of the valid range.

/Swat/SwatDateEntry.php at line 562

validateRanges

protected void validateRanges()

Makes sure the date the user entered is within the valid range

If the date is not within the valid range, this method attaches an error message to this date entry.


silverorange Code