From 682f7ef6933f4ad485baedddf7a30367d003d7bf Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 25 Jan 2007 05:49:22 +0000 Subject: Fixed #502 --- framework/I18N/core/CultureInfo.php | 5 ++- framework/Web/UI/WebControls/TStyle.php | 62 +++++++++++++++++++++++++++- framework/Web/UI/WebControls/TWebControl.php | 16 +++++++ 3 files changed, 80 insertions(+), 3 deletions(-) (limited to 'framework') diff --git a/framework/I18N/core/CultureInfo.php b/framework/I18N/core/CultureInfo.php index bcf2f245..404c81fe 100644 --- a/framework/I18N/core/CultureInfo.php +++ b/framework/I18N/core/CultureInfo.php @@ -414,7 +414,7 @@ class CultureInfo * Gets the culture name in English. * Returns array('Language','Country'); * 'Country' is omitted if the culture is neutral. - * @return array array with language and country as elements. + * @return string language (country), it may locale code string if english name does not exist. */ function getEnglishName() { @@ -423,6 +423,9 @@ class CultureInfo $culture = $this->getInvariantCulture(); $language = $culture->findInfo("Languages/{$lang}"); + if(count($language) == 0) + return $this->culture; + $region = $culture->findInfo("Countries/{$reg}"); if($region) return $language[0].' ('.$region[0].')'; diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index cc383766..73ff4adf 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -43,6 +43,10 @@ class TStyle extends TComponent * @var string CSS style string (those not represented by specific fields of TStyle) */ private $_customStyle=null; + /** + * @var string display style + */ + private $_displayStyle='Fixed'; /** * Constructor. @@ -173,7 +177,7 @@ class TStyle extends TComponent $this->_font=new TFont; return $this->_font; } - + /** * @return boolean true if font is set. */ @@ -182,6 +186,37 @@ class TStyle extends TComponent return $this->_font !== null; } + /** + * @param TDisplayStyle control display style, default is TDisplayStyle::Fixed + */ + public function setDisplayStyle($value) + { + $this->_displayStyle = TPropertyValue::ensureEnum($value, 'TDisplayStyle'); + switch($this->_displayStyle) + { + case TDisplayStyle::None: + $this->_fields['display'] = 'none'; + break; + case TDisplayStyle::Dynamic: + $this->_fields['display'] = ''; //remove the display property + break; + case TDisplayStyle::Fixed: + $this->_fields['visibility'] = 'visible'; + break; + case TDisplayStyle::Hidden: + $this->_fields['visibility'] = 'hidden'; + break; + } + } + + /** + * @return TDisplayStyle display style + */ + public function getDisplayStyle() + { + return $this->_displayStyle; + } + /** * @return string the foreground color of the control */ @@ -362,7 +397,7 @@ class TStyle extends TComponent if($this->_class!==null) $writer->addAttribute('class',$this->_class); } - + /** * @return array list of style fields. */ @@ -372,6 +407,29 @@ class TStyle extends TComponent } } +/** + * TDisplayStyle defines the enumerable type for the possible styles + * that a web control can display. + * + * The following enumerable values are defined: + * - None: the control is not displayed and not included in the layout. + * - Dynamic: the control is displayed and included in the layout, the layout flow is dependent on the control (equivalent to display:'' in css). + * - Fixed: Similar to Dynamic with CSS "visibility" set "shown". + * - Hidden: the control is not displayed and is included in the layout. + * + * @author Wei Zhuo + * @version $Id$ + * @package System.Web.UI.WebControls + * @since 3.1 + */ +class TDisplayStyle extends TEnumerable +{ + const None='None'; + const Dynamic='Dynamic'; + const Fixed='Fixed'; + const Hidden='Hidden'; +} + /** * TTableStyle class. * TTableStyle represents the CSS style specific for HTML table. diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index a45bab05..78c1aa98 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -193,6 +193,22 @@ class TWebControl extends TControl return ''; } + /** + * @param TDisplayStyle display style of the control, default is TDisplayStyle::Fixed + */ + public function setDisplay($value) + { + $this->getStyle()->setDisplayStyle($value); + } + + /** + * @return TDisplayStyle display style of the control, default is TDisplayStyle::Fixed + */ + public function getDisplay() + { + return $this->getStyle()->getDisplayStyle(); + } + /** * @param string the css class of the control */ -- cgit v1.2.3