From 551cdfb76ddde47198106839747df9c1ef74e4fe Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 3 Jan 2006 00:15:59 +0000 Subject: Added TBulletedList and its demos. --- .gitattributes | 3 + .../quickstart/protected/pages/Controls/List.page | 1 + .../pages/Controls/Samples/TBulletedList/Home.page | 69 +++++++ .../pages/Controls/Samples/TBulletedList/Home.php | 12 ++ .../pages/Controls/Samples/TCheckBoxList/Home.page | 6 +- .../Controls/Samples/TRadioButtonList/Home.page | 6 +- framework/Web/UI/WebControls/TBulletedList.php | 230 +++++++++++++++++++++ framework/Web/UI/WebControls/TLinkButton.php | 2 +- 8 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php create mode 100644 framework/Web/UI/WebControls/TBulletedList.php diff --git a/.gitattributes b/.gitattributes index b16270db..7022ed95 100644 --- a/.gitattributes +++ b/.gitattributes @@ -40,6 +40,8 @@ demos/quickstart/protected/pages/Configurations/Templates3.page -text demos/quickstart/protected/pages/Construction.page -text demos/quickstart/protected/pages/Controls/List.page -text demos/quickstart/protected/pages/Controls/Overview.page -text +demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page -text +demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page -text demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page -text @@ -213,6 +215,7 @@ framework/Web/UI/TTemplateControl.php -text framework/Web/UI/TTemplateManager.php -text framework/Web/UI/TThemeManager.php -text framework/Web/UI/WebControls/TBaseValidator.php -text +framework/Web/UI/WebControls/TBulletedList.php -text framework/Web/UI/WebControls/TButton.php -text framework/Web/UI/WebControls/TCheckBox.php -text framework/Web/UI/WebControls/TCheckBoxList.php -text diff --git a/demos/quickstart/protected/pages/Controls/List.page b/demos/quickstart/protected/pages/Controls/List.page index f70c4368..5b0e766a 100644 --- a/demos/quickstart/protected/pages/Controls/List.page +++ b/demos/quickstart/protected/pages/Controls/List.page @@ -24,5 +24,6 @@ List controls covered in this section are all inherit directly or indirectly fro

TBulletList

+ \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page new file mode 100644 index 00000000..c5171868 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page @@ -0,0 +1,69 @@ + + +

TBulletedList Samples

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Bulleted list with default settings: + + + + + + + +
+Bulleted list with customized color, font, bullet style: + + + + + + + +
+Bulleted list of hyperlinks: + + + + + + +
+Bulleted list of link buttons (click on them to see the result): + + + + + + + +
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php new file mode 100644 index 00000000..d3e04787 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php @@ -0,0 +1,12 @@ +Items[$param->Index]; + $this->Result->Text="You clicked $item->Text : $item->Value."; + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page index ac9de17e..d4833ea9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page @@ -104,7 +104,8 @@ Check box list's behavior upon postback: - + +
@@ -121,7 +122,8 @@ Auto postback check box list: - + + diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.page index 95fea89b..3f5f7053 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.page @@ -104,7 +104,8 @@ Radio button list's behavior upon postback: - + +
@@ -121,7 +122,8 @@ Auto postback radio button list: - + + diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php new file mode 100644 index 00000000..f2540644 --- /dev/null +++ b/framework/Web/UI/WebControls/TBulletedList.php @@ -0,0 +1,230 @@ +getCausesValidation()) + $this->getPage()->validate($this->getValidationGroup()); + $this->onClick(new TBulletedListEventParameter((int)$param)); + } + + protected function getTagName() + { + switch($this->getBulletStyle()) + { + case 'Numbered': + case 'LowerAlpha': + case 'UpperAlpha': + case 'LowerRoman': + case 'UpperRoman': + return 'ol'; + } + return 'ul'; + } + + protected function addAttributesToRender($writer) + { + $needStart=false; + switch($this->getBulletStyle()) + { + case 'Numbered': + $writer->addStyleAttribute('list-style-type','decimal'); + $needStart=true; + break; + case 'LowerAlpha': + $writer->addStyleAttribute('list-style-type','lower-alpha'); + $needStart=true; + break; + case 'UpperAlpha': + $writer->addStyleAttribute('list-style-type','upper-alpha'); + $needStart=true; + break; + case 'LowerRoman': + $writer->addStyleAttribute('list-style-type','lower-roman'); + $needStart=true; + break; + case 'UpperRoman': + $writer->addStyleAttribute('list-style-type','upper-roman'); + $needStart=true; + break; + case 'Disc': + $writer->addStyleAttribute('list-style-type','disc'); + break; + case 'Circle': + $writer->addStyleAttribute('list-style-type','circle'); + break; + case 'Square': + $writer->addStyleAttribute('list-style-type','square'); + break; + case 'CustomImage': + $url=$this->getBulletImageUrl(); + $writer->addStyleAttribute('list-style-image',"url($url)"); + break; + } + if($needStart && ($start=$this->getFirstBulletNumber())!=1) + $writer->addAttribute('start',"$start"); + parent::addAttributesToRender($writer); + } + + public function getBulletImageUrl() + { + return $this->getViewState('BulletImageUrl',''); + } + + public function setBulletImageUrl($value) + { + $this->setViewState('BulletImageUrl',$value,''); + } + + public function getBulletStyle() + { + return $this->getViewState('BulletStyle','NotSet'); + } + + public function setBulletStyle($value) + { + $this->setViewState('BulletStyle',TPropertyValue::ensureEnum($value,'NotSet','Numbered','LowerAlpha','UpperAlpha','LowerRoman','UpperRoman','Disc','Circle','Square','CustomImage'),'NotSet'); + } + + public function getDisplayMode() + { + return $this->getViewState('DisplayMode','Text'); + } + + public function setDisplayMode($value) + { + $this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'Text','HyperLink','LinkButton'),'Text'); + } + + public function getFirstBulletNumber() + { + return $this->getViewState('FirstBulletNumber',1); + } + + public function setFirstBulletNumber($value) + { + $this->setViewState('FirstBulletNumber',TPropertyValue::ensureInteger($value),1); + } + + public function onClick($param) + { + $this->raiseEvent('Click',$this,$param); + } + + /** + * @return string the target window or frame to display the Web page content linked to when the THyperLink component is clicked. + */ + public function getTarget() + { + return $this->getViewState('Target',''); + } + + /** + * Sets the target window or frame to display the Web page content linked to when the THyperLink component is clicked. + * @param string the target window, valid values include '_blank', '_parent', '_self', '_top' and empty string. + */ + public function setTarget($value) + { + $this->setViewState('Target',$value,''); + } + + protected function render($writer) + { + if($this->getHasItems()) + parent::render($writer); + } + + protected function renderContents($writer) + { + $this->_isEnabled=$this->getEnabled(true); + $this->_postBackOptions=$this->getPostBackOptions(); + $writer->writeLine(); + foreach($this->getItems() as $index=>$item) + { + if($item->getHasAttributes()) + { + foreach($item->getAttributes() as $name=>$value) + $writer->addAttribute($name,$value); + } + $writer->renderBeginTag('li'); + $this->renderBulletText($writer,$item,$index); + $writer->renderEndTag(); + $writer->writeLine(); + } + } + + protected function renderBulletText($writer,$item,$index) + { + switch($this->getDisplayMode()) + { + case 'Text': + if($item->getEnabled()) + $writer->write(THttpUtility::htmlEncode($item->getText())); + else + { + $writer->addAttribute('disabled','disabled'); + $writer->renderBeginTag('span'); + $writer->write(THttpUtility::htmlEncode($item->getText())); + $writer->renderEndTag(); + } + return; + case 'HyperLink': + if(!$this->_isEnabled || !$item->getEnabled()) + $writer->addAttribute('disabled','disabled'); + else + { + $writer->addAttribute('href',$item->getValue()); + if(($target=$this->getTarget())!=='') + $writer->addAttribute('target',$target); + } + break; + case 'LinkButton': + if(!$this->_isEnabled || !$item->getEnabled()) + $writer->addAttribute('disabled','disabled'); + else + { + $postback=$this->getPage()->getClientScript()->getPostBackEventReference($this,"$index",$this->_postBackOptions); + $writer->addAttribute('href',$postback); + } + } + if(($accesskey=$this->getAccessKey())!=='') + $writer->addAttribute('accesskey',$accesskey); + $writer->renderBeginTag('a'); + $writer->write(THttpUtility::htmlEncode($item->getText())); + $writer->renderEndTag(); + } + + protected function getPostBackOptions() + { + $option=new TPostBackOptions(); + $group = $this->getValidationGroup(); + $hasValidators = $this->getPage()->getValidators($group)->getCount()>0; + if($this->getCausesValidation() && $hasValidators) + { + $options->setPerformValidation(true); + $options->setValidationGroup($this->getValidationGroup()); + return $options; + } + else + return null; + } +} + +class TBulletedListEventParameter extends TEventParameter +{ + private $_index; + public function __construct($index) + { + $this->_index=$index; + } + + public function getIndex() + { + return $this->_index; + } +} +?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d3518ee4..16d670b3 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -86,7 +86,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler { $url = $this->getPostBackUrl(); //create unique no-op url references - $nop = "javascript:;//{$this->ClientID}"; + $nop = "javascript:;//".$this->getClientID(); $writer->addAttribute('href', $url ? $url : $nop); $scripts = $this->getPage()->getClientScript(); -- cgit v1.2.3