summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/TDataFieldAccessor.php16
-rw-r--r--framework/Web/UI/TTemplateManager.php43
-rw-r--r--framework/Web/UI/WebControls/TMultiView.php2
-rw-r--r--framework/Web/UI/WebControls/TWizard.php82
-rw-r--r--framework/core.php80
5 files changed, 170 insertions, 53 deletions
diff --git a/framework/Data/TDataFieldAccessor.php b/framework/Data/TDataFieldAccessor.php
index e0c87add..a28b9d1f 100644
--- a/framework/Data/TDataFieldAccessor.php
+++ b/framework/Data/TDataFieldAccessor.php
@@ -57,7 +57,12 @@ class TDataFieldAccessor
else if(is_object($data))
{
if(strpos($field,'.')===false) // simple field
- return call_user_func(array($data,'get'.$field));
+ {
+ if(property_exists($data,$field))
+ return $data->{$field};
+ else
+ return call_user_func(array($data,'get'.$field));
+ }
else // field in the format of xxx.yyy.zzz
{
$object=$data;
@@ -82,11 +87,12 @@ class TDataFieldAccessor
{
if(strpos($field,'.')===false) // simple field
{
- $getter='get'.$field;
- if(is_callable(array($data,$getter)))
- return call_user_func(array($data,$getter));
- else if(in_array($field, array_keys(get_object_vars($data))))
+ if(property_exists($data,$field))
return $data->{$field};
+ else if(is_callable(array($data,'get'.$field)))
+ return call_user_func(array($data,'get'.$field));
+ else
+ throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field);
}
else // field in the format of xxx.yyy.zzz
{
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 7c32e6a1..33c2edc5 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -704,13 +704,13 @@ class TTemplate extends TApplicationComponent implements ITemplate
{
// a subproperty, so the first segment must be readable
$subname=substr($name,0,$pos);
- if(!$class->containsMethod('get'.$subname))
+ if(!$class->hasMethod('get'.$subname))
throw new TConfigurationException('template_property_unknown',$type,$subname);
}
else if(strncasecmp($name,'on',2)===0)
{
// an event
- if(!$class->containsMethod($name))
+ if(!$class->hasMethod($name))
throw new TConfigurationException('template_event_unknown',$type,$name);
else if(!is_string($att))
throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
@@ -718,9 +718,9 @@ class TTemplate extends TApplicationComponent implements ITemplate
else
{
// a simple property
- if(!$class->containsMethod('set'.$name))
+ if(!$class->hasMethod('set'.$name))
{
- if($class->containsMethod('get'.$name))
+ if($class->hasMethod('get'.$name))
throw new TConfigurationException('template_property_readonly',$type,$name);
else
throw new TConfigurationException('template_property_unknown',$type,$name);
@@ -745,7 +745,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
{
// a subproperty, so the first segment must be readable
$subname=substr($name,0,$pos);
- if(!$class->containsMethod('get'.$subname))
+ if(!$class->hasMethod('get'.$subname))
throw new TConfigurationException('template_property_unknown',$type,$subname);
}
else if(strncasecmp($name,'on',2)===0)
@@ -753,9 +753,9 @@ class TTemplate extends TApplicationComponent implements ITemplate
else
{
// id is still alowed for TComponent, even if id property doesn't exist
- if(strcasecmp($name,'id')!==0 && !$class->containsMethod('set'.$name))
+ if(strcasecmp($name,'id')!==0 && !$class->hasMethod('set'.$name))
{
- if($class->containsMethod('get'.$name))
+ if($class->hasMethod('get'.$name))
throw new TConfigurationException('template_property_readonly',$type,$name);
else
throw new TConfigurationException('template_property_unknown',$type,$name);
@@ -768,33 +768,4 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
}
-/**
- * TReflectionClass class.
- * This class is written to cope with the incompatibility between 5.1+ and earlier versions.
- * It mainly provides a way to detect if a method exists for a given class name.
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Revision: $ $Date: $
- * @package System.Web.UI
- * @since 3.0
- */
-class TReflectionClass extends ReflectionClass
-{
- /**
- * @param string method name
- * @return boolean whether the method exists
- */
- public function containsMethod($method)
- {
- try
- {
- return $this->getMethod($method)!==null;
- }
- catch(Exception $e)
- {
- return false;
- }
- }
-}
-
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TMultiView.php b/framework/Web/UI/WebControls/TMultiView.php
index d44668f4..a88fbda7 100644
--- a/framework/Web/UI/WebControls/TMultiView.php
+++ b/framework/Web/UI/WebControls/TMultiView.php
@@ -139,7 +139,7 @@ class TMultiView extends TControl
{
if($view->getActive())
return;
- $triggerEvent=$this->getControlStage()>=TControl::CS_STATE_LOADED || !$this->getPage()->getIsPostBack();
+ $triggerEvent=$this->getControlStage()>=TControl::CS_STATE_LOADED || !$this->getPage() || !$this->getPage()->getIsPostBack();
foreach($this->getViews() as $v)
{
if($v===$view)
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index 0e2e6c41..52a11164 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -16,6 +16,10 @@ Prado::using('System.Web.UI.WebControls.TMultiView');
class TWizard extends TWebControl implements INamingContainer
{
/**
+ * @var TMultiView multiview that contains the wizard steps
+ */
+ private $_multiView=null;
+ /**
* @var mixed navigation template for the start step.
*/
private $_startNavigationTemplate=null;
@@ -35,26 +39,27 @@ class TWizard extends TWebControl implements INamingContainer
* @var mixed template for the side bar.
*/
private $_sideBarTemplate=null;
+ /**
+ * @var TWizardStepCollection
+ */
+ private $_wizardSteps=null;
/**
* @return string tag name for the wizard
*/
protected function getTagName()
{
- return 'table';
+ return 'div';
}
- // SideBarDataList, MultiView, History
- /**
- * Creates a style object for the wizard.
- * This method creates a {@link TTableStyle} to be used by the wizard.
- * @return TTableStyle control style to be used
- */
- protected function createStyle()
+ public function addParsedObject($object)
{
- return new TTableStyle;
+ if(is_object($object))
+ $this->getWizardSteps()->add($object);
}
+ // SideBarDataList, History
+
/**
* @return integer the cellspacing for the table used by wizard. Defaults to -1, meaning not set.
*/
@@ -117,6 +122,9 @@ class TWizard extends TWebControl implements INamingContainer
public function getWizardSteps()
{
+ if($this->_wizardSteps===null)
+ $this->_wizardSteps=new TWizardStepCollection($this);
+ return $this->_wizardSteps;
}
public function getTemplatedSteps()
@@ -477,6 +485,18 @@ class TWizard extends TWebControl implements INamingContainer
$this->raiseEvent('OnSideBarButtonClick',$this,$param);
}
+ protected function getMultiView()
+ {
+ if($this->_multiView===null)
+ {
+ $this->_multiView=new TMultiView;
+ $this->_multiView->setID('WizardMultiView');
+ // add handler to OnActiveViewChanged
+ // ignore bubble events
+ }
+ return $this->_multiView;
+ }
+
public function addedWizardStep($step)
{
if(($owner=$step->getOwner())!==null)
@@ -489,7 +509,7 @@ class TWizard extends TWebControl implements INamingContainer
//$this->getTemplateWizardSteps()->add($step);
// register it ???
}
- $this->onWizardStepsChanged();
+ //$this->wizardStepsChanged();
}
public function removedWizardStep($step)
@@ -501,7 +521,42 @@ class TWizard extends TWebControl implements INamingContainer
// $this->_templatedSteps....
//$this->getTemplateWizardSteps()->remove($step);
}
- $this->onWizardStepsChanged();
+ $this->wizardStepsChanged();
+ }
+
+ protected function createChildControls()
+ {
+ // side bar
+ if($this->getDisplaySideBar())
+ {
+ // render side bar here
+ }
+
+ // header
+ $header=new TPanel;
+ $header->setID('Header');
+ if(($template=$this->getHeaderTemplate())!==null)
+ $template->instantiateIn($header);
+ else
+ $header->getControls()->add($this->getHeaderText());
+
+ // steps
+ $content=new TPanel;
+ $content->setID('Content');
+ $content->getControls()->add($this->getMultiView());
+ $this->getMultiView()->setActiveViewIndex(0);
+ $this->getControls()->add($content);
+ // navigation
+ /*
+ $navigation=new TPanel;
+ $navigation->setID('Navigation');
+ $startNavigation=$this->createStartNavigation();
+ $stepNavigation=$this->createStepNavigation();
+ $finishNavigation=$this->createFinishNavigation();
+ $navigation->getControls()->add($startNavigation);
+ $navigation->getControls()->add($stepNavigation);
+ $navigation->getControls()->add($finishNavigation);
+ */
}
}
@@ -745,6 +800,11 @@ class TCompleteWizardStep extends TTemplateWizardStep
class TWizardStepCollection extends TList
{
/**
+ * @var TWizard
+ */
+ private $_wizard;
+
+ /**
* Constructor.
* @param TWizard wizard that owns this collection
*/
diff --git a/framework/core.php b/framework/core.php
index bac24ca2..56fe12e7 100644
--- a/framework/core.php
+++ b/framework/core.php
@@ -883,4 +883,84 @@ class TTextWriter extends TComponent implements ITextWriter
}
}
+if(version_compare(phpversion(),'5.1.0','>='))
+{
+ /**
+ * TReflectionClass class.
+ * This class is written to cope with the incompatibility between different PHP versions.
+ * It is equivalent to ReflectionClass if PHP version >= 5.1.0
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
+ */
+ class TReflectionClass extends ReflectionClass
+ {
+ }
+}
+else // PHP < 5.1.0
+{
+ /**
+ * TReflectionClass class.
+ * This class is written to cope with the incompatibility between different PHP versions.
+ * It mainly provides a way to detect if a method exists for a given class name.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
+ */
+ class TReflectionClass extends ReflectionClass
+ {
+ /**
+ * @param string method name
+ * @return boolean whether the method exists
+ */
+ public function hasMethod($method)
+ {
+ try
+ {
+ return $this->getMethod($method)!==null;
+ }
+ catch(Exception $e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @param string property name
+ * @return boolean whether the property exists
+ */
+ public function hasProperty($property)
+ {
+ try
+ {
+ return $this->getProperty($property)!==null;
+ }
+ catch(Exception $e)
+ {
+ return false;
+ }
+ }
+ }
+
+ if(!function_exists('property_exists'))
+ {
+ /**
+ * Detects whether an object contains the specified member variable.
+ * @param object
+ * @param string member variable (property) name
+ * @return boolean
+ */
+ function property_exists($object, $property)
+ {
+ if(is_object($object))
+ return array_key_exists($property, get_object_vars($object));
+ else
+ return false;
+ }
+ }
+}
+
?> \ No newline at end of file