diff options
-rw-r--r-- | .gitattributes | 3 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/List.page | 1 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page | 23 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php | 52 | ||||
-rw-r--r-- | framework/Web/UI/TControl.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TCheckBoxList.php | 237 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TPanel.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRepeatInfo.php | 16 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TWebControl.php | 4 |
9 files changed, 327 insertions, 15 deletions
diff --git a/.gitattributes b/.gitattributes index 4a83b580..1cb1d8e2 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/TCheckBoxList/Home.page -text +demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page -text demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TLabel/Home.page -text @@ -209,6 +211,7 @@ framework/Web/UI/TThemeManager.php -text framework/Web/UI/WebControls/TBaseValidator.php -text framework/Web/UI/WebControls/TButton.php -text framework/Web/UI/WebControls/TCheckBox.php -text +framework/Web/UI/WebControls/TCheckBoxList.php -text framework/Web/UI/WebControls/TContent.php -text framework/Web/UI/WebControls/TContentPlaceHolder.php -text framework/Web/UI/WebControls/TDataBoundControl.php -text diff --git a/demos/quickstart/protected/pages/Controls/List.page b/demos/quickstart/protected/pages/Controls/List.page index f305580b..f3c4cd96 100644 --- a/demos/quickstart/protected/pages/Controls/List.page +++ b/demos/quickstart/protected/pages/Controls/List.page @@ -18,6 +18,7 @@ List controls covered in this section are all inherit directly or indirectly fro <com:RunBar PagePath="Controls.Samples.TDropDownList.Home" />
<h2>TCheckBoxList</h2>
+<com:RunBar PagePath="Controls.Samples.TCheckBoxList.Home" />
<h2>TRadioButtonList</h2>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page new file mode 100644 index 00000000..04d6e91b --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.page @@ -0,0 +1,23 @@ +<com:TContent ID="body">
+
+<h1>TCheckBoxList Samples</h1>
+
+<table class="sampletable">
+
+<tr>
+<td class="samplenote">
+Check box list with initial items:
+</td>
+<td class="sampleaction">
+<com:TCheckBoxList RepeatLayout="Flow" RepeatDirection="Horizontal" RepeatColumns="2">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" Selected="true" />
+</com:TCheckBoxList>
+</td>
+</tr>
+
+</table>
+
+</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php new file mode 100644 index 00000000..6b1d07e1 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TCheckBoxList/Home.php @@ -0,0 +1,52 @@ +<?php
+
+class Home extends TPage
+{
+ public function selectionChanged($sender,$param)
+ {
+ $index=$sender->SelectedIndex;
+ $value=$sender->SelectedValue;
+ $text=$sender->SelectedItem->Text;
+ $this->SelectionResult->Text="Your selection is (Index: $index, Value: $value, Text: $text).";
+ }
+
+ public function buttonClicked($sender,$param)
+ {
+ $index=$this->ListBox1->SelectedIndex;
+ $value=$this->ListBox1->SelectedValue;
+ $text=$this->ListBox1->SelectedItem->Text;
+ $this->SelectionResult2->Text="Your selection is (Index: $index, Value: $value, Text: $text).";
+ }
+
+ public function multiSelectionChanged($sender,$param)
+ {
+ $indices=$sender->SelectedIndices;
+ $result='';
+ foreach($indices as $index)
+ {
+ $item=$sender->Items[$index];
+ $result.="(Index: $index, Value: $item->Value, Text: $item->Text)\n";
+ }
+ if($result==='')
+ $this->MultiSelectionResult->Text='Your selection is empty.';
+ else
+ $this->MultiSelectionResult->Text='Your selection is: '.$result;
+ }
+
+ public function buttonClicked2($sender,$param)
+ {
+ $indices=$this->ListBox2->SelectedIndices;
+ $result='';
+ foreach($indices as $index)
+ {
+ $item=$this->ListBox2->Items[$index];
+ $result.="(Index: $index, Value: $item->Value, Text: $item->Text)\n";
+ }
+ if($result==='')
+ $this->MultiSelectionResult2->Text='Your selection is empty.';
+ else
+ $this->MultiSelectionResult2->Text='Your selection is: '.$result;
+ }
+}
+
+?>
\ No newline at end of file diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 03d962f4..1663b783 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -67,7 +67,7 @@ class TControl extends TComponent /**
* format of control ID
*/
- const ID_FORMAT='/^[a-zA-Z_]\\w*$/';
+ const ID_FORMAT='/^\\w*$/';
/**
* separator char between IDs in a UniqueID
*/
diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php new file mode 100644 index 00000000..31d06ef9 --- /dev/null +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -0,0 +1,237 @@ +<?php
+
+Prado::using('System.Web.UI.WebControls.TRepeatInfo');
+
+class TCheckBoxList extends TListControl implements IRepeatInfoUser
+{
+ private $_repeatedControl;
+ private $_isEnabled;
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_repeatedControl=new TCheckBox;
+ $this->_repeatedControl->setEnableViewState(false);
+ $this->_repeatedControl->setID('0');
+ $this->getControls()->add($this->_repeatedControl);
+ }
+
+ public function findControl($id)
+ {
+ return $this;
+ }
+
+ protected function getIsMultiSelect()
+ {
+ return true;
+ }
+
+ protected function createStyle()
+ {
+ return new TTableStyle;
+ }
+
+ protected function getRepeatInfo()
+ {
+ if(($repeatInfo=$this->getViewState('RepeatInfo',null))===null)
+ {
+ $repeatInfo=new TRepeatInfo;
+ $this->setViewState('RepeatInfo',$repeatInfo,null);
+ }
+ return $repeatInfo;
+ }
+
+ /**
+ * @return string the alignment of the text caption, defaults to 'Right'.
+ */
+ public function getTextAlign()
+ {
+ return $this->getViewState('TextAlign','Right');
+ }
+
+ /**
+ * Sets the text alignment of the checkboxes
+ * @param string either 'Left' or 'Right'
+ */
+ public function setTextAlign($value)
+ {
+ $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,array('Left','Right')),'Right');
+ }
+
+ /**
+ * @return integer the number of columns that the list should be displayed with. Defaults to 0 meaning not set.
+ */
+ public function getRepeatColumns()
+ {
+ return $this->getRepeatInfo()->getRepeatColumns();
+ }
+
+ /**
+ * Sets the number of columns that the list should be displayed with.
+ * @param integer the number of columns that the list should be displayed with.
+ */
+ public function setRepeatColumns($value)
+ {
+ $this->getRepeatInfo()->setRepeatColumns($value);
+ }
+
+ /**
+ * @return string the direction of traversing the list, defaults to 'Vertical'
+ */
+ public function getRepeatDirection()
+ {
+ return $this->getRepeatInfo()->getRepeatDirection();
+ }
+
+ /**
+ * Sets the direction of traversing the list (Vertical, Horizontal)
+ * @param string the direction of traversing the list
+ */
+ public function setRepeatDirection($value)
+ {
+ $this->getRepeatInfo()->setRepeatDirection($value);
+ }
+
+ /**
+ * @return string how the list should be displayed, using table or using line breaks. Defaults to 'Table'.
+ */
+ public function getRepeatLayout()
+ {
+ return $this->getRepeatInfo()->getRepeatLayout();
+ }
+
+ /**
+ * Sets how the list should be displayed, using table or using line breaks (Table, Flow)
+ * @param string how the list should be displayed, using table or using line breaks (Table, Flow)
+ */
+ public function setRepeatLayout($value)
+ {
+ $this->getRepeatInfo()->setRepeatLayout($value);
+ }
+
+ /**
+ * @return integer the cellspacing for the table keeping the checkbox list. Defaults to -1, meaning not set.
+ */
+ public function getCellSpacing()
+ {
+ if($this->getHasStyle())
+ return $this->getStyle()->getCellSpacing();
+ else
+ return -1;
+ }
+
+ /**
+ * Sets the cellspacing for the table keeping the checkbox list.
+ * @param integer the cellspacing for the table keeping the checkbox list.
+ */
+ public function setCellSpacing($value)
+ {
+ $this->getStyle()->setCellSpacing($value);
+ }
+
+ /**
+ * @return integer the cellpadding for the table keeping the checkbox list. Defaults to -1, meaning not set.
+ */
+ public function getCellPadding()
+ {
+ if($this->getHasStyle())
+ return $this->getStyle()->getCellPadding();
+ else
+ return -1;
+ }
+
+ /**
+ * Sets the cellpadding for the table keeping the checkbox list.
+ * @param integer the cellpadding for the table keeping the checkbox list.
+ */
+ public function setCellPadding($value)
+ {
+ $this->getStyle()->setCellPadding($value);
+ }
+
+ public function loadPostData($key,$values)
+ {
+ }
+
+ public function raisePostDataChangedEvent()
+ {
+ }
+
+ public function getHasHeader()
+ {
+ return false;
+ }
+
+ public function getHasFooter()
+ {
+ return false;
+ }
+
+ public function getHasSeparators()
+ {
+ return false;
+ }
+
+ public function getItemStyle($itemType,$index)
+ {
+ return null;
+ }
+
+ public function getRepeatedItemCount()
+ {
+ if($this->getHasItems())
+ return $this->getItems()->getCount();
+ else
+ return 0;
+ }
+
+ public function renderItem($writer,$repeatInfo,$itemType,$index)
+ {
+ $item=$this->getItems()->itemAt($index);
+ if($item->getHasAttributes())
+ $this->_repeatedControl->getAttributes()->copyFrom($item->getAttributes());
+ else if($this->_repeatedControl->getHasAttributes())
+ $this->_repeatedControl->getAttributes()->clear();
+ $this->_repeatedControl->setID("$index");
+ $this->_repeatedControl->setText($item->getText());
+ $this->_repeatedControl->setChecked($item->getSelected());
+ $this->_repeatedControl->setEnabled($this->_isEnabled && $item->getEnabled());
+ $this->_repeatedControl->renderControl($writer);
+ }
+
+ protected function onPreRender($param)
+ {
+ parent::onPreRender($param);
+ $this->_repeatedControl->setAutoPostBack($this->getAutoPostBack());
+ $this->_repeatedControl->setCausesValidation($this->getCausesValidation());
+ $this->_repeatedControl->setValidationGroup($this->getValidationGroup());
+ $page=$this->getPage();
+ $n=$this->getRepeatedItemCount();
+ for($i=0;$i<$n;++$i)
+ {
+ $this->_repeatedControl->setID("$i");
+ $page->registerRequiresPostData($this->_repeatedControl);
+ }
+ }
+
+ protected function render($writer)
+ {
+ if($this->getRepeatedItemCount()>0)
+ {
+ $this->_isEnabled=$this->getEnabled(true);
+ $repeatInfo=$this->getRepeatInfo();
+ $accessKey=$this->getAccessKey();
+ $tabIndex=$this->getTabIndex();
+ $this->_repeatedControl->setTextAlign($this->getTextAlign());
+ $this->_repeatedControl->setAccessKey($accessKey);
+ $this->_repeatedControl->setTabIndex($tabIndex);
+ $this->setAccessKey('');
+ $this->setTabIndex(0);
+ $repeatInfo->renderRepeater($writer,$this);
+ $this->setAccessKey($accessKey);
+ $this->setTabIndex($tabIndex);
+ }
+ }
+}
+
+?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php index eeee4d59..c7464c7c 100644 --- a/framework/Web/UI/WebControls/TPanel.php +++ b/framework/Web/UI/WebControls/TPanel.php @@ -204,7 +204,7 @@ class TPanel extends TWebControl * Renders the openning tag for the control (including attributes)
* @param THtmlWriter the writer used for the rendering purpose
*/
- protected function renderBeginTag($writer)
+ public function renderBeginTag($writer)
{
parent::renderBeginTag($writer);
if(($text=$this->getGroupingText())!=='')
@@ -220,7 +220,7 @@ class TPanel extends TWebControl * Renders the closing tag for the control
* @param THtmlWriter the writer used for the rendering purpose
*/
- protected function renderEndTag($writer)
+ public function renderEndTag($writer)
{
if($this->getGroupingText()!=='')
$writer->renderEndTag();
diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php index ffb10c12..66584ded 100644 --- a/framework/Web/UI/WebControls/TRepeatInfo.php +++ b/framework/Web/UI/WebControls/TRepeatInfo.php @@ -92,7 +92,7 @@ class TRepeatInfo extends TComponent else
$this->renderHorizontalContents($writer,$user);
- $control->renderEndTag();
+ $control->renderEndTag($writer);
}
protected function renderHorizontalContents($writer,$user)
@@ -251,7 +251,6 @@ class TRepeatInfo extends TComponent for($row=0;$row<$rows;++$row)
{
$index=$row;
- $writer->renderBeginTag('tr');
for($col=0;$col<$columns;++$col)
{
if($renderedItems>=$itemCount)
@@ -273,8 +272,6 @@ class TRepeatInfo extends TComponent $writer->writeBreak();
$user->renderItem($writer,$this,'Separator',$index);
}
- else if($columns>1)
- $writer->write('<td></td>');
}
if($row<$rows-1 || $user->getHasFooter())
$writer->writeBreak();
@@ -297,13 +294,13 @@ class TRepeatInfo extends TComponent if(($style=$user->getItemStyle('Header',-1))!==null)
$style->addAttributesToRender($writer);
$writer->renderBeginTag('th');
- $user->renderItem($writer,$this,'Header',-1)
+ $user->renderItem($writer,$this,'Header',-1);
$writer->renderEndTag();
$writer->renderEndTag();
}
else
{
- $user->renderItem($writer,$this,'Header',-1)
+ $user->renderItem($writer,$this,'Header',-1);
if($needBreak)
$writer->writeBreak();
}
@@ -316,16 +313,15 @@ class TRepeatInfo extends TComponent $writer->renderBeginTag('tr');
if($columns>1)
$writer->addAttribute('colspan',"$columns");
- $writer->addAttribute('scope','col');
- if(($style=$user->getItemStyle('Header',-1))!==null)
+ if(($style=$user->getItemStyle('Footer',-1))!==null)
$style->addAttributesToRender($writer);
$writer->renderBeginTag('td');
- $user->renderItem($writer,$this,'Header',-1)
+ $user->renderItem($writer,$this,'Footer',-1);
$writer->renderEndTag();
$writer->renderEndTag();
}
else
- $user->renderItem($writer,$this,'Header',-1)
+ $user->renderItem($writer,$this,'Footer',-1);
}
}
diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index 8ef47ede..ba6fe04c 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -379,7 +379,7 @@ class TWebControl extends TControl * Renders the openning tag for the control (including attributes)
* @param THtmlWriter the writer used for the rendering purpose
*/
- protected function renderBeginTag($writer)
+ public function renderBeginTag($writer)
{
$this->addAttributesToRender($writer);
$writer->renderBeginTag($this->getTagName());
@@ -400,7 +400,7 @@ class TWebControl extends TControl * Renders the closing tag for the control
* @param THtmlWriter the writer used for the rendering purpose
*/
- protected function renderEndTag($writer)
+ public function renderEndTag($writer)
{
$writer->renderEndTag();
}
|