diff options
author | xue <> | 2006-05-17 21:24:40 +0000 |
---|---|---|
committer | xue <> | 2006-05-17 21:24:40 +0000 |
commit | 3d437d9dcd37dc901f53ca3322ba118851e3c676 (patch) | |
tree | 076d80a286ab5b1cac4267a4155591d2a77f5e80 /framework/Web/UI/WebControls | |
parent | fc2d7f134f07a89e4f01b703ba10d54f63fe6a68 (diff) |
Merge from 3.0 branch till 1073.
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 58 |
2 files changed, 40 insertions, 22 deletions
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 02386515..59a71c90 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -50,7 +50,7 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); * <b>ButtonText</b> property
* # <b>ImageButton</b> -- Shows an image next to the text input, clicking on
* the image shows the date picker, image source can be
- * change through the <b>ImageUrl</b> property.
+ * change through the <b>ButtonImageUrl</b> property.
*
* The <b>CssClass</b> property can be used to override the css class name
* for the date picker panel. <b>CalendarStyle</b> property sets the packages
@@ -712,4 +712,4 @@ class TDatePicker extends TTextBox }
}
-?>
\ No newline at end of file +?>
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 1c7fe11b..f97eb307 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -182,7 +182,7 @@ abstract class TListControl extends TDataBoundControl $textFormat=$this->getDataTextFormatString();
foreach($data as $key=>$object)
{
- $item=new TListItem;
+ $item=$items->createListItem();
if(is_array($object) || is_object($object))
{
$text=TDataFieldAccessor::getDataFieldValue($object,$textField);
@@ -195,7 +195,6 @@ abstract class TListControl extends TDataBoundControl $item->setValue("$key");
}
$item->setText($this->formatDataValue($textFormat,$text));
- $items->add($item);
}
// SelectedValue or SelectedIndex may be set before databinding
// so we make them be effective now
@@ -216,6 +215,16 @@ abstract class TListControl extends TDataBoundControl }
/**
+ * Creates a collection object to hold list items.
+ * This method may be overriden to create a customized collection.
+ * @return TListItemCollection the collection object
+ */
+ protected function createListItemCollection()
+ {
+ return new TListItemCollection;
+ }
+
+ /**
* Saves items into viewstate.
* This method is invoked right before control state is to be saved.
*/
@@ -238,7 +247,7 @@ abstract class TListControl extends TDataBoundControl $this->_stateLoaded=true;
if(!$this->getIsDataBound())
{
- $this->_items=new TListItemCollection;
+ $this->_items=$this->createListItemCollection();
$this->_items->loadState($this->getViewState('Items',null));
}
$this->clearViewState('Items');
@@ -379,7 +388,7 @@ abstract class TListControl extends TDataBoundControl public function getItems()
{
if(!$this->_items)
- $this->_items=new TListItemCollection;
+ $this->_items=$this->createListItemCollection();
return $this->_items;
}
@@ -637,6 +646,23 @@ abstract class TListControl extends TDataBoundControl class TListItemCollection extends TList
{
/**
+ * Creates a list item object.
+ * This method may be overriden to provide a customized list item object.
+ * @param integer index where the newly created item is to be inserted at.
+ * If -1, the item will be appended to the end.
+ * @return TListItem list item object
+ */
+ public function createListItem($index=-1)
+ {
+ $item=new TListItem;
+ if($index<0)
+ $this->add($item);
+ else
+ $this->insertAt($index,$item);
+ return $item;
+ }
+
+ /**
* Inserts an item into the collection.
* @param integer the location where the item will be inserted.
* The current item at the place and the following ones will be moved backward.
@@ -645,10 +671,13 @@ class TListItemCollection extends TList */
public function insertAt($index,$item)
{
- if(is_string($item))
- parent::insertAt($index,new TListItem($item));
- else if($item instanceof TListItem)
+ if($item instanceof TListItem)
parent::insertAt($index,$item);
+ else if(is_string($item))
+ {
+ $item=$this->createListItem($index);
+ $item->setText($item);
+ }
else
throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this));
}
@@ -728,10 +757,7 @@ class TListItemCollection extends TList {
$this->clear();
if($state!==null)
- {
- foreach($state as $item)
- $this->add(new TListItem($item[0],$item[1],$item[2],$item[3]));
- }
+ $this->copyFrom($state);
}
/**
@@ -741,15 +767,7 @@ class TListItemCollection extends TList */
public function saveState()
{
- if($this->getCount()>0)
- {
- $state=array();
- foreach($this as $item)
- $state[]=array($item->getText(),$item->getValue(),$item->getEnabled(),$item->getSelected());
- return $state;
- }
- else
- return null;
+ return ($this->getCount()>0) ? $this->toArray() : null;
}
}
|