summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
authorwei <>2006-06-24 05:46:22 +0000
committerwei <>2006-06-24 05:46:22 +0000
commita6be5564823be40670e0cad8dc758557dbd37549 (patch)
tree13083fe7ea207b5426c9ee29afc36654e1ed623d /framework/Web/UI/WebControls
parentcb8b23aca4c682c58323f432aa38a88c7a695377 (diff)
Update active controls.
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r--framework/Web/UI/WebControls/TBulletedList.php8
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php2
-rw-r--r--framework/Web/UI/WebControls/THyperLink.php25
-rw-r--r--framework/Web/UI/WebControls/TListControl.php78
4 files changed, 96 insertions, 17 deletions
diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php
index 5499a9eb..c47b1035 100644
--- a/framework/Web/UI/WebControls/TBulletedList.php
+++ b/framework/Web/UI/WebControls/TBulletedList.php
@@ -395,6 +395,14 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
{
throw new TNotSupportedException('bulletedlist_selectedvalue_unsupported');
}
+
+ /**
+ * @throws TNotSupportedException if this method is invoked
+ */
+ public function setSelectedValues($values)
+ {
+ throw new TNotSupportedException('bulletedlist_selectedvalue_unsupported');
+ }
}
/**
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index 9f26b02c..6fe562c9 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -347,7 +347,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$writer->addAttribute('type','checkbox');
if(($value = $this->getValueAttribute()) !== '')
$writer->addAttribute('value',$value);
- if($onclick!=='')
+ if(!empty($onclick))
$writer->addAttribute('onclick',$onclick);
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php
index 011ce4db..7827038a 100644
--- a/framework/Web/UI/WebControls/THyperLink.php
+++ b/framework/Web/UI/WebControls/THyperLink.php
@@ -68,15 +68,26 @@ class THyperLink extends TWebControl
}
else
{
- $image=Prado::createComponent('System.Web.UI.WebControls.TImage');
- $image->setImageUrl($imageUrl);
- if(($toolTip=$this->getToolTip())!=='')
- $image->setToolTip($toolTip);
- if(($text=$this->getText())!=='')
- $image->setAlternateText($text);
- $image->renderControl($writer);
+ $this->createImage($imageUrl)->renderControl($writer);
}
}
+
+ /**
+ * Gets the TImage for rendering the ImageUrl property. This is not for
+ * creating dynamic images.
+ * @param string image url.
+ * @return TImage image control for rendering.
+ */
+ protected function createImage($imageUrl)
+ {
+ $image=Prado::createComponent('System.Web.UI.WebControls.TImage');
+ $image->setImageUrl($imageUrl);
+ if(($toolTip=$this->getToolTip())!=='')
+ $image->setToolTip($toolTip);
+ if(($text=$this->getText())!=='')
+ $image->setAlternateText($text);
+ return $image;
+ }
/**
* @return string the text caption of the THyperLink
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index a9087af5..3ad46db8 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -436,6 +436,8 @@ abstract class TListControl extends TDataBoundControl
throw new TInvalidDataValueException('listcontrol_selectedindex_invalid',get_class($this),$index);
}
$this->_cachedSelectedIndex=$index;
+ if($this->getAdapter() instanceof IListControlAdaptee)
+ $this->getAdapter()->setSelectedIndex($index);
}
/**
@@ -469,6 +471,9 @@ abstract class TListControl extends TDataBoundControl
$this->_items->itemAt($index)->setSelected(true);
}
}
+
+ if($this->getAdapter() instanceof IListControlAdaptee)
+ $this->getAdapter()->setSelectedIndices($indices);
}
/**
@@ -512,6 +517,8 @@ abstract class TListControl extends TDataBoundControl
throw new TInvalidDataValueException('listcontrol_selectedvalue_invalid',get_class($this),$value);
}
$this->_cachedSelectedValue=$value;
+ if($this->getAdapter() instanceof IListControlAdaptee)
+ $this->getAdapter()->setSelectedValue($value);
}
@@ -551,6 +558,9 @@ abstract class TListControl extends TDataBoundControl
throw new TInvalidDataValueException('listcontrol_selectedvalue_invalid',get_class($this),$value);
}
}
+
+ if($this->getAdapter() instanceof IListControlAdaptee)
+ $this->getAdapter()->setSelectedValues($values);
}
/**
@@ -579,6 +589,9 @@ abstract class TListControl extends TDataBoundControl
foreach($this->_items as $item)
$item->setSelected(false);
}
+
+ if($this->getAdapter() instanceof IListControlAdaptee)
+ $this->getAdapter()->clearSelection();
}
/**
@@ -707,13 +720,24 @@ class TListItemCollection extends TList
*/
public function createListItem($index=-1)
{
- $item=new TListItem;
+ $item=$this->createNewListItem();
if($index<0)
$this->add($item);
else
$this->insertAt($index,$item);
return $item;
}
+
+ /**
+ * @return TListItem new item.
+ */
+ protected function createNewListItem($text=null)
+ {
+ $item = new TListItem;
+ if(!is_null($text))
+ $item->setText($text);
+ return $item;
+ }
/**
* Inserts an item into the collection.
@@ -724,15 +748,11 @@ class TListItemCollection extends TList
*/
public function insertAt($index,$item)
{
- if($item instanceof TListItem)
- parent::insertAt($index,$item);
- else if(is_string($item))
- {
- $item=$this->createListItem($index);
- $item->setText($item);
- }
- else
+ if(is_string($item))
+ $item = $this->createNewListItem($item);
+ if(!($item instanceof TListItem))
throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this));
+ parent::insertAt($index,$item);
}
/**
@@ -824,4 +844,44 @@ class TListItemCollection extends TList
}
}
+/**
+ * IListControlAdapter interface
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ Sun Jun 25 04:53:43 EST 2006 $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.0
+ */
+interface IListControlAdaptee
+{
+ /**
+ * Selects an item based on zero-base index on the client side.
+ * @param integer the index (zero-based) of the item to be selected
+ */
+ public function setSelectedIndex($index);
+ /**
+ * Selects a list of item based on zero-base indices on the client side.
+ * @param array list of index of items to be selected
+ */
+ public function setSelectedIndices($indices);
+
+ /**
+ * Sets selection by item value on the client side.
+ * @param string the value of the item to be selected.
+ */
+ public function setSelectedValue($value);
+
+ /**
+ * Sets selection by a list of item values on the client side.
+ * @param array list of the selected item values
+ */
+ public function setSelectedValues($values);
+
+ /**
+ * Clears all existing selections on the client side.
+ */
+ public function clearSelection();
+}
+
+
?>