From 62274f7a89ff033a32bcd436923d39d90831f4db Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 1 Aug 2006 00:43:51 +0000 Subject: Fixed #311 --- .gitattributes | 1 + framework/Util/TSimpleDateFormatter.php | 5 ++++- framework/Web/Javascripts/js/validator.js | 2 +- framework/Web/Javascripts/prado/validation3.js | 2 +- framework/Web/UI/WebControls/TDatePicker.php | 16 ++++++++++++---- .../tickets/protected/pages/Ticket311.page | 18 ++++++++++++++++++ 6 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 tests/FunctionalTests/tickets/protected/pages/Ticket311.page diff --git a/.gitattributes b/.gitattributes index 01c536f9..4570c63a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1634,6 +1634,7 @@ tests/FunctionalTests/tickets/protected/pages/Ticket284.page -text tests/FunctionalTests/tickets/protected/pages/Ticket284.php -text tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php -text tests/FunctionalTests/tickets/protected/pages/Ticket284Component.tpl -text +tests/FunctionalTests/tickets/protected/pages/Ticket311.page -text tests/FunctionalTests/tickets/protected/pages/Ticket54.page -text tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php -text tests/FunctionalTests/tickets/protected/pages/Ticket54Master.tpl -text diff --git a/framework/Util/TSimpleDateFormatter.php b/framework/Util/TSimpleDateFormatter.php index 2a3da63a..971225b5 100644 --- a/framework/Util/TSimpleDateFormatter.php +++ b/framework/Util/TSimpleDateFormatter.php @@ -294,11 +294,14 @@ class TSimpleDateFormatter } if ($i_val != $this->length($value)) throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); - + //var_dump('month is '.$month); if(!$defaultToCurrentTime && (is_null($month) || is_null($day) || is_null($year))) return null; else + { + $day = intval($day) <= 0 ? 1 : intval($day); return @mktime(0, 0, 0, $month, $day, $year); + } } /** diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js index 1480368f..ee578ea2 100644 --- a/framework/Web/Javascripts/js/validator.js +++ b/framework/Web/Javascripts/js/validator.js @@ -54,7 +54,7 @@ this.visible=this.visible&&this.messages.style.display!="none";Prado.Validation. return;} var refresh=update||this.visible==false||this.options.Refresh!=false;if(this.options.ShowSummary!=false&&refresh) {this.updateHTMLMessages(this.getMessages(validators));this.showSummary(validators);} -if(this.options.ScrollToSummary!=false) +if(this.options.ScrollToSummary!=false&&refresh) window.scrollTo(this.messages.offsetLeft-20,this.messages.offsetTop-20);if(this.options.ShowMessageBox==true&&refresh) {this.alertMessages(this.getMessages(validators));this.visible=true;}},updateHTMLMessages:function(messages) {while(this.messages.childNodes.length>0) diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 0e765c48..f5f058c8 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -387,7 +387,7 @@ Prado.WebUI.TValidationSummary.prototype = this.showSummary(validators); } - if(this.options.ScrollToSummary != false) + if(this.options.ScrollToSummary != false && refresh) window.scrollTo(this.messages.offsetLeft-20, this.messages.offsetTop-20); if(this.options.ShowMessageBox == true && refresh) diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index a746437b..529728ec 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -384,7 +384,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 +499,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']); } @@ -562,13 +565,14 @@ 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'); $writer->renderBeginTag('select'); $this->renderDropDownListOptions($writer, - $this->getLocalizedMonthNames($info), $selected); + $this->getLocalizedMonthNames($info), $selected-1); $writer->renderEndTag(); } @@ -585,8 +589,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; diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket311.page b/tests/FunctionalTests/tickets/protected/pages/Ticket311.page new file mode 100644 index 00000000..45b41b7d --- /dev/null +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket311.page @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3