summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Collections/TDummyDataSource.php12
-rw-r--r--framework/Collections/TList.php15
-rw-r--r--framework/Collections/TMap.php15
-rw-r--r--framework/Collections/TPagedDataSource.php12
-rw-r--r--framework/Collections/TStack.php12
-rw-r--r--framework/PradoBase.php86
-rw-r--r--framework/Web/THttpRequest.php12
-rw-r--r--framework/Web/THttpSession.php15
-rw-r--r--framework/Web/UI/TTemplateControl.php2
9 files changed, 90 insertions, 91 deletions
diff --git a/framework/Collections/TDummyDataSource.php b/framework/Collections/TDummyDataSource.php
index 46e625ab..d7fee4a9 100644
--- a/framework/Collections/TDummyDataSource.php
+++ b/framework/Collections/TDummyDataSource.php
@@ -26,7 +26,7 @@
* @package System.Collections
* @since 3.0
*/
-class TDummyDataSource extends TComponent implements IteratorAggregate
+class TDummyDataSource extends TComponent implements IteratorAggregate, Countable
{
private $_count;
@@ -54,6 +54,16 @@ class TDummyDataSource extends TComponent implements IteratorAggregate
{
return new TDummyDataSourceIterator($this->_count);
}
+
+ /**
+ * Returns the number of (virtual) items in the data source.
+ * This method is required by Countable interface.
+ * @return integer number of (virtual) items in the data source.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
}
/**
diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php
index 015781cb..1104ec47 100644
--- a/framework/Collections/TList.php
+++ b/framework/Collections/TList.php
@@ -25,9 +25,8 @@
* unset($list[$index]); // remove the item at $index
* if(isset($list[$index])) // if the list has an item at $index
* foreach($list as $index=>$item) // traverse each item in the list
+ * $n=count($list); // returns the number of items in the list
* </code>
- * Note, count($list) will always return 1. You should use {@link getCount()}
- * to determine the number of items in the list.
*
* To extend TList by doing additional operations with each addition or removal
* operation, override {@link insertAt()}, and {@link removeAt()}.
@@ -37,7 +36,7 @@
* @package System.Collections
* @since 3.0
*/
-class TList extends TComponent implements IteratorAggregate,ArrayAccess
+class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable
{
/**
* internal data storage
@@ -95,6 +94,16 @@ class TList extends TComponent implements IteratorAggregate,ArrayAccess
}
/**
+ * Returns the number of items in the list.
+ * This method is required by Countable interface.
+ * @return integer number of items in the list.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return integer the number of items in the list
*/
public function getCount()
diff --git a/framework/Collections/TMap.php b/framework/Collections/TMap.php
index e3a26e5f..ef393866 100644
--- a/framework/Collections/TMap.php
+++ b/framework/Collections/TMap.php
@@ -24,16 +24,15 @@
* unset($map[$key]); // remove the value with the specified key
* if(isset($map[$key])) // if the map contains the key
* foreach($map as $key=>$value) // traverse the items in the map
+ * $n=count($map); // returns the number of items in the map
* </code>
- * Note, count($map) will always return 1. You should use {@link getCount()}
- * to determine the number of items in the map.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Collections
* @since 3.0
*/
-class TMap extends TComponent implements IteratorAggregate,ArrayAccess
+class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable
{
/**
* @var array internal data storage
@@ -85,6 +84,16 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess
}
/**
+ * Returns the number of items in the map.
+ * This method is required by Countable interface.
+ * @return integer number of items in the map.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return integer the number of items in the map
*/
public function getCount()
diff --git a/framework/Collections/TPagedDataSource.php b/framework/Collections/TPagedDataSource.php
index 6192b1f7..a2bce9e3 100644
--- a/framework/Collections/TPagedDataSource.php
+++ b/framework/Collections/TPagedDataSource.php
@@ -28,7 +28,7 @@
* @package System.Collections
* @since 3.0
*/
-class TPagedDataSource extends TComponent implements IteratorAggregate
+class TPagedDataSource extends TComponent implements IteratorAggregate,Countable
{
/**
* @var mixed original data source
@@ -183,6 +183,16 @@ class TPagedDataSource extends TComponent implements IteratorAggregate
}
/**
+ * Returns the number of items in the current page.
+ * This method is required by Countable interface.
+ * @return integer number of items in the current page.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return integer number of pages
*/
public function getPageCount()
diff --git a/framework/Collections/TStack.php b/framework/Collections/TStack.php
index 79d17902..f1118d90 100644
--- a/framework/Collections/TStack.php
+++ b/framework/Collections/TStack.php
@@ -31,7 +31,7 @@
* @package System.Collections
* @since 3.0
*/
-class TStack extends TComponent implements IteratorAggregate
+class TStack extends TComponent implements IteratorAggregate,Countable
{
/**
* internal data storage
@@ -160,6 +160,16 @@ class TStack extends TComponent implements IteratorAggregate
{
return $this->_c;
}
+
+ /**
+ * Returns the number of items in the stack.
+ * This method is required by Countable interface.
+ * @return integer number of items in the stack.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
}
/**
diff --git a/framework/PradoBase.php b/framework/PradoBase.php
index efac53ac..6ce6ad0d 100644
--- a/framework/PradoBase.php
+++ b/framework/PradoBase.php
@@ -563,86 +563,16 @@ class PradoBase
}
/**
- * The following code is meant to fill the gaps between different PHP versions.
+ * TReflectionClass class.
+ * This class was originally written to cope with the incompatibility between different PHP versions.
+ * It is equivalent to ReflectionClass for PHP version >= 5.1.0
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
*/
-if(version_compare(phpversion(),'5.1.0','>='))
+class TReflectionClass extends ReflectionClass
{
- /**
- * 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
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index d251f6ab..130dc3cf 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -57,7 +57,7 @@
* @package System.Web
* @since 3.0
*/
-class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,IModule
+class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
{
/**
* Separator used to separate GET variable name and value when URL format is Path.
@@ -661,6 +661,16 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * Returns the number of items in the request.
+ * This method is required by Countable interface.
+ * @return integer number of items in the request.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return array the key list
*/
public function getKeys()
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php
index 4439cf57..19473cda 100644
--- a/framework/Web/THttpSession.php
+++ b/framework/Web/THttpSession.php
@@ -61,7 +61,7 @@
* @package System.Web
* @since 3.0
*/
-class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,IModule
+class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
{
/**
* @var boolean whether this module has been initialized
@@ -139,7 +139,8 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc'));
if($this->_cookie!==null)
session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure());
- session_start();
+ if(ini_get('session.auto_start')!=='1')
+ session_start();
$this->_started=true;
}
}
@@ -487,6 +488,16 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * Returns the number of items in the session.
+ * This method is required by Countable interface.
+ * @return integer number of items in the session.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return array the list of session variable names
*/
public function getKeys()
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index c7364d4b..3bbe52c5 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -129,7 +129,7 @@ class TTemplateControl extends TCompositeControl
*/
public function createChildControls()
{
- if($tpl=$this->getTemplate(true))
+ if($tpl=$this->getTemplate())
{
foreach($tpl->getDirective() as $name=>$value)
{