From 3d437d9dcd37dc901f53ca3322ba118851e3c676 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Wed, 17 May 2006 21:24:40 +0000
Subject: Merge from 3.0 branch till 1073.
---
framework/Web/THttpSession.php | 12 +++---
framework/Web/UI/TThemeManager.php | 9 +++++
framework/Web/UI/WebControls/TDatePicker.php | 4 +-
framework/Web/UI/WebControls/TListControl.php | 58 ++++++++++++++++++---------
4 files changed, 55 insertions(+), 28 deletions(-)
(limited to 'framework')
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php
index 13526dd1..379bc7b6 100644
--- a/framework/Web/THttpSession.php
+++ b/framework/Web/THttpSession.php
@@ -401,7 +401,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
/**
* Session open handler.
- * This method should be overriden if session Storage is set as 'user'.
+ * This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @param string session save path
* @param string session name
* @return boolean whether session is opened successfully
@@ -413,7 +413,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
/**
* Session close handler.
- * This method should be overriden if session Storage is set as 'user'.
+ * This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @return boolean whether session is closed successfully
*/
public function _close()
@@ -423,7 +423,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
/**
* Session read handler.
- * This method should be overriden if session Storage is set as 'user'.
+ * This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @param string session ID
* @return string the session data
*/
@@ -434,7 +434,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
/**
* Session write handler.
- * This method should be overriden if session Storage is set as 'user'.
+ * This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @param string session ID
* @param string session data
* @return boolean whether session write is successful
@@ -446,7 +446,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
/**
* Session destroy handler.
- * This method should be overriden if session Storage is set as 'user'.
+ * This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @param string session ID
* @return boolean whether session is destroyed successfully
*/
@@ -457,7 +457,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
/**
* Session GC (garbage collection) handler.
- * This method should be overriden if session Storage is set as 'user'.
+ * This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @param integer the number of seconds after which data will be seen as 'garbage' and cleaned up.
* @return boolean whether session is GCed successfully
*/
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php
index c351bcdb..6a908759 100644
--- a/framework/Web/UI/TThemeManager.php
+++ b/framework/Web/UI/TThemeManager.php
@@ -207,6 +207,7 @@ class TTheme extends TApplicationComponent implements ITheme
public function __construct($themePath,$themeUrl)
{
$this->_themeUrl=$themeUrl;
+ $this->_themePath=realpath($themePath);
$this->_name=basename($themePath);
$cacheValid=false;
// TODO: the following needs to be cleaned up (Qiang)
@@ -308,6 +309,14 @@ class TTheme extends TApplicationComponent implements ITheme
return $this->_themeUrl;
}
+ /**
+ * @return string the file path to the theme folder
+ */
+ public function getBasePath()
+ {
+ return $this->_themePath;
+ }
+
/**
* Applies the theme to a particular control.
* The control's class name and SkinID value will be used to
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 02386515..59a71c90 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -50,7 +50,7 @@ Prado::using('System.Web.UI.WebControls.TTextBox');
* ButtonText property
* # ImageButton -- Shows an image next to the text input, clicking on
* the image shows the date picker, image source can be
- * change through the ImageUrl property.
+ * change through the ButtonImageUrl property.
*
* The CssClass property can be used to override the css class name
* for the date picker panel. CalendarStyle property sets the packages
@@ -712,4 +712,4 @@ class TDatePicker extends TTextBox
}
}
-?>
\ No newline at end of file
+?>
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 1c7fe11b..f97eb307 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -182,7 +182,7 @@ abstract class TListControl extends TDataBoundControl
$textFormat=$this->getDataTextFormatString();
foreach($data as $key=>$object)
{
- $item=new TListItem;
+ $item=$items->createListItem();
if(is_array($object) || is_object($object))
{
$text=TDataFieldAccessor::getDataFieldValue($object,$textField);
@@ -195,7 +195,6 @@ abstract class TListControl extends TDataBoundControl
$item->setValue("$key");
}
$item->setText($this->formatDataValue($textFormat,$text));
- $items->add($item);
}
// SelectedValue or SelectedIndex may be set before databinding
// so we make them be effective now
@@ -215,6 +214,16 @@ abstract class TListControl extends TDataBoundControl
}
}
+ /**
+ * Creates a collection object to hold list items.
+ * This method may be overriden to create a customized collection.
+ * @return TListItemCollection the collection object
+ */
+ protected function createListItemCollection()
+ {
+ return new TListItemCollection;
+ }
+
/**
* Saves items into viewstate.
* This method is invoked right before control state is to be saved.
@@ -238,7 +247,7 @@ abstract class TListControl extends TDataBoundControl
$this->_stateLoaded=true;
if(!$this->getIsDataBound())
{
- $this->_items=new TListItemCollection;
+ $this->_items=$this->createListItemCollection();
$this->_items->loadState($this->getViewState('Items',null));
}
$this->clearViewState('Items');
@@ -379,7 +388,7 @@ abstract class TListControl extends TDataBoundControl
public function getItems()
{
if(!$this->_items)
- $this->_items=new TListItemCollection;
+ $this->_items=$this->createListItemCollection();
return $this->_items;
}
@@ -636,6 +645,23 @@ abstract class TListControl extends TDataBoundControl
*/
class TListItemCollection extends TList
{
+ /**
+ * Creates a list item object.
+ * This method may be overriden to provide a customized list item object.
+ * @param integer index where the newly created item is to be inserted at.
+ * If -1, the item will be appended to the end.
+ * @return TListItem list item object
+ */
+ public function createListItem($index=-1)
+ {
+ $item=new TListItem;
+ if($index<0)
+ $this->add($item);
+ else
+ $this->insertAt($index,$item);
+ return $item;
+ }
+
/**
* Inserts an item into the collection.
* @param integer the location where the item will be inserted.
@@ -645,10 +671,13 @@ class TListItemCollection extends TList
*/
public function insertAt($index,$item)
{
- if(is_string($item))
- parent::insertAt($index,new TListItem($item));
- else if($item instanceof TListItem)
+ if($item instanceof TListItem)
parent::insertAt($index,$item);
+ else if(is_string($item))
+ {
+ $item=$this->createListItem($index);
+ $item->setText($item);
+ }
else
throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this));
}
@@ -728,10 +757,7 @@ class TListItemCollection extends TList
{
$this->clear();
if($state!==null)
- {
- foreach($state as $item)
- $this->add(new TListItem($item[0],$item[1],$item[2],$item[3]));
- }
+ $this->copyFrom($state);
}
/**
@@ -741,15 +767,7 @@ class TListItemCollection extends TList
*/
public function saveState()
{
- if($this->getCount()>0)
- {
- $state=array();
- foreach($this as $item)
- $state[]=array($item->getText(),$item->getValue(),$item->getEnabled(),$item->getSelected());
- return $state;
- }
- else
- return null;
+ return ($this->getCount()>0) ? $this->toArray() : null;
}
}
--
cgit v1.2.3