From 6228873cf9d6471463d2413e7dfd7447f759baf2 Mon Sep 17 00:00:00 2001 From: "christophe.boulain" <> Date: Wed, 3 Dec 2008 14:22:03 +0000 Subject: Merge from trunk --- framework/Web/UI/WebControls/TBaseDataList.php | 1 - framework/Web/UI/WebControls/TBaseValidator.php | 15 +- framework/Web/UI/WebControls/TBoundColumn.php | 1 - framework/Web/UI/WebControls/TBulletedList.php | 1 - framework/Web/UI/WebControls/TButton.php | 1 - framework/Web/UI/WebControls/TButtonColumn.php | 1 - framework/Web/UI/WebControls/TCaptcha.php | 1 - framework/Web/UI/WebControls/TCaptchaValidator.php | 1 - framework/Web/UI/WebControls/TCheckBox.php | 18 ++ framework/Web/UI/WebControls/TCheckBoxColumn.php | 1 - framework/Web/UI/WebControls/TCheckBoxList.php | 19 +- framework/Web/UI/WebControls/TClientScript.php | 1 - .../Web/UI/WebControls/TClientScriptLoader.php | 1 - framework/Web/UI/WebControls/TColorPicker.php | 4 +- framework/Web/UI/WebControls/TCompareValidator.php | 1 - framework/Web/UI/WebControls/TConditional.php | 1 - framework/Web/UI/WebControls/TContent.php | 1 - .../Web/UI/WebControls/TContentPlaceHolder.php | 1 - framework/Web/UI/WebControls/TCustomValidator.php | 26 +- framework/Web/UI/WebControls/TDataGrid.php | 1 - framework/Web/UI/WebControls/TDataGridColumn.php | 1 - .../Web/UI/WebControls/TDataGridItemRenderer.php | 1 - .../Web/UI/WebControls/TDataGridPagerStyle.php | 1 - framework/Web/UI/WebControls/TDataList.php | 1 - .../Web/UI/WebControls/TDataListItemRenderer.php | 1 - framework/Web/UI/WebControls/TDataRenderer.php | 1 - .../Web/UI/WebControls/TDataSourceControl.php | 1 - framework/Web/UI/WebControls/TDataSourceView.php | 1 - .../Web/UI/WebControls/TDataTypeValidator.php | 1 - framework/Web/UI/WebControls/TDatePicker.php | 46 ++- framework/Web/UI/WebControls/TDropDownList.php | 19 +- .../Web/UI/WebControls/TDropDownListColumn.php | 1 - .../Web/UI/WebControls/TEditCommandColumn.php | 1 - .../Web/UI/WebControls/TEmailAddressValidator.php | 1 - framework/Web/UI/WebControls/TExpression.php | 1 - framework/Web/UI/WebControls/TFileUpload.php | 20 +- framework/Web/UI/WebControls/TFont.php | 1 - framework/Web/UI/WebControls/THead.php | 21 +- framework/Web/UI/WebControls/THiddenField.php | 19 +- framework/Web/UI/WebControls/THtmlArea.php | 1 - framework/Web/UI/WebControls/THyperLink.php | 1 - framework/Web/UI/WebControls/THyperLinkColumn.php | 1 - framework/Web/UI/WebControls/TImage.php | 1 - framework/Web/UI/WebControls/TImageMap.php | 1 - framework/Web/UI/WebControls/TInlineFrame.php | 1 - framework/Web/UI/WebControls/TItemDataRenderer.php | 1 - framework/Web/UI/WebControls/TJavascriptLogger.php | 1 - framework/Web/UI/WebControls/TKeyboard.php | 1 - framework/Web/UI/WebControls/TLabel.php | 1 - framework/Web/UI/WebControls/TLinkButton.php | 1 - framework/Web/UI/WebControls/TListBox.php | 19 +- .../Web/UI/WebControls/TListControlValidator.php | 1 - framework/Web/UI/WebControls/TListItem.php | 1 - framework/Web/UI/WebControls/TLiteral.php | 1 - framework/Web/UI/WebControls/TLiteralColumn.php | 1 - framework/Web/UI/WebControls/TMarkdown.php | 1 - framework/Web/UI/WebControls/TMultiView.php | 1 - framework/Web/UI/WebControls/TOutputCache.php | 1 - framework/Web/UI/WebControls/TPager.php | 1 - framework/Web/UI/WebControls/TPanel.php | 1 - framework/Web/UI/WebControls/TPanelStyle.php | 1 - framework/Web/UI/WebControls/TPlaceHolder.php | 1 - framework/Web/UI/WebControls/TRadioButton.php | 1 - framework/Web/UI/WebControls/TRadioButtonList.php | 1 - framework/Web/UI/WebControls/TRangeValidator.php | 1 - framework/Web/UI/WebControls/TRatingList.php | 348 ++++++++++++++------- .../UI/WebControls/TRegularExpressionValidator.php | 21 +- framework/Web/UI/WebControls/TRepeatInfo.php | 1 - framework/Web/UI/WebControls/TRepeater.php | 1 - .../Web/UI/WebControls/TRepeaterItemRenderer.php | 1 - .../Web/UI/WebControls/TRequiredFieldValidator.php | 1 - framework/Web/UI/WebControls/TSafeHtml.php | 1 - framework/Web/UI/WebControls/TSlider.php | 7 +- framework/Web/UI/WebControls/TStatements.php | 1 - framework/Web/UI/WebControls/TStyle.php | 1 - framework/Web/UI/WebControls/TTable.php | 1 - framework/Web/UI/WebControls/TTableCell.php | 1 - framework/Web/UI/WebControls/TTableFooterRow.php | 1 - framework/Web/UI/WebControls/TTableHeaderCell.php | 1 - framework/Web/UI/WebControls/TTableHeaderRow.php | 1 - framework/Web/UI/WebControls/TTableRow.php | 1 - framework/Web/UI/WebControls/TTemplateColumn.php | 1 - framework/Web/UI/WebControls/TTextBox.php | 19 +- framework/Web/UI/WebControls/TTextHighlighter.php | 1 - framework/Web/UI/WebControls/TTextProcessor.php | 1 - .../Web/UI/WebControls/TValidationSummary.php | 1 - framework/Web/UI/WebControls/TWebControl.php | 1 - .../Web/UI/WebControls/TWebControlAdapter.php | 1 - framework/Web/UI/WebControls/TWizard.php | 1 - .../WebControls/TWizardNavigationButtonStyle.php | 1 - framework/Web/UI/WebControls/TXmlTransform.php | 1 - framework/Web/UI/WebControls/assets/captcha.php | 1 - 92 files changed, 483 insertions(+), 215 deletions(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TBaseDataList.php b/framework/Web/UI/WebControls/TBaseDataList.php index df91a0a6..d202eab8 100644 --- a/framework/Web/UI/WebControls/TBaseDataList.php +++ b/framework/Web/UI/WebControls/TBaseDataList.php @@ -188,4 +188,3 @@ abstract class TBaseDataList extends TDataBoundControl } } -?> diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index add771cc..b418885c 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -269,8 +269,11 @@ abstract class TBaseValidator extends TLabel implements IValidator { $class = preg_replace ('/ '.preg_quote($cssClass).'/', '',$control->getCssClass()); if(!$this->getIsValid()) + { $class .= ' '.$cssClass; - $control->setCssClass($class); + $control->setCssClass($class); + } elseif ($control->getIsValid()) + $control->setCssClass($class); } } } @@ -493,7 +496,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $this->setIsValid(true); $this->onValidate(); if($this->getVisible(true) && $this->getEnabled(true)) - { + { // if the target is not a disabled web control if(($target=$this->getValidationTarget())!==null && !($target instanceof TWebControl && !$target->getEnabled(true))) { @@ -504,10 +507,17 @@ abstract class TBaseValidator extends TLabel implements IValidator } else { + $target->setIsValid(false); $this->setIsValid(false); $this->onValidationError(); } } + else + { + $this->evaluateIsValid(); + $this->setIsValid(true); + $this->onValidationSuccess(); + } } return $this->getIsValid(); } @@ -721,4 +731,3 @@ class TValidationDataType extends TEnumerable const String='String'; } -?> diff --git a/framework/Web/UI/WebControls/TBoundColumn.php b/framework/Web/UI/WebControls/TBoundColumn.php index 13fb6af8..264bbc6c 100644 --- a/framework/Web/UI/WebControls/TBoundColumn.php +++ b/framework/Web/UI/WebControls/TBoundColumn.php @@ -233,4 +233,3 @@ class TBoundColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php index f99c7986..60cf743e 100644 --- a/framework/Web/UI/WebControls/TBulletedList.php +++ b/framework/Web/UI/WebControls/TBulletedList.php @@ -485,4 +485,3 @@ class TBulletedListDisplayMode extends TEnumerable const LinkButton='LinkButton'; } -?> diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index dc66e9d6..81929a28 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -366,4 +366,3 @@ class TButtonType extends TEnumerable const Button='Button'; } -?> diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php index 24199ddd..186577e5 100644 --- a/framework/Web/UI/WebControls/TButtonColumn.php +++ b/framework/Web/UI/WebControls/TButtonColumn.php @@ -276,4 +276,3 @@ class TButtonColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TCaptcha.php b/framework/Web/UI/WebControls/TCaptcha.php index 153b1d30..3c51c389 100644 --- a/framework/Web/UI/WebControls/TCaptcha.php +++ b/framework/Web/UI/WebControls/TCaptcha.php @@ -489,4 +489,3 @@ class TCaptcha extends TImage } } -?> diff --git a/framework/Web/UI/WebControls/TCaptchaValidator.php b/framework/Web/UI/WebControls/TCaptchaValidator.php index 770cd514..5477fe54 100644 --- a/framework/Web/UI/WebControls/TCaptchaValidator.php +++ b/framework/Web/UI/WebControls/TCaptchaValidator.php @@ -121,4 +121,3 @@ class TCaptchaValidator extends TBaseValidator } } -?> diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index faff5086..d8c2cc0b 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -43,6 +43,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer, ISurroundable { private $_dataChanged=false; + private $_isValid=true; /** * @return string tag name of the button @@ -125,6 +126,23 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl return $this->getChecked(); } + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /** * @return string the text caption of the checkbox */ diff --git a/framework/Web/UI/WebControls/TCheckBoxColumn.php b/framework/Web/UI/WebControls/TCheckBoxColumn.php index 36217343..71eea97f 100644 --- a/framework/Web/UI/WebControls/TCheckBoxColumn.php +++ b/framework/Web/UI/WebControls/TCheckBoxColumn.php @@ -121,4 +121,3 @@ class TCheckBoxColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 1e1c3b10..742dd18b 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -53,6 +53,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont private $_isEnabled; private $_changedEventRaised=false; private $_dataChanged=false; + private $_isValid=true; /** * Constructor. @@ -428,6 +429,23 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont return $this->getSelectedValue(); } + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /** * Gets the name of the javascript class responsible for performing postback for this control. * This method overrides the parent implementation. @@ -454,4 +472,3 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont } -?> diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php index 5369d27d..b5806a57 100644 --- a/framework/Web/UI/WebControls/TClientScript.php +++ b/framework/Web/UI/WebControls/TClientScript.php @@ -129,4 +129,3 @@ class TClientScript extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TClientScriptLoader.php b/framework/Web/UI/WebControls/TClientScriptLoader.php index c916bcc5..ec763bb3 100644 --- a/framework/Web/UI/WebControls/TClientScriptLoader.php +++ b/framework/Web/UI/WebControls/TClientScriptLoader.php @@ -168,4 +168,3 @@ class TClientScriptLoader extends TWebControl } } -?> diff --git a/framework/Web/UI/WebControls/TColorPicker.php b/framework/Web/UI/WebControls/TColorPicker.php index 5b96723a..67a4ccfe 100644 --- a/framework/Web/UI/WebControls/TColorPicker.php +++ b/framework/Web/UI/WebControls/TColorPicker.php @@ -4,7 +4,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -203,6 +203,7 @@ class TColorPicker extends TTextBox $writer->addAttribute('style', "background-color:{$color};"); $writer->addAttribute('width', '20'); $writer->addAttribute('height', '20'); + $writer->addAttribute('alt', ''); $writer->renderBeginTag('img'); $writer->renderEndTag(); $writer->renderEndTag(); @@ -270,4 +271,3 @@ class TColorPickerClientSide extends TClientSideOptions } } -?> diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index e5723f2a..1261cded 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -263,4 +263,3 @@ class TValidationCompareOperator extends TEnumerable const LessThanEqual='LessThanEqual'; } -?> diff --git a/framework/Web/UI/WebControls/TConditional.php b/framework/Web/UI/WebControls/TConditional.php index 7af6622e..fafe12c9 100644 --- a/framework/Web/UI/WebControls/TConditional.php +++ b/framework/Web/UI/WebControls/TConditional.php @@ -141,4 +141,3 @@ class TConditional extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TContent.php b/framework/Web/UI/WebControls/TContent.php index ecc2a1b5..b327b440 100644 --- a/framework/Web/UI/WebControls/TContent.php +++ b/framework/Web/UI/WebControls/TContent.php @@ -45,4 +45,3 @@ class TContent extends TControl implements INamingContainer } } -?> diff --git a/framework/Web/UI/WebControls/TContentPlaceHolder.php b/framework/Web/UI/WebControls/TContentPlaceHolder.php index 29e12ab3..90390d9d 100644 --- a/framework/Web/UI/WebControls/TContentPlaceHolder.php +++ b/framework/Web/UI/WebControls/TContentPlaceHolder.php @@ -46,4 +46,3 @@ class TContentPlaceHolder extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index e998cef6..0b82ac5c 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -88,7 +88,9 @@ class TCustomValidator extends TBaseValidator */ public function evaluateIsValid() { - $value=$this->getValidationValue($this->getValidationTarget()); + $value = ''; + if($this->getValidationTarget()!==null) + $value=$this->getValidationValue($this->getValidationTarget()); return $this->onServerValidate($value); } @@ -105,9 +107,24 @@ class TCustomValidator extends TBaseValidator { $param=new TServerValidateEventParameter($value,true); $this->raiseEvent('OnServerValidate',$this,$param); - return $param->getIsValid(); + if($this->getValidationTarget()==null) + return true; + else + return $param->getIsValid(); + } + + /** + * @return TControl control to be validated. Null if no control is found. + */ + protected function getValidationTarget() + { + if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null) + return $control; + else if(($id=$this->getControlToValidate())!=='') + throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this)); + else + return null; } - /** * Returns an array of javascript validator options. @@ -191,4 +208,3 @@ class TServerValidateEventParameter extends TEventParameter $this->_isValid=TPropertyValue::ensureBoolean($value); } } -?> diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index c8e6c9a8..9551b376 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -2203,4 +2203,3 @@ class TDataGridPagerPosition extends TEnumerable const TopAndBottom='TopAndBottom'; } -?> diff --git a/framework/Web/UI/WebControls/TDataGridColumn.php b/framework/Web/UI/WebControls/TDataGridColumn.php index e3c2f297..577c0068 100644 --- a/framework/Web/UI/WebControls/TDataGridColumn.php +++ b/framework/Web/UI/WebControls/TDataGridColumn.php @@ -565,4 +565,3 @@ class TButtonColumnType extends TEnumerable const ImageButton='ImageButton'; } -?> diff --git a/framework/Web/UI/WebControls/TDataGridItemRenderer.php b/framework/Web/UI/WebControls/TDataGridItemRenderer.php index 8e0f9e70..62c226f6 100644 --- a/framework/Web/UI/WebControls/TDataGridItemRenderer.php +++ b/framework/Web/UI/WebControls/TDataGridItemRenderer.php @@ -28,4 +28,3 @@ class TDataGridItemRenderer extends TItemDataRenderer { } -?> diff --git a/framework/Web/UI/WebControls/TDataGridPagerStyle.php b/framework/Web/UI/WebControls/TDataGridPagerStyle.php index dcc9d983..e29b9dc9 100644 --- a/framework/Web/UI/WebControls/TDataGridPagerStyle.php +++ b/framework/Web/UI/WebControls/TDataGridPagerStyle.php @@ -219,4 +219,3 @@ class TDataGridPagerStyle extends TPanelStyle } } -?> diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php index 7d0965a2..ca628b21 100644 --- a/framework/Web/UI/WebControls/TDataList.php +++ b/framework/Web/UI/WebControls/TDataList.php @@ -1764,4 +1764,3 @@ class TDataListItemCollection extends TList } } -?> diff --git a/framework/Web/UI/WebControls/TDataListItemRenderer.php b/framework/Web/UI/WebControls/TDataListItemRenderer.php index 5481cad7..1bf2fcb2 100644 --- a/framework/Web/UI/WebControls/TDataListItemRenderer.php +++ b/framework/Web/UI/WebControls/TDataListItemRenderer.php @@ -170,4 +170,3 @@ class TDataListItemRenderer extends TItemDataRenderer implements IStyleable } } -?> diff --git a/framework/Web/UI/WebControls/TDataRenderer.php b/framework/Web/UI/WebControls/TDataRenderer.php index e884afe1..4aaeec0a 100644 --- a/framework/Web/UI/WebControls/TDataRenderer.php +++ b/framework/Web/UI/WebControls/TDataRenderer.php @@ -50,4 +50,3 @@ abstract class TDataRenderer extends TTemplateControl implements IDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/TDataSourceControl.php b/framework/Web/UI/WebControls/TDataSourceControl.php index e42d7381..1d0823ff 100644 --- a/framework/Web/UI/WebControls/TDataSourceControl.php +++ b/framework/Web/UI/WebControls/TDataSourceControl.php @@ -116,4 +116,3 @@ class TReadOnlyDataSource extends TDataSourceControl } } -?> diff --git a/framework/Web/UI/WebControls/TDataSourceView.php b/framework/Web/UI/WebControls/TDataSourceView.php index 7c0ee2d0..7297fd45 100644 --- a/framework/Web/UI/WebControls/TDataSourceView.php +++ b/framework/Web/UI/WebControls/TDataSourceView.php @@ -204,4 +204,3 @@ class TReadOnlyDataSourceView extends TDataSourceView } } -?> diff --git a/framework/Web/UI/WebControls/TDataTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php index d4fa20c3..14017585 100644 --- a/framework/Web/UI/WebControls/TDataTypeValidator.php +++ b/framework/Web/UI/WebControls/TDataTypeValidator.php @@ -139,4 +139,3 @@ class TDataTypeValidator extends TBaseValidator } } -?> diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 84455fee..770099eb 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -4,7 +4,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -59,7 +59,12 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); * In DropDownList mode, in addition to the popup date picker, three * drop down list (day, month and year) are presented to select the date . * + * The PositionMode property can be set to "Top" or "Bottom" with default + * as "Bottom". It specifies the position of the calendar popup, relative to the + * input field. + * * @author Wei Zhuo + * @author Carl G. Mathisen * @version $Id$ * @package System.Web.UI.WebControls * @since 3.0 @@ -263,6 +268,22 @@ class TDatePicker extends TTextBox { return $this->getViewState('UpToYear', intval(@date('Y'))+10); } + + /** + * @param TDatePickerPositionMode calendar UI position + */ + public function setPositionMode($value) + { + $this->setViewState('PositionMode', TPropertyValue::ensureEnum($value, 'TDatePickerPositionMode'), TDatePickerPositionMode::Bottom); + } + + /** + * @return TDatePickerPositionMode current calendar UI position. + */ + public function getPositionMode() + { + return $this->getViewState('PositionMode', TDatePickerPositionMode::Bottom); + } /** * @return integer current selected date from the date picker as timestamp, NULL if timestamp is not set previously. @@ -505,6 +526,7 @@ class TDatePicker extends TTextBox $options['UpToYear'] = $this->getUpToYear(); if($this->getMode()!==TDatePickerMode::Basic) $options['Trigger'] = $this->getDatePickerButtonID(); + $options['PositionMode'] = $this->getPositionMode(); $options = array_merge($options, $this->getCulturalOptions()); if(!is_null($this->_clientScript)) @@ -853,8 +875,8 @@ class TDatePicker extends TTextBox * * The OnDateChanged event is raise when the date picker's date * is changed. - * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent - * as parameter to this event + * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent + * as parameter to this event * * @author Wei Zhuo * @version $Id$ @@ -923,4 +945,20 @@ class TDatePickerMode extends TEnumerable const ImageButton='ImageButton'; } -?> +/** + * TDatePickerPositionMode class. + * TDatePickerPositionMode defines the positions available for the calendar popup, relative to the corresponding input. + * + * The following enumerable values are defined: + * - Top: the date picker is placed above the input field + * - Bottom: the date picker is placed below the input field + * + * @author Carl G. Mathisen + * @package System.Web.UI.WebControls + * @since 3.1.4 + */ +class TDatePickerPositionMode extends TEnumerable +{ + const Top='Top'; + const Bottom='Bottom'; +} \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php index f00466d5..73be981c 100644 --- a/framework/Web/UI/WebControls/TDropDownList.php +++ b/framework/Web/UI/WebControls/TDropDownList.php @@ -40,6 +40,7 @@ Prado::using('System.Web.UI.WebControls.TListControl'); class TDropDownList extends TListControl implements IPostBackDataHandler, IValidatable { private $_dataChanged=false; + private $_isValid=true; /** * Adds attributes to renderer. @@ -127,5 +128,21 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid { return $this->getSelectedValue(); } + + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } } -?> diff --git a/framework/Web/UI/WebControls/TDropDownListColumn.php b/framework/Web/UI/WebControls/TDropDownListColumn.php index cff42cad..a225abac 100644 --- a/framework/Web/UI/WebControls/TDropDownListColumn.php +++ b/framework/Web/UI/WebControls/TDropDownListColumn.php @@ -319,4 +319,3 @@ class TDropDownListColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TEditCommandColumn.php b/framework/Web/UI/WebControls/TEditCommandColumn.php index f9989a4e..1699afa2 100644 --- a/framework/Web/UI/WebControls/TEditCommandColumn.php +++ b/framework/Web/UI/WebControls/TEditCommandColumn.php @@ -263,4 +263,3 @@ class TEditCommandColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php index c5407516..206bd23d 100644 --- a/framework/Web/UI/WebControls/TEmailAddressValidator.php +++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php @@ -95,4 +95,3 @@ class TEmailAddressValidator extends TRegularExpressionValidator } } -?> diff --git a/framework/Web/UI/WebControls/TExpression.php b/framework/Web/UI/WebControls/TExpression.php index 022a0b21..34190473 100644 --- a/framework/Web/UI/WebControls/TExpression.php +++ b/framework/Web/UI/WebControls/TExpression.php @@ -60,4 +60,3 @@ class TExpression extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TFileUpload.php b/framework/Web/UI/WebControls/TFileUpload.php index 47d49c0c..6658e93d 100644 --- a/framework/Web/UI/WebControls/TFileUpload.php +++ b/framework/Web/UI/WebControls/TFileUpload.php @@ -59,6 +59,7 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata */ private $_errorCode=UPLOAD_ERR_NO_FILE; private $_dataChanged=false; + private $_isValid=true; /** * @return string tag name of the file upload control @@ -255,6 +256,23 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata { return $this->getFileName(); } + + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + } -?> diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php index cb0fba93..9ba644f8 100644 --- a/framework/Web/UI/WebControls/TFont.php +++ b/framework/Web/UI/WebControls/TFont.php @@ -316,4 +316,3 @@ class TFont extends TComponent $writer->addStyleAttribute('font-family',$this->_name); } } -?> diff --git a/framework/Web/UI/WebControls/THead.php b/framework/Web/UI/WebControls/THead.php index 1b51f8ae..62ee46d3 100644 --- a/framework/Web/UI/WebControls/THead.php +++ b/framework/Web/UI/WebControls/THead.php @@ -4,7 +4,7 @@ * * @author Marcus Nyeholt and Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI @@ -29,6 +29,13 @@ * * * + * + * A MetaTag for "generator" is added by default if you haven't specified your own generator meta tag. You can override + * the property by adding the following code to your template: + * + * + * + * * * Note, {@link TPage} has a property {@link TPage::getHead Head} that refers to * the THead control currently on the page. A page can have at most once THead @@ -155,14 +162,24 @@ class THead extends TControl if(($icon=$this->getShortcutIcon())!=='') $writer->write('\n"); + $generatorAdded = false; if(($metaTags=$this->getMetaTags())!==null) { foreach($metaTags as $metaTag) { + if(strtolower($metaTag->getName()) == 'generator') + $generatorAdded = true; $metaTag->render($writer); $writer->writeLine(); } } + if(!$generatorAdded) + { + $metaTag = new TMetaTag(); + $metaTag->setName('generator'); + $metaTag->setContent(Prado::metaGenerator()); + $metaTag->render($writer); + } $cs=$page->getClientScript(); $cs->renderStyleSheetFiles($writer); $cs->renderStyleSheets($writer); @@ -374,4 +391,4 @@ class TMetaTagCollection extends TList } } -?> +?> diff --git a/framework/Web/UI/WebControls/THiddenField.php b/framework/Web/UI/WebControls/THiddenField.php index 2fbbcf99..49b1aa39 100644 --- a/framework/Web/UI/WebControls/THiddenField.php +++ b/framework/Web/UI/WebControls/THiddenField.php @@ -26,6 +26,7 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatable, IDataRenderer { private $_dataChanged=false; + private $_isValid=true; /** * @return string tag name of the hidden field. @@ -111,6 +112,23 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatabl return $this->getValue(); } + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /** * Raises postdata changed event. * This method calls {@link onValueChanged} method. @@ -204,4 +222,3 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatabl } } -?> diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index b9245be3..7fea5862 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -473,4 +473,3 @@ class THtmlArea extends TTextBox } } -?> diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php index 3bd92ffd..217fa267 100644 --- a/framework/Web/UI/WebControls/THyperLink.php +++ b/framework/Web/UI/WebControls/THyperLink.php @@ -187,4 +187,3 @@ class THyperLink extends TWebControl implements IDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/THyperLinkColumn.php b/framework/Web/UI/WebControls/THyperLinkColumn.php index 8ac1177f..7db6eda8 100644 --- a/framework/Web/UI/WebControls/THyperLinkColumn.php +++ b/framework/Web/UI/WebControls/THyperLinkColumn.php @@ -215,4 +215,3 @@ class THyperLinkColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TImage.php b/framework/Web/UI/WebControls/TImage.php index e1ff8535..220fa4a6 100644 --- a/framework/Web/UI/WebControls/TImage.php +++ b/framework/Web/UI/WebControls/TImage.php @@ -155,4 +155,3 @@ class TImage extends TWebControl implements IDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php index 89daca44..d0cd8a0a 100644 --- a/framework/Web/UI/WebControls/TImageMap.php +++ b/framework/Web/UI/WebControls/TImageMap.php @@ -835,4 +835,3 @@ class THotSpotMode extends TEnumerable const Inactive='Inactive'; } -?> diff --git a/framework/Web/UI/WebControls/TInlineFrame.php b/framework/Web/UI/WebControls/TInlineFrame.php index dae728d3..c47af648 100644 --- a/framework/Web/UI/WebControls/TInlineFrame.php +++ b/framework/Web/UI/WebControls/TInlineFrame.php @@ -274,4 +274,3 @@ class TInlineFrameScrollBars extends TEnumerable const Auto='Auto'; const Both='Both'; } -?> diff --git a/framework/Web/UI/WebControls/TItemDataRenderer.php b/framework/Web/UI/WebControls/TItemDataRenderer.php index a57ff27d..79e0186e 100644 --- a/framework/Web/UI/WebControls/TItemDataRenderer.php +++ b/framework/Web/UI/WebControls/TItemDataRenderer.php @@ -81,4 +81,3 @@ abstract class TItemDataRenderer extends TDataRenderer implements IItemDataRende } } -?> diff --git a/framework/Web/UI/WebControls/TJavascriptLogger.php b/framework/Web/UI/WebControls/TJavascriptLogger.php index 11e64735..6d49f801 100644 --- a/framework/Web/UI/WebControls/TJavascriptLogger.php +++ b/framework/Web/UI/WebControls/TJavascriptLogger.php @@ -91,4 +91,3 @@ class TJavascriptLogger extends TWebControl } } -?> diff --git a/framework/Web/UI/WebControls/TKeyboard.php b/framework/Web/UI/WebControls/TKeyboard.php index 7c9357d7..9c26fab8 100644 --- a/framework/Web/UI/WebControls/TKeyboard.php +++ b/framework/Web/UI/WebControls/TKeyboard.php @@ -186,4 +186,3 @@ class TKeyboard extends TWebControl } } -?> diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php index 3e61eddf..d1595ead 100644 --- a/framework/Web/UI/WebControls/TLabel.php +++ b/framework/Web/UI/WebControls/TLabel.php @@ -152,4 +152,3 @@ class TLabel extends TWebControl implements IDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d847f07e..459b98cf 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -332,4 +332,3 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC } } -?> diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index 903dbed8..1b4599fc 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -39,6 +39,7 @@ Prado::using('System.Web.UI.WebControls.TListControl'); class TListBox extends TListControl implements IPostBackDataHandler, IValidatable { private $_dataChanged=false; + private $_isValid=true; /** * Adds attribute name-value pairs to renderer. @@ -220,6 +221,23 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl { return $this->getSelectedValue(); } + + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } } @@ -242,4 +260,3 @@ class TListSelectionMode extends TEnumerable const Multiple='Multiple'; } -?> diff --git a/framework/Web/UI/WebControls/TListControlValidator.php b/framework/Web/UI/WebControls/TListControlValidator.php index f468a30e..f547884f 100644 --- a/framework/Web/UI/WebControls/TListControlValidator.php +++ b/framework/Web/UI/WebControls/TListControlValidator.php @@ -223,4 +223,3 @@ class TListControlValidator extends TBaseValidator return $options; } } -?> diff --git a/framework/Web/UI/WebControls/TListItem.php b/framework/Web/UI/WebControls/TListItem.php index 2017b64e..eb72d183 100644 --- a/framework/Web/UI/WebControls/TListItem.php +++ b/framework/Web/UI/WebControls/TListItem.php @@ -182,4 +182,3 @@ class TListItem extends TComponent } } -?> diff --git a/framework/Web/UI/WebControls/TLiteral.php b/framework/Web/UI/WebControls/TLiteral.php index 0c93043a..3a7f4581 100644 --- a/framework/Web/UI/WebControls/TLiteral.php +++ b/framework/Web/UI/WebControls/TLiteral.php @@ -110,4 +110,3 @@ class TLiteral extends TControl implements IDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/TLiteralColumn.php b/framework/Web/UI/WebControls/TLiteralColumn.php index cb97adb5..8ca87023 100644 --- a/framework/Web/UI/WebControls/TLiteralColumn.php +++ b/framework/Web/UI/WebControls/TLiteralColumn.php @@ -152,4 +152,3 @@ class TLiteralColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TMarkdown.php b/framework/Web/UI/WebControls/TMarkdown.php index dc6bc5e2..d630cd29 100644 --- a/framework/Web/UI/WebControls/TMarkdown.php +++ b/framework/Web/UI/WebControls/TMarkdown.php @@ -73,4 +73,3 @@ class TMarkdown extends TTextHighlighter } } -?> diff --git a/framework/Web/UI/WebControls/TMultiView.php b/framework/Web/UI/WebControls/TMultiView.php index 6adaed5b..1f87b03f 100644 --- a/framework/Web/UI/WebControls/TMultiView.php +++ b/framework/Web/UI/WebControls/TMultiView.php @@ -376,4 +376,3 @@ class TView extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php index dd38ae03..c0747a11 100644 --- a/framework/Web/UI/WebControls/TOutputCache.php +++ b/framework/Web/UI/WebControls/TOutputCache.php @@ -582,4 +582,3 @@ class TOutputCacheCalculateKeyEventParameter extends TEventParameter } } -?> diff --git a/framework/Web/UI/WebControls/TPager.php b/framework/Web/UI/WebControls/TPager.php index d1a5db25..51ea2a11 100644 --- a/framework/Web/UI/WebControls/TPager.php +++ b/framework/Web/UI/WebControls/TPager.php @@ -790,4 +790,3 @@ class TPagerButtonType extends TEnumerable const ImageButton='ImageButton'; } -?> diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php index 661795d7..5bbcdcca 100644 --- a/framework/Web/UI/WebControls/TPanel.php +++ b/framework/Web/UI/WebControls/TPanel.php @@ -234,4 +234,3 @@ class TPanel extends TWebControl } } -?> diff --git a/framework/Web/UI/WebControls/TPanelStyle.php b/framework/Web/UI/WebControls/TPanelStyle.php index 08667860..2d6ee824 100644 --- a/framework/Web/UI/WebControls/TPanelStyle.php +++ b/framework/Web/UI/WebControls/TPanelStyle.php @@ -276,4 +276,3 @@ class TScrollBars extends TEnumerable const Vertical='Vertical'; } -?> diff --git a/framework/Web/UI/WebControls/TPlaceHolder.php b/framework/Web/UI/WebControls/TPlaceHolder.php index ae878e2b..cdfd3873 100644 --- a/framework/Web/UI/WebControls/TPlaceHolder.php +++ b/framework/Web/UI/WebControls/TPlaceHolder.php @@ -26,4 +26,3 @@ class TPlaceHolder extends TControl { } -?> diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 20973732..fdaf53a8 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -318,4 +318,3 @@ class TRadioButton extends TCheckBox } } -?> diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php index b225834a..a8c53dee 100644 --- a/framework/Web/UI/WebControls/TRadioButtonList.php +++ b/framework/Web/UI/WebControls/TRadioButtonList.php @@ -99,4 +99,3 @@ class TRadioButtonList extends TCheckBoxList } } -?> diff --git a/framework/Web/UI/WebControls/TRangeValidator.php b/framework/Web/UI/WebControls/TRangeValidator.php index 0f92fb45..d741118f 100644 --- a/framework/Web/UI/WebControls/TRangeValidator.php +++ b/framework/Web/UI/WebControls/TRangeValidator.php @@ -358,4 +358,3 @@ class TRangeValidationDataType extends TValidationDataType { const StringLength='StringLength'; } -?> diff --git a/framework/Web/UI/WebControls/TRatingList.php b/framework/Web/UI/WebControls/TRatingList.php index 22cc0844..aba44fb0 100644 --- a/framework/Web/UI/WebControls/TRatingList.php +++ b/framework/Web/UI/WebControls/TRatingList.php @@ -4,7 +4,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -21,191 +21,320 @@ Prado::using('System.Web.UI.WebControls.TRadioButtonList'); * This class is EXPERIMENTAL. * * @author Wei Zhuo + * @author Bradley Booms * @version $Id$ * @package System.Web.UI.WebControls * @since 3.0 */ class TRatingList extends TRadioButtonList { + /** + * Script path relative to the TClientScriptManager::SCRIPT_PATH + */ const SCRIPT_PATH='prado/ratings'; + /** + * @var array list of published rating images. + */ private $_ratingImages = array(); + /** + * Sets the default repeat direction to horizontal. + */ public function __construct() { parent::__construct(); - $this->getRepeatInfo()->setRepeatDirection('Horizontal'); + $this->setRepeatDirection(TRepeatDirection::Horizontal); } + /** + * @return boolean whether the items in the column can be edited. Defaults to false. + */ + public function getReadOnly() + { + return $this->getViewState('ReadOnly',false); + } + + /** + * @param boolean whether the items in the column can be edited + */ + public function setReadOnly($value) + { + $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false); + } + + /** + * Wrapper for {@link setReadOnly ReadOnly} property. + * @return boolean whether the rating list can be edited. Defaults to true. + */ public function getAllowInput() { - return $this->getViewState('AllowInput', true); + return !$this->getReadOnly(); } + /** + * Wrapper for {@link setReadOnly ReadOnly} property. + * @param boolean whether the rating list can be edited + */ public function setAllowInput($value) { - $this->setViewState('AllowInput', TPropertyValue::ensureBoolean($value), true); + $this->setReadOnly(!TPropertyValue::ensureBoolean($value)); } - public function getRating() + /** + * Wrapper for {@link setReadOnly ReadOnly} property. + * @param boolean whether the rating list can be edited + */ + public function setEnabled($value) { - if($this->getAllowInput()) - return $this->getSelectedIndex(); - else - return $this->getViewState('Rating',0); + $this->setReadOnly(!TPropertyValue::ensureBoolean($value)); } - public function setRating($value) + /** + * The repeat layout must be Table. + * @param string repeat layout type + * @throws TInvaliddataValueException when repeat layout is not Table. + */ + public function setRepeatLayout($value) { - if($this->getAllowInput()) - $this->setSelectedIndex($value); + if($value!==TRepeatLayout::Table) + throw new TInvalidDataValueException('ratinglist_table_layout_only'); else - $this->setViewState('Rating', TPropertyValue::ensureFloat($value),0); + parent::setRepeatLayout($value); } /** - * @param string set the rating style + * @return float rating value. */ - public function setRatingStyle($value) + public function getRating() { - $this->setViewState('RatingStyle', $value, 'default'); + $rating = $this->getViewState('Rating', null); + if ($rating === null) + return $this->getSelectedIndex()+1; + else + return $rating; } /** - * @return TRatingListStyle current rating style + * @param float rating value, also sets the selected Index */ - public function getRatingStyle() + public function setRating($value) { - return $this->getViewState('RatingStyle', 'default'); + $value = TPropertyValue::ensureFloat($value); + $this->setViewState('Rating', $value, null); + $index = $this->getRatingIndex($value); + parent::setSelectedIndex($index); + } + + public function setSelectedIndex($value) + { + $this->setRating($value+1); + parent::setSelectedIndex($value); } /** - * @return string caption text. Default is "Rate It:". + * @param float rating value + * @return int rating as integer */ - public function getCaption() + protected function getRatingIndex($rating) { - return $this->getViewState('Caption', 'Rate It:'); + $interval = $this->getHalfRatingInterval(); + $base = intval($rating)-1; + $remainder = $rating-$base-1; + return $remainder > $interval[1] ? $base+1 : $base; } /** - * @param string caption text + * @param int change the rating selection index */ - public function setCaption($value) + public function onSelectedIndexChanged($param) { - $this->setViewState('Caption', $value, 'Rate It:'); + $value = $this->getRating(); + $value = TPropertyValue::ensureInteger($value); + $this->setRating($value); + parent::onSelectedIndexChanged($param); } + /** + * @return string control or html element ID for displaying a caption. + */ + public function getCaptionID() + { + return $this->getViewState('CaptionID', ''); + } - public function setHalfRatingLimit($value) + /** + * @param string control or html element ID for displaying a caption. + */ + public function setCaptionID($value) { - $this->setViewState('HalfRating', - TPropertyValue::ensureArray($value), array(0.3, 0.7)); + $this->setViewState('CaptionID', $value, ''); } - public function getHalfRatingLimit() + protected function getCaptionControl() { - return $this->getViewState('HalfRating', array(0.3, 0.7)); + if(($id=$this->getCaptionID())!=='') + { + if($control=$this->getParent()->findControl($id)) + return $control; + } + throw new TInvalidDataValueException( + 'ratinglist_invalid_caption_id',$id,$this->getID()); } /** - * @param string asset file in the self::SCRIPT_PATH directory. - * @return string asset file url. + * @return string caption text. Default is "Rate It:". */ - protected function getAssetUrl($file='') + public function getCaption() { - $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); - return $base.'/'.self::SCRIPT_PATH.'/'.$file; + return $this->getCaptionControl()->getText(); } - public function getRatingClientOptions() - { - $options['cssClass'] = 'TRatingList_'.$this->getRatingStyle(); - $options['ID'] = $this->getClientID(); - $options['caption'] = $this->getCaption(); - $options['field'] = $this->getUniqueID(); - $options['selectedIndex'] = $this->getSelectedIndex(); + /** + * @return TRatingListStyle current rating style + */ + public function setCaption($value) + { + $this->getCaptionControl()->setText($value); + } + + /** + * @param string set the rating style, default is "default" + */ + public function setRatingStyle($value) + { + $this->setViewState('RatingStyle', $value, 'default'); + } + + /** + * @return TRatingListStyle current rating style + */ + public function getRatingStyle() + { + return $this->getViewState('RatingStyle', 'default'); + } + + /** + * @return string rating style css class name. + */ + protected function getRatingStyleCssClass() + { + return 'TRatingList_'.$this->getRatingStyle(); + } + + /** + * Sets the interval such that those rating values within the interval + * will be considered as a half star rating. + * @param array rating display half value interval, default is array(0.3, 0.7); + */ + public function setHalfRatingInterval($value) + { + $this->setViewState('HalfRating', + TPropertyValue::ensureArray($value), array(0.3, 0.7)); + } + + /** + * @return array rating display half value interval, default is array(0.3, 0.7); + */ + public function getHalfRatingInterval() + { + return $this->getViewState('HalfRating', array(0.3, 0.7)); + } + + /** + * @return array list of post back options. + */ + protected function getPostBackOptions() + { + $options = parent::getPostBackOptions(); + $options['AutoPostBack'] = $this->getAutoPostBack(); + $options['ReadOnly'] = $this->getReadOnly(); + $options['Style'] = $this->getRatingStyleCssClass(); + $options['CaptionID'] = $this->getCaptionControlID(); + $options['SelectedIndex'] = $this->getSelectedIndex(); + $options['Rating'] = $this->getRating(); + $options['HalfRating'] = $this->getHalfRatingInterval(); return $options; - } + } - protected function publishRatingListStyle($style) - { + /** + * @return string find the client ID of the caption control. + */ + protected function getCaptionControlID() + { + if(($id=$this->getCaptionID())!=='') + { + if($control=$this->getParent()->findControl($id)) + { + if($control->getVisible(true)) + return $control->getClientID(); + } + else + return $id; + } + return ''; + } + + /** + * Publish the the rating style css file and rating image files. + */ + public function onPreRender($param) + { + parent::onPreRender($param); + $this->publishStyle($this->getRatingStyle()); + $this->_ratingImages = $this->publishImages($this->getRatingStyle()); + } + + /** + * @param string rating style name + * @return string URL of the css style file + */ + protected function publishStyle($style) + { $cs = $this->getPage()->getClientScript(); $url = $this->getAssetUrl($style.'.css'); if(!$cs->isStyleSheetFileRegistered($url)) $cs->registerStyleSheetFile($url, $url); return $url; - } + } - protected function publishRatingListImages($style, $fileExt='.gif') - { - $images = array('blank', 'hover', 'selected', 'half'); + /** + * @param string rating style name + * @param string rating image file extension, default is '.gif' + * @return array URL of publish the rating images + */ + protected function publishImages($style, $fileExt='.gif') + { + $types = array('blank', 'selected', 'half', 'combined'); $files = array(); - foreach($images as $type) + foreach($types as $type) $files[$type] = $this->getAssetUrl("{$style}_{$type}{$fileExt}"); return $files; - } + } /** - * @param THtmlWriter writer + * @param string asset file in the self::SCRIPT_PATH directory. + * @return string asset file url. */ - public function onPreRender($param) - { - parent::onPreRender($param); - - $this->publishRatingListStyle($this->getRatingStyle()); - $this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle()); - - if($this->getAllowInput()) - $this->registerRatingListClientScript(); - else - { - $this->getRepeatInfo()->setCaption($this->getCaption()); - $this->setAttribute('title', $this->getRating()); - } - } - - protected function registerRatingListClientScript() - { - $id = $this->getClientID(); - $scripts = $this->getPage()->getClientScript(); - $scripts->registerPradoScript('prado'); - $options = TJavaScript::encode($this->getRatingClientOptions()); - $code = "new Prado.WebUI.TRatingList($options);"; - $scripts->registerEndScript("prado:$id", $code); - } - - public function renderItem($writer,$repeatInfo,$itemType,$index) - { - if($this->getAllowInput()) - parent::renderItem($writer, $repeatInfo, $itemType, $index); - else - $this->renderRatingListItem($writer, $repeatInfo, $itemType, $index); - } - - protected function renderRatingListItem($writer, $repeatInfo, $itemType, $index) - { - $image = new TImage; - $image->setImageUrl($this->_ratingImages[$this->getRatingImageType($index)]); - $image->setAlternateText($this->getRating()); - $image->render($writer); - } - - protected function getRatingImageType($index) - { - $rating = floatval($this->getRating()); - $int = intval($rating); - $limit = $this->getHalfRatingLimit(); - if($index < $int || ($rating < $index + 1 && $rating > $index +$limit[1])) - return 'selected'; - if($rating >= $index+$limit[0] && $rating <= $index+$limit[1]) - return 'half'; - return 'blank'; - } + protected function getAssetUrl($file='') + { + $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); + return $base.'/'.self::SCRIPT_PATH.'/'.$file; + } - public function generateItemStyle($itemType,$index) - { - return new TStyle; - } + /** + * Add rating style class name to the class attribute + * when {@link setReadOnly ReadOnly} property is true and when the + * {@link setCssClass CssClass} property is empty. + * @param THtmlWriter renderer + */ + public function render($writer) + { + $writer->addAttribute('id',$this->getClientID()); + $this->getPage()->getClientScript()->registerPostBackControl( + $this->getClientClassName(), $this->getPostBackOptions()); + parent::render($writer); + } /** * Gets the name of the javascript class responsible for performing postback for this control. @@ -218,4 +347,3 @@ class TRatingList extends TRadioButtonList } } -?> diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index f0c645a4..be861e45 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -96,7 +96,7 @@ class TRegularExpressionValidator extends TBaseValidator } /** - * @param string pattern modifiers, + * @param string pattern modifiers for server side validation, * see http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php */ public function setPatternModifiers($value) @@ -112,6 +112,23 @@ class TRegularExpressionValidator extends TBaseValidator return $this->getViewState('PatternModifiers', ''); } + /** + * @param string pattern modifiers for clientside. + * (Only 'g','i' and 'm' are available.) + */ + public function setClientSidePatternModifiers($value) + { + $this->setViewState('ClientSidePatternModifiers', $value); + } + + /** + * @return string clientside pattern modifiers, no modifiers by default. + */ + public function getClientSidePatternModifiers() + { + return $this->getViewState('ClientSidePatternModifiers', ''); + } + /** * Returns an array of javascript validator options. * @return array javascript validator options. @@ -120,8 +137,8 @@ class TRegularExpressionValidator extends TBaseValidator { $options = parent::getClientScriptOptions(); $options['ValidationExpression']=$this->getRegularExpression(); + $options['PatternModifiers']=$this->getClientSidePatternModifiers(); return $options; } } -?> diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php index ecf0ebf7..30c85f14 100644 --- a/framework/Web/UI/WebControls/TRepeatInfo.php +++ b/framework/Web/UI/WebControls/TRepeatInfo.php @@ -558,4 +558,3 @@ class TRepeatLayout extends TEnumerable const Raw='Raw'; } -?> diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php index 6b9c08c1..a6c9903d 100644 --- a/framework/Web/UI/WebControls/TRepeater.php +++ b/framework/Web/UI/WebControls/TRepeater.php @@ -1023,4 +1023,3 @@ class TRepeaterItemCollection extends TList } } -?> diff --git a/framework/Web/UI/WebControls/TRepeaterItemRenderer.php b/framework/Web/UI/WebControls/TRepeaterItemRenderer.php index d99da302..79ff9087 100644 --- a/framework/Web/UI/WebControls/TRepeaterItemRenderer.php +++ b/framework/Web/UI/WebControls/TRepeaterItemRenderer.php @@ -48,4 +48,3 @@ class TRepeaterItemRenderer extends TItemDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php index 8d0eaec2..e6ddd6d3 100644 --- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php +++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php @@ -136,4 +136,3 @@ class TRequiredFieldValidator extends TBaseValidator } } -?> diff --git a/framework/Web/UI/WebControls/TSafeHtml.php b/framework/Web/UI/WebControls/TSafeHtml.php index 0f4de2cb..d6829f8b 100644 --- a/framework/Web/UI/WebControls/TSafeHtml.php +++ b/framework/Web/UI/WebControls/TSafeHtml.php @@ -62,4 +62,3 @@ class TSafeHtml extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TSlider.php b/framework/Web/UI/WebControls/TSlider.php index 3fd8e244..ee725e99 100644 --- a/framework/Web/UI/WebControls/TSlider.php +++ b/framework/Web/UI/WebControls/TSlider.php @@ -4,7 +4,7 @@ * * @author Christophe Boulain * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -218,7 +218,7 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer public function setValues($value) { $this->setViewState('Values', TPropertyValue::ensureArray($value), array()); - } + } /** * @return boolean a value indicating whether an automatic postback to the server @@ -488,7 +488,7 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer // Add max if it's not in the array because of step if (!in_array($maxValue, $values)) $values[]=$maxValue; } - $options['values'] = TJavascript::Encode($values,false); + $options['values'] = TJavaScript::Encode($values,false); if($this->_clientScript!==null) $options = array_merge($options,$this->_clientScript->getOptions()->toArray()); return $options; @@ -572,4 +572,3 @@ class TSliderDirection extends TEnumerable } -?> diff --git a/framework/Web/UI/WebControls/TStatements.php b/framework/Web/UI/WebControls/TStatements.php index 09c03cb9..d07e68a1 100644 --- a/framework/Web/UI/WebControls/TStatements.php +++ b/framework/Web/UI/WebControls/TStatements.php @@ -61,4 +61,3 @@ class TStatements extends TControl } } -?> diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index c81a6db9..7cb1d8c8 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -891,4 +891,3 @@ class TTableGridLines extends TEnumerable const Both='Both'; } -?> diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index 9fa9130d..57efa7f7 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -408,4 +408,3 @@ class TTableCaptionAlign extends TEnumerable const Right='Right'; } -?> diff --git a/framework/Web/UI/WebControls/TTableCell.php b/framework/Web/UI/WebControls/TTableCell.php index 10d4f457..8bc83c52 100644 --- a/framework/Web/UI/WebControls/TTableCell.php +++ b/framework/Web/UI/WebControls/TTableCell.php @@ -220,4 +220,3 @@ class TTableCell extends TWebControl implements IDataRenderer } } -?> diff --git a/framework/Web/UI/WebControls/TTableFooterRow.php b/framework/Web/UI/WebControls/TTableFooterRow.php index f3c35dc3..dd0de143 100644 --- a/framework/Web/UI/WebControls/TTableFooterRow.php +++ b/framework/Web/UI/WebControls/TTableFooterRow.php @@ -45,4 +45,3 @@ class TTableFooterRow extends TTableRow } } -?> diff --git a/framework/Web/UI/WebControls/TTableHeaderCell.php b/framework/Web/UI/WebControls/TTableHeaderCell.php index a1a8919a..1e18cee3 100644 --- a/framework/Web/UI/WebControls/TTableHeaderCell.php +++ b/framework/Web/UI/WebControls/TTableHeaderCell.php @@ -122,4 +122,3 @@ class TTableHeaderScope extends TEnumerable const Column='Column'; } -?> diff --git a/framework/Web/UI/WebControls/TTableHeaderRow.php b/framework/Web/UI/WebControls/TTableHeaderRow.php index fa7e4515..7b8488bd 100644 --- a/framework/Web/UI/WebControls/TTableHeaderRow.php +++ b/framework/Web/UI/WebControls/TTableHeaderRow.php @@ -45,4 +45,3 @@ class TTableHeaderRow extends TTableRow } } -?> diff --git a/framework/Web/UI/WebControls/TTableRow.php b/framework/Web/UI/WebControls/TTableRow.php index be93529e..c70f28dd 100644 --- a/framework/Web/UI/WebControls/TTableRow.php +++ b/framework/Web/UI/WebControls/TTableRow.php @@ -206,4 +206,3 @@ class TTableRowSection extends TEnumerable const Footer='Footer'; } -?> diff --git a/framework/Web/UI/WebControls/TTemplateColumn.php b/framework/Web/UI/WebControls/TTemplateColumn.php index de4bc2ef..21190f23 100644 --- a/framework/Web/UI/WebControls/TTemplateColumn.php +++ b/framework/Web/UI/WebControls/TTemplateColumn.php @@ -254,4 +254,3 @@ class TTemplateColumn extends TDataGridColumn } } -?> diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index 3c3e6d0e..4e6a66e9 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -67,6 +67,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable */ private $_safeText; private $_dataChanged=false; + private $_isValid=true; /** * @return string tag name of the textbox @@ -243,6 +244,23 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable return $this->getText(); } + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /** * Raises OnTextChanged event. * This method is invoked when the value of the {@link getText Text} @@ -618,4 +636,3 @@ class TTextBoxAutoCompleteType extends TEnumerable const Search='Search'; } -?> diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php index 0356c4e7..890deb05 100644 --- a/framework/Web/UI/WebControls/TTextHighlighter.php +++ b/framework/Web/UI/WebControls/TTextHighlighter.php @@ -198,4 +198,3 @@ class TTextHighlighterLineNumberStyle extends TEnumerable const Li='Li'; const Table='Table'; } -?> diff --git a/framework/Web/UI/WebControls/TTextProcessor.php b/framework/Web/UI/WebControls/TTextProcessor.php index ccb78196..26dab754 100644 --- a/framework/Web/UI/WebControls/TTextProcessor.php +++ b/framework/Web/UI/WebControls/TTextProcessor.php @@ -84,4 +84,3 @@ abstract class TTextProcessor extends TWebControl } } -?> diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index 4e0e0e50..95679e15 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -504,4 +504,3 @@ class TValidationSummaryDisplayStyle extends TEnumerable const Fixed='Fixed'; } -?> diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index 829a9d03..2e1899ad 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -432,4 +432,3 @@ class TWebControl extends TControl implements IStyleable } } -?> diff --git a/framework/Web/UI/WebControls/TWebControlAdapter.php b/framework/Web/UI/WebControls/TWebControlAdapter.php index 35e157af..a99afe7f 100644 --- a/framework/Web/UI/WebControls/TWebControlAdapter.php +++ b/framework/Web/UI/WebControls/TWebControlAdapter.php @@ -69,4 +69,3 @@ class TWebControlAdapter extends TControlAdapter } } -?> diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php index 1f9e886b..774096f7 100644 --- a/framework/Web/UI/WebControls/TWizard.php +++ b/framework/Web/UI/WebControls/TWizard.php @@ -2153,4 +2153,3 @@ class TWizardStepType extends TEnumerable const Finish='Finish'; } -?> diff --git a/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php b/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php index 6eebce74..54d585c4 100644 --- a/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php +++ b/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php @@ -153,4 +153,3 @@ class TWizardNavigationButtonStyle extends TStyle } } -?> diff --git a/framework/Web/UI/WebControls/TXmlTransform.php b/framework/Web/UI/WebControls/TXmlTransform.php index ab49ae61..991aed39 100644 --- a/framework/Web/UI/WebControls/TXmlTransform.php +++ b/framework/Web/UI/WebControls/TXmlTransform.php @@ -191,4 +191,3 @@ class TXmlTransform extends TControl { } } -?> diff --git a/framework/Web/UI/WebControls/assets/captcha.php b/framework/Web/UI/WebControls/assets/captcha.php index bff2f61a..8c9ff0a3 100644 --- a/framework/Web/UI/WebControls/assets/captcha.php +++ b/framework/Web/UI/WebControls/assets/captcha.php @@ -221,4 +221,3 @@ function morphImage($image,$width,$height) } } -?> -- cgit v1.2.3