summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
authorxue <>2006-01-31 00:01:49 +0000
committerxue <>2006-01-31 00:01:49 +0000
commit01bc363ac789cfb9d644ce82a949da5cd7e1c220 (patch)
treea059046856645d59cf0cb1badee83eb5c73671e9 /framework/Web/UI/WebControls
parent265b7e85766ba403ca0a8b58648dd091e483cf38 (diff)
Modified TList and TMap implementation so that they can be more easily extended.
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php34
-rw-r--r--framework/Web/UI/WebControls/TDataList.php17
-rw-r--r--framework/Web/UI/WebControls/TDataSourceView.php2
-rw-r--r--framework/Web/UI/WebControls/TListControl.php21
-rw-r--r--framework/Web/UI/WebControls/TRepeater.php17
-rw-r--r--framework/Web/UI/WebControls/TTable.php83
6 files changed, 92 insertions, 82 deletions
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index 646ead01..0aad717d 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -1553,15 +1553,18 @@ class TDataGridItem extends TTableRow implements INamingContainer
class TDataGridItemCollection extends TList
{
/**
- * Returns true only when the item to be added is a {@link TDataGridItem}.
- * This method is invoked before adding an item to the list.
- * If it returns true, the item will be added to the list, otherwise not.
- * @param mixed item to be added
- * @return boolean whether the item can be added to the list
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by inserting only TDataGridItem.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TDataGridItem.
*/
- protected function canAddItem($item)
+ public function insertAt($index,$item)
{
- return ($item instanceof TDataGridItem);
+ if($item instanceof TDataGridItem)
+ parent::insertAt($index,$item);
+ else
+ throw new TInvalidDataTypeException('datagriditemcollection_datagriditem_required');
}
}
@@ -1578,15 +1581,18 @@ class TDataGridItemCollection extends TList
class TDataGridColumnCollection extends TList
{
/**
- * Returns true only when the item to be added is a {@link TDataGridItem}.
- * This method is invoked before adding an item to the list.
- * If it returns true, the item will be added to the list, otherwise not.
- * @param mixed item to be added
- * @return boolean whether the item can be added to the list
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by inserting only TDataGridColumn.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TDataGridColumn.
*/
- protected function canAddItem($item)
+ public function insertAt($index,$item)
{
- return ($item instanceof TDataGridColumn);
+ if($item instanceof TDataGridColumn)
+ parent::insertAt($index,$item);
+ else
+ throw new TInvalidDataTypeException('datagridcolumncollection_datagridcolumn_required');
}
}
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php
index c0d74974..47b60cd6 100644
--- a/framework/Web/UI/WebControls/TDataList.php
+++ b/framework/Web/UI/WebControls/TDataList.php
@@ -1354,15 +1354,18 @@ class TDataListItem extends TWebControl implements INamingContainer
class TDataListItemCollection extends TList
{
/**
- * Returns true only when the item to be added is a {@link TDataListItem}.
- * This method is invoked before adding an item to the list.
- * If it returns true, the item will be added to the list, otherwise not.
- * @param mixed item to be added
- * @return boolean whether the item can be added to the list
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by inserting only TDataListItem.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TDataListItem.
*/
- protected function canAddItem($item)
+ public function insertAt($index,$item)
{
- return ($item instanceof TDataListItem);
+ if($item instanceof TDataListItem)
+ parent::insertAt($index,$item);
+ else
+ throw new TInvalidDataTypeException('datalistitemcollection_datalistitem_required');
}
}
diff --git a/framework/Web/UI/WebControls/TDataSourceView.php b/framework/Web/UI/WebControls/TDataSourceView.php
index ab79e74c..c20556bb 100644
--- a/framework/Web/UI/WebControls/TDataSourceView.php
+++ b/framework/Web/UI/WebControls/TDataSourceView.php
@@ -103,7 +103,7 @@ abstract class TDataSourceView extends TComponent
* @param array|TMap
* @return integer affected rows
*/
- public function insert($values)
+ public function insertAt($values)
{
throw new TNotSupportedException('datasourceview_insert_unsupported');
}
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 6faccf31..8d2959b4 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -567,33 +567,18 @@ abstract class TListControl extends TDataBoundControl
class TListItemCollection extends TList
{
/**
- * Appends an item to the collection.
- * @param TListItem the item to be appended.
- * @throws TInvalidDataTypeException if the item being appended is neither a string nor a TListItem
- */
- public function add($item)
- {
- if(is_string($item))
- parent::add(new TListItem($item));
- else if($item instanceof TListItem)
- parent::add($item);
- else
- throw new TInvalidDataTypeException('listitemcollection_item_invalid');
- }
-
- /**
* 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.
* @param TListItem the item to be inserted.
* @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem
*/
- public function insert($index,$item)
+ public function insertAt($index,$item)
{
if(is_string($item))
- parent::insert($index,new TListItem($item));
+ parent::insertAt($index,new TListItem($item));
else if($item instanceof TListItem)
- parent::insert($index,$item);
+ parent::insertAt($index,$item);
else
throw new TInvalidDataTypeException('listitemcollection_item_invalid');
}
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php
index 6aa6b461..a122f387 100644
--- a/framework/Web/UI/WebControls/TRepeater.php
+++ b/framework/Web/UI/WebControls/TRepeater.php
@@ -661,15 +661,18 @@ class TRepeaterItem extends TControl implements INamingContainer
class TRepeaterItemCollection extends TList
{
/**
- * Returns true only when the item to be added is a {@link TRepeaterItem}.
- * This method is invoked before adding an item to the list.
- * If it returns true, the item will be added to the list, otherwise not.
- * @param mixed item to be added
- * @return boolean whether the item can be added to the list
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by inserting only TRepeaterItem.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TRepeaterItem.
*/
- protected function canAddItem($item)
+ public function insertAt($index,$item)
{
- return ($item instanceof TRepeaterItem);
+ if($item instanceof TRepeaterItem)
+ parent::insertAt($index,$item);
+ else
+ throw new TInvalidDataTypeException('repeateritemcollection_repeateritem_required');
}
}
diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php
index dab0fb60..fb70e66c 100644
--- a/framework/Web/UI/WebControls/TTable.php
+++ b/framework/Web/UI/WebControls/TTable.php
@@ -712,32 +712,38 @@ class TTableRowCollection extends TList
}
/**
- * Only string or instance of TControl can be added into collection.
- * @param mixed the item to be added
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by performing additional
+ * operations for each newly added table row.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TTableRow object.
*/
- protected function canAddItem($item)
+ public function insertAt($index,$item)
{
- return ($item instanceof TTableRow);
- }
-
- /**
- * Overrides the parent implementation with customized processing of the newly added item.
- * @param mixed the newly added item
- */
- protected function addedItem($item)
- {
- if($this->_owner)
- $this->_owner->getControls()->add($item);
+ if($item instanceof TTableRow)
+ {
+ parent::insertAt($index,$item);
+ if($this->_owner)
+ $this->_owner->getControls()->insertAt($index,$item);
+ }
+ else
+ throw new TInvalidDataTypeException('tablerowcollection_tablerow_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 table row.
+ * @param integer the index of the item to be removed.
+ * @return mixed the removed item.
*/
- protected function removedItem($item)
+ public function removeAt($index)
{
- if($this->_owner)
+ $item=parent::removeAt($index);
+ if($item instanceof TTableRow)
$this->_owner->getControls()->remove($item);
+ return $item;
}
}
@@ -768,33 +774,40 @@ class TTableCellCollection extends TList
$this->_owner=$owner;
}
- /**
- * Only string or instance of TTableCell can be added into collection.
- * @param mixed the item to be added
- */
- protected function canAddItem($item)
- {
- return ($item instanceof TTableCell);
- }
/**
- * Overrides the parent implementation with customized processing of the newly added item.
- * @param mixed the newly added item
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by performing additional
+ * operations for each newly added table cell.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TTableCell object.
*/
- protected function addedItem($item)
+ public function insertAt($index,$item)
{
- if($this->_owner)
- $this->_owner->getControls()->add($item);
+ if($item instanceof TTableCell)
+ {
+ parent::insertAt($index,$item);
+ if($this->_owner)
+ $this->_owner->getControls()->insertAt($index,$item);
+ }
+ else
+ throw new TInvalidDataTypeException('tablecellcollection_tablecell_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 table cell.
+ * @param integer the index of the item to be removed.
+ * @return mixed the removed item.
*/
- protected function removedItem($item)
+ public function removeAt($index)
{
- if($this->_owner)
+ $item=parent::removeAt($index);
+ if($item instanceof TTableCell)
$this->_owner->getControls()->remove($item);
+ return $item;
}
}
?> \ No newline at end of file