From e392ecbf6e422825083bc7204eacb7090619a47c Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 21 Apr 2006 12:36:06 +0000 Subject: Merge from 3.0 branch till 953. --- framework/Web/UI/TThemeManager.php | 1 - framework/Web/UI/WebControls/TBaseValidator.php | 26 ++++--- framework/Web/UI/WebControls/TButton.php | 1 + framework/Web/UI/WebControls/TButtonColumn.php | 89 ++++++++++++++++++---- framework/Web/UI/WebControls/TCompareValidator.php | 13 ++-- framework/Web/UI/WebControls/TCustomValidator.php | 2 +- framework/Web/UI/WebControls/THtmlArea.php | 14 ++-- framework/Web/UI/WebControls/TRangeValidator.php | 8 +- .../UI/WebControls/TRegularExpressionValidator.php | 2 +- .../Web/UI/WebControls/TRequiredFieldValidator.php | 2 +- .../Web/UI/WebControls/TValidationSummary.php | 20 ++--- 11 files changed, 126 insertions(+), 52 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index 23189cae..83032684 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -107,7 +107,6 @@ class TThemeManager extends TModule $this->_basePath=Prado::getPathOfAlias($value); if($this->_basePath===null || !is_dir($this->_basePath)) throw new TInvalidDataValueException('thememanager_basepath_invalid',$value); - $this->_basePath=$value; } } diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 03362110..c5b5e7a5 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -131,14 +131,18 @@ abstract class TBaseValidator extends TLabel implements IValidator */ protected function getClientScriptOptions() { - $options['id'] = $this->getClientID(); - $options['display'] = $this->getDisplay(); - $options['errormessage'] = $this->getErrorMessage(); - $options['focusonerror'] = $this->getFocusOnError(); - $options['focuselementid'] = $this->getFocusElementID(); - $options['validationgroup'] = $this->getValidationGroup(); - $options['controltovalidate'] = $this->getValidationTarget()->getClientID(); - $options['controlcssclass'] = $this->getControlCssClass(); + $options['ID'] = $this->getClientID(); + $options['FormID'] = $this->getPage()->getForm()->getClientID(); + $options['Display'] = $this->getDisplay(); + $options['ErrorMessage'] = $this->getErrorMessage(); + if($this->getFocusOnError()) + { + $options['FocusOnError'] = $this->getFocusOnError(); + $options['FocusElementID'] = $this->getFocusElementID(); + } + $options['ValidationGroup'] = $this->getValidationGroup(); + $options['ControlToValidate'] = $this->getValidationTarget()->getClientID(); + $options['ControlCssClass'] = $this->getControlCssClass(); return $options; } @@ -156,8 +160,10 @@ abstract class TBaseValidator extends TLabel implements IValidator $scriptKey = "TBaseValidator:$formID"; if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) { + $manager['FormID'] = $formID; + $options = TJavaScript::encode($manager); $scripts->registerPradoScript('validator'); - $scripts->registerEndScript($scriptKey, "Prado.Validation.AddForm('$formID');"); + $scripts->registerEndScript($scriptKey, "new Prado.Validation({$options});"); } if($this->getEnableClientScript()) $this->registerClientScriptValidator(); @@ -195,7 +201,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $scriptKey = "prado:".$this->getClientID(); $scripts = $this->getPage()->getClientScript(); $options = TJavaScript::encode($this->getClientScriptOptions()); - $js = "new Prado.Validation(Prado.Validation.{$class}, {$options});"; + $js = "new Prado.WebUI.{$class}({$options});"; $scripts->registerEndScript($scriptKey, $js); } } diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index 72c68a2c..b9872a64 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -109,6 +109,7 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr { $options['ID']=$this->getClientID(); $options['CausesValidation']=$this->getCausesValidation(); + $options['EventTarget'] = $this->getUniqueID(); $options['ValidationGroup']=$this->getValidationGroup(); return $options; diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php index 12b38171..20844f14 100644 --- a/framework/Web/UI/WebControls/TButtonColumn.php +++ b/framework/Web/UI/WebControls/TButtonColumn.php @@ -14,6 +14,9 @@ * TDataGridColumn class file */ Prado::using('System.Web.UI.WebControls.TDataGridColumn'); +Prado::using('System.Web.UI.WebControls.TButton'); +Prado::using('System.Web.UI.WebControls.TLinkButton'); +Prado::using('System.Web.UI.WebControls.TImageButton'); /** * TButtonColumn class @@ -92,6 +95,54 @@ class TButtonColumn extends TDataGridColumn $this->setViewState('DataTextFormatString',$value,''); } + /** + * @return string the URL of the image file for image buttons + */ + public function getImageUrl() + { + return $this->getViewState('ImageUrl',''); + } + + /** + * @param string the URL of the image file for image buttons + */ + public function setImageUrl($value) + { + $this->setViewState('ImageUrl',$value,''); + } + + /** + * @return string the field name from the data source to bind to the button image url + */ + public function getDataImageUrlField() + { + return $this->getViewState('DataImageUrlField',''); + } + + /** + * @param string the field name from the data source to bind to the button image url + */ + public function setDataImageUrlField($value) + { + $this->setViewState('DataImageUrlField',$value,''); + } + + /** + * @return string the formatting string used to control how the button image url will be displayed. + */ + public function getDataImageUrlFormatString() + { + return $this->getViewState('DataImageUrlFormatString',''); + } + + /** + * @param string the formatting string used to control how the button image url will be displayed. + */ + public function setDataImageUrlFormatString($value) + { + $this->setViewState('DataImageUrlFormatString',$value,''); + } + /** * @return string the type of command button. Defaults to LinkButton. */ @@ -101,11 +152,11 @@ class TButtonColumn extends TDataGridColumn } /** - * @param string the type of command button, LinkButton or PushButton + * @param string the type of command button, LinkButton, PushButton or ImageButton */ public function setButtonType($value) { - $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'LinkButton','PushButton'),'LinkButton'); + $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'LinkButton','PushButton','ImageButton'),'LinkButton'); } /** @@ -170,15 +221,21 @@ class TButtonColumn extends TDataGridColumn parent::initializeCell($cell,$columnIndex,$itemType); if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM || $itemType===TDataGrid::IT_EDITITEM) { - if($this->getButtonType()==='LinkButton') - $button=Prado::createComponent('System.Web.UI.WebControls.TLinkButton'); - else - $button=Prado::createComponent('System.Web.UI.WebControls.TButton'); + $buttonType=$this->getButtonType(); + if($buttonType==='LinkButton') + $button=new TLinkButton; + else if($buttonType==='PushButton') + $button=new TButton; + else // image button + { + $button=new TImageButton; + $button->setImageUrl($this->getImageUrl()); + } $button->setText($this->getText()); $button->setCommandName($this->getCommandName()); $button->setCausesValidation($this->getCausesValidation()); $button->setValidationGroup($this->getValidationGroup()); - if($this->getDataTextField()!=='') + if($this->getDataTextField()!=='' || ($buttonType==='ImageButton' && $this->getDataImageUrlField()!=='')) $button->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); $cell->getControls()->add($button); } @@ -191,14 +248,20 @@ class TButtonColumn extends TDataGridColumn */ public function dataBindColumn($sender,$param) { - if(($field=$this->getDataTextField())!=='') + if($sender instanceof IButtonControl) { - $item=$sender->getNamingContainer(); - $data=$item->getDataItem(); - $value=$this->getDataFieldValue($data,$field); - $text=$this->formatDataValue($this->getDataTextFormatString(),$value); - if(($sender instanceof TLinkButton) || ($sender instanceof TButton)) + if(($field=$this->getDataTextField())!=='') + { + $value=$this->getDataFieldValue($sender->getNamingContainer()->getDataItem(),$field); + $text=$this->formatDataValue($this->getDataTextFormatString(),$value); $sender->setText($text); + } + if(($sender instanceof TImageButton) && ($field=$this->getDataImageUrlField())!=='') + { + $value=$this->getDataFieldValue($sender->getNamingContainer()->getDataItem(),$field); + $url=$this->formatDataValue($this->getDataImageUrlFormatString(),$value); + $sender->setImageUrl($url); + } } } } diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index 1bf4c529..172e472f 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -32,7 +32,8 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * - Integer A 32-bit signed integer data type. * - Float A double-precision floating point number data type. * - Currency A decimal data type that can contain currency symbols. - * - Date A date data type. The format follows the GNU date syntax. + * - Date A date data type. The format can be specified by the + * {@link setDateFormat DateFormat} property * - String A string data type. * * Use the {@link setOperator Operator} property to specify the type of comparison @@ -220,15 +221,15 @@ class TCompareValidator extends TBaseValidator if(($name=$this->getControlToCompare())!=='') { if(($control=$this->findControl($name))!==null) - $options['controltocompare']=$options['controlhookup']=$control->getClientID(); + $options['ControlToCompare']=$control->getClientID(); } if(($value=$this->getValueToCompare())!=='') - $options['valuetocompare']=$value; + $options['ValueToCompare']=$value; if(($operator=$this->getOperator())!=='Equal') - $options['operator']=$operator; - $options['type']=$this->getDataType(); + $options['Operator']=$operator; + $options['DataType']=$this->getDataType(); if(($dateFormat=$this->getDateFormat())!=='') - $options['dateformat']=$dateFormat; + $options['DateFormat']=$dateFormat; return $options; } } diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index b72ec344..27cfa67a 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -107,7 +107,7 @@ class TCustomValidator extends TBaseValidator { $options=parent::getClientScriptOptions(); if(($clientJs=$this->getClientValidationFunction())!=='') - $options['clientvalidationfunction']=$clientJs; + $options['ClientValidationFunction']=$clientJs; return $options; } } diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index 038c7368..7e47d638 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -33,7 +33,7 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); * under the situation. * * The default editor gives only the basic tool bar. To change or add - * additional tool bars, use the Options property to add additional + * additional tool bars, use the {@link setOptions Options} property to add additional * editor options with each options on a new line. * See http://tinymce.moxiecode.com/tinymce/docs/index.html * for a list of options. The options can be change/added as shown in the @@ -79,7 +79,7 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); class THtmlArea extends TTextBox { // Qiang: need to clean up the following (too inefficient) - private $langs = array( + private static $_langs = array( 'da' => array('da'), 'fa' => array('fa'), 'hu' => array('hu'), @@ -307,17 +307,21 @@ class THtmlArea extends TTextBox { $app = $this->getApplication()->getGlobalization(); if(empty($culture) && !is_null($app)) - $culture = $app->getCulture(); + $culture = $app->getCulture(); $variants = array(); if(!is_null($app)) $variants = $app->getCultureVariants($culture); //default the variant to "en" if(count($variants) == 0) - $variants[] = empty($culture) ? 'en' : strtolower($culture); + { + if($empty($culture)) + return 'en'; + $variants[] = strtolower($culture); + } // TODO: triple loops??? - foreach($this->langs as $js => $langs) + foreach(self::$_langs as $js => $langs) { foreach($variants as $variant) { diff --git a/framework/Web/UI/WebControls/TRangeValidator.php b/framework/Web/UI/WebControls/TRangeValidator.php index 7ded3e71..56cc16bc 100644 --- a/framework/Web/UI/WebControls/TRangeValidator.php +++ b/framework/Web/UI/WebControls/TRangeValidator.php @@ -271,11 +271,11 @@ class TRangeValidator extends TBaseValidator protected function getClientScriptOptions() { $options=parent::getClientScriptOptions(); - $options['minimumvalue']=$this->getMinValue(); - $options['maximumvalue']=$this->getMaxValue(); - $options['type']=$this->getDataType(); + $options['MinValue']=$this->getMinValue(); + $options['MaxValue']=$this->getMaxValue(); + $options['DataType']=$this->getDataType(); if(($dateFormat=$this->getDateFormat())!=='') - $options['dateformat']=$dateFormat; + $options['DateFormat']=$dateFormat; return $options; } } diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index 4271c820..e73fd5be 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -89,7 +89,7 @@ class TRegularExpressionValidator extends TBaseValidator protected function getClientScriptOptions() { $options = parent::getClientScriptOptions(); - $options['validationexpression']=$this->getRegularExpression(); + $options['ValidationExpression']=$this->getRegularExpression(); return $options; } } diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php index 702fc5d2..ddbb12c8 100644 --- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php +++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php @@ -68,7 +68,7 @@ class TRequiredFieldValidator extends TBaseValidator protected function getClientScriptOptions() { $options = parent::getClientScriptOptions(); - $options['initialvalue']=$this->getInitialValue(); + $options['InitialValue']=$this->getInitialValue(); return $options; } } diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index 437e10d6..2bc3f62c 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -219,7 +219,7 @@ class TValidationSummary extends TWebControl if(!$this->getEnabled(true) || !$this->getEnableClientScript()) return; $options=TJavaScript::encode($this->getClientScriptOptions()); - $script = "new Prado.Validation.Summary({$options});"; + $script = "new Prado.WebUI.TValidationSummary({$options});"; $this->getPage()->getClientScript()->registerEndScript($this->getClientID(), $script); } @@ -229,19 +229,19 @@ class TValidationSummary extends TWebControl */ protected function getClientScriptOptions() { - $options['id'] = $this->ClientID; - $options['form'] = $this->Page->Form->ClientID; + $options['ID'] = $this->getClientID(); + $options['FormID'] = $this->getPage()->getForm()->getClientID(); if($this->getShowMessageBox()) - $options['showmessagebox']='True'; + $options['ShowMessageBox']=true; if(!$this->getShowSummary()) - $options['showsummary']='False'; + $options['ShowSummary']=false; - $options['headertext']=$this->getHeaderText(); - $options['displaymode']=$this->getDisplayMode(); + $options['HeaderText']=$this->getHeaderText(); + $options['DisplayMode']=$this->getDisplayMode(); - $options['refresh'] = $this->getAutoUpdate(); - $options['validationgroup'] = $this->getValidationGroup(); - $options['display'] = $this->getDisplay(); + $options['Refresh'] = $this->getAutoUpdate(); + $options['ValidationGroup'] = $this->getValidationGroup(); + $options['Display'] = $this->getDisplay(); return $options; } -- cgit v1.2.3