summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-06-04 15:33:50 +0000
committerxue <>2006-06-04 15:33:50 +0000
commit502676c24a6889051b82de1697596ccfeed77f65 (patch)
tree05db722d7fbdc61de918ac38cf3f5e7a524dc514
parentaf6a5a01a2d847a38189bb471c541eb1e7593bc7 (diff)
Some minor documentation change.
Changed TControl::onBubbleEvent() to TControl::bubbleEvent()
-rw-r--r--HISTORY1
-rw-r--r--UPGRADE2
-rw-r--r--framework/TApplicationComponent.php2
-rw-r--r--framework/TComponent.php130
-rw-r--r--framework/Web/UI/TControl.php9
-rw-r--r--framework/Web/UI/WebControls/TDataBoundControl.php8
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php11
-rw-r--r--framework/Web/UI/WebControls/TDataList.php6
-rw-r--r--framework/Web/UI/WebControls/TMultiView.php2
-rw-r--r--framework/Web/UI/WebControls/TRepeater.php6
-rw-r--r--framework/Web/UI/WebControls/TWizard.php2
11 files changed, 106 insertions, 73 deletions
diff --git a/HISTORY b/HISTORY
index 030aaac3..d84c9187 100644
--- a/HISTORY
+++ b/HISTORY
@@ -25,6 +25,7 @@ ENH: refactored TUserManager and TAuthManager so that they are easier to be exte
ENH: template syntax now supports setting event handler via subproperties (Qiang)
CHG: Ticket#151 - URL format is modified to handle empty GET values (Qiang)
CHG: Ticket#153 - TAssetManager now ignores .svn directories (Qiang)
+CHG: Changed TControl::onBubbleEvent() to TControl::bubbleEvent() (Qiang)
NEW: TTableHeaderRow, TTableFooterRow and table section support (Qiang)
NEW: TCompositeControl (Qiang)
NEW: TTextProcessor (Qiang)
diff --git a/UPGRADE b/UPGRADE
index 478da933..f4dbc2d4 100644
--- a/UPGRADE
+++ b/UPGRADE
@@ -23,6 +23,8 @@ Upgrading from v3.0.0
/index.php/ServiceID,ServiceParam/Name1,Value1/Name2,Value2/...
In v3.0.0, the above URL is written as:
/index.php/ServiceID/ServiceParam/Name1/Value1/Name2/Value2/...
+- TControl::onBubbleEvent() has been changed to TControl::bubbleEvent().
+ This change only affects user controls that override this method.
Upgrading from v3.0.0 RC2
-------------------------
diff --git a/framework/TApplicationComponent.php b/framework/TApplicationComponent.php
index 580f1d33..bd4f0db0 100644
--- a/framework/TApplicationComponent.php
+++ b/framework/TApplicationComponent.php
@@ -75,7 +75,7 @@ class TApplicationComponent extends TComponent
}
/**
- * @return IUser user
+ * @return IUser information about the current user
*/
public function getUser()
{
diff --git a/framework/TComponent.php b/framework/TComponent.php
index 103b041e..7564edff 100644
--- a/framework/TComponent.php
+++ b/framework/TComponent.php
@@ -582,12 +582,8 @@ class TEventParameter extends TComponent
/**
* TComponentReflection class.
*
- * TComponentReflection provides functionalities to inspect the properties and events
- * defined in a component. It shows the definition of component properties, including
- * their name, type, writability and defining class. It also shows the definition
- * of component events, including their name and defining class.
- *
- * Note, only public properties and events are displayed.
+ * TComponentReflection provides functionalities to inspect the public/protected
+ * properties, events and methods defined in a class.
*
* The following code displays the properties and events defined in {@link TDataGrid},
* <code>
@@ -606,74 +602,99 @@ class TComponentReflection extends TComponent
private $_className;
private $_properties=array();
private $_events=array();
+ private $_methods=array();
/**
* Constructor.
- * @param TComponent|string the component instance or the class name
+ * @param object|string the component instance or the class name
* @throws TInvalidDataTypeException if the object is not a component
*/
public function __construct($component)
{
- if(is_string($component))
+ if(is_string($component) && class_exists($component,false))
$this->_className=$component;
- else if($component instanceof TComponent)
+ else if(is_object($component))
$this->_className=get_class($component);
else
throw new TInvalidDataTypeException('componentreflection_class_invalid');
$this->reflect();
}
+ private function isPropertyMethod($method)
+ {
+ $methodName=$method->getName();
+ return $method->getNumberOfRequiredParameters()===0
+ && strncasecmp($methodName,'get',3)===0
+ && isset($methodName[3]);
+ }
+
+ private function isEventMethod($method)
+ {
+ $methodName=$method->getName();
+ return strncasecmp($methodName,'on',2)===0
+ && isset($methodName[2]);
+ }
+
private function reflect()
{
$class=new TReflectionClass($this->_className);
- $methods=$class->getMethods();
$properties=array();
$events=array();
- foreach($methods as $method)
+ $methods=array();
+ $isComponent=is_subclass_of($this->_className,'TComponent') || strcasecmp($this->_className,'TComponent')===0;
+ foreach($class->getMethods() as $method)
{
- if($method->isPublic() && !$method->isStatic())
+ if($method->isPublic() || $method->isProtected())
{
$methodName=$method->getName();
- if($method->getNumberOfRequiredParameters()===0 && strncasecmp($methodName,'get',3)===0 && isset($methodName[3]))
+ if(!$method->isStatic() && $isComponent)
{
- $propertyName=substr($methodName,3);
- $readOnly=!$class->hasMethod('set'.$propertyName);
- $methodClass=$method->getDeclaringClass()->getName();
- $properties[$methodClass][$propertyName]=$method;
- }
- else if(strncasecmp($methodName,'on',2)===0 && isset($methodName[2]))
- {
- $methodName[0]='O';
- $methodClass=$method->getDeclaringClass()->getName();
- $events[$methodClass][$methodName]=$method;
+ if($this->isPropertyMethod($method))
+ $properties[substr($methodName,3)]=$method;
+ else if($this->isEventMethod($method))
+ {
+ $methodName[0]='O';
+ $events[$methodName]=$method;
+ }
}
+ if(strncmp($methodName,'__',2)!==0)
+ $methods[$methodName]=$method;
}
}
- foreach($properties as $className=>$props)
+ $reserved=array();
+ ksort($properties);
+ foreach($properties as $name=>$method)
{
- ksort($props);
- foreach($props as $name=>$method)
- {
- $this->_properties[]=array(
- 'name'=>$name,
- 'type'=>$this->determinePropertyType($method),
- 'readonly'=>!$class->hasMethod('set'.$name),
- 'class'=>$className,
- 'comments'=>$method->getDocComment()
- );
- }
+ $this->_properties[$name]=array(
+ 'type'=>$this->determinePropertyType($method),
+ 'readonly'=>!$class->hasMethod('set'.$name),
+ 'protected'=>$method->isProtected(),
+ 'class'=>$method->getDeclaringClass()->getName(),
+ 'comments'=>$method->getDocComment()
+ );
+ $reserved['get'.strtolower($name)]=1;
+ $reserved['set'.strtolower($name)]=1;
}
- foreach($events as $className=>$evts)
+ ksort($events);
+ foreach($events as $name=>$method)
{
- ksort($evts);
- foreach($evts as $name=>$method)
- {
- $this->_events[]=array(
- 'name'=>$name,
- 'class'=>$className,
+ $this->_events[$name]=array(
+ 'class'=>$method->getDeclaringClass()->getName(),
+ 'protected'=>$method->isProtected(),
+ 'comments'=>$method->getDocComment()
+ );
+ $reserved[strtolower($name)]=1;
+ }
+ ksort($methods);
+ foreach($methods as $name=>$method)
+ {
+ if(!isset($reserved[strtolower($name)]))
+ $this->_methods[$name]=array(
+ 'class'=>$method->getDeclaringClass()->getName(),
+ 'protected'=>$method->isProtected(),
+ 'static'=>$method->isStatic(),
'comments'=>$method->getDocComment()
);
- }
}
}
@@ -701,10 +722,11 @@ class TComponentReflection extends TComponent
}
/**
- * @return array list of component properties. Each array element is of the following structure:
- * [name]=>property name,
+ * @return array list of component properties. Array keys are property names.
+ * Each array element is of the following structure:
* [type]=>property type,
* [readonly]=>whether the property is read-only,
+ * [protected]=>whether the method is protected or not
* [class]=>the class where the property is inherited from,
* [comments]=>comments associated with the property.
*/
@@ -714,8 +736,9 @@ class TComponentReflection extends TComponent
}
/**
- * @return array list of component events. Each array element is of the following structure:
- * [name]=>event name,
+ * @return array list of component events. Array keys are event names.
+ * Each array element is of the following structure:
+ * [protected]=>whether the event is protected or not
* [class]=>the class where the event is inherited from.
* [comments]=>comments associated with the event.
*/
@@ -723,6 +746,19 @@ class TComponentReflection extends TComponent
{
return $this->_events;
}
+
+ /**
+ * @return array list of public/protected methods. Array keys are method names.
+ * Each array element is of the following structure:
+ * [protected]=>whether the method is protected or not
+ * [static]=>whether the method is static or not
+ * [class]=>the class where the property is inherited from,
+ * [comments]=>comments associated with the event.
+ */
+ public function getMethods()
+ {
+ return $this->_methods;
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 36cc34dd..21065ae6 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -590,6 +590,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
}
/**
+ * Sets a custom control attribute.
* @param string attribute name
* @param string value of the attribute
*/
@@ -1315,18 +1316,18 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
}
/**
- * Invokes the parent's onBubbleEvent method.
+ * Invokes the parent's bubbleEvent method.
* A control who wants to bubble an event must call this method in its onEvent method.
* @param TControl sender of the event
* @param TEventParameter event parameter
- * @see onBubbleEvent
+ * @see bubbleEvent
*/
protected function raiseBubbleEvent($sender,$param)
{
$control=$this;
while($control=$control->_parent)
{
- if($control->onBubbleEvent($sender,$param))
+ if($control->bubbleEvent($sender,$param))
break;
}
}
@@ -1340,7 +1341,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
* @return boolean true if the event bubbling is handled and no more bubbling.
* @see raiseBubbleEvent
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
return false;
}
diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php
index 9e6ecbf3..09023b66 100644
--- a/framework/Web/UI/WebControls/TDataBoundControl.php
+++ b/framework/Web/UI/WebControls/TDataBoundControl.php
@@ -128,7 +128,7 @@ abstract class TDataBoundControl extends TWebControl
}
/**
- * @return boolean if databind has been invoked in the previous page request
+ * @return boolean whether databind has been invoked in the previous page request
*/
protected function getIsDataBound()
{
@@ -272,7 +272,7 @@ abstract class TDataBoundControl extends TWebControl
}
/**
- * Sets page's <b>OnPreLoad</b> event handler as {@link onPagePreLoad}.
+ * Sets page's <b>OnPreLoad</b> event handler as {@link pagePreLoad}.
* If viewstate is disabled and the current request is a postback,
* {@link setRequiresDataBinding RequiresDataBinding} will be set true.
* This method overrides the parent implementation.
@@ -282,7 +282,7 @@ abstract class TDataBoundControl extends TWebControl
{
parent::onInit($param);
$page=$this->getPage();
- $page->attachEventHandler('OnPreLoad',array($this,'onPagePreLoad'));
+ $page->attachEventHandler('OnPreLoad',array($this,'pagePreLoad'));
}
/**
@@ -291,7 +291,7 @@ abstract class TDataBoundControl extends TWebControl
* @param mixed event sender
* @param TEventParameter event parameter
*/
- public function onPagePreLoad($sender,$param)
+ public function pagePreLoad($sender,$param)
{
$this->_initialized=true;
$isPostBack=$this->getPage()->getIsPostBack();
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index 82c243ca..d2625c0d 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -217,7 +217,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
/**
- * @return TDataGridColumnCollection automatically specified datagrid columns
+ * @return TDataGridColumnCollection automatically generated datagrid columns
*/
public function getAutoColumns()
{
@@ -683,7 +683,6 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
/**
- * Handles <b>OnBubbleEvent</b>.
* This method overrides parent's implementation to handle
* {@link onItemCommand OnItemCommand} event which is bubbled from
* {@link TDataGridItem} child controls.
@@ -696,7 +695,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TDataGridCommandEventParameter)
{
@@ -1890,14 +1889,13 @@ class TDataGridItem extends TTableRow implements INamingContainer
}
/**
- * Handles <b>BubbleEvent</b>.
* This method overrides parent's implementation by wrapping event parameter
* for <b>OnCommand</b> event with item information.
* @param TControl the sender of the event
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TCommandEventParameter)
{
@@ -1934,14 +1932,13 @@ class TDataGridPager extends TPanel implements INamingContainer
}
/**
- * Handles <b>BubbleEvent</b>.
* This method overrides parent's implementation by wrapping event parameter
* for <b>OnCommand</b> event with item information.
* @param TControl the sender of the event
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TCommandEventParameter)
{
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php
index 695d072a..0bec8921 100644
--- a/framework/Web/UI/WebControls/TDataList.php
+++ b/framework/Web/UI/WebControls/TDataList.php
@@ -635,7 +635,6 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
}
/**
- * Handles <b>BubbleEvent</b>.
* This method overrides parent's implementation to handle
* {@link onItemCommand OnItemCommand} event which is bubbled from
* {@link TDataListItem} child controls.
@@ -648,7 +647,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TDataListCommandEventParameter)
{
@@ -1356,14 +1355,13 @@ class TDataListItem extends TWebControl implements INamingContainer
}
/**
- * Handles <b>BubbleEvent</b>.
* This method overrides parent's implementation by wrapping event parameter
* for <b>Command</b> event with item information.
* @param TControl the sender of the event
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TCommandEventParameter)
{
diff --git a/framework/Web/UI/WebControls/TMultiView.php b/framework/Web/UI/WebControls/TMultiView.php
index 59b9f53d..b6001f90 100644
--- a/framework/Web/UI/WebControls/TMultiView.php
+++ b/framework/Web/UI/WebControls/TMultiView.php
@@ -213,7 +213,7 @@ class TMultiView extends TControl
* @param mixed event parameter
* @return boolean whether this event is handled
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if(!$this->_ignoreBubbleEvents && ($param instanceof TCommandEventParameter))
{
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php
index 9aa7af8d..2070cb1a 100644
--- a/framework/Web/UI/WebControls/TRepeater.php
+++ b/framework/Web/UI/WebControls/TRepeater.php
@@ -463,7 +463,6 @@ class TRepeater extends TDataBoundControl implements INamingContainer
}
/**
- * Handles <b>BubbleEvent</b>.
* This method overrides parent's implementation to handle
* {@link onItemCommand OnItemCommand} event which is bubbled from
* {@link TRepeaterItem} child controls.
@@ -472,7 +471,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TRepeaterCommandEventParameter)
{
@@ -717,14 +716,13 @@ class TRepeaterItem extends TControl implements INamingContainer
}
/**
- * Handles <b>BubbleEvent</b>.
* This method overrides parent's implementation by wrapping event parameter
* for <b>Command</b> event with item information.
* @param TControl the sender of the event
* @param TEventParameter event parameter
* @return boolean whether the event bubbling should stop here.
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TCommandEventParameter)
{
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index 2cc3f346..f92742e7 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -1333,7 +1333,7 @@ class TWizard extends TWebControl implements INamingContainer
* @param TEventParameter event parameter
* @throws TInvalidDataValueException if a navigation command is associated with an invalid parameter
*/
- public function onBubbleEvent($sender,$param)
+ public function bubbleEvent($sender,$param)
{
if($param instanceof TCommandEventParameter)
{