diff options
Diffstat (limited to 'framework/Web/UI/WebControls/TDatePicker.php')
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 27d080c6..42cb305e 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -69,6 +69,15 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); class TDatePicker extends TTextBox
{
/**
+ * AutoPostBack is not supported.
+ */
+ public function setAutoPostBack($value)
+ {
+ throw new TNotSupportedException('tdatepicker_autopostback_unsupported',
+ get_class($this));
+ }
+
+ /**
* @return string the format of the date string
*/
public function getDateFormat()
@@ -328,7 +337,7 @@ class TDatePicker extends TTextBox */
protected function renderDatePickerButtons($writer)
{
- if($this->getShowCalendar())
+ if($this->getShowCalendar() && $this->getEnabled(true))
{
switch ($this->getMode())
{
@@ -384,7 +393,9 @@ class TDatePicker extends TTextBox $year = intval($values[$key.'$year']);
else
$year = $date['year'];
+
$date = @mktime(0, 0, 0, $month, $day, $year);
+
$pattern = $this->getDateFormat();
$pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern);
$formatter = Prado::createComponent('System.Util.TSimpleDateFormatter', $pattern);
@@ -497,12 +508,13 @@ class TDatePicker extends TTextBox {
$formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',
$this->getDateFormat());
+
foreach($formatter->getDayMonthYearOrdering() as $type)
{
if($type == 'day')
$this->renderCalendarDayOptions($writer,$date['mday']);
elseif($type == 'month')
- $this->renderCalendarMonthOptions($writer,$date['mon']-1);
+ $this->renderCalendarMonthOptions($writer,$date['mon']);
elseif($type == 'year')
$this->renderCalendarYearOptions($writer,$date['year']);
}
@@ -550,6 +562,8 @@ class TDatePicker extends TTextBox $writer->addAttribute('id', $this->getClientID().'_day');
$writer->addAttribute('name', $this->getUniqueID().'$day');
$writer->addAttribute('class', 'datepicker_day_options');
+ if($this->getReadOnly() || !$this->getEnabled(true))
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$this->renderDropDownListOptions($writer, $days, $selected);
$writer->renderEndTag();
@@ -562,13 +576,16 @@ class TDatePicker extends TTextBox */
protected function renderCalendarMonthOptions($writer, $selected=null)
{
+
$info = $this->getLocalizedCalendarInfo();
$writer->addAttribute('id', $this->getClientID().'_month');
$writer->addAttribute('name', $this->getUniqueID().'$month');
$writer->addAttribute('class', 'datepicker_month_options');
+ if($this->getReadOnly() || !$this->getEnabled(true))
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$this->renderDropDownListOptions($writer,
- $this->getLocalizedMonthNames($info), $selected);
+ $this->getLocalizedMonthNames($info), $selected-1);
$writer->renderEndTag();
}
@@ -585,8 +602,12 @@ class TDatePicker extends TTextBox $this->getDateFormat());
switch($formatter->getMonthPattern())
{
- case 'MMM':
- case 'MM': return $info->getAbbreviatedMonthNames();
+ case 'MMM': return $info->getAbbreviatedMonthNames();
+ case 'MM':
+ $array = array();
+ for($i=1;$i<=12;$i++)
+ $array[$i-1] = $i < 10 ? '0'.$i : $i;
+ return $array;
case 'M':
$array = array(); for($i=1;$i<=12;$i++) $array[$i-1] = $i;
return $array;
@@ -606,6 +627,8 @@ class TDatePicker extends TTextBox $years[$i] = $i;
$writer->addAttribute('id', $this->getClientID().'_year');
$writer->addAttribute('name', $this->getUniqueID().'$year');
+ if($this->getReadOnly() || !$this->getEnabled(true))
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$writer->addAttribute('class', 'datepicker_year_options');
$this->renderDropDownListOptions($writer, $years, $selected);
|