From 01bc363ac789cfb9d644ce82a949da5cd7e1c220 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 31 Jan 2006 00:01:49 +0000 Subject: Modified TList and TMap implementation so that they can be more easily extended. --- framework/Web/UI/TControl.php | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'framework/Web/UI/TControl.php') diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 7b9fee4e..ee1b8e11 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1487,32 +1487,39 @@ class TControlList extends TList } /** - * Overrides the parent implementation with customized processing of the newly added item. - * @param mixed the newly added item - */ - protected function addedItem($item) - { - if($item instanceof TControl) + * Inserts an item at the specified position. + * This overrides the parent implementation by performing additional + * operations for each newly added child control. + * @param integer the speicified position. + * @param mixed new item + * @throws TInvalidDataTypeException if the item to be inserted is neither a string nor a TControl. + */ + public function insertAt($index,$item) + { + if(is_string($item)) + parent::insertAt($index,$item); + else if($item instanceof TControl) + { + parent::insertAt($index,$item); $this->_o->addedControl($item); + } + else + throw new TInvalidDataTypeException('controllist_control_required'); } /** - * Overrides the parent implementation with customized processing of the removed item. - * @param mixed the removed item + * Removes an item at the specified position. + * This overrides the parent implementation by performing additional + * cleanup work when removing a child control. + * @param integer the index of the item to be removed. + * @return mixed the removed item. */ - protected function removedItem($item) + public function removeAt($index) { + $item=parent::removeAt($index); if($item instanceof TControl) $this->_o->removedControl($item); - } - - /** - * Only string or instance of TControl can be added into collection. - * @param mixed the item to be added - */ - protected function canAddItem($item) - { - return is_string($item) || ($item instanceof TControl); + return $item; } /** -- cgit v1.2.3