diff options
Diffstat (limited to 'framework')
303 files changed, 2995 insertions, 1867 deletions
diff --git a/framework/3rdParty/TinyMCE/tiny_mce.md5 b/framework/3rdParty/TinyMCE/tiny_mce.md5 index a5b8fc8e..bf138c10 100644 --- a/framework/3rdParty/TinyMCE/tiny_mce.md5 +++ b/framework/3rdParty/TinyMCE/tiny_mce.md5 @@ -1 +1 @@ -6f0b8991531854895cb4461d218023bd tiny_mce.tar +cf8b1ec3fc54577b1d834772ddecfc2e tiny_mce.tar diff --git a/framework/3rdParty/TinyMCE/tiny_mce.tar b/framework/3rdParty/TinyMCE/tiny_mce.tar Binary files differindex b4e9060d..beb06fb9 100644 --- a/framework/3rdParty/TinyMCE/tiny_mce.tar +++ b/framework/3rdParty/TinyMCE/tiny_mce.tar diff --git a/framework/Caching/TAPCCache.php b/framework/Caching/TAPCCache.php index 057d7585..5935e732 100644 --- a/framework/Caching/TAPCCache.php +++ b/framework/Caching/TAPCCache.php @@ -131,4 +131,3 @@ class TAPCCache extends TCache }
}
-?> diff --git a/framework/Caching/TCache.php b/framework/Caching/TCache.php index 27618e84..02a4ae3b 100644 --- a/framework/Caching/TCache.php +++ b/framework/Caching/TCache.php @@ -4,7 +4,7 @@ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Caching
@@ -136,7 +136,8 @@ abstract class TCache extends TModule implements ICache, ArrayAccess /**
* Stores a value identified by a key into cache.
* If the cache already contains such a key, the existing value and
- * expiration time will be replaced with the new ones.
+ * expiration time will be replaced with the new ones. If the value is
+ * empty, the cache key will be deleted.
*
* @param string the key identifying the value to be cached
* @param mixed the value to be cached
@@ -146,13 +147,18 @@ abstract class TCache extends TModule implements ICache, ArrayAccess */
public function set($id,$value,$expire=0,$dependency=null)
{
- $data=array($value,$dependency);
- return $this->setValue($this->generateUniqueKey($id),serialize($data),$expire);
+ if(empty($value) && $expire === 0)
+ $this->delete($id);
+ else
+ {
+ $data=array($value,$dependency);
+ return $this->setValue($this->generateUniqueKey($id),serialize($data),$expire);
+ }
}
/**
* Stores a value identified by a key into cache if the cache does not contain this key.
- * Nothing will be done if the cache already contains the key.
+ * Nothing will be done if the cache already contains the key or if value is empty.
* @param string the key identifying the value to be cached
* @param mixed the value to be cached
* @param integer the number of seconds in which the cached value will expire. 0 means never expire.
@@ -161,6 +167,8 @@ abstract class TCache extends TModule implements ICache, ArrayAccess */
public function add($id,$value,$expire=0,$dependency=null)
{
+ if(empty($value) && $expire === 0)
+ return false;
$data=array($value,$dependency);
return $this->addValue($this->generateUniqueKey($id),serialize($data),$expire);
}
@@ -710,4 +718,4 @@ class TCacheDependencyList extends TList }
}
-?> +?>
diff --git a/framework/Caching/TMemCache.php b/framework/Caching/TMemCache.php index b6e9c7d8..0f0ac26d 100644 --- a/framework/Caching/TMemCache.php +++ b/framework/Caching/TMemCache.php @@ -307,4 +307,3 @@ class TMemCache extends TCache } } -?> diff --git a/framework/Caching/TSqliteCache.php b/framework/Caching/TSqliteCache.php index 4d41542c..ca8d2261 100644 --- a/framework/Caching/TSqliteCache.php +++ b/framework/Caching/TSqliteCache.php @@ -221,4 +221,3 @@ class TSqliteCache extends TCache }
}
-?> diff --git a/framework/Collections/TAttributeCollection.php b/framework/Collections/TAttributeCollection.php index 6b35d70e..93a48e1c 100644 --- a/framework/Collections/TAttributeCollection.php +++ b/framework/Collections/TAttributeCollection.php @@ -170,4 +170,3 @@ class TAttributeCollection extends TMap }
}
-?> diff --git a/framework/Collections/TDummyDataSource.php b/framework/Collections/TDummyDataSource.php index ef11b286..491c36c0 100644 --- a/framework/Collections/TDummyDataSource.php +++ b/framework/Collections/TDummyDataSource.php @@ -144,4 +144,3 @@ class TDummyDataSourceIterator implements Iterator }
}
-?> diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php index 329e162f..50cbaf01 100644 --- a/framework/Collections/TList.php +++ b/framework/Collections/TList.php @@ -427,4 +427,3 @@ class TListIterator implements Iterator }
}
-?> diff --git a/framework/Collections/TMap.php b/framework/Collections/TMap.php index 42f57890..56748ea2 100644 --- a/framework/Collections/TMap.php +++ b/framework/Collections/TMap.php @@ -350,4 +350,3 @@ class TMapIterator implements Iterator return $this->_key!==false;
}
}
-?> diff --git a/framework/Collections/TPagedDataSource.php b/framework/Collections/TPagedDataSource.php index 3db4882a..fcb17f53 100644 --- a/framework/Collections/TPagedDataSource.php +++ b/framework/Collections/TPagedDataSource.php @@ -444,4 +444,3 @@ class TPagedMapIterator implements Iterator }
}
-?> diff --git a/framework/Collections/TPagedList.php b/framework/Collections/TPagedList.php index a2a2aa14..50286aec 100644 --- a/framework/Collections/TPagedList.php +++ b/framework/Collections/TPagedList.php @@ -475,4 +475,3 @@ class TPagedListFetchDataEventParameter extends TEventParameter }
}
-?> diff --git a/framework/Collections/TQueue.php b/framework/Collections/TQueue.php index 856b12ff..d8b692d1 100644 --- a/framework/Collections/TQueue.php +++ b/framework/Collections/TQueue.php @@ -261,4 +261,3 @@ class TQueueIterator implements Iterator }
}
-?> diff --git a/framework/Collections/TStack.php b/framework/Collections/TStack.php index 58394a8a..0d3890b4 100644 --- a/framework/Collections/TStack.php +++ b/framework/Collections/TStack.php @@ -260,4 +260,3 @@ class TStackIterator implements Iterator }
}
-?> diff --git a/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php b/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php index be88f015..eaab5735 100644 --- a/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php +++ b/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php @@ -39,4 +39,3 @@ class TActiveRecordConfigurationException extends TActiveRecordException }
-?> diff --git a/framework/Data/ActiveRecord/Exceptions/messages.txt b/framework/Data/ActiveRecord/Exceptions/messages.txt index fabfc1a4..0702c840 100644 --- a/framework/Data/ActiveRecord/Exceptions/messages.txt +++ b/framework/Data/ActiveRecord/Exceptions/messages.txt @@ -10,6 +10,7 @@ ar_primary_key_is_scalar = Primary key '{1}' in table '{0}' is NOT a composi ar_invalid_db_connection = Missing or invalid default database connection for ActiveRecord class '{0}', default connection is set by the DbConnection property of TActiveRecordManager.
ar_mismatch_args_exception = ActiveRecord finder method '{0}' expects {1} parameters but found only {2} parameters instead.
ar_invalid_tablename_property = Constant {0}::{1} must be a valid database table name.
+ar_invalid_tablename_method = Method {0}::{1} must return a valid database table name.
ar_value_must_not_be_null = Property '{0}::${2}' must not be null as defined by column '{2}' in table '{1}'.
ar_missing_pk_values = Missing primary key values in forming IN(key1, key2, ...) for table '{0}'.
ar_pk_value_count_mismatch = Composite key value count mismatch in forming IN( (key1, key2, ..), (key3, key4, ..)) for table '{0}'.
@@ -21,4 +22,4 @@ ar_invalid_criteria = Invalid criteria object, must be a string or instanc ar_relations_undefined = Unable to determine Active Record relationships because static array property {0}::${1} is not defined.
ar_undefined_relation_prop = Unable to find {1}::${2}['{0}'], Active Record relationship definition for property "{0}" not found in entries of {1}::${2}.
ar_invalid_relationship = Invalid active record relationship.
-ar_relations_missing_fk = Unable to find foreign key relationships in table '{0}' that corresponds to table '{1}'.
\ No newline at end of file +ar_relations_missing_fk = Unable to find foreign key relationships in table '{0}' that corresponds to table '{1}'.
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php b/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php index 9f8777e2..40936011 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php @@ -136,4 +136,3 @@ class TActiveRecordBelongsTo extends TActiveRecordRelation }
}
-?> diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php index c66afa14..6f191b9f 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php @@ -119,4 +119,3 @@ class TActiveRecordHasMany extends TActiveRecordRelation }
}
-?> diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php index 9b01d323..4c71f91c 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php @@ -374,4 +374,3 @@ class TActiveRecordHasManyAssociation extends TActiveRecordRelation return $data;
}
}
-?> diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php index 6e8d30de..b1aa7b91 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php @@ -143,4 +143,3 @@ class TActiveRecordHasOne extends TActiveRecordRelation }
}
-?> diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php index 4044a5ce..a352cb07 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php @@ -247,4 +247,3 @@ abstract class TActiveRecordRelation }
}
-?> diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php index 329007af..696bb5b1 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php @@ -228,4 +228,3 @@ class TActiveRecordRelationContext }
}
-?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php index 05de2019..c8177d5e 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php @@ -49,4 +49,3 @@ class TIbmScaffoldInput extends TScaffoldInputCommon } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php index bca1bcb2..be495e98 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php @@ -51,4 +51,3 @@ class TMssqlScaffoldInput extends TScaffoldInputCommon } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php index a8ecdd13..c06e4113 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php @@ -81,4 +81,3 @@ class TMysqlScaffoldInput extends TScaffoldInputCommon } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php index 69b67e7f..cd244b27 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php @@ -52,4 +52,3 @@ class TPgsqlScaffoldInput extends TScaffoldInputCommon } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php index ad563f2f..d8db9c59 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php @@ -101,4 +101,3 @@ class TScaffoldInputBase } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php index 12f9bc25..d02bc9a0 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php @@ -307,4 +307,3 @@ class TScaffoldInputCommon extends TScaffoldInputBase } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php index c187e825..5f431067 100644 --- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php +++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php @@ -97,4 +97,3 @@ class TSqliteScaffoldInput extends TScaffoldInputCommon } } -?> diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php index 1e9b87e7..9c548308 100644 --- a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php +++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php @@ -204,4 +204,3 @@ abstract class TScaffoldBase extends TTemplateControl }
}
-?> diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php index 1760b27d..b38b739f 100644 --- a/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php +++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php @@ -307,4 +307,3 @@ interface IScaffoldEditRenderer extends IDataRenderer public function updateRecord($record);
}
-?> diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php index 79ab40ab..6c28651a 100644 --- a/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php +++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php @@ -304,4 +304,3 @@ class TScaffoldListView extends TScaffoldBase }
}
-?> diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php index a7f58735..b1cd6cbc 100644 --- a/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php +++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php @@ -148,4 +148,3 @@ class TScaffoldSearch extends TScaffoldBase }
}
-?> diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php index 1ddba335..04420e9a 100644 --- a/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php +++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php @@ -141,4 +141,3 @@ class TScaffoldView extends TScaffoldBase }
}
-?> diff --git a/framework/Data/ActiveRecord/TActiveRecord.php b/framework/Data/ActiveRecord/TActiveRecord.php index 370dd69a..fa134a9f 100644 --- a/framework/Data/ActiveRecord/TActiveRecord.php +++ b/framework/Data/ActiveRecord/TActiveRecord.php @@ -79,7 +79,7 @@ Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationContext'); * 'email_address'=>'email', * ); * public $username; - * pulbic $email; + * public $email; * } * </code> * In the above, the 'users' table consists of 'user_id' and 'email_address' columns, @@ -129,6 +129,18 @@ Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationContext'); * } * </code> * + * Since v3.1.3 you can also define a method that returns the table name. + * <code> + * class UserRecord extends TActiveRecord + * { + * public function table() + * { + * return 'users'; + * } + * + * } + * </code> + * * @author Wei Zhuo <weizho[at]gmail[dot]com> * @version $Id$ * @package System.Data.ActiveRecord @@ -318,6 +330,14 @@ abstract class TActiveRecord extends TComponent } /** + * @return TDbTableInfo the meta information of the table associated with this AR class. + */ + public function getRecordTableInfo() + { + return $this->getRecordGateway()->getRecordTableInfo($this); + } + + /** * Compare two records using their primary key values (all column values if * table does not defined primary keys). The default uses simple == for * comparison of their values. Set $strict=true for identity comparison (===). @@ -329,7 +349,7 @@ abstract class TActiveRecord extends TComponent { if($record===null || get_class($this)!==get_class($record)) return false; - $tableInfo = $this->getRecordGateway()->getRecordTableInfo($this); + $tableInfo = $this->getRecordTableInfo(); $pks = $tableInfo->getPrimaryKeys(); $properties = count($pks) > 0 ? $pks : $tableInfo->getColumns()->getKeys(); $equals=true; @@ -378,7 +398,7 @@ abstract class TActiveRecord extends TComponent /** * @return TActiveRecordGateway record table gateway. */ - public static function getRecordGateway() + public function getRecordGateway() { return TActiveRecordManager::getInstance()->getRecordGateway(); } @@ -552,6 +572,7 @@ abstract class TActiveRecord extends TComponent { $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; $criteria = $this->getRecordCriteria($criteria,$parameters, $args); + $criteria->setLimit(1); $data = $this->getRecordGateway()->findRecordsByCriteria($this,$criteria); return $this->populateObject($data); } @@ -629,6 +650,7 @@ abstract class TActiveRecord extends TComponent { $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; $criteria = $this->getRecordCriteria($sql,$parameters, $args); + $criteria->setLimit(1); $data = $this->getRecordGateway()->findRecordBySql($this,$criteria); return $this->populateObject($data); } @@ -1000,4 +1022,3 @@ class TActiveRecordChangeEventParameter extends TEventParameter } } -?> diff --git a/framework/Data/ActiveRecord/TActiveRecordConfig.php b/framework/Data/ActiveRecord/TActiveRecordConfig.php index 4e21635e..63f05aef 100644 --- a/framework/Data/ActiveRecord/TActiveRecordConfig.php +++ b/framework/Data/ActiveRecord/TActiveRecordConfig.php @@ -105,4 +105,3 @@ class TActiveRecordConfig extends TDataSourceConfig }
}
-?> diff --git a/framework/Data/ActiveRecord/TActiveRecordCriteria.php b/framework/Data/ActiveRecord/TActiveRecordCriteria.php index eec6df04..41e8ad02 100644 --- a/framework/Data/ActiveRecord/TActiveRecordCriteria.php +++ b/framework/Data/ActiveRecord/TActiveRecordCriteria.php @@ -37,4 +37,3 @@ class TActiveRecordCriteria extends TSqlCriteria }
-?> diff --git a/framework/Data/ActiveRecord/TActiveRecordGateway.php b/framework/Data/ActiveRecord/TActiveRecordGateway.php index 23104c00..6cce9eb9 100644 --- a/framework/Data/ActiveRecord/TActiveRecordGateway.php +++ b/framework/Data/ActiveRecord/TActiveRecordGateway.php @@ -1,414 +1,425 @@ -<?php
-/**
- * TActiveRecordGateway, TActiveRecordStatementType, TActiveRecordEventParameter classes file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Data.ActiveRecord
- */
-
-/**
- * TActiveRecordGateway excutes the SQL command queries and returns the data
- * record as arrays (for most finder methods).
- *
- * @author Wei Zhuo <weizho[at]gmail[dot]com>
- * @version $Id$
- * @package System.Data.ActiveRecord
- * @since 3.1
- */
-class TActiveRecordGateway extends TComponent
-{
- private $_manager;
- private $_tables=array(); //table cache
- private $_meta=array(); //meta data cache.
- private $_commandBuilders=array();
- private $_currentRecord;
-
- /**
- * Constant name for specifying optional table name in TActiveRecord.
- */
- const TABLE_CONST='TABLE';
-
- /**
- * Record gateway constructor.
- * @param TActiveRecordManager $manager
- */
- public function __construct(TActiveRecordManager $manager)
- {
- $this->_manager=$manager;
- }
-
- /**
- * @return TActiveRecordManager record manager.
- */
- protected function getManager()
- {
- return $this->_manager;
- }
-
- /**
- * Gets the table name from the 'TABLE' constant of the active record
- * class if defined, otherwise use the class name as table name.
- * @param TActiveRecord active record instance
- * @return string table name for the given record class.
- */
- protected function getRecordTableName(TActiveRecord $record)
- {
- $class = new ReflectionClass($record);
- if($class->hasConstant(self::TABLE_CONST))
- {
- $value = $class->getConstant(self::TABLE_CONST);
- if(empty($value))
- throw new TActiveRecordException('ar_invalid_tablename_property',
- get_class($record),self::TABLE_CONST);
- return $value;
- }
- else
- return strtolower(get_class($record));
- }
-
- /**
- * Returns table information, trys the application cache first.
- * @param TActiveRecord $record
- * @return TDbTableInfo table information.
- */
- public function getRecordTableInfo(TActiveRecord $record)
- {
- $tableName = $this->getRecordTableName($record);
- return $this->getTableInfo($record->getDbConnection(), $tableName);
- }
-
- /**
- * Returns table information for table in the database connection.
- * @param TDbConnection database connection
- * @param string table name
- * @return TDbTableInfo table details.
- */
- public function getTableInfo(TDbConnection $connection, $tableName)
- {
- $connStr = $connection->getConnectionString();
- $key = $connStr.$tableName;
- if(!isset($this->_tables[$key]))
- {
- //call this first to ensure that unserializing the cache
- //will find the correct driver dependent classes.
- if(!isset($this->_meta[$connStr]))
- {
- Prado::using('System.Data.Common.TDbMetaData');
- $this->_meta[$connStr] = TDbMetaData::getInstance($connection);
- }
-
- $tableInfo = null;
- if(($cache=$this->getManager()->getCache())!==null)
- $tableInfo = $cache->get($key);
- if(empty($tableInfo))
- {
- $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName);
- if($cache!==null)
- $cache->set($key, $tableInfo);
- }
- $this->_tables[$key] = $tableInfo;
- }
- return $this->_tables[$key];
- }
-
- /**
- * @param TActiveRecord $record
- * @return TDataGatewayCommand
- */
- public function getCommand(TActiveRecord $record)
- {
- $conn = $record->getDbConnection();
- $connStr = $conn->getConnectionString();
- $tableInfo = $this->getRecordTableInfo($record);
- if(!isset($this->_commandBuilders[$connStr]))
- {
- $builder = $tableInfo->createCommandBuilder($record->getDbConnection());
- Prado::using('System.Data.DataGateway.TDataGatewayCommand');
- $command = new TDataGatewayCommand($builder);
- $command->OnCreateCommand[] = array($this, 'onCreateCommand');
- $command->OnExecuteCommand[] = array($this, 'onExecuteCommand');
- $this->_commandBuilders[$connStr] = $command;
-
- }
- $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo);
- $this->_currentRecord=$record;
- return $this->_commandBuilders[$connStr];
- }
-
- /**
- * Raised when a command is prepared and parameter binding is completed.
- * The parameter object is TDataGatewayEventParameter of which the
- * {@link TDataGatewayEventParameter::getCommand Command} property can be
- * inspected to obtain the sql query to be executed.
- * This method also raises the OnCreateCommand event on the ActiveRecord
- * object calling this gateway.
- * @param TDataGatewayCommand originator $sender
- * @param TDataGatewayEventParameter
- */
- public function onCreateCommand($sender, $param)
- {
- $this->raiseEvent('OnCreateCommand', $this, $param);
- if($this->_currentRecord!==null)
- $this->_currentRecord->onCreateCommand($param);
- }
-
- /**
- * Raised when a command is executed and the result from the database was returned.
- * The parameter object is TDataGatewayResultEventParameter of which the
- * {@link TDataGatewayEventParameter::getResult Result} property contains
- * the data return from the database. The data returned can be changed
- * by setting the {@link TDataGatewayEventParameter::setResult Result} property.
- * This method also raises the OnCreateCommand event on the ActiveRecord
- * object calling this gateway.
- * @param TDataGatewayCommand originator $sender
- * @param TDataGatewayResultEventParameter
- */
- public function onExecuteCommand($sender, $param)
- {
- $this->raiseEvent('OnExecuteCommand', $this, $param);
- if($this->_currentRecord!==null)
- $this->_currentRecord->onExecuteCommand($param);
- }
-
- /**
- * Returns record data matching the given primary key(s). If the table uses
- * composite key, specify the name value pairs as an array.
- * @param TActiveRecord active record instance.
- * @param array primary name value pairs
- * @return array record data
- */
- public function findRecordByPK(TActiveRecord $record,$keys)
- {
- $command = $this->getCommand($record);
- return $command->findByPk($keys);
- }
-
- /**
- * Returns records matching the list of given primary keys.
- * @param TActiveRecord active record instance.
- * @param array list of primary name value pairs
- * @return array matching data.
- */
- public function findRecordsByPks(TActiveRecord $record, $keys)
- {
- return $this->getCommand($record)->findAllByPk($keys);
- }
-
-
- /**
- * Returns record data matching the given critera. If $iterator is true, it will
- * return multiple rows as TDbDataReader otherwise it returns the <b>first</b> row data.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria search criteria.
- * @param boolean true to return multiple rows as iterator, false returns first row.
- * @return mixed matching data.
- */
- public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false)
- {
- $command = $this->getCommand($record);
- return $iterator ? $command->findAll($criteria) : $command->find($criteria);
- }
-
- /**
- * Return record data from sql query.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria sql query
- * @return array result.
- */
- public function findRecordBySql(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->findBySql($criteria);
- }
-
- /**
- * Return record data from sql query.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria sql query
- * @return TDbDataReader result iterator.
- */
- public function findRecordsBySql(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->findAllBySql($criteria);
- }
-
- public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values)
- {
- return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values);
- }
-
- /**
- * Returns the number of records that match the given criteria.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria search criteria
- * @return int number of records.
- */
- public function countRecords(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->count($criteria);
- }
-
- /**
- * Insert a new record.
- * @param TActiveRecord new record.
- * @return int number of rows affected.
- */
- public function insert(TActiveRecord $record)
- {
- //$this->updateAssociatedRecords($record,true);
- $result = $this->getCommand($record)->insert($this->getInsertValues($record));
- if($result)
- $this->updatePostInsert($record);
- //$this->updateAssociatedRecords($record);
- return $result;
- }
-
- /**
- * Sets the last insert ID to the corresponding property of the record if available.
- * @param TActiveRecord record for insertion
- */
- protected function updatePostInsert($record)
- {
- $command = $this->getCommand($record);
- $tableInfo = $command->getTableInfo();
- foreach($tableInfo->getColumns() as $name => $column)
- {
- if($column->hasSequence())
- $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName()));
- }
- }
-
- /**
- * @param TActiveRecord record
- * @return array insert values.
- */
- protected function getInsertValues(TActiveRecord $record)
- {
- $values=array();
- $tableInfo = $this->getCommand($record)->getTableInfo();
- foreach($tableInfo->getColumns() as $name=>$column)
- {
- if($column->getIsExcluded())
- continue;
- $value = $record->getColumnValue($name);
- if(!$column->getAllowNull() && $value===null && !$column->hasSequence())
- {
- throw new TActiveRecordException(
- 'ar_value_must_not_be_null', get_class($record),
- $tableInfo->getTableFullName(), $name);
- }
- if($value!==null)
- $values[$name] = $value;
- }
- return $values;
- }
-
- /**
- * Update the record.
- * @param TActiveRecord dirty record.
- * @return int number of rows affected.
- */
- public function update(TActiveRecord $record)
- {
- //$this->updateAssociatedRecords($record,true);
- list($data, $keys) = $this->getUpdateValues($record);
- $result = $this->getCommand($record)->updateByPk($data, $keys);
- //$this->updateAssociatedRecords($record);
- return $result;
- }
-
- protected function getUpdateValues(TActiveRecord $record)
- {
- $values=array();
- $tableInfo = $this->getCommand($record)->getTableInfo();
- $primary=array();
- foreach($tableInfo->getColumns() as $name=>$column)
- {
- if($column->getIsExcluded())
- continue;
- $value = $record->getColumnValue($name);
- if(!$column->getAllowNull() && $value===null)
- {
- throw new TActiveRecordException(
- 'ar_value_must_not_be_null', get_class($record),
- $tableInfo->getTableFullName(), $name);
- }
- if($column->getIsPrimaryKey())
- $primary[] = $value;
- else
- $values[$name] = $value;
- }
- return array($values,$primary);
- }
-
- protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false)
- {
- $context = new TActiveRecordRelationContext($record);
- return $context->updateAssociatedRecords($updateBelongsTo);
- }
-
- /**
- * Delete the record.
- * @param TActiveRecord record to be deleted.
- * @return int number of rows affected.
- */
- public function delete(TActiveRecord $record)
- {
- return $this->getCommand($record)->deleteByPk($this->getPrimaryKeyValues($record));
- }
-
- protected function getPrimaryKeyValues(TActiveRecord $record)
- {
- $tableInfo = $this->getCommand($record)->getTableInfo();
- $primary=array();
- foreach($tableInfo->getColumns() as $name=>$column)
- {
- if($column->getIsPrimaryKey())
- $primary[$name] = $record->getColumnValue($name);
- }
- return $primary;
- }
-
- /**
- * Delete multiple records using primary keys.
- * @param TActiveRecord finder instance.
- * @return int number of rows deleted.
- */
- public function deleteRecordsByPk(TActiveRecord $record, $keys)
- {
- return $this->getCommand($record)->deleteByPk($keys);
- }
-
- /**
- * Delete multiple records by criteria.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria search criteria
- * @return int number of records.
- */
- public function deleteRecordsByCriteria(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->delete($criteria);
- }
-
- /**
- * Raise the corresponding command event, insert, update, delete or select.
- * @param string command type
- * @param TDbCommand sql command to be executed.
- * @param TActiveRecord active record
- * @param TActiveRecordCriteria data for the command.
- */
- protected function raiseCommandEvent($event,$command,$record,$criteria)
- {
- if(!($criteria instanceof TSqlCriteria))
- $criteria = new TActiveRecordCriteria(null,$criteria);
- $param = new TActiveRecordEventParameter($command,$record,$criteria);
- $manager = $record->getRecordManager();
- $manager->{$event}($param);
- $record->{$event}($param);
- }
-}
-
-?>
+<?php +/** + * TActiveRecordGateway, TActiveRecordStatementType, TActiveRecordEventParameter classes file. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2008 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Data.ActiveRecord + */ + +/** + * TActiveRecordGateway excutes the SQL command queries and returns the data + * record as arrays (for most finder methods). + * + * @author Wei Zhuo <weizho[at]gmail[dot]com> + * @version $Id$ + * @package System.Data.ActiveRecord + * @since 3.1 + */ +class TActiveRecordGateway extends TComponent +{ + private $_manager; + private $_tables=array(); //table cache + private $_meta=array(); //meta data cache. + private $_commandBuilders=array(); + private $_currentRecord; + + /** + * Constant name for specifying optional table name in TActiveRecord. + */ + const TABLE_CONST='TABLE'; + /** + * Method name for returning optional table name in in TActiveRecord + */ + const TABLE_METHOD='table'; + + /** + * Record gateway constructor. + * @param TActiveRecordManager $manager + */ + public function __construct(TActiveRecordManager $manager) + { + $this->_manager=$manager; + } + + /** + * @return TActiveRecordManager record manager. + */ + protected function getManager() + { + return $this->_manager; + } + + /** + * Gets the table name from the 'TABLE' constant of the active record + * class if defined, otherwise use the class name as table name. + * @param TActiveRecord active record instance + * @return string table name for the given record class. + */ + protected function getRecordTableName(TActiveRecord $record) + { + $class = new ReflectionClass($record); + if($class->hasConstant(self::TABLE_CONST)) + { + $value = $class->getConstant(self::TABLE_CONST); + if(empty($value)) + throw new TActiveRecordException('ar_invalid_tablename_property', + get_class($record),self::TABLE_CONST); + return $value; + } + elseif ($class->hasMethod(self::TABLE_METHOD)) + { + $value = $record->{self::TABLE_METHOD}(); + if(empty($value)) + throw new TActiveRecordException('ar_invalid_tablename_method', + get_class($record),self::TABLE_METHOD); + return $value; + } + else + return strtolower(get_class($record)); + } + + /** + * Returns table information, trys the application cache first. + * @param TActiveRecord $record + * @return TDbTableInfo table information. + */ + public function getRecordTableInfo(TActiveRecord $record) + { + $tableName = $this->getRecordTableName($record); + return $this->getTableInfo($record->getDbConnection(), $tableName); + } + + /** + * Returns table information for table in the database connection. + * @param TDbConnection database connection + * @param string table name + * @return TDbTableInfo table details. + */ + public function getTableInfo(TDbConnection $connection, $tableName) + { + $connStr = $connection->getConnectionString(); + $key = $connStr.$tableName; + if(!isset($this->_tables[$key])) + { + //call this first to ensure that unserializing the cache + //will find the correct driver dependent classes. + if(!isset($this->_meta[$connStr])) + { + Prado::using('System.Data.Common.TDbMetaData'); + $this->_meta[$connStr] = TDbMetaData::getInstance($connection); + } + + $tableInfo = null; + if(($cache=$this->getManager()->getCache())!==null) + $tableInfo = $cache->get($key); + if(empty($tableInfo)) + { + $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); + if($cache!==null) + $cache->set($key, $tableInfo); + } + $this->_tables[$key] = $tableInfo; + } + return $this->_tables[$key]; + } + + /** + * @param TActiveRecord $record + * @return TDataGatewayCommand + */ + public function getCommand(TActiveRecord $record) + { + $conn = $record->getDbConnection(); + $connStr = $conn->getConnectionString(); + $tableInfo = $this->getRecordTableInfo($record); + if(!isset($this->_commandBuilders[$connStr])) + { + $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); + Prado::using('System.Data.DataGateway.TDataGatewayCommand'); + $command = new TDataGatewayCommand($builder); + $command->OnCreateCommand[] = array($this, 'onCreateCommand'); + $command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); + $this->_commandBuilders[$connStr] = $command; + + } + $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo); + $this->_currentRecord=$record; + return $this->_commandBuilders[$connStr]; + } + + /** + * Raised when a command is prepared and parameter binding is completed. + * The parameter object is TDataGatewayEventParameter of which the + * {@link TDataGatewayEventParameter::getCommand Command} property can be + * inspected to obtain the sql query to be executed. + * This method also raises the OnCreateCommand event on the ActiveRecord + * object calling this gateway. + * @param TDataGatewayCommand originator $sender + * @param TDataGatewayEventParameter + */ + public function onCreateCommand($sender, $param) + { + $this->raiseEvent('OnCreateCommand', $this, $param); + if($this->_currentRecord!==null) + $this->_currentRecord->onCreateCommand($param); + } + + /** + * Raised when a command is executed and the result from the database was returned. + * The parameter object is TDataGatewayResultEventParameter of which the + * {@link TDataGatewayEventParameter::getResult Result} property contains + * the data return from the database. The data returned can be changed + * by setting the {@link TDataGatewayEventParameter::setResult Result} property. + * This method also raises the OnCreateCommand event on the ActiveRecord + * object calling this gateway. + * @param TDataGatewayCommand originator $sender + * @param TDataGatewayResultEventParameter + */ + public function onExecuteCommand($sender, $param) + { + $this->raiseEvent('OnExecuteCommand', $this, $param); + if($this->_currentRecord!==null) + $this->_currentRecord->onExecuteCommand($param); + } + + /** + * Returns record data matching the given primary key(s). If the table uses + * composite key, specify the name value pairs as an array. + * @param TActiveRecord active record instance. + * @param array primary name value pairs + * @return array record data + */ + public function findRecordByPK(TActiveRecord $record,$keys) + { + $command = $this->getCommand($record); + return $command->findByPk($keys); + } + + /** + * Returns records matching the list of given primary keys. + * @param TActiveRecord active record instance. + * @param array list of primary name value pairs + * @return array matching data. + */ + public function findRecordsByPks(TActiveRecord $record, $keys) + { + return $this->getCommand($record)->findAllByPk($keys); + } + + + /** + * Returns record data matching the given critera. If $iterator is true, it will + * return multiple rows as TDbDataReader otherwise it returns the <b>first</b> row data. + * @param TActiveRecord active record finder instance. + * @param TActiveRecordCriteria search criteria. + * @param boolean true to return multiple rows as iterator, false returns first row. + * @return mixed matching data. + */ + public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false) + { + $command = $this->getCommand($record); + return $iterator ? $command->findAll($criteria) : $command->find($criteria); + } + + /** + * Return record data from sql query. + * @param TActiveRecord active record finder instance. + * @param TActiveRecordCriteria sql query + * @return array result. + */ + public function findRecordBySql(TActiveRecord $record, $criteria) + { + return $this->getCommand($record)->findBySql($criteria); + } + + /** + * Return record data from sql query. + * @param TActiveRecord active record finder instance. + * @param TActiveRecordCriteria sql query + * @return TDbDataReader result iterator. + */ + public function findRecordsBySql(TActiveRecord $record, $criteria) + { + return $this->getCommand($record)->findAllBySql($criteria); + } + + public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values) + { + return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values); + } + + /** + * Returns the number of records that match the given criteria. + * @param TActiveRecord active record finder instance. + * @param TActiveRecordCriteria search criteria + * @return int number of records. + */ + public function countRecords(TActiveRecord $record, $criteria) + { + return $this->getCommand($record)->count($criteria); + } + + /** + * Insert a new record. + * @param TActiveRecord new record. + * @return int number of rows affected. + */ + public function insert(TActiveRecord $record) + { + //$this->updateAssociatedRecords($record,true); + $result = $this->getCommand($record)->insert($this->getInsertValues($record)); + if($result) + $this->updatePostInsert($record); + //$this->updateAssociatedRecords($record); + return $result; + } + + /** + * Sets the last insert ID to the corresponding property of the record if available. + * @param TActiveRecord record for insertion + */ + protected function updatePostInsert($record) + { + $command = $this->getCommand($record); + $tableInfo = $command->getTableInfo(); + foreach($tableInfo->getColumns() as $name => $column) + { + if($column->hasSequence()) + $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName())); + } + } + + /** + * @param TActiveRecord record + * @return array insert values. + */ + protected function getInsertValues(TActiveRecord $record) + { + $values=array(); + $tableInfo = $this->getCommand($record)->getTableInfo(); + foreach($tableInfo->getColumns() as $name=>$column) + { + if($column->getIsExcluded()) + continue; + $value = $record->getColumnValue($name); + if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && !$column->getDefaultValue()) + { + throw new TActiveRecordException( + 'ar_value_must_not_be_null', get_class($record), + $tableInfo->getTableFullName(), $name); + } + if($value!==null) + $values[$name] = $value; + } + return $values; + } + + /** + * Update the record. + * @param TActiveRecord dirty record. + * @return int number of rows affected. + */ + public function update(TActiveRecord $record) + { + //$this->updateAssociatedRecords($record,true); + list($data, $keys) = $this->getUpdateValues($record); + $result = $this->getCommand($record)->updateByPk($data, $keys); + //$this->updateAssociatedRecords($record); + return $result; + } + + protected function getUpdateValues(TActiveRecord $record) + { + $values=array(); + $tableInfo = $this->getCommand($record)->getTableInfo(); + $primary=array(); + foreach($tableInfo->getColumns() as $name=>$column) + { + if($column->getIsExcluded()) + continue; + $value = $record->getColumnValue($name); + if(!$column->getAllowNull() && $value===null) + { + throw new TActiveRecordException( + 'ar_value_must_not_be_null', get_class($record), + $tableInfo->getTableFullName(), $name); + } + if($column->getIsPrimaryKey()) + $primary[] = $value; + else + $values[$name] = $value; + } + return array($values,$primary); + } + + protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false) + { + $context = new TActiveRecordRelationContext($record); + return $context->updateAssociatedRecords($updateBelongsTo); + } + + /** + * Delete the record. + * @param TActiveRecord record to be deleted. + * @return int number of rows affected. + */ + public function delete(TActiveRecord $record) + { + return $this->getCommand($record)->deleteByPk($this->getPrimaryKeyValues($record)); + } + + protected function getPrimaryKeyValues(TActiveRecord $record) + { + $tableInfo = $this->getCommand($record)->getTableInfo(); + $primary=array(); + foreach($tableInfo->getColumns() as $name=>$column) + { + if($column->getIsPrimaryKey()) + $primary[$name] = $record->getColumnValue($name); + } + return $primary; + } + + /** + * Delete multiple records using primary keys. + * @param TActiveRecord finder instance. + * @return int number of rows deleted. + */ + public function deleteRecordsByPk(TActiveRecord $record, $keys) + { + return $this->getCommand($record)->deleteByPk($keys); + } + + /** + * Delete multiple records by criteria. + * @param TActiveRecord active record finder instance. + * @param TActiveRecordCriteria search criteria + * @return int number of records. + */ + public function deleteRecordsByCriteria(TActiveRecord $record, $criteria) + { + return $this->getCommand($record)->delete($criteria); + } + + /** + * Raise the corresponding command event, insert, update, delete or select. + * @param string command type + * @param TDbCommand sql command to be executed. + * @param TActiveRecord active record + * @param TActiveRecordCriteria data for the command. + */ + protected function raiseCommandEvent($event,$command,$record,$criteria) + { + if(!($criteria instanceof TSqlCriteria)) + $criteria = new TActiveRecordCriteria(null,$criteria); + $param = new TActiveRecordEventParameter($command,$record,$criteria); + $manager = $record->getRecordManager(); + $manager->{$event}($param); + $record->{$event}($param); + } +} + diff --git a/framework/Data/ActiveRecord/TActiveRecordManager.php b/framework/Data/ActiveRecord/TActiveRecordManager.php index ce14ac4d..9912e7ff 100644 --- a/framework/Data/ActiveRecord/TActiveRecordManager.php +++ b/framework/Data/ActiveRecord/TActiveRecordManager.php @@ -109,4 +109,3 @@ class TActiveRecordManager extends TComponent }
-?> diff --git a/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php b/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php index ee87a374..3b7001ab 100644 --- a/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php +++ b/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php @@ -154,4 +154,3 @@ class TIbmColumnMetaData extends TComponent }
-?> diff --git a/framework/Data/Common/IbmDb2/TIbmMetaData.php b/framework/Data/Common/IbmDb2/TIbmMetaData.php index 059ef2d5..496bb12f 100644 --- a/framework/Data/Common/IbmDb2/TIbmMetaData.php +++ b/framework/Data/Common/IbmDb2/TIbmMetaData.php @@ -110,4 +110,3 @@ class TIbmMetaData extends TDbMetaDataCommon }
-?> diff --git a/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php b/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php index cfb4803d..a37fad6e 100644 --- a/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php +++ b/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php @@ -110,4 +110,3 @@ class TIbmMetaDataInspector extends TDbMetaDataInspector return new TIbmMetaData($table,$columns,$pks);
}
}
-?> diff --git a/framework/Data/Common/Mssql/TMssqlCommandBuilder.php b/framework/Data/Common/Mssql/TMssqlCommandBuilder.php index 75d98198..1a0ad4ce 100644 --- a/framework/Data/Common/Mssql/TMssqlCommandBuilder.php +++ b/framework/Data/Common/Mssql/TMssqlCommandBuilder.php @@ -170,4 +170,3 @@ class TMssqlCommandBuilder extends TDbCommandBuilder }
}
-?> diff --git a/framework/Data/Common/Mssql/TMssqlMetaData.php b/framework/Data/Common/Mssql/TMssqlMetaData.php index faa94e69..8309e4ec 100644 --- a/framework/Data/Common/Mssql/TMssqlMetaData.php +++ b/framework/Data/Common/Mssql/TMssqlMetaData.php @@ -232,4 +232,3 @@ EOD; } } -?> diff --git a/framework/Data/Common/Mssql/TMssqlTableColumn.php b/framework/Data/Common/Mssql/TMssqlTableColumn.php index 5f41f429..8a291b52 100644 --- a/framework/Data/Common/Mssql/TMssqlTableColumn.php +++ b/framework/Data/Common/Mssql/TMssqlTableColumn.php @@ -62,4 +62,3 @@ class TMssqlTableColumn extends TDbTableColumn }
}
-?> diff --git a/framework/Data/Common/Mssql/TMssqlTableInfo.php b/framework/Data/Common/Mssql/TMssqlTableInfo.php index 3a2ae033..356c6f26 100644 --- a/framework/Data/Common/Mssql/TMssqlTableInfo.php +++ b/framework/Data/Common/Mssql/TMssqlTableInfo.php @@ -62,4 +62,3 @@ class TMssqlTableInfo extends TDbTableInfo }
}
-?> diff --git a/framework/Data/Common/Mysql/TMysqlCommandBuilder.php b/framework/Data/Common/Mysql/TMysqlCommandBuilder.php index b296a82d..3326851f 100644 --- a/framework/Data/Common/Mysql/TMysqlCommandBuilder.php +++ b/framework/Data/Common/Mysql/TMysqlCommandBuilder.php @@ -24,4 +24,3 @@ class TMysqlCommandBuilder extends TDbCommandBuilder {
}
-?> diff --git a/framework/Data/Common/Mysql/TMysqlMetaData.php b/framework/Data/Common/Mysql/TMysqlMetaData.php index aaebd8dc..75f7a7cf 100644 --- a/framework/Data/Common/Mysql/TMysqlMetaData.php +++ b/framework/Data/Common/Mysql/TMysqlMetaData.php @@ -246,7 +246,9 @@ class TMysqlMetaData extends TDbMetaData if($row['Key_name']==='PRIMARY')
$primary[] = $row['Column_name'];
}
- if($this->getServerVersion() > 5)
+ // MySQL version was increased to >=5.1.21 instead of 5.x + // due to a MySQL bug (http://bugs.mysql.com/bug.php?id=19588) + if($this->getServerVersion() >= 5.121)
$foreign = $this->getForeignConstraints($schemaName,$tableName);
else
$foreign = $this->findForeignConstraints($schemaName,$tableName);
@@ -352,4 +354,3 @@ EOD; }
}
-?> diff --git a/framework/Data/Common/Mysql/TMysqlTableColumn.php b/framework/Data/Common/Mysql/TMysqlTableColumn.php index 99b4333a..5f4351a7 100644 --- a/framework/Data/Common/Mysql/TMysqlTableColumn.php +++ b/framework/Data/Common/Mysql/TMysqlTableColumn.php @@ -70,4 +70,3 @@ class TMysqlTableColumn extends TDbTableColumn }
}
-?> diff --git a/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php b/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php index 460da46a..4cae8b89 100644 --- a/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php +++ b/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php @@ -67,4 +67,3 @@ class TPgsqlCommandBuilder extends TDbCommandBuilder }
-?> diff --git a/framework/Data/Common/Pgsql/TPgsqlMetaData.php b/framework/Data/Common/Pgsql/TPgsqlMetaData.php index 45d55086..a2243531 100644 --- a/framework/Data/Common/Pgsql/TPgsqlMetaData.php +++ b/framework/Data/Common/Pgsql/TPgsqlMetaData.php @@ -390,4 +390,3 @@ EOD; }
}
-?> diff --git a/framework/Data/Common/Pgsql/TPgsqlTableColumn.php b/framework/Data/Common/Pgsql/TPgsqlTableColumn.php index 7ec2312a..562e2c56 100644 --- a/framework/Data/Common/Pgsql/TPgsqlTableColumn.php +++ b/framework/Data/Common/Pgsql/TPgsqlTableColumn.php @@ -47,4 +47,3 @@ class TPgsqlTableColumn extends TDbTableColumn }
}
-?> diff --git a/framework/Data/Common/Pgsql/TPgsqlTableInfo.php b/framework/Data/Common/Pgsql/TPgsqlTableInfo.php index 2a3a8461..2447c141 100644 --- a/framework/Data/Common/Pgsql/TPgsqlTableInfo.php +++ b/framework/Data/Common/Pgsql/TPgsqlTableInfo.php @@ -56,4 +56,3 @@ class TPgsqlTableInfo extends TDbTableInfo }
}
-?> diff --git a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php index c02ed76d..c60e17a3 100644 --- a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php +++ b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php @@ -45,4 +45,3 @@ class TSqliteCommandBuilder extends TDbCommandBuilder }
}
-?> diff --git a/framework/Data/Common/Sqlite/TSqliteMetaData.php b/framework/Data/Common/Sqlite/TSqliteMetaData.php index c562c930..010a2148 100644 --- a/framework/Data/Common/Sqlite/TSqliteMetaData.php +++ b/framework/Data/Common/Sqlite/TSqliteMetaData.php @@ -178,4 +178,3 @@ CREATE TABLE bar );
*/
-?> diff --git a/framework/Data/Common/Sqlite/TSqliteTableColumn.php b/framework/Data/Common/Sqlite/TSqliteTableColumn.php index 3c9100ab..4e79de6d 100644 --- a/framework/Data/Common/Sqlite/TSqliteTableColumn.php +++ b/framework/Data/Common/Sqlite/TSqliteTableColumn.php @@ -62,4 +62,3 @@ class TSqliteTableColumn extends TDbTableColumn }
}
-?> diff --git a/framework/Data/Common/Sqlite/TSqliteTableInfo.php b/framework/Data/Common/Sqlite/TSqliteTableInfo.php index 95c3fe02..b729a593 100644 --- a/framework/Data/Common/Sqlite/TSqliteTableInfo.php +++ b/framework/Data/Common/Sqlite/TSqliteTableInfo.php @@ -45,4 +45,3 @@ class TSqliteTableInfo extends TDbTableInfo }
}
-?> diff --git a/framework/Data/Common/TDbMetaData.php b/framework/Data/Common/TDbMetaData.php index c0f10d41..bcdf0e46 100644 --- a/framework/Data/Common/TDbMetaData.php +++ b/framework/Data/Common/TDbMetaData.php @@ -121,4 +121,3 @@ abstract class TDbMetaData extends TComponent }
}
-?> diff --git a/framework/Data/Common/TDbTableColumn.php b/framework/Data/Common/TDbTableColumn.php index b3d603ae..3bb9454b 100644 --- a/framework/Data/Common/TDbTableColumn.php +++ b/framework/Data/Common/TDbTableColumn.php @@ -197,4 +197,3 @@ class TDbTableColumn extends TComponent }
}
-?> diff --git a/framework/Data/Common/TDbTableInfo.php b/framework/Data/Common/TDbTableInfo.php index 87af2234..e2aae3d0 100644 --- a/framework/Data/Common/TDbTableInfo.php +++ b/framework/Data/Common/TDbTableInfo.php @@ -156,4 +156,3 @@ class TDbTableInfo extends TComponent }
}
-?> diff --git a/framework/Data/DataGateway/TTableGateway.php b/framework/Data/DataGateway/TTableGateway.php index 0f2644be..163efcf5 100644 --- a/framework/Data/DataGateway/TTableGateway.php +++ b/framework/Data/DataGateway/TTableGateway.php @@ -474,4 +474,3 @@ class TTableGateway extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TDiscriminator.php b/framework/Data/SqlMap/Configuration/TDiscriminator.php index 75ce2352..747c4158 100644 --- a/framework/Data/SqlMap/Configuration/TDiscriminator.php +++ b/framework/Data/SqlMap/Configuration/TDiscriminator.php @@ -230,4 +230,3 @@ class TSubMap extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php b/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php index d29d5f27..2e8f38d6 100644 --- a/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php +++ b/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php @@ -27,7 +27,7 @@ class TInlineParameterMapParser /**
* Regular expression for parsing inline parameter maps.
*/
- const PARAMETER_TOKEN_REGEXP = '/#(#?[^#]+#?)#/';
+ const PARAMETER_TOKEN_REGEXP = '/#([^#]+)#/';
/**
* Parse the sql text for inline parameters.
@@ -77,4 +77,3 @@ class TInlineParameterMapParser }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TParameterMap.php b/framework/Data/SqlMap/Configuration/TParameterMap.php index 117c6037..f4fbbe1c 100644 --- a/framework/Data/SqlMap/Configuration/TParameterMap.php +++ b/framework/Data/SqlMap/Configuration/TParameterMap.php @@ -205,4 +205,3 @@ class TParameterMap extends TComponent return $value;
}
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TParameterProperty.php b/framework/Data/SqlMap/Configuration/TParameterProperty.php index d0af3a75..dcea754c 100644 --- a/framework/Data/SqlMap/Configuration/TParameterProperty.php +++ b/framework/Data/SqlMap/Configuration/TParameterProperty.php @@ -136,4 +136,3 @@ class TParameterProperty extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TResultMap.php b/framework/Data/SqlMap/Configuration/TResultMap.php index 168041d2..d59d9522 100644 --- a/framework/Data/SqlMap/Configuration/TResultMap.php +++ b/framework/Data/SqlMap/Configuration/TResultMap.php @@ -198,4 +198,3 @@ class TResultMap extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TResultProperty.php b/framework/Data/SqlMap/Configuration/TResultProperty.php index 711fa7a0..8e20d5e4 100644 --- a/framework/Data/SqlMap/Configuration/TResultProperty.php +++ b/framework/Data/SqlMap/Configuration/TResultProperty.php @@ -326,4 +326,3 @@ class TResultProperty extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php b/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php index 6df8cefd..9a9b1277 100644 --- a/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php +++ b/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php @@ -43,4 +43,3 @@ class TSimpleDynamicParser }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php b/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php index edb78ea7..d7984dc4 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php @@ -214,4 +214,3 @@ class TSqlMapCacheKey }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php index 77b714fd..3afcc75f 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php @@ -428,4 +428,3 @@ class TSqlMapSelectKey extends TSqlMapStatement }
}
-?> diff --git a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php index d0c57d57..f2d13966 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php @@ -309,6 +309,16 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder private $_FlushOnExecuteStatements=array();
+ /** + * Regular expressions for escaping simple/inline parameter symbols + */ + const SIMPLE_MARK='$'; + const INLINE_SYMBOL='#'; + const ESCAPED_SIMPLE_MARK_REGEXP='/\$\$/'; + const ESCAPED_INLINE_SYMBOL_REGEXP='/\#\#/'; + const SIMPLE_PLACEHOLDER='`!!`'; + const INLINE_PLACEHOLDER='`!!!`'; + /**
* @param TSqlMapXmlConfiguration parent xml configuration.
*/
@@ -532,6 +542,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder $scope['file'] = $this->_configFile;
$scope['node'] = $node;
+ $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement); if($statement->parameterMap() === null)
{
// Build a Parametermap with the inline parameters.
@@ -548,6 +559,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder }
$sqlStatement = $sqlText['sql'];
}
+ $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement); $this->prepareSql($statement, $sqlStatement, $node);
}
@@ -562,6 +574,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder protected function prepareSql($statement,$sqlStatement, $node)
{
$simpleDynamic = new TSimpleDynamicParser;
+ $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement); $dynamics = $simpleDynamic->parse($sqlStatement);
if(count($dynamics['parameters']) > 0)
{
@@ -570,6 +583,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder }
else
$sql = new TStaticSql();
+ $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); $sql->buildPreparedStatement($statement, $sqlStatement);
$statement->setSqlText($sql);
}
@@ -724,4 +738,3 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder }
}
-?> diff --git a/framework/Data/SqlMap/DataMapper/TLazyLoadList.php b/framework/Data/SqlMap/DataMapper/TLazyLoadList.php index 02b08e8e..69b20bf6 100644 --- a/framework/Data/SqlMap/DataMapper/TLazyLoadList.php +++ b/framework/Data/SqlMap/DataMapper/TLazyLoadList.php @@ -142,4 +142,3 @@ class TObjectProxy }
}
-?> diff --git a/framework/Data/SqlMap/DataMapper/TPropertyAccess.php b/framework/Data/SqlMap/DataMapper/TPropertyAccess.php index 23e854ac..a27cb50f 100644 --- a/framework/Data/SqlMap/DataMapper/TPropertyAccess.php +++ b/framework/Data/SqlMap/DataMapper/TPropertyAccess.php @@ -106,7 +106,8 @@ class TPropertyAccess $object = $object->{$getter}();
else if(in_array($prop, array_keys(get_object_vars($object))))
$object = $object->{$prop};
- return false;
+ else
+ return false;
}
else
return false;
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapCache.php b/framework/Data/SqlMap/DataMapper/TSqlMapCache.php index 61c5bb95..05b72e08 100644 --- a/framework/Data/SqlMap/DataMapper/TSqlMapCache.php +++ b/framework/Data/SqlMap/DataMapper/TSqlMapCache.php @@ -225,4 +225,3 @@ class TSqlMapApplicationCache implements ICache }
}
-?> diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapException.php b/framework/Data/SqlMap/DataMapper/TSqlMapException.php index 69a0b0cd..0bf0ac32 100644 --- a/framework/Data/SqlMap/DataMapper/TSqlMapException.php +++ b/framework/Data/SqlMap/DataMapper/TSqlMapException.php @@ -113,4 +113,3 @@ class TSqlMapExecutionException extends TSqlMapException {
}
-?> diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php b/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php index b3a88653..86171c1e 100644 --- a/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php +++ b/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php @@ -206,4 +206,3 @@ class TSqlMapPagedList extends TPagedList }
}
-?> diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php b/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php index aa39dce1..05866395 100644 --- a/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php +++ b/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php @@ -190,4 +190,3 @@ abstract class TSqlMapTypeHandler extends TComponent public abstract function createNewInstance($row=null);
}
-?> diff --git a/framework/Data/SqlMap/Statements/IMappedStatement.php b/framework/Data/SqlMap/Statements/IMappedStatement.php index 94189420..dc628c9e 100644 --- a/framework/Data/SqlMap/Statements/IMappedStatement.php +++ b/framework/Data/SqlMap/Statements/IMappedStatement.php @@ -80,4 +80,3 @@ interface IMappedStatement public function executeQueryForObject($connection,$parameter, $result=null);
}
-?> diff --git a/framework/Data/SqlMap/Statements/TCachingStatement.php b/framework/Data/SqlMap/Statements/TCachingStatement.php index 7c9498d4..c8a748c1 100644 --- a/framework/Data/SqlMap/Statements/TCachingStatement.php +++ b/framework/Data/SqlMap/Statements/TCachingStatement.php @@ -106,4 +106,3 @@ class TCachingStatement implements IMappedStatement }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php b/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php index bb95cab9..1a3d738a 100644 --- a/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php @@ -22,4 +22,3 @@ class TDeleteMappedStatement extends TUpdateMappedStatement {
}
-?> diff --git a/framework/Data/SqlMap/Statements/TInsertMappedStatement.php b/framework/Data/SqlMap/Statements/TInsertMappedStatement.php index 28ade045..1efb5b6b 100644 --- a/framework/Data/SqlMap/Statements/TInsertMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TInsertMappedStatement.php @@ -47,4 +47,3 @@ class TInsertMappedStatement extends TMappedStatement }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TMappedStatement.php b/framework/Data/SqlMap/Statements/TMappedStatement.php index 2feeba90..6a9130fe 100644 --- a/framework/Data/SqlMap/Statements/TMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TMappedStatement.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Data.SqlMap.Statements
@@ -561,7 +561,7 @@ class TMappedStatement extends TComponent implements IMappedStatement else
$obj = $this->fillDefaultResultMap(null, $row, $resultObject);
if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord)
- //Create a new clean active record. + //Create a new clean active record.
$obj=TActiveRecord::createRecord(get_class($obj),$obj);
return $obj;
}
@@ -1115,7 +1115,7 @@ class TSqlMapObjectCollectionTree else if(is_array($list))
$list[] = $this->_entries[$node]['object'];
else
- throw TSqlMapExecutionException(
+ throw new TSqlMapExecutionException(
'sqlmap_property_must_be_list');
}
@@ -1216,4 +1216,3 @@ class TResultSetMapItemParameter extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TPreparedCommand.php b/framework/Data/SqlMap/Statements/TPreparedCommand.php index 76407190..99bb6eff 100644 --- a/framework/Data/SqlMap/Statements/TPreparedCommand.php +++ b/framework/Data/SqlMap/Statements/TPreparedCommand.php @@ -58,4 +58,3 @@ class TPreparedCommand }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TPreparedStatement.php b/framework/Data/SqlMap/Statements/TPreparedStatement.php index be005e81..7d862378 100644 --- a/framework/Data/SqlMap/Statements/TPreparedStatement.php +++ b/framework/Data/SqlMap/Statements/TPreparedStatement.php @@ -41,4 +41,3 @@ class TPreparedStatement extends TComponent }
-?> diff --git a/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php b/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php index 5c3e2f22..44603408 100644 --- a/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php +++ b/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php @@ -47,4 +47,3 @@ class TPreparedStatementFactory }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TSelectMappedStatement.php b/framework/Data/SqlMap/Statements/TSelectMappedStatement.php index a8253536..1802db2f 100644 --- a/framework/Data/SqlMap/Statements/TSelectMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TSelectMappedStatement.php @@ -34,4 +34,3 @@ class TSelectMappedStatement extends TMappedStatement }
-?> diff --git a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php index 38554778..910fd659 100644 --- a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php +++ b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php @@ -47,4 +47,3 @@ class TSimpleDynamicSql extends TStaticSql }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TStaticSql.php b/framework/Data/SqlMap/Statements/TStaticSql.php index 8f4687df..eba54ed7 100644 --- a/framework/Data/SqlMap/Statements/TStaticSql.php +++ b/framework/Data/SqlMap/Statements/TStaticSql.php @@ -34,4 +34,3 @@ class TStaticSql extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php b/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php index c0aa798e..633ec797 100644 --- a/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php @@ -47,4 +47,3 @@ class TUpdateMappedStatement extends TMappedStatement }
}
-?> diff --git a/framework/Data/SqlMap/TSqlMapConfig.php b/framework/Data/SqlMap/TSqlMapConfig.php index 5a779dda..98f2a844 100644 --- a/framework/Data/SqlMap/TSqlMapConfig.php +++ b/framework/Data/SqlMap/TSqlMapConfig.php @@ -162,4 +162,3 @@ class TSqlMapConfig extends TDataSourceConfig }
}
-?> diff --git a/framework/Data/SqlMap/TSqlMapGateway.php b/framework/Data/SqlMap/TSqlMapGateway.php index dd7c2069..97b31b50 100644 --- a/framework/Data/SqlMap/TSqlMapGateway.php +++ b/framework/Data/SqlMap/TSqlMapGateway.php @@ -259,4 +259,3 @@ class TSqlMapGateway extends TComponent }
}
-?> diff --git a/framework/Data/SqlMap/TSqlMapManager.php b/framework/Data/SqlMap/TSqlMapManager.php index 62c2de20..290050d1 100644 --- a/framework/Data/SqlMap/TSqlMapManager.php +++ b/framework/Data/SqlMap/TSqlMapManager.php @@ -258,4 +258,3 @@ class TSqlMapManager extends TComponent }
}
-?> diff --git a/framework/Data/TDataSourceConfig.php b/framework/Data/TDataSourceConfig.php index 804ea848..9e6bb2fc 100644 --- a/framework/Data/TDataSourceConfig.php +++ b/framework/Data/TDataSourceConfig.php @@ -165,5 +165,3 @@ class TDataSourceConfig extends TModule throw new TConfigurationException('datasource_dbconnection_invalid',$id);
}
}
-
-?>
diff --git a/framework/Data/TDbCommand.php b/framework/Data/TDbCommand.php index c48e7ded..d09c53f4 100644 --- a/framework/Data/TDbCommand.php +++ b/framework/Data/TDbCommand.php @@ -305,4 +305,3 @@ class TDbCommand extends TComponent }
}
-?> diff --git a/framework/Data/TDbConnection.php b/framework/Data/TDbConnection.php index 5489c7fd..259ca7b7 100644 --- a/framework/Data/TDbConnection.php +++ b/framework/Data/TDbConnection.php @@ -167,9 +167,11 @@ class TDbConnection extends TComponent try
{
$this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(),
- $this->getPassword(),$this->_attributes);
+ $this->getPassword(),$this->_attributes); + // This attribute is only useful for PDO::MySql driver. + // Ignore the warning if a driver doesn't understand this. + @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->_active=true;
$this->setConnectionCharset();
}
diff --git a/framework/Data/TDbDataReader.php b/framework/Data/TDbDataReader.php index 65fc363d..7b54414e 100644 --- a/framework/Data/TDbDataReader.php +++ b/framework/Data/TDbDataReader.php @@ -223,4 +223,3 @@ class TDbDataReader extends TComponent implements Iterator }
}
-?> diff --git a/framework/Data/TDbTransaction.php b/framework/Data/TDbTransaction.php index 5a19cacf..60b14a55 100644 --- a/framework/Data/TDbTransaction.php +++ b/framework/Data/TDbTransaction.php @@ -110,4 +110,3 @@ class TDbTransaction extends TComponent }
}
-?> diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index 589e841c..fa8e6d4a 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -362,4 +362,3 @@ class TErrorHandler extends TModule }
}
-?> diff --git a/framework/Exceptions/TException.php b/framework/Exceptions/TException.php index 4173a04e..c6a87b4d 100644 --- a/framework/Exceptions/TException.php +++ b/framework/Exceptions/TException.php @@ -417,4 +417,3 @@ class THttpException extends TSystemException }
}
-?> diff --git a/framework/Exceptions/messages/messages.txt b/framework/Exceptions/messages/messages.txt index 3edd5d49..fc2b63f1 100644 --- a/framework/Exceptions/messages/messages.txt +++ b/framework/Exceptions/messages/messages.txt @@ -408,6 +408,11 @@ soapservice_serverid_duplicated = SOAP server ID '{0}' is duplicated. soapserver_id_invalid = Invalid SOAP server ID '{0}'. It should not end with '.wsdl'. soapserver_version_invalid = Invalid SOAP version '{0}'. It must be either '1.1' or '1.2'. +jsonservice_id_required = TJsonService requires 'id' attribute in its JSON elements. +jsonservice_response_type_invalid = JSON class {0} is invalid. It should be TJsonResponse or extend from TJsonResponse. +jsonservice_class_required = TJsonService requires 'class' attribute in its JSON elements. +jsonservice_provider_unknown = Unknown JSON provider '{0}' requested. + dbusermanager_userclass_required = TDbUserManager.UserClass is required. dbusermanager_userclass_invalid = TDbUserManager.UserClass '{0}' is not a valid user class. The class must extend TDbUser. dbusermanager_connectionid_invalid = TDbUserManager.ConnectionID '{0}' does not point to a valid TDataSourceConfig module. @@ -466,3 +471,5 @@ datasource_dbconnection_invalid = TDataSourceConfig.DbConnection '{0}' is inva response_status_reason_missing = HTTP 1.1 need reason for extended status-codes response_status_reason_badchars = For HTTP 1.1 header, the token status-reason must not contain token CR or LF + +activefileupload_temppath_invalid = TActiveFileUpload TempPath path '{0}' does not exist or is not writable by Web server process. diff --git a/framework/I18N/TDateFormat.php b/framework/I18N/TDateFormat.php index 2343011e..914131bd 100644 --- a/framework/I18N/TDateFormat.php +++ b/framework/I18N/TDateFormat.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.I18N
@@ -51,6 +51,9 @@ Prado::using('System.I18N.TI18NControl'); * 'fulldate', 'longdate', 'mediumdate', 'shortdate', 'fulltime',
* 'longtime', 'mediumtime', and 'shorttime'. Custom patterns can specified
* when the Pattern property does not match the predefined patterns.
+ * - <b>DefaultText</b>, string,
+ * <br>Gets or sets the default text. If Value is not set, DefaultText will be
+ * shown instead of todays date and time.
*
* @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004
@@ -146,7 +149,11 @@ class TDateFormat extends TI18NControl implements IDataRenderer {
$value = $this->getViewState('Value','');
if(empty($value))
- return time();
+ {
+ $defaultText = $this->getDefaultText();
+ if(empty($defaultText))
+ return time();
+ }
return $value;
}
@@ -158,6 +165,24 @@ class TDateFormat extends TI18NControl implements IDataRenderer {
$this->setViewState('Value',$value,'');
}
+
+ /**
+ * Get the default text value for this control.
+ * @return string default text value
+ */
+ public function getDefaultText()
+ {
+ return $this->getViewState('DefaultText','');
+ }
+
+ /**
+ * Set the default text value for this control.
+ * @param string default text value
+ */
+ public function setDefaultText($value)
+ {
+ $this->setViewState('DefaultText',$value,'');
+ }
/**
* Get the date-time value for this control.
@@ -193,6 +218,11 @@ class TDateFormat extends TI18NControl implements IDataRenderer */
protected function getFormattedDate()
{
+ $value = $this->getValue();
+ $defaultText = $this->getDefaultText();
+ if(empty($value) && !empty($defaultText))
+ return $this->getDefaultText();
+
$app = $this->getApplication()->getGlobalization();
//initialized the default class wide formatter
@@ -205,12 +235,12 @@ class TDateFormat extends TI18NControl implements IDataRenderer if(strlen($culture) && $app->getCulture() !== $culture)
{
$formatter = new DateFormat($culture);
- return $formatter->format($this->getValue(),
+ return $formatter->format($value,
$this->getPattern(),
$this->getCharset());
}
//return the application wide culture formatted date time.
- $result = self::$formatter->format($this->getValue(),
+ $result = self::$formatter->format($value,
$this->getPattern(),
$this->getCharset());
return $result;
@@ -221,5 +251,4 @@ class TDateFormat extends TI18NControl implements IDataRenderer $writer->write($this->getFormattedDate());
}
-}
-?> +}
\ No newline at end of file diff --git a/framework/I18N/TGlobalizationAutoDetect.php b/framework/I18N/TGlobalizationAutoDetect.php index b4611910..a77ea861 100644 --- a/framework/I18N/TGlobalizationAutoDetect.php +++ b/framework/I18N/TGlobalizationAutoDetect.php @@ -47,4 +47,3 @@ class TGlobalizationAutoDetect extends TGlobalization }
}
-?> diff --git a/framework/I18N/TI18NControl.php b/framework/I18N/TI18NControl.php index 9060ee77..ac3246fe 100644 --- a/framework/I18N/TI18NControl.php +++ b/framework/I18N/TI18NControl.php @@ -88,4 +88,3 @@ class TI18NControl extends TControl }
}
-?> diff --git a/framework/I18N/TNumberFormat.php b/framework/I18N/TNumberFormat.php index 12422521..62b43243 100644 --- a/framework/I18N/TNumberFormat.php +++ b/framework/I18N/TNumberFormat.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.I18N
@@ -56,6 +56,9 @@ Prado::using('System.I18N.TI18NControl'); * The default is 'USD' if the Currency property is not specified.
* - <b>Pattern</b>, string,
* <br>Gets or sets the custom number formatting pattern.
+ * - <b>DefaultText</b>, string,
+ * <br>Gets or sets the default text. If Value is not set, DefaultText will be
+ * shown instead of the default currency Value/Pattern.
*
* @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version v1.0, last update on Sat Dec 11 17:49:56 EST 2004
@@ -105,6 +108,23 @@ class TNumberFormat extends TI18NControl implements IDataRenderer $this->setViewState('Value',$value,'');
}
+ /**
+ * Get the default text value for this control.
+ * @return string default text value
+ */
+ public function getDefaultText()
+ {
+ return $this->getViewState('DefaultText','');
+ }
+
+ /**
+ * Set the default text value for this control.
+ * @param string default text value
+ */
+ public function setDefaultText($value)
+ {
+ $this->setViewState('DefaultText',$value,'');
+ }
/**
* Get the numberic value for this control.
@@ -193,6 +213,11 @@ class TNumberFormat extends TI18NControl implements IDataRenderer */
protected function getFormattedValue()
{
+ $value = $this->getValue();
+ $defaultText = $this->getDefaultText();
+ if(empty($value) && !empty($defaultText))
+ return $this->getDefaultText();
+
$app = $this->getApplication()->getGlobalization();
//initialized the default class wide formatter
if(is_null(self::$formatter))
@@ -223,4 +248,4 @@ class TNumberFormat extends TI18NControl implements IDataRenderer }
}
-?> +?>
diff --git a/framework/I18N/TTranslate.php b/framework/I18N/TTranslate.php index c3b28c79..2f1e0633 100644 --- a/framework/I18N/TTranslate.php +++ b/framework/I18N/TTranslate.php @@ -254,4 +254,3 @@ class TTranslate extends TI18NControl }
}
-?> diff --git a/framework/I18N/TTranslateParameter.php b/framework/I18N/TTranslateParameter.php index 2b32b27b..37443133 100644 --- a/framework/I18N/TTranslateParameter.php +++ b/framework/I18N/TTranslateParameter.php @@ -117,4 +117,3 @@ class TTranslateParameter extends TControl }
}
-?> diff --git a/framework/I18N/Translation.php b/framework/I18N/Translation.php index cb90577f..a0fa504d 100644 --- a/framework/I18N/Translation.php +++ b/framework/I18N/Translation.php @@ -106,4 +106,3 @@ class Translation extends TComponent }
}
-?> diff --git a/framework/I18N/core/CultureInfo.php b/framework/I18N/core/CultureInfo.php index 46b833b7..7ee50bba 100644 --- a/framework/I18N/core/CultureInfo.php +++ b/framework/I18N/core/CultureInfo.php @@ -630,4 +630,3 @@ class CultureInfo }
}
-?> diff --git a/framework/I18N/core/DateTimeFormatInfo.php b/framework/I18N/core/DateTimeFormatInfo.php index 0a99082d..aebd094a 100644 --- a/framework/I18N/core/DateTimeFormatInfo.php +++ b/framework/I18N/core/DateTimeFormatInfo.php @@ -514,4 +514,3 @@ class DateTimeFormatInfo }
}
-?> diff --git a/framework/I18N/core/Gettext/MO.php b/framework/I18N/core/Gettext/MO.php index 2a85598a..2a97aee7 100644 --- a/framework/I18N/core/Gettext/MO.php +++ b/framework/I18N/core/Gettext/MO.php @@ -353,4 +353,3 @@ class TGettext_MO extends TGettext return true;
}
}
-?> diff --git a/framework/I18N/core/Gettext/PO.php b/framework/I18N/core/Gettext/PO.php index edadbf9a..54fe10e3 100644 --- a/framework/I18N/core/Gettext/PO.php +++ b/framework/I18N/core/Gettext/PO.php @@ -158,4 +158,3 @@ class TGettext_PO extends TGettext return true;
}
}
-?> diff --git a/framework/I18N/core/Gettext/TGettext.php b/framework/I18N/core/Gettext/TGettext.php index ea35154b..39e5d07e 100644 --- a/framework/I18N/core/Gettext/TGettext.php +++ b/framework/I18N/core/Gettext/TGettext.php @@ -284,4 +284,3 @@ class TGettext return $PO;
}
}
-?> diff --git a/framework/I18N/core/HTTPNegotiator.php b/framework/I18N/core/HTTPNegotiator.php index f76efbe2..9199ba15 100644 --- a/framework/I18N/core/HTTPNegotiator.php +++ b/framework/I18N/core/HTTPNegotiator.php @@ -127,4 +127,3 @@ class HTTPNegotiator }
}
-?> diff --git a/framework/I18N/core/IMessageSource.php b/framework/I18N/core/IMessageSource.php index eb0e5a1a..1d40bd73 100644 --- a/framework/I18N/core/IMessageSource.php +++ b/framework/I18N/core/IMessageSource.php @@ -120,4 +120,3 @@ interface IMessageSource }
-?> diff --git a/framework/I18N/core/MessageFormat.php b/framework/I18N/core/MessageFormat.php index 21cf5f23..7af6deb1 100644 --- a/framework/I18N/core/MessageFormat.php +++ b/framework/I18N/core/MessageFormat.php @@ -253,4 +253,3 @@ class MessageFormat }
}
-?> diff --git a/framework/I18N/core/MessageSource_XLIFF.php b/framework/I18N/core/MessageSource_XLIFF.php index f962e9a1..4c101bf0 100644 --- a/framework/I18N/core/MessageSource_XLIFF.php +++ b/framework/I18N/core/MessageSource_XLIFF.php @@ -502,7 +502,7 @@ class MessageSource_XLIFF extends MessageSource {
$date = @date('c');
$xml = <<<EOD
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file
source-language="EN"
diff --git a/framework/I18N/core/NumberFormat.php b/framework/I18N/core/NumberFormat.php index 3edc6482..3b683c6c 100644 --- a/framework/I18N/core/NumberFormat.php +++ b/framework/I18N/core/NumberFormat.php @@ -304,4 +304,3 @@ class NumberFormat }
}
-?> diff --git a/framework/I18N/core/NumberFormatInfo.php b/framework/I18N/core/NumberFormatInfo.php index 136a20eb..17149317 100644 --- a/framework/I18N/core/NumberFormatInfo.php +++ b/framework/I18N/core/NumberFormatInfo.php @@ -648,4 +648,3 @@ class NumberFormatInfo }
}
-?> diff --git a/framework/IO/TTextWriter.php b/framework/IO/TTextWriter.php index 0dd9bcf5..b043e217 100644 --- a/framework/IO/TTextWriter.php +++ b/framework/IO/TTextWriter.php @@ -57,4 +57,3 @@ class TTextWriter extends TComponent implements ITextWriter }
}
-?> diff --git a/framework/PradoBase.php b/framework/PradoBase.php index 15932cad..11bc7f41 100644 --- a/framework/PradoBase.php +++ b/framework/PradoBase.php @@ -115,6 +115,11 @@ class PradoBase return '<a title="Powered by PRADO" href="http://www.pradosoft.com/" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
}
+ public static function metaGenerator() + { + return 'PRADO - http://www.pradosoft.com/'; + } + /**
* PHP error handler.
* This method should be registered as PHP error handler using
diff --git a/framework/Security/IUserManager.php b/framework/Security/IUserManager.php index d8907160..37cf632f 100644 --- a/framework/Security/IUserManager.php +++ b/framework/Security/IUserManager.php @@ -56,4 +56,3 @@ interface IUserManager public function validateUser($username,$password);
}
-?> diff --git a/framework/Security/TAuthManager.php b/framework/Security/TAuthManager.php index 64422845..40d94e19 100644 --- a/framework/Security/TAuthManager.php +++ b/framework/Security/TAuthManager.php @@ -4,7 +4,7 @@ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Security
@@ -25,6 +25,13 @@ Prado::using('System.Security.IUserManager'); * browser to a login page that is specified via the {@link setLoginPage LoginPage}.
* To login or logout a user, call {@link login} or {@link logout}, respectively.
*
+ * The {@link setAuthExpire AuthExpire} property can be used to define the time
+ * in seconds after which the authentication should expire.
+ * {@link setAllowAutoLogin AllowAutoLogin} specifies if the login information
+ * should be stored in a cookie to perform automatic login. Enabling this
+ * feature will cause that {@link setAuthExpire AuthExpire} has no effect
+ * since the user will be logged in again on authentication expiration.
+ *
* To load TAuthManager, configure it in application configuration as follows,
* <module id="auth" class="System.Security.TAuthManager" UserManager="users" LoginPage="login" />
* <module id="users" class="System.Security.TUserManager" />
@@ -68,6 +75,10 @@ class TAuthManager extends TModule * @var string variable name used to store user session or cookie
*/
private $_userKey;
+ /**
+ * @var integer authentication expiration time in seconds. Defaults to zero (no expiration)
+ */
+ private $_authExpire=0;
/**
* Initializes this module.
@@ -242,6 +253,24 @@ class TAuthManager extends TModule }
/**
+ * @return integer authentication expiration time in seconds. Defaults to zero (no expiration).
+ * @since 3.1.3
+ */
+ public function getAuthExpire()
+ {
+ return $this->_authExpire;
+ }
+
+ /**
+ * @param integer authentication expiration time in seconds. Defaults to zero (no expiration).
+ * @since 3.1.3
+ */
+ public function setAuthExpire($value)
+ {
+ $this->_authExpire=TPropertyValue::ensureInteger($value);
+ }
+
+ /**
* Performs the real authentication work.
* An OnAuthenticate event will be raised if there is any handler attached to it.
* If the application already has a non-null user, it will return without further authentication.
@@ -260,8 +289,12 @@ class TAuthManager extends TModule $sessionInfo=$session->itemAt($this->getUserKey());
$user=$this->_userManager->getUser(null)->loadFromString($sessionInfo);
+ // check for authentication expiration
+ $isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() &&
+ ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time();
+
// try authenticating through cookie if possible
- if($this->getAllowAutoLogin() && $user->getIsGuest())
+ if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
{
$cookie=$this->getRequest()->getCookies()->itemAt($this->getUserKey());
if($cookie instanceof THttpCookie)
@@ -270,17 +303,37 @@ class TAuthManager extends TModule {
$user=$user2;
$this->updateSessionUser($user);
+ // user is restored from cookie, auth may not expire
+ $isAuthExpired = false;
}
}
}
$application->setUser($user);
+ // handle authentication expiration or update expiration time
+ if($isAuthExpired)
+ $this->onAuthExpire($param);
+ else
+ $session->add('AuthExpireTime', time() + $this->_authExpire);
+
// event handler gets a chance to do further auth work
if($this->hasEventHandler('OnAuthenticate'))
$this->raiseEvent('OnAuthenticate',$this,$application);
}
-
+
+ /**
+ * Performs user logout on authentication expiration.
+ * An 'OnAuthExpire' event will be raised if there is any handler attached to it.
+ * @param mixed parameter to be passed to OnAuthExpire event.
+ */
+ public function onAuthExpire($param)
+ {
+ $this->logout();
+ if($this->hasEventHandler('OnAuthExpire'))
+ $this->raiseEvent('OnAuthExpire',$this,$param);
+ }
+
/**
* Performs the real authorization work.
* Authorization rules obtained from the application will be used to check
@@ -401,4 +454,4 @@ class TAuthManager extends TModule }
}
-?> +?>
diff --git a/framework/Security/TAuthorizationRule.php b/framework/Security/TAuthorizationRule.php index d301737b..896ce376 100644 --- a/framework/Security/TAuthorizationRule.php +++ b/framework/Security/TAuthorizationRule.php @@ -294,4 +294,3 @@ class TAuthorizationRuleCollection extends TList }
}
-?> diff --git a/framework/Security/TDbUserManager.php b/framework/Security/TDbUserManager.php index bd70de8d..873d43f8 100644 --- a/framework/Security/TDbUserManager.php +++ b/framework/Security/TDbUserManager.php @@ -318,4 +318,3 @@ abstract class TDbUser extends TUser }
}
-?> diff --git a/framework/Security/TSecurityManager.php b/framework/Security/TSecurityManager.php index 9fbadd10..d43c9fec 100644 --- a/framework/Security/TSecurityManager.php +++ b/framework/Security/TSecurityManager.php @@ -279,4 +279,3 @@ class TSecurityManagerValidationMode extends TEnumerable const SHA1='SHA1';
}
-?> diff --git a/framework/Security/TUser.php b/framework/Security/TUser.php index d0e850cf..35e3e3a5 100644 --- a/framework/Security/TUser.php +++ b/framework/Security/TUser.php @@ -220,4 +220,3 @@ class TUser extends TComponent implements IUser }
}
-?> diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php index 6326803d..dbaa5ffb 100644 --- a/framework/Security/TUserManager.php +++ b/framework/Security/TUserManager.php @@ -148,7 +148,7 @@ class TUserManager extends TModule implements IUserManager * Loads user/role information from an XML node.
* @param TXmlElement the XML node containing the user information
*/
- private function loadUserDataFromXml($xmlNode)
+ protected function loadUserDataFromXml($xmlNode)
{
foreach($xmlNode->getElementsByTagName('user') as $node)
{
diff --git a/framework/TApplication.php b/framework/TApplication.php index d9626179..e690aa96 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -293,6 +293,11 @@ class TApplication extends TComponent * @var TApplicationMode application mode */ private $_mode=TApplicationMode::Debug; + + /** + * @var string Customizable page service ID + */ + private $_pageServiceID = self::PAGE_SERVICE_ID; /** * Constructor. @@ -325,7 +330,8 @@ class TApplication extends TComponent // generates unique ID by hashing the runtime path $this->_uniqueID=md5($this->_runtimePath); $this->_parameters=new TMap; - $this->_services=array(self::PAGE_SERVICE_ID=>array('TPageService',array(),null)); + $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); + Prado::setPathOfAlias('Application',$this->_basePath); } @@ -509,6 +515,22 @@ class TApplication extends TComponent { $this->_id=$value; } + + /** + * @return string page service ID + */ + public function getPageServiceID() + { + return $this->_pageServiceID; + } + + /** + * @param string page service ID + */ + public function setPageServiceID($value) + { + $this->_pageServiceID=$value; + } /** * @return string an ID that uniquely identifies this Prado application from the others @@ -623,6 +645,10 @@ class TApplication extends TComponent public function setRuntimePath($value) { $this->_runtimePath=$value; + if($this->_cacheFile) + $this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE; + // generates unique ID by hashing the runtime path + $this->_uniqueID=md5($this->_runtimePath); } /** @@ -912,6 +938,9 @@ class TApplication extends TComponent foreach($config->getProperties() as $name=>$value) $this->setSubProperty($name,$value); } + + if(empty($this->_services)) + $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); // load parameters foreach($config->getParameters() as $id=>$parameter) @@ -996,8 +1025,8 @@ class TApplication extends TComponent } if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) - $serviceID=self::PAGE_SERVICE_ID; - + $serviceID=$this->getPageServiceID(); + $this->startService($serviceID); } @@ -1761,4 +1790,3 @@ class TApplicationStatePersister extends TModule implements IStatePersister } } -?> diff --git a/framework/TApplicationComponent.php b/framework/TApplicationComponent.php index 41e1b80e..6e2c5bbe 100644 --- a/framework/TApplicationComponent.php +++ b/framework/TApplicationComponent.php @@ -116,4 +116,3 @@ class TApplicationComponent extends TComponent }
}
-?> diff --git a/framework/TComponent.php b/framework/TComponent.php index cba21b7d..f9c36cc8 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -839,4 +839,3 @@ class TComponentReflection extends TComponent } } -?> diff --git a/framework/TModule.php b/framework/TModule.php index 9ff20d6f..6426aa70 100644 --- a/framework/TModule.php +++ b/framework/TModule.php @@ -54,4 +54,3 @@ abstract class TModule extends TApplicationComponent implements IModule }
}
-?> diff --git a/framework/TService.php b/framework/TService.php index a10460cc..cf2fb142 100644 --- a/framework/TService.php +++ b/framework/TService.php @@ -81,4 +81,3 @@ abstract class TService extends TApplicationComponent implements IService }
}
-?> diff --git a/framework/TShellApplication.php b/framework/TShellApplication.php index ad219cd1..0d2cb826 100644 --- a/framework/TShellApplication.php +++ b/framework/TShellApplication.php @@ -46,4 +46,3 @@ class TShellApplication extends TApplication }
}
-?> diff --git a/framework/Util/TDataFieldAccessor.php b/framework/Util/TDataFieldAccessor.php index fa65a9a2..bf0b58ae 100644 --- a/framework/Util/TDataFieldAccessor.php +++ b/framework/Util/TDataFieldAccessor.php @@ -80,4 +80,3 @@ class TDataFieldAccessor }
}
-?> diff --git a/framework/Util/TLogRouter.php b/framework/Util/TLogRouter.php index 5c755985..aa772194 100644 --- a/framework/Util/TLogRouter.php +++ b/framework/Util/TLogRouter.php @@ -96,6 +96,20 @@ class TLogRouter extends TModule }
/**
+ * Adds a TLogRoute instance to the log router.
+ *
+ * @param TLogRoute $route
+ * @throws TInvalidDataTypeException if the route object is invalid
+ */
+ public function addRoute($route)
+ {
+ if(!($route instanceof TLogRoute))
+ throw new TInvalidDataTypeException('logrouter_routetype_invalid');
+ $this->_routes[]=$route;
+ $route->init(null);
+ }
+
+ /**
* @return string external configuration file. Defaults to null.
*/
public function getConfigFile()
@@ -106,11 +120,11 @@ class TLogRouter extends TModule /**
* @param string external configuration file in namespace format. The file
* must be suffixed with '.xml'.
- * @throws TInvalidDataValueException if the file is invalid.
+ * @throws TConfigurationException if the file is invalid.
*/
public function setConfigFile($value)
{
- if(($this->_configFile=Prado::getPathOfNamespace($value,self::LOG_FILE_EXT))===null)
+ if(($this->_configFile=Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT))===null)
throw new TConfigurationException('logrouter_configfile_invalid',$value);
}
@@ -509,8 +523,9 @@ class TEmailLogRoute extends TLogRoute foreach($logs as $log)
$message.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);
$message=wordwrap($message,70);
+ $returnPath = ini_get('sendmail_path') ? "Return-Path:{$this->_from}\r\n" : '';
foreach($this->_emails as $email)
- mail($email,$this->getSubject(),$message,"From:{$this->_from}\r\n");
+ mail($email,$this->getSubject(),$message,"From:{$this->_from}\r\n{$returnPath}");
}
diff --git a/framework/Util/TLogger.php b/framework/Util/TLogger.php index 6d5385eb..51005883 100644 --- a/framework/Util/TLogger.php +++ b/framework/Util/TLogger.php @@ -127,4 +127,3 @@ class TLogger extends TComponent }
}
-?> diff --git a/framework/Util/TParameterModule.php b/framework/Util/TParameterModule.php index 020db8db..529f20ca 100644 --- a/framework/Util/TParameterModule.php +++ b/framework/Util/TParameterModule.php @@ -141,4 +141,3 @@ class TParameterModule extends TModule }
}
-?> diff --git a/framework/Util/TVarDumper.php b/framework/Util/TVarDumper.php index 180bb71a..e30e2400 100644 --- a/framework/Util/TVarDumper.php +++ b/framework/Util/TVarDumper.php @@ -126,4 +126,3 @@ class TVarDumper }
}
-?> diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php index 511515c8..9c4741a4 100644 --- a/framework/Web/Javascripts/TJavaScript.php +++ b/framework/Web/Javascripts/TJavaScript.php @@ -227,4 +227,3 @@ class TJavaScript }
}
-?> diff --git a/framework/Web/Javascripts/source/packages.php b/framework/Web/Javascripts/source/packages.php index 1cca7b7c..d6c04e7f 100644 --- a/framework/Web/Javascripts/source/packages.php +++ b/framework/Web/Javascripts/source/packages.php @@ -47,7 +47,8 @@ $packages = array( ),
'dragdrop'=>array(
- SCRIPTACULOUS_DIR.'/dragdrop.js'
+ SCRIPTACULOUS_DIR.'/dragdrop.js', + 'prado/activecontrols/dragdrop.js'
),
'slider'=>array(
@@ -60,6 +61,14 @@ $packages = array( 'tabpanel'=>array(
'prado/controls/tabpanel.js'
+ ), + + 'activedatepicker' => array( + 'prado/activecontrols/activedatepicker.js' + ), + + 'activefileupload' => array( + 'prado/activefileupload/activefileupload.js' ),
);
@@ -67,19 +76,20 @@ $packages = array( //package names and their dependencies
$dependencies = array(
- 'prado' => array('prado'),
- 'effects' => array('prado', 'effects'),
- 'validator' => array('prado', 'validator'),
- 'logger' => array('prado', 'logger'),
- 'datepicker' => array('prado', 'datepicker'),
- 'colorpicker' => array('prado', 'colorpicker'),
- 'ajax' => array('prado', 'effects', 'ajax'),
- 'dragdrop' => array('prado', 'effects', 'dragdrop'),
- 'slider' => array('prado', 'slider'),
- 'keyboard' => array('prado', 'keyboard'),
- 'tabpanel' => array('prado', 'tabpanel'),
+ 'prado' => array('prado'),
+ 'effects' => array('prado', 'effects'),
+ 'validator' => array('prado', 'validator'),
+ 'logger' => array('prado', 'logger'),
+ 'datepicker' => array('prado', 'datepicker'),
+ 'colorpicker' => array('prado', 'colorpicker'),
+ 'ajax' => array('prado', 'effects', 'ajax'),
+ 'dragdrop' => array('prado', 'effects', 'ajax', 'dragdrop'),
+ 'slider' => array('prado', 'slider'),
+ 'keyboard' => array('prado', 'keyboard'),
+ 'tabpanel' => array('prado', 'tabpanel'), + 'activedatepicker' => array('datepicker', 'ajax', 'activedatepicker'), + 'activefileupload' => array('prado', 'ajax', 'activefileupload'),
);
return array($packages, $dependencies);
-?> diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index 7ee4c0e6..d5cae7b8 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -1,362 +1,387 @@ -/**
- * Generic postback control.
- */
-Prado.WebUI.CallbackControl = Class.extend(Prado.WebUI.PostBackControl,
-{
- onPostBack : function(event, options)
- {
- var request = new Prado.CallbackRequest(options.EventTarget, options);
- request.dispatch();
- Event.stop(event);
- }
-});
-
-/**
- * TActiveButton control.
- */
-Prado.WebUI.TActiveButton = Class.extend(Prado.WebUI.CallbackControl);
-/**
- * TActiveLinkButton control.
- */
-Prado.WebUI.TActiveLinkButton = Class.extend(Prado.WebUI.CallbackControl);
-
-Prado.WebUI.TActiveImageButton = Class.extend(Prado.WebUI.TImageButton,
-{
- onPostBack : function(event, options)
- {
- this.addXYInput(event,options);
- var request = new Prado.CallbackRequest(options.EventTarget, options);
- request.dispatch();
- Event.stop(event);
- }
-});
-/**
- * Active check box.
- */
-Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl,
-{
- onPostBack : function(event, options)
- {
- var request = new Prado.CallbackRequest(options.EventTarget, options);
- if(request.dispatch()==false)
- Event.stop(event);
- }
-});
-
-/**
- * TActiveRadioButton control.
- */
-Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox);
-
-
-Prado.WebUI.TActiveCheckBoxList = Base.extend(
-{
- constructor : function(options)
- {
- for(var i = 0; i<options.ItemCount; i++)
- {
- var checkBoxOptions = Object.extend(
- {
- ID : options.ListID+"_c"+i,
- EventTarget : options.ListName+"$c"+i
- }, options);
- new Prado.WebUI.TActiveCheckBox(checkBoxOptions);
- }
- }
-});
-
-Prado.WebUI.TActiveRadioButtonList = Prado.WebUI.TActiveCheckBoxList;
-
-/**
- * TActiveTextBox control, handles onchange event.
- */
-Prado.WebUI.TActiveTextBox = Class.extend(Prado.WebUI.TTextBox,
-{
- onInit : function(options)
- {
- this.options=options;
- if(options['TextMode'] != 'MultiLine')
- Event.observe(this.element, "keydown", this.handleReturnKey.bind(this));
- if(this.options['AutoPostBack']==true)
- Event.observe(this.element, "change", this.doCallback.bindEvent(this,options));
- },
-
- doCallback : function(event, options)
- {
- var request = new Prado.CallbackRequest(options.EventTarget, options);
- request.dispatch();
- if (!Prototype.Browser.IE)
- Event.stop(event);
- }
-});
-
-/**
- * TAutoComplete control.
- */
-Prado.WebUI.TAutoComplete = Class.extend(Autocompleter.Base, Prado.WebUI.TActiveTextBox.prototype);
-Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete,
-{
- initialize : function(options)
- {
- this.options = options;
- this.hasResults = false;
- this.baseInitialize(options.ID, options.ResultPanel, options);
- Object.extend(this.options,
- {
- onSuccess : this.onComplete.bind(this)
- });
-
- if(options.AutoPostBack)
- this.onInit(options);
- },
-
- doCallback : function(event, options)
- {
- if(!this.active)
- {
- var request = new Prado.CallbackRequest(this.options.EventTarget, options);
- request.dispatch();
- Event.stop(event);
- }
- },
-
- //Overrides parent implementation, fires onchange event.
- onClick: function(event)
- {
- var element = Event.findElement(event, 'LI');
- this.index = element.autocompleteIndex;
- this.selectEntry();
- this.hide();
- Event.fireEvent(this.element, "change");
- },
-
- getUpdatedChoices : function()
- {
- var options = new Array(this.getToken(),"__TAutoComplete_onSuggest__");
- Prado.Callback(this.options.EventTarget, options, null, this.options);
- },
-
- /**
- * Overrides parent implements, don't update if no results.
- */
- selectEntry: function()
- {
- if(this.hasResults)
- {
- this.active = false;
- this.updateElement(this.getCurrentEntry());
- var options = [this.index, "__TAutoComplete_onSuggestionSelected__"];
- Prado.Callback(this.options.EventTarget, options, null, this.options);
- }
- },
-
- onComplete : function(request, boundary)
- {
- var result = Prado.Element.extractContent(request.transport.responseText, boundary);
- if(typeof(result) == "string")
- {
- if(result.length > 0)
- {
- this.hasResults = true;
- this.updateChoices(result);
- }
- else
- {
- this.active = false;
- this.hasResults = false;
- this.hide();
- }
- }
- }
-});
-
-/**
- * Time Triggered Callback class.
- */
-Prado.WebUI.TTimeTriggeredCallback = Base.extend(
-{
- constructor : function(options)
- {
- this.options = Object.extend({ Interval : 1 }, options || {});
- Prado.WebUI.TTimeTriggeredCallback.register(this);
- },
-
- startTimer : function()
- {
- setTimeout(this.onTimerEvent.bind(this), 100);
- if(typeof(this.timer) == 'undefined' || this.timer == null)
- this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);
- },
-
- stopTimer : function()
- {
- if(typeof(this.timer) != 'undefined')
- {
- clearInterval(this.timer);
- this.timer = null;
- }
- },
-
- onTimerEvent : function()
- {
- var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
- request.dispatch();
- }
-},
-//class methods
-{
- timers : {},
-
- register : function(timer)
- {
- Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID] = timer;
- },
-
- start : function(id)
- {
- if(Prado.WebUI.TTimeTriggeredCallback.timers[id])
- Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();
- },
-
- stop : function(id)
- {
- if(Prado.WebUI.TTimeTriggeredCallback.timers[id])
- Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();
- }
-});
-
-Prado.WebUI.ActiveListControl = Base.extend(
-{
- constructor : function(options)
- {
- this.element = $(options.ID);
- if(this.element)
- {
- this.options = options;
- Event.observe(this.element, "change", this.doCallback.bind(this));
- }
- },
-
- doCallback : function(event)
- {
- var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
- request.dispatch();
- Event.stop(event);
- }
-});
-
-Prado.WebUI.TActiveDropDownList = Prado.WebUI.ActiveListControl;
-Prado.WebUI.TActiveListBox = Prado.WebUI.ActiveListControl;
-
-/**
- * Observe event of a particular control to trigger a callback request.
- */
-Prado.WebUI.TEventTriggeredCallback = Base.extend(
-{
- constructor : function(options)
- {
- this.options = options;
- var element = $(options['ControlID']);
- if(element)
- Event.observe(element, this.getEventName(element), this.doCallback.bind(this));
- },
-
- getEventName : function(element)
- {
- var name = this.options.EventName;
- if(typeof(name) == "undefined" && element.type)
- {
- switch (element.type.toLowerCase())
- {
- case 'password':
- case 'text':
- case 'textarea':
- case 'select-one':
- case 'select-multiple':
- return 'change';
- }
- }
- return typeof(name) == "undefined" || name == "undefined" ? 'click' : name;
- },
-
- doCallback : function(event)
- {
- var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
- request.dispatch();
- if(this.options.StopEvent == true)
- Event.stop(event);
- }
-});
-
-/**
- * Observe changes to a property of a particular control to trigger a callback.
- */
-Prado.WebUI.TValueTriggeredCallback = Base.extend(
-{
- count : 1,
-
- observing : true,
-
- constructor : function(options)
- {
- this.options = options;
- this.options.PropertyName = this.options.PropertyName || 'value';
- var element = $(options['ControlID']);
- this.value = element ? element[this.options.PropertyName] : undefined;
- Prado.WebUI.TValueTriggeredCallback.register(this);
- this.startObserving();
- },
-
- stopObserving : function()
- {
- clearTimeout(this.timer);
- this.observing = false;
- },
-
- startObserving : function()
- {
- this.timer = setTimeout(this.checkChanges.bind(this), this.options.Interval*1000);
- },
-
- checkChanges : function()
- {
- var element = $(this.options.ControlID);
- if(element)
- {
- var value = element[this.options.PropertyName];
- if(this.value != value)
- {
- this.doCallback(this.value, value);
- this.value = value;
- this.count=1;
- }
- else
- this.count = this.count + this.options.Decay;
- if(this.observing)
- this.time = setTimeout(this.checkChanges.bind(this),
- parseInt(this.options.Interval*1000*this.count));
- }
- },
-
- doCallback : function(oldValue, newValue)
- {
- var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
- var param = {'OldValue' : oldValue, 'NewValue' : newValue};
- request.setCallbackParameter(param);
- request.dispatch();
- }
-},
-//class methods
-{
- timers : {},
-
- register : function(timer)
- {
- Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID] = timer;
- },
-
- stop : function(id)
- {
- Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();
- }
-});
+/** + * Generic postback control. + */ +Prado.WebUI.CallbackControl = Class.extend(Prado.WebUI.PostBackControl, +{ + onPostBack : function(event, options) + { + var request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); + Event.stop(event); + } +}); + +/** + * TActiveButton control. + */ +Prado.WebUI.TActiveButton = Class.extend(Prado.WebUI.CallbackControl); +/** + * TActiveLinkButton control. + */ +Prado.WebUI.TActiveLinkButton = Class.extend(Prado.WebUI.CallbackControl); + +Prado.WebUI.TActiveImageButton = Class.extend(Prado.WebUI.TImageButton, +{ + onPostBack : function(event, options) + { + this.addXYInput(event,options); + var request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); + Event.stop(event); + this.removeXYInput(event,options); + } +}); +/** + * Active check box. + */ +Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl, +{ + onPostBack : function(event, options) + { + var request = new Prado.CallbackRequest(options.EventTarget, options); + if(request.dispatch()==false) + Event.stop(event); + } +}); + +/** + * TActiveRadioButton control. + */ +Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox); + + +Prado.WebUI.TActiveCheckBoxList = Base.extend( +{ + constructor : function(options) + { + for(var i = 0; i<options.ItemCount; i++) + { + var checkBoxOptions = Object.extend( + { + ID : options.ListID+"_c"+i, + EventTarget : options.ListName+"$c"+i + }, options); + new Prado.WebUI.TActiveCheckBox(checkBoxOptions); + } + } +}); + +Prado.WebUI.TActiveRadioButtonList = Prado.WebUI.TActiveCheckBoxList; + +/** + * TActiveTextBox control, handles onchange event. + */ +Prado.WebUI.TActiveTextBox = Class.extend(Prado.WebUI.TTextBox, +{ + onInit : function(options) + { + this.options=options; + if(options['TextMode'] != 'MultiLine') + Event.observe(this.element, "keydown", this.handleReturnKey.bind(this)); + if(this.options['AutoPostBack']==true) + Event.observe(this.element, "change", this.doCallback.bindEvent(this,options)); + }, + + doCallback : function(event, options) + { + var request = new Prado.CallbackRequest(options.EventTarget, options); + request.dispatch(); + if (!Prototype.Browser.IE) + Event.stop(event); + } +}); + +/** + * TAutoComplete control. + */ +Prado.WebUI.TAutoComplete = Class.extend(Autocompleter.Base, Prado.WebUI.TActiveTextBox.prototype); +Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, +{ + initialize : function(options) + { + this.options = options; + this.hasResults = false; + this.baseInitialize(options.ID, options.ResultPanel, options); + Object.extend(this.options, + { + onSuccess : this.onComplete.bind(this) + }); + + if(options.AutoPostBack) + this.onInit(options); + }, + + doCallback : function(event, options) + { + if(!this.active) + { + var request = new Prado.CallbackRequest(this.options.EventTarget, options); + request.dispatch(); + Event.stop(event); + } + }, + + //Overrides parent implementation, fires onchange event. + onClick: function(event) + { + var element = Event.findElement(event, 'LI'); + this.index = element.autocompleteIndex; + this.selectEntry(); + this.hide(); + Event.fireEvent(this.element, "change"); + }, + + getUpdatedChoices : function() + { + var options = new Array(this.getToken(),"__TAutoComplete_onSuggest__"); + Prado.Callback(this.options.EventTarget, options, null, this.options); + }, + + /** + * Overrides parent implements, don't update if no results. + */ + selectEntry: function() + { + if(this.hasResults) + { + this.active = false; + this.updateElement(this.getCurrentEntry()); + var options = [this.index, "__TAutoComplete_onSuggestionSelected__"]; + Prado.Callback(this.options.EventTarget, options, null, this.options); + } + }, + + onComplete : function(request, boundary) + { + var result = Prado.Element.extractContent(request.transport.responseText, boundary); + if(typeof(result) == "string") + { + if(result.length > 0) + { + this.hasResults = true; + this.updateChoices(result); + } + else + { + this.active = false; + this.hasResults = false; + this.hide(); + } + } + } +}); + +/** + * Time Triggered Callback class. + */ +Prado.WebUI.TTimeTriggeredCallback = Base.extend( +{ + constructor : function(options) + { + this.options = Object.extend({ Interval : 1 }, options || {}); + Prado.WebUI.TTimeTriggeredCallback.register(this); + }, + + startTimer : function() + { + setTimeout(this.onTimerEvent.bind(this), 100); + if(typeof(this.timer) == 'undefined' || this.timer == null) + this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000); + }, + + stopTimer : function() + { + if(typeof(this.timer) != 'undefined') + { + clearInterval(this.timer); + this.timer = null; + } + }, + + resetTimer : function() + { + if(typeof(this.timer) != 'undefined') + { + clearInterval(this.timer); + this.timer = null; + this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000); + } + }, + + onTimerEvent : function() + { + var request = new Prado.CallbackRequest(this.options.EventTarget, this.options); + request.dispatch(); + }, + + setInterval : function(value) + { + if (this.options.Interval != value){ + this.options.Interval = value; + this.resetTimer(); + } + } +}, +//class methods +{ + timers : {}, + + register : function(timer) + { + Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID] = timer; + }, + + start : function(id) + { + if(Prado.WebUI.TTimeTriggeredCallback.timers[id]) + Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer(); + }, + + stop : function(id) + { + if(Prado.WebUI.TTimeTriggeredCallback.timers[id]) + Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer(); + }, + + setInterval : function (id,value) + { + if(Prado.WebUI.TTimeTriggeredCallback.timers[id]) + Prado.WebUI.TTimeTriggeredCallback.timers[id].setInterval(value); + } +}); + +Prado.WebUI.ActiveListControl = Base.extend( +{ + constructor : function(options) + { + this.element = $(options.ID); + if(this.element) + { + this.options = options; + Event.observe(this.element, "change", this.doCallback.bind(this)); + } + }, + + doCallback : function(event) + { + var request = new Prado.CallbackRequest(this.options.EventTarget, this.options); + request.dispatch(); + Event.stop(event); + } +}); + +Prado.WebUI.TActiveDropDownList = Prado.WebUI.ActiveListControl; +Prado.WebUI.TActiveListBox = Prado.WebUI.ActiveListControl; + +/** + * Observe event of a particular control to trigger a callback request. + */ +Prado.WebUI.TEventTriggeredCallback = Base.extend( +{ + constructor : function(options) + { + this.options = options; + var element = $(options['ControlID']); + if(element) + Event.observe(element, this.getEventName(element), this.doCallback.bind(this)); + }, + + getEventName : function(element) + { + var name = this.options.EventName; + if(typeof(name) == "undefined" && element.type) + { + switch (element.type.toLowerCase()) + { + case 'password': + case 'text': + case 'textarea': + case 'select-one': + case 'select-multiple': + return 'change'; + } + } + return typeof(name) == "undefined" || name == "undefined" ? 'click' : name; + }, + + doCallback : function(event) + { + var request = new Prado.CallbackRequest(this.options.EventTarget, this.options); + request.dispatch(); + if(this.options.StopEvent == true) + Event.stop(event); + } +}); + +/** + * Observe changes to a property of a particular control to trigger a callback. + */ +Prado.WebUI.TValueTriggeredCallback = Base.extend( +{ + count : 1, + + observing : true, + + constructor : function(options) + { + this.options = options; + this.options.PropertyName = this.options.PropertyName || 'value'; + var element = $(options['ControlID']); + this.value = element ? element[this.options.PropertyName] : undefined; + Prado.WebUI.TValueTriggeredCallback.register(this); + this.startObserving(); + }, + + stopObserving : function() + { + clearTimeout(this.timer); + this.observing = false; + }, + + startObserving : function() + { + this.timer = setTimeout(this.checkChanges.bind(this), this.options.Interval*1000); + }, + + checkChanges : function() + { + var element = $(this.options.ControlID); + if(element) + { + var value = element[this.options.PropertyName]; + if(this.value != value) + { + this.doCallback(this.value, value); + this.value = value; + this.count=1; + } + else + this.count = this.count + this.options.Decay; + if(this.observing) + this.time = setTimeout(this.checkChanges.bind(this), + parseInt(this.options.Interval*1000*this.count)); + } + }, + + doCallback : function(oldValue, newValue) + { + var request = new Prado.CallbackRequest(this.options.EventTarget, this.options); + var param = {'OldValue' : oldValue, 'NewValue' : newValue}; + request.setCallbackParameter(param); + request.dispatch(); + } +}, +//class methods +{ + timers : {}, + + register : function(timer) + { + Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID] = timer; + }, + + stop : function(id) + { + Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving(); + } +}); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js new file mode 100755 index 00000000..87b48bf3 --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js @@ -0,0 +1,79 @@ +/** + * TActiveDatePicker control + */ +Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, +{ + initialize : function(options) + { + this.options = options || []; + this.control = $(options.ID); + this.dateSlot = new Array(42); + this.weekSlot = new Array(6); + this.minimalDaysInFirstWeek = 4; + this.selectedDate = this.newDate(); + this.positionMode = 'Bottom'; + + //which element to trigger to show the calendar + if(this.options.Trigger) + { + this.trigger = $(this.options.Trigger) ; + var triggerEvent = this.options.TriggerEvent || "click"; + } + else + { + this.trigger = this.control; + var triggerEvent = this.options.TriggerEvent || "focus"; + } + + // Popup position + if(this.options.PositionMode == 'Top') + { + this.positionMode = this.options.PositionMode; + } + + Object.extend(this,options); + + Event.observe(this.trigger, triggerEvent, this.show.bindEvent(this)); + + // Listen to change event + if(this.options.InputMode == "TextBox") + { + Event.observe(this.control, "change", this.onDateChanged.bindEvent(this)); + } + else + { + var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); + var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control); + var year = Prado.WebUI.TDatePicker.getYearListControl(this.control); + Event.observe (day, "change", this.onDateChanged.bindEvent(this)); + Event.observe (month, "change", this.onDateChanged.bindEvent(this)); + Event.observe (year, "change", this.onDateChanged.bindEvent(this)); + + } + + }, + + // Respond to change event on the textbox or dropdown list + // This method raises OnDateChanged event on client side if it has been defined, + // and raise the callback request + onDateChanged : function () + { + var date; + if (this.options.InputMode == "TextBox") + { + date=this.control.value; + } + else + { + var day = Prado.WebUI.TDatePicker.getDayListControl(this.control).selectedIndex+1; + var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control).selectedIndex; + var year = Prado.WebUI.TDatePicker.getYearListControl(this.control).value; + date=new Date(year, month, day, 0,0,0).SimpleFormat(this.Format, this); + } + if (typeof(this.options.OnDateChanged) == "function") this.options.OnDateChanged(this, date); + + // Make callback request + var request = new Prado.CallbackRequest(this.options.EventTarget,this.options); + request.dispatch(); + } +}); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js new file mode 100755 index 00000000..0b42afd5 --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js @@ -0,0 +1,24 @@ +/** + * DropContainer control + */ + +Prado.WebUI.DropContainer = Class.extend(Prado.WebUI.CallbackControl); + +Object.extend(Prado.WebUI.DropContainer.prototype, +{ + initialize: function(options) + { + this.options = options; + Object.extend (this.options, + { + onDrop: this.onDrop.bind(this) + }); + + Droppables.add (options.ID, this.options); + }, + + onDrop: function(dragElement, dropElement) + { + Prado.Callback(this.options.EventTarget, dragElement.id, null, this.options); + } +}); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js index 87b8ddde..51e3f489 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js @@ -188,7 +188,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( if(this.options.AutoHide)
this.showLabel();
}
- else if (Event.keyCode(e) == Event.KEY_RETURN)
+ else if (Event.keyCode(e) == Event.KEY_RETURN && this.options.TextMode != 'MultiLine')
Event.stop(e);
},
diff --git a/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadBlank.html b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadBlank.html new file mode 100755 index 00000000..44f50ce4 --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadBlank.html @@ -0,0 +1 @@ +<!-- Nothing here to see, move right along. -->
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadComplete.png b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadComplete.png Binary files differnew file mode 100755 index 00000000..98badd7f --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadComplete.png diff --git a/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadError.png b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadError.png Binary files differnew file mode 100755 index 00000000..26c529fc --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadError.png diff --git a/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadIndicator.gif b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadIndicator.gif Binary files differnew file mode 100755 index 00000000..085ccaec --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activefileupload/ActiveFileUploadIndicator.gif diff --git a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js new file mode 100755 index 00000000..9f57f912 --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js @@ -0,0 +1,63 @@ +Prado.WebUI.TActiveFileUpload = Base.extend( +{ + constructor : function(options) + { + this.options = options || {}; + Prado.WebUI.TActiveFileUpload.register(this); + + this.input = $(options.inputID); + this.flag = $(options.flagID); + this.form = $(options.formID); + + this.indicator = $(options.indicatorID); + this.complete = $(options.completeID); + this.error = $(options.errorID); + + // set up events + Event.observe(this.input,"change",this.fileChanged.bind(this)); + }, + + fileChanged:function(){ + // show the upload indicator, and hide the complete and error indicators (if they areSn't already). + this.flag.value = '1'; + this.complete.style.display = 'none'; + this.error.style.display = 'none'; + this.indicator.style.display = ''; + + // set the form to submit in the iframe, submit it, and then reset it. + this.oldtargetID = this.form.target; + this.form.target = this.options.targetID; + this.form.submit(); + this.form.target = this.oldtargetID; + }, + + finishUpload:function(options){ + // hide the display indicator. + this.flag.value = ''; + this.indicator.style.display = 'none'; + if (this.options.targetID == options.targetID){ + // show the complete indicator. + if (options.errorCode == 0){ + this.complete.style.display = ''; + this.input.value = ''; + } else { + this.error.style.display = ''; + } + Prado.Callback(this.options.EventTarget, options, null, this.options); + } + } +}, +{ +// class methods + controls : {}, + + register : function(control) + { + Prado.WebUI.TActiveFileUpload.controls[control.options.ID] = control; + }, + + onFileUpload: function(options) + { + Prado.WebUI.TActiveFileUpload.controls[options.clientID].finishUpload(options); + } +});
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/activeratings/blocks.css b/framework/Web/Javascripts/source/prado/activeratings/blocks.css deleted file mode 100644 index bb846094..00000000 --- a/framework/Web/Javascripts/source/prado/activeratings/blocks.css +++ /dev/null @@ -1,42 +0,0 @@ -.TActiveRatingList_blocks
-{
- border-collapse: collapse;
-}
-.TActiveRatingList_blocks input, .TActiveRatingList_blocks label
-{
- display: none;
-}
-
-.TActiveRatingList_blocks td
-{
- width: 18px;
- height: 9px;
- padding: 1px;
-}
-
-.TActiveRatingList_blocks td.rating
-{
- background-image: url(blocks_combined.gif);
- background-repeat: no-repeat;
- cursor: pointer;
- background-position: 1px 0px;
-}
-.TActiveRatingList_blocks td.rating_selected
-{
- background-position: 1px -100px;
-}
-
-.TActiveRatingList_blocks td.rating_half
-{
- background-position: 1px -200px;
-}
-
-.TActiveRatingList_blocks td.rating_hover
-{
- background-position: 1px -300px;
-}
-
-.TActiveRatingList_blocks td.rating_disabled
-{
- cursor: default !important;
-}
diff --git a/framework/Web/Javascripts/source/prado/activeratings/default.css b/framework/Web/Javascripts/source/prado/activeratings/default.css deleted file mode 100644 index ba90eb27..00000000 --- a/framework/Web/Javascripts/source/prado/activeratings/default.css +++ /dev/null @@ -1,43 +0,0 @@ -.TActiveRatingList_default
-{
- border-collapse: collapse;
-}
-.TActiveRatingList_default input, .TActiveRatingList_default label
-{
- display: none;
-}
-
-.TActiveRatingList_default td
-{
- width: 18px;
- height: 18px;
- padding: 0;
-}
-
-.TActiveRatingList_default td.rating
-{
- background-image: url(default_combined.gif);
- background-repeat: no-repeat;
- cursor: pointer;
- background-position: 0px 0px;
-}
-
-.TActiveRatingList_default td.rating_selected
-{
- background-position: 0px -100px;
-}
-
-.TActiveRatingList_default td.rating_half
-{
- background-position: 0px -200px;
-}
-
-.TActiveRatingList_default td.rating_hover
-{
- background-position: 0px -300px;
-}
-
-.TActiveRatingList_default td.rating_disabled
-{
- cursor: default !important;
-}
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/activeratings/ratings.js b/framework/Web/Javascripts/source/prado/activeratings/ratings.js deleted file mode 100644 index 4eeddbd8..00000000 --- a/framework/Web/Javascripts/source/prado/activeratings/ratings.js +++ /dev/null @@ -1,178 +0,0 @@ -Prado.WebUI.TActiveRatingList = Base.extend(
-{
- selectedIndex : -1,
- rating: -1,
- enabled : true,
- readOnly : false,
-
- constructor : function(options)
- {
- var cap = $(options.CaptionID);
- this.options = Object.extend(
- {
- caption : cap ? cap.innerHTML : ''
- }, options || {});
-
- Prado.WebUI.TActiveRatingList.register(this);
- this._init();
- this.selectedIndex = options.SelectedIndex;
- this.rating = options.Rating;
- if(options.Rating <= 0 && options.SelectedIndex >= 0)
- this.rating = options.SelectedIndex+1;
- this.showRating(this.rating);
- },
-
- _init: function(options)
- {
- Element.addClassName($(this.options.ListID),this.options.Style);
- this.radios = new Array();
- var index=0;
- for(var i = 0; i<this.options.ItemCount; i++)
- {
- var radio = $(this.options.ListID+'_c'+i);
- var td = radio.parentNode.parentNode;
- if(radio && td.tagName.toLowerCase()=='td')
- {
- this.radios.push(radio);
- Event.observe(td, "mouseover", this.hover.bindEvent(this,index));
- Event.observe(td, "mouseout", this.recover.bindEvent(this,index));
- Event.observe(td, "click", this.click.bindEvent(this, index));
- index++;
- Element.addClassName(td,"rating");
- }
- }
- },
-
- hover : function(ev,index)
- {
- if(this.enabled==false) return;
- for(var i = 0; i<this.radios.length; i++)
- {
- var node = this.radios[i].parentNode.parentNode;
- var action = i <= index ? 'addClassName' : 'removeClassName'
- Element[action](node,"rating_hover");
- Element.removeClassName(node,"rating_selected");
- Element.removeClassName(node,"rating_half");
- }
- this.showCaption(this.getIndexCaption(index));
- },
-
- recover : function(ev,index)
- {
- if(this.enabled==false) return;
- this.showRating(this.rating);
- this.showCaption(this.options.caption);
- },
-
- click : function(ev, index)
- {
- if(this.enabled==false) return;
- for(var i = 0; i<this.radios.length; i++)
- this.radios[i].checked = (i == index);
-
- this.selectedIndex = index;
- this.setRating(index+1);
-
- this.dispatchRequest(ev);
- },
-
- dispatchRequest : function(ev)
- {
- var requestOptions = Object.extend(
- {
- ID : this.options.ListID+"_c"+this.selectedIndex,
- EventTarget : this.options.ListName+"$c"+this.selectedIndex
- },this.options);
- var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions);
- if(request.dispatch()==false)
- Event.stop(ev);
- },
-
- setRating : function(value)
- {
- this.rating = value;
- var base = Math.floor(value-1);
- var remainder = value - base-1;
- var halfMax = this.options.HalfRating["1"];
- var index = remainder > halfMax ? base+1 : base;
- for(var i = 0; i<this.radios.length; i++)
- this.radios[i].checked = (i == index);
-
- var caption = this.getIndexCaption(index);
- this.setCaption(caption);
- this.showCaption(caption);
-
- this.showRating(value);
- },
-
- showRating: function(value)
- {
- var base = Math.floor(value-1);
- var remainder = value - base-1;
- var halfMin = this.options.HalfRating["0"];
- var halfMax = this.options.HalfRating["1"];
- var index = remainder > halfMax ? base+1 : base;
- var hasHalf = remainder >= halfMin && remainder <= halfMax;
- for(var i = 0; i<this.radios.length; i++)
- {
- var node = this.radios[i].parentNode.parentNode;
- var action = i > index ? 'removeClassName' : 'addClassName';
- Element[action](node, "rating_selected");
- if(i==index+1 && hasHalf)
- Element.addClassName(node, "rating_half");
- else
- Element.removeClassName(node, "rating_half");
- Element.removeClassName(node,"rating_hover");
- }
- },
-
- getIndexCaption : function(index)
- {
- return index > -1 ? this.radios[index].value : this.options.caption;
- },
-
- showCaption : function(value)
- {
- var caption = $(this.options.CaptionID);
- if(caption) caption.innerHTML = value;
- $(this.options.ListID).title = value;
- },
-
- setCaption : function(value)
- {
- this.options.caption = value;
- this.showCaption(value);
- },
-
- setEnabled : function(value)
- {
- this.enabled = value;
- for(var i = 0; i<this.radios.length; i++)
- {
- var action = value ? 'removeClassName' : 'addClassName'
- Element[action](this.radios[i].parentNode.parentNode, "rating_disabled");
- }
- }
-},
-{
-ratings : {},
-register : function(rating)
-{
- Prado.WebUI.TActiveRatingList.ratings[rating.options.ListID] = rating;
-},
-
-setEnabled : function(id,value)
-{
- Prado.WebUI.TActiveRatingList.ratings[id].setEnabled(value);
-},
-
-setRating : function(id,value)
-{
- Prado.WebUI.TActiveRatingList.ratings[id].setRating(value);
-},
-
-setCaption : function(id,value)
-{
- Prado.WebUI.TActiveRatingList.ratings[id].setCaption(value);
-}
-});
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js index bea18e76..dac7a0c0 100644 --- a/framework/Web/Javascripts/source/prado/controls/controls.js +++ b/framework/Web/Javascripts/source/prado/controls/controls.js @@ -69,12 +69,9 @@ Object.extend(Prado.WebUI.TImageButton.prototype, */
onPostBack : function(event, options)
{
- if(!this.hasXYInput)
- {
- this.addXYInput(event,options);
- this.hasXYInput = true;
- }
+ this.addXYInput(event,options);
Prado.PostBack(event, options);
+ this.removeXYInput(event,options);
},
/**
@@ -111,6 +108,18 @@ Object.extend(Prado.WebUI.TImageButton.prototype, y_input = INPUT({type:'hidden',name:id+'_y','id':id+'_y',value:y});
this.element.parentNode.appendChild(y_input);
}
+ },
+
+ /**
+ * Remove hidden inputs for x,y-click capturing
+ * @param event DOM click event.
+ * @param array image button options.
+ */
+ removeXYInput : function(event,options)
+ {
+ id = options['EventTarget'];
+ this.element.parentNode.removeChild($(id+"_x"));
+ this.element.parentNode.removeChild($(id+"_y"));
}
});
diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js index 834e89cf..a16cc3d6 100644 --- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js +++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js @@ -67,6 +67,7 @@ Prado.WebUI.TDatePicker.prototype = this.weekSlot = new Array(6);
this.minimalDaysInFirstWeek = 4;
this.selectedDate = this.newDate();
+ this.positionMode = 'Bottom';
//which element to trigger to show the calendar
if(this.options.Trigger)
@@ -79,6 +80,12 @@ Prado.WebUI.TDatePicker.prototype = this.trigger = this.control;
var triggerEvent = this.options.TriggerEvent || "focus";
}
+
+ // Popup position
+ if(this.options.PositionMode == 'Top')
+ {
+ this.positionMode = this.options.PositionMode;
+ }
Object.extend(this,options);
@@ -309,8 +316,8 @@ Prado.WebUI.TDatePicker.prototype = if(this.iePopUp)
{
this.iePopUp.style.display = "block";
- this.iePopUp.style.top = (this._calDiv.offsetTop -1 ) + "px";
this.iePopUp.style.left = (this._calDiv.offsetLeft -1)+ "px";
+ this.iePopUp.style.top = (this._calDiv.offsetTop -1 ) + "px";
this.iePopUp.style.width = Math.abs(this._calDiv.offsetWidth -2)+ "px";
this.iePopUp.style.height = (this._calDiv.offsetHeight + 1)+ "px";
if(cleanup) this.iePopUp.style.display = "none";
@@ -603,12 +610,10 @@ Prado.WebUI.TDatePicker.prototype = var pos = this.control.positionedOffset();
pos[1] += this.getDatePickerOffsetHeight();
-
- this._calDiv.style.display = "block";
this._calDiv.style.top = (pos[1]-1) + "px";
+ this._calDiv.style.display = "block";
this._calDiv.style.left = pos[0] + "px";
- this.ieHack(false);
this.documentClickEvent = this.hideOnClick.bindEvent(this);
this.documentKeyDownEvent = this.keyPressed.bindEvent(this);
Event.observe(document.body, "click", this.documentClickEvent);
@@ -620,6 +625,14 @@ Prado.WebUI.TDatePicker.prototype = }
Event.observe(document,"keydown", this.documentKeyDownEvent);
this.showing = true;
+
+ if(this.positionMode=='Top')
+ {
+ this._calDiv.style.top = ((pos[1]-1) - this.getDatePickerOffsetHeight() - this._calDiv.offsetHeight) + 'px';
+ if(Prado.Browser().ie)
+ this.iePopup = this._calDiv.style.top;
+ }
+ this.ieHack(false);
}
},
diff --git a/framework/Web/Javascripts/source/prado/ratings/ratings.js b/framework/Web/Javascripts/source/prado/ratings/ratings.js index e1770f1f..8af32bb9 100644 --- a/framework/Web/Javascripts/source/prado/ratings/ratings.js +++ b/framework/Web/Javascripts/source/prado/ratings/ratings.js @@ -1,60 +1,205 @@ -Prado.WebUI.TRatingList = Class.create();
-Prado.WebUI.TRatingList.prototype =
+Prado.WebUI.TRatingList = Base.extend(
{
selectedIndex : -1,
+ rating: -1,
+ readOnly : false,
- initialize : function(options)
+ constructor : function(options)
{
- this.options = options;
- this.element = $(options['ID']);
- Element.addClassName(this.element,options.cssClass);
- this.radios = document.getElementsByName(options.field);
- for(var i = 0; i<this.radios.length; i++)
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
+ {
+ caption : cap ? cap.innerHTML : ''
+ }, options || {});
+
+ Prado.WebUI.TRatingList.register(this);
+ this._init();
+ this.selectedIndex = options.SelectedIndex;
+ this.rating = options.Rating;
+ this.readOnly = options.ReadOnly
+ if(options.Rating <= 0 && options.SelectedIndex >= 0)
+ this.rating = options.SelectedIndex+1;
+ this.setReadOnly(this.readOnly);
+ },
+
+ _init: function(options)
+ {
+ Element.addClassName($(this.options.ListID),this.options.Style);
+ this.radios = new Array();
+ this._mouseOvers = new Array();
+ this._mouseOuts = new Array();
+ this._clicks = new Array();
+ var index=0;
+ for(var i = 0; i<this.options.ItemCount; i++)
{
- Event.observe(this.radios[i].parentNode.parentNode, "mouseover", this.hover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode.parentNode, "mouseout", this.recover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode.parentNode, "click", this.click.bindEvent(this, i));
+ var radio = $(this.options.ListID+'_c'+i);
+ var td = radio.parentNode.parentNode;
+ if(radio && td.tagName.toLowerCase()=='td')
+ {
+ this.radios.push(radio);
+ this._mouseOvers.push(this.hover.bindEvent(this,index));
+ this._mouseOuts.push(this.recover.bindEvent(this,index));
+ this._clicks.push(this.click.bindEvent(this,index));
+ index++;
+ Element.addClassName(td,"rating");
+ }
}
- this.caption = CAPTION();
- this.element.appendChild(this.caption);
- this.selectedIndex = options.selectedIndex;
- this.setRating(this.selectedIndex);
},
hover : function(ev,index)
{
+ if(this.readOnly==true) return;
for(var i = 0; i<this.radios.length; i++)
- this.radios[i].parentNode.parentNode.className = (i<=index) ? "rating_hover" : "";
- this.setCaption(index);
+ {
+ var node = this.radios[i].parentNode.parentNode;
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](node,"rating_hover");
+ Element.removeClassName(node,"rating_selected");
+ Element.removeClassName(node,"rating_half");
+ }
+ this.showCaption(this.getIndexCaption(index));
},
recover : function(ev,index)
{
- for(var i = 0; i<=index; i++)
- Element.removeClassName(this.radios[i].parentNode.parentNode, "rating_hover");
- this.setRating(this.selectedIndex);
+ if(this.readOnly==true) return;
+ this.showRating(this.rating);
+ this.showCaption(this.options.caption);
},
click : function(ev, index)
{
+ if(this.readOnly==true) return;
for(var i = 0; i<this.radios.length; i++)
this.radios[i].checked = (i == index);
this.selectedIndex = index;
- this.setRating(index);
- if(typeof(this.options.onChange)=="function")
- this.options.onChange(this,index);
+ this.setRating(index+1);
+
+ if(this.options['AutoPostBack']==true){
+ this.dispatchRequest(ev);
+ }
+ },
+
+ dispatchRequest : function(ev)
+ {
+ var requestOptions = Object.extend(
+ {
+ ID : this.options.ListID+"_c"+this.selectedIndex,
+ EventTarget : this.options.ListName+"$c"+this.selectedIndex
+ },this.options);
+ Prado.PostBack(ev, requestOptions);
+ },
+
+ setRating : function(value)
+ {
+ this.rating = value;
+ var base = Math.floor(value-1);
+ var remainder = value - base-1;
+ var halfMax = this.options.HalfRating["1"];
+ var index = remainder > halfMax ? base+1 : base;
+ for(var i = 0; i<this.radios.length; i++)
+ this.radios[i].checked = (i == index);
+
+ var caption = this.getIndexCaption(index);
+ this.setCaption(caption);
+ this.showCaption(caption);
+
+ this.showRating(this.rating);
+ },
+
+ showRating: function(value)
+ {
+ var base = Math.floor(value-1);
+ var remainder = value - base-1;
+ var halfMin = this.options.HalfRating["0"];
+ var halfMax = this.options.HalfRating["1"];
+ var index = remainder > halfMax ? base+1 : base;
+ var hasHalf = remainder >= halfMin && remainder <= halfMax;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var node = this.radios[i].parentNode.parentNode;
+ var action = i > index ? 'removeClassName' : 'addClassName';
+ Element[action](node, "rating_selected");
+ if(i==index+1 && hasHalf)
+ Element.addClassName(node, "rating_half");
+ else
+ Element.removeClassName(node, "rating_half");
+ Element.removeClassName(node,"rating_hover");
+ }
+ },
+
+ getIndexCaption : function(index)
+ {
+ return index > -1 ? this.radios[index].value : this.options.caption;
+ },
+
+ showCaption : function(value)
+ {
+ var caption = $(this.options.CaptionID);
+ if(caption) caption.innerHTML = value;
+ $(this.options.ListID).title = value;
},
- setRating: function(index)
+ setCaption : function(value)
{
- for(var i = 0; i<=index; i++)
- this.radios[i].parentNode.parentNode.className = "rating_selected";
- this.setCaption(index);
+ this.options.caption = value;
+ this.showCaption(value);
},
- setCaption : function(index)
+ setReadOnly : function(value)
+ {
+ this.readOnly = value;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+
+ var action = value ? 'addClassName' : 'removeClassName';
+ Element[action](this.radios[i].parentNode.parentNode, "rating_disabled");
+
+ var action = value ? 'stopObserving' : 'observe';
+ var td = this.radios[i].parentNode.parentNode;
+ Event[action](td, "mouseover", this._mouseOvers[i]);
+ Event[action](td, "mouseout", this._mouseOuts[i]);
+ Event[action](td, "click", this._clicks[i]);
+ }
+
+ this.showRating(this.rating);
+ }
+},
+{
+ratings : {},
+register : function(rating)
+{
+ Prado.WebUI.TRatingList.ratings[rating.options.ListID] = rating;
+},
+
+setReadOnly : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setReadOnly(value);
+},
+
+setRating : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setRating(value);
+},
+
+setCaption : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setCaption(value);
+}
+});
+
+Prado.WebUI.TActiveRatingList = Prado.WebUI.TRatingList.extend(
+{
+ dispatchRequest : function(ev)
{
- this.caption.innerHTML = index > -1 ?
- this.radios[index].value : this.options.caption;
+ var requestOptions = Object.extend(
+ {
+ ID : this.options.ListID+"_c"+this.selectedIndex,
+ EventTarget : this.options.ListName+"$c"+this.selectedIndex
+ },this.options);
+ var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions);
+ if(request.dispatch()==false)
+ Event.stop(ev);
}
-};
+
+});
diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js index c9dba7a1..a3b803d8 100644 --- a/framework/Web/Javascripts/source/prado/validator/validation3.js +++ b/framework/Web/Javascripts/source/prado/validator/validation3.js @@ -686,7 +686,7 @@ Prado.WebUI.TValidationSummary.prototype = {
switch(type)
{
- case "List":
+ case "SimpleList":
return { header : "<br />", first : "", pre : "", post : "<br />", last : ""};
case "SingleParagraph":
return { header : " ", first : "", pre : "", post : " ", last : "<br />"};
@@ -1668,6 +1668,7 @@ Prado.WebUI.TRegularExpressionValidator = Class.extend(Prado.WebUI.TBaseValidato * @constructor initialize
* @param {object} options - Additional constructor option:
* @... {string} ValidationExpression - Regular expression to match against.
+ * @... {string} PatternModifiers - Pattern modifiers: combinations of g, i, and m
*/
/**
@@ -1678,12 +1679,12 @@ Prado.WebUI.TRegularExpressionValidator = Class.extend(Prado.WebUI.TBaseValidato evaluateIsValid : function()
{
var value = this.getValidationValue();
- if (value.length <= 0)
+ if (value.length <= 0)
return true;
- var rx = new RegExp(this.options.ValidationExpression);
- var matches = rx.exec(value);
- return (matches != null && value == matches[0]);
+ var rx = new RegExp(this.options.ValidationExpression,this.options.PatternModifiers);
+ var matches = rx.exec(value);
+ return (matches != null && value == matches[0]);
}
});
@@ -1847,6 +1848,8 @@ Prado.WebUI.TCaptchaValidator = Class.extend(Prado.WebUI.TBaseValidator, {
var a = this.getValidationValue();
var h = 0;
+ if (this.options.CaseSensitive==false)
+ a = a.toUpperCase();
for(var i = a.length-1; i >= 0; --i)
h += a.charCodeAt(i);
return h == this.options.TokenHash;
diff --git a/framework/Web/Javascripts/source/scriptaculous-1.8.1/dragdrop.js b/framework/Web/Javascripts/source/scriptaculous-1.8.1/dragdrop.js index bf429c26..14f9546e 100644 --- a/framework/Web/Javascripts/source/scriptaculous-1.8.1/dragdrop.js +++ b/framework/Web/Javascripts/source/scriptaculous-1.8.1/dragdrop.js @@ -407,7 +407,7 @@ var Draggable = Class.create({ if(this.options.ghosting) { if (!this.element._originallyAbsolute) Position.relativize(this.element); - delete this.element._originallyAbsolute; + this.element._originallyAbsolute=null; Element.remove(this._clone); this._clone = null; } diff --git a/framework/Web/Services/TFeedService.php b/framework/Web/Services/TFeedService.php index fea39290..7ecd10a7 100644 --- a/framework/Web/Services/TFeedService.php +++ b/framework/Web/Services/TFeedService.php @@ -143,4 +143,3 @@ interface IFeedContentProvider public function getContentType();
}
-?> diff --git a/framework/Web/Services/TJsonService.php b/framework/Web/Services/TJsonService.php index 93ad10d2..e3ed9a7f 100644 --- a/framework/Web/Services/TJsonService.php +++ b/framework/Web/Services/TJsonService.php @@ -92,7 +92,7 @@ class TJsonService extends TService throw new TConfigurationException('jsonservice_class_required',$id);
}
else
- throw new THttpException(404,'jsonservice_feed_unknown',$id);
+ throw new THttpException(404,'jsonservice_provider_unknown',$id);
}
/**
diff --git a/framework/Web/Services/TSoapService.php b/framework/Web/Services/TSoapService.php index 259fa5f8..f5962647 100644 --- a/framework/Web/Services/TSoapService.php +++ b/framework/Web/Services/TSoapService.php @@ -612,4 +612,3 @@ class TSoapServer extends TApplicationComponent } } -?> diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index d8028d93..7925d209 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -4,7 +4,7 @@ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web
@@ -113,7 +113,7 @@ class TAssetManager extends TModule {
$this->_basePath=Prado::getPathOfNamespace($value);
if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath))
- throw new TInvalidDataValueException('assetmanage_basepath_invalid',$value);
+ throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value);
}
}
@@ -267,7 +267,10 @@ class TAssetManager extends TModule else if(is_file($src.DIRECTORY_SEPARATOR.$file))
{
if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file))
+ {
@copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
+ @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD);
+ }
}
else
$this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
@@ -333,4 +336,4 @@ class TAssetManager extends TModule }
-?> +?>
diff --git a/framework/Web/TCacheHttpSession.php b/framework/Web/TCacheHttpSession.php index 0d89a519..daa94122 100644 --- a/framework/Web/TCacheHttpSession.php +++ b/framework/Web/TCacheHttpSession.php @@ -148,4 +148,3 @@ class TCacheHttpSession extends THttpSession } } -?> diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index d595c1b9..7100a4c5 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -1237,4 +1237,3 @@ class THttpRequestUrlFormat extends TEnumerable const Path='Path'; } -?> diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 44a853b0..fd45acf5 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -574,4 +574,3 @@ class THttpResponse extends TModule implements ITextWriter } } -?> diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php index 251db64b..96d70704 100644 --- a/framework/Web/THttpSession.php +++ b/framework/Web/THttpSession.php @@ -708,4 +708,3 @@ class THttpSessionCookieMode extends TEnumerable const Only='Only';
}
-?> diff --git a/framework/Web/THttpUtility.php b/framework/Web/THttpUtility.php index c6e7c3fc..a410b957 100644 --- a/framework/Web/THttpUtility.php +++ b/framework/Web/THttpUtility.php @@ -48,4 +48,3 @@ class THttpUtility }
}
-?> diff --git a/framework/Web/TUrlManager.php b/framework/Web/TUrlManager.php index 778b762a..f87bee8f 100644 --- a/framework/Web/TUrlManager.php +++ b/framework/Web/TUrlManager.php @@ -139,4 +139,3 @@ class TUrlManager extends TModule }
}
-?> diff --git a/framework/Web/TUrlMapping.php b/framework/Web/TUrlMapping.php index e1deea0f..83dd99b6 100644 --- a/framework/Web/TUrlMapping.php +++ b/framework/Web/TUrlMapping.php @@ -76,7 +76,7 @@ class TUrlMapping extends TUrlManager /**
* @var TUrlMappingPattern[] list of patterns.
*/
- private $_patterns=array();
+ protected $_patterns=array();
/**
* @var TUrlMappingPattern matched pattern.
*/
@@ -92,7 +92,7 @@ class TUrlMapping extends TUrlManager /**
* @var array rules for constructing URLs
*/
- private $_constructRules=array();
+ protected $_constructRules=array();
private $_urlPrefix='';
@@ -264,7 +264,8 @@ class TUrlMapping extends TUrlManager if(is_string($key))
$params[$key]=$value;
}
- $params[$pattern->getServiceID()]=$pattern->getServiceParameter();
+ if (!$pattern->getIsWildCardPattern()) + $params[$pattern->getServiceID()]=$pattern->getServiceParameter();
return $params;
}
}
@@ -299,6 +300,8 @@ class TUrlMapping extends TUrlManager if(!(is_array($getItems) || ($getItems instanceof Traversable)))
$getItems=array();
$key=$serviceID.':'.$serviceParam;
+ $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ? + $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*'; if(isset($this->_constructRules[$key]))
{
foreach($this->_constructRules[$key] as $rule)
@@ -306,6 +309,17 @@ class TUrlMapping extends TUrlManager if($rule->supportCustomUrl($getItems))
return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems);
}
+ } + elseif(isset($this->_constructRules[$wildCardKey])) + { + foreach($this->_constructRules[$wildCardKey] as $rule)
+ {
+ if($rule->supportCustomUrl($getItems))
+ { + $getItems['*']= $pos ? substr($serviceParam,$pos+1) : $serviceParam; + return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems);
+ } + }
}
}
return parent::constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems);
@@ -399,6 +413,8 @@ class TUrlMappingPattern extends TComponent private $_manager;
private $_caseSensitive=true;
+ + private $_isWildCardPattern=false; /**
* Constructor.
@@ -428,6 +444,8 @@ class TUrlMappingPattern extends TComponent {
if($this->_serviceParameter===null)
throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern());
+ if(strpos($this->_serviceParameter,'*')!==false) + $this->_isWildCardPattern=true; }
/**
@@ -444,6 +462,11 @@ class TUrlMappingPattern extends TComponent $params[]='{'.$key.'}';
$values[]='(?P<'.$key.'>'.$value.')';
}
+ if ($this->getIsWildCardPattern()) { + $params[]='{*}'; + // service parameter must not contain '=' and '/' + $values[]='(?P<'.$this->getServiceID().'>[^=/]+)'; + } $params[]='/';
$values[]='\\/';
$regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/');
@@ -585,6 +608,14 @@ class TUrlMappingPattern extends TComponent }
/**
+ * @return boolean whether this pattern is a wildcard pattern + * @since 3.1.4
+ */
+ public function getIsWildCardPattern() { + return $this->_isWildCardPattern; + } + + /**
* @param array list of GET items to be put in the constructed URL
* @return boolean whether this pattern IS the one for constructing the URL with the specified GET items.
* @since 3.1.1
@@ -616,10 +647,8 @@ class TUrlMappingPattern extends TComponent // for the GET variables matching the pattern, put them in the URL path
foreach($getItems as $key=>$value)
{
- if($encodeGetItems)
- $value=urlencode($value);
- if($this->_parameters->contains($key))
- $replace['{'.$key.'}']=$value;
+ if($this->_parameters->contains($key) || $key==='*' && $this->getIsWildCardPattern())
+ $replace['{'.$key.'}']=$encodeGetItems ? rawurlencode($value) : $value;
else
$extra[$key]=$value;
}
@@ -637,12 +666,12 @@ class TUrlMappingPattern extends TComponent {
if(is_array($value))
{
- $name=urlencode($name.'[]');
+ $name=rawurlencode($name.'[]');
foreach($value as $v)
- $url2.=$amp.$name.'='.urlencode($v);
+ $url2.=$amp.$name.'='.rawurlencode($v);
}
else
- $url2.=$amp.urlencode($name).'='.urlencode($value);
+ $url2.=$amp.rawurlencode($name).'='.rawurlencode($value);
}
}
else
@@ -664,4 +693,3 @@ class TUrlMappingPattern extends TComponent }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php index 992f41e3..0990ff41 100644 --- a/framework/Web/UI/ActiveControls/TActiveButton.php +++ b/framework/Web/UI/ActiveControls/TActiveButton.php @@ -130,4 +130,3 @@ class TActiveButton extends TButton implements ICallbackEventHandler, IActiveCon }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php index 88e4fdfe..34872f98 100644 --- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -97,7 +97,7 @@ class TActiveControlAdapter extends TControlAdapter $data = $this->getPage()->getPostDataLoaders();
if(count($data) > 0)
{
- $options = TJavascript::encode($data,false);
+ $options = TJavaScript::encode($data,false);
$script = "Prado.CallbackRequest.addPostLoaders({$options});";
$cs->registerEndScript($key, $script);
}
@@ -146,12 +146,12 @@ class TActiveControlAdapter extends TControlAdapter * Starts viewstate tracking if necessary after when controls has been loaded
*/
public function onLoad($param)
- { + {
if($this->getIsTrackingPageState())
{
$this->_stateTracker = new TCallbackPageStateTracker($this->getControl());
$this->_stateTracker->trackChanges();
- } + }
parent::onLoad($param);
}
@@ -560,4 +560,3 @@ class TMapCollectionDiff extends TViewStateDiff }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php index 8428c810..6c74aa7d 100644 --- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php +++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php @@ -239,4 +239,3 @@ class TActiveCustomValidatorClientSide extends TCallbackClientSide return is_null($changes) ? true : $changes;
}
}
-?> diff --git a/framework/Web/UI/ActiveControls/TActiveDatePicker.php b/framework/Web/UI/ActiveControls/TActiveDatePicker.php new file mode 100755 index 00000000..052ed199 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveDatePicker.php @@ -0,0 +1,129 @@ +<?php +/** + * TActiveDatePicker class file + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2008 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Web.UI.ActiveControls + */ + +/** + * Load active control adapter. + */ +Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); + +/** + * TActiveDatePicker class + * + * The active control counter part to date picker control. + * When the date selection is changed, the {@link onCallback OnCallback} event is + * raised. + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * @version $Id$ + * @package System.Web.UI.ActiveControls + * @since 3.1.3 + */ +class TActiveDatePicker extends TDatePicker implements ICallbackEventHandler, IActiveControl { + + + /** + * Get javascript date picker options. + * @return array date picker client-side options + */ + protected function getDatePickerOptions(){ + $options = parent::getDatePickerOptions(); + $options['EventTarget'] = $this->getUniqueID(); + return $options; + } + + /** + * Creates a new callback control, sets the adapter to + * TActiveControlAdapter. If you override this class, be sure to set the + * adapter appropriately by, for example, by calling this constructor. + */ + public function __construct() + { + parent::__construct(); + $this->setAdapter(new TActiveControlAdapter($this)); + } + + /** + * @return TBaseActiveCallbackControl standard callback control options. + */ + public function getActiveControl(){ + return $this->getAdapter()->getBaseActiveControl(); + } + + /** + * Client-side Text property can only be updated after the OnLoad stage. + * @param string text content for the textbox + */ + public function setText($value){ + parent::setText($value); + if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData()){ + $cb=$this->getPage()->getCallbackClient(); + $cb->setValue($this, $value); + if ($this->getInputMode()==TDatePickerInputMode::DropDownList) + { + $s = Prado::createComponent('System.Util.TDateTimeStamp'); + $date = $s->getDate($this->getTimeStampFromText()); + $id=$this->getClientID(); + $cb->select($id.TControl::CLIENT_ID_SEPARATOR.'day', 'Value', $date['mday'], 'select'); + $cb->select($id.TControl::CLIENT_ID_SEPARATOR.'month', 'Value', $date['mon']-1, 'select'); + $cb->select($id.TControl::CLIENT_ID_SEPARATOR.'year', 'Value', $date['year'], 'select'); + + } + } + } + + /** + * Raises the callback event. This method is required by {@link + * ICallbackEventHandler} interface. + * This method is mainly used by framework and control developers. + * @param TCallbackEventParameter the event parameter + */ + public function raiseCallbackEvent($param){ + $this->onCallback($param); + } + + /** + * This method is invoked when a callback is requested. The method raises + * 'OnCallback' event to fire up the event handlers. If you override this + * method, be sure to call the parent implementation so that the event + * handler can be invoked. + * @param TCallbackEventParameter event parameter to be passed to the event handlers + */ + public function onCallback($param){ + $this->raiseEvent('OnCallback', $this, $param); + } + + /** + * Registers the javascript code to initialize the date picker. + */ + protected function registerCalendarClientScript() + { + if($this->getShowCalendar()) + { + $cs = $this->getPage()->getClientScript(); + $cs->registerPradoScript("activedatepicker"); + + if(!$cs->isEndScriptRegistered('TDatePicker.spacer')) + { + $spacer = $this->getAssetUrl('spacer.gif'); + $code = "Prado.WebUI.TDatePicker.spacer = '$spacer';"; + $cs->registerEndScript('TDatePicker.spacer', $code); + } + + $options = TJavaScript::encode($this->getDatePickerOptions()); + $code = "new Prado.WebUI.TActiveDatePicker($options);"; + $cs->registerEndScript("prado:".$this->getClientID(), $code); + } + } +} +?> diff --git a/framework/Web/UI/ActiveControls/TActiveFileUpload.php b/framework/Web/UI/ActiveControls/TActiveFileUpload.php new file mode 100755 index 00000000..e1b85f0d --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveFileUpload.php @@ -0,0 +1,315 @@ +<?php +/** + * TActiveFileUpload.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * @version $Id$ + */ + +/** + * Load TActiveControlAdapter and TFileUpload. + */ +Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); +Prado::using('System.Web.UI.WebControls.TFileUpload'); + +/** + * TActiveFileUpload + * + * TActiveFileUpload displays a file upload field on a page. Upon postback, + * the text entered into the field will be treated as the name of the file + * that will be uploaded to the server. The property {@link getHasFile HasFile} + * indicates whether the file upload is successful. If successful, the file + * may be obtained by calling {@link saveAs} to save it at a specified place. + * You can use {@link getFileName FileName}, {@link getFileType FileType}, + * {@link getFileSize FileSize} to get the original client-side file name, + * the file mime type, and the file size information. If the upload is not + * successful, {@link getErrorCode ErrorCode} contains the error code + * describing the cause of failure. + * + * TActiveFileUpload raises {@link onFileUpload OnFileUpload} event if a file is uploaded + * (whether it succeeds or not). + * + * TActiveFileUpload actually does a postback in a hidden IFrame, and then does a callback. + * This callback then raises the {@link onFileUpload OnFileUpload} event. After the postback + * a status icon is displayed; either a green checkmark if the upload is successful, + * or a red x if there was an error. + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * + * @version $Id$ + */ +class TActiveFileUpload extends TFileUpload implements IActiveControl, ICallbackEventHandler, INamingContainer +{ + + const SCRIPT_PATH = 'prado/activefileupload'; + + /** + * @var THiddenField a flag to tell which component is doing the callback. + */ + private $_flag; + /** + * @var TImage that spins to show that the file is being uploaded. + */ + private $_busy; + /** + * @var TImage that shows a green check mark for completed upload. + */ + private $_success; + /** + * @var TImage that shows a red X for incomplete upload. + */ + private $_error; + /** + * @var TInlineFrame used to submit the data in an "asynchronous" fashion. + */ + private $_target; + + + /** + * Creates a new callback control, sets the adapter to + * TActiveControlAdapter. If you override this class, be sure to set the + * adapter appropriately by, for example, by calling this constructor. + */ + public function __construct(){ + parent::__construct(); + $this->setAdapter(new TActiveControlAdapter($this)); + } + + + /** + * @param string asset file in the self::SCRIPT_PATH directory. + * @return string asset file url. + */ + protected function getAssetUrl($file='') + { + $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); + return $base.'/'.self::SCRIPT_PATH.'/'.$file; + } + + + /** + * This method is invoked when a file is uploaded. + * If you override this method, be sure to call the parent implementation to ensure + * the invocation of the attached event handlers. + * @param TEventParameter event parameter to be passed to the event handlers + */ + public function onFileUpload($param){ + if ($this->_flag->getValue() && $this->getPage()->getIsPostBack()){ + // save the file so that it will persist past the end of this return. + $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); + parent::saveAs($localName); + + $filename=addslashes($this->getFileName()); + // return some javascript to display a completion status. + echo <<<EOS +<script language="Javascript"> + Options = new Object(); + Options.clientID = '{$this->getClientID()}'; + Options.targetID = '{$this->_target->getUniqueID()}'; + Options.localName = '$localName'; + Options.fileName = '{$filename}'; + Options.fileSize = '{$this->getFileSize()}'; + Options.fileType = '{$this->getFileType()}'; + Options.errorCode = '{$this->getErrorCode()}'; + parent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options); +</script> +EOS; + exit(); + } + } + + /** + * @return string the path where the uploaded file will be stored temporarily, in namespace format + * default "Application.runtime.*" + */ + public function getTempPath(){ + return $this->getViewState('TempPath', 'Application.runtime.*'); + } + + /** + * @param string the path where the uploaded file will be stored temporarily in namespace format + * default "Application.runtime.*" + */ + public function setTempPath($value){ + $this->setViewState('TempNamespace',$value,'Application.runtime.*'); + } + + /** + * @throws TInvalidDataValueException if the {@link getTempPath TempPath} is not writable. + */ + public function onInit($sender){ + parent::onInit($sender); + if (!is_writable(Prado::getPathOfNamespace($this->getTempPath()))){ + throw new TInvalidDataValueException("activefileupload_temppath_invalid", $this->getTempPath()); + } + } + + /** + * Raises <b>OnFileUpload</b> event. + * + * This method is required by {@link ICallbackEventHandler} interface. + * This method is mainly used by framework and control developers. + * @param TCallbackEventParameter the event parameter + */ + public function raiseCallbackEvent($param){ + $cp = $param->getCallbackParameter(); + if ($key = $cp->targetID == $this->_target->getUniqueID()){ + $_FILES[$key]['name'] = $cp->fileName; + $_FILES[$key]['size'] = intval($cp->fileSize); + $_FILES[$key]['type'] = $cp->fileType; + $_FILES[$key]['error'] = intval($cp->errorCode); + $_FILES[$key]['tmp_name'] = $cp->localName; + $this->loadPostData($key, null); + + $this->raiseEvent('OnFileUpload', $this, $param); + } + } + + /** + * Publish the javascript + */ + public function onPreRender($param){ + parent::onPreRender($param); + $this->getPage()->getClientScript()->registerPradoScript('activefileupload'); + } + + + public function createChildControls(){ + $this->_flag = Prado::createComponent('THiddenField'); + $this->_flag->setID('Flag'); + $this->getControls()->add($this->_flag); + + $this->_busy = Prado::createComponent('TImage'); + $this->_busy->setID('Busy'); + $this->_busy->setImageUrl($this->getAssetUrl('ActiveFileUploadIndicator.gif')); + $this->_busy->setStyle("display:none"); + $this->getControls()->add($this->_busy); + + $this->_success = Prado::createComponent('TImage'); + $this->_success->setID('Success'); + $this->_success->setImageUrl($this->getAssetUrl('ActiveFileUploadComplete.png')); + $this->_success->setStyle("display:none"); + $this->getControls()->add($this->_success); + + $this->_error = Prado::createComponent('TImage'); + $this->_error->setID('Error'); + $this->_error->setImageUrl($this->getAssetUrl('ActiveFileUploadError.png')); + $this->_error->setStyle("display:none"); + $this->getControls()->add($this->_error); + + $this->_target = Prado::createComponent('TInlineFrame'); + $this->_target->setID('Target'); + $this->_target->setFrameUrl($this->getAssetUrl('ActiveFileUploadBlank.html')); + $this->_target->setStyle("width:0px; height:0px;"); + $this->_target->setShowBorder(false); + $this->getControls()->add($this->_target); + } + + + /** + * Removes localfile on ending of the callback. + */ + public function onUnload($param){ + if ($this->getPage()->getIsCallback() && + $this->getHasFile() && + file_exists($this->getLocalName())){ + unlink($this->getLocalName()); + } + parent::onUnload($param); + } + + /** + * @return TBaseActiveCallbackControl standard callback control options. + */ + public function getActiveControl(){ + return $this->getAdapter()->getBaseActiveControl(); + } + + /** + * Adds ID attribute, and renders the javascript for active component. + * @param THtmlWriter the writer used for the rendering purpose + */ + public function addAttributesToRender($writer){ + parent::addAttributesToRender($writer); + $writer->addAttribute('id',$this->getClientID()); + + $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(),$this->getClientOptions()); + } + + /** + * @return string corresponding javascript class name for this control. + */ + protected function getClientClassName(){ + return 'Prado.WebUI.TActiveFileUpload'; + } + + /** + * Gets the client side options for this control. + * @return array ( inputID => input client ID, + * flagID => flag client ID, + * targetName => target unique ID, + * formID => form client ID, + * indicatorID => upload indicator client ID, + * completeID => complete client ID, + * errorID => error client ID) + */ + protected function getClientOptions(){ + $options['ID'] = $this->getClientID(); + $options['EventTarget'] = $this->getUniqueID(); + + $options['inputID'] = $this->getClientID(); + $options['flagID'] = $this->_flag->getClientID(); + $options['targetID'] = $this->_target->getUniqueID(); + $options['formID'] = $this->getPage()->getForm()->getClientID(); + $options['indicatorID'] = $this->_busy->getClientID(); + $options['completeID'] = $this->_success->getClientID(); + $options['errorID'] = $this->_error->getClientID(); + return $options; + } + + /** + * Saves the uploaded file. + * @param string the file name used to save the uploaded file + * @param boolean whether to delete the temporary file after saving. + * If true, you will not be able to save the uploaded file again. + * @return boolean true if the file saving is successful + */ + public function saveAs($fileName,$deleteTempFile=true){ + if (($this->getErrorCode()===UPLOAD_ERR_OK) && (file_exists($this->getLocalName()))){ + if ($deleteTempFile) + return rename($this->getLocalName(),$fileName); + else + return copy($this->getLocalName(),$fileName); + } else + return false; + } + + /** + * @return TImage the image displayed when an upload + * completes successfully. + */ + public function getSuccessImage(){ + $this->ensureChildControls(); + return $this->_success; + } + + /** + * @return TImage the image displayed when an upload + * does not complete successfully. + */ + public function getErrorImage(){ + $this->ensureChildControls(); + return $this->_error; + } + + /** + * @return TImage the image displayed when an upload + * is in progress. + */ + public function getBusyImage(){ + $this->ensureChildControls(); + return $this->_busy; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveHiddenField.php b/framework/Web/UI/ActiveControls/TActiveHiddenField.php index 378fc76f..6d837cb2 100644 --- a/framework/Web/UI/ActiveControls/TActiveHiddenField.php +++ b/framework/Web/UI/ActiveControls/TActiveHiddenField.php @@ -114,4 +114,3 @@ class TActiveHiddenField extends THiddenField implements ICallbackEventHandler, } } -?> diff --git a/framework/Web/UI/ActiveControls/TActiveLabel.php b/framework/Web/UI/ActiveControls/TActiveLabel.php index e4b4bc6f..4105e3dc 100644 --- a/framework/Web/UI/ActiveControls/TActiveLabel.php +++ b/framework/Web/UI/ActiveControls/TActiveLabel.php @@ -77,6 +77,14 @@ class TActiveLabel extends TLabel implements IActiveControl $this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id); } } + + /** + * Adds attribute id to the renderer. + * @param THtmlWriter the writer used for the rendering purpose
+ */ + protected function addAttributesToRender($writer) { + $writer->addAttribute('id',$this->getClientID()); + parent::addAttributesToRender($writer); + } } -?> diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php index 5a863a9d..f1551b40 100644 --- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php +++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php @@ -11,6 +11,11 @@ */ /** + * Load active control adapter. + */ +Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); + +/** * TActiveLinkButton is the active control counter part to TLinkButton. * * When a TActiveLinkButton is clicked, rather than a normal post back request a diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 684082b8..c52f0775 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -155,7 +155,7 @@ class TActivePageAdapter extends TControlAdapter $responseData = $response->getAdapter()->getResponseData(); if(!is_null($responseData)) { - $data = TJavascript::jsonEncode($responseData); + $data = TJavaScript::jsonEncode($responseData); $this->appendContentPart($response, self::CALLBACK_DATA_HEADER, $data); //$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data); @@ -186,7 +186,7 @@ class TActivePageAdapter extends TControlAdapter //output the actions $executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute(); - $actions = TJavascript::jsonEncode($executeJavascript); + $actions = TJavaScript::jsonEncode($executeJavascript); $this->appendContentPart($response, self::CALLBACK_ACTION_HEADER, $actions); //$response->appendHeader(self::CALLBACK_ACTION_HEADER.': '.$actions); } @@ -264,7 +264,7 @@ class TActivePageAdapter extends TControlAdapter { $param = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); if(strlen($param) > 0) - $this->_callbackEventParameter=TJavascript::jsonDecode((string)$param); + $this->_callbackEventParameter=TJavaScript::jsonDecode((string)$param); } return $this->_callbackEventParameter; } @@ -315,7 +315,7 @@ class TCallbackErrorHandler extends TErrorHandler if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) { $response = $this->getApplication()->getResponse(); - $trace = TJavascript::jsonEncode($this->getExceptionStackTrace($exception)); + $trace = TJavaScript::jsonEncode($this->getExceptionStackTrace($exception)); $response->appendHeader('HTTP/1.0 500 Internal Error'); $response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$trace); } @@ -367,4 +367,3 @@ class TInvalidCallbackException extends TException { } -?> diff --git a/framework/Web/UI/ActiveControls/TActivePager.php b/framework/Web/UI/ActiveControls/TActivePager.php index 7e5ee33e..9dd856c9 100644 --- a/framework/Web/UI/ActiveControls/TActivePager.php +++ b/framework/Web/UI/ActiveControls/TActivePager.php @@ -176,12 +176,16 @@ class TActivePager extends TPager implements IActiveControl, ICallbackEventHandl // Update all the buttons pagers attached to the same control. // Dropdown pagers doesn't need to be re-rendered. $controlToPaginate=$this->getControlToPaginate(); - foreach ($this->getNamingContainer()->findControlsByType('TActivePager') as $control) + foreach ($this->getNamingContainer()->findControlsByType('TActivePager', false) as $control) { if ($control->getMode() !== TPagerMode::DropDownList && $control->getControlToPaginate()===$controlToPaginate) + { $control->render($param->getNewWriter()); + // FIXME : With some very fast machine, the getNewWriter() consecutive calls are in the same microsecond, resulting + // of getting the same boundaries in ajax response. Wait 1 microsecond to avoid this. + usleep(1); + } } - // Raise callback event $this->onCallback($param); } @@ -202,4 +206,3 @@ class TActivePager extends TPager implements IActiveControl, ICallbackEventHandl } } -?> diff --git a/framework/Web/UI/ActiveControls/TActivePanel.php b/framework/Web/UI/ActiveControls/TActivePanel.php index ef41a1dd..51e9fb08 100644 --- a/framework/Web/UI/ActiveControls/TActivePanel.php +++ b/framework/Web/UI/ActiveControls/TActivePanel.php @@ -89,4 +89,3 @@ class TActivePanel extends TPanel implements IActiveControl }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php index 10602427..63ef8ef4 100644 --- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php +++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php @@ -11,6 +11,12 @@ */ /** + * Load active control adapter and active radio button. + */ +Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter'); +Prado::using('System.Web.UI.ActiveControls.TActiveRadioButton'); + +/** * TActiveRadioButtonList class. * * The active control counter part to radio button list control. diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php index 4ec7b6c3..473ca06a 100644 --- a/framework/Web/UI/ActiveControls/TActiveRatingList.php +++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php @@ -3,8 +3,9 @@ * TActiveRatingList class file.
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -13,107 +14,85 @@ /**
* TActiveRatingList Class
*
- * Displays clickable images that represent a TActiveRadioButtonList
+ * Displays clickable images that represent a TRadioButtonList
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.ActiveControls
* @since 3.1
*/
-class TActiveRatingList extends TActiveRadioButtonList
+class TActiveRatingList extends TRatingList implements IActiveControl, ICallbackEventHandler
{
- const SCRIPT_PATH = 'prado/activeratings';
-
- /**
- * @var array list of published rating images.
- */
- private $_ratingImages = array();
-
/**
- * Sets the default repeat direction to horizontal.
+ * Creates a new callback control, sets the adapter to
+ * TActiveListControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
*/
public function __construct()
{
+ $this->setAdapter(new TActiveListControlAdapter($this));
+ $this->setAutoPostBack(true);
parent::__construct();
- $this->setRepeatDirection(TRepeatDirection::Horizontal);
- }
-
- /**
- * @return boolean whether the items in the column can be edited. Defaults to false.
- */
- public function getReadOnly()
- {
- return $this->getViewState('ReadOnly',false);
}
/**
- * @param boolean whether the items in the column can be edited
+ * @return TBaseActiveCallbackControl standard callback control options.
*/
- public function setReadOnly($value)
+ public function getActiveControl()
{
- $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false);
+ return $this->getAdapter()->getBaseActiveControl();
}
/**
- * The repeat layout must be Table.
- * @param string repeat layout type
- * @throws TInvaliddataValueException when repeat layout is not Table.
+ * @return TCallbackClientSide client side request options.
*/
- public function setRepeatLayout($value)
+ public function getClientSide()
{
- if($value!==TRepeatLayout::Table)
- throw new TInvalidDataValueException('ratinglist_table_layout_only');
- else
- parent::setRepeatLayout($value);
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
}
/**
- * @return float rating value.
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
*/
- public function getRating()
+ public function raiseCallbackEvent($param)
{
- return $this->getViewState('Rating',0.0);
+ $this->onCallback($param);
}
/**
- * @param float rating value, also sets the selected Index
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
*/
- public function setRating($value)
+ public function onCallback($param)
{
- $rating = TPropertyValue::ensureFloat($value);
- $this->setViewState('Rating', $rating);
- $canUpdate = $this->getActiveControl()->getEnableUpdate();
- $this->getActiveControl()->setEnableUpdate(false);
- parent::setSelectedIndex($this->getRatingIndex($rating));
- $this->getActiveControl()->setEnableUpdate($canUpdate);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->callClientFunction('setRating',$rating);
+ $this->raiseEvent('OnCallback', $this, $param);
}
/**
- * @param float rating value
- * @return int rating as integer
+ * @param boolean whether the items in the column can be edited
*/
- protected function getRatingIndex($rating)
+ public function setReadOnly($value)
{
- $interval = $this->getHalfRatingInterval();
- $base = intval($rating)-1;
- $remainder = $rating-$base-1;
- return $remainder > $interval[1] ? $base+1 : $base;
+ parent::setReadOnly($value);
+ $value = $this->getReadOnly();
+ $this->callClientFunction('setReadOnly',$value);
}
/**
- * @param int change the rating selection index
+ * @param float rating value, also sets the selected Index
*/
- public function setSelectedIndex($value)
+ public function setRating($value)
{
- $value = TPropertyValue::ensureInteger($value);
- $canUpdate = $this->getActiveControl()->getEnableUpdate();
- $this->getActiveControl()->setEnableUpdate(false);
- parent::setSelectedIndex($value);
- $this->getActiveControl()->setEnableUpdate($canUpdate);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->callClientFunction('setRating',$value+1);
+ parent::setRating($value);
+ $value = $this->getRating();
+ $this->callClientFunction('setRating',$value);
}
/**
@@ -123,250 +102,22 @@ class TActiveRatingList extends TActiveRadioButtonList */
protected function callClientFunction($func,$value)
{
- $client = $this->getPage()->getCallbackClient();
- $code = $this->getClientClassName().'.'.$func;
- $client->callClientFunction($code,array($this,$value));
- }
-
- /**
- * @return string control or html element ID for displaying a caption.
- */
- public function getCaptionID()
- {
- return $this->getViewState('CaptionID', '');
- }
-
- /**
- * @param string control or html element ID for displaying a caption.
- */
- public function setCaptionID($value)
- {
- $this->setViewState('CaptionID', $value, '');
- }
-
- protected function getCaptionControl()
- {
- if(($id=$this->getCaptionID())!=='')
- {
- if($control=$this->getParent()->findControl($id))
- return $control;
- }
- throw new TInvalidDataValueException(
- 'ratinglist_invalid_caption_id',$id,$this->getID());
- }
-
- public function setCaption($value)
- {
- $this->getCaptionControl()->setText($value);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->callClientFunction('setCaption',$value);
- }
-
- public function getCaption()
- {
- return $this->getCaptionControl()->getText();
- }
-
- /**
- * @param boolean true to enable the rating to be changed.
- */
- public function setEnabled($value)
- {
- $value = TPropertyValue::ensureBoolean($value);
- parent::setEnabled($value);
if($this->getActiveControl()->canUpdateClientSide())
- $this->callClientFunction('setEnabled',$value);
- }
-
- /**
- * @param string set the rating style, default is "default"
- */
- public function setRatingStyle($value)
- {
- $this->setViewState('RatingStyle', $value, 'default');
- }
-
- /**
- * @return TActiveRatingListStyle current rating style
- */
- public function getRatingStyle()
- {
- return $this->getViewState('RatingStyle', 'default');
- }
-
- /**
- * Sets the interval such that those rating values within the interval
- * will be considered as a half star rating.
- * @param array rating display half value interval, default is array(0.3, 0.7);
- */
- public function setHalfRatingInterval($value)
- {
- $this->setViewState('HalfRating',
- TPropertyValue::ensureArray($value), array(0.3, 0.7));
- }
-
- /**
- * @return array rating display half value interval, default is array(0.3, 0.7);
- */
- public function getHalfRatingInterval()
- {
- return $this->getViewState('HalfRating', array(0.3, 0.7));
- }
-
- /**
- * @return string rating style css class name.
- */
- protected function getRatingStyleCssClass()
- {
- return 'TActiveRatingList_'.$this->getRatingStyle();
- }
-
- /**
- * @return array list of post back options.
- */
- protected function getPostBackOptions()
- {
- $options = parent::getPostBackOptions();
- $options['Style'] = $this->getRatingStyleCssClass();
- $options['CaptionID'] = $this->getCaptionControlID();
- $options['SelectedIndex'] = $this->getSelectedIndex();
- $options['Rating'] = $this->getRating();
- $options['HalfRating'] = $this->getHalfRatingInterval();
- return $options;
- }
-
- /**
- * Registers the javascript code for initializing the active control
- * only if {@link setReadOnly ReadOnly} property is false.
- */
- protected function renderClientControlScript($writer)
- {
- if($this->getReadOnly()===false)
- parent::renderClientControlScript($writer);
- }
-
- /**
- * @return string find the client ID of the caption control.
- */
- protected function getCaptionControlID()
- {
- if(($id=$this->getCaptionID())!=='')
{
- if($control=$this->getParent()->findControl($id))
- {
- if($control->getVisible(true))
- return $control->getClientID();
- }
- else
- return $id;
+ $client = $this->getPage()->getCallbackClient();
+ $code = parent::getClientClassName().'.'.$func;
+ $client->callClientFunction($code,array($this,$value));
}
- return '';
}
/**
- * @param string asset file in the self::SCRIPT_PATH directory.
- * @return string asset file url.
+ * @param string caption text
*/
- protected function getAssetUrl($file='')
- {
- $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl();
- return $base.'/'.self::SCRIPT_PATH.'/'.$file;
- }
-
- /**
- * @param string rating style name
- * @return string URL of the css style file
- */
- protected function publishRatingListStyle($style)
- {
- $cs = $this->getPage()->getClientScript();
- $url = $this->getAssetUrl($style.'.css');
- if(!$cs->isStyleSheetFileRegistered($url))
- $cs->registerStyleSheetFile($url, $url);
- return $url;
- }
-
- /**
- * @param string rating style name
- * @param string rating image file extension, default is '.gif'
- * @return array URL of publish the rating images
- */
- protected function publishRatingListImages($style, $fileExt='.gif')
- {
- $types = array('blank', 'selected', 'half', 'combined');
- $files = array();
- foreach($types as $type)
- $files[$type] = $this->getAssetUrl("{$style}_{$type}{$fileExt}");
- return $files;
- }
-
- /**
- * Add rating style class name to the class attribute
- * when {@link setReadOnly ReadOnly} property is true and when the
- * {@link setCssClass CssClass} property is empty.
- * @param THtmlWriter renderer
- */
- public function render($writer)
- {
- if($this->getReadOnly())
- $writer->addAttribute('class', $this->getRatingStyleCssClass());
- else
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
- }
- parent::render($writer);
- }
-
- /**
- * Publish the the rating style css file and rating image files.
- */
- public function onPreRender($param)
- {
- parent::onPreRender($param);
-
- $this->publishRatingListStyle($this->getRatingStyle());
- $this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle());
- }
-
- /**
- * Renders the rating images if {@link setReadOnly ReadOnly} is true
- * otherwise render the radio buttons.
- */
- public function renderItem($writer,$repeatInfo,$itemType,$index)
- {
- if($this->getReadOnly())
- $this->renderStaticRating($writer, $repeatInfo, $itemType, $index);
- else
- parent::renderItem($writer, $repeatInfo, $itemType, $index);
- }
-
- /**
- * Renders the static rating images.
- */
- protected function renderStaticRating($writer, $repeatInfo, $itemType, $index)
- {
- $image = new TImage;
- $image->setImageUrl($this->_ratingImages[$this->getRatingImageType($index)]);
- $image->setAlternateText($this->getRating());
- $image->render($writer);
- }
-
- /**
- * @param integer rating image index
- * @return string the rating image corresponding to current index to be rendered.
- */
- protected function getRatingImageType($index)
+ public function setCaption($value)
{
- $rating = floatval($this->getRating());
- $int = intval($rating);
- $limit = $this->getHalfRatingInterval();
- if($index < $int || ($rating < $index+1 && $rating > $index+$limit[1]))
- return 'selected';
- if($rating >= $index+$limit[0] && $rating <= $index+$limit[1])
- return 'half';
- return 'blank';
+ parent::setCaption($value);
+ // if it's an active control, this should not be needed.
+ $this->callClientFunction('setCaption',$value);
}
/**
@@ -380,4 +131,3 @@ class TActiveRatingList extends TActiveRadioButtonList }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php index f7acfe6a..97efe008 100644 --- a/framework/Web/UI/ActiveControls/TActiveTextBox.php +++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php @@ -123,4 +123,3 @@ class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveC }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index c1379ac1..5a3633ec 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -328,7 +328,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer {
$string = strtr($string,array('\t'=>"\t",'\n'=>"\n",'\r'=>"\r"));
$token = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
- $options['tokens'] = TJavascript::encode($token,false);
+ $options['tokens'] = TJavaScript::encode($token,false);
}
if($this->getAutoPostBack())
{
@@ -343,8 +343,8 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer if(($minchars=$this->getMinChars())!=='')
$options['minChars'] = $minchars;
if(($frequency=$this->getFrequency())!=='')
- $options['frequency'] = $frequency; - $options['CausesValidation'] = $this->getCausesValidation(); + $options['frequency'] = $frequency;
+ $options['CausesValidation'] = $this->getCausesValidation();
$options['ValidationGroup'] = $this->getValidationGroup();
return $options;
}
@@ -438,4 +438,3 @@ class TAutoCompleteTemplate extends TComponent implements ITemplate }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 4ede6ff6..8f55e27b 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -385,8 +385,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl */
public function getJsCallbackOptions()
{
- return TJavascript::encode($this->getClientSideOptions());
+ return TJavaScript::encode($this->getClientSideOptions());
}
}
-?> diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php index 2e0fed69..c1559c1f 100644 --- a/framework/Web/UI/ActiveControls/TCallback.php +++ b/framework/Web/UI/ActiveControls/TCallback.php @@ -99,4 +99,3 @@ class TCallback extends TControl implements ICallbackEventHandler, IActiveContro }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index bc02182d..8f275ef8 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -670,4 +670,3 @@ class TCallbackClientScript extends TApplicationComponent }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSide.php b/framework/Web/UI/ActiveControls/TCallbackClientSide.php index a11204fb..57436278 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientSide.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientSide.php @@ -322,4 +322,3 @@ class TCallbackClientSide extends TClientSideOptions }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TCallbackEventParameter.php b/framework/Web/UI/ActiveControls/TCallbackEventParameter.php index 8e33407d..f08d40a9 100644 --- a/framework/Web/UI/ActiveControls/TCallbackEventParameter.php +++ b/framework/Web/UI/ActiveControls/TCallbackEventParameter.php @@ -85,4 +85,3 @@ class TCallbackEventParameter extends TEventParameter }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TCallbackOptions.php b/framework/Web/UI/ActiveControls/TCallbackOptions.php index 745cef17..7c48b795 100644 --- a/framework/Web/UI/ActiveControls/TCallbackOptions.php +++ b/framework/Web/UI/ActiveControls/TCallbackOptions.php @@ -51,4 +51,3 @@ class TCallbackOptions extends TControl }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TDraggable.php b/framework/Web/UI/ActiveControls/TDraggable.php new file mode 100755 index 00000000..e4e4c4c4 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TDraggable.php @@ -0,0 +1,152 @@ +<?php +/** + * TDraggable class file + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @version $Id$ + */ + +/** + * TDraggable is a control which can be dragged + * + * This control will make "draggable" control. + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @version $Id$ + */ +class TDraggable extends TPanel +{ + /** + * Set the handle id or css class + * @param string + */ + public function setHandle ($value) + { + $this->setViewState('DragHandle', TPropertyValue::ensureString($value), null); + } + + /** + * Get the handle id or css class + * @return string + */ + public function getHandle () + { + return $this->getViewState('DragHandle', null); + } + + /** + * Determine if draggable element should revert to it orginal position + * upon release in an non-droppable container. + * @return boolean true to revert + */ + public function getRevert() + { + return $this->getViewState('Revert', true); + } + + /** + * Sets whether the draggable element should revert to it orginal position + * upon release in an non-droppable container. + * @param boolean true to revert + */ + public function setRevert($value) + { + $this->setViewState('Revert', TPropertyValue::ensureBoolean($value), true); + } + + /** + * Determine if the element should be cloned when dragged + * If true, Clones the element and drags the clone, leaving the original in place until the clone is dropped. + * Defaults to false + * @return boolean true to clone the element + */ + public function getGhosting () + { + return $this->getViewState('Ghosting', false); + } + + /** + * Sets wether the element should be cloned when dragged + * If true, Clones the element and drags the clone, leaving the original in place until the clone is dropped. + * Defaults to false + * @return boolean true to clone the element + */ + public function setGhosting ($value) + { + $this->setViewState('Ghosting', TPropertyValue::ensureBoolean($value), false); + } + + /** + * Determine if the element should be constrainted in one direction or not + * @return CDraggableConstraint + */ + public function getConstraint() + { + return $this->getViewState('Constraint', TDraggableConstraint::None); + } + + /** + * Set wether the element should be constrainted in one direction + * @param CDraggableConstraint + */ + public function setConstraint($value) + { + $this->setViewState('Constraint', TPropertyValue::ensureEnum($value, 'TDraggableConstraint'), TDraggableConstraint::None); + } + + + /** + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. + */ + protected function addAttributesToRender($writer) + { + parent::addAttributesToRender($writer); + $writer->addAttribute('id',$this->getClientID()); + $cs=$this->getPage()->getClientScript(); + $cs->registerPradoScript('dragdrop'); + $options=TJavascript::encode($this->getPostBackOptions()); + $class=$this->getClientClassName(); + $code="new {$class}('{$this->getClientId()}', {$options}) "; + $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); + } + + /** + * Gets the name of the javascript class responsible for performing postback for this control. + * This method overrides the parent implementation. + * @return string the javascript class name + */ + protected function getClientClassName () + { + return 'Draggable'; + } + + /** + * Gets the post back options for this textbox. + * @return array + */ + protected function getPostBackOptions() + { + $options['ID'] = $this->getClientID(); + + if (($handle=$this->getHandle())!== null) $options['handle']=$handle; + $options['revert']=$this->getRevert(); + if (($constraint=$this->getConstraint())!==TDraggableConstraint::None) $options['constraint']=strtolower($constraint); + $options['ghosting']=$this->getGhosting(); + + return $options; + } + +} + +class TDraggableConstraint extends TEnumerable +{ + const None='None'; + const Horizontal='Horizontal'; + const Vertical='Vertical'; +} +?>
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php new file mode 100755 index 00000000..5d090d95 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TDropContainer.php @@ -0,0 +1,275 @@ +<?php +/** + * TDropContainer class file + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @version $Id$ + */ + +/** + * Load active control adapter. + */ +Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); +/** + * Load active panel. + */ +Prado::using('System.Web.UI.ActiveControls.TActivePanel'); + + +/** + * TDropContainer is a panel where TDraggable controls can be dropped. + * When a TDraggable component is dropped into a TDropContainer, the {@link OnDrop OnDrop} event is raised. + * The {@link TDropContainerEventParameter} param will contain the dropped control. + * + * Properties : + * + * <b>{@link setAcceptCssClass AcceptCssClass}</b> : a coma delimited classname of elements that the drop container can accept. + * <b>{@link setHoverCssClass HoverCssClass}</b>: CSS classname of the container when a draggable element hovers over the container. + * + * Events: + * + * <b>{@link OnDrop OnDrop} : raised when a TDraggable control is dropped. The dropped control is encapsulated in the event parameter + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @version $Id$ + */ +class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHandler +{ + private $_container=null; + + /** + * Creates a new callback control, sets the adapter to + * TActiveControlAdapter. If you override this class, be sure to set the + * adapter appropriately by, for example, by calling this constructor. + */ + public function __construct() + { + parent::__construct(); + $this->setAdapter(new TActiveControlAdapter($this)); + } + + /** + * @return TBaseActiveControl standard active control options. + */ + public function getActiveControl() + { + return $this->getAdapter()->getBaseActiveControl(); + } + + + /** + * Gets the Css class name that this container can accept. + * @return string + */ + public function getAcceptCssClass() + { + return $this->getViewState('Accepts', ''); + } + + /** + * Sets the Css class name that this container can accept. + * @param string comma delimited css class names. + */ + public function setAcceptCssClass($value) + { + $this->setViewState('Accepts', TPropertyValue::ensureArray($value), ''); + } + + /** + * Sets the Css class name used when a draggble element is hovering + * over this container. + * @param string css class name during draggable hover. + */ + public function setHoverCssClass($value) + { + $this->setViewState('HoverClass', $value, ''); + } + + /** + * Gets the Css class name used when a draggble element is hovering + * over this container. + * @return string css class name during draggable hover. + */ + public function getHoverCssClass() + { + return $this->getViewState('HoverClass', ''); + } + + + /** + * Raises callback event. This method is required bu {@link ICallbackEventHandler} + * interface. + * It raises the {@link onDrop OnDrop} event, then, the {@link onCallback OnCallback} event + * This method is mainly used by framework and control developers. + * @param TCallbackEventParameter the parameter associated with the callback event + */ + public function raiseCallbackEvent($param) + { + $this->onDrop($param->getCallbackParameter()); + $this->onCallback($param); + } + + /** + * Raises the onDrop event. + * The dropped control is encapsulated into a {@link TDropContainerEventParameter} + * + * @param string $dropControlId + */ + public function onDrop ($dropControlId) + { + // Find the control + // Warning, this will not work if you have a '_' in your control Id ! + $control=$this->getPage(); + $namingContainers=explode(TControl::CLIENT_ID_SEPARATOR, $dropControlId); + foreach ($namingContainers as $nc) + { + $control=$control->findControl($nc); + } + $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($control)); + + } + + /** + * This method is invoked when a callback is requested. The method raises + * 'OnCallback' event to fire up the event handlers. If you override this + * method, be sure to call the parent implementation so that the event + * handler can be invoked. + * @param TCallbackEventParameter event parameter to be passed to the event handlers + */ + public function onCallback($param) + { + $this->raiseEvent('OnCallback', $this, $param); + } + + /** + * Gets the post back options for this textbox. + * @return array + */ + protected function getPostBackOptions() + { + $options['ID'] = $this->getClientID(); + $options['EventTarget'] = $this->getUniqueID(); + + $options['accept'] = TJavascript::encode($this->getAcceptCssClass()); + $options['hoverclass'] = $this->getHoverCssClass(); + return $options; + } + + /** + * Gets the name of the javascript class responsible for performing postback for this control. + * This method overrides the parent implementation. + * @return string the javascript class name + */ + protected function getClientClassName() + { + return 'Prado.WebUI.DropContainer'; + } + + + /** + * Ensure that the ID attribute is rendered and registers the javascript code + * for initializing the active control. + */ + protected function addAttributesToRender($writer) + { + parent::addAttributesToRender($writer); + $writer->addAttribute('id',$this->getClientID()); + + $this->getPage()->getClientScript()->registerPradoScript('dragdrop'); + + $this->getActiveControl()->registerCallbackClientScript( + $this->getClientClassName(), $this->getPostBackOptions()); + } + + /** + * Creates child control + * Override parent implementation to create a container which will contain all + * child controls. This container will be a TActivePanel, in order to allow user + * to update its content on callback. + */ + public function createChildControls () + { + if ($this->_container===null) + { + $this->_container=Prado::CreateComponent('System.Web.UI.ActiveControls.TActivePanel'); + $this->_container->setId($this->getId().'_content'); + parent::getControls()->add($this->_container); + } + } + + /** + * Override parent implementation to return the container control collection. + * + * @return TControlCollection + */ + public function getControls() + { + $this->ensureChildControls(); + return $this->_container->getControls(); + } + + /** + * Renders and replaces the panel's content on the client-side. + * When render() is called before the OnPreRender event, such as when render() + * is called during a callback event handler, the rendering + * is defered until OnPreRender event is raised. + * @param THtmlWriter html writer + */ + public function render ($writer) + { + if($this->getHasPreRendered()) + { + parent::render($writer); + if($this->getActiveControl()->canUpdateClientSide()) + $this->getPage()->getCallbackClient()->replaceContent($this->_container,$writer); + } + else + { + $this->getPage()->getAdapter()->registerControlToRender($this->_container,$writer); + } + } + +} + +/** + * TDropContainerEventParameter class + * + * TDropContainerEventParameter encapsulate the parameter + * data for <b>OnDrop</b> event of TDropContainer components + * + * @author Christophe BOULAIN (Christophe.Boulain@ceram.fr) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @version $Id$ + */ +class TDropContainerEventParameter extends TEventParameter +{ + /* + * the id of control which has been dropped + * @var string + */ + private $_droppedControl; + + /** + * constructor + * + * @param string the id of control which been dropped + */ + public function __construct ($control) + { + $this->_droppedControl=$control; + } + + /** + * @return TDraggable + */ + public function getDroppedControl () + { + return $this->_droppedControl; + } +} +?>
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php b/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php index 735ff926..fe4be8a8 100644 --- a/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php @@ -93,4 +93,3 @@ class TEventTriggeredCallback extends TTriggeredCallback }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php index 855e78a0..6e1c6b7a 100644 --- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php +++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php @@ -269,4 +269,3 @@ class TInPlaceTextBox extends TActiveTextBox }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php index a1410364..3dee5c59 100644 --- a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php @@ -49,6 +49,10 @@ class TTimeTriggeredCallback extends TCallback if($interval <= 0) throw new TConfigurationException('callback_interval_be_positive', $this->getID()); $this->setViewState('Interval', $interval, 1); + if ($this->getActiveControl()->canUpdateClientSide()){ + $client = $this->getPage()->getCallbackClient(); + $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.setInterval', array($this, $interval)); + } } /** @@ -56,10 +60,8 @@ class TTimeTriggeredCallback extends TCallback */ public function startTimer() { - $id = $this->getClientID(); - $code = "Prado.WebUI.TTimeTriggeredCallback.start('{$id}');"; - $cs = $this->getPage()->getClientScript(); - $cs->registerEndScript("{$id}:start", $code); + $client = $this->getPage()->getCallbackClient(); + $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.start', array($this)); } /** @@ -67,10 +69,8 @@ class TTimeTriggeredCallback extends TCallback */ public function stopTimer() { - $id = $this->getClientID(); - $code = "Prado.WebUI.TTimeTriggeredCallback.stop('{$id}');"; - $cs = $this->getPage()->getClientScript(); - $cs->registerEndScript("{$id}:stop", $code); + $client = $this->getPage()->getCallbackClient(); + $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.stop', array($this)); } /** @@ -110,8 +110,12 @@ class TTimeTriggeredCallback extends TCallback parent::render($writer); $this->getActiveControl()->registerCallbackClientScript( $this->getClientClassName(), $this->getTriggerOptions()); - if($this->getStartTimerOnLoad()) - $this->startTimer(); + if($this->getStartTimerOnLoad()){ + $id = $this->getClientID(); + $code = "Prado.WebUI.TTimeTriggeredCallback.start('{$id}');"; + $cs = $this->getPage()->getClientScript(); + $cs->registerEndScript("{$id}:start", $code); + } } /** diff --git a/framework/Web/UI/ActiveControls/TTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTriggeredCallback.php index 18679b4a..6923a53a 100644 --- a/framework/Web/UI/ActiveControls/TTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TTriggeredCallback.php @@ -68,4 +68,3 @@ abstract class TTriggeredCallback extends TCallback }
}
-?> diff --git a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php index 5a44f380..305afd70 100644 --- a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php @@ -116,4 +116,3 @@ class TValueTriggeredCallback extends TTriggeredCallback return 'Prado.WebUI.TValueTriggeredCallback';
}
}
-?> diff --git a/framework/Web/UI/TCachePageStatePersister.php b/framework/Web/UI/TCachePageStatePersister.php index 0b201d92..742bd687 100644 --- a/framework/Web/UI/TCachePageStatePersister.php +++ b/framework/Web/UI/TCachePageStatePersister.php @@ -199,4 +199,3 @@ class TCachePageStatePersister extends TComponent implements IPageStatePersister }
}
-?> diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 83fdf789..f0eb6157 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -169,7 +169,10 @@ class TClientScriptManager extends TApplicationComponent $scriptLoaderPath = $path.'/'.basename(self::SCRIPT_LOADER); $scriptLoaderSrc = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_LOADER; if(!is_file($scriptLoaderPath)) + { copy($scriptLoaderSrc, $scriptLoaderPath); + chmod($scriptLoaderPath, PRADO_CHMOD); + } $url .= '/'.basename(self::SCRIPT_LOADER).'?js='.implode(',', $packages); if($debug!==false && $this->getApplication()->getMode()===TApplicationMode::Debug) { @@ -230,7 +233,7 @@ class TClientScriptManager extends TApplicationComponent $class = new TReflectionClass($callbackHandler); $clientSide = $callbackHandler->getActiveControl()->getClientSide(); $options = array_merge($options, $clientSide->getOptions()->toArray()); - $optionString = TJavascript::encode($options); + $optionString = TJavaScript::encode($options); $this->registerPradoScriptInternal('ajax'); $id = $callbackHandler->getUniqueID(); return "new Prado.CallbackRequest('{$id}',{$optionString})"; @@ -677,8 +680,8 @@ abstract class TClientSideOptions extends TComponent */ protected function setFunction($name, $code) { - if(!TJavascript::isFunction($code)) - $code = TJavascript::quoteFunction($this->ensureFunction($code)); + if(!TJavaScript::isFunction($code)) + $code = TJavaScript::quoteFunction($this->ensureFunction($code)); $this->setOption($name, $code); } @@ -717,4 +720,3 @@ abstract class TClientSideOptions extends TComponent } } -?> diff --git a/framework/Web/UI/TCompositeControl.php b/framework/Web/UI/TCompositeControl.php index d30756e2..1cf31440 100644 --- a/framework/Web/UI/TCompositeControl.php +++ b/framework/Web/UI/TCompositeControl.php @@ -36,4 +36,3 @@ class TCompositeControl extends TControl implements INamingContainer }
}
-?> diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 576db89b..1c03a04d 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1997,6 +1997,14 @@ interface IValidatable * @return mixed the value of the property to be validated.
*/
public function getValidationPropertyValue();
+ /** + * @return boolean wether this control's validators validated successfully (must default to true) + */ + public function getIsValid(); + /** + * @return boolean wether this control's validators validated successfully + */ + public function setIsValid($value); }
/**
diff --git a/framework/Web/UI/TControlAdapter.php b/framework/Web/UI/TControlAdapter.php index a6263f7f..16a8c839 100644 --- a/framework/Web/UI/TControlAdapter.php +++ b/framework/Web/UI/TControlAdapter.php @@ -141,4 +141,3 @@ class TControlAdapter extends TApplicationComponent }
}
-?> diff --git a/framework/Web/UI/TForm.php b/framework/Web/UI/TForm.php index 436352c5..2356a733 100644 --- a/framework/Web/UI/TForm.php +++ b/framework/Web/UI/TForm.php @@ -165,4 +165,3 @@ class TForm extends TControl }
}
-?> diff --git a/framework/Web/UI/THtmlWriter.php b/framework/Web/UI/THtmlWriter.php index dd68b828..217b9663 100644 --- a/framework/Web/UI/THtmlWriter.php +++ b/framework/Web/UI/THtmlWriter.php @@ -254,4 +254,3 @@ class THtmlWriter extends TApplicationComponent implements ITextWriter }
}
-?> diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 1a0f04a6..12433715 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -1234,10 +1234,10 @@ class TPageStateFormatter $str=$sm->hashData(Prado::serialize($data));
else
$str=Prado::serialize($data);
- if($page->getEnableStateEncryption())
- $str=$sm->encrypt($str);
if(extension_loaded('zlib'))
$str=gzcompress($str);
+ if($page->getEnableStateEncryption())
+ $str=$sm->encrypt($str);
return base64_encode($str);
}
@@ -1251,13 +1251,13 @@ class TPageStateFormatter $str=base64_decode($data);
if($str==='')
return null;
- if(extension_loaded('zlib'))
- $str=@gzuncompress($str);
if($str!==false)
{
$sm=$page->getApplication()->getSecurityManager();
if($page->getEnableStateEncryption())
$str=$sm->decrypt($str);
+ if(extension_loaded('zlib'))
+ $str=@gzuncompress($str);
if($page->getEnableStateValidation())
{
if(($str=$sm->validateData($str))!==false)
diff --git a/framework/Web/UI/TPageStatePersister.php b/framework/Web/UI/TPageStatePersister.php index e8ea0713..4b217aee 100644 --- a/framework/Web/UI/TPageStatePersister.php +++ b/framework/Web/UI/TPageStatePersister.php @@ -69,4 +69,3 @@ class TPageStatePersister extends TComponent implements IPageStatePersister }
}
-?> diff --git a/framework/Web/UI/TSessionPageStatePersister.php b/framework/Web/UI/TSessionPageStatePersister.php index 2c93118c..f422dfa8 100644 --- a/framework/Web/UI/TSessionPageStatePersister.php +++ b/framework/Web/UI/TSessionPageStatePersister.php @@ -129,4 +129,3 @@ class TSessionPageStatePersister extends TComponent implements IPageStatePersist }
}
-?> diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php index e8138e30..7da54e6c 100644 --- a/framework/Web/UI/TTemplateControl.php +++ b/framework/Web/UI/TTemplateControl.php @@ -241,4 +241,3 @@ class TTemplateControl extends TCompositeControl }
}
-?> diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index be2beba6..f44d414c 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -4,7 +4,7 @@ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI
@@ -174,10 +174,10 @@ class TTemplate extends TApplicationComponent implements ITemplate * '<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>' - component tags
* '<\/?prop:([\w\.]+)\s*>' - property tags
* '<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>' - directives
- * '<%[%#~\\$=\\[](.*?)%>' - expressions
+ * '<%[%#~\/\\$=\\[](.*?)%>' - expressions
* '<prop:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/>' - group subproperty tags
*/
- const REGEX_RULES='/<!--.*?--!>|<!---.*?--->|<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/>/msS';
+ const REGEX_RULES='/<!--.*?--!>|<!---.*?--->|<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>|<%[%#~\/\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/>/msS';
/**
* Different configurations of component property/event/attribute
@@ -661,6 +661,8 @@ class TTemplate extends TApplicationComponent implements ITemplate $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
else if($str[2]==='~')
$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
+ else if($str[2]==='/')
+ $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"dirname(\$this->getApplication()->getRequest()->getApplicationUrl()).'/$literal'"));
else if($str[2]==='[')
{
$literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\"));
@@ -1064,4 +1066,3 @@ class TTemplate extends TApplicationComponent implements ITemplate }
}
-?> diff --git a/framework/Web/UI/WebControls/TBaseDataList.php b/framework/Web/UI/WebControls/TBaseDataList.php index df91a0a6..d202eab8 100644 --- a/framework/Web/UI/WebControls/TBaseDataList.php +++ b/framework/Web/UI/WebControls/TBaseDataList.php @@ -188,4 +188,3 @@ abstract class TBaseDataList extends TDataBoundControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index add771cc..b418885c 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -269,8 +269,11 @@ abstract class TBaseValidator extends TLabel implements IValidator { $class = preg_replace ('/ '.preg_quote($cssClass).'/', '',$control->getCssClass()); if(!$this->getIsValid()) + { $class .= ' '.$cssClass; - $control->setCssClass($class); + $control->setCssClass($class); + } elseif ($control->getIsValid()) + $control->setCssClass($class); } } } @@ -493,7 +496,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $this->setIsValid(true); $this->onValidate(); if($this->getVisible(true) && $this->getEnabled(true)) - { + { // if the target is not a disabled web control if(($target=$this->getValidationTarget())!==null && !($target instanceof TWebControl && !$target->getEnabled(true))) { @@ -504,10 +507,17 @@ abstract class TBaseValidator extends TLabel implements IValidator } else { + $target->setIsValid(false); $this->setIsValid(false); $this->onValidationError(); } } + else + { + $this->evaluateIsValid(); + $this->setIsValid(true); + $this->onValidationSuccess(); + } } return $this->getIsValid(); } @@ -721,4 +731,3 @@ class TValidationDataType extends TEnumerable const String='String'; } -?> diff --git a/framework/Web/UI/WebControls/TBoundColumn.php b/framework/Web/UI/WebControls/TBoundColumn.php index 13fb6af8..264bbc6c 100644 --- a/framework/Web/UI/WebControls/TBoundColumn.php +++ b/framework/Web/UI/WebControls/TBoundColumn.php @@ -233,4 +233,3 @@ class TBoundColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php index f99c7986..60cf743e 100644 --- a/framework/Web/UI/WebControls/TBulletedList.php +++ b/framework/Web/UI/WebControls/TBulletedList.php @@ -485,4 +485,3 @@ class TBulletedListDisplayMode extends TEnumerable const LinkButton='LinkButton';
}
-?> diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index dc66e9d6..81929a28 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -366,4 +366,3 @@ class TButtonType extends TEnumerable const Button='Button';
}
-?> diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php index 24199ddd..186577e5 100644 --- a/framework/Web/UI/WebControls/TButtonColumn.php +++ b/framework/Web/UI/WebControls/TButtonColumn.php @@ -276,4 +276,3 @@ class TButtonColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TCaptcha.php b/framework/Web/UI/WebControls/TCaptcha.php index 153b1d30..3c51c389 100644 --- a/framework/Web/UI/WebControls/TCaptcha.php +++ b/framework/Web/UI/WebControls/TCaptcha.php @@ -489,4 +489,3 @@ class TCaptcha extends TImage }
}
-?> diff --git a/framework/Web/UI/WebControls/TCaptchaValidator.php b/framework/Web/UI/WebControls/TCaptchaValidator.php index 770cd514..5477fe54 100644 --- a/framework/Web/UI/WebControls/TCaptchaValidator.php +++ b/framework/Web/UI/WebControls/TCaptchaValidator.php @@ -121,4 +121,3 @@ class TCaptchaValidator extends TBaseValidator }
}
-?> diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index faff5086..d8c2cc0b 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -43,6 +43,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer, ISurroundable
{
private $_dataChanged=false;
+ private $_isValid=true; /**
* @return string tag name of the button
@@ -125,6 +126,23 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl return $this->getChecked();
}
+ /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /**
* @return string the text caption of the checkbox
*/
diff --git a/framework/Web/UI/WebControls/TCheckBoxColumn.php b/framework/Web/UI/WebControls/TCheckBoxColumn.php index 36217343..71eea97f 100644 --- a/framework/Web/UI/WebControls/TCheckBoxColumn.php +++ b/framework/Web/UI/WebControls/TCheckBoxColumn.php @@ -121,4 +121,3 @@ class TCheckBoxColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 1e1c3b10..742dd18b 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -53,6 +53,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont private $_isEnabled;
private $_changedEventRaised=false;
private $_dataChanged=false;
+ private $_isValid=true; /**
* Constructor.
@@ -428,6 +429,23 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont return $this->getSelectedValue();
}
+ /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /**
* Gets the name of the javascript class responsible for performing postback for this control.
* This method overrides the parent implementation.
@@ -454,4 +472,3 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont }
-?> diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php index 5369d27d..b5806a57 100644 --- a/framework/Web/UI/WebControls/TClientScript.php +++ b/framework/Web/UI/WebControls/TClientScript.php @@ -129,4 +129,3 @@ class TClientScript extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TClientScriptLoader.php b/framework/Web/UI/WebControls/TClientScriptLoader.php index c916bcc5..ec763bb3 100644 --- a/framework/Web/UI/WebControls/TClientScriptLoader.php +++ b/framework/Web/UI/WebControls/TClientScriptLoader.php @@ -168,4 +168,3 @@ class TClientScriptLoader extends TWebControl } } -?> diff --git a/framework/Web/UI/WebControls/TColorPicker.php b/framework/Web/UI/WebControls/TColorPicker.php index 5b96723a..67a4ccfe 100644 --- a/framework/Web/UI/WebControls/TColorPicker.php +++ b/framework/Web/UI/WebControls/TColorPicker.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -203,6 +203,7 @@ class TColorPicker extends TTextBox $writer->addAttribute('style', "background-color:{$color};");
$writer->addAttribute('width', '20');
$writer->addAttribute('height', '20');
+ $writer->addAttribute('alt', '');
$writer->renderBeginTag('img');
$writer->renderEndTag();
$writer->renderEndTag();
@@ -270,4 +271,3 @@ class TColorPickerClientSide extends TClientSideOptions }
}
-?> diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index e5723f2a..1261cded 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -263,4 +263,3 @@ class TValidationCompareOperator extends TEnumerable const LessThanEqual='LessThanEqual';
}
-?> diff --git a/framework/Web/UI/WebControls/TConditional.php b/framework/Web/UI/WebControls/TConditional.php index 7af6622e..fafe12c9 100644 --- a/framework/Web/UI/WebControls/TConditional.php +++ b/framework/Web/UI/WebControls/TConditional.php @@ -141,4 +141,3 @@ class TConditional extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TContent.php b/framework/Web/UI/WebControls/TContent.php index ecc2a1b5..b327b440 100644 --- a/framework/Web/UI/WebControls/TContent.php +++ b/framework/Web/UI/WebControls/TContent.php @@ -45,4 +45,3 @@ class TContent extends TControl implements INamingContainer }
}
-?> diff --git a/framework/Web/UI/WebControls/TContentPlaceHolder.php b/framework/Web/UI/WebControls/TContentPlaceHolder.php index 29e12ab3..90390d9d 100644 --- a/framework/Web/UI/WebControls/TContentPlaceHolder.php +++ b/framework/Web/UI/WebControls/TContentPlaceHolder.php @@ -46,4 +46,3 @@ class TContentPlaceHolder extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index e998cef6..0b82ac5c 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -4,7 +4,7 @@ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -88,7 +88,9 @@ class TCustomValidator extends TBaseValidator */
public function evaluateIsValid()
{
- $value=$this->getValidationValue($this->getValidationTarget());
+ $value = '';
+ if($this->getValidationTarget()!==null)
+ $value=$this->getValidationValue($this->getValidationTarget());
return $this->onServerValidate($value);
}
@@ -105,9 +107,24 @@ class TCustomValidator extends TBaseValidator {
$param=new TServerValidateEventParameter($value,true);
$this->raiseEvent('OnServerValidate',$this,$param);
- return $param->getIsValid();
+ if($this->getValidationTarget()==null)
+ return true;
+ else
+ return $param->getIsValid();
+ }
+
+ /**
+ * @return TControl control to be validated. Null if no control is found.
+ */
+ protected function getValidationTarget()
+ {
+ if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null)
+ return $control;
+ else if(($id=$this->getControlToValidate())!=='')
+ throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this));
+ else
+ return null;
}
-
/**
* Returns an array of javascript validator options.
@@ -191,4 +208,3 @@ class TServerValidateEventParameter extends TEventParameter $this->_isValid=TPropertyValue::ensureBoolean($value);
}
}
-?> diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index c8e6c9a8..9551b376 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -2203,4 +2203,3 @@ class TDataGridPagerPosition extends TEnumerable const TopAndBottom='TopAndBottom';
}
-?> diff --git a/framework/Web/UI/WebControls/TDataGridColumn.php b/framework/Web/UI/WebControls/TDataGridColumn.php index e3c2f297..577c0068 100644 --- a/framework/Web/UI/WebControls/TDataGridColumn.php +++ b/framework/Web/UI/WebControls/TDataGridColumn.php @@ -565,4 +565,3 @@ class TButtonColumnType extends TEnumerable const ImageButton='ImageButton';
}
-?> diff --git a/framework/Web/UI/WebControls/TDataGridItemRenderer.php b/framework/Web/UI/WebControls/TDataGridItemRenderer.php index 8e0f9e70..62c226f6 100644 --- a/framework/Web/UI/WebControls/TDataGridItemRenderer.php +++ b/framework/Web/UI/WebControls/TDataGridItemRenderer.php @@ -28,4 +28,3 @@ class TDataGridItemRenderer extends TItemDataRenderer {
}
-?> diff --git a/framework/Web/UI/WebControls/TDataGridPagerStyle.php b/framework/Web/UI/WebControls/TDataGridPagerStyle.php index dcc9d983..e29b9dc9 100644 --- a/framework/Web/UI/WebControls/TDataGridPagerStyle.php +++ b/framework/Web/UI/WebControls/TDataGridPagerStyle.php @@ -219,4 +219,3 @@ class TDataGridPagerStyle extends TPanelStyle }
}
-?> diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php index 7d0965a2..ca628b21 100644 --- a/framework/Web/UI/WebControls/TDataList.php +++ b/framework/Web/UI/WebControls/TDataList.php @@ -1764,4 +1764,3 @@ class TDataListItemCollection extends TList }
}
-?> diff --git a/framework/Web/UI/WebControls/TDataListItemRenderer.php b/framework/Web/UI/WebControls/TDataListItemRenderer.php index 5481cad7..1bf2fcb2 100644 --- a/framework/Web/UI/WebControls/TDataListItemRenderer.php +++ b/framework/Web/UI/WebControls/TDataListItemRenderer.php @@ -170,4 +170,3 @@ class TDataListItemRenderer extends TItemDataRenderer implements IStyleable }
}
-?> diff --git a/framework/Web/UI/WebControls/TDataRenderer.php b/framework/Web/UI/WebControls/TDataRenderer.php index e884afe1..4aaeec0a 100644 --- a/framework/Web/UI/WebControls/TDataRenderer.php +++ b/framework/Web/UI/WebControls/TDataRenderer.php @@ -50,4 +50,3 @@ abstract class TDataRenderer extends TTemplateControl implements IDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/TDataSourceControl.php b/framework/Web/UI/WebControls/TDataSourceControl.php index e42d7381..1d0823ff 100644 --- a/framework/Web/UI/WebControls/TDataSourceControl.php +++ b/framework/Web/UI/WebControls/TDataSourceControl.php @@ -116,4 +116,3 @@ class TReadOnlyDataSource extends TDataSourceControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TDataSourceView.php b/framework/Web/UI/WebControls/TDataSourceView.php index 7c0ee2d0..7297fd45 100644 --- a/framework/Web/UI/WebControls/TDataSourceView.php +++ b/framework/Web/UI/WebControls/TDataSourceView.php @@ -204,4 +204,3 @@ class TReadOnlyDataSourceView extends TDataSourceView }
}
-?> diff --git a/framework/Web/UI/WebControls/TDataTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php index d4fa20c3..14017585 100644 --- a/framework/Web/UI/WebControls/TDataTypeValidator.php +++ b/framework/Web/UI/WebControls/TDataTypeValidator.php @@ -139,4 +139,3 @@ class TDataTypeValidator extends TBaseValidator }
}
-?> diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 84455fee..770099eb 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -59,7 +59,12 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); * In <tt>DropDownList</tt> mode, in addition to the popup date picker, three
* drop down list (day, month and year) are presented to select the date .
*
+ * The <b>PositionMode</b> property can be set to "Top" or "Bottom" with default
+ * as "Bottom". It specifies the position of the calendar popup, relative to the
+ * input field.
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @author Carl G. Mathisen <carlgmathisen@gmail.com>
* @version $Id$
* @package System.Web.UI.WebControls
* @since 3.0
@@ -263,6 +268,22 @@ class TDatePicker extends TTextBox {
return $this->getViewState('UpToYear', intval(@date('Y'))+10);
}
+
+ /**
+ * @param TDatePickerPositionMode calendar UI position
+ */
+ public function setPositionMode($value)
+ {
+ $this->setViewState('PositionMode', TPropertyValue::ensureEnum($value, 'TDatePickerPositionMode'), TDatePickerPositionMode::Bottom);
+ }
+
+ /**
+ * @return TDatePickerPositionMode current calendar UI position.
+ */
+ public function getPositionMode()
+ {
+ return $this->getViewState('PositionMode', TDatePickerPositionMode::Bottom);
+ }
/**
* @return integer current selected date from the date picker as timestamp, NULL if timestamp is not set previously.
@@ -505,6 +526,7 @@ class TDatePicker extends TTextBox $options['UpToYear'] = $this->getUpToYear();
if($this->getMode()!==TDatePickerMode::Basic)
$options['Trigger'] = $this->getDatePickerButtonID();
+ $options['PositionMode'] = $this->getPositionMode();
$options = array_merge($options, $this->getCulturalOptions());
if(!is_null($this->_clientScript))
@@ -853,8 +875,8 @@ class TDatePicker extends TTextBox *
* The <tt>OnDateChanged</tt> event is raise when the date picker's date
* is changed.
- * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent - * as parameter to this event + * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent
+ * as parameter to this event
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
@@ -923,4 +945,20 @@ class TDatePickerMode extends TEnumerable const ImageButton='ImageButton';
}
-?> +/**
+ * TDatePickerPositionMode class.
+ * TDatePickerPositionMode defines the positions available for the calendar popup, relative to the corresponding input.
+ *
+ * The following enumerable values are defined:
+ * - Top: the date picker is placed above the input field
+ * - Bottom: the date picker is placed below the input field
+ *
+ * @author Carl G. Mathisen <carlgmathisen@gmail.com>
+ * @package System.Web.UI.WebControls
+ * @since 3.1.4
+ */
+class TDatePickerPositionMode extends TEnumerable
+{
+ const Top='Top';
+ const Bottom='Bottom';
+}
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php index f00466d5..73be981c 100644 --- a/framework/Web/UI/WebControls/TDropDownList.php +++ b/framework/Web/UI/WebControls/TDropDownList.php @@ -40,6 +40,7 @@ Prado::using('System.Web.UI.WebControls.TListControl'); class TDropDownList extends TListControl implements IPostBackDataHandler, IValidatable
{
private $_dataChanged=false;
+ private $_isValid=true; /**
* Adds attributes to renderer.
@@ -127,5 +128,21 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid {
return $this->getSelectedValue();
}
+ + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } }
-?> diff --git a/framework/Web/UI/WebControls/TDropDownListColumn.php b/framework/Web/UI/WebControls/TDropDownListColumn.php index cff42cad..a225abac 100644 --- a/framework/Web/UI/WebControls/TDropDownListColumn.php +++ b/framework/Web/UI/WebControls/TDropDownListColumn.php @@ -319,4 +319,3 @@ class TDropDownListColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TEditCommandColumn.php b/framework/Web/UI/WebControls/TEditCommandColumn.php index f9989a4e..1699afa2 100644 --- a/framework/Web/UI/WebControls/TEditCommandColumn.php +++ b/framework/Web/UI/WebControls/TEditCommandColumn.php @@ -263,4 +263,3 @@ class TEditCommandColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php index c5407516..206bd23d 100644 --- a/framework/Web/UI/WebControls/TEmailAddressValidator.php +++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php @@ -95,4 +95,3 @@ class TEmailAddressValidator extends TRegularExpressionValidator }
}
-?> diff --git a/framework/Web/UI/WebControls/TExpression.php b/framework/Web/UI/WebControls/TExpression.php index 022a0b21..34190473 100644 --- a/framework/Web/UI/WebControls/TExpression.php +++ b/framework/Web/UI/WebControls/TExpression.php @@ -60,4 +60,3 @@ class TExpression extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TFileUpload.php b/framework/Web/UI/WebControls/TFileUpload.php index 47d49c0c..6658e93d 100644 --- a/framework/Web/UI/WebControls/TFileUpload.php +++ b/framework/Web/UI/WebControls/TFileUpload.php @@ -59,6 +59,7 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata */
private $_errorCode=UPLOAD_ERR_NO_FILE;
private $_dataChanged=false;
+ private $_isValid=true; /**
* @return string tag name of the file upload control
@@ -255,6 +256,23 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata {
return $this->getFileName();
}
+ + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + }
-?> diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php index cb0fba93..9ba644f8 100644 --- a/framework/Web/UI/WebControls/TFont.php +++ b/framework/Web/UI/WebControls/TFont.php @@ -316,4 +316,3 @@ class TFont extends TComponent $writer->addStyleAttribute('font-family',$this->_name);
}
}
-?> diff --git a/framework/Web/UI/WebControls/THead.php b/framework/Web/UI/WebControls/THead.php index 1b51f8ae..62ee46d3 100644 --- a/framework/Web/UI/WebControls/THead.php +++ b/framework/Web/UI/WebControls/THead.php @@ -4,7 +4,7 @@ *
* @author Marcus Nyeholt <tanus@users.sourceforge.net> and Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI
@@ -29,6 +29,13 @@ * <com:TMetaTag Name="keywords" Content="Prado" />
* </com:THead>
* </code>
+ *
+ * A MetaTag for "generator" is added by default if you haven't specified your own generator meta tag. You can override
+ * the property by adding the following code to your template:
+ * <com:THead>
+ * <com:TMetaTag Name="generator" Content="Custom name" />
+ * </com:THead>
+ * </code>
*
* Note, {@link TPage} has a property {@link TPage::getHead Head} that refers to
* the THead control currently on the page. A page can have at most once THead
@@ -155,14 +162,24 @@ class THead extends TControl if(($icon=$this->getShortcutIcon())!=='')
$writer->write('<link rel="shortcut icon" href="'.$icon."\" />\n");
+ $generatorAdded = false;
if(($metaTags=$this->getMetaTags())!==null)
{
foreach($metaTags as $metaTag)
{
+ if(strtolower($metaTag->getName()) == 'generator')
+ $generatorAdded = true;
$metaTag->render($writer);
$writer->writeLine();
}
}
+ if(!$generatorAdded)
+ {
+ $metaTag = new TMetaTag();
+ $metaTag->setName('generator');
+ $metaTag->setContent(Prado::metaGenerator());
+ $metaTag->render($writer);
+ }
$cs=$page->getClientScript();
$cs->renderStyleSheetFiles($writer);
$cs->renderStyleSheets($writer);
@@ -374,4 +391,4 @@ class TMetaTagCollection extends TList }
}
-?> +?>
diff --git a/framework/Web/UI/WebControls/THiddenField.php b/framework/Web/UI/WebControls/THiddenField.php index 2fbbcf99..49b1aa39 100644 --- a/framework/Web/UI/WebControls/THiddenField.php +++ b/framework/Web/UI/WebControls/THiddenField.php @@ -26,6 +26,7 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatable, IDataRenderer
{
private $_dataChanged=false;
+ private $_isValid=true; /**
* @return string tag name of the hidden field.
@@ -111,6 +112,23 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatabl return $this->getValue();
}
+ /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /**
* Raises postdata changed event.
* This method calls {@link onValueChanged} method.
@@ -204,4 +222,3 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatabl }
}
-?> diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index b9245be3..7fea5862 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -473,4 +473,3 @@ class THtmlArea extends TTextBox }
}
-?> diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php index 3bd92ffd..217fa267 100644 --- a/framework/Web/UI/WebControls/THyperLink.php +++ b/framework/Web/UI/WebControls/THyperLink.php @@ -187,4 +187,3 @@ class THyperLink extends TWebControl implements IDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/THyperLinkColumn.php b/framework/Web/UI/WebControls/THyperLinkColumn.php index 8ac1177f..7db6eda8 100644 --- a/framework/Web/UI/WebControls/THyperLinkColumn.php +++ b/framework/Web/UI/WebControls/THyperLinkColumn.php @@ -215,4 +215,3 @@ class THyperLinkColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TImage.php b/framework/Web/UI/WebControls/TImage.php index e1ff8535..220fa4a6 100644 --- a/framework/Web/UI/WebControls/TImage.php +++ b/framework/Web/UI/WebControls/TImage.php @@ -155,4 +155,3 @@ class TImage extends TWebControl implements IDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php index 89daca44..d0cd8a0a 100644 --- a/framework/Web/UI/WebControls/TImageMap.php +++ b/framework/Web/UI/WebControls/TImageMap.php @@ -835,4 +835,3 @@ class THotSpotMode extends TEnumerable const Inactive='Inactive';
}
-?> diff --git a/framework/Web/UI/WebControls/TInlineFrame.php b/framework/Web/UI/WebControls/TInlineFrame.php index dae728d3..c47af648 100644 --- a/framework/Web/UI/WebControls/TInlineFrame.php +++ b/framework/Web/UI/WebControls/TInlineFrame.php @@ -274,4 +274,3 @@ class TInlineFrameScrollBars extends TEnumerable const Auto='Auto'; const Both='Both'; } -?> diff --git a/framework/Web/UI/WebControls/TItemDataRenderer.php b/framework/Web/UI/WebControls/TItemDataRenderer.php index a57ff27d..79e0186e 100644 --- a/framework/Web/UI/WebControls/TItemDataRenderer.php +++ b/framework/Web/UI/WebControls/TItemDataRenderer.php @@ -81,4 +81,3 @@ abstract class TItemDataRenderer extends TDataRenderer implements IItemDataRende }
}
-?> diff --git a/framework/Web/UI/WebControls/TJavascriptLogger.php b/framework/Web/UI/WebControls/TJavascriptLogger.php index 11e64735..6d49f801 100644 --- a/framework/Web/UI/WebControls/TJavascriptLogger.php +++ b/framework/Web/UI/WebControls/TJavascriptLogger.php @@ -91,4 +91,3 @@ class TJavascriptLogger extends TWebControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TKeyboard.php b/framework/Web/UI/WebControls/TKeyboard.php index 7c9357d7..9c26fab8 100644 --- a/framework/Web/UI/WebControls/TKeyboard.php +++ b/framework/Web/UI/WebControls/TKeyboard.php @@ -186,4 +186,3 @@ class TKeyboard extends TWebControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php index 3e61eddf..d1595ead 100644 --- a/framework/Web/UI/WebControls/TLabel.php +++ b/framework/Web/UI/WebControls/TLabel.php @@ -152,4 +152,3 @@ class TLabel extends TWebControl implements IDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d847f07e..459b98cf 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -332,4 +332,3 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC }
}
-?> diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index 903dbed8..1b4599fc 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -39,6 +39,7 @@ Prado::using('System.Web.UI.WebControls.TListControl'); class TListBox extends TListControl implements IPostBackDataHandler, IValidatable
{
private $_dataChanged=false;
+ private $_isValid=true; /**
* Adds attribute name-value pairs to renderer.
@@ -220,6 +221,23 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl {
return $this->getSelectedValue();
}
+ + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } }
@@ -242,4 +260,3 @@ class TListSelectionMode extends TEnumerable const Multiple='Multiple';
}
-?> diff --git a/framework/Web/UI/WebControls/TListControlValidator.php b/framework/Web/UI/WebControls/TListControlValidator.php index f468a30e..f547884f 100644 --- a/framework/Web/UI/WebControls/TListControlValidator.php +++ b/framework/Web/UI/WebControls/TListControlValidator.php @@ -223,4 +223,3 @@ class TListControlValidator extends TBaseValidator return $options;
}
}
-?> diff --git a/framework/Web/UI/WebControls/TListItem.php b/framework/Web/UI/WebControls/TListItem.php index 2017b64e..eb72d183 100644 --- a/framework/Web/UI/WebControls/TListItem.php +++ b/framework/Web/UI/WebControls/TListItem.php @@ -182,4 +182,3 @@ class TListItem extends TComponent }
}
-?> diff --git a/framework/Web/UI/WebControls/TLiteral.php b/framework/Web/UI/WebControls/TLiteral.php index 0c93043a..3a7f4581 100644 --- a/framework/Web/UI/WebControls/TLiteral.php +++ b/framework/Web/UI/WebControls/TLiteral.php @@ -110,4 +110,3 @@ class TLiteral extends TControl implements IDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/TLiteralColumn.php b/framework/Web/UI/WebControls/TLiteralColumn.php index cb97adb5..8ca87023 100644 --- a/framework/Web/UI/WebControls/TLiteralColumn.php +++ b/framework/Web/UI/WebControls/TLiteralColumn.php @@ -152,4 +152,3 @@ class TLiteralColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TMarkdown.php b/framework/Web/UI/WebControls/TMarkdown.php index dc6bc5e2..d630cd29 100644 --- a/framework/Web/UI/WebControls/TMarkdown.php +++ b/framework/Web/UI/WebControls/TMarkdown.php @@ -73,4 +73,3 @@ class TMarkdown extends TTextHighlighter }
}
-?> diff --git a/framework/Web/UI/WebControls/TMultiView.php b/framework/Web/UI/WebControls/TMultiView.php index 6adaed5b..1f87b03f 100644 --- a/framework/Web/UI/WebControls/TMultiView.php +++ b/framework/Web/UI/WebControls/TMultiView.php @@ -376,4 +376,3 @@ class TView extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php index dd38ae03..c0747a11 100644 --- a/framework/Web/UI/WebControls/TOutputCache.php +++ b/framework/Web/UI/WebControls/TOutputCache.php @@ -582,4 +582,3 @@ class TOutputCacheCalculateKeyEventParameter extends TEventParameter }
}
-?> diff --git a/framework/Web/UI/WebControls/TPager.php b/framework/Web/UI/WebControls/TPager.php index d1a5db25..51ea2a11 100644 --- a/framework/Web/UI/WebControls/TPager.php +++ b/framework/Web/UI/WebControls/TPager.php @@ -790,4 +790,3 @@ class TPagerButtonType extends TEnumerable const ImageButton='ImageButton';
}
-?> diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php index 661795d7..5bbcdcca 100644 --- a/framework/Web/UI/WebControls/TPanel.php +++ b/framework/Web/UI/WebControls/TPanel.php @@ -234,4 +234,3 @@ class TPanel extends TWebControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TPanelStyle.php b/framework/Web/UI/WebControls/TPanelStyle.php index 08667860..2d6ee824 100644 --- a/framework/Web/UI/WebControls/TPanelStyle.php +++ b/framework/Web/UI/WebControls/TPanelStyle.php @@ -276,4 +276,3 @@ class TScrollBars extends TEnumerable const Vertical='Vertical';
}
-?> diff --git a/framework/Web/UI/WebControls/TPlaceHolder.php b/framework/Web/UI/WebControls/TPlaceHolder.php index ae878e2b..cdfd3873 100644 --- a/framework/Web/UI/WebControls/TPlaceHolder.php +++ b/framework/Web/UI/WebControls/TPlaceHolder.php @@ -26,4 +26,3 @@ class TPlaceHolder extends TControl {
}
-?> diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 20973732..fdaf53a8 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -318,4 +318,3 @@ class TRadioButton extends TCheckBox }
}
-?> diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php index b225834a..a8c53dee 100644 --- a/framework/Web/UI/WebControls/TRadioButtonList.php +++ b/framework/Web/UI/WebControls/TRadioButtonList.php @@ -99,4 +99,3 @@ class TRadioButtonList extends TCheckBoxList }
}
-?> diff --git a/framework/Web/UI/WebControls/TRangeValidator.php b/framework/Web/UI/WebControls/TRangeValidator.php index 0f92fb45..d741118f 100644 --- a/framework/Web/UI/WebControls/TRangeValidator.php +++ b/framework/Web/UI/WebControls/TRangeValidator.php @@ -358,4 +358,3 @@ class TRangeValidationDataType extends TValidationDataType {
const StringLength='StringLength';
}
-?> diff --git a/framework/Web/UI/WebControls/TRatingList.php b/framework/Web/UI/WebControls/TRatingList.php index 22cc0844..aba44fb0 100644 --- a/framework/Web/UI/WebControls/TRatingList.php +++ b/framework/Web/UI/WebControls/TRatingList.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -21,191 +21,320 @@ Prado::using('System.Web.UI.WebControls.TRadioButtonList'); * This class is EXPERIMENTAL.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.WebControls
* @since 3.0
*/
class TRatingList extends TRadioButtonList
{
+ /**
+ * Script path relative to the TClientScriptManager::SCRIPT_PATH
+ */
const SCRIPT_PATH='prado/ratings';
+ /**
+ * @var array list of published rating images.
+ */
private $_ratingImages = array();
+ /**
+ * Sets the default repeat direction to horizontal.
+ */
public function __construct()
{
parent::__construct();
- $this->getRepeatInfo()->setRepeatDirection('Horizontal');
+ $this->setRepeatDirection(TRepeatDirection::Horizontal);
}
+ /**
+ * @return boolean whether the items in the column can be edited. Defaults to false.
+ */
+ public function getReadOnly()
+ {
+ return $this->getViewState('ReadOnly',false);
+ }
+
+ /**
+ * @param boolean whether the items in the column can be edited
+ */
+ public function setReadOnly($value)
+ {
+ $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false);
+ }
+
+ /**
+ * Wrapper for {@link setReadOnly ReadOnly} property.
+ * @return boolean whether the rating list can be edited. Defaults to true.
+ */
public function getAllowInput()
{
- return $this->getViewState('AllowInput', true);
+ return !$this->getReadOnly();
}
+ /**
+ * Wrapper for {@link setReadOnly ReadOnly} property.
+ * @param boolean whether the rating list can be edited
+ */
public function setAllowInput($value)
{
- $this->setViewState('AllowInput', TPropertyValue::ensureBoolean($value), true);
+ $this->setReadOnly(!TPropertyValue::ensureBoolean($value));
}
- public function getRating()
+ /**
+ * Wrapper for {@link setReadOnly ReadOnly} property.
+ * @param boolean whether the rating list can be edited
+ */
+ public function setEnabled($value)
{
- if($this->getAllowInput())
- return $this->getSelectedIndex();
- else
- return $this->getViewState('Rating',0);
+ $this->setReadOnly(!TPropertyValue::ensureBoolean($value));
}
- public function setRating($value)
+ /**
+ * The repeat layout must be Table.
+ * @param string repeat layout type
+ * @throws TInvaliddataValueException when repeat layout is not Table.
+ */
+ public function setRepeatLayout($value)
{
- if($this->getAllowInput())
- $this->setSelectedIndex($value);
+ if($value!==TRepeatLayout::Table)
+ throw new TInvalidDataValueException('ratinglist_table_layout_only');
else
- $this->setViewState('Rating', TPropertyValue::ensureFloat($value),0);
+ parent::setRepeatLayout($value);
}
/**
- * @param string set the rating style
+ * @return float rating value.
*/
- public function setRatingStyle($value)
+ public function getRating()
{
- $this->setViewState('RatingStyle', $value, 'default');
+ $rating = $this->getViewState('Rating', null);
+ if ($rating === null)
+ return $this->getSelectedIndex()+1;
+ else
+ return $rating;
}
/**
- * @return TRatingListStyle current rating style
+ * @param float rating value, also sets the selected Index
*/
- public function getRatingStyle()
+ public function setRating($value)
{
- return $this->getViewState('RatingStyle', 'default');
+ $value = TPropertyValue::ensureFloat($value);
+ $this->setViewState('Rating', $value, null);
+ $index = $this->getRatingIndex($value);
+ parent::setSelectedIndex($index);
+ }
+
+ public function setSelectedIndex($value)
+ {
+ $this->setRating($value+1);
+ parent::setSelectedIndex($value);
}
/**
- * @return string caption text. Default is "Rate It:".
+ * @param float rating value
+ * @return int rating as integer
*/
- public function getCaption()
+ protected function getRatingIndex($rating)
{
- return $this->getViewState('Caption', 'Rate It:');
+ $interval = $this->getHalfRatingInterval();
+ $base = intval($rating)-1;
+ $remainder = $rating-$base-1;
+ return $remainder > $interval[1] ? $base+1 : $base;
}
/**
- * @param string caption text
+ * @param int change the rating selection index
*/
- public function setCaption($value)
+ public function onSelectedIndexChanged($param)
{
- $this->setViewState('Caption', $value, 'Rate It:');
+ $value = $this->getRating();
+ $value = TPropertyValue::ensureInteger($value);
+ $this->setRating($value);
+ parent::onSelectedIndexChanged($param);
}
+ /**
+ * @return string control or html element ID for displaying a caption.
+ */
+ public function getCaptionID()
+ {
+ return $this->getViewState('CaptionID', '');
+ }
- public function setHalfRatingLimit($value)
+ /**
+ * @param string control or html element ID for displaying a caption.
+ */
+ public function setCaptionID($value)
{
- $this->setViewState('HalfRating',
- TPropertyValue::ensureArray($value), array(0.3, 0.7));
+ $this->setViewState('CaptionID', $value, '');
}
- public function getHalfRatingLimit()
+ protected function getCaptionControl()
{
- return $this->getViewState('HalfRating', array(0.3, 0.7));
+ if(($id=$this->getCaptionID())!=='')
+ {
+ if($control=$this->getParent()->findControl($id))
+ return $control;
+ }
+ throw new TInvalidDataValueException(
+ 'ratinglist_invalid_caption_id',$id,$this->getID());
}
/**
- * @param string asset file in the self::SCRIPT_PATH directory.
- * @return string asset file url.
+ * @return string caption text. Default is "Rate It:".
*/
- protected function getAssetUrl($file='')
+ public function getCaption()
{
- $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl();
- return $base.'/'.self::SCRIPT_PATH.'/'.$file;
+ return $this->getCaptionControl()->getText();
}
- public function getRatingClientOptions()
- {
- $options['cssClass'] = 'TRatingList_'.$this->getRatingStyle();
- $options['ID'] = $this->getClientID();
- $options['caption'] = $this->getCaption();
- $options['field'] = $this->getUniqueID();
- $options['selectedIndex'] = $this->getSelectedIndex();
+ /**
+ * @return TRatingListStyle current rating style
+ */
+ public function setCaption($value)
+ {
+ $this->getCaptionControl()->setText($value);
+ }
+
+ /**
+ * @param string set the rating style, default is "default"
+ */
+ public function setRatingStyle($value)
+ {
+ $this->setViewState('RatingStyle', $value, 'default');
+ }
+
+ /**
+ * @return TRatingListStyle current rating style
+ */
+ public function getRatingStyle()
+ {
+ return $this->getViewState('RatingStyle', 'default');
+ }
+
+ /**
+ * @return string rating style css class name.
+ */
+ protected function getRatingStyleCssClass()
+ {
+ return 'TRatingList_'.$this->getRatingStyle();
+ }
+
+ /**
+ * Sets the interval such that those rating values within the interval
+ * will be considered as a half star rating.
+ * @param array rating display half value interval, default is array(0.3, 0.7);
+ */
+ public function setHalfRatingInterval($value)
+ {
+ $this->setViewState('HalfRating',
+ TPropertyValue::ensureArray($value), array(0.3, 0.7));
+ }
+
+ /**
+ * @return array rating display half value interval, default is array(0.3, 0.7);
+ */
+ public function getHalfRatingInterval()
+ {
+ return $this->getViewState('HalfRating', array(0.3, 0.7));
+ }
+
+ /**
+ * @return array list of post back options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = parent::getPostBackOptions();
+ $options['AutoPostBack'] = $this->getAutoPostBack();
+ $options['ReadOnly'] = $this->getReadOnly();
+ $options['Style'] = $this->getRatingStyleCssClass();
+ $options['CaptionID'] = $this->getCaptionControlID();
+ $options['SelectedIndex'] = $this->getSelectedIndex();
+ $options['Rating'] = $this->getRating();
+ $options['HalfRating'] = $this->getHalfRatingInterval();
return $options;
- }
+ }
- protected function publishRatingListStyle($style)
- {
+ /**
+ * @return string find the client ID of the caption control.
+ */
+ protected function getCaptionControlID()
+ {
+ if(($id=$this->getCaptionID())!=='')
+ {
+ if($control=$this->getParent()->findControl($id))
+ {
+ if($control->getVisible(true))
+ return $control->getClientID();
+ }
+ else
+ return $id;
+ }
+ return '';
+ }
+
+ /**
+ * Publish the the rating style css file and rating image files.
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+ $this->publishStyle($this->getRatingStyle());
+ $this->_ratingImages = $this->publishImages($this->getRatingStyle());
+ }
+
+ /**
+ * @param string rating style name
+ * @return string URL of the css style file
+ */
+ protected function publishStyle($style)
+ {
$cs = $this->getPage()->getClientScript();
$url = $this->getAssetUrl($style.'.css');
if(!$cs->isStyleSheetFileRegistered($url))
$cs->registerStyleSheetFile($url, $url);
return $url;
- }
+ }
- protected function publishRatingListImages($style, $fileExt='.gif')
- {
- $images = array('blank', 'hover', 'selected', 'half');
+ /**
+ * @param string rating style name
+ * @param string rating image file extension, default is '.gif'
+ * @return array URL of publish the rating images
+ */
+ protected function publishImages($style, $fileExt='.gif')
+ {
+ $types = array('blank', 'selected', 'half', 'combined');
$files = array();
- foreach($images as $type)
+ foreach($types as $type)
$files[$type] = $this->getAssetUrl("{$style}_{$type}{$fileExt}");
return $files;
- }
+ }
/**
- * @param THtmlWriter writer
+ * @param string asset file in the self::SCRIPT_PATH directory.
+ * @return string asset file url.
*/
- public function onPreRender($param)
- {
- parent::onPreRender($param);
-
- $this->publishRatingListStyle($this->getRatingStyle());
- $this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle());
-
- if($this->getAllowInput())
- $this->registerRatingListClientScript();
- else
- {
- $this->getRepeatInfo()->setCaption($this->getCaption());
- $this->setAttribute('title', $this->getRating());
- }
- }
-
- protected function registerRatingListClientScript()
- {
- $id = $this->getClientID();
- $scripts = $this->getPage()->getClientScript();
- $scripts->registerPradoScript('prado');
- $options = TJavaScript::encode($this->getRatingClientOptions());
- $code = "new Prado.WebUI.TRatingList($options);";
- $scripts->registerEndScript("prado:$id", $code);
- }
-
- public function renderItem($writer,$repeatInfo,$itemType,$index)
- {
- if($this->getAllowInput())
- parent::renderItem($writer, $repeatInfo, $itemType, $index);
- else
- $this->renderRatingListItem($writer, $repeatInfo, $itemType, $index);
- }
-
- protected function renderRatingListItem($writer, $repeatInfo, $itemType, $index)
- {
- $image = new TImage;
- $image->setImageUrl($this->_ratingImages[$this->getRatingImageType($index)]);
- $image->setAlternateText($this->getRating());
- $image->render($writer);
- }
-
- protected function getRatingImageType($index)
- {
- $rating = floatval($this->getRating());
- $int = intval($rating);
- $limit = $this->getHalfRatingLimit();
- if($index < $int || ($rating < $index + 1 && $rating > $index +$limit[1]))
- return 'selected';
- if($rating >= $index+$limit[0] && $rating <= $index+$limit[1])
- return 'half';
- return 'blank';
- }
+ protected function getAssetUrl($file='')
+ {
+ $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl();
+ return $base.'/'.self::SCRIPT_PATH.'/'.$file;
+ }
- public function generateItemStyle($itemType,$index)
- {
- return new TStyle;
- }
+ /**
+ * Add rating style class name to the class attribute
+ * when {@link setReadOnly ReadOnly} property is true and when the
+ * {@link setCssClass CssClass} property is empty.
+ * @param THtmlWriter renderer
+ */
+ public function render($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getPage()->getClientScript()->registerPostBackControl(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ parent::render($writer);
+ }
/**
* Gets the name of the javascript class responsible for performing postback for this control.
@@ -218,4 +347,3 @@ class TRatingList extends TRadioButtonList }
}
-?> diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index f0c645a4..be861e45 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -96,7 +96,7 @@ class TRegularExpressionValidator extends TBaseValidator }
/**
- * @param string pattern modifiers,
+ * @param string pattern modifiers for server side validation,
* see http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
*/
public function setPatternModifiers($value)
@@ -113,6 +113,23 @@ class TRegularExpressionValidator extends TBaseValidator }
/**
+ * @param string pattern modifiers for clientside.
+ * (Only 'g','i' and 'm' are available.)
+ */
+ public function setClientSidePatternModifiers($value)
+ {
+ $this->setViewState('ClientSidePatternModifiers', $value);
+ }
+
+ /**
+ * @return string clientside pattern modifiers, no modifiers by default.
+ */
+ public function getClientSidePatternModifiers()
+ {
+ return $this->getViewState('ClientSidePatternModifiers', '');
+ }
+
+ /**
* Returns an array of javascript validator options.
* @return array javascript validator options.
*/
@@ -120,8 +137,8 @@ class TRegularExpressionValidator extends TBaseValidator {
$options = parent::getClientScriptOptions();
$options['ValidationExpression']=$this->getRegularExpression();
+ $options['PatternModifiers']=$this->getClientSidePatternModifiers();
return $options;
}
}
-?> diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php index ecf0ebf7..30c85f14 100644 --- a/framework/Web/UI/WebControls/TRepeatInfo.php +++ b/framework/Web/UI/WebControls/TRepeatInfo.php @@ -558,4 +558,3 @@ class TRepeatLayout extends TEnumerable const Raw='Raw';
}
-?> diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php index 6b9c08c1..a6c9903d 100644 --- a/framework/Web/UI/WebControls/TRepeater.php +++ b/framework/Web/UI/WebControls/TRepeater.php @@ -1023,4 +1023,3 @@ class TRepeaterItemCollection extends TList }
}
-?> diff --git a/framework/Web/UI/WebControls/TRepeaterItemRenderer.php b/framework/Web/UI/WebControls/TRepeaterItemRenderer.php index d99da302..79ff9087 100644 --- a/framework/Web/UI/WebControls/TRepeaterItemRenderer.php +++ b/framework/Web/UI/WebControls/TRepeaterItemRenderer.php @@ -48,4 +48,3 @@ class TRepeaterItemRenderer extends TItemDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php index 8d0eaec2..e6ddd6d3 100644 --- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php +++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php @@ -136,4 +136,3 @@ class TRequiredFieldValidator extends TBaseValidator }
}
-?> diff --git a/framework/Web/UI/WebControls/TSafeHtml.php b/framework/Web/UI/WebControls/TSafeHtml.php index 0f4de2cb..d6829f8b 100644 --- a/framework/Web/UI/WebControls/TSafeHtml.php +++ b/framework/Web/UI/WebControls/TSafeHtml.php @@ -62,4 +62,3 @@ class TSafeHtml extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TSlider.php b/framework/Web/UI/WebControls/TSlider.php index 3fd8e244..ee725e99 100644 --- a/framework/Web/UI/WebControls/TSlider.php +++ b/framework/Web/UI/WebControls/TSlider.php @@ -4,7 +4,7 @@ *
* @author Christophe Boulain <Christophe.Boulain@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -218,7 +218,7 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer public function setValues($value)
{
$this->setViewState('Values', TPropertyValue::ensureArray($value), array());
- } + }
/**
* @return boolean a value indicating whether an automatic postback to the server
@@ -488,7 +488,7 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer // Add max if it's not in the array because of step
if (!in_array($maxValue, $values)) $values[]=$maxValue;
}
- $options['values'] = TJavascript::Encode($values,false);
+ $options['values'] = TJavaScript::Encode($values,false);
if($this->_clientScript!==null)
$options = array_merge($options,$this->_clientScript->getOptions()->toArray());
return $options;
@@ -572,4 +572,3 @@ class TSliderDirection extends TEnumerable }
-?> diff --git a/framework/Web/UI/WebControls/TStatements.php b/framework/Web/UI/WebControls/TStatements.php index 09c03cb9..d07e68a1 100644 --- a/framework/Web/UI/WebControls/TStatements.php +++ b/framework/Web/UI/WebControls/TStatements.php @@ -61,4 +61,3 @@ class TStatements extends TControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index c81a6db9..7cb1d8c8 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -891,4 +891,3 @@ class TTableGridLines extends TEnumerable const Both='Both';
}
-?> diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index 9fa9130d..57efa7f7 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -408,4 +408,3 @@ class TTableCaptionAlign extends TEnumerable const Right='Right';
}
-?> diff --git a/framework/Web/UI/WebControls/TTableCell.php b/framework/Web/UI/WebControls/TTableCell.php index 10d4f457..8bc83c52 100644 --- a/framework/Web/UI/WebControls/TTableCell.php +++ b/framework/Web/UI/WebControls/TTableCell.php @@ -220,4 +220,3 @@ class TTableCell extends TWebControl implements IDataRenderer }
}
-?> diff --git a/framework/Web/UI/WebControls/TTableFooterRow.php b/framework/Web/UI/WebControls/TTableFooterRow.php index f3c35dc3..dd0de143 100644 --- a/framework/Web/UI/WebControls/TTableFooterRow.php +++ b/framework/Web/UI/WebControls/TTableFooterRow.php @@ -45,4 +45,3 @@ class TTableFooterRow extends TTableRow }
}
-?> diff --git a/framework/Web/UI/WebControls/TTableHeaderCell.php b/framework/Web/UI/WebControls/TTableHeaderCell.php index a1a8919a..1e18cee3 100644 --- a/framework/Web/UI/WebControls/TTableHeaderCell.php +++ b/framework/Web/UI/WebControls/TTableHeaderCell.php @@ -122,4 +122,3 @@ class TTableHeaderScope extends TEnumerable const Column='Column';
}
-?> diff --git a/framework/Web/UI/WebControls/TTableHeaderRow.php b/framework/Web/UI/WebControls/TTableHeaderRow.php index fa7e4515..7b8488bd 100644 --- a/framework/Web/UI/WebControls/TTableHeaderRow.php +++ b/framework/Web/UI/WebControls/TTableHeaderRow.php @@ -45,4 +45,3 @@ class TTableHeaderRow extends TTableRow }
}
-?> diff --git a/framework/Web/UI/WebControls/TTableRow.php b/framework/Web/UI/WebControls/TTableRow.php index be93529e..c70f28dd 100644 --- a/framework/Web/UI/WebControls/TTableRow.php +++ b/framework/Web/UI/WebControls/TTableRow.php @@ -206,4 +206,3 @@ class TTableRowSection extends TEnumerable const Footer='Footer';
}
-?> diff --git a/framework/Web/UI/WebControls/TTemplateColumn.php b/framework/Web/UI/WebControls/TTemplateColumn.php index de4bc2ef..21190f23 100644 --- a/framework/Web/UI/WebControls/TTemplateColumn.php +++ b/framework/Web/UI/WebControls/TTemplateColumn.php @@ -254,4 +254,3 @@ class TTemplateColumn extends TDataGridColumn }
}
-?> diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index 3c3e6d0e..4e6a66e9 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -67,6 +67,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable */
private $_safeText;
private $_dataChanged=false;
+ private $_isValid=true; /**
* @return string tag name of the textbox
@@ -243,6 +244,23 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable return $this->getText();
}
+ /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /**
* Raises <b>OnTextChanged</b> event.
* This method is invoked when the value of the {@link getText Text}
@@ -618,4 +636,3 @@ class TTextBoxAutoCompleteType extends TEnumerable const Search='Search';
}
-?> diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php index 0356c4e7..890deb05 100644 --- a/framework/Web/UI/WebControls/TTextHighlighter.php +++ b/framework/Web/UI/WebControls/TTextHighlighter.php @@ -198,4 +198,3 @@ class TTextHighlighterLineNumberStyle extends TEnumerable const Li='Li'; const Table='Table'; }
-?> diff --git a/framework/Web/UI/WebControls/TTextProcessor.php b/framework/Web/UI/WebControls/TTextProcessor.php index ccb78196..26dab754 100644 --- a/framework/Web/UI/WebControls/TTextProcessor.php +++ b/framework/Web/UI/WebControls/TTextProcessor.php @@ -84,4 +84,3 @@ abstract class TTextProcessor extends TWebControl }
}
-?> diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index 4e0e0e50..95679e15 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -504,4 +504,3 @@ class TValidationSummaryDisplayStyle extends TEnumerable const Fixed='Fixed';
}
-?> diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index 829a9d03..2e1899ad 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -432,4 +432,3 @@ class TWebControl extends TControl implements IStyleable }
}
-?> diff --git a/framework/Web/UI/WebControls/TWebControlAdapter.php b/framework/Web/UI/WebControls/TWebControlAdapter.php index 35e157af..a99afe7f 100644 --- a/framework/Web/UI/WebControls/TWebControlAdapter.php +++ b/framework/Web/UI/WebControls/TWebControlAdapter.php @@ -69,4 +69,3 @@ class TWebControlAdapter extends TControlAdapter }
}
-?> diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php index 1f9e886b..774096f7 100644 --- a/framework/Web/UI/WebControls/TWizard.php +++ b/framework/Web/UI/WebControls/TWizard.php @@ -2153,4 +2153,3 @@ class TWizardStepType extends TEnumerable const Finish='Finish';
}
-?> diff --git a/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php b/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php index 6eebce74..54d585c4 100644 --- a/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php +++ b/framework/Web/UI/WebControls/TWizardNavigationButtonStyle.php @@ -153,4 +153,3 @@ class TWizardNavigationButtonStyle extends TStyle }
}
-?> diff --git a/framework/Web/UI/WebControls/TXmlTransform.php b/framework/Web/UI/WebControls/TXmlTransform.php index ab49ae61..991aed39 100644 --- a/framework/Web/UI/WebControls/TXmlTransform.php +++ b/framework/Web/UI/WebControls/TXmlTransform.php @@ -191,4 +191,3 @@ class TXmlTransform extends TControl { } } -?> diff --git a/framework/Web/UI/WebControls/assets/captcha.php b/framework/Web/UI/WebControls/assets/captcha.php index bff2f61a..8c9ff0a3 100644 --- a/framework/Web/UI/WebControls/assets/captcha.php +++ b/framework/Web/UI/WebControls/assets/captcha.php @@ -221,4 +221,3 @@ function morphImage($image,$width,$height) }
}
-?> diff --git a/framework/Xml/TXmlDocument.php b/framework/Xml/TXmlDocument.php index 9325c62a..d7ddf187 100644 --- a/framework/Xml/TXmlDocument.php +++ b/framework/Xml/TXmlDocument.php @@ -547,4 +547,3 @@ class TXmlElementList extends TList } } -?> diff --git a/framework/interfaces.php b/framework/interfaces.php index 634a6e51..2012dff7 100644 --- a/framework/interfaces.php +++ b/framework/interfaces.php @@ -379,4 +379,3 @@ interface IDataRenderer */
public function setData($value);
}
-?> diff --git a/framework/prado.php b/framework/prado.php index 4690617c..3777f763 100644 --- a/framework/prado.php +++ b/framework/prado.php @@ -56,4 +56,3 @@ require_once(dirname(__FILE__).'/TApplication.php'); */
require_once(dirname(__FILE__).'/TShellApplication.php');
-?> |