summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TDatePicker.php
diff options
context:
space:
mode:
authorwei <>2006-04-25 01:00:08 +0000
committerwei <>2006-04-25 01:00:08 +0000
commitc84f3e19b54cf54f525f4b2d158696ae32d1bf60 (patch)
tree60720fba29ef72175db47dd3cd4b74d8bbed605b /framework/Web/UI/WebControls/TDatePicker.php
parent09edc6590523e26fffbf32f7b0e7958c166f7537 (diff)
Add TListControlValidator. Update client-side validators, datepicker.js, colorpicker.js.
Diffstat (limited to 'framework/Web/UI/WebControls/TDatePicker.php')
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php45
1 files changed, 37 insertions, 8 deletions
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index c6a2345b..02386515 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -245,17 +245,16 @@ class TDatePicker extends TTextBox
/**
* @return integer current selected date from the date picker as timestamp.
*/
- public function getDate()
+ public function getTimeStamp()
{
- $date = $this->getDateFromText();
- return $date[0];
+ return $this->getTimeStampFromText();
}
/**
* Sets the date for the date picker using timestamp.
* @param integer time stamp for the date picker
*/
- public function setDate($value)
+ public function setTimeStamp($value)
{
$date = TPropertyValue::ensureInteger($value);
$formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',
@@ -264,6 +263,34 @@ class TDatePicker extends TTextBox
}
/**
+ * @return string the date string.
+ */
+ public function getDate()
+ {
+ return $this->getText();
+ }
+
+ /**
+ * @param string date string
+ */
+ public function setDate($value)
+ {
+ $this->setText($value);
+ }
+
+ /**
+ * Returns the value to be validated.
+ * This methid is required by IValidatable interface.
+ * @return integer the value of the property to be validated.
+ */
+ public function getValidationPropertyValue()
+ {
+ if($this->getText() === '')
+ return '';
+ return $this->getTimeStamp();
+ }
+
+ /**
* Publish the date picker Css asset files.
*/
public function onPreRender($param)
@@ -396,6 +423,7 @@ class TDatePicker extends TTextBox
$date = $this->getLocalizedCalendarInfo();
$options['MonthNames'] = TJavaScript::encode($date->getMonthNames(),false);
+ $options['AbbreviatedMonthNames'] = TJavaScript::encode($date->getAbbreviatedMonthNames(),false);
$options['ShortWeekDayNames'] = TJavaScript::encode($date->getAbbreviatedDayNames(),false);
return $options;
@@ -439,7 +467,8 @@ class TDatePicker extends TTextBox
$writer->addAttribute('class', $class);
$writer->renderBeginTag('span');
- $date = $this->getDateFromText();
+ $date = @getdate($this->getTimeStampFromText());
+
$this->renderCalendarSelections($writer, $date);
//render a hidden input field
@@ -481,9 +510,9 @@ class TDatePicker extends TTextBox
/**
* Gets the date from the text input using TSimpleDateFormatter
- * @return array current selected date
+ * @return integer current selected date timestamp
*/
- protected function getDateFromText()
+ protected function getTimeStampFromText()
{
$pattern = $this->getDateFormat();
$pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern);
@@ -559,7 +588,7 @@ class TDatePicker extends TTextBox
case 'MMM':
case 'MM': return $info->getAbbreviatedMonthNames();
case 'M':
- $array = array(); for($i=1;$i<=12;$i++) $array[$i] = $i;
+ $array = array(); for($i=1;$i<=12;$i++) $array[$i-1] = $i;
return $array;
default : return $info->getMonthNames();
}