diff options
author | xue <> | 2006-08-05 21:34:30 +0000 |
---|---|---|
committer | xue <> | 2006-08-05 21:34:30 +0000 |
commit | b7f95ce37ae577e95a81e64aa2aaf3e2e698109d (patch) | |
tree | 85c6b9961ebbd4c9283fbd9b841703f9e4c47307 /framework/Web | |
parent | 550ba06593b467b643862d41a00ca2dd12ee704b (diff) |
merge from 3.0 branch till 1329.
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/js/validator.js | 9 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/validation3.js | 14 | ||||
-rw-r--r-- | framework/Web/TAssetManager.php | 3 | ||||
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 34 | ||||
-rw-r--r-- | framework/Web/UI/TPage.php | 21 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TBaseValidator.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDataGrid.php | 1 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDataList.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDataTypeValidator.php | 3 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 3 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TOutputCache.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TPanelStyle.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TStyle.php | 33 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TStyleSheet.php | 18 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TWizard.php | 10 |
15 files changed, 130 insertions, 29 deletions
diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js index 5e896aa1..711c996e 100644 --- a/framework/Web/Javascripts/js/validator.js +++ b/framework/Web/Javascripts/js/validator.js @@ -97,7 +97,8 @@ control.addClassName(CssClass);}},hide:function() {this.isValid=true;this.updateControl();this.visible=false;},validate:function(invoker) {if(typeof(this.options.OnValidate)=="function") this.options.OnValidate(this,invoker);if(this.enabled) -this.isValid=this.evaluateIsValid();if(this.isValid) +this.isValid=this.evaluateIsValid();else +this.isValid=true;if(this.isValid) {if(typeof(this.options.OnSuccess)=="function") {this.visible=true;this.message.style.visibility="visible";this.updateControlCssClass(this.control,this.isValid);this.options.OnSuccess(this,invoker);} else @@ -126,7 +127,11 @@ return value;},getValidationValue:function(control) control=this.control switch(this.options.ControlType) {case'TDatePicker':if(control.type=="text") -return this.trim($F(control));else +{value=this.trim($F(control));if(this.options.DateFormat) +{date=value.toDate(this.options.DateFormat);return date==null?'':date;} +else +return value;} +else {this.observeDatePickerChanges();return Prado.WebUI.TDatePicker.getDropDownDate(control).getTime();} case'THtmlArea':if(typeof tinyMCE!="undefined") tinyMCE.triggerSave();return this.trim($F(control));case'TRadioButton':if(this.options.GroupName) diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 1dba23da..7df6efeb 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -661,6 +661,8 @@ Prado.WebUI.TBaseValidator.prototype = if(this.enabled)
this.isValid = this.evaluateIsValid();
+ else
+ this.isValid = true;
if(this.isValid)
{
@@ -776,7 +778,17 @@ Prado.WebUI.TBaseValidator.prototype = {
case 'TDatePicker':
if(control.type == "text")
- return this.trim($F(control));
+ {
+ value = this.trim($F(control));
+
+ if(this.options.DateFormat)
+ {
+ date = value.toDate(this.options.DateFormat);
+ return date == null ? '' : date;
+ }
+ else
+ return value;
+ }
else
{
this.observeDatePickerChanges();
diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index f9fe156f..f6384a08 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -199,7 +199,10 @@ class TAssetManager extends TModule protected function copyFile($src,$dst)
{
if(!is_dir($dst))
+ {
@mkdir($dst);
+ @chmod($dst, 0777);
+ }
$dstFile=$dst.'/'.basename($src);
if(@filemtime($dstFile)<@filemtime($src))
{
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 540ea01e..d1f3f457 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -145,7 +145,7 @@ class TClientScriptManager extends TApplicationComponent } } - /** + /** * Renders the <script> tag that will load the javascript library files. * @param THtmlWriter writer that renders the <script> tag. */ @@ -163,7 +163,7 @@ class TClientScriptManager extends TApplicationComponent } } - /** + /** * Returns javascript statement that create a new callback request object. * @param ICallbackEventHandler callback response handler * @param array additional callback options @@ -244,8 +244,11 @@ class TClientScriptManager extends TApplicationComponent */ public function registerFocusControl($target) { - $this->registerPradoScriptInternal('prado'); - $this->_endScripts['prado:focus']='Prado.Focus.setFocus("'.TJavaScript::quoteString($target).'");'; + $this->registerPradoScriptInternal('effects'); + if($target instanceof TControl) + $target=$target->getClientID(); + $id = TJavaScript::quoteString($target); + $this->_endScripts['prado:focus'] = 'new Effect.ScrollTo("'.$id.'"); Prado.Element.focus("'.$id.'");'; $params=func_get_args(); $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); @@ -268,10 +271,14 @@ class TClientScriptManager extends TApplicationComponent * Registers a CSS file to be rendered in the page head * @param string a unique key identifying the file * @param string URL to the CSS file + * @param string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. */ - public function registerStyleSheetFile($key,$url) + public function registerStyleSheetFile($key,$url,$media='') { - $this->_styleSheetFiles[$key]=$url; + if($media==='') + $this->_styleSheetFiles[$key]=$url; + else + $this->_styleSheetFiles[$key]=array($url,$media); $params=func_get_args(); $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); @@ -282,7 +289,7 @@ class TClientScriptManager extends TApplicationComponent * @param string a unique key identifying the CSS block * @param string CSS block */ - public function registerStyleSheet($key,$css) + public function registerStyleSheet($key,$css,$media='') { $this->_styleSheets[$key]=$css; @@ -431,7 +438,7 @@ class TClientScriptManager extends TApplicationComponent { return isset($this->_endScripts[$key]); } - + /** * @return boolean true if any end scripts are registered. */ @@ -439,7 +446,7 @@ class TClientScriptManager extends TApplicationComponent { return count($this->_endScripts) > 0; } - + /** * @return boolean true if any begin scripts are registered. */ @@ -464,7 +471,12 @@ class TClientScriptManager extends TApplicationComponent { $str=''; foreach($this->_styleSheetFiles as $url) - $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; + { + if(is_array($url)) + $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; + else + $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; + } $writer->write($str); } @@ -620,4 +632,4 @@ abstract class TClientSideOptions extends TComponent } } -?>
\ No newline at end of file +?> diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 22aee89f..60586fab 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -637,20 +637,37 @@ class TPage extends TTemplateControl if($this->_theme instanceof ITheme)
{
foreach($this->_theme->getStyleSheetFiles() as $url)
- $cs->registerStyleSheetFile($url,$url);
+ $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
foreach($this->_theme->getJavaScriptFiles() as $url)
$cs->registerHeadScriptFile($url,$url);
}
if($this->_styleSheet instanceof ITheme)
{
foreach($this->_styleSheet->getStyleSheetFiles() as $url)
- $cs->registerStyleSheetFile($url,$url);
+ $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
foreach($this->_styleSheet->getJavaScriptFiles() as $url)
$cs->registerHeadScriptFile($url,$url);
}
}
/**
+ * Determines the media type of the CSS file.
+ * The media type is determined according to the following file name pattern:
+ * xxx.media-type.extension
+ * For example, 'mystyle.print.css' means its media type is 'print'.
+ * @param string CSS URL
+ * @return string media type of the CSS file
+ */
+ private function getCssMediaType($url)
+ {
+ $segs=explode('.',basename($url));
+ if(isset($segs[2]))
+ return $segs[count($segs)-2];
+ else
+ return '';
+ }
+
+ /**
* Raises OnSaveStateComplete event.
* This method is invoked right after {@link onSaveState OnSaveState} stage.
* You may override this method to provide additional logic after page state is saved.
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 6660184e..ff026b49 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -167,6 +167,10 @@ abstract class TBaseValidator extends TLabel implements IValidator $options['ControlCssClass'] = $this->getControlCssClass(); $options['ControlType'] = $this->getClientControlClass($control); + + //get date format from date picker target control + if($control instanceof TDatePicker) + $options['DateFormat'] = $control->getDateFormat(); if(!is_null($this->_clientSide)) $options = array_merge($options,$this->_clientSide->getOptions()->toArray()); diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index 2687ac35..e27f6ead 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -278,6 +278,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer $style=new TTableStyle;
$style->setGridLines('Both');
$style->setCellSpacing(0);
+ $style->setBorderCollapse(true);
return $style;
}
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php index 42c47f86..22bec07e 100644 --- a/framework/Web/UI/WebControls/TDataList.php +++ b/framework/Web/UI/WebControls/TDataList.php @@ -1357,7 +1357,7 @@ class TDataListItem extends TWebControl implements INamingContainer /**
* Creates a style object for the control.
- * This method creates a {@link TTableStyle} to be used by checkbox list.
+ * This method creates a {@link TTableItemStyle} to be used by a datalist item.
* @return TStyle control style to be used
*/
protected function createStyle()
diff --git a/framework/Web/UI/WebControls/TDataTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php index bd7569fc..3e91ec15 100644 --- a/framework/Web/UI/WebControls/TDataTypeValidator.php +++ b/framework/Web/UI/WebControls/TDataTypeValidator.php @@ -89,6 +89,9 @@ class TDataTypeValidator extends TBaseValidator */
protected function evaluateDataTypeCheck($value)
{
+ if($value=='')
+ return true;
+
switch($this->getDataType())
{
case 'Integer':
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 42cb305e..001c7c46 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -296,7 +296,8 @@ class TDatePicker extends TTextBox {
if($this->getText() === '')
return '';
- return $this->getTimeStamp();
+ $date = $this->getTimeStamp();
+ return $date == null ? '' : $date;
}
/**
diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php index 20c04f7c..ff07a6db 100644 --- a/framework/Web/UI/WebControls/TOutputCache.php +++ b/framework/Web/UI/WebControls/TOutputCache.php @@ -37,7 +37,7 @@ * to respond to the {@link onCheckDependency OnCheckDependency} event and set
* the event parameter's {@link TOutputCacheCheckDependencyEventParameter::getIsValid IsValid}
* property to indicate whether the cached data remains valid or not.
- * One can also extend TOutputCache and override its {@link getCacheDependency CacheDependency}
+ * One can also extend TOutputCache and override its {@link getCacheDependency}
* function. While the former is easier to use, the latter offers more extensibility.
*
* The content fetched from cache may be variated with respect to
diff --git a/framework/Web/UI/WebControls/TPanelStyle.php b/framework/Web/UI/WebControls/TPanelStyle.php index 02f366b8..dc20806e 100644 --- a/framework/Web/UI/WebControls/TPanelStyle.php +++ b/framework/Web/UI/WebControls/TPanelStyle.php @@ -171,7 +171,7 @@ class TPanelStyle extends TStyle /**
* Sets the style attributes to default values.
* This method overrides the parent implementation by
- * resetting additional TTableStyle specific attributes.
+ * resetting additional TPanelStyle specific attributes.
*/
public function reset()
{
diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index 597229ea..d4cb6154 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -403,6 +403,10 @@ class TTableStyle extends TStyle * @var string grid line setting of the table
*/
private $_gridLines=null;
+ /**
+ * @var boolean whether the table border should be collapsed
+ */
+ private $_borderCollapse=null;
/**
* Sets the style attributes to default values.
@@ -416,6 +420,7 @@ class TTableStyle extends TStyle $this->_cellPadding=null;
$this->_cellSpacing=null;
$this->_gridLines=null;
+ $this->_borderCollapse=null;
}
/**
@@ -439,6 +444,8 @@ class TTableStyle extends TStyle $this->_cellSpacing=$style->_cellSpacing;
if($style->_gridLines!==null)
$this->_gridLines=$style->_gridLines;
+ if($style->_borderCollapse!==null)
+ $this->_borderCollapse=$style->_borderCollapse;
}
}
@@ -463,6 +470,8 @@ class TTableStyle extends TStyle $this->_cellSpacing=$style->_cellSpacing;
if($this->_gridLines===null && $style->_gridLines!==null)
$this->_gridLines=$style->_gridLines;
+ if($this->_borderCollapse===null && $style->_borderCollapse!==null)
+ $this->_borderCollapse=$style->_borderCollapse;
}
}
@@ -484,11 +493,10 @@ class TTableStyle extends TStyle $writer->addAttribute('cellpadding',"$cellPadding");
if(($cellSpacing=$this->getCellSpacing())>=0)
- {
$writer->addAttribute('cellspacing',"$cellSpacing");
- if($this->getCellSpacing()===0)
- $writer->addStyleAttribute('border-collapse','collapse');
- }
+
+ if($this->getBorderCollapse())
+ $writer->addStyleAttribute('border-collapse','collapse');
switch($this->getGridLines())
{
@@ -588,6 +596,23 @@ class TTableStyle extends TStyle {
$this->_gridLines=TPropertyValue::ensureEnum($value,array('None', 'Horizontal', 'Vertical', 'Both'));
}
+
+
+ /**
+ * @return boolean whether the table borders should be collapsed. Defaults to false.
+ */
+ public function getBorderCollapse()
+ {
+ return $this->_borderCollapse===null?false:$this->_borderCollapse;
+ }
+
+ /**
+ * @param boolean whether the table borders should be collapsed.
+ */
+ public function setBorderCollapse($value)
+ {
+ $this->_borderCollapse=TPropertyValue::ensureBoolean($value);
+ }
}
/**
diff --git a/framework/Web/UI/WebControls/TStyleSheet.php b/framework/Web/UI/WebControls/TStyleSheet.php index 5925645c..3e172697 100644 --- a/framework/Web/UI/WebControls/TStyleSheet.php +++ b/framework/Web/UI/WebControls/TStyleSheet.php @@ -46,6 +46,22 @@ class TStyleSheet extends TControl } /** + * @return string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. + */ + public function getMediaType() + { + return $this->getViewState('MediaType',''); + } + + /** + * @param string media type of the CSS (such as 'print', 'screen', etc.). If empty, it means the CSS applies to all media types. + */ + public function setMediaType($value) + { + $this->setViewState('MediaType',$value,''); + } + + /** * Registers the stylesheet file and content to be rendered. * This method overrides the parent implementation and is invoked right before rendering. * @param mixed event parameter @@ -53,7 +69,7 @@ class TStyleSheet extends TControl public function onPreRender($param) { if(($url=$this->getStyleSheetUrl())!=='') - $this->getPage()->getClientScript()->registerStyleSheetFile($url,$url); + $this->getPage()->getClientScript()->registerStyleSheetFile($url,$url,$this->getMediaType()); } /** diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php index fa0fd92a..684ef5dc 100644 --- a/framework/Web/UI/WebControls/TWizard.php +++ b/framework/Web/UI/WebControls/TWizard.php @@ -715,9 +715,11 @@ class TWizard extends TWebControl implements INamingContainer }
/**
+ * Returns the multiview that holds the wizard steps.
+ * This method should only be used by control developers.
* @return TMultiView the multiview holding wizard steps
*/
- protected function getMultiView()
+ public function getMultiView()
{
if($this->_multiView===null)
{
@@ -740,7 +742,6 @@ class TWizard extends TWebControl implements INamingContainer if(($wizard=$step->getWizard())!==null)
$wizard->getWizardSteps()->remove($step);
$step->setWizard($this);
- $this->getMultiView()->getViews()->add($step);
$this->wizardStepsChanged();
}
@@ -752,7 +753,6 @@ class TWizard extends TWebControl implements INamingContainer */
public function removedWizardStep($step)
{
- $this->getMultiView()->getViews()->remove($step);
$step->setWizard(null);
$this->wizardStepsChanged();
}
@@ -1262,7 +1262,7 @@ class TWizard extends TWebControl implements INamingContainer if($this->_sideBarDataList!==null)
{
$this->_sideBarDataList->setDataSource($this->getWizardSteps());
- $this->_sideBarDataList->setSelectedIndex($this->getActiveStepIndex());
+ $this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex());
$this->_sideBarDataList->dataBind();
}
}
@@ -1816,6 +1816,7 @@ class TWizardStepCollection extends TList if($item instanceof TWizardStep)
{
parent::insertAt($index,$item);
+ $this->_wizard->getMultiView()->getViews()->insertAt($index,$item);
$this->_wizard->addedWizardStep($item);
}
else
@@ -1830,6 +1831,7 @@ class TWizardStepCollection extends TList public function removeAt($index)
{
$step=parent::removeAt($index);
+ $this->_wizard->getMultiView()->getViews()->remove($step);
$this->_wizard->removedWizardStep($step);
return $step;
}
|