# HG changeset patch # User ymh # Date 1254754686 -7200 # Node ID d17aa71a58e0176d90ad8c320e80cbb39589c300 # Parent 42c8da096ceba37a8c265e033eebbdda0076d769 finish project configuration diff -r 42c8da096ceb -r d17aa71a58e0 .hgignore --- a/.hgignore Mon Oct 05 16:05:28 2009 +0200 +++ b/.hgignore Mon Oct 05 16:58:06 2009 +0200 @@ -1,6 +1,11 @@ syntax: regexp ^web/tagging/xxy\.f4v$ +^web/thdProject/cache/.*$ +^web/thdProject/cache$ +^web/thdProject/web/phpinfo.php$ +^web/thdProject/log/.*$ syntax: glob .DS_Store +*.swp diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/config/ProjectConfiguration.class.php --- a/web/thdProject/config/ProjectConfiguration.class.php Mon Oct 05 16:05:28 2009 +0200 +++ b/web/thdProject/config/ProjectConfiguration.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -7,7 +7,7 @@ define('SF_ENVIRONMENT', 'dev'); -require_once '/Users/gautierthibault/SRV/symfony-1.2.8/lib/autoload/sfCoreAutoload.class.php'; +require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/config/databases.yml --- a/web/thdProject/config/databases.yml Mon Oct 05 16:05:28 2009 +0200 +++ b/web/thdProject/config/databases.yml Mon Oct 05 16:58:06 2009 +0200 @@ -2,6 +2,6 @@ doctrine: class: sfDoctrineDatabase param: - dsn: mysql:host=localhost;dbname=thd - username: thd - password: helsinki + dsn: 'mysql:host=localhost;dbname=thd' + username: root + password: null diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/config/propel.ini --- a/web/thdProject/config/propel.ini Mon Oct 05 16:05:28 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -propel.targetPackage = lib.model -propel.packageObjectModel = true -propel.project = thd -propel.database = mysql -propel.database.driver = mysql -propel.database.url = mysql:dbname=thd;host=localhost -propel.database.creole.url = ${propel.database.url} -propel.database.user = root -propel.database.password = -propel.database.encoding = utf8 - -; mysql options -propel.mysql.tableType = InnoDB - -propel.addVendorInfo = true -propel.addGenericAccessors = true -propel.addGenericMutators = true -propel.addTimeStamp = true -propel.addValidators = false - -propel.useDateTimeClass = true -propel.defaultTimeStampFormat = Y-m-d H:i:s -propel.defaultTimeFormat = H:i:s -propel.defaultDateFormat = Y-m-d - -propel.schema.validate = false -propel.samePhpName = false -propel.disableIdentifierQuoting = false -propel.emulateForeignKeyConstraints = true - -; directories -propel.home = . -propel.output.dir = /Users/gautierthibault/Sites/thd -propel.schema.dir = ${propel.output.dir}/config -propel.conf.dir = ${propel.output.dir}/config -propel.phpconf.dir = ${propel.output.dir}/config -propel.sql.dir = ${propel.output.dir}/data/sql -propel.runtime.conf.file = runtime-conf.xml -propel.php.dir = ${propel.output.dir} -propel.default.schema.basename = schema -propel.datadump.mapper.from = *schema.xml -propel.datadump.mapper.to = *data.xml - -; builder settings -propel.builder.peer.class = plugins.sfPropelPlugin.lib.builder.SfPeerBuilder -propel.builder.object.class = plugins.sfPropelPlugin.lib.builder.SfObjectBuilder -propel.builder.objectstub.class = plugins.sfPropelPlugin.lib.builder.SfExtensionObjectBuilder -propel.builder.peerstub.class = plugins.sfPropelPlugin.lib.builder.SfExtensionPeerBuilder -propel.builder.objectmultiextend.class = plugins.sfPropelPlugin.lib.builder.SfMultiExtendObjectBuilder -propel.builder.mapbuilder.class = plugins.sfPropelPlugin.lib.builder.SfMapBuilderBuilder - -propel.builder.addIncludes = false -propel.builder.addComments = true -propel.builder.addBehaviors = true diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/config/schema.yml diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/log/.keepme diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/LICENSE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/LICENSE Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,7 @@ +Copyright (c) 2006-2008 Jonathan H. Wage + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/config/autoload.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/config/autoload.yml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,6 @@ +autoload: + sfDoctrinePlugin_lib: + name: sfDoctrinePlugin lib + path: %SF_SYMFONY_LIB_DIR%/plugins/sfDoctrinePlugin/lib + recursive: true + exclude: [doctrine] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/config/config.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/config/config.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,31 @@ +dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelDoctrine', 'listenToAddPanelEvent')); +} + +require_once sfConfig::get('sfDoctrinePlugin_doctrine_lib_path', dirname(__FILE__).'/../lib/vendor/doctrine/Doctrine.php'); +spl_autoload_register(array('Doctrine', 'autoload')); + +$manager = Doctrine_Manager::getInstance(); +$manager->setAttribute('export', 'all'); +$manager->setAttribute('validate', 'all'); +$manager->setAttribute('recursive_merge_fixtures', true); +$manager->setAttribute('auto_accessor_override', true); +$manager->setAttribute('autoload_table_classes', true); + +$configuration = sfProjectConfiguration::getActive(); + +if (method_exists($configuration, 'configureDoctrine')) +{ + $configuration->configureDoctrine($manager); +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/config/sfDoctrinePluginConfiguration.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/config/sfDoctrinePluginConfiguration.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrinePluginConfiguration Class + * + * @package symfony + * @subpackage doctrine + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineConnectionListener.class.php 11878 2008-09-30 20:14:40Z Jonathan.Wage $ + */ +class sfDoctrinePluginConfiguration extends sfPluginConfiguration +{ + public function initialize() + { + require_once dirname(__FILE__) . '/config.php'; + + return true; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormBaseTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormBaseTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,14 @@ +[?php + +/** + * Project form base class. + * + * @package form + * @version SVN: $Id: sfDoctrineFormBaseTemplate.php 6174 2007-11-27 06:22:40Z fabien $ + */ +abstract class BaseFormDoctrine extends sfFormDoctrine +{ + public function setup() + { + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormGeneratedTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormGeneratedTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,123 @@ +[?php + +/** + * modelName ?> form base class. + * + * @package form + * @subpackage underscore($this->modelName) ?> + + * @version SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $ + */ +class BasemodelName ?>Form extends BaseFormDoctrine +{ + public function setup() + { + $this->setWidgets(array( +getColumns() as $column): ?> + 'getFieldName() ?>'getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => new getWidgetClassForColumn($column) ?>(getWidgetOptionsForColumn($column) ?>), + +getManyToManyRelations() as $relation): ?> + 'underscore($relation['alias']) ?>_list'getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => new sfWidgetFormDoctrineChoiceMany(array('model' => 'getOption('name') ?>')), + + )); + + $this->setValidators(array( +getColumns() as $column): ?> + 'getFieldName() ?>'getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => new getValidatorClassForColumn($column) ?>(getValidatorOptionsForColumn($column) ?>), + +getManyToManyRelations() as $relation): ?> + 'underscore($relation['alias']) ?>_list'getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => new sfValidatorDoctrineChoiceMany(array('model' => 'getOption('name') ?>', 'required' => false)), + + )); + +getUniqueColumnNames()): ?> + $this->validatorSchema->setPostValidator( + 1): ?> + new sfValidatorAnd(array( + + new sfValidatorDoctrineUnique(array('model' => 'table->getOption('name') ?>', 'column' => array(''))), + + )) + + new sfValidatorDoctrineUnique(array('model' => 'table->getOption('name') ?>', 'column' => array(''))) + + ); + + + $this->widgetSchema->setNameFormat('underscore($this->modelName) ?>[%s]'); + + $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); + + parent::setup(); + } + + public function getModelName() + { + return 'modelName ?>'; + } + +getManyToManyRelations()): ?> + public function updateDefaultsFromObject() + { + parent::updateDefaultsFromObject(); + +getManyToManyRelations() as $relation): ?> + if (isset($this->widgetSchema['underscore($relation['alias']) ?>_list'])) + { + $this->setDefault('underscore($relation['alias']) ?>_list', $this->object->->getPrimaryKeys()); + } + + + } + + protected function doSave($con = null) + { + parent::doSave($con); + +getManyToManyRelations() as $relation): ?> + $this->saveList($con); + + } + +getManyToManyRelations() as $relation): ?> + public function saveList($con = null) + { + if (!$this->isValid()) + { + throw $this->getErrorSchema(); + } + + if (!isset($this->widgetSchema['underscore($relation['alias']) ?>_list'])) + { + // somebody has unset this widget + return; + } + + if (is_null($con)) + { + $con = $this->getConnection(); + } + + $existing = $this->object->->getPrimaryKeys(); + $values = $this->getValue('underscore($relation['alias']) ?>_list'); + if (!is_array($values)) + { + $values = array(); + } + + $unlink = array_diff($existing, $values); + if (count($unlink)) + { + $this->object->unlink('', array_values($unlink)); + } + + $link = array_diff($values, $existing); + if (count($link)) + { + $this->object->link('', array_values($link)); + } + } + + + +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormPluginTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormPluginTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,13 @@ +[?php + +/** + * Plugintable->getOption('name') ?> form. + * + * @package form + * @subpackage table->getOption('name') ?> + + * @version SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ + */ +abstract class Plugintable->getOption('name') ?>Form extends Basetable->getOption('name') ?>Form +{ +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrineFormTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,16 @@ +[?php + +/** + * table->getOption('name') ?> form. + * + * @package form + * @subpackage table->getOption('name') ?> + + * @version SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ + */ +class table->getOption('name') ?>Form extends Basetable->getOption('name') ?>Form +{ + public function configure() + { + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrinePluginFormTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineForm/default/template/sfDoctrinePluginFormTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,16 @@ +[?php + +/** + * table->getOption('name') ?> form. + * + * @package form + * @subpackage table->getOption('name') ?> + + * @version SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ + */ +class table->getOption('name') ?>Form extends Plugintable->getOption('name') ?>Form +{ + public function configure() + { + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterBaseTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterBaseTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,15 @@ +[?php + +/** + * Project filter form base class. + * + * @package filters + * + * @version SVN: $Id: sfDoctrineFormFilterBaseTemplate.php 11675 2008-09-19 15:21:38Z fabien $ + */ +abstract class BaseFormFilterDoctrine extends sfFormFilterDoctrine +{ + public function setup() + { + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterGeneratedTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterGeneratedTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,78 @@ +[?php + +require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php'); + +/** + * table->getOption('name') ?> filter form base class. + * + * @package filters + * @subpackage table->getOption('name') ?> + * + * @version SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $ + */ +class Basetable->getOption('name') ?>FormFilter extends BaseFormFilterDoctrine +{ + public function setup() + { + $this->setWidgets(array( +getColumns() as $column): ?> +isPrimaryKey()) continue ?> + 'getFieldName() ?>'getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => new getWidgetClassForColumn($column) ?>(getWidgetOptionsForColumn($column) ?>), + +getManyToManyRelations() as $relation): ?> + 'underscore($relation['alias']) ?>_list'getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => new sfWidgetFormDoctrineChoiceMany(array('model' => 'getOption('name') ?>')), + + )); + + $this->setValidators(array( +getColumns() as $column): ?> +isPrimaryKey()) continue ?> + 'getFieldName() ?>'getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => getValidatorForColumn($column) ?>, + +getManyToManyRelations() as $relation): ?> + 'underscore($relation['alias']) ?>_list'getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => new sfValidatorDoctrineChoiceMany(array('model' => 'getOption('name') ?>', 'required' => false)), + + )); + + $this->widgetSchema->setNameFormat('underscore($this->modelName) ?>_filters[%s]'); + + $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); + + parent::setup(); + } + +getManyToManyRelations() as $relation): ?> + public function addListColumnQuery(Doctrine_Query $query, $field, $values) + { + if (!is_array($values)) + { + $values = array($values); + } + + if (!count($values)) + { + return; + } + + $query->leftJoin('r.getOption('name') ?> getOption('name') ?>') + ->andWhereIn('getOption('name') ?>.getForeignFieldName() ?>', $values); + } + + + public function getModelName() + { + return 'modelName ?>'; + } + + public function getFields() + { + return array( +getColumns() as $column): ?> + 'getFieldName() ?>'getColumnNameMaxLength() - strlen($column->getFieldName())) ?> => 'getType($column) ?>', + +getManyToManyRelations() as $relation): ?> + 'underscore($relation['alias']) ?>_list'getColumnNameMaxLength() - strlen($this->underscore($relation['alias']).'_list')) ?> => 'ManyKey', + + ); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterPluginTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterPluginTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,13 @@ +[?php + +/** + * Plugintable->getOption('name') ?> form. + * + * @package filters + * @subpackage table->getOption('name') ?> + * + * @version SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $ + */ +abstract class Plugintable->getOption('name') ?>FormFilter extends Basetable->getOption('name') ?>FormFilter +{ +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrineFormFilterTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,16 @@ +[?php + +/** + * table->getOption('name') ?> filter form. + * + * @package filters + * @subpackage table->getOption('name') ?> + * + * @version SVN: $Id: sfDoctrineFormFilterTemplate.php 11675 2008-09-19 15:21:38Z fabien $ + */ +class table->getOption('name') ?>FormFilter extends Basetable->getOption('name') ?>FormFilter +{ + public function configure() + { + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrinePluginFormFilterTemplate.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineFormFilter/default/template/sfDoctrinePluginFormFilterTemplate.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,16 @@ +[?php + +/** + * table->getOption('name') ?> filter form. + * + * @package filters + * @subpackage table->getOption('name') ?> + * + * @version SVN: $Id: sfDoctrineFormFilterTemplate.php 11675 2008-09-19 15:21:38Z fabien $ + */ +class table->getOption('name') ?>FormFilter extends Plugintable->getOption('name') ?>FormFilter +{ + public function configure() + { + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/actionsConfiguration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/actionsConfiguration.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,51 @@ + public function getCredentials($action) + { + if (0 === strpos($action, '_')) + { + $action = substr($action, 1); + } + + return isset($this->configuration['credentials'][$action]) ? $this->configuration['credentials'][$action] : array(); + } + + public function getActionsDefault() + { + return asPhp(isset($this->config['actions']) ? $this->config['actions'] : array()) ?>; +config['actions']) ?> + } + + public function getFormActions() + { + return asPhp(isset($this->config['form']['actions']) ? $this->config['form']['actions'] : array('_delete' => null, '_list' => null, '_save' => null, '_save_and_add' => null)) ?>; +config['form']['actions']) ?> + } + + public function getNewActions() + { + return asPhp(isset($this->config['new']['actions']) ? $this->config['new']['actions'] : array()) ?>; +config['new']['actions']) ?> + } + + public function getEditActions() + { + return asPhp(isset($this->config['edit']['actions']) ? $this->config['edit']['actions'] : array()) ?>; +config['edit']['actions']) ?> + } + + public function getListObjectActions() + { + return asPhp(isset($this->config['list']['object_actions']) ? $this->config['list']['object_actions'] : array('_edit' => null, '_delete' => null)) ?>; +config['list']['object_actions']) ?> + } + + public function getListActions() + { + return asPhp(isset($this->config['list']['actions']) ? $this->config['list']['actions'] : array('_new' => null)) ?>; +config['list']['actions']) ?> + } + + public function getListBatchActions() + { + return asPhp(isset($this->config['list']['batch_actions']) ? $this->config['list']['batch_actions'] : array('_delete' => null)) ?>; +config['list']['batch_actions']) ?> + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/batchAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/batchAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,66 @@ + public function executeBatch(sfWebRequest $request) + { + $request->checkCSRFProtection(); + + if (!$ids = $request->getParameter('ids')) + { + $this->getUser()->setFlash('error', 'You must at least select one item.'); + + $this->redirect('@getUrlForAction('list') ?>'); + } + + if (!$action = $request->getParameter('batch_action')) + { + $this->getUser()->setFlash('error', 'You must select an action to execute on the selected items.'); + + $this->redirect('@getUrlForAction('list') ?>'); + } + + if (!method_exists($this, $method = 'execute'.ucfirst($action))) + { + throw new InvalidArgumentException(sprintf('You must create a "%s" method for action "%s"', $method, $action)); + } + + if (!$this->getUser()->hasCredential($this->configuration->getCredentials($action))) + { + $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); + } + + $validator = new sfValidatorDoctrineChoiceMany(array('model' => 'getModelClass() ?>')); + try + { + // validate ids + $ids = $validator->clean($ids); + + // execute batch + $this->$method($request); + } + catch (sfValidatorError $e) + { + $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items as some items do not exist anymore.'); + } + + $this->redirect('@getUrlForAction('list') ?>'); + } + + protected function executeBatchDelete(sfWebRequest $request) + { + $ids = $request->getParameter('ids'); + + $count = Doctrine_Query::create() + ->delete() + ->from('getModelClass() ?>') + ->whereIn('getPrimaryKeys(true) ?>', $ids) + ->execute(); + + if ($count >= count($ids)) + { + $this->getUser()->setFlash('notice', 'The selected items have been deleted successfully.'); + } + else + { + $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); + } + + $this->redirect('@getUrlForAction('list') ?>'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/configuration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/configuration.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,85 @@ +[?php + +/** + * getModuleName() ?> module configuration. + * + * @package ##PROJECT_NAME## + * @subpackage getModuleName()."\n" ?> + * @author ##AUTHOR_NAME## + * @version SVN: $Id: configuration.php 12474 2008-10-31 10:41:27Z fabien $ + */ +class BasegetModuleName()) ?>GeneratorConfiguration extends sfModelGeneratorConfiguration +{ + + + + + /** + * Gets a new form object. + * + * @param mixed $object + * + * @return sfForm + */ + public function getForm($object = null) + { + $class = $this->getFormClass(); + + return new $class($object, $this->getFormOptions()); + } + + /** + * Gets the form class name. + * + * @return string The form class name + */ + public function getFormClass() + { + return 'config['form']['class']) ? $this->config['form']['class'] : $this->getModelClass().'Form' ?>'; +config['form']['class']) ?> + } + + public function getFormOptions() + { + return array(); + } + + public function hasFilterForm() + { + return config['filter']['class']) || false !== $this->config['filter']['class'] ? 'true' : 'false' ?>; + } + + /** + * Gets the filter form class name + * + * @return string The filter form class name associated with this generator + */ + public function getFilterFormClass() + { + return 'config['filter']['class']) && !in_array($this->config['filter']['class'], array(null, true, false), true) ? $this->config['filter']['class'] : $this->getModelClass().'FormFilter' ?>'; +config['filter']['class']) ?> + } + + + + + + + + public function getTableMethod() + { + return 'config['list']['table_method']) ? $this->config['list']['table_method'] : null ?>'; +config['list']['table_method']) ?> + } + + public function getTableCountMethod() + { + return 'config['list']['table_count_method']) ? $this->config['list']['table_count_method'] : null ?>'; +config['list']['table_count_method']) ?> + } + + public function getConnection() + { + return null; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/createAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/createAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,9 @@ + public function executeCreate(sfWebRequest $request) + { + $this->form = $this->configuration->getForm(); + $this->getSingularName() ?> = $this->form->getObject(); + + $this->processForm($request, $this->form); + + $this->setTemplate('new'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/deleteAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/deleteAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,12 @@ + public function executeDelete(sfWebRequest $request) + { + $request->checkCSRFProtection(); + + $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject()))); + + $this->getRoute()->getObject()->delete(); + + $this->getUser()->setFlash('notice', 'The item was deleted successfully.'); + + $this->redirect('@getUrlForAction('list') ?>'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/editAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/editAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,5 @@ + public function executeEdit(sfWebRequest $request) + { + $this->getSingularName() ?> = $this->getRoute()->getObject(); + $this->form = $this->configuration->getForm($this->getSingularName() ?>); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/fieldsConfiguration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/fieldsConfiguration.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,86 @@ + public function getListParams() + { + return asPhp(isset($this->config['list']['params']) ? $this->config['list']['params'] : '%%'.implode('%% - %%', isset($this->config['list']['display']) ? $this->config['list']['display'] : $this->getAllFieldNames(false)).'%%') ?>; +config['list']['params']) ?> + } + + public function getListLayout() + { + return 'config['list']['layout']) ? $this->config['list']['layout'] : 'tabular' ?>'; +config['list']['layout']) ?> + } + + public function getListTitle() + { + return 'escapeString(isset($this->config['list']['title']) ? $this->config['list']['title'] : sfInflector::humanize($this->getModuleName()).' List') ?>'; +config['list']['title']) ?> + } + + public function getEditTitle() + { + return 'escapeString(isset($this->config['edit']['title']) ? $this->config['edit']['title'] : 'Edit '.sfInflector::humanize($this->getModuleName())) ?>'; +config['edit']['title']) ?> + } + + public function getNewTitle() + { + return 'escapeString(isset($this->config['new']['title']) ? $this->config['new']['title'] : 'New '.sfInflector::humanize($this->getModuleName())) ?>'; +config['new']['title']) ?> + } + + public function getFilterDisplay() + { + return asPhp(isset($this->config['filter']['display']) ? $this->config['filter']['display'] : array()) ?>; +config['filter']['display']) ?> + } + + public function getFormDisplay() + { + return asPhp(isset($this->config['form']['display']) ? $this->config['form']['display'] : array()) ?>; +config['form']['display']) ?> + } + + public function getEditDisplay() + { + return asPhp(isset($this->config['edit']['display']) ? $this->config['edit']['display'] : array()) ?>; +config['edit']['display']) ?> + } + + public function getNewDisplay() + { + return asPhp(isset($this->config['new']['display']) ? $this->config['new']['display'] : array()) ?>; +config['new']['display']) ?> + } + + public function getListDisplay() + { +config['list']['display'])): ?> + return asPhp($this->config['list']['display']) ?>; +config['list']['hide'])): ?> + return asPhp(array_diff($this->getAllFieldNames(false), $this->config['list']['hide'])) ?>; + + return asPhp($this->getAllFieldNames(false)) ?>; + +config['list']['display'], $this->config['list']['hide']) ?> + } + + public function getFieldsDefault() + { + return array( +getDefaultFieldsConfiguration() as $name => $params): ?> + '' => asPhp($params) ?>, + + ); + } + + + public function getFields() + { + return array( +getFieldsConfiguration($context) as $name => $params): ?> + '' => asPhp($params) ?>, + + ); + } + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/filterAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/filterAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,26 @@ + public function executeFilter(sfWebRequest $request) + { + $this->setPage(1); + + if ($request->hasParameter('_reset')) + { + $this->setFilters($this->configuration->getFilterDefaults()); + + $this->redirect('@getUrlForAction('list') ?>'); + } + + $this->filters = $this->configuration->getFilterForm($this->getFilters()); + + $this->filters->bind($request->getParameter($this->filters->getName())); + if ($this->filters->isValid()) + { + $this->setFilters($this->filters->getValues()); + + $this->redirect('@getUrlForAction('list') ?>'); + } + + $this->pager = $this->getPager(); + $this->sort = $this->getSort(); + + $this->setTemplate('index'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/filtersAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/filtersAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,9 @@ + protected function getFilters() + { + return $this->getUser()->getAttribute('getModuleName() ?>.filters', $this->configuration->getFilterDefaults(), 'admin_module'); + } + + protected function setFilters(array $filters) + { + return $this->getUser()->setAttribute('getModuleName() ?>.filters', $filters, 'admin_module'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/filtersConfiguration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/filtersConfiguration.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,16 @@ + public function getFilterForm($filters) + { + $class = $this->getFilterFormClass(); + + return new $class($filters, $this->getFilterFormOptions()); + } + + public function getFilterFormOptions() + { + return array(); + } + + public function getFilterDefaults() + { + return array(); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/indexAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/indexAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,17 @@ + public function executeIndex(sfWebRequest $request) + { + // sorting + if ($request->getParameter('sort')) + { + $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type'))); + } + + // pager + if ($request->getParameter('page')) + { + $this->setPage($request->getParameter('page')); + } + + $this->pager = $this->getPager(); + $this->sort = $this->getSort(); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/newAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/newAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,5 @@ + public function executeNew(sfWebRequest $request) + { + $this->form = $this->configuration->getForm(); + $this->getSingularName() ?> = $this->form->getObject(); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/paginationAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/paginationAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,49 @@ + protected function getPager() + { + $pager = $this->configuration->getPager('getModelClass() ?>'); + $pager->setQuery($this->buildQuery()); + $pager->setPage($this->getPage()); + $pager->init(); + + return $pager; + } + + protected function setPage($page) + { + $this->getUser()->setAttribute('getModuleName() ?>.page', $page, 'admin_module'); + } + + protected function getPage() + { + return $this->getUser()->getAttribute('getModuleName() ?>.page', 1, 'admin_module'); + } + + protected function buildQuery() + { + $tableMethod = $this->configuration->getTableMethod(); +configuration->hasFilterForm()): ?> + if (is_null($this->filters)) + { + $this->filters = $this->configuration->getFilterForm($this->getFilters()); + } + + $this->filters->setTableMethod($tableMethod); + + $query = $this->filters->buildQuery($this->getFilters()); + + $query = Doctrine::getTable('getModelClass() ?>') + ->createQuery('a'); + + if ($tableMethod) + { + $query = Doctrine::getTable('getModelClass() ?>')->$tableMethod($query); + } + + + $this->addSortQuery($query); + + $event = $this->dispatcher->filter(new sfEvent($this, 'admin.build_query'), $query); + $query = $event->getReturnValue(); + + return $query; + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/paginationConfiguration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/paginationConfiguration.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,18 @@ + public function getPager($model) + { + $class = $this->getPagerClass(); + + return new $class($model, $this->getPagerMaxPerPage()); + } + + public function getPagerClass() + { + return 'config['list']['pager_class']) ? $this->config['list']['pager_class'] : 'sfDoctrinePager' ?>'; +config['list']['pager_class']) ?> + } + + public function getPagerMaxPerPage() + { + return config['list']['max_per_page']) ? (integer) $this->config['list']['max_per_page'] : 20 ?>; +config['list']['max_per_page']) ?> + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/processFormAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/processFormAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,29 @@ + protected function processForm(sfWebRequest $request, sfForm $form) + { + $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); + if ($form->isValid()) + { + $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.'; + + $getSingularName() ?> = $form->save(); + + $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $getSingularName() ?>))); + + if ($request->hasParameter('_save_and_add')) + { + $this->getUser()->setFlash('notice', $notice.' You can add another one below.'); + + $this->redirect('@getUrlForAction('new') ?>'); + } + else + { + $this->getUser()->setFlash('notice', $notice); + + $this->redirect(array('sf_route' => 'getUrlForAction('edit') ?>', 'sf_subject' => $getSingularName() ?>)); + } + } + else + { + $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false); + } + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/sortingAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/sortingAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,31 @@ + protected function addSortQuery($query) + { + if (array(null, null) == ($sort = $this->getSort())) + { + return; + } + + $query->addOrderBy($sort[0] . ' ' . $sort[1]); + } + + protected function getSort() + { + if (!is_null($sort = $this->getUser()->getAttribute('getModuleName() ?>.sort', null, 'admin_module'))) + { + return $sort; + } + + $this->setSort($this->configuration->getDefaultSort()); + + return $this->getUser()->getAttribute('getModuleName() ?>.sort', null, 'admin_module'); + } + + protected function setSort(array $sort) + { + if (!is_null($sort[0]) && is_null($sort[1])) + { + $sort[1] = 'asc'; + } + + $this->getUser()->setAttribute('getModuleName() ?>.sort', $sort, 'admin_module'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/sortingConfiguration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/sortingConfiguration.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,10 @@ + public function getDefaultSort() + { +config['list']['sort']) ? $this->config['list']['sort'] : false)): ?> + + return array('', ''); + + return array(null, null); + +config['list']['sort']) ?> + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/updateAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/updateAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,9 @@ + public function executeUpdate(sfWebRequest $request) + { + $this->getSingularName() ?> = $this->getRoute()->getObject(); + $this->form = $this->configuration->getForm($this->getSingularName() ?>); + + $this->processForm($request, $this->form); + + $this->setTemplate('edit'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/skeleton/actions/actions.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/skeleton/actions/actions.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,16 @@ +moduleName) ?>GeneratorConfiguration.class.php'); +require_once(dirname(__FILE__).'/../lib/BasemoduleName) ?>GeneratorHelper.class.php'); + +/** + * getModuleName() ?> actions. + * + * @package ##PROJECT_NAME## + * @subpackage getModuleName()."\n" ?> + * @author ##AUTHOR_NAME## + * @version SVN: $Id: actions.class.php 12493 2008-10-31 14:43:26Z fabien $ + */ +class getGeneratedModuleName() ?>Actions extends sfActions +{ + public function preExecute() + { + $this->configuration = new getModuleName() ?>GeneratorConfiguration(); + + if (!$this->getUser()->hasCredential($this->configuration->getCredentials($this->getActionName()))) + { + $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); + } + + $this->dispatcher->notify(new sfEvent($this, 'admin.pre_execute', array('configuration' => $this->configuration))); + + $this->helper = new getModuleName() ?>GeneratorHelper(); + } + + + +configuration->hasFilterForm()): ?> + + + + + + + + + + + + + +configuration->getValue('list.batch_actions')): ?> + + + + + +configuration->hasFilterForm()): ?> + + + + + + +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/lib/helper.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/lib/helper.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,57 @@ +[?php + +/** + * getModuleName() ?> module configuration. + * + * @package ##PROJECT_NAME## + * @subpackage getModuleName()."\n" ?> + * @author ##AUTHOR_NAME## + * @version SVN: $Id: helper.php 12482 2008-10-31 11:13:22Z fabien $ + */ +class BasegetModuleName()) ?>GeneratorHelper extends sfModelGeneratorHelper +{ + public function linkToNew($params) + { + return '
  • '.link_to(__($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('new')).'
  • '; + } + + public function linkToEdit($object, $params) + { + return '
  • '.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('edit'), $object).'
  • '; + } + + public function linkToDelete($object, $params) + { + if ($object->isNew()) + { + return ''; + } + + return '
  • '.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('delete'), $object, array('method' => 'delete', 'confirm' => !empty($params['confirm']) ? __($params['confirm'], array(), 'sf_admin') : $params['confirm'])).'
  • '; + } + + public function linkToList($params) + { + return '
  • '.link_to(__($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('list')).'
  • '; + } + + public function linkToSave($object, $params) + { + return '
  • '; + } + + public function linkToSaveAndAdd($object, $params) + { + if (!$object->isNew()) + { + return ''; + } + + return '
  • '; + } + + public function getUrlForAction($action) + { + return 'list' == $action ? 'params['route_prefix'] ?>' : 'params['route_prefix'] ?>_'.$action; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_assets.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_assets.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,6 @@ +params['css'])): ?> +[?php use_stylesheet('params['css'] ?>', 'first') ?] + +[?php use_stylesheet('', 'first') ?] +[?php use_stylesheet('', 'first') ?] + \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_filters.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_filters.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,36 @@ +[?php include_stylesheets_for_form($form) ?] +[?php include_javascripts_for_form($form) ?] + +
    + [?php if ($form->hasGlobalErrors()): ?] + [?php echo $form->renderGlobalErrors() ?] + [?php endif; ?] + +
    + + + + + + + + [?php foreach ($configuration->getFormFilterFields($form) as $name => $field): ?] + [?php if ((isset($form[$name]) && $form[$name]->isHidden()) || (!isset($form[$name]) && $field->isReal())) continue ?] + [?php include_partial('getModuleName() ?>/filters_field', array( + 'name' => $name, + 'attributes' => $field->getConfig('attributes', array()), + 'label' => $field->getConfig('label'), + 'help' => $field->getConfig('help'), + 'form' => $form, + 'field' => $field, + 'class' => 'sf_admin_form_row sf_admin_'.strtolower($field->getType()).' sf_admin_filter_field_'.$name, + )) ?] + [?php endforeach; ?] + +
    + [?php echo $form->renderHiddenFields() ?] + [?php echo link_to(__('Reset', array(), 'sf_admin'), 'getUrlForAction('collection') ?>', array('action' => 'filter'), array('query_string' => '_reset', 'method' => 'post')) ?] + +
    +
    +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_filters_field.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_filters_field.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,20 @@ +[?php if ($field->isPartial()): ?] + [?php include_partial('getModuleName() ?>/'.$name, array('type' => 'filter', 'form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?] +[?php elseif ($field->isComponent()): ?] + [?php include_component('getModuleName() ?>', $name, array('type' => 'filter', 'form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?] +[?php else: ?] + + + [?php echo $form[$name]->renderLabel($label) ?] + + + [?php echo $form[$name]->renderError() ?] + + [?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?] + + [?php if ($help || $help = $form[$name]->renderHelp()): ?] +
    [?php echo __($help, array(), 'getI18nCatalogue() ?>') ?]
    + [?php endif; ?] + + +[?php endif; ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_flashes.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_flashes.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,7 @@ +[?php if ($sf_user->hasFlash('notice')): ?] +
    [?php echo __($sf_user->getFlash('notice'), array(), 'sf_admin') ?]
    +[?php endif; ?] + +[?php if ($sf_user->hasFlash('error')): ?] +
    [?php echo __($sf_user->getFlash('error'), array(), 'sf_admin') ?]
    +[?php endif; ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,18 @@ +[?php include_stylesheets_for_form($form) ?] +[?php include_javascripts_for_form($form) ?] + +
    + [?php echo form_tag_for($form, '@params['route_prefix'] ?>') ?] + [?php echo $form->renderHiddenFields() ?] + + [?php if ($form->hasGlobalErrors()): ?] + [?php echo $form->renderGlobalErrors() ?] + [?php endif; ?] + + [?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?] + [?php include_partial('getModuleName() ?>/form_fieldset', array('getSingularName() ?>' => $getSingularName() ?>, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?] + [?php endforeach; ?] + + [?php include_partial('getModuleName() ?>/form_actions', array('getSingularName() ?>' => $getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?] + +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_actions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_actions.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,35 @@ + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_field.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_field.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,18 @@ +[?php if ($field->isPartial()): ?] + [?php include_partial('getModuleName() ?>/'.$name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?] +[?php elseif ($field->isComponent()): ?] + [?php include_component('getModuleName() ?>', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?] +[?php else: ?] +
    + [?php echo $form[$name]->renderError() ?] +
    + [?php echo $form[$name]->renderLabel($label) ?] + + [?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?] + + [?php if ($help || $help = $form[$name]->renderHelp()): ?] +
    [?php echo __($help, array(), 'getI18nCatalogue() ?>') ?]
    + [?php endif; ?] +
    +
    +[?php endif; ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_fieldset.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_fieldset.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,18 @@ +
    + [?php if ('NONE' != $fieldset): ?] +

    [?php echo __($fieldset, array(), 'getI18nCatalogue() ?>') ?]

    + [?php endif; ?] + + [?php foreach ($fields as $name => $field): ?] + [?php if ((isset($form[$name]) && $form[$name]->isHidden()) || (!isset($form[$name]) && $field->isReal())) continue ?] + [?php include_partial('getModuleName() ?>/form_field', array( + 'name' => $name, + 'attributes' => $field->getConfig('attributes', array()), + 'label' => $field->getConfig('label'), + 'help' => $field->getConfig('help'), + 'form' => $form, + 'field' => $field, + 'class' => 'sf_admin_form_row sf_admin_'.strtolower($field->getType()).' sf_admin_form_field_'.$name, + )) ?] + [?php endforeach; ?] +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_footer.php diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_form_header.php diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,54 @@ +
    + [?php if (!$pager->getNbResults()): ?] +

    [?php echo __('No result', array(), 'sf_admin') ?]

    + [?php else: ?] + + + +configuration->getValue('list.batch_actions')): ?> + + + [?php include_partial('getModuleName() ?>/list_th_configuration->getValue('list.layout') ?>', array('sort' => $sort)) ?] +configuration->getValue('list.object_actions')): ?> + + + + + + + + + + + [?php foreach ($pager->getResults() as $i => $getSingularName() ?>): $odd = fmod(++$i, 2) ? 'odd' : 'even' ?] + +configuration->getValue('list.batch_actions')): ?> + [?php include_partial('getModuleName() ?>/list_td_batch_actions', array('getSingularName() ?>' => $getSingularName() ?>, 'helper' => $helper)) ?] + + [?php include_partial('getModuleName() ?>/list_td_configuration->getValue('list.layout') ?>', array('getSingularName() ?>' => $getSingularName() ?>)) ?] +configuration->getValue('list.object_actions')): ?> + [?php include_partial('getModuleName() ?>/list_td_actions', array('getSingularName() ?>' => $getSingularName() ?>, 'helper' => $helper)) ?] + + + [?php endforeach; ?] + +
    [?php echo __('Actions', array(), 'sf_admin') ?]
    + [?php if ($pager->haveToPaginate()): ?] + [?php include_partial('getModuleName() ?>/pagination', array('pager' => $pager)) ?] + [?php endif; ?] + + [?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1% results', array('%1%' => $pager->getNbResults()), $pager->getNbResults(), 'sf_admin') ?] + [?php if ($pager->haveToPaginate()): ?] + [?php echo __('(page %%page%%/%%nb_pages%%)', array('%%page%%' => $pager->getPage(), '%%nb_pages%%' => $pager->getLastPage()), 'sf_admin') ?] + [?php endif; ?] +
    + [?php endif; ?] +
    + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_actions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_actions.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,11 @@ +configuration->getValue('list.actions')): ?> + $params): ?> + +addCredentialCondition('[?php echo $helper->linkToNew('.$this->asPhp($params).') ?]', $params)."\n" ?> + +
  • + addCredentialCondition($this->getLinkToAction($name, $params, false), $params)."\n" ?> +
  • + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_batch_actions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_batch_actions.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,15 @@ +configuration->getValue('list.batch_actions')): ?> +
  • + + [?php $form = new sfForm(); if ($form->isCSRFProtected()): ?] + + [?php endif; ?] + +
  • + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_field_boolean.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_field_boolean.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,5 @@ +[?php if ($value): ?] + [?php echo image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/tick.png', array('alt' => __('Checked', array(), 'sf_admin'), 'title' => __('Checked', array(), 'sf_admin'))) ?] +[?php else: ?] +   +[?php endif; ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_footer.php diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_header.php diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_actions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_actions.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,18 @@ + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_batch_actions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_batch_actions.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,3 @@ + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_stacked.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_stacked.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,3 @@ + + [?php echo getI18NString('list.params') ?> ?] + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_tabular.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_td_tabular.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,9 @@ +configuration->getValue('list.display') as $name => $field): ?> +addCredentialCondition(sprintf(<< + [?php echo %s ?] + + +EOF +, strtolower($field->getType()), $name, $this->renderField($field)), $field->getConfig()) ?> + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_th_stacked.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_th_stacked.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,1 @@ +[?php include_partial('getModuleName() ?>/list_th_tabular', array('sort' => $sort)) ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_th_tabular.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_th_tabular.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,17 @@ +configuration->getValue('list.display') as $name => $field): ?> +[?php slot('sf_admin.current_header') ?] + +isReal()): ?> + [?php if ('' == $sort[0]): ?] + [?php echo link_to(__('getConfig('label', '', true) ?>', array(), 'getI18nCatalogue() ?>'), '@getUrlForAction('list') ?>?sort=&sort_type='.($sort[1] == 'asc' ? 'desc' : 'asc')) ?] + [?php echo image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/'.$sort[1].'.png', array('alt' => __($sort[1], array(), 'sf_admin'), 'title' => __($sort[1], array(), 'sf_admin'))) ?] + [?php else: ?] + [?php echo link_to(__('getConfig('label', '', true) ?>', array(), 'getI18nCatalogue() ?>'), '@getUrlForAction('list') ?>?sort=&sort_type=asc') ?] + [?php endif; ?] + + [?php echo __('getConfig('label', '', true) ?>', array(), 'getI18nCatalogue() ?>') ?] + + +[?php end_slot(); ?] +addCredentialCondition("[?php include_slot('sf_admin.current_header') ?]", $field->getConfig()) ?> + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_pagination.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_pagination.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,25 @@ + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/editSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/editSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,20 @@ +[?php use_helper('I18N', 'Date') ?] +[?php include_partial('getModuleName() ?>/assets') ?] + +
    +

    [?php echo getI18NString('edit.title') ?> ?]

    + + [?php include_partial('getModuleName() ?>/flashes') ?] + +
    + [?php include_partial('getModuleName() ?>/form_header', array('getSingularName() ?>' => $getSingularName() ?>, 'form' => $form, 'configuration' => $configuration)) ?] +
    + +
    + [?php include_partial('getModuleName() ?>/form', array('getSingularName() ?>' => $getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?] +
    + + +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/indexSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/indexSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,36 @@ +[?php use_helper('I18N', 'Date') ?] +[?php include_partial('getModuleName() ?>/assets') ?] + +
    +

    [?php echo getI18NString('list.title') ?> ?]

    + + [?php include_partial('getModuleName() ?>/flashes') ?] + +
    + [?php include_partial('getModuleName() ?>/list_header', array('pager' => $pager)) ?] +
    + +configuration->hasFilterForm()): ?> +
    + [?php include_partial('getModuleName() ?>/filters', array('form' => $filters, 'configuration' => $configuration)) ?] +
    + + +
    +configuration->getValue('list.batch_actions')): ?> +
    + + [?php include_partial('getModuleName() ?>/list', array('pager' => $pager, 'sort' => $sort, 'helper' => $helper)) ?] +
      + [?php include_partial('getModuleName() ?>/list_batch_actions', array('helper' => $helper)) ?] + [?php include_partial('getModuleName() ?>/list_actions', array('helper' => $helper)) ?] +
    +configuration->getValue('list.batch_actions')): ?> +
    + +
    + + +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/newSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/newSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,20 @@ +[?php use_helper('I18N', 'Date') ?] +[?php include_partial('getModuleName() ?>/assets') ?] + +
    +

    [?php echo getI18NString('new.title') ?> ?]

    + + [?php include_partial('getModuleName() ?>/flashes') ?] + +
    + [?php include_partial('getModuleName() ?>/form_header', array('getSingularName() ?>' => $getSingularName() ?>, 'form' => $form, 'configuration' => $configuration)) ?] +
    + +
    + [?php include_partial('getModuleName() ?>/form', array('getSingularName() ?>' => $getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?] +
    + + +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/createAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/createAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,13 @@ + public function executeCreate(sfWebRequest $request) + { +params['with_doctrine_route']) && $this->params['with_doctrine_route']): ?> + + $this->forward404Unless($request->isMethod('post')); + + + $this->form = new getModelClass().'Form' ?>(); + + $this->processForm($request, $this->form); + + $this->setTemplate('new'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/deleteAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/deleteAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,17 @@ + public function executeDelete(sfWebRequest $request) + { + $request->checkCSRFProtection(); + +params['with_doctrine_route']) && $this->params['with_doctrine_route']): ?> + $this->getRoute()->getObject()->delete(); + + $this->forward404Unless($getSingularName() ?> = Doctrine::getTable('getModelClass() ?>')->find(getRetrieveByPkParamsForAction(43) ?>), sprintf('Object getSingularName() ?> does not exist (%s).', getRetrieveByPkParamsForAction(43) ?>)); + $getSingularName() ?>->delete(); + + +params['route_prefix']) && $this->params['route_prefix']): ?> + $this->redirect('@getUrlForAction('list') ?>'); + + $this->redirect('getModuleName() ?>/index'); + + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/editAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/editAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,9 @@ + public function executeEdit(sfWebRequest $request) + { +params['with_doctrine_route']) && $this->params['with_doctrine_route']): ?> + $this->form = new getModelClass().'Form' ?>($this->getRoute()->getObject()); + + $this->forward404Unless($getSingularName() ?> = Doctrine::getTable('getModelClass() ?>')->find(getRetrieveByPkParamsForAction(43) ?>), sprintf('Object getSingularName() ?> does not exist (%s).', getRetrieveByPkParamsForAction(43) ?>)); + $this->form = new getModelClass().'Form' ?>($getSingularName() ?>); + + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/indexAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/indexAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,10 @@ + public function executeIndex(sfWebRequest $request) + { +params['with_doctrine_route']) && $this->params['with_doctrine_route']): ?> + $this->getPluralName() ?> = $this->getRoute()->getObjects(); + + $this->getPluralName() ?> = Doctrine::getTable('getModelClass() ?>') + ->createQuery('a') + ->execute(); + + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/newAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/newAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,4 @@ + public function executeNew(sfWebRequest $request) + { + $this->form = new getModelClass().'Form' ?>(); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/processFormAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/processFormAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,14 @@ + protected function processForm(sfWebRequest $request, sfForm $form) + { + $form->bind($request->getParameter($form->getName())); + if ($form->isValid()) + { + $getSingularName() ?> = $form->save(); + +params['route_prefix']) && $this->params['route_prefix']): ?> + $this->redirect('@getUrlForAction('edit') ?>?getPrimaryKeyUrlParams() ?>); + + $this->redirect('getModuleName() ?>/edit?getPrimaryKeyUrlParams() ?>); + + } + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/showAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/showAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,9 @@ + public function executeShow(sfWebRequest $request) + { +params['with_doctrine_route']) && $this->params['with_doctrine_route']): ?> + $this->getSingularName() ?> = $this->getRoute()->getObject(); + + $this->getSingularName() ?> = Doctrine::getTable('getModelClass() ?>')->find(getRetrieveByPkParamsForAction(65) ?>); + $this->forward404Unless($this->getSingularName() ?>); + + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/updateAction.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/parts/updateAction.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,14 @@ + public function executeUpdate(sfWebRequest $request) + { +params['with_doctrine_route']) && $this->params['with_doctrine_route']): ?> + $this->form = new getModelClass().'Form' ?>($this->getRoute()->getObject()); + + $this->forward404Unless($request->isMethod('post') || $request->isMethod('put')); + $this->forward404Unless($getSingularName() ?> = Doctrine::getTable('getModelClass() ?>')->find(getRetrieveByPkParamsForAction(43) ?>), sprintf('Object getSingularName() ?> does not exist (%s).', getRetrieveByPkParamsForAction(43) ?>)); + $this->form = new getModelClass().'Form' ?>($getSingularName() ?>); + + + $this->processForm($request, $this->form); + + $this->setTemplate('edit'); + } diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/skeleton/actions/actions.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/skeleton/actions/actions.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,13 @@ +getModuleName() ?> actions. + * + * @package ##PROJECT_NAME## + * @subpackage getModuleName()."\n" ?> + * @author ##AUTHOR_NAME## + * @version SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $ + */ +class getGeneratedModuleName() ?>Actions extends sfActions +{ + + +params['with_show']) && $this->params['with_show']): ?> + + + + + + + + + + + + + + +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/_form.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/_form.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,53 @@ +[?php include_stylesheets_for_form($form) ?] +[?php include_javascripts_for_form($form) ?] + +getFormObject() ?> +params['route_prefix']) && $this->params['route_prefix']): ?> +[?php echo form_tag_for($form, '@params['route_prefix'] ?>') ?] + +
    isMultipart() and print 'enctype="multipart/form-data" ' ?]> +[?php if (!$form->getObject()->isNew()): ?] + +[?php endif; ?] + + + + + + + + +params['non_verbose_templates']) && $this->params['non_verbose_templates']): ?> + [?php echo $form ?] + + [?php echo $form->renderGlobalErrors() ?] + $field): if ($field->isHidden()) continue ?> + + + + + + + +
    +params['non_verbose_templates']) || !$this->params['non_verbose_templates']): ?> + [?php echo $form->renderHiddenFields() ?] + +params['route_prefix']) && $this->params['route_prefix']): ?> +  Cancel + +  Cancel + + [?php if (!$form->getObject()->isNew()): ?] +params['route_prefix']) && $this->params['route_prefix']): ?> +  [?php echo link_to('Delete', 'getUrlForAction('delete') ?>', $form->getObject(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?] + +  [?php echo link_to('Delete', 'getModuleName() ?>/delete?getPrimaryKeyUrlParams('$form->getObject()', true) ?>, array('method' => 'delete', 'confirm' => 'Are you sure?')) ?] + + [?php endif; ?] + +
    [?php echo $form['']->renderLabel() ?] + [?php echo $form['']->renderError() ?] + [?php echo $form[''] ?] +
    +
    diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/editSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/editSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,3 @@ +

    Edit getModuleName()) ?>

    + +[?php include_partial('form', array('form' => $form)) ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/indexSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/indexSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,35 @@ +getFormObject() ?> +

    getModuleName()) ?> List

    + + + + +getColumns() as $column): ?> + + + + + + [?php foreach ($getPluralName() ?> as $getSingularName() ?>): ?] + +getColumns() as $column): ?> +isPrimaryKey()): ?> +params['route_prefix']) && $this->params['route_prefix']): ?> + + + + + + + + + + [?php endforeach; ?] + +
    getPhpName())) ?>
    [?php echo $getSingularName() ?>->getgetPhpName()) ?>() ?][?php echo $getSingularName() ?>->getgetPhpName()) ?>() ?][?php echo $getSingularName() ?>->getgetPhpName()) ?>() ?]
    + +params['route_prefix']) && $this->params['route_prefix']): ?> + New + + New + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/newSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/newSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,3 @@ +

    New getModuleName()) ?>

    + +[?php include_partial('form', array('form' => $form)) ?] diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/showSuccess.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/showSuccess.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,22 @@ + + +getColumns() as $column): ?> + + + + + + +
    getPhpName())) ?>:[?= $getSingularName() ?>->getgetPhpName() ?>() ?]
    + +
    + +params['route_prefix']) && $this->params['route_prefix']): ?> +Edit +  +List + +Edit +  +List + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ar.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ar.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + جديد + + + Edit + تحديث + + + Delete + حذ٠+ + + List + لائحة + + + Save + Ø­ÙØ¸ + + + Save and add + Ø­ÙØ¸ Ùˆ Ø¥Ø¶Ø§ÙØ© + + + Cancel + إلغاء + + + + + Reset + مسح + + + Filter + ÙØ±Ø² + + + + + No result + لا توجد نتائج + + + Actions + إجراءات + + + (page %%page%%/%%nb_pages%%) + (%%nb_pages%%/%%page%% ØµÙØ­Ø©) + + + asc + تصاعدي + + + desc + تنازلي + + + + + First page + الأولى + + + Previous page + Ø§Ù„ØµÙØ­Ø© السابقة + + + Next page + Ø§Ù„ØµÙØ­Ø© الاحقة + + + Last page + الاخيرة + + + + + The item was created successfully. + .تمت Ø§Ù„Ø¥Ø¶Ø§ÙØ© بنجاح + + + The item was updated successfully. + .تم التحديث بنجاح + + + The item was created successfully. You can add another one below. + .تمت Ø§Ù„Ø¥Ø¶Ø§ÙØ© بنجاح. يمكنك Ø¥Ø¶Ø§ÙØ© آخر + + + The item was updated successfully. You can add another one below. + .تم التحديث بنجاح. يمكنك Ø¥Ø¶Ø§ÙØ© آخر + + + The item has not been saved due to some errors. + .لم يتم التحديث + + + The item was deleted successfully. + .تم الحذ٠بنجاح + + + You must at least select one item. + .يجب اختيار عنصر واحد على الأقل + + + You must select an action to execute on the selected items. + .يجب اختيار عمل للتنÙيذ ضمن العناصر المختارة + + + A problem occurs when deleting the selected items as some items do not exist anymore. + .حال مشكل دون عملية الحذ٠للعناصر المختارة لأن بعضها غير موجود + + + The selected items have been deleted successfully. + .تم حذ٠العناصر المختارة بنجاح + + + A problem occurs when deleting the selected items. + .حال مشكل أثناء عملية الحذ٠للعناصر المختارة + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.bg.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.bg.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,126 @@ + + + + +
    + + + + New + Ðов + + + Edit + Ð ÐµÐ´Ð°ÐºÑ†Ð¸Ñ + + + Delete + Изтриване + + + List + СпиÑък + + + Save + СъхранÑване + + + Save and add + СъхранÑване и ДобавÑне + + + Cancel + Отказ + + + Choose an action + Избери дейÑтвие + + + go + ок + + + + + Reset + Ðулиране + + + Filter + Филтър + + + + + No result + ÐÑма резултати + + + Actions + ДейÑÑ‚Ð²Ð¸Ñ + + + (page %%page%%/%%nb_pages%%) + (Ñтраница %%page%% от %%nb_pages%%) + + + asc + възходÑщ + + + desc + низходÑщ + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] нÑма резултати|[1] 1 резултат|(1,+Inf] %1% резултата + + + + + First page + Първа Ñтраница + + + Previous page + Предишна Ñтраница + + + Next page + Следваща Ñтраница + + + Last page + ПоÑледна Ñтраница + + + + + The item was created successfully. + ЗапиÑÑŠÑ‚ беше Ñъздаден уÑпешно. + + + The item was updated successfully. + ЗапиÑÑŠÑ‚ беше уÑпешно обновен. + + + The item was created successfully. You can add another one below. + ЗапиÑÑŠÑ‚ беше Ñъздаден уÑпешно. Можете да добавите друг. + + + The item was updated successfully. You can add another one below. + ЗапиÑÑŠÑ‚ беше уÑпешно обновен. Можете да добавите друг. + + + The item has not been saved due to some errors. + ЗапиÑÑŠÑ‚ не беше запазен поради грешки. + + + The item was deleted successfully. + ЗапиÑÑŠÑ‚ беше уÑпешно изтрит. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ca.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ca.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,147 @@ + + + + +
    + + + + New + Nou + + + Edit + Edita + + + Delete + Esborrar + + + List + Llista + + + Save + Salvar + + + Save and add + Desar i afegir + + + Cancel + Cancelar + + + + + Reset + Restablir + + + Filter + Filtrar + + + + + No result + Cap resultat + + + Actions + Accions + + + (page %%page%%/%%nb_pages%%) + (pàgina %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + Choose an action + Tria una opció + + + go + executa + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] cap resultat|[1] 1 resultat|(1,+Inf] %1% resultats + + + + + First page + Primera pàgina + + + Previous page + Pàgina anterior + + + Next page + Pàgina següent + + + Last page + Última pàgina + + + + + + The item was created successfully. + El tema s'ha creat amb èxit. + + + The item was updated successfully. + El tema s'ha actualitzat amb èxit. + + + The item was created successfully. You can add another one below. + El tema s'ha creat amb èxit. Podeu afegir una altra més endavant. + + + The item was updated successfully. You can add another one below. + El tema s'ha actualitzat amb èxit. Podeu afegir una altra més endavant. + + + The item has not been saved due to some errors. + El tema no s'ha desat degut a alguns errors. + + + The item was deleted successfully. + El tema s'ha eliminat amb èxit. + + + You must at least select one item. + Has de seleccionar almenys un element. + + + You must select an action to execute on the selected items. + Has de triar l'acció que vols executar sobre els elements seleccionats. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + S'ha produït un error a l'esborrar els elements seleccionats perquè almenys un d'ells ja no existeix. + + + The selected items have been deleted successfully. + Els elements seleccionats s'han esborrat correctament. + + + A problem occurs when deleting the selected items. + S'ha produït un error a l'esborrar els elements seleccionats. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.cs.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.cs.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Vytvořit + + + Edit + Upravit + + + Delete + Odstranit + + + List + Výpis + + + Save + Uložit + + + Save and add + Uložit a přidat + + + Cancel + Zrušit + + + + + Reset + Zrušit + + + Filter + Filtrovat + + + + + No result + Žádné položky + + + Actions + Akce + + + (page %%page%%/%%nb_pages%%) + (stránka %%page%%/%%nb_pages%%) + + + asc + vzestupně + + + desc + sestupně + + + + + First page + První stránka + + + Previous page + Předchozí stránka + + + Next page + Další stránka + + + Last page + Poslední stránka + + + + + The item was created successfully. + Položka byla úspešně vytvořena. + + + The item was updated successfully. + Položka byla úspešně upravena. + + + The item was created successfully. You can add another one below. + Položka byla úspešně vytvořena. Můžete přidat další. + + + The item was updated successfully. You can add another one below. + Položka byla úspešne upravena. Můžete přidat další. + + + The item has not been saved due to some errors. + Položka nebyla uložena kvůli chybám. + + + The item was deleted successfully. + Položka byla úspešně odstraněna. + + + You must at least select one item. + Zvolte alespoň jednu položku. + + + You must select an action to execute on the selected items. + Zvolte si akci, která se provede se zvolenými položkami. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Došlo k chybě při odstraňování zvolených položek, některé z nich již neexistují. + + + The selected items have been deleted successfully. + Zvolené položky byly úspěšně odstraněny. + + + A problem occurs when deleting the selected items. + Došlo k chybě při odstraňování zvolených položek. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.da.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.da.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Ny + + + Edit + Rediger + + + Delete + Slet + + + List + Liste + + + Save + Gem + + + Save and add + Gem og tilføj + + + Cancel + Annuler + + + + + Reset + Nulstil + + + Filter + Filtrer + + + + + No result + Intet resultat + + + Actions + Handlinger + + + (page %%page%%/%%nb_pages%%) + (side %%page%% af %%nb_pages%%) + + + asc + stigende + + + desc + faldende + + + + + First page + Første side + + + Previous page + Forrige side + + + Next page + Næste side + + + Last page + Sidste side + + + + + The item was created successfully. + Elementet er blevet tilføjet. + + + The item was updated successfully. + Elementet er blevet opdateret. + + + The item was created successfully. You can add another one below. + Elementet er blevet tilføjet, du kan tilføje endnu et element herunder. + + + The item was updated successfully. You can add another one below. + Elementet er blevet opdateret, du kan tilføje endnu et herunder. + + + The item has not been saved due to some errors. + Elementet er ikke blevet tilføjet, pga. fejl. + + + The item was deleted successfully. + Elementet er blevet slettet. + + + You must at least select one item. + Du skal vælge mindst et element. + + + You must select an action to execute on the selected items. + Du skal vælge en handling, at udføre på de valgte elementer. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Et problem opstod ved sletning af de valgte elementer, da nogen af disse ikke eksisterer mere. + + + The selected items have been deleted successfully. + De valgte elementer er blevet slettet. + + + A problem occurs when deleting the selected items. + Der var et problem, med at slette de valgte elementer. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.de.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.de.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,126 @@ + + + + +
    + + + + New + Neu + + + Edit + Bearbeiten + + + Delete + Löschen + + + List + Liste + + + Save + Speichern + + + Save and add + Speichern und hinzufügen + + + Cancel + Abbrechen + + + Choose an action + Eine Aktion wählen + + + go + ok + + + + + Reset + Zurücksetzen + + + Filter + Filtern + + + + + No result + Keine Ergebnisse + + + Actions + Aktionen + + + (page %%page%%/%%nb_pages%%) + (Seite %%page%% von %%nb_pages%%) + + + asc + aufsteigend + + + desc + absteigend + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] kein Ergebnis|[1] 1 Ergebnis|(1,+Inf] %1% Ergebnisse + + + + + First page + Erste Seite + + + Previous page + Vorherige Seite + + + Next page + Nächste Seite + + + Last page + Letzte Seite + + + + + The item was created successfully. + Das Objekt wurde erfolgreich erstellt. + + + The item was updated successfully. + Das Objekt wurde erfolgreich aktualisiert. + + + The item was created successfully. You can add another one below. + Das Objekt wurde erfolgreich erstellt. Weitere können unten erstellt werden. + + + The item was updated successfully. You can add another one below. + Das Objekt wurde erfolgreich aktualisiert. Weitere können unten erstellt werden. + + + The item has not been saved due to some errors. + Das Objekt konnte wegen Fehlern nicht gespeichert werden. + + + The item was deleted successfully. + Das Objekt wurde erfolgreich gelöscht. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.el.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.el.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Îέο + + + Edit + ΕπεξεÏγασία + + + Delete + ΔιαγÏαφή + + + List + ΑπαÏίθμηση + + + Save + Αποθήκευση + + + Save and add + Αποθήκευση και ΠÏοσθήκη + + + Cancel + ΑκÏÏωση + + + + + Reset + ΚαθαÏισμός + + + Filter + ΦίλτÏο + + + + + No result + Κανένα Αποτέλεσμα. + + + Actions + ΕνέÏγειες + + + (page %%page%%/%%nb_pages%%) + (Σελίδα %%page%%/%%nb_pages%%) + + + asc + αυξ + + + desc + φθι + + + + + First page + ΠÏώτη Σελίδα + + + Previous page + ΠÏοηγοÏμενη Σελίδα + + + Next page + Επόμενη Σελίδα + + + Last page + Τελευταία Σελίδα + + + + + The item was created successfully. + Το αντικείμενο δημιουÏγήθηκε επιτυχώς. + + + The item was updated successfully. + Το αντικείμενο ενημεÏώθηκε επιτυχώς. + + + The item was created successfully. You can add another one below. + Το αντικείμενο δημιουÏγήθηκε επιτυχώς. ΜποÏείτε να Ï€Ïοσθέσετε ένα καινοÏÏιο παÏακάτω. + + + The item was updated successfully. You can add another one below. + Το αντικείμενο ενημεÏώθηκε επιτυχώς. ΜποÏείτε να Ï€Ïοσθέσετε ένα καινοÏÏιο παÏακάτω. + + + The item has not been saved due to some errors. + Το αντικείμενο δεν αποθηκεÏθηκε λόγω κάποιων σφαλμάτων. + + + The item was deleted successfully. + Το αντικείμενο διαγÏάφηκε επιτυχώς. + + + You must at least select one item. + ΠÏέπει να επιλέξετε τουλάχιστον ένα αντικείμενο. + + + You must select an action to execute on the selected items. + ΠÏέπει να επιλέξετε κάποια ενέÏγεια να εκτελεστεί στα επιλεγμένα αντικείμενα. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Κάποιο Ï€Ïόβλημα σημειώθηκε κατά την διαγÏαφή των επιλεγμένων αντικειμένων καθώς μεÏικά αντικείμενα δεν υπάÏχουν πια. + + + The selected items have been deleted successfully. + Τα επιλεγμένα αντικείμενα διαγÏάφηκαν επιτυχώς. + + + A problem occurs when deleting the selected items. + Κάποιο Ï€Ïόβλημα σημειώθηκε κατά την διαγÏαφή των επιλεγμένων αντικειμένων. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.es.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.es.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ + + + + +
    + + + + New + Nuevo + + + Edit + Editar + + + Delete + Borrar + + + List + Listado + + + Save + Guardar + + + Save and add + Guardar y crear otro + + + Cancel + Cancelar + + + Choose an action + Selecciona una acción + + + go + ok + + + + + Reset + Restablecer + + + Filter + Filtrar + + + + + No result + Sin resultados + + + Actions + Acciones + + + (page %%page%%/%%nb_pages%%) + (página %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] sin resultados|[1] 1 resultado|(1,+Inf] %1% resultados + + + + + First page + Primera página + + + Previous page + Página anterior + + + Next page + Página siguiente + + + Last page + Última página + + + + + The item was created successfully. + El elemento se ha creado correctamente. + + + The item was updated successfully. + El elemento se ha actualizado correctamente. + + + The item was created successfully. You can add another one below. + El elemento se ha creado correctamente y ahora puedes crear otro elemento. + + + The item was updated successfully. You can add another one below. + El elemento se ha actualizado correctamente y ahora puedes crear otro elemento. + + + The item has not been saved due to some errors. + El elemento no se ha guardado porque se ha producido algún error. + + + The item was deleted successfully. + El elemento se ha borrado correctamente. + + + You must at least select one item. + Debes seleccionar al menos un elemento. + + + You must select an action to execute on the selected items. + Selecciona la acción que quieres ejecutar sobre los elementos seleccionados. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Se ha producido un error al borrar los elementos seleccionados porque al menos uno de ellos ya no existe. + + + The selected items have been deleted successfully. + Los elementos seleccionados se han borrado correctamente. + + + A problem occurs when deleting the selected items. + Se ha producido un error al borrar los elementos seleccionados. + + + + \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.es_AR.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.es_AR.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ + + + + +
    + + + + New + Nuevo + + + Edit + Editar + + + Delete + Borrar + + + List + Listar + + + Save + Guardar + + + Save and add + Guardar y agregar otro + + + Cancel + Cancelar + + + + + Reset + Reiniciar + + + Filter + Filtrar + + + + + No result + Sin resultados + + + Actions + Acciones + + + (page %%page%%/%%nb_pages%%) + (página %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + + + First page + Primera página + + + Previous page + Página anterior + + + Next page + Siguiente página + + + Last page + Ultima página + + + + + The item was created successfully. + El elemento fue creado satisfactoriamente. + + + The item was updated successfully. + El elemento fue actualizado satisfactoriamente. + + + The item was created successfully. You can add another one below. + El elemento fue creado satisfactoriamente. Podés agregar otro abajo. + + + The item was updated successfully. You can add another one below. + El elemento fue actualizado satisfactoriamente. Podés agregar otro abajo. + + + The item has not been saved due to some errors. + El elemento no fue guardado debido a algunos errores. + + + The item was deleted successfully. + El elemento fue borrado satisfactoriamente. + + + + \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.eu.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.eu.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ + + + + +
    + + + + New + Berria + + + Edit + Aldatu + + + Delete + Ezabatu + + + List + Zerrendatu + + + Save + Gorde + + + Save and add + Gorde eta berria + + + Cancel + Ezeztatu + + + Choose an action + Ekintza bat aukeratu + + + go + ok + + + + + Reset + Garbitu + + + Filter + Mugatu + + + + + No result + Emaitzarik ez + + + Actions + Ekintzak + + + (page %%page%%/%%nb_pages%%) + (%%page%%/%%nb_pages%% orria) + + + asc + gora + + + desc + behera + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] emaitzarik ez|[1] emaitza bat|(1,+Inf] %1% emaitzak + + + + + First page + Lehen orria + + + Previous page + Aurreko orria + + + Next page + Hurrengo orria + + + Last page + Azken orria + + + + + The item was created successfully. + Elementua egoki sortu da. + + + The item was updated successfully. + Elementua egoki eguneratu da. + + + The item was created successfully. You can add another one below. + Elementua egoki sortu da eta orain beste elementu bat sor dezakezu. + + + The item was updated successfully. You can add another one below. + Elementua egoki eguneratu da eta orain beste elementu bat sor dezakezu. + + + The item has not been saved due to some errors. + Elementua ez da gorde errakuntzaren bat gertatu delako. + + + The item was deleted successfully. + Elementua egoki ezabatu da. + + + You must at least select one item. + Gutxienez, elementu bat aukeratu behar duzu. + + + You must select an action to execute on the selected items. + Aukeratutako elementuen artean, exekutatu nahi duzun ekintza aukeratu. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Aukeratutako elementuak ezabatzerakoan errakuntza bat gertatu da, horietako bat, gutxienez, existitzen ez delako. + + + The selected items have been deleted successfully. + Aukeratutako elementuak egoki ezabatu dira. + + + A problem occurs when deleting the selected items. + Errakuntza bat gertatu da, aukeratutako elementuak ezabatzerakoan. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.fi.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.fi.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Uusi + + + Edit + Muokkaa + + + Delete + Poista + + + List + Näytä lista + + + Save + Tallenna + + + Save and add + Tallenna ja lisää + + + Cancel + Peruuta + + + + + Reset + Tyhjennä + + + Filter + Suodata + + + + + No result + Ei tuloksia + + + Actions + Toiminnot + + + (page %%page%%/%%nb_pages%%) + (sivu %%page%%/%%nb_pages%%) + + + asc + kasvava + + + desc + madaltuva + + + + + First page + Ensimmäinen sivu + + + Previous page + Edellinen sivu + + + Next page + Seuraava sivu + + + Last page + Viimeinen sivu + + + + + The item was created successfully. + Merkinnän luonti onnistui. + + + The item was updated successfully. + Merkinnän päivittäminen onnistui. + + + The item was created successfully. You can add another one below. + Merkinnän luonti onnistui. Voit lisätä sen alle seuraavan. + + + The item was updated successfully. You can add another one below. + Merkinnän päivitys onnistui. Voit lisätä sen alle seuraavan. + + + The item has not been saved due to some errors. + Merkintää ei tallennettu virheiden takia. + + + The item was deleted successfully. + Merkinnän poistaminen onnistui. + + + You must at least select one item. + Valitse vähintään yksi merkintä. + + + You must select an action to execute on the selected items. + Valitse toiminto, joka suoritetaan valituille merkinnöille. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Valittujen merkintöjen poistamisessa esiintyi virhe, koska jotkut merkinnät eivät enää olleet olemassa. + + + The selected items have been deleted successfully. + Valittujen merkintöjen poistaminen onnistui. + + + A problem occurs when deleting the selected items. + Valittujen merkintöjen poistamisessa esiintyi virhe. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.fr.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.fr.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,154 @@ + + + + +
    + + + + New + Nouveau + + + Edit + Modifier + + + Delete + Supprimer + + + List + Liste + + + Save + Mettre à jour + + + Save and add + Mettre à jour et ajouter + + + Cancel + Annuler + + + Choose an action + Choisir une action + + + go + ok + + + + + Reset + Effacer + + + Filter + Filtrer + + + + + No result + Aucun résultat. + + + Actions + Actions + + + (page %%page%%/%%nb_pages%%) + (page %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] aucun résultat|[1] 1 résultat|(1,+Inf] %1% résultats + + + Are you sure? + Êtes-vous sûr ? + + + Checked + Activé + + + + + First page + Première page + + + Previous page + Page précédente + + + Next page + Page suivante + + + Last page + Dernière page + + + + + The item was created successfully. + L'objet a été ajouté avec succès. + + + The item was updated successfully. + L'objet a été mis à jour avec succès. + + + The item was created successfully. You can add another one below. + L'objet a été ajouté avec succès. Vous pouvez en ajouter un autre. + + + The item was updated successfully. You can add another one below. + L'objet a été mis à jour avec succès. Vous pouvez en ajouter un autre. + + + The item has not been saved due to some errors. + L'objet n'a pu être mis à jour. + + + The item was deleted successfully. + L'objet a été supprimé avec succès. + + + You must at least select one item. + Vous devez au moins sélectionner un objet. + + + You must select an action to execute on the selected items. + Vous devez sélectionner une action à executer sur les objets sélectionnés. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Un problème est survenu lors de la suppression des objets sélectionnés car certains objets n'existent plus. + + + The selected items have been deleted successfully. + Les objets sélectionnés ont été supprimés avec succès. + + + A problem occurs when deleting the selected items. + Un problème est survenu lors de la suppression des objets sélectionnés. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.hr.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.hr.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Novo + + + Edit + Uredi + + + Delete + Obriši + + + List + Lista + + + Save + Spremi + + + Save and add + Spremi i dodaj + + + Cancel + Odustani + + + + + Reset + Poništi + + + Filter + Filtriraj + + + + + No result + Nema rezultata + + + Actions + Akcije + + + (page %%page%%/%%nb_pages%%) + (stranica %%page%%/%%nb_pages%%) + + + asc + rastuće + + + desc + padajuće + + + + + First page + Prva stranica + + + Previous page + Prethodna stranica + + + Next page + Sljedeća stranica + + + Last page + Zadnja stranica + + + + + The item was created successfully. + Stavka je uspješno kreirana. + + + The item was updated successfully. + Izmjene su spremljene. + + + The item was created successfully. You can add another one below. + Stavka uspješno kreirana. Možete dodati sljedeću. + + + The item was updated successfully. You can add another one below. + Izmjene su spremljene. Možete dodati sljedeću stavku. + + + The item has not been saved due to some errors. + Stavka nije spremljena zbog greške. + + + The item was deleted successfully. + Stavka uspješno izbrisana. + + + You must at least select one item. + Morate izabrati barem jednu stavku. + + + You must select an action to execute on the selected items. + Morate izabrati akciju koja će se izvršiti na izabranim stavkama. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Ne mogu izbrisati izabrane stavke jer neke više ne postoje. + + + The selected items have been deleted successfully. + Izabrane stavke su uspješno obrisane. + + + A problem occurs when deleting the selected items. + Ne mogu izbrisati izabrane stavke zbog greške. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.hu.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.hu.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Új + + + Edit + Szerkesztés + + + Delete + Törlés + + + List + Lista + + + Save + Mentés + + + Save and add + Mentés és új elem + + + Cancel + Mégsem + + + + + Reset + Alapértelmezett + + + Filter + Szűrés + + + + + No result + Nincs találat. + + + Actions + Műveletek + + + (page %%page%%/%%nb_pages%%) + (oldal %%page%%/%%nb_pages%%) + + + asc + növekvő + + + desc + csökkenő + + + + + First page + Első oldal + + + Previous page + Előző oldal + + + Next page + Következő oldal + + + Last page + Utolsó oldal + + + + + The item was created successfully. + Az elem létrehozása sikeres volt. + + + The item was updated successfully. + Az elem mentése sikeres volt. + + + The item was created successfully. You can add another one below. + Az elem létrehozása sikeres volt. Újabb létrehozása az alábbi adatlapon. + + + The item was updated successfully. You can add another one below. + Az elem mentése sikeres volt. Újabb létrehozása az alábbi adatlapon. + + + The item has not been saved due to some errors. + Az elem mentése hiba miatt sikertelen volt. + + + The item was deleted successfully. + Az elem törlése sikeres volt. + + + You must at least select one item. + Legalább egy elemet ki kell választani. + + + You must select an action to execute on the selected items. + Válassza ki a kiválasztott elemeken végrehajtandó műveletet. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Probléma lépett fel a kiválasztott elemek törlése közben, valamely elem már eleve nem létezett. + + + The selected items have been deleted successfully. + A kiválasztott elemek törlése sikeres volt. + + + A problem occurs when deleting the selected items. + Probléma lépett fel a kiválasztott elemek törlése közben. + + + + \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.id.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.id.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Buat Baru + + + Edit + Sunting + + + Delete + Hapus + + + List + Indeks + + + Save + Simpan + + + Save and add + Simpan dan tambah baru + + + Cancel + Batalkan + + + + + Reset + Kembalikan seperti semula + + + Filter + Filter + + + + + No result + Tak ada hasil + + + Actions + Aksi + + + (page %%page%%/%%nb_pages%%) + (halaman %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + + + First page + Halaman pertama + + + Previous page + Halaman sebelumnya + + + Next page + Halaman berikut + + + Last page + Halaman terakhir + + + + + The item was created successfully. + Data telah berhasil dibuat. + + + The item was updated successfully. + Data telah berhasil diperbaharui. + + + The item was created successfully. You can add another one below. + Data telah berhasil dibuat. Anda dapat menambahkan data baru di bawah ini. + + + The item was updated successfully. You can add another one below. + Data telah berhasil diperbaharui. Anda dapat menambahkan data baru di bawah ini. + + + The item has not been saved due to some errors. + Data gagal disimpan karena adanya kesalahan. + + + The item was deleted successfully. + Data telah berhasil dihapus. + + + You must at least select one item. + Anda harus memilih paling tidak satu data. + + + You must select an action to execute on the selected items. + Anda harus memilih sebuah aksi pada data yang telah terpilih. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Terjadi masalah pada saat akan menghapus data yang terpilih karena beberapa data tidak lagi tersedia. + + + The selected items have been deleted successfully. + Data yang terpilih telah berhasil dihapus. + + + A problem occurs when deleting the selected items. + Terjadi masalah pada saat akan menghapus data yang terpilih. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.it.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.it.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ + + + + +
    + + + + New + Nuovo + + + Edit + Modifica + + + Delete + Cancella + + + List + Lista + + + Save + Salva + + + Save and add + Salva e aggiungi + + + Cancel + Annulla + + + Choose an action + Scegli un'azione + + + go + ok + + + + + Reset + Reset + + + Filter + Filtra + + + + + No result + Nessun risultato + + + Actions + Azioni + + + (page %%page%%/%%nb_pages%%) + (pagina %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + disc + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] nessun risultato|[1] 1 risultato|(1,+Inf] %1% risultati + + + + + First page + Prima pagina + + + Previous page + Pagina precedente + + + Next page + Pagina seguente + + + Last page + Ultima pagina + + + + + The item was created successfully. + L'elemento è stato creato con successo. + + + The item was updated successfully. + L'elemento è stato aggiornato con successo. + + + The item was created successfully. You can add another one below. + L'elemento è stato creato con successo. Puoi aggiungerne un altro di seguito. + + + The item was updated successfully. You can add another one below. + L'elemento è stato aggiornato con successo. Puoi aggiungerne un altro di seguito. + + + The item has not been saved due to some errors. + L'elemento non è stato salvato a causa di qualche errore. + + + The item was deleted successfully. + L'elemento è stato cancellato con successo. + + + You must at least select one item. + Selezionare almeno un elemento. + + + You must select an action to execute on the selected items. + Selezionare un'azione da eseguire sugli elementi selezionati. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Si è verificato un problema durante la cancellazione degli elementi selezionati, alcuni elementi non esistono più. + + + The selected items have been deleted successfully. + Gli elementi selezionati sono stati cancellati. + + + A problem occurs when deleting the selected items. + Si è verificato un problema durante la cancellazione degli elementi selezionati. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ja.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ja.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ + + + + +
    + + + + New + æ–°è¦ä½œæˆ + + + Edit + 編集 + + + Delete + 削除 + + + List + 一覧 + + + Save + ä¿å­˜ + + + Save and add + ä¿å­˜ã—ã¦æ›´ã«è¿½åŠ  + + + Cancel + キャンセル + + + + + Reset + リセット + + + Filter + 検索 + + + + + No result + データãŒã‚りã¾ã›ã‚“ + + + Actions + æ“作 + + + (page %%page%%/%%nb_pages%%) + (ページ %%page%%%%nb_pages%%) + + + asc + é™é † + + + desc + 昇順 + + + + + First page + 最åˆã®ãƒšãƒ¼ã‚¸ + + + Previous page + å‰ã®ãƒšãƒ¼ã‚¸ + + + Next page + 次ã®ãƒšãƒ¼ã‚¸ + + + Last page + 最後ã®ãƒšãƒ¼ã‚¸ + + + + + The item was created successfully. + アイテムを作æˆã—ã¾ã—㟠+ + + The item was updated successfully. + アイテムを更新ã—ã¾ã—㟠+ + + The item was created successfully. You can add another one below. + アイテムを作æˆã—ã¾ã—ãŸã€‚以下ã§åˆ¥ã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’追加ã§ãã¾ã™ã€‚ + + + The item was updated successfully. You can add another one below. + アイテムを更新ã—ã¾ã—ãŸã€‚以下ã§åˆ¥ã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’追加ã§ãã¾ã™ã€‚ + + + The item has not been saved due to some errors. + エラーã®ãŸã‚アイテムをä¿å­˜ã§ãã¾ã›ã‚“ã§ã—㟠+ + + The item was deleted successfully. + アイテムを削除ã—ã¾ã—㟠+ + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.lt.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.lt.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Naujas + + + Edit + Redaguoti + + + Delete + Å alinti + + + List + SÄ…raÅ¡as + + + Save + IÅ¡saugoti + + + Save and add + IÅ¡saugoti ir pridÄ—ti + + + Cancel + AtÅ¡aukti + + + + + Reset + Atstatyti + + + Filter + Filtruoti + + + + + No result + Rezultatų nerasta + + + Actions + Veiksmai + + + (page %%page%%/%%nb_pages%%) + (puslapis %%page%%/%%nb_pages%%) + + + asc + didÄ—janÄiai + + + desc + mažėjanÄiai + + + + + First page + Pirmas puslapis + + + Previous page + Ankstesnis puslapis + + + Next page + Kitas puslapis + + + Last page + Paskutinis puslapis + + + + + The item was created successfully. + Sukurta sÄ—kmingai. + + + The item was updated successfully. + Atnaujinta sÄ—kmingai. + + + The item was created successfully. You can add another one below. + Sukurta sÄ—kmingai. NaujÄ… galite pridÄ—ti žemiau. + + + The item was updated successfully. You can add another one below. + Ataujinta sÄ—kmingai. NaujÄ… galite pridÄ—ti žemiau. + + + The item has not been saved due to some errors. + IÅ¡saugoti nepavyko dÄ—l esanÄių klaidų. + + + The item was deleted successfully. + PaÅ¡alinta sÄ—kmingai. + + + You must at least select one item. + Turite pasirinkti bent vienÄ… elementÄ…. + + + You must select an action to execute on the selected items. + Turite pasirinkti veiksmÄ…, kurį norite atlikti su pasirinktais elementais. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Nepavyko paÅ¡alinti pasirinktų elementų, kadangi kai kurie elementai jau nebeegzistuoja. + + + The selected items have been deleted successfully. + Pasirinkti elementai paÅ¡alinti sÄ—kmingai. + + + A problem occurs when deleting the selected items. + Nepavyko paÅ¡alinti pasirinktų elementų. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.lv.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.lv.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Jauns + + + Edit + Rediģēt + + + Delete + DzÄ“st + + + List + Saraksts + + + Save + SaglabÄt + + + Save and add + SaglabÄt un pievienot + + + Cancel + Atcelt + + + + + Reset + AtiestatÄ«t + + + Filter + FiltrÄ“t + + + + + No result + Nav datu + + + Actions + DarbÄ«bas + + + (page %%page%%/%%nb_pages%%) + (lapa %%page%%/%%nb_pages%%) + + + asc + augoÅ¡i + + + desc + dilstoÅ¡i + + + + + First page + PirmÄ lapa + + + Previous page + IepriekÅ¡ejÄ lapa + + + Next page + NÄkamÄ lapa + + + Last page + PÄ“dÄ“jÄ lapa + + + + + The item was created successfully. + Izveide sekmÄ«ga. + + + The item was updated successfully. + Rediģēšana sekmÄ«ga. + + + The item was created successfully. You can add another one below. + Izveide sekmÄ«ga, lai pievienotu vÄ“l vienu, lietojiet zemÄk esoÅ¡o formu. + + + The item was updated successfully. You can add another one below. + Rediģēšana sekmÄ«ga, lai pievienotu vÄ“l vienu, lietojiet zemÄk esoÅ¡o formu. + + + The item has not been saved due to some errors. + NeizdevÄs saglabÄt kļūdu dēļ. + + + The item was deleted successfully. + Dzēšana sekmÄ«ga. + + + You must at least select one item. + JÄiezÄ«mÄ“ vismaz viena vienÄ«ba. + + + You must select an action to execute on the selected items. + JÄnorÄda darbÄ«ba, kura veicama ar iezÄ«mÄ“tajÄm vienÄ«bÄm. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + ProblÄ“ma dzÄ“sot - visas vienÄ«bas vairs neeksistÄ“. + + + The selected items have been deleted successfully. + AtzÄ«mÄ“tÄs vienÄ«bas sekmÄ«gi izdzÄ“stas. + + + A problem occurs when deleting the selected items. + DzÄ“sot atzÄ«mÄ“tÄs vienÄ«bas notiek kļūda. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.nl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.nl.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,126 @@ + + + + +
    + + + + New + Nieuw + + + Edit + Wijzig + + + Delete + Verwijder + + + List + Lijst + + + Save + Opslaan + + + Save and add + Opslaan en Doorgaan + + + Cancel + Annuleren + + + Choose an action + Kies een optie + + + go + ok + + + + + Reset + Herstellen + + + Filter + Filteren + + + + + No result + Geen resultaat + + + Actions + Acties + + + (page %%page%%/%%nb_pages%%) + (pagina %%page%%/%%nb_pages%%) + + + asc + opl + + + desc + afl + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] geen resultaat|[1] 1 resultaat|(1,+Inf] %1% resultaten + + + + + First page + Eerste pagina + + + Previous page + Vorige pagina + + + Next page + Volgende pagina + + + Last page + Laatste pagina + + + + + The item was created successfully. + Het item is succesvol aangemaakt. + + + The item was updated successfully. + Het item is succesvol gewijzigd. + + + The item was created successfully. You can add another one below. + Het items is succesvol aangemaakt. Hieronder kan je nog een item toevoegen. + + + The item was updated successfully. You can add another one below. + Het item is succesvol gewijzigd. Hieronder kan je nog een item toevoegen. + + + The item has not been saved due to some errors. + Het item is niet opgeslagen vanwege fouten. + + + The item was deleted successfully. + Het item is succesvol verwijderd + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.no.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.no.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ + + + + +
    + + + + New + Ny + + + Edit + Rediger + + + Delete + Slett + + + List + Liste + + + Save + Lagre + + + Save and add + Lagre og opprett ny + + + Cancel + Avbryt + + + + + Reset + Tilbakestill + + + Filter + Filtrer + + + + + No result + Ingen resultater + + + Actions + Handlinger + + + (page %%page%%/%%nb_pages%%) + (side %%page%%/%%nb_pages%%) + + + asc + stigende + + + desc + synkende + + + + + First page + Første side + + + Previous page + Forrige side + + + Next page + Neste side + + + Last page + Siste side + + + + + The item was created successfully. + Nytt objekt opprettet. + + + The item was updated successfully. + Objekt oppdatert. + + + The item was created successfully. You can add another one below. + Objektet ble opprettet, du kan opprette et nytt nedenfor. + + + The item was updated successfully. You can add another one below. + Objekt oppdatert, du kan opprette et nytt nedenfor. + + + The item has not been saved due to some errors. + Objektet ble ikke lagret, grunnet noen feil. + + + The item was deleted successfully. + Objekt slettet. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.pl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.pl.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ + + + + +
    + + + + New + Nowy + + + Edit + Edytuj + + + Delete + Skasuj + + + List + Lista + + + Save + Zapisz + + + Save and add + Zapisz i dodaj + + + Cancel + Anuluj + + + Choose an action + Wybierz akcję + + + go + ok + + + + + Reset + Wyczyść + + + Filter + Szukaj + + + + + No result + Brak wyników. + + + Actions + Akcje + + + (page %%page%%/%%nb_pages%%) + (strona %%page%%/%%nb_pages%%) + + + asc + rosnąco + + + desc + malejąco + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] brak wyników|[1,+Inf] wyników: %1% + + + + + First page + Pierwsza strona + + + Previous page + Poprzednia strona + + + Next page + Następna strona + + + Last page + Ostatnia strona + + + + + The item was created successfully. + Obiekt został poprawnie utworzony. + + + The item was updated successfully. + Obiekt został poprawnie zaktualizowany. + + + The item was created successfully. You can add another one below. + Obiekt został poprawnie utworzony. Możesz teraz dodać kolejny. + + + The item was updated successfully. You can add another one below. + Obiekt został poprawnie zaktualizowany. Możesz teraz dodać kolejny. + + + The item has not been saved due to some errors. + Z powodu błędów obiekt nie został zapisany. + + + The item was deleted successfully. + Obiekt został poprawnie skasowany. + + + You must at least select one item. + Musisz wybrać co najmniej jeden obiekt. + + + You must select an action to execute on the selected items. + Musisz wybrać akcję do wykonania na wybranych obiektach. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Wystąpił błąd podczas usuwania wybranych obiektów, ponieważ niektóre już nie istnieją. + + + The selected items have been deleted successfully. + Wybrane obiekty zostały skasowane. + + + A problem occurs when deleting the selected items. + Wystąpił błąd podczas usuwania wybranych obiektów. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.pt.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.pt.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,135 @@ + + + + +
    + + + + New + Novo + + + Edit + Editar + + + Delete + Apagar + + + List + Listar + + + Save + Gravar + + + Save and add + Gravar e adicionar + + + Cancel + Cancelar + + + + + Reset + Eliminar + + + Filter + Filtrar + + + + + No result + Nenhum resultado. + + + Actions + Acções + + + (page %%page%%/%%nb_pages%%) + (página %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + + + First page + Primeira página + + + Previous page + Página anterior + + + Next page + Próxima página + + + Last page + Última página + + + + + The item was created successfully. + O objecto foi criado com sucesso. + + + The item was updated successfully. + O objecto foi actualizado com sucesso. + + + The item was created successfully. You can add another one below. + O objecto foi criado com sucesso. Poderá adicionar outro de seguida. + + + The item was updated successfully. You can add another one below. + O objecto foi actualizado com sucesso. Poderá adicionar outro de seguida. + + + The item has not been saved due to some errors. + O objecto não foi guardado devido a erros. + + + The item was deleted successfully. + O objecto foi apagado com sucesso. + + + You must at least select one item. + Deverá seleccionar pelo menos um objecto. + + + You must select an action to execute on the selected items. + Deverá selecionar uma acção para executar nos objectos seleccionados. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Um problema ocorreu ao apagar os objectos seleccionados devido à sua inexistência. + + + The selected items have been deleted successfully. + Os objectos seleccionados foram apagados com sucesso.. + + + A problem occurs when deleting the selected items. + Ocorreu um erro ao apagar os objectos seleccionados. + + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.pt_BR.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.pt_BR.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,138 @@ + + + + +
    + + + + New + Novo + + + Edit + Editar + + + Delete + Remover + + + List + Listar + + + Save + Salvar + + + Save and add + Salvar e Adicionar outro + + + Cancel + Cancelar + + + + + Reset + Limpar + + + Filter + Filtrar + + + + + No result + Nenhum resultado. + + + Actions + Ações + + + (page %%page%%/%%nb_pages%%) + (página %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + + + First page + Primeira página + + + Previous page + Página anterior + + + Next page + Próxima página + + + Last page + Última página + + + + + The item was created successfully. + Item adicionado com sucesso. + + + The item was updated successfully. + Item atualizado com sucesso. + + + The item was created successfully. You can add another one below. + Item adicionado com sucesso. Você pode adicionar outro abaixo. + + + The item was updated successfully. You can add another one below. + Item atualizado com sucesso. Você pode adicionar outro abaixo. + + + The item has not been saved due to some errors. + Item não atualizado devido a erros. + + + The item was deleted successfully. + Item removido com sucesso. + + + The item was deleted successfully. + Ãtem excluído com sucesso. + + + You must at least select one item. + Você deve selecionar pelo menos um ítem. + + + You must select an action to execute on the selected items. + Você deve selecionar uma ação a ser executada nos ítens selecionados. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Ocorreu um problema ao excluir os ítens selecionados pois alguns deles não existem mais. + + + The selected items have been deleted successfully. + Os ítens selecionados foram excluídos com sucesso. + + + A problem occurs when deleting the selected items. + Ocorreu um problema ao deletar os ítens selecionados. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ro.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ro.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,137 @@ + + + + + + + +
    + + + + New + Nou + + + Edit + Editare + + + Delete + Ştergere + + + List + Listare + + + Save + Salvare + + + Save and add + Salvare şi adăugare + + + Cancel + Anulare + + + + + Reset + Resetare + + + Filter + Filtrare + + + + + No result + Nici un rezultat. + + + Actions + Acţiuni + + + (page %%page%%/%%nb_pages%%) + (pagina %%page%%/%%nb_pages%%) + + + asc + asc + + + desc + desc + + + + + First page + Prima pagină + + + Previous page + Pagina precedentă + + + Next page + Pagina următoare + + + Last page + Ultima pagină + + + + + The item was created successfully. + Obiectul a fost creat cu succes. + + + The item was updated successfully. + Obiectul a fost actualizat cu succes. + + + The item was created successfully. You can add another one below. + Obiectul a fost creat cu succes. Puteţi să mai adăugaţi unul mai jos. + + + The item was updated successfully. You can add another one below. + Obiectul a fost actualizat cu succes. Puteţi să mai adăugaţi unul mai jos. + + + The item has not been saved due to some errors. + Obiectul n-a putut fi salvat. + + + The item was deleted successfully. + Obiectul a fost şters cu succes. + + + You must at least select one item. + Trebuie să selectaţi cel puţin un obiect. + + + You must select an action to execute on the selected items. + Trebuie să selectaţi o acţiune ce va fi executată asupra obiectelor selectate. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + A survenit o problemă la ştergerea obiectelor selectate deoarece o parte din acestea nu mai există. + + + The selected items have been deleted successfully. + Obiectele selectate au fost şterse cu succes. + + + A problem occurs when deleting the selected items. + A survenit o problemă la ştergerea obiectelor selectate. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ru.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.ru.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Создать + + + Edit + Редактировать + + + Delete + Удалить + + + List + СпиÑок + + + Save + Сохранить + + + Save and add + Сохранить и добавить + + + Cancel + Отмена + + + + + Reset + ОчиÑтить + + + Filter + Фильтр + + + + + No result + Ðет результатов + + + Actions + ДейÑÑ‚Ð²Ð¸Ñ + + + (page %%page%%/%%nb_pages%%) + (Ñтраница %%page%%/%%nb_pages%%) + + + asc + По возраÑтанию + + + desc + По убыванию + + + + + First page + ÐŸÐµÑ€Ð²Ð°Ñ Ñтраница + + + Previous page + ÐŸÑ€ÐµÐ´Ñ‹Ð´ÑƒÑ‰Ð°Ñ Ñтраница + + + Next page + Ð¡Ð»ÐµÐ´ÑƒÑŽÑ‰Ð°Ñ Ñтраница + + + Last page + ПоÑледнÑÑ Ñтраница + + + + + The item was created successfully. + Объект уÑпешно Ñоздан. + + + The item was updated successfully. + Объект уÑпешно изменен. + + + The item was created successfully. You can add another one below. + Объект уÑпешно Ñоздан. Ð’Ñ‹ можете добавить еще один. + + + The item was updated successfully. You can add another one below. + Объект уÑпешно обновлен. Ð’Ñ‹ можете добавить еще один. + + + The item has not been saved due to some errors. + Объект не Ñохранен из-за некоторых ошибок. + + + The item was deleted successfully. + Объект уÑпешно удален. + + + You must at least select one item. + Ð’Ñ‹ должны выделить как-минимум один объект. + + + You must select an action to execute on the selected items. + Ð’Ñ‹ должны выбрать дейÑтвие, которое будет выполнено Ñ Ð²Ñ‹Ð´ÐµÐ»ÐµÐ½Ð½Ñ‹Ð¼Ð¸ объектами. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Возникла проблемма при удалении выделенных объектов, так как некоторые объекты больше не ÑущеÑтвуют. + + + The selected items have been deleted successfully. + Выделенные объекты уÑпешно удалены. + + + A problem occurs when deleting the selected items. + Возникла проблемма при удалении выделенных объектов. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.sk.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.sk.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + VytvoriÅ¥ + + + Edit + UpraviÅ¥ + + + Delete + VymazaÅ¥ + + + List + Výpis + + + Save + UložiÅ¥ + + + Save and add + UložiÅ¥ a pridaÅ¥ + + + Cancel + ZruÅ¡iÅ¥ + + + + + Reset + ZruÅ¡iÅ¥ + + + Filter + FiltrovaÅ¥ + + + + + No result + Žiaden výsledok. + + + Actions + Akcie + + + (page %%page%%/%%nb_pages%%) + (stránka %%page%%/%%nb_pages%%) + + + asc + vzostupne + + + desc + zostupne + + + + + First page + Prvá stránka + + + Previous page + Predchádzajúca stránka + + + Next page + Nasledujúca stránka + + + Last page + Posledná stránka + + + + + The item was created successfully. + Položka bola úspeÅ¡ne vytvorená. + + + The item was updated successfully. + Položka bola úspeÅ¡ne upravená. + + + The item was created successfully. You can add another one below. + Položka bola úspeÅ¡ne vytvorená. Môžete pridaÅ¥ ÄalÅ¡iu. + + + The item was updated successfully. You can add another one below. + Položka bola úspeÅ¡ne upravená. Môžete pridaÅ¥ ÄalÅ¡iu. + + + The item has not been saved due to some errors. + Položka nebola uložená kôli niekoľkým chybám. + + + The item was deleted successfully. + Položka bola úspeÅ¡ne vymazaná. + + + You must at least select one item. + Prosím zvoľte si aspoň jednu položku. + + + You must select an action to execute on the selected items. + Prosím zvoľte si akciu na vykonanie s týmito položkami. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Vyskytol sa problem pri mazaní viacerých položiek, keÄže niektore z nich už neexistujú. + + + The selected items have been deleted successfully. + Vybrané položky boli úspeÅ¡ne vymazané. + + + A problem occurs when deleting the selected items. + Vyskytol sa problem pri mazaní zvolených položiek. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.sv.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.sv.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ + + + + +
    + + + + New + Ny + + + Edit + Redigera + + + Delete + Radera + + + List + Lista + + + Save + Spara + + + Save and add + Spara och skapa ny + + + Cancel + Avbryt + + + Choose an action + Välj en åtgärd + + + go + ok + + + + + Reset + Nollställ + + + Filter + Filtrera + + + + + No result + Inga resultat + + + Actions + Åtgärder + + + (page %%page%%/%%nb_pages%%) + (sida %%page%%/%%nb_pages%%) + + + asc + stigande + + + desc + fallande + + + [0] no result|[1] 1 result|(1,+Inf] %1% results + [0] inget resultat|[1] 1 resultat|(1,+Inf] %1% resultat + + + + + First page + Första sidan + + + Previous page + Föregående sida + + + Next page + Näste sida + + + Last page + Sista sidan + + + + + The item was created successfully. + Objekt skapades. + + + The item was updated successfully. + Objekt uppdaterat. + + + The item was created successfully. You can add another one below. + Objektet skapades. Du kan skapa ett nytt nedanför. + + + The item was updated successfully. You can add another one below. + Objektet uppdaterades. Du kan skapa ett nytt nedanför. + + + The item has not been saved due to some errors. + Objektet kunde inte sparas på grund av vissa fel. + + + The item was deleted successfully. + Objektet raderades. + + + You must at least select one item. + Du måste välja minst ett objekt + + + You must select an action to execute on the selected items. + Du måste välja en åtgärd att utföra på det valda objektet. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Ett problem uppstod när de valda objekten skulle raderas då vissa objekt inte existerar längre. + + + The selected items have been deleted successfully. + De valda objekten har raderats. + + + A problem occurs when deleting the selected items. + Ett problem uppstod när de valda objekten raderades. + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.tr.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.tr.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,135 @@ + + + + +
    + + + + New + Yeni + + + Edit + Düzenle + + + Delete + Sil + + + List + Liste + + + Save + Kaydet + + + Save and add + Kaydet ve ekle + + + Cancel + Vazgeç + + + + + Reset + Temizle + + + Filter + Filtrele + + + + + No result + Kayıt yok. + + + Actions + Eylemler + + + (page %%page%%/%%nb_pages%%) + (sayfa %%page%%/%%nb_pages%%) + + + asc + artan + + + desc + azalan + + + + + First page + İlk sayfa + + + Previous page + Önceki sayfa + + + Next page + Sonraki sayfa + + + Last page + Son sayfa + + + + + The item was created successfully. + Kayıt başarıyla oluşturuldu. + + + The item was updated successfully. + Kayıt başarıyla güncellendi. + + + The item was created successfully. You can add another one below. + Kayıt başarıyla oluşturuldu. Aşağıdan yeni bir tane ekleyebilirsiniz. + + + The item was updated successfully. You can add another one below. + Kayıt başarıyla güncellendi. Aşağıdan yeni bir tane ekleyebilirsiniz. + + + The item has not been saved due to some errors. + Bazı hatalar nedeniyle kayıt oluşturulamadı. + + + The item was deleted successfully. + Kayıt başarıyla silindi. + + + You must at least select one item. + En az bir kayıt seçmelisiniz. + + + You must select an action to execute on the selected items. + Seçilmiş kayıtlar üzerinde çalıştırılmak üzere bir eylem seçmelisiniz. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + Seçilmiş kayıtlar silinirken bir sorun oluştu, bazı kayıtlar artık bulunmuyor. + + + The selected items have been deleted successfully. + Seçilmiş kayıtlar başarıyla silindi. + + + A problem occurs when deleting the selected items. + Seçilmiş kayıtlar silinirken bir sorun oluştu. + + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.uk.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.uk.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ + + + + +
    + + + + New + Ðовий Ð·Ð°Ð¿Ð¸Ñ + + + Edit + Редагувати + + + Delete + Видалити + + + List + СпиÑок + + + Save + Зберегти + + + Save and add + Зберегти Ñ– додати + + + Cancel + Відмінити + + + + + Reset + Скинути + + + Filter + Фільтрувати + + + + + No result + Результат відÑутній + + + Actions + Дії + + + (page %%page%%/%%nb_pages%%) + (Ñторінка %%page%%/%%nb_pages%%) + + + asc + (Ð-Я) + + + desc + (Я-Ð) + + + + + First page + Перша Ñторінка + + + Previous page + ÐŸÐ¾Ð¿ÐµÑ€ÐµÐ´Ð½Ñ Ñторінка + + + Next page + ÐаÑтупна Ñторінка + + + Last page + ОÑÑ‚Ð°Ð½Ð½Ñ Ñторінка + + + + + The item was created successfully. + Ð—Ð°Ð¿Ð¸Ñ Ñтворено уÑпішно. + + + The item was updated successfully. + Ð—Ð°Ð¿Ð¸Ñ Ð·Ð¼Ñ–Ð½ÐµÐ½Ð¾ уÑпішно. + + + The item was created successfully. You can add another one below. + Ð—Ð°Ð¿Ð¸Ñ Ñтворено уÑпішно. Можете додати наÑтупний. + + + The item was updated successfully. You can add another one below. + Ð—Ð°Ð¿Ð¸Ñ Ð·Ð¼Ñ–Ð½ÐµÐ½Ð¾ уÑпішно. Можете додати наÑтупний. + + + The item has not been saved due to some errors. + Ð—Ð°Ð¿Ð¸Ñ Ð½Ðµ було збережено через помилки. + + + The item was deleted successfully. + Ð—Ð°Ð¿Ð¸Ñ Ð·Ð½Ð¸Ñ‰ÐµÐ½Ð¾ уÑпішно. + + + You must at least select one item. + Ви повинні вибрати принаймні один запиÑ. + + + You must select an action to execute on the selected items. + Ви повинні вибрати дію, що буде виконана над позначеними запиÑами. + + + A problem occurs when deleting the selected items as some items do not exist anymore. + ДеÑкі запиÑи Ñеред вибраних Ð´Ð»Ñ Ð·Ð½Ð¸Ñ‰ÐµÐ½Ð½Ñ Ð²Ð¶Ðµ відÑутні. + + + The selected items have been deleted successfully. + Позначені запиÑи знищено уÑпішно. + + + A problem occurs when deleting the selected items. + При видаленні позначених запиÑів виникла помилка. + + + + \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.zh_CN.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/i18n/sf_admin.zh_CN.xml Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,135 @@ + + + + +
    + + + + New + 新建 + + + Edit + 编辑 + + + Delete + 删除 + + + List + 列表 + + + Save + ä¿å­˜ + + + Save and add + ä¿å­˜å¹¶ç»§ç»­æ·»åŠ  + + + Cancel + 返回 + + + + + Reset + é‡è®¾ + + + Filter + 过滤器 + + + + + No result + æ²¡æœ‰æ•°æ® + + + Actions + æ“作 + + + (page %%page%%/%%nb_pages%%) + (é¡µç  %%page%%/%%nb_pages%%) + + + asc + é¡ºåº + + + desc + é€†åº + + + + + First page + 首页 + + + Previous page + 上一页 + + + Next page + 下一页 + + + Last page + 尾页 + + + + + The item was created successfully. + 内容创建æˆåŠŸã€‚ + + + The item was updated successfully. + 内容已更新。 + + + The item was created successfully. You can add another one below. + 内容已创建,将继续创建新内容。 + + + The item was updated successfully. You can add another one below. + 内容已更新,将继续创建新内容。 + + + The item has not been saved due to some errors. + 有错误,内容ä¿å­˜å¤±è´¥ã€‚ + + + The item was deleted successfully. + 内容已删除。 + + + You must at least select one item. + 至少è¦é€‰æ‹©ä¸€é¡¹ã€‚ + + + You must select an action to execute on the selected items. + 请选å–一个针对该æ¡ç›®çš„æ“ä½œã€‚ + + + A problem occurs when deleting the selected items as some items do not exist anymore. + ä¸èƒ½åˆ é™¤ä¸å­˜åœ¨çš„æ¡ç›®ã€‚ + + + The selected items have been deleted successfully. + 选定的æ¡ç›®å·²åˆ é™¤ã€‚ + + + A problem occurs when deleting the selected items. + 在删除过程中å‘生错误。 + + + + + diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/cli/sfDoctrineCli.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/cli/sfDoctrineCli.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,71 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrineCli + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineCli.class.php 13851 2008-12-08 22:54:16Z Jonathan.Wage $ + */ +class sfDoctrineCli extends Doctrine_Cli +{ + protected $dispatcher, + $formatter; + + /** + * Set the dispatcher of the cli instance + * + * @param object $dispatcher + * @return void + */ + public function setDispatcher($dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Set the formatter to use for the cli + * + * @param object $formatter + * @return void + */ + public function setFormatter($formatter) + { + $this->formatter = $formatter; + } + + /** + * Notify the dispatcher of a message. We silent the messages from the Doctrine cli. + * + * @param string $notification + * @param string $style + * @return false + */ + public function notify($notification = null, $style = 'HEADER') + { + $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('doctrine', $notification)))); + } + + /** + * Notify symfony of an exception thrown by the Doctrine cli + * + * @param Doctrine_Exception $exception + * @return void + * @throws sfException + */ + public function notifyException($exception) + { + throw new sfException($exception->getMessage()); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/database/sfDoctrineConnectionListener.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/database/sfDoctrineConnectionListener.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Standard connection listener + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineConnectionListener.class.php 11878 2008-09-30 20:14:40Z Jonathan.Wage $ + */ +class sfDoctrineConnectionListener extends Doctrine_EventListener +{ + public function __construct($connection, $encoding) + { + $this->connection = $connection; + $this->encoding = $encoding; + } + + public function postConnect(Doctrine_Event $event) + { + $this->connection->setCharset($this->encoding); + $this->connection->setDateFormat(); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/database/sfDoctrineDataRetriever.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/database/sfDoctrineDataRetriever.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,41 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Doctrine data retriever. Used to assist helpers with retrieving data for + * selector options. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineDataRetriever.class.php 12089 2008-10-08 20:23:25Z Jonathan.Wage $ + */ +class sfDoctrineDataRetriever +{ + /** + * Used internally by symfony for retrieving objects for selector helper options. + * + * @param string $model Name of the model to retrieve the objects from. + * @param string $peerMethod Name of the peer method to invoke on the Doctrine_Table instance for the model. + */ + static public function retrieveObjects($class, $peerMethod = 'findAll') + { + if (!$peerMethod) + { + $peerMethod = 'findAll'; + } + + $table = Doctrine::getTable($class); + + return call_user_func(array($table, $peerMethod)); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/database/sfDoctrineDatabase.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/database/sfDoctrineDatabase.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,130 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * A symfony database driver for Doctrine. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineDatabase.class.php 14977 2009-01-26 23:11:38Z Jonathan.Wage $ + */ +class sfDoctrineDatabase extends sfDatabase +{ + /** + * Instance of the Doctrine_Connection for this instance of sfDoctrineDatabase. + * Connection can be accessed by the getDoctrineConnection() accessor method. + * + * @var Doctrine_Connection $_doctrineConnection + */ + protected $_doctrineConnection = null; + + /** + * Initialize a sfDoctrineDatabase connection with the given parameters. + * + * + * $parameters = array( + * 'name' => 'doctrine', + * 'dsn' => 'sqlite:////path/to/sqlite/db'); + * + * $p = new sfDoctrineDatabase($parameters); + * + * + * @param array $parameters Array of parameters used to initialize the database connection + * @return void + */ + public function initialize($parameters = array()) + { + parent::initialize($parameters); + + if (!is_null($this->_doctrineConnection)) + { + return; + } + + $dsn = $this->getParameter('dsn'); + $name = $this->getParameter('name'); + + // Make sure we pass non-PEAR style DSNs as an array + if ( !strpos($dsn, '://')) + { + $dsn = array($dsn, $this->getParameter('username'), $this->getParameter('password')); + } + + // Make the Doctrine connection for $dsn and $name + $this->_doctrineConnection = Doctrine_Manager::connection($dsn, $name); + $attributes = $this->getParameter('attributes', array()); + foreach ($attributes as $name => $value) + { + $this->_doctrineConnection->setAttribute($name, $value); + } + + $encoding = $this->getParameter('encoding', 'UTF8'); + $eventListener = new sfDoctrineConnectionListener($this->_doctrineConnection, $encoding); + $this->_doctrineConnection->addListener($eventListener); + + // Load Query Logger Listener + if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) + { + $this->_doctrineConnection->addListener(new sfDoctrineLogger()); + } + + // Invoke the configuration methods for the connection if they exist + $configuration = sfProjectConfiguration::getActive(); + + $method = sprintf('configureDoctrineConnection%s', ucwords($this->_doctrineConnection->getName())); + + if (method_exists($configuration, 'configureDoctrineConnection') && ! method_exists($configuration, $method)) + { + $configuration->configureDoctrineConnection($this->_doctrineConnection); + } + + if (method_exists($configuration, $method)) + { + $configuration->$method($this->_doctrineConnection); + } + } + + /** + * Get the Doctrine_Connection instance. + * + * @return Doctrine_Connection $conn + */ + public function getDoctrineConnection() + { + return $this->_doctrineConnection; + } + + /** + * Initializes the connection and sets it to object. + * + * @return void + */ + public function connect() + { + $this->connection = $this->_doctrineConnection->getDbh(); + } + + /** + * Execute the shutdown procedure. + * + * @return void + */ + public function shutdown() + { + if ($this->connection !== null) + { + $this->connection = null; + $this->_doctrineConnection = null; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/debug/sfWebDebugPanelDoctrine.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/debug/sfWebDebugPanelDoctrine.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,168 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfWebDebugPanelDoctrine adds a panel to the web debug toolbar with Doctrine information. + * + * @package symfony + * @subpackage debug + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfWebDebugPanelDoctrine.class.php 11205 2008-08-27 16:24:17Z fabien $ + */ +class sfWebDebugPanelDoctrine extends sfWebDebugPanel +{ + /** + * Constructor. + * + * @param sfWebDebug $webDebug The web debut toolbar instance + */ + public function __construct(sfWebDebug $webDebug) + { + parent::__construct($webDebug); + + $this->webDebug->getEventDispatcher()->connect('debug.web.filter_logs', array($this, 'filterLogs')); + } + + /** + * Get the title/icon for the panel + * + * @return string $html + */ + public function getTitle() + { + if ($sqlLogs = $this->getSqlLogs()) + { + return 'SQL queries '.count($sqlLogs); + } + } + + /** + * Get the verbal title of the panel + * + * @return string $title + */ + public function getPanelTitle() + { + return 'SQL queries'; + } + + /** + * Get the html content of the panel + * + * @return string $html + */ + public function getPanelContent() + { + return ' +
    +
    1. '.implode("
    2. \n
    3. ", $this->getSqlLogs()).'
    +
    + '; + } + + /** + * Filter the logs to only include the entries from sfDoctrineLogger + * + * @param sfEvent $event + * @param array $Logs + * @return array $newLogs + */ + public function filterLogs(sfEvent $event, $newSqlogs) + { + $newLogs = array(); + foreach ($newSqlogs as $newSqlog) + { + if ('sfDoctrineLogger' != $newSqlog['type']) + { + $newLogs[] = $newSqlog; + } + } + + return $newLogs; + } + + /** + * Hook to allow the loading of the Doctrine webdebug toolbar with the rest of the panels + * + * @param sfEvent $event + * @return void + */ + static public function listenToAddPanelEvent(sfEvent $event) + { + $event->getSubject()->setPanel('db', new self($event->getSubject())); + } + + /** + * Build the sql logs and return them as an array + * + * @return array $newSqlogs + */ + protected function getSqlLogs() + { + $logs = array(); + $bindings = array(); + $i = 0; + foreach ($this->webDebug->getLogger()->getLogs() as $log) + { + if ('sfDoctrineLogger' != $log['type']) + { + continue; + } + + if (preg_match('/^.*?(\b(?:SELECT|INSERT|UPDATE|DELETE)\b.*)$/', $log['message'], $match)) + { + $logs[$i++] = self::formatSql($match[1]); + $bindings[$i - 1] = array(); + } + else if (preg_match('/Binding (.*) at position (.+?) w\//', $log['message'], $match)) + { + $bindings[$i - 1][] = $match[2].' = '.$match[1]; + } + } + + foreach ($logs as $i => $log) + { + if (count($bindings[$i])) + { + $logs[$i] .= sprintf(' (%s)', implode(', ', $bindings[$i])); + } + } + + return $logs; + } + + /** + * Format a SQL with some colors on SQL keywords to make it more readable + * + * @param string $sql SQL string to format + * @return string $newSql The new formatted SQL string + */ + static protected function formatSql($sql) + { + $color = "#990099"; + $newSql = $sql; + $newSql = str_replace("SELECT ", "SELECT ",$newSql); + $newSql = str_replace("FROM ", "FROM ",$newSql); + $newSql = str_replace(" LEFT JOIN ", " LEFT JOIN ",$newSql); + $newSql = str_replace(" INNER JOIN ", " INNER JOIN ",$newSql); + $newSql = str_replace(" WHERE ", " WHERE ",$newSql); + $newSql = str_replace(" GROUP BY ", " GROUP BY ",$newSql); + $newSql = str_replace(" HAVING ", " HAVING ",$newSql); + $newSql = str_replace(" AS ", " AS ",$newSql); + $newSql = str_replace(" ON ", " ON ",$newSql); + $newSql = str_replace(" ORDER BY ", " ORDER BY ",$newSql); + $newSql = str_replace(" LIMIT ", " LIMIT ",$newSql); + $newSql = str_replace(" OFFSET ", " OFFSET ",$newSql); + + return $newSql; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,531 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfFormDoctrine.class.php 7845 2008-03-12 22:36:14Z fabien $ + */ + +/** + * sfFormDoctrine is the base class for forms based on Doctrine objects. + * + * @package symfony + * @subpackage form + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfFormDoctrine.class.php 7845 2008-03-12 22:36:14Z fabien $ + */ +abstract class sfFormDoctrine extends sfForm +{ + protected + $isNew = true, + $object = null; + + /** + * Constructor. + * + * @param BaseObject A Doctrine object used to initialize default values + * @param array An array of options + * @param string A CSRF secret (false to disable CSRF protection, null to use the global CSRF secret) + * + * @see sfForm + */ + public function __construct($object = null, $options = array(), $CSRFSecret = null) + { + $class = $this->getModelName(); + if (!$object) + { + $this->object = new $class(); + } + else + { + if (!$object instanceof $class) + { + throw new sfException(sprintf('The "%s" form only accepts a "%s" object.', get_class($this), $class)); + } + + $this->object = $object; + $this->isNew = !$this->object->exists(); + } + + parent::__construct(array(), $options, $CSRFSecret); + + $this->updateDefaultsFromObject(); + } + + /** + * Returns the default connection for the current model. + * + * @return Connection A database connection + */ + public function getConnection() + { + return Doctrine_Manager::getInstance()->getConnectionForComponent($this->getModelName()); + } + + /** + * Returns the current model name. + */ + abstract public function getModelName(); + + /** + * Returns true if the current form embeds a new object. + * + * @return Boolean true if the current form embeds a new object, false otherwise + */ + public function isNew() + { + $this->isNew = !$this->object->exists(); + + return $this->isNew; + } + + /** + * Embeds i18n objects into the current form. + * + * @param array $cultures An array of cultures + * @param string $decorator A HTML decorator for the embedded form + */ + public function embedI18n($cultures, $decorator = null) + { + if (!$this->isI18n()) + { + throw new sfException(sprintf('The model "%s" is not internationalized.', $this->getModelName())); + } + + $class = $this->getI18nFormClass(); + foreach ($cultures as $culture) + { + $i18nObject = $this->object->Translation[$culture]; + $i18n = new $class($i18nObject); + unset($i18n['id'], $i18n['lang']); + + $this->embedForm($culture, $i18n, $decorator); + } + } + + /** + * Returns the current object for this form. + * + * @return BaseObject The current object. + */ + public function getObject() + { + return $this->object; + } + + /** + * Binds the current form and save the to the database in one step. + * + * @param array An array of tainted values to use to bind the form + * @param array An array of uploaded files (in the $_FILES or $_GET format) + * @param Connection An optional Doctrine Connection object + * + * @return Boolean true if the form is valid, false otherwise + */ + public function bindAndSave($taintedValues, $taintedFiles = null, $con = null) + { + $this->bind($taintedValues, $taintedFiles); + if ($this->isValid()) + { + $this->save($con); + + return true; + } + + return false; + } + + /** + * Saves the current object to the database. + * + * The object saving is done in a transaction and handled by the doSave() method. + * + * If the form is not valid, it throws an sfValidatorError. + * + * @param Connection An optional Connection object + * + * @return BaseObject The current saved object + * + * @see doSave() + */ + public function save($con = null) + { + if (!$this->isValid()) + { + throw $this->getErrorSchema(); + } + + if (is_null($con)) + { + $con = $this->getConnection(); + } + + try + { + $con->beginTransaction(); + + $this->doSave($con); + + $con->commit(); + } + catch (Exception $e) + { + $con->rollback(); + + throw $e; + } + + return $this->object; + } + + /** + * Updates the values of the object with the cleaned up values. + * + * @param array $values An array of values + * + * @return BaseObject The current updated object + */ + public function updateObject($values = null) + { + if (is_null($values)) + { + $values = $this->values; + } + + $values = $this->processValues($values); + + $this->object->fromArray($values); + + // embedded forms + $this->updateObjectEmbeddedForms($values); + + return $this->object; + } + + /** + * Updates the values of the objects in embedded forms. + * + * @param array $values An array of values + * @param array $forms An array of forms + */ + public function updateObjectEmbeddedForms($values, $forms = null) + { + if (is_null($forms)) + { + $forms = $this->embeddedForms; + } + + foreach ($forms as $name => $form) + { + if (!isset($values[$name]) || !is_array($values[$name])) + { + continue; + } + + if ($form instanceof sfFormDoctrine) + { + $form->updateObject($values[$name]); + } + else + { + $this->updateObjectEmbeddedForms($values[$name], $form->getEmbeddedForms()); + } + } + } + + /** + * Processes cleaned up values with user defined methods. + * + * To process a value before it is used by the updateObject() method, + * you need to define an updateXXXColumn() method where XXX is the PHP name + * of the column. + * + * The method must return the processed value or false to remove the value + * from the array of cleaned up values. + * + * @return array An array of cleaned up values processed by the user defined methods + */ + public function processValues($values = null) + { + // see if the user has overridden some column setter + $valuesToProcess = $values; + foreach ($valuesToProcess as $field => $value) + { + $method = sprintf('update%sColumn', self::camelize($field)); + + if (method_exists($this, $method)) + { + if (false === $ret = $this->$method($value)) + { + unset($values[$field]); + } + else + { + $values[$field] = $ret; + } + } + else + { + // save files + if ($this->validatorSchema[$field] instanceof sfValidatorFile) + { + $values[$field] = $this->processUploadedFile($field, null, $valuesToProcess); + } + } + } + + return $values; + } + + /** + * Returns true if the current form has some associated i18n objects. + * + * @return Boolean true if the current form has some associated i18n objects, false otherwise + */ + public function isI18n() + { + return $this->getObject()->getTable()->hasTemplate('Doctrine_Template_I18n'); + } + + /** + * Returns the name of the i18n model. + * + * @return string The name of the i18n model + */ + public function getI18nModelName() + { + return $this->getObject()->getTable()->getTemplate('Doctrine_Template_I18n')->getI18n()->getOption('className'); + } + + /** + * Returns the name of the i18n form class. + * + * @return string The name of the i18n form class + */ + public function getI18nFormClass() + { + return $this->getI18nModelName() . 'Form'; + } + + /** + * Renders a form tag suitable for the related Doctrine object. + * + * The method is automatically guessed based on the Doctrine object: + * + * * if the object is new, the method is POST + * * if the object already exists, the method is PUT + * + * @param string $url The URL for the action + * @param array $attributes An array of HTML attributes + * + * @return string An HTML representation of the opening form tag + * + * @see sfForm + */ + public function renderFormTag($url, array $attributes = array()) + { + if (!isset($attributes['method'])) + { + $attributes['method'] = $this->isNew() ? 'post' : 'put'; + } + + return parent::renderFormTag($url, $attributes); + } + + /** + * Updates and saves the current object. + * + * If you want to add some logic before saving or save other associated objects, + * this is the method to override. + * + * @param Connection An optional Connection object + */ + protected function doSave($con = null) + { + if (is_null($con)) + { + $con = $this->getConnection(); + } + + $this->updateObject(); + + $this->object->save($con); + + // embedded forms + $this->saveEmbeddedForms($con); + } + + /** + * Saves embedded form objects. + * + * @param Connection $con An optional Connection object + * @param array $forms An array of forms + */ + public function saveEmbeddedForms($con = null, $forms = null) + { + if (is_null($con)) + { + $con = $this->getConnection(); + } + + if (is_null($forms)) + { + $forms = $this->embeddedForms; + } + + foreach ($forms as $form) + { + if ($form instanceof sfFormDoctrine) + { + $form->getObject()->save($con); + $form->saveEmbeddedForms($con); + } + else + { + $this->saveEmbeddedForms($con, $form->getEmbeddedForms()); + } + } + } + + /** + * Updates the default values of the form with the current values of the current object. + */ + protected function updateDefaultsFromObject() + { + // update defaults for the main object + if ($this->isNew()) + { + $this->setDefaults(array_merge($this->object->toArray(false), $this->getDefaults())); + } + else + { + $this->setDefaults(array_merge($this->getDefaults(), $this->object->toArray(false))); + } + + $defaults = $this->getDefaults(); + foreach ($this->embeddedForms as $name => $form) + { + if ($form instanceof sfFormDoctrine) + { + $form->updateDefaultsFromObject(); + $defaults[$name] = $form->getDefaults(); + } + } + $this->setDefaults($defaults); + } + + /** + * Saves the uploaded file for the given field. + * + * @param string $field The field name + * @param string $filename The file name of the file to save + * @param array $values An array of values + * + * @return string The filename used to save the file + */ + protected function processUploadedFile($field, $filename = null, $values = null) + { + if (!$this->validatorSchema[$field] instanceof sfValidatorFile) + { + throw new LogicException(sprintf('You cannot save the current file for field "%s" as the field is not a file.', $field)); + } + + if (is_null($values)) + { + $values = $this->values; + } + + if (isset($values[$field.'_delete']) && $values[$field.'_delete']) + { + $this->removeFile($field); + + return ''; + } + + if (!$values[$field]) + { + return $this->object->$field; + } + + // we need the base directory + if (!$this->validatorSchema[$field]->getOption('path')) + { + return $values[$field]; + } + + $this->removeFile($field); + + return $this->saveFile($field, $filename, $values[$field]); + } + + /** + * Removes the current file for the field. + * + * @param string $field The field name + */ + protected function removeFile($field) + { + if (!$this->validatorSchema[$field] instanceof sfValidatorFile) + { + throw new LogicException(sprintf('You cannot remove the current file for field "%s" as the field is not a file.', $field)); + } + + if (($directory = $this->validatorSchema[$field]->getOption('path')) && is_file($directory.$this->object->$field)) + { + unlink($directory.$this->object->$field); + } + } + + /** + * Saves the current file for the field. + * + * @param string $field The field name + * @param string $filename The file name of the file to save + * @param sfValidatedFile $file The validated file to save + * + * @return string The filename used to save the file + */ + protected function saveFile($field, $filename = null, sfValidatedFile $file = null) + { + if (!$this->validatorSchema[$field] instanceof sfValidatorFile) + { + throw new LogicException(sprintf('You cannot save the current file for field "%s" as the field is not a file.', $field)); + } + if (is_null($file)) + { + $file = $this->getValue($field); + } + + $method = sprintf('generate%sFilename', $field); + + if (!is_null($filename)) + { + return $file->save($filename); + } + else if (method_exists($this->object, $method)) + { + return $file->save($this->object->$method($file)); + } + else + { + return $file->save(); + } + } + + protected function camelize($text) + { + return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')")); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,278 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfFormFilterDoctrine is the base class for filter forms based on Doctrine objects. + * + * @package symfony + * @subpackage form + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfFormFilterDoctrine.class.php 11690 2008-09-20 19:50:03Z fabien $ + */ +abstract class sfFormFilterDoctrine extends sfFormFilter +{ + protected + $tableMethodName = null; + + /** + * Returns the current model name. + * + * @return string The model class name + */ + abstract public function getModelName(); + + /** + * Returns the fields and their filter type. + * + * @return array An array of fields with their filter type + */ + abstract public function getFields(); + + /** + * Get the name of the table method used to retrieve the query object for the filter + * + * @return string $tableMethodName + */ + public function getTableMethod() + { + return $this->tableMethodName; + } + + /** + * Set the name of the table method used to retrieve the query object for the filter + * + * @param string $tableMethodName + * @return void + */ + public function setTableMethod($tableMethodName) + { + $this->tableMethodName = $tableMethodName; + } + + /** + * Returns a Doctrine Query based on the current values form the form. + * + * @return Query A Doctrine Query object + */ + public function getQuery() + { + if (!$this->isValid()) + { + throw $this->getErrorSchema(); + } + + return $this->buildQuery($this->getValues()); + } + + /** + * Processes cleaned up values with user defined methods. + * + * To process a value before it is used by the buildQuery() method, + * you need to define an convertXXXValue() method where XXX is the PHP name + * of the column. + * + * The method must return the processed value or false to remove the value + * from the array of cleaned up values. + * + * @param array An array of cleaned up values to process + * + * @return array An array of cleaned up values processed by the user defined methods + */ + public function processValues($values) + { + // see if the user has overridden some column setter + $originalValues = $values; + foreach ($originalValues as $field => $value) + { + try + { + $method = sprintf('convert%sValue', self::camelize($field)); + } + catch (Exception $e) + { + // no a "real" column of this object + continue; + } + + if (method_exists($this, $method)) + { + if (false === $ret = $this->$method($value)) + { + unset($values[$field]); + } + else + { + $values[$field] = $ret; + } + } + } + + return $values; + } + + /** + * Builds a Doctrine Query based on the passed values. + * + * @param array An array of parameters to build the Query object + * + * @return Query A Doctrine Query object + */ + public function buildQuery(array $values) + { + $values = $this->processValues($values); + + $query = Doctrine::getTable($this->getModelName())->createQuery('r'); + + if ($this->tableMethodName) + { + $method = $this->tableMethodName; + $query = Doctrine::getTable($this->getModelName())->$method($query); + } + + foreach ($this->getFields() as $field => $type) + { + if (!isset($values[$field]) || is_null($values[$field]) || '' === $values[$field]) + { + continue; + } + + if ($this->getTable()->hasField($field)) + { + $method = sprintf('add%sColumnQuery', self::camelize($this->getFieldName($field))); + } else { + // not a "real" column + if (!method_exists($this, $method = sprintf('add%sColumnQuery', self::camelize($field)))) + { + throw new LogicException(sprintf('You must define a "%s" method to be able to filter with the "%s" field.', $method, $field)); + } + } + + if (method_exists($this, $method)) + { + $this->$method($query, $field, $values[$field]); + } + else + { + if (!method_exists($this, $method = sprintf('add%sQuery', $type))) + { + throw new LogicException(sprintf('Unable to filter for the "%s" type.', $type)); + } + + $this->$method($query, $field, $values[$field]); + } + } + + return $query; + } + + protected function addForeignKeyQuery(Doctrine_Query $query, $field, $value) + { + $fieldName = $this->getFieldName($field); + + if (is_array($value)) + { + $query->orWhereIn('r.' . $fieldName, $value); + } + else + { + $query->addWhere('r.' . $fieldName . ' = ?', $value); + } + } + + protected function addEnumQuery(Doctrine_Query $query, $field, $value) + { + $fieldName = $this->getFieldName($field); + + $query->addWhere('r.' . $fieldName . ' = ?', $value); + } + + protected function addTextQuery(Doctrine_Query $query, $field, $values) + { + $fieldName = $this->getFieldName($field); + + if (is_array($values) && isset($values['is_empty']) && $values['is_empty']) + { + $query->addWhere('r.' . $fieldName . ' IS NULL'); + } + else if (is_array($values) && isset($values['text']) && '' != $values['text']) + { + $query->addWhere('r.' . $fieldName . ' LIKE ?', '%' . $values['text'] . '%'); + } + } + + protected function addNumberQuery(Doctrine_Query $query, $field, $values) + { + $fieldName = $this->getFieldName($field); + + if (is_array($values) && isset($values['is_empty']) && $values['is_empty']) + { + $query->addWhere('r.' . $fieldName . ' IS NULL'); + } + else if (is_array($values) && isset($values['text']) && '' != $values['text']) + { + $query->addWhere('r.' . $fieldName . ' = ?', $values['text']); + } + } + + protected function addBooleanQuery(Doctrine_Query $query, $field, $value) + { + $fieldName = $this->getFieldName($field); + $query->addWhere('r.' . $fieldName . ' = ?', $value); + } + + protected function addDateQuery(Doctrine_Query $query, $field, $values) + { + $fieldName = $this->getFieldName($field); + + if (isset($values['is_empty']) && $values['is_empty']) + { + $query->addWhere('r.' . $fieldName . ' IS NULL'); + } + else + { + $criterion = null; + if (!is_null($values['from']) && !is_null($values['to'])) + { + $query->andWhere('r.' . $fieldName . ' >= ?', $values['from']); + $query->andWhere('r.' . $fieldName . ' <= ?', $values['to']); + } + else if (!is_null($values['from'])) + { + $query->andWhere('r.' . $fieldName . ' >= ?', $values['from']); + } + else if (!is_null($values['to'])) + { + $query->andWhere('r.' . $fieldName . ' <= ?', $values['to']); + } + } + } + + protected function getColName($field) + { + return $this->getTable()->getColumnName($field); + } + + protected function getFieldName($colName) + { + return $this->getTable()->getFieldName($colName); + } + + protected function camelize($text) + { + return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')")); + } + + protected function getTable() + { + return Doctrine::getTable($this->getModelName()); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineColumn.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineColumn.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,309 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Represents a Doctrine column + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineAdminColumn.class.php 12356 2008-10-23 21:54:50Z Jonathan.Wage $ + */ +class sfDoctrineColumn implements ArrayAccess +{ + /** + * Array mapping Doctrine column types to the native symfony type + */ + static $doctrineToSymfony = array( + 'boolean' => 'BOOLEAN', + 'string' => 'LONGVARCHAR', + 'integer' => 'INTEGER', + 'date' => 'DATE', + 'timestamp' => 'TIMESTAMP', + 'time' => 'TIME', + 'enum' => 'LONGVARCHAR', + 'float' => 'FLOAT', + 'double' => 'DOUBLE', + 'clob' => 'CLOB', + 'blob' => 'BLOB', + 'object' => 'LONGVARCHAR', + 'array' => 'LONGVARCHAR', + 'decimal' => 'DECIMAL', + ); + + /** + * Store the name of the related class for this column if it is + * a foreign key + * + * @var string + */ + protected $foreignClassName = null; + + /** + * Doctrine_Table instance this column belongs to + * + * @var Doctrine_Table $table + */ + protected $table = null; + + /** + * Field name of the column + * + * @var string + */ + protected $name = null; + + /** + * Definition of the column + * + * @var array $definition + */ + protected $definition = array(); + + public function __construct($name, Doctrine_Table $table) + { + $this->name = $name; + $this->table = $table; + $this->definition = $table->getDefinitionOf($name); + } + + /** + * Get the name of the column + * + * @return string $name + */ + public function getName() + { + return $this->table->getColumnName($this->name); + } + + /** + * Get the alias/field name + * + * @return string $fieldName + */ + public function getFieldName() + { + return $this->table->getFieldName($this->getName()); + } + + /** + * Get php name. Exists for backwards compatibility with propel orm + * + * @return string $fieldName + */ + public function getPhpName() + { + return $this->getFieldName(); + } + + /** + * Get the Doctrine type of the column + * + * @return void + */ + public function getDoctrineType() + { + return isset($this->definition['type']) ? $this->definition['type']:null; + } + + /** + * Get symfony type of the column + * + * @return void + */ + public function getType() + { + $doctrineType = $this->getDoctrineType(); + + // we simulate the CHAR/VARCHAR types to generate input_tags + if(($doctrineType == 'string') and ($this->getSize() < 256)) + { + return 'VARCHAR'; + } + + return $doctrineType ? self::$doctrineToSymfony[$doctrineType]:'VARCHAR'; + } + + /** + * Get size/length of the column + * + * @return void + */ + public function getSize() + { + return $this->definition['length']; + } + + public function getLength() + { + return $this->getSize(); + } + + /** + * Check if the column definition has a certain key + * + * @param string $key + * @return bool + */ + public function hasDefinitionKey($key) + { + return isset($this->definition[$key]) ? true:false; + } + + /** + * Get the value of a column definition key + * + * @param string $key + * @return array $definition + */ + public function getDefinitionKey($key) + { + if ($this->hasDefinitionKey($key)) + { + return $this->definition[$key]; + } else { + return false; + } + } + + /** + * Returns true of the column is not null and false if it is null + * + * @return boolean + */ + public function isNotNull() + { + if (isset($this->definition['notnull'])) + { + return $this->definition['notnull']; + } + if (isset($this->definition['notblank'])) + { + return $this->definition['notblank']; + } + return false; + } + + /** + * Returns true if the column is a primary key and false if it is not + * + * @return void + */ + public function isPrimaryKey() + { + if (isset($this->definition['primary'])) + { + return $this->definition['primary']; + } + return false; + } + + /** + * Returns true if this column is a foreign key and false if it is not + * + * @return boolean $isForeignKey + */ + public function isForeignKey() + { + if (isset($this->foreignClassName)) + { + return true; + } + + if ($this->isPrimaryKey()) + { + return false; + } + + foreach ($this->table->getRelations() as $relation) + { + if (strtolower($relation['local']) == strtolower($this->name)) + { + $this->foreignClassName = $relation['class']; + return true; + } + } + return false; + } + + /** + * Get the name of the related class for this column foreign key. + * + * @return string $foreignClassName + */ + public function getForeignClassName() + { + if ($this->isForeignKey()) + { + return $this->foreignClassName; + } else { + return false; + } + } + + /** + * If foreign key get the related Doctrine_Table object + * + * @return Doctrine_Table $table + */ + public function getForeignTable() + { + if ($this->isForeignKey()) + { + return Doctrine::getTable($this->foreignClassName); + } else { + return false; + } + } + + /** + * Set the Doctrine_Table object this column belongs to + * + * @param Doctrine_Table $table + * @return void + */ + public function setTable(Doctrine_Table $table) + { + $this->table = $table; + } + + /** + * Get the Doctrine_Table object this column belongs to + * + * @return Doctrine_Table $table + */ + public function getTable() + { + return $this->table; + } + + public function offsetExists($offset) + { + return isset($this->definition[$offset]); + } + + public function offsetSet($offset, $value) + { + $this->definition[$offset] = $value; + } + + public function offsetGet($offset) + { + return $this->definition[$offset]; + } + + public function offsetUnset($offset) + { + unset($this->definition[$offset]); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineFormFilterGenerator.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineFormFilterGenerator.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,334 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Doctrine filter form generator. + * + * This class generates a Doctrine filter forms. + * + * @package symfony + * @subpackage generator + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineFormFilterGenerator.class.php 11675 2008-09-19 15:21:38Z fabien $ + */ +class sfDoctrineFormFilterGenerator extends sfDoctrineFormGenerator +{ + /** + * Initializes the current sfGenerator instance. + * + * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance + */ + public function initialize(sfGeneratorManager $generatorManager) + { + parent::initialize($generatorManager); + + $this->setGeneratorClass('sfDoctrineFormFilter'); + } + + /** + * Generates classes and templates in cache. + * + * @param array $params The parameters + * + * @return string The data to put in configuration cache + */ + public function generate($params = array()) + { + $this->params = $params; + + if (!isset($this->params['connection'])) + { + throw new sfParseException('You must specify a "connection" parameter.'); + } + + if (!isset($this->params['model_dir_name'])) + { + $this->params['model_dir_name'] = 'model'; + } + + if (!isset($this->params['filter_dir_name'])) + { + $this->params['filter_dir_name'] = 'filter'; + } + + $models = $this->loadModels(); + + // create the project base class for all forms + $file = sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php'; + if (!file_exists($file)) + { + if (!is_dir(sfConfig::get('sf_lib_dir').'/filter/doctrine/base')) + { + mkdir(sfConfig::get('sf_lib_dir').'/filter/doctrine/base', 0777, true); + } + + file_put_contents($file, $this->evalTemplate('sfDoctrineFormFilterBaseTemplate.php')); + } + + $pluginPaths = $this->generatorManager->getConfiguration()->getAllPluginPaths(); + + // create a form class for every Doctrine class + foreach ($models as $model) + { + $this->table = Doctrine::getTable($model); + $this->modelName = $model; + + $baseDir = sfConfig::get('sf_lib_dir') . '/filter/doctrine'; + + $isPluginModel = $this->isPluginModel($model); + if ($isPluginModel) + { + $pluginName = $this->getPluginNameForModel($model); + $baseDir .= '/' . $pluginName; + } + + if (!is_dir($baseDir.'/base')) + { + mkdir($baseDir.'/base', 0777, true); + } + + file_put_contents($baseDir.'/base/Base'.$model.'FormFilter.class.php', $this->evalTemplate('sfDoctrineFormFilterGeneratedTemplate.php')); + if ($isPluginModel) + { + $pluginBaseDir = $pluginPaths[$pluginName].'/lib/filter/doctrine'; + if (!file_exists($classFile = $pluginBaseDir.'/Plugin'.$model.'FormFilter.class.php')) + { + if (!is_dir($pluginBaseDir)) + { + mkdir($pluginBaseDir, 0777, true); + } + file_put_contents($classFile, $this->evalTemplate('sfDoctrineFormFilterPluginTemplate.php')); + } + } + if (!file_exists($classFile = $baseDir.'/'.$model.'FormFilter.class.php')) + { + if ($isPluginModel) + { + file_put_contents($classFile, $this->evalTemplate('sfDoctrinePluginFormFilterTemplate.php')); + } else { + file_put_contents($classFile, $this->evalTemplate('sfDoctrineFormFilterTemplate.php')); + } + } + } + } + + /** + * Returns a sfWidgetForm class name for a given column. + * + * @param sfDoctrineColumn $column + * @return string The name of a subclass of sfWidgetForm + */ + public function getWidgetClassForColumn($column) + { + switch ($column->getDoctrineType()) + { + case 'boolean': + $name = 'Choice'; + break; + case 'date': + case 'datetime': + case 'timestamp': + $name = 'FilterDate'; + break; + case 'enum': + $name = 'Choice'; + break; + default: + $name = 'FilterInput'; + } + + if ($column->isForeignKey()) + { + $name = 'DoctrineChoice'; + } + + return sprintf('sfWidgetForm%s', $name); + } + + /** + * Returns a PHP string representing options to pass to a widget for a given column. + * + * @param sfDoctrineColumn $column + * @return string The options to pass to the widget as a PHP string + */ + public function getWidgetOptionsForColumn($column) + { + $options = array(); + + $withEmpty = sprintf('\'with_empty\' => %s', $column->isNotNull() ? 'false' : 'true'); + switch ($column->getDoctrineType()) + { + case 'boolean': + $options[] = "'choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')"; + break; + case 'date': + case 'datetime': + case 'timestamp': + $options[] = "'from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate()"; + $options[] = $withEmpty; + break; + case 'enum': + $values = array('' => ''); + $values = array_merge($values, $column['values']); + $values = array_combine($values, $values); + $options[] = "'choices' => " . str_replace("\n", '', $this->arrayExport($values)); + break; + } + + if ($column->isForeignKey()) + { + $options[] = sprintf('\'model\' => \'%s\', \'add_empty\' => true', $column->getForeignTable()->getOption('name')); + } + + return count($options) ? sprintf('array(%s)', implode(', ', $options)) : ''; + } + + /** + * Returns a sfValidator class name for a given column. + * + * @param sfDoctrineColumn $column + * @return string The name of a subclass of sfValidator + */ + public function getValidatorClassForColumn($column) + { + switch ($column->getDoctrineType()) + { + case 'boolean': + $name = 'Choice'; + break; + case 'float': + case 'decimal': + $name = 'Number'; + break; + case 'integer': + $name = 'Integer'; + break; + case 'date': + case 'datetime': + case 'timestamp': + $name = 'DateRange'; + break; + case 'enum': + $name = 'Choice'; + break; + default: + $name = 'Pass'; + } + + if ($column->isPrimarykey() || $column->isForeignKey()) + { + $name = 'DoctrineChoice'; + } + + return sprintf('sfValidator%s', $name); + } + + /** + * Returns a PHP string representing options to pass to a validator for a given column. + * + * @param sfDoctrineColumn $column + * @return string The options to pass to the validator as a PHP string + */ + public function getValidatorOptionsForColumn($column) + { + $options = array('\'required\' => false'); + + if ($column->isForeignKey()) + { + $columns = $column->getForeignTable()->getColumns(); + foreach ($columns as $name => $col) + { + if (isset($col['primary']) && $col['primary']) + { + break; + } + } + + $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $column->getForeignTable()->getOption('name'), $column->getForeignTable()->getFieldName($name)); + } + else if ($column->isPrimaryKey()) + { + $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->table->getOption('name'), $this->table->getFieldName($columnName)); + } + else + { + switch ($column->getDoctrineType()) + { + case 'boolean': + $options[] = "'choices' => array('', 1, 0)"; + break; + case 'date': + case 'datetime': + case 'timestamp': + $options[] = "'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false))"; + break; + case 'enum': + $values = array_combine($column['values'], $column['values']); + $options[] = "'choices' => " . str_replace("\n", '', $this->arrayExport($values)); + break; + } + } + + return count($options) ? sprintf('array(%s)', implode(', ', $options)) : ''; + } + + public function getValidatorForColumn($column) + { + $format = 'new %s(%s)'; + if (in_array($class = $this->getValidatorClassForColumn($column), array('sfValidatorInteger', 'sfValidatorNumber'))) + { + $format = 'new sfValidatorSchemaFilter(\'text\', new %s(%s))'; + } + + return sprintf($format, $class, $this->getValidatorOptionsForColumn($column)); + } + + public function getType($column) + { + if ($column->isForeignKey()) + { + return 'ForeignKey'; + } + + switch ($column->getDoctrineType()) + { + case 'enum': + return 'Enum'; + case 'boolean': + return 'Boolean'; + case 'date': + case 'datetime': + case 'timestamp': + return 'Date'; + case 'integer': + case 'decimal': + case 'float': + return 'Number'; + default: + return 'Text'; + } + } + + /** + * Array export. Export array to formatted php code + * + * @param array $values + * @return string $php + */ + protected function arrayExport($values) + { + $php = var_export($values, true); + $php = str_replace("\n", '', $php); + $php = str_replace('array ( ', 'array(', $php); + $php = str_replace(',)', ')', $php); + $php = str_replace(' ', ' ', $php); + return $php; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineFormGenerator.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineFormGenerator.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,624 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Doctrine form generator. + * + * This class generates a Doctrine forms. + * + * @package symfony + * @subpackage generator + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineFormGenerator.class.php 8512 2008-04-17 18:06:12Z fabien $ + */ +class sfDoctrineFormGenerator extends sfGenerator +{ + /** + * Array of all the loaded models + * + * @var array + */ + public $models = array(); + + /** + * Array of all plugin models + * + * @var array + */ + public $pluginModels = array(); + + /** + * Initializes the current sfGenerator instance. + * + * @param sfGeneratorManager A sfGeneratorManager instance + */ + public function initialize(sfGeneratorManager $generatorManager) + { + parent::initialize($generatorManager); + + $this->getPluginModels(); + $this->setGeneratorClass('sfDoctrineForm'); + } + + /** + * Generates classes and templates in cache. + * + * @param array The parameters + * + * @return string The data to put in configuration cache + */ + public function generate($params = array()) + { + $this->params = $params; + + if (!isset($this->params['connection'])) + { + throw new sfParseException('You must specify a "connection" parameter.'); + } + + if (!isset($this->params['model_dir_name'])) + { + $this->params['model_dir_name'] = 'model'; + } + + if (!isset($this->params['form_dir_name'])) + { + $this->params['form_dir_name'] = 'form'; + } + + $models = $this->loadModels(); + + // create the project base class for all forms + $file = sfConfig::get('sf_lib_dir').'/form/doctrine/BaseFormDoctrine.class.php'; + if (!file_exists($file)) + { + if (!is_dir(sfConfig::get('sf_lib_dir').'/form/doctrine/base')) + { + mkdir(sfConfig::get('sf_lib_dir').'/form/doctrine/base', 0777, true); + } + + file_put_contents($file, $this->evalTemplate('sfDoctrineFormBaseTemplate.php')); + } + + $pluginPaths = $this->generatorManager->getConfiguration()->getAllPluginPaths(); + + // create a form class for every Doctrine class + foreach ($models as $model) + { + $this->table = Doctrine::getTable($model); + $this->modelName = $model; + + $baseDir = sfConfig::get('sf_lib_dir') . '/form/doctrine'; + + $isPluginModel = $this->isPluginModel($model); + if ($isPluginModel) + { + $pluginName = $this->getPluginNameForModel($model); + $baseDir .= '/' . $pluginName; + } + + if (!is_dir($baseDir.'/base')) + { + mkdir($baseDir.'/base', 0777, true); + } + + file_put_contents($baseDir.'/base/Base'.$model.'Form.class.php', $this->evalTemplate('sfDoctrineFormGeneratedTemplate.php')); + if ($isPluginModel) + { + $pluginBaseDir = $pluginPaths[$pluginName].'/lib/form/doctrine'; + if (!file_exists($classFile = $pluginBaseDir.'/Plugin'.$model.'Form.class.php')) + { + if (!is_dir($pluginBaseDir)) + { + mkdir($pluginBaseDir, 0777, true); + } + file_put_contents($classFile, $this->evalTemplate('sfDoctrineFormPluginTemplate.php')); + } + } + if (!file_exists($classFile = $baseDir.'/'.$model.'Form.class.php')) + { + if ($isPluginModel) + { + file_put_contents($classFile, $this->evalTemplate('sfDoctrinePluginFormTemplate.php')); + } else { + file_put_contents($classFile, $this->evalTemplate('sfDoctrineFormTemplate.php')); + } + } + } + } + + /** + * Get all the models which are a part of a plugin and the name of the plugin. + * The array format is modelName => pluginName + * + * @todo This method is ugly and is a very weird way of finding the models which + * belong to plugins. If we could come up with a better way that'd be great + * @return array $pluginModels + */ + public function getPluginModels() + { + if (!$this->pluginModels) + { + $plugins = $this->generatorManager->getConfiguration()->getPlugins(); + $pluginPaths = $this->generatorManager->getConfiguration()->getAllPluginPaths(); + + foreach ($pluginPaths as $pluginName => $path) + { + if (!in_array($pluginName, $plugins)) + { + continue; + } + + foreach (sfFinder::type('file')->name('*.php')->in($path.'/lib/model/doctrine') as $path) + { + $info = pathinfo($path); + $e = explode('.', $info['filename']); + $modelName = substr($e[0], 6, strlen($e[0])); + + if (class_exists($e[0]) && class_exists($modelName)) + { + $parent = new ReflectionClass('Doctrine_Record'); + $reflection = new ReflectionClass($modelName); + if ($reflection->isSubClassOf($parent)) + { + $this->pluginModels[$modelName] = $pluginName; + $generators = Doctrine::getTable($modelName)->getGenerators(); + foreach ($generators as $generator) + { + $this->pluginModels[$generator->getOption('className')] = $pluginName; + } + } + } + } + } + } + + return $this->pluginModels; + } + + /** + * Check to see if a model is part of a plugin + * + * @param string $modelName + * @return boolean $bool + */ + public function isPluginModel($modelName) + { + return isset($this->pluginModels[$modelName]) ? true:false; + } + + /** + * Get the name of the plugin a model belongs to + * + * @param string $modelName + * @return string $pluginName + */ + public function getPluginNameForModel($modelName) + { + if ($this->isPluginModel($modelName)) + { + return $this->pluginModels[$modelName]; + } else { + return false; + } + } + + /** + * Returns an array of relations that represents a many to many relationship. + * + * A table is considered to be a m2m table if it has 2 foreign keys that are also primary keys. + * + * @return array An array of relations. + */ + public function getManyToManyRelations() + { + $relations = array(); + foreach ($this->table->getRelations() as $relation) + { + if ($relation->getType() === Doctrine_Relation::MANY && isset($relation['refTable'])) + { + $relations[] = $relation; + } + } + return $relations; + } + + /** + * Returns PHP names for all foreign keys of the current table. + * + * This method does not returns foreign keys that are also primary keys. + * + * @return array An array composed of: + * * The foreign table PHP name + * * The foreign key PHP name + * * A Boolean to indicate whether the column is required or not + * * A Boolean to indicate whether the column is a many to many relationship or not + */ + public function getForeignKeyNames() + { + $names = array(); + foreach ($this->table->getRelations() as $relation) + { + if ($relation->getType() === Doctrine_Relation::ONE) + { + $foreignDef = $relation->getTable()->getDefinitionOf($relation->getForeignFieldName()); + $names[] = array($relation['table']->getOption('name'), $relation->getForeignFieldName(), $this->isColumnNotNull($relation->getForeignFieldName(), $foreignDef), false); + } + } + + foreach ($this->getManyToManyRelations() as $relation) + { + $names[] = array($relation['table']->getOption('name'), $relation['alias'], false, true); + } + + return $names; + } + + /** + * Returns the first primary key column of the current table. + * + * @param ColumnMap A ColumnMap object + */ + public function getPrimaryKey() + { + foreach ($this->getColumns() as $column) + { + if ($column->isPrimaryKey()) + { + return $column; + } + } + } + + /** + * Returns a sfWidgetForm class name for a given column. + * + * @param sfDoctrineColumn $column + * @return string The name of a subclass of sfWidgetForm + */ + public function getWidgetClassForColumn($column) + { + switch ($column->getDoctrineType()) + { + case 'string': + if ($column->getLength() > 255) + { + $widgetSubclass = 'Textarea'; + } else { + $widgetSubclass = 'Input'; + } + break; + case 'boolean': + $widgetSubclass = 'InputCheckbox'; + break; + case 'blob': + case 'clob': + $widgetSubclass = 'Textarea'; + break; + case 'date': + $widgetSubclass = 'Date'; + break; + case 'time': + $widgetSubclass = 'Time'; + break; + case 'timestamp': + $widgetSubclass = 'DateTime'; + break; + case 'enum': + $widgetSubclass = 'Choice'; + break; + default: + $widgetSubclass = 'Input'; + } + + if ($column->isPrimaryKey()) + { + $widgetSubclass = 'InputHidden'; + } + else if ($column->isForeignKey()) + { + $widgetSubclass = 'DoctrineChoice'; + } + + return sprintf('sfWidgetForm%s', $widgetSubclass); + } + + /** + * Returns a PHP string representing options to pass to a widget for a given column. + * + * @param sfDoctrineColumn $column + * @return string The options to pass to the widget as a PHP string + */ + public function getWidgetOptionsForColumn($column) + { + $options = array(); + + if ($column->isForeignKey()) + { + $options[] = sprintf('\'model\' => \'%s\', \'add_empty\' => %s', $column->getForeignTable()->getOption('name'), $column->isNotNull() ? 'false' : 'true'); + } + else + { + switch ($column->getDoctrineType()) + { + case 'enum': + $values = $column->getDefinitionKey('values'); + $values = array_combine($values, $values); + $options[] = "'choices' => " . str_replace("\n", '', $this->arrayExport($values)); + break; + } + } + + return count($options) ? sprintf('array(%s)', implode(', ', $options)) : ''; + } + + /** + * Returns a sfValidator class name for a given column. + * + * @param sfDoctrineColumn $column + * @return string The name of a subclass of sfValidator + */ + public function getValidatorClassForColumn($column) + { + switch ($column->getDoctrineType()) + { + case 'boolean': + $validatorSubclass = 'Boolean'; + break; + case 'string': + if ($column->getDefinitionKey('email')) + { + $validatorSubclass = 'Email'; + } + else if ($column->getDefinitionKey('regexp')) + { + $validatorSubclass = 'Regex'; + } + else + { + $validatorSubclass = 'String'; + } + break; + case 'clob': + case 'blob': + $validatorSubclass = 'String'; + break; + case 'float': + case 'decimal': + $validatorSubclass = 'Number'; + break; + case 'integer': + $validatorSubclass = 'Integer'; + break; + case 'date': + $validatorSubclass = 'Date'; + break; + case 'time': + $validatorSubclass = 'Time'; + break; + case 'timestamp': + $validatorSubclass = 'DateTime'; + break; + case 'enum': + $validatorSubclass = 'Choice'; + break; + default: + $validatorSubclass = 'Pass'; + } + + if ($column->isPrimaryKey() || $column->isForeignKey()) + { + $validatorSubclass = 'DoctrineChoice'; + } + + return sprintf('sfValidator%s', $validatorSubclass); + } + + /** + * Returns a PHP string representing options to pass to a validator for a given column. + * + * @param sfDoctrineColumn $column + * @return string The options to pass to the validator as a PHP string + */ + public function getValidatorOptionsForColumn($column) + { + $options = array(); + + if ($column->isForeignKey()) + { + $options[] = sprintf('\'model\' => \'%s\'', $column->getForeignTable()->getOption('name')); + } + else if ($column->isPrimaryKey()) + { + $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->modelName, $column->getName()); + } + else + { + switch ($column->getDoctrineType()) + { + case 'string': + if ($column['length']) + { + $options[] = sprintf('\'max_length\' => %s', $column['length']); + } + if (isset($column['minlength'])) + { + $options[] = sprintf('\'min_length\' => %s', $column['minlength']); + } + if (isset($column['regexp'])) + { + $options[] = sprintf('\'pattern\' => \'%s\'', $column['regexp']); + } + break; + case 'enum': + $values = array_combine($column['values'], $column['values']); + $options[] = "'choices' => " . str_replace("\n", '', $this->arrayExport($values)); + break; + } + } + + if (!$column->isNotNull() || $column->isPrimaryKey()) + { + $options[] = '\'required\' => false'; + } + + return count($options) ? sprintf('array(%s)', implode(', ', $options)) : ''; + } + + /** + * Returns the maximum length for a column name. + * + * @return integer The length of the longer column name + */ + public function getColumnNameMaxLength() + { + $max = 0; + foreach ($this->getColumns() as $column) + { + if (($m = strlen($column->getFieldName())) > $max) + { + $max = $m; + } + } + + foreach ($this->getManyToManyRelations() as $relation) + { + if (($m = strlen($this->underscore($relation['alias']).'_list')) > $max) + { + $max = $m; + } + } + + return $max; + } + + /** + * Returns an array of primary key column names. + * + * @return array An array of primary key column names + */ + public function getPrimaryKeyColumNames() + { + return $this->table->getIdentifierColumnNames(); + } + + /** + * Returns a PHP string representation for the array of all primary key column names. + * + * @return string A PHP string representation for the array of all primary key column names + * + * @see getPrimaryKeyColumNames() + */ + public function getPrimaryKeyColumNamesAsString() + { + return sprintf('array(\'%s\')', implode('\', \'', $this->getPrimaryKeyColumNames())); + } + + /** + * Returns true if the current table is internationalized. + * + * @return Boolean true if the current table is internationalized, false otherwise + */ + public function isI18n() + { + return $this->table->hasRelation('Translation'); + } + + /** + * Returns the i18n model name for the current table. + * + * @return string The model class name + */ + public function getI18nModel() + { + return $this->table->getRelation('Translation')->getTable()->create(); + } + + public function underscore($name) + { + return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), '\\1_\\2', $name)); + } + + /** + * Get array of sfDoctrineColumn objects + * + * @return array $columns + */ + public function getColumns() + { + foreach (array_keys($this->table->getColumns()) as $name) + { + $columns[] = new sfDoctrineColumn($name, $this->table); + } + + return $columns; + } + + public function getUniqueColumnNames() + { + $uniqueColumns = array(); + + foreach ($this->getColumns() as $column) + { + if ($column->getDefinitionKey('unique')) + { + $uniqueColumns[] = array($column->getName()); + } + } + + $indexes = $this->table->getOption('indexes'); + foreach ($indexes as $name => $index) + { + if (isset($index['type']) && $index['type'] == 'unique') + { + $tmp = $index['fields']; + if (is_array(array_shift($tmp))) + { + $uniqueColumns[] = array_keys($index['fields']); + } else { + $uniqueColumns[] = $index['fields']; + } + } + } + + return $uniqueColumns; + } + + /** + * Loads all Doctrine builders. + */ + protected function loadModels() + { + Doctrine::loadModels($this->generatorManager->getConfiguration()->getModelDirs(), + Doctrine::MODEL_LOADING_CONSERVATIVE); + $models = Doctrine::getLoadedModels(); + $models = Doctrine::initializeModels($models); + $this->models = Doctrine::filterInvalidModels($models); + return $this->models; + } + + /** + * Array export. Export array to formatted php code + * + * @param array $values + * @return string $php + */ + protected function arrayExport($values) + { + $php = var_export($values, true); + $php = str_replace("\n", '', $php); + $php = str_replace('array ( ', 'array(', $php); + $php = str_replace(',)', ')', $php); + $php = str_replace(' ', ' ', $php); + return $php; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineGenerator.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/generator/sfDoctrineGenerator.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,282 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Doctrine generator. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineGenerator.class.php 12507 2008-10-31 18:26:58Z fabien $ + */ +class sfDoctrineGenerator extends sfModelGenerator +{ + protected + $table = null; + + /** + * Initializes the current sfGenerator instance. + * + * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance + */ + public function initialize(sfGeneratorManager $generatorManager) + { + parent::initialize($generatorManager); + + $this->setGeneratorClass('sfDoctrineModule'); + } + + /** + * Configures this generator. + */ + public function configure() + { + $this->table = Doctrine::getTable($this->modelClass); + + // load all primary keys + $this->loadPrimaryKeys(); + } + + /** + * Returns an array of tables that represents a many to many relationship. + * + * A table is considered to be a m2m table if it has 2 foreign keys that are also primary keys. + * + * @return array An array of tables. + */ + public function getManyToManyTables() + { + $relations = array(); + foreach ($this->table->getRelations() as $relation) + { + if ($relation->getType() === Doctrine_Relation::MANY && isset($relation['refTable'])) + { + $relations[] = $relation; + } + } + return $relations; + } + + /** + * Loads primary keys. + * + * @throws sfException + */ + protected function loadPrimaryKeys() + { + $this->primaryKey = array(); + foreach ($this->getColumns() as $name => $column) + { + if ($column->isPrimaryKey()) + { + $this->primaryKey[] = $name; + } + } + + if (!count($this->primaryKey)) + { + throw new sfException(sprintf('Cannot generate a module for a model without a primary key (%s)', $this->modelClass)); + } + } + + /** + * Returns the getter either non-developped: 'getFoo' or developped: '$class->getFoo()'. + * + * @param string $column The column name + * @param boolean $developed true if you want developped method names, false otherwise + * @param string $prefix The prefix value + * + * @return string PHP code + */ + public function getColumnGetter($column, $developed = false, $prefix = '') + { + $getter = 'get'.sfInflector::camelize($column); + if ($developed) + { + $getter = sprintf('$%s%s->%s()', $prefix, $this->getSingularName(), $getter); + } + + return $getter; + } + + /** + * Returns the type of a column. + * + * @param object $column A column object + * + * @return string The column type + */ + public function getType($column) + { + if ($column->isForeignKey()) + { + return 'ForeignKey'; + } + + switch ($column->getDoctrineType()) + { + case 'enum': + return 'Enum'; + case 'boolean': + return 'Boolean'; + case 'date': + case 'timestamp': + return 'Date'; + case 'time': + return 'Time'; + default: + return 'Text'; + } + } + + /** + * Returns the default configuration for fields. + * + * @return array An array of default configuration for all fields + */ + public function getDefaultFieldsConfiguration() + { + $fields = array(); + + $names = array(); + foreach ($this->getColumns() as $name => $column) + { + $names[] = $name; + $fields[$name] = array_merge(array( + 'is_link' => (Boolean) $column->isPrimaryKey(), + 'is_real' => true, + 'is_partial' => false, + 'is_component' => false, + 'type' => $this->getType($column), + ), isset($this->config['fields'][$name]) ? $this->config['fields'][$name] : array()); + } + + foreach ($this->getManyToManyTables() as $tables) + { + $name = sfInflector::underscore($tables['alias']).'_list'; + $names[] = $name; + $fields[$name] = array_merge(array( + 'is_link' => false, + 'is_real' => false, + 'is_partial' => false, + 'is_component' => false, + 'type' => 'Text', + ), isset($this->config['fields'][$name]) ? $this->config['fields'][$name] : array()); + } + + if (isset($this->config['fields'])) + { + foreach ($this->config['fields'] as $name => $params) + { + if (in_array($name, $names)) + { + continue; + } + + $fields[$name] = array_merge(array( + 'is_link' => false, + 'is_real' => false, + 'is_partial' => false, + 'is_component' => false, + 'type' => 'Text', + ), is_array($params) ? $params : array()); + } + } + + unset($this->config['fields']); + + return $fields; + } + + /** + * Returns the configuration for fields in a given context. + * + * @param string $context The Context + * + * @return array An array of configuration for all the fields in a given context + */ + public function getFieldsConfiguration($context) + { + $fields = array(); + + $names = array(); + foreach ($this->getColumns() as $name => $column) + { + $names[] = $name; + $fields[$name] = isset($this->config[$context]['fields'][$name]) ? $this->config[$context]['fields'][$name] : array(); + } + + foreach ($this->getManyToManyTables() as $tables) + { + $name = sfInflector::underscore($tables['alias']).'_list'; + $names[] = $name; + $fields[$name] = isset($this->config[$context]['fields'][$name]) ? $this->config[$context]['fields'][$name] : array(); + } + + if (isset($this->config[$context]['fields'])) + { + foreach ($this->config[$context]['fields'] as $name => $params) + { + if (in_array($name, $names)) + { + continue; + } + + $fields[$name] = is_array($params) ? $params : array(); + } + } + + unset($this->config[$context]['fields']); + + return $fields; + } + + /** + * Gets all the fields for the current model. + * + * @param Boolean $withM2M Whether to include m2m fields or not + * + * @return array An array of field names + */ + public function getAllFieldNames($withM2M = true) + { + $names = array(); + foreach ($this->getColumns() as $name => $column) + { + $names[] = $name; + } + + if ($withM2M) + { + foreach ($this->getManyToManyTables() as $tables) + { + $names[] = sfInflector::underscore($tables['alias']).'_list'; + } + } + + return $names; + } + + /** + * Get array of sfDoctrineAdminColumn objects + * + * @return array $columns + */ + public function getColumns() + { + foreach (array_keys($this->table->getColumns()) as $name) + { + $name = $this->table->getFieldName($name); + $columns[$name] = new sfDoctrineColumn($name, $this->table); + } + + return $columns; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/helper/ObjectDoctrineAdminHelper.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/helper/ObjectDoctrineAdminHelper.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,122 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * ObjectHelper for doctrine admin generator. + * + * @package sfDoctrinePlugin + * @subpackage helper + * @author Olivier Verdier + * @author Jonathan H. Wage + * @author Fabien Potencier + * @version SVN: $Id: ObjectDoctrineAdminHelper.php 12089 2008-10-08 20:23:25Z Jonathan.Wage $ + */ + +sfLoader::loadHelpers(array('ObjectAdmin')); + +/** + * object_doctrine_admin_double_list + * + * @param string $object + * @param string $method + * @param string $options + * @return void + */ +function object_doctrine_admin_double_list($object, $method, $options = array()) +{ + return object_admin_double_list($object, $method, $options, '_get_doctrine_object_list'); +} + +/** + * object_doctrine_admin_select_list + * + * @param string $object + * @param string $method + * @param string $options + * @return void + */ +function object_doctrine_admin_select_list($object, $method, $options = array()) +{ + return object_admin_select_list($object, $method, $options, '_get_doctrine_object_list'); +} + +/** + * object_doctrine_admin_check_list + * + * @param string $object + * @param string $method + * @param string $options + * @return void + */ +function object_doctrine_admin_check_list($object, $method, $options = array()) +{ + return object_admin_check_list($object, $method, $options, '_get_doctrine_object_list'); +} + +/** + * _get_doctrine_object_list + * + * @param string $object + * @param string $method + * @param string $options + * @return void + */ +function _get_doctrine_object_list($object, $method, $options) +{ + $foreignTable = $object->getTable()->getRelation($method[1][0])->getTable(); + $foreignClass = $foreignTable->getComponentName(); + + if (isset($options['dql'])) + { + $dql = $options['dql']; + unset($options['dql']); # Otherwise it will show up in the html + + $allObjects = $foreignTable->findByDQL($dql); + } else if (isset($options['table_method'])) { + $throughTable = $object->getTable()->getRelation($options['through_class'])->getTable(); + $peerMethod = $options['table_method']; + $allObjects = $throughTable->$peerMethod(); + } else { + $allObjects = $foreignTable->findAll(); + } + + $associatedObjects = $object->get($method[1][0]); + + $ids = array(); + foreach ($associatedObjects as $associatedObject) + { + $ids[] = $associatedObject->identifier(); + } + + if ($associatedObjects instanceof Doctrine_Collection && $associatedObjects->count() === 0) + { + $associatedObjects = null; + } + + return array($allObjects, $associatedObjects, $ids); +} + +/** + * object_enum_tag + * + * @param string $object + * @param string $method + * @param string $options + * @return void + */ +function object_enum_tag($object, $method, $options) +{ + $enumValues = _get_option($options, 'enumValues', array()); + $currentValue = _get_object_value($object, $method); + $enumValues = array_combine($enumValues, $enumValues); + + return select_tag(_convert_method_to_name($method, $options), options_for_select($enumValues, $currentValue), $options); +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/log/sfDoctrineLogger.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/log/sfDoctrineLogger.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Logs queries to file and web debug toolbar + * + * @package symfony + * @package doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineLogger.class.php 8938 2008-05-14 01:52:35Z Jonathan.Wage $ + */ +class sfDoctrineLogger extends Doctrine_EventListener +{ + protected $connection = null, + $encoding = 'UTF8'; + + /** + * Log a query before it is executed + * + * @param Doctrine_Event $event + * @return void + */ + public function preExecute(Doctrine_Event $event) + { + $this->sfLogQuery('executeQuery : ', $event); + } + + /** + * Add the time after a query is executed + * + * @param Doctrine_Event $event + * @return void + */ + public function postExecute(Doctrine_Event $event) + { + $this->sfAddTime(); + } + + /** + * Add the time after a query is prepared + * + * @param Doctrine_Event $event + * @return void + */ + public function postPrepare(Doctrine_Event $event) + { + $this->sfAddTime(); + } + + /** + * Before a query statement is executed log it + * + * @param Doctrine_Event $event + * @return void + */ + public function preStmtExecute(Doctrine_Event $event) + { + $this->sfLogQuery('executeQuery : ', $event); + } + + /** + * postStmtExecute + * + * @param Doctrine_Event $event + * @return void + */ + public function postStmtExecute(Doctrine_Event $event) + { + $this->sfAddTime(); + } + + /** + * Log a query before it is executed + * + * @param Doctrine_Event $event + * @return void + */ + public function preQuery(Doctrine_Event $event) + { + $this->sfLogQuery('executeQuery : ', $event); + } + + /** + * Post query add the time + * + * @param string $Doctrine_Event + * @return void + */ + public function postQuery(Doctrine_Event $event) + { + $this->sfAddTime(); + } + + /** + * Log a Doctrine_Query + * + * @param string $message + * @param string $event + * @return void + */ + protected function sfLogQuery($message, $event) + { + $message .= $event->getQuery(); + + if ($params = $event->getParams()) + { + foreach ($params as $key => $param) + { + if (strlen($param) >= 255) + { + $len = strlen($param); + $kb = '[' . number_format($len / 1024, 2) . 'Kb]'; + $params[$key] = $kb; + } + } + $message .= ' - ('.implode(', ', $params) . ' )'; + } + + $message = '{sfDoctrineLogger} ' . $message; + if (sfContext::hasInstance()) + { + sfContext::getInstance()->getLogger()->log($message); + } + + $sqlTimer = sfTimerManager::getTimer('Database (Doctrine)'); + } + + /** + * Add the time to the log + * + * @return void + */ + protected function sfAddTime() + { + sfTimerManager::getTimer('Database (Doctrine)')->addTime(); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/pager/sfDoctrinePager.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/pager/sfDoctrinePager.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,177 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrine pager class + * + * @package sfDoctrinePlugin + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrinePager.class.php 19265 2009-06-15 10:13:34Z Jonathan.Wage $ + */ +class sfDoctrinePager extends sfPager implements Serializable +{ + protected + $query = null, + $tableMethodName = null, + $tableMethodCalled = false; + + /** + * Get the name of the table method used to retrieve the query object for the pager + * + * @return string $tableMethodName + */ + public function getTableMethod() + { + return $this->tableMethodName; + } + + /** + * Set the name of the table method used to retrieve the query object for the pager + * + * @param string $tableMethodName + * @return void + */ + public function setTableMethod($tableMethodName) + { + $this->tableMethodName = $tableMethodName; + } + + /** + * Serialize the pager object + * + * @return string $serialized + */ + public function serialize() + { + $vars = get_object_vars($this); + unset($vars['query']); + return serialize($vars); + } + + /** + * Unserialize a pager object + * + * @param string $serialized + * @return void + */ + public function unserialize($serialized) + { + $array = unserialize($serialized); + + foreach($array as $name => $values) + { + $this->$name = $values; + } + } + + public function getCountQuery() + { + $q = clone $this->getQuery() + ->offset(0) + ->limit(0); + + return $q; + } + + /** + * Initialize the pager instance and prepare it to be used for rendering + * + * @return void + */ + public function init() + { + $countQuery = $this->getCountQuery(); + $count = $countQuery->count(); + + $this->setNbResults($count); + + $p = $this->getQuery(); + $p->offset(0); + $p->limit(0); + if ($this->getPage() == 0 || $this->getMaxPerPage() == 0 || $this->getNbResults() == 0) + { + $this->setLastPage(0); + } + else + { + $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); + + $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage())); + + $p->offset($offset); + $p->limit($this->getMaxPerPage()); + } + } + + /** + * Get the query for the pager + * + * @return Doctrine_Query $query + */ + public function getQuery() + { + if (!$this->tableMethodCalled && $this->tableMethodName) + { + $method = $this->tableMethodName; + $this->query = Doctrine::getTable($this->getClass())->$method($this->query); + $this->tableMethodCalled = true; + } else if (!$this->query) { + $this->query = Doctrine::getTable($this->getClass())->createQuery(); + } + return $this->query; + } + + /** + * Set query object for the pager + * + * @param Doctrine_Query $query + * @return void + */ + public function setQuery($query) + { + $this->query = $query; + } + + /** + * Retrieve the object for a certain offset + * + * @param integer $offset + * @return Doctrine_Record $record + */ + protected function retrieveObject($offset) + { + $cForRetrieve = clone $this->getQuery(); + $cForRetrieve->offset($offset - 1); + $cForRetrieve->limit(1); + + $results = $cForRetrieve->execute(); + + return $results[0]; + } + + /** + * Get all the results for the pager instance + * + * @param integer $hydrationMode Doctrine::HYDRATE_* constants + * @return mixed Doctrine_Collection/array + */ + public function getResults($hydrationMode = Doctrine::HYDRATE_RECORD) + { + $p = $this->getQuery(); + + if ($hydrationMode == 'array') + { + $hydrationMode = Doctrine::HYDRATE_ARRAY; + } + + return $p->execute(array(), $hydrationMode); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,212 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Base sfDoctrineRecord extends the base Doctrine_Record in Doctrine to provide some + * symfony specific functionality to Doctrine_Records + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineRecord.class.php 19987 2009-07-07 20:31:36Z Jonathan.Wage $ + */ +abstract class sfDoctrineRecord extends Doctrine_Record +{ + static protected + $_initialized = false, + $_defaultCulture = 'en'; + + /** + * Custom Doctrine_Record constructor. + * Used to initialize I18n to make sure the culture is set from symfony + * + * @return void + */ + public function construct() + { + self::initializeI18n(); + + if ($this->getTable()->hasRelation('Translation')) + { + $this->unshiftFilter(new sfDoctrineRecordI18nFilter()); + } + } + + /** + * Initialize I18n culture from symfony sfUser instance + * Add event listener to change default culture whenever the user changes culture + * + * @return void + */ + public static function initializeI18n() + { + if (!self::$_initialized) + { + if (!self::$_initialized && class_exists('sfProjectConfiguration', false)) + { + $dispatcher = sfProjectConfiguration::getActive()->getEventDispatcher(); + $dispatcher->connect('user.change_culture', array('sfDoctrineRecord', 'listenToChangeCultureEvent')); + } + + if (class_exists('sfContext', false) && sfContext::hasInstance() && $user = sfContext::getInstance()->getUser()) + { + self::$_defaultCulture = $user->getCulture(); + } + self::$_initialized = true; + } + } + + /** + * Listens to the user.change_culture event. + * + * @param sfEvent An sfEvent instance + */ + public static function listenToChangeCultureEvent(sfEvent $event) + { + self::$_defaultCulture = $event['culture']; + } + + /** + * Sets the default culture + * + * @param string $culture + */ + static public function setDefaultCulture($culture) + { + self::$_defaultCulture = $culture; + } + + /** + * Return the default culture + * + * @return string the default culture + */ + static public function getDefaultCulture() + { + self::initializeI18n(); + + if (!self::$_defaultCulture) + { + throw new sfException('The default culture has not been set'); + } + return self::$_defaultCulture; + } + + /** + * Get the primary key of a Doctrine_Record. + * This a proxy method to Doctrine_Record::identifier() for Propel BC + * + * @return mixed $identifier Array for composite primary keys and string for single primary key + */ + public function getPrimaryKey() + { + $identifier = (array) $this->identifier(); + return end($identifier); + } + + /** + * Function require by symfony >= 1.2 admin generators + * + * @return boolean + */ + public function isNew() + { + return ! $this->exists(); + } + + /** + * Returns a string representation of the record. + * + * @return string A string representation of the record. + */ + public function __toString() + { + $guesses = array('name', + 'title', + 'description', + 'subject', + 'keywords', + 'id'); + + // we try to guess a column which would give a good description of the object + foreach ($guesses as $descriptionColumn) + { + try + { + return (string) $this->get($descriptionColumn); + } catch (Exception $e) {} + } + + return sprintf('No description for object of class "%s"', $this->getTable()->getComponentName()); + } + + /* + * Provide accessors with setters and getters to Doctrine models. + * + * @param string $method The method name. + * @param array $arguments The method arguments. + * @return mixed The returned value of the called method. + */ + public function __call($method, $arguments) + { + try { + if (in_array($verb = substr($method, 0, 3), array('set', 'get'))) + { + $name = substr($method, 3); + + $table = $this->getTable(); + if ($table->hasRelation($name)) + { + $entityName = $name; + } + else if ($table->hasField($fieldName = $table->getFieldName($name))) + { + $entityNameLower = strtolower($fieldName); + if ($table->hasField($entityNameLower) || $table->hasRelation($entityNameLower)) + { + $entityName = $entityNameLower; + } else { + $entityName = $fieldName; + } + } + else + { + $underScored = $table->getFieldName(sfInflector::underscore($name)); + if ($table->hasField($underScored) || $table->hasRelation($underScored)) + { + $entityName = $underScored; + } else if ($table->hasField(strtolower($name)) || $table->hasRelation(strtolower($name))) { + $entityName = strtolower($name); + } else { + $camelCase = $table->getFieldName(sfInflector::camelize($name)); + $camelCase = strtolower($camelCase[0]).substr($camelCase, 1, strlen($camelCase)); + if ($table->hasField($camelCase) || $table->hasRelation($camelCase)) + { + $entityName = $camelCase; + } else { + $entityName = $underScored; + } + } + } + + return call_user_func_array( + array($this, $verb), + array_merge(array($entityName), $arguments) + ); + } else { + return parent::__call($method, $arguments); + } + } catch(Exception $e) { + return parent::__call($method, $arguments); + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/record/sfDoctrineRecordI18nFilter.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/record/sfDoctrineRecordI18nFilter.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrineRecordI18nFilter implements access to the translated properties for + * the current culture from the internationalized model. + * + * @package symfony + * @subpackage doctrine + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineRecordI18nFilter.class.php 11878 2008-09-30 20:14:40Z Jonathan.Wage $ + */ +class sfDoctrineRecordI18nFilter extends Doctrine_Record_Filter +{ + public function init() + { + } + + /** + * Implementation of filterSet() to call set on Translation relationship to allow + * access to I18n properties from the main object. + * + * @param Doctrine_Record $record + * @param string $name Name of the property + * @param string $value Value of the property + * @return void + */ + public function filterSet(Doctrine_Record $record, $name, $value) + { + return $record['Translation'][sfDoctrineRecord::getDefaultCulture()][$name] = $value; + } + + /** + * Implementation of filterGet() to call get on Translation relationship to allow + * access to I18n properties from the main object. + * + * @param Doctrine_Record $record + * @param string $name Name of the property + * @param string $value Value of the property + * @return void + */ + public function filterGet(Doctrine_Record $record, $name) + { + $culture = sfDoctrineRecord::getDefaultCulture(); + if (isset($record['Translation'][$culture])) + { + return $record['Translation'][$culture][$name]; + } else { + $defaultCulture = sfConfig::get('sf_default_culture'); + return $record['Translation'][$defaultCulture][$name]; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/record/sfDoctrineRecordListener.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/record/sfDoctrineRecordListener.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,55 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Default Doctrine_Record listener + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineRecordListener.class.php 11878 2008-09-30 20:14:40Z Jonathan.Wage $ + */ +class sfDoctrineRecordListener extends Doctrine_Record_Listener +{ + /** + * preInsert + * + * @param string $Doctrine_Event + * @return void + */ + public function preInsert(Doctrine_Event $event) + { + if ($event->getInvoker()->getTable()->hasColumn('created_at')) + { + $event->getInvoker()->created_at = date('Y-m-d H:i:s', time()); + } + + if ($event->getInvoker()->getTable()->hasColumn('updated_at')) + { + $event->getInvoker()->updated_at = date('Y-m-d H:i:s', time()); + } + } + + /** + * preUpdate + * + * @param string $Doctrine_Event + * @return void + */ + public function preUpdate(Doctrine_Event $event) + { + if ($event->getInvoker()->getTable()->hasColumn('updated_at')) + { + $event->getInvoker()->updated_at = date('Y-m-d H:i:s', time()); + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/routing/sfDoctrineRoute.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/routing/sfDoctrineRoute.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,163 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrineRoute represents a route that is bound to a Doctrine class. + * + * A Doctrine route can represent a single Doctrine object or a list of objects. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineRoute.class.php 11475 2008-09-12 11:07:23Z fabien $ + */ +class sfDoctrineRoute extends sfObjectRoute +{ + protected + $query = null; + + /** + * Constructor. + * + * @param string $pattern The pattern to match + * @param array $defaults An array of default parameter values + * @param array $requirements An array of requirements for parameters (regexes) + * @param array $options An array of options + * + * @see sfObjectRoute + */ + public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array()) + { + parent::__construct($pattern, $defaults, $requirements, $options); + + $this->options['object_model'] = $this->options['model']; + } + + public function setListQuery(Doctrine_Query $query) + { + if (!$this->isBound()) + { + throw new LogicException('The route is not bound.'); + } + + $this->query = $query; + } + + protected function getObjectForParameters($parameters) + { + $results = $this->getObjectsForParameters($parameters); + + // If query returned Doctrine_Collection with results inside then we + // need to return the first Doctrine_Record + if ($results instanceof Doctrine_Collection) + { + if (count($results)) + { + $results = $results->getFirst(); + } else { + $results = null; + } + } + // If an object is returned then lets return it otherwise return null + else if(!is_object($results)) + { + $results = null; + } + + return $results; + } + + protected function getObjectsForParameters($parameters) + { + $this->options['model'] = Doctrine::getTable($this->options['model']); + + $variables = array(); + $values = array(); + foreach($this->getRealVariables() as $variable) + { + if($this->options['model']->hasColumn($this->options['model']->getColumnName($variable))) + { + $variables[] = $variable; + $values[$variable] = $parameters[$variable]; + } + } + + if (!isset($this->options['method'])) + { + if (is_null($this->query)) + { + $q = $this->options['model']->createQuery('a'); + foreach ($values as $variable => $value) + { + $fieldName = $this->options['model']->getFieldName($variable); + $q->andWhere('a.'. $fieldName . ' = ?', $parameters[$variable]); + } + } + else + { + $q = $this->query; + } + if (isset($this->options['method_for_query'])) + { + $method = $this->options['method_for_query']; + $results = $this->options['model']->$method($q); + } + else + { + $results = $q->execute(); + } + } + else + { + $method = $this->options['method']; + $results = $this->options['model']->$method($this->filterParameters($parameters)); + } + + // If query returned a Doctrine_Record instance instead of a + // Doctrine_Collection then we need to create a new Doctrine_Collection with + // one element inside and return that + if ($results instanceof Doctrine_Record) + { + $obj = $results; + $results = new Doctrine_Collection($obj->getTable()); + $results[] = $obj; + } + + return $results; + } + + protected function doConvertObjectToArray($object) + { + if (isset($this->options['convert']) || method_exists($object, 'toParams')) + { + return parent::doConvertObjectToArray($object); + } + + $className = $this->options['model']; + + $parameters = array(); + + foreach ($this->getRealVariables() as $variable) + { + try { + $parameters[$variable] = $object->$variable; + } catch (Exception $e) { + try { + $method = 'get'.sfInflector::camelize($variable); + $parameters[$variable] = $object->$method; + } catch (Exception $e) {} + } + } + + return $parameters; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/routing/sfDoctrineRouteCollection.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/routing/sfDoctrineRouteCollection.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,25 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfObjectRouteCollection represents a collection of routes bound to Doctrine objects. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineRouteCollection.class.php 11475 2008-09-12 11:07:23Z fabien $ + */ +class sfDoctrineRouteCollection extends sfObjectRouteCollection +{ + protected + $routeClass = 'sfDoctrineRoute'; +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/sfDoctrineException.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/sfDoctrineException.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,23 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrine exception class + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineException.class.php 11629 2008-09-17 22:22:25Z Jonathan.Wage $ + */ +class sfDoctrineException extends sfException +{ +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBaseTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBaseTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Base class for all symfony Doctrine tasks. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBaseTask.class.php 15865 2009-02-28 03:34:26Z Jonathan.Wage $ + */ +abstract class sfDoctrineBaseTask extends sfBaseTask +{ + static protected $done = false; + + public function initialize(sfEventDispatcher $dispatcher, sfFormatter $formatter) + { + parent::initialize($dispatcher, $formatter); + self::$done = true; + } + + protected function createConfiguration($application, $env) + { + $configuration = parent::createConfiguration($application, $env); + + $autoloader = sfSimpleAutoload::getInstance(); + $config = new sfAutoloadConfigHandler(); + $mapping = $config->evaluate($configuration->getConfigPaths('config/autoload.yml')); + foreach ($mapping as $class => $file) + { + $autoloader->setClassPath($class, $file); + } + $autoloader->register(); + + return $configuration; + } + /** + * Get array of configuration variables for the Doctrine cli + * + * @return array $config + */ + public function getCliConfig() + { + $fixtures = array(); + $fixtures[] = sfConfig::get('sf_root_dir').'/data/fixtures'; + $pluginPaths = $this->configuration->getPluginPaths(); + foreach ($pluginPaths as $pluginPath) + { + if (is_dir($dir = $pluginPath.'/data/fixtures')) + { + $fixtures[] = $dir; + } + } + $models = sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR . 'doctrine'; + $migrations = sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'migration' . DIRECTORY_SEPARATOR . 'doctrine'; + $sql = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'sql'; + $yaml = sfConfig::get('sf_config_dir') . DIRECTORY_SEPARATOR . 'doctrine'; + + $config = array('data_fixtures_path' => $fixtures, + 'models_path' => $models, + 'migrations_path' => $migrations, + 'sql_path' => $sql, + 'yaml_schema_path' => $yaml); + + foreach ($config as $dir) + { + $dirs = (array) $dir; + foreach ($dirs as $dir) + { + Doctrine_Lib::makeDirectories($dir); + } + } + + return $config; + } + + /** + * Call a command from the Doctrine CLI + * + * @param string $task Name of the Doctrine task to call + * @param string $args Arguments for the task + * @return void + */ + public function callDoctrineCli($task, $args = array()) + { + $config = $this->getCliConfig(); + + $arguments = array('./symfony', $task); + + foreach ($args as $key => $arg) + { + if (isset($config[$key])) + { + $config[$key] = $arg; + } else { + $arguments[] = $arg; + } + } + + $cli = new sfDoctrineCli($config); + $cli->setDispatcher($this->dispatcher); + $cli->setFormatter($this->formatter); + $cli->run($arguments); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllLoadTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllLoadTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,109 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Creates Databases, Generates Doctrine model, SQL, initializes database, and load data. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildAllLoadTask.class.php 18971 2009-06-05 15:44:44Z Jonathan.Wage $ + */ +class sfDoctrineBuildAllLoadTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), + new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms'), + new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'), + )); + + $this->aliases = array('doctrine-build-all-load'); + $this->namespace = 'doctrine'; + $this->name = 'build-all-load'; + $this->briefDescription = 'Generates Doctrine model, SQL, initializes database, and loads fixtures data'; + + $this->detailedDescription = <<configuration); + + $buildAll = new sfDoctrineBuildAllTask($this->dispatcher, $this->formatter); + $buildAll->setCommandApplication($this->commandApplication); + + $buildAllOptions = array(); + if ($options['skip-forms']) + { + $buildAllOptions[] = '--skip-forms'; + } + if ($options['no-confirmation']) + { + $buildAllOptions[] = '--no-confirmation'; + } + if (isset($options['application']) && $options['application']) + { + $buildAllOptions[] = '--application=' . $options['application']; + } + $ret = $buildAll->run(array(), $buildAllOptions); + + if (0 == $ret) + { + $loadData = new sfDoctrineLoadDataTask($this->dispatcher, $this->formatter); + $loadData->setCommandApplication($this->commandApplication); + + $loadDataOptions = array('--env='.$options['env'], '--connection='.$options['connection']); + if (isset($options['application'])) + { + $loadDataOptions[] = '--application='.$options['application']; + } + if (!empty($options['dir'])) + { + $loadDataOptions[] = '--dir=' . implode(' --dir=', $options['dir']); + } + + $loadData->run(array(), $loadDataOptions); + } + + return $ret; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllReloadTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllReloadTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,107 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Drops Databases, Creates Databases, Generates Doctrine model, SQL, initializes database, and load data. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildAllReloadTask.class.php 15823 2009-02-26 19:16:05Z Jonathan.Wage $ + */ +class sfDoctrineBuildAllReloadTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), + new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms'), + new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'), + )); + + $this->aliases = array('doctrine-build-all-reload'); + $this->namespace = 'doctrine'; + $this->name = 'build-all-reload'; + $this->briefDescription = 'Generates Doctrine model, SQL, initializes database, and load data'; + + $this->detailedDescription = <<dispatcher, $this->formatter); + $dropDb->setCommandApplication($this->commandApplication); + + $dropDbOptions = array(); + $dropDbOptions[] = '--env='.$options['env']; + if (isset($options['no-confirmation']) && $options['no-confirmation']) + { + $dropDbOptions[] = '--no-confirmation'; + } + if (isset($options['application']) && $options['application']) + { + $dropDbOptions[] = '--application=' . $options['application']; + } + $ret = $dropDb->run(array(), $dropDbOptions); + + if ($ret) + { + return $ret; + } + + $buildAllLoad = new sfDoctrineBuildAllLoadTask($this->dispatcher, $this->formatter); + $buildAllLoad->setCommandApplication($this->commandApplication); + + $buildAllLoadOptions = array(); + $buildAllLoadOptions[] = '--env='.$options['env']; + if (!empty($options['dir'])) + { + $buildAllLoadOptions[] = '--dir=' . implode(' --dir=', $options['dir']); + } + if (isset($options['append']) && $options['append']) + { + $buildAllLoadOptions[] = '--append'; + } + if (isset($options['application']) && $options['application']) + { + $buildAllLoadOptions[] = '--application=' . $options['application']; + } + if (isset($options['skip-forms']) && $options['skip-forms']) + { + $buildAllLoadOptions[] = '--skip-forms'; + } + $buildAllLoad->run(array(), $buildAllLoadOptions); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllReloadTestAllTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllReloadTestAllTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,102 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Drops Databases, Creates Databases, Generates Doctrine model, SQL, initializes database, load data and run + * all test suites + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildAllReloadTask.class.php 8743 2008-05-03 05:02:39Z Jonathan.Wage $ + */ +class sfDoctrineBuildAllReloadTestAllTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('append', null, sfCommandOption::PARAMETER_NONE, 'Don\'t delete current data in the database'), + new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'), + new sfCommandOption('force', null, sfCommandOption::PARAMETER_NONE, 'Whether to force dropping of the database'), + )); + + $this->aliases = array('doctrine-build-all-reload-test-all'); + $this->namespace = 'doctrine'; + $this->name = 'build-all-reload-test-all'; + $this->briefDescription = 'Generates Doctrine model, SQL, initializes database, load data and run all tests'; + + $this->detailedDescription = <<dispatcher, $this->formatter); + $buildAllReload->setCommandApplication($this->commandApplication); + + $buildAllReloadOptions = array(); + if (!empty($options['application'])) + { + $buildAllReloadOptions[] = '--application=' . $options['application']; + } + $buildAllReloadOptions[] = '--env='.$options['env']; + if (!empty($options['dir'])) + { + $buildAllReloadOptions[] = '--dir=' . implode(' --dir=', $options['dir']); + } + if (isset($options['append']) && $options['append']) + { + $buildAllReloadOptions[] = '--append'; + } + if (isset($options['no-confirmation']) && $options['no-confirmation']) + { + $buildAllReloadOptions[] = '--no-confirmation'; + } + $ret = $buildAllReload->run(array(), $buildAllReloadOptions); + + if ($ret) + { + return $ret; + } + + $this->logSection('doctrine', 'running test suite'); + + $testAll = new sfTestAllTask($this->dispatcher, $this->formatter); + $testAll->setCommandApplication($this->commandApplication); + $testAll->run(); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,127 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Generates Doctrine model, SQL and initializes the database. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildAllTask.class.php 16087 2009-03-07 22:08:50Z Kris.Wallsmith $ + */ +class sfDoctrineBuildAllTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->aliases = array('doctrine-build-all'); + $this->namespace = 'doctrine'; + $this->name = 'build-all'; + $this->briefDescription = 'Generates Doctrine model, SQL and initializes the database'; + + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), + new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms') + )); + + $this->detailedDescription = <<configuration instanceof sfApplicationConfiguration ? array( + '--application='.$this->configuration->getApplication(), + '--env='.$options['env'], + ) : array(); + + $buildDb = new sfDoctrineBuildDbTask($this->dispatcher, $this->formatter); + $buildDb->setCommandApplication($this->commandApplication); + $ret = $buildDb->run(array(), $baseOptions); + + if ($ret) + { + return $ret; + } + + $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter); + $buildModel->setCommandApplication($this->commandApplication); + $ret = $buildModel->run(array(), $baseOptions); + + if ($ret) + { + return $ret; + } + + $buildSql = new sfDoctrineBuildSqlTask($this->dispatcher, $this->formatter); + $buildSql->setCommandApplication($this->commandApplication); + $ret = $buildSql->run(array(), $baseOptions); + + if ($ret) + { + return $ret; + } + + if (!$options['skip-forms']) + { + $buildForms = new sfDoctrineBuildFormsTask($this->dispatcher, $this->formatter); + $buildForms->setCommandApplication($this->commandApplication); + $ret = $buildForms->run(array(), $baseOptions); + + if ($ret) + { + return $ret; + } + + $buildFilters = new sfDoctrineBuildFiltersTask($this->dispatcher, $this->formatter); + $buildFilters->setCommandApplication($this->commandApplication); + $ret = $buildFilters->run(array(), $baseOptions); + + if ($ret) + { + return $ret; + } + } + + $insertSql = new sfDoctrineInsertSqlTask($this->dispatcher, $this->formatter); + $insertSql->setCommandApplication($this->commandApplication); + $ret = $insertSql->run(array(), $baseOptions); + + return $ret; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildDbTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildDbTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,59 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Creates database for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildDbTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineBuildDbTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-build-db'); + $this->namespace = 'doctrine'; + $this->name = 'build-db'; + $this->briefDescription = 'Creates database for current model'; + + $this->detailedDescription = <<logSection('doctrine', 'creating databases'); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('create-db'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildFiltersTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildFiltersTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,85 @@ + + * + * For the full copyright and license informationation, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Create filter form classes for the current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineBuildFiltersTask.class.php 12537 2008-11-01 14:43:27Z fabien $ + */ +class sfDoctrineBuildFiltersTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + new sfCommandOption('model-dir-name', null, sfCommandOption::PARAMETER_REQUIRED, 'The model dir name', 'model'), + new sfCommandOption('filter-dir-name', null, sfCommandOption::PARAMETER_REQUIRED, 'The filter form dir name', 'filter'), + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->namespace = 'doctrine'; + $this->name = 'build-filters'; + $this->briefDescription = 'Creates filter form classes for the current model'; + + $this->detailedDescription = <<logSection('doctrine', 'generating filter form classes'); + $databaseManager = new sfDatabaseManager($this->configuration); + $generatorManager = new sfGeneratorManager($this->configuration); + $generatorManager->generate('sfDoctrineFormFilterGenerator', array( + 'connection' => $options['connection'], + 'model_dir_name' => $options['model-dir-name'], + 'filter_dir_name' => $options['filter-dir-name'], + )); + + $properties = parse_ini_file(sfConfig::get('sf_config_dir').DIRECTORY_SEPARATOR.'properties.ini', true); + + $constants = array( + 'PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', + 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here' + ); + + // customize php and yml files + $finder = sfFinder::type('file')->name('*.php'); + $this->getFilesystem()->replaceTokens($finder->in(sfConfig::get('sf_lib_dir').'/filter/'), '##', '##', $constants); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildFormsTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildFormsTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Create form classes for the current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineBuildFormsTask.class.php 12537 2008-11-01 14:43:27Z fabien $ + */ +class sfDoctrineBuildFormsTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + new sfCommandOption('model-dir-name', null, sfCommandOption::PARAMETER_REQUIRED, 'The model dir name', 'model'), + new sfCommandOption('form-dir-name', null, sfCommandOption::PARAMETER_REQUIRED, 'The form dir name', 'form'), + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->namespace = 'doctrine'; + $this->name = 'build-forms'; + $this->briefDescription = 'Creates form classes for the current model'; + + $this->detailedDescription = <<logSection('doctrine', 'generating form classes'); + $databaseManager = new sfDatabaseManager($this->configuration); + $generatorManager = new sfGeneratorManager($this->configuration); + $generatorManager->generate('sfDoctrineFormGenerator', array( + 'connection' => $options['connection'], + 'model_dir_name' => $options['model-dir-name'], + 'form_dir_name' => $options['form-dir-name'], + )); + + $properties = parse_ini_file(sfConfig::get('sf_config_dir').DIRECTORY_SEPARATOR.'properties.ini', true); + + $constants = array( + 'PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', + 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here' + ); + + // customize php and yml files + $finder = sfFinder::type('file')->name('*.php'); + $this->getFilesystem()->replaceTokens($finder->in(sfConfig::get('sf_lib_dir').'/form/'), '##', '##', $constants); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildModelTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildModelTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,137 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Create classes for the current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildModelTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineBuildModelTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-build-model'); + $this->namespace = 'doctrine'; + $this->name = 'build-model'; + $this->briefDescription = 'Creates classes for the current model'; + + $this->detailedDescription = <<logSection('doctrine', 'generating model classes'); + + $config = $this->getCliConfig(); + + $this->_checkForPackageParameter($config['yaml_schema_path']); + + $tmpPath = sfConfig::get('sf_cache_dir').DIRECTORY_SEPARATOR.'tmp'; + + if (!file_exists($tmpPath)) + { + Doctrine_Lib::makeDirectories($tmpPath); + } + + $plugins = $this->configuration->getPlugins(); + foreach ($this->configuration->getAllPluginPaths() as $plugin => $path) + { + if (!in_array($plugin, $plugins)) + { + continue; + } + $schemas = sfFinder::type('file')->name('*.yml')->in($path.'/config/doctrine'); + foreach ($schemas as $schema) + { + $tmpSchemaPath = $tmpPath.DIRECTORY_SEPARATOR.$plugin.'-'.basename($schema); + + $models = Doctrine_Parser::load($schema, 'yml'); + if (!isset($models['package'])) + { + $models['package'] = $plugin.'.lib.model.doctrine'; + $models['package_custom_path'] = $path.'/lib/model/doctrine'; + } + Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath); + } + } + + $options = array('generateBaseClasses' => true, + 'generateTableClasses' => true, + 'packagesPath' => sfConfig::get('sf_plugins_dir'), + 'packagesPrefix' => 'Plugin', + 'suffix' => '.class.php', + 'baseClassesDirectory' => 'base', + 'baseClassName' => 'sfDoctrineRecord'); + $options = array_merge($options, sfConfig::get('doctrine_model_builder_options', array())); + + $import = new Doctrine_Import_Schema(); + $import->setOptions($options); + $import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']); + } + + /** + * Check for package parameter in main schema files. + * sfDoctrinePlugin uses the package feature of Doctrine + * for plugins and cannot be used by the user + * + * @param string $path + * @return void + */ + protected function _checkForPackageParameter($path) + { + $files = sfFinder::type('file')->name('*.yml')->in($path); + foreach ($files as $file) + { + $array = sfYaml::load($file); + if (is_array($array) AND !empty($array)) + { + foreach ($array as $key => $value) + { + if ($key == 'package' || (is_array($value) && isset($value['package']))) + { + throw new sfDoctrineException( + sprintf('Cannot use package parameter in symfony Doctrine schema files. Found in "%s"', $file) + ); + } + } + } + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildSchemaTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildSchemaTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,59 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Creates a schema.xml from an existing database. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildSchemaTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineBuildSchemaTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-build-schema'); + $this->namespace = 'doctrine'; + $this->name = 'build-schema'; + $this->briefDescription = 'Creates a schema from an existing database'; + + $this->detailedDescription = <<logSection('doctrine', 'generating yaml schema from database'); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('generate-yaml-db'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildSqlTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineBuildSqlTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,61 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Create SQL for the current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineBuildSqlTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineBuildSqlTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-build-sql'); + $this->namespace = 'doctrine'; + $this->name = 'build-sql'; + $this->briefDescription = 'Creates SQL for the current model'; + + $this->detailedDescription = <<logSection('doctrine', 'generating sql for models'); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('generate-sql'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDataDumpTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDataDumpTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,89 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Dumps data to the fixtures directory. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineDataDumpTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineDumpDataTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('target', sfCommandArgument::OPTIONAL, 'The target filename'), + )); + + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-dump-data'); + $this->namespace = 'doctrine'; + $this->name = 'data-dump'; + $this->briefDescription = 'Dumps data to the fixtures directory'; + + $this->detailedDescription = <<configuration); + + $config = $this->getCliConfig(); + $dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'fixtures'; + Doctrine_Lib::makeDirectories($dir); + + $args = array(); + if (isset($arguments['target'])) + { + $filename = $arguments['target']; + + if (!sfToolkit::isPathAbsolute($filename)) + { + $filename = $dir . DIRECTORY_SEPARATOR . $filename; + } + + Doctrine_Lib::makeDirectories(dirname($filename)); + + $args = array('data_fixtures_path' => array($filename)); + $this->logSection('doctrine', sprintf('dumping data to fixtures to "%s"', $filename)); + } else { + $this->logSection('doctrine', sprintf('dumping data to fixtures to "%s"', $config['data_fixtures_path'][0])); + } + + $this->callDoctrineCli('dump-data', $args); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDataLoadTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDataLoadTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,89 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Loads data from fixtures directory. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineDataLoadTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineLoadDataTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('append', null, sfCommandOption::PARAMETER_NONE, 'Don\'t delete current data in the database'), + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'), + )); + + $this->aliases = array('doctrine-load-data'); + $this->namespace = 'doctrine'; + $this->name = 'data-load'; + $this->briefDescription = 'Loads data from fixtures directory'; + + $this->detailedDescription = <<configuration); + + $arguments = array(); + if (isset($options['append']) && $options['append']) + { + $arguments['append'] = $options['append']; + } + + if (isset($options['dir']) && $options['dir']) + { + $arguments['data_fixtures_path'] = $options['dir']; + foreach ($options['dir'] as $dir) + { + $this->logSection('doctrine', sprintf('loading data fixtures from "%s"', $dir)); + } + } else { + $config = $this->getCliConfig(); + $this->logSection('doctrine', sprintf('loading data fixtures from "%s"', $config['data_fixtures_path'][0])); + } + + $this->callDoctrineCli('load-data', $arguments); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDqlTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDqlTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,93 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Creates database for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineDqlTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineDqlTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('dql_query', sfCommandArgument::REQUIRED, 'The DQL query to execute', null), + )); + + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('show-sql', null, sfCommandOption::PARAMETER_NONE, 'Show the sql that would be executed'), + )); + + $this->aliases = array('doctrine-dql'); + $this->namespace = 'doctrine'; + $this->name = 'dql'; + $this->briefDescription = 'Execute a DQL query and view the results'; + + $this->detailedDescription = <<configuration); + + $dql = $arguments['dql_query']; + + $q = Doctrine_Query::create() + ->parseQuery($dql); + + $this->logSection('doctrine', 'executing dql query'); + + echo sprintf('DQL: %s', $dql) . "\n"; + + if ($options['show-sql']) { + echo sprintf('SQL: %s', $q->getSql()) . "\n"; + } + + $count = $q->count(); + + if ($count) + { + echo sprintf('found %s results', $count) . "\n"; + + $results = $q->fetchArray(); + $yaml = sfYaml::dump($results, 4); + $lines = explode("\n", $yaml); + foreach ($lines as $line) + { + echo $line . "\n"; + } + } else { + $this->logSection('doctrine', 'no results found'); + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDropDbTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineDropDbTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,71 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Drops database for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineDropDbTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineDropDbTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Whether to force dropping of the database') + )); + + $this->aliases = array('doctrine-drop-db'); + $this->namespace = 'doctrine'; + $this->name = 'drop-db'; + $this->briefDescription = 'Drops database for current model'; + + $this->detailedDescription = <<askConfirmation(array('This command will remove all data in your database.', 'Are you sure you want to proceed? (y/N)'), null, false) + ) + { + $this->logSection('doctrine', 'task aborted'); + + return 1; + } + + $this->logSection('doctrine', 'dropping databases'); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('drop-db', array('force' => true)); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateAdminTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateAdminTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,188 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Generates a Doctrine admin module. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineGenerateAdminTask.class.php 12474 2008-10-31 10:41:27Z fabien $ + */ +class sfDoctrineGenerateAdminTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'), + new sfCommandArgument('route_or_model', sfCommandArgument::REQUIRED, 'The route name or the model class'), + )); + + $this->addOptions(array( + new sfCommandOption('module', null, sfCommandOption::PARAMETER_REQUIRED, 'The module name', null), + new sfCommandOption('theme', null, sfCommandOption::PARAMETER_REQUIRED, 'The theme name', 'admin'), + new sfCommandOption('singular', null, sfCommandOption::PARAMETER_REQUIRED, 'The singular name', null), + new sfCommandOption('plural', null, sfCommandOption::PARAMETER_REQUIRED, 'The plural name', null), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->namespace = 'doctrine'; + $this->name = 'generate-admin'; + $this->briefDescription = 'Generates a Doctrine admin module'; + + $this->detailedDescription = <<getRouteFromName($arguments['route_or_model']))) + { + $arguments['route'] = $route; + $arguments['route_name'] = $arguments['route_or_model']; + + return $this->generateForRoute($arguments, $options); + } + + // is it a model class name + if (!class_exists($arguments['route_or_model'])) + { + throw new sfCommandException(sprintf('The route "%s" does not exist and there is no "%s" class.', $arguments['route_or_model'], $arguments['route_or_model'])); + } + + $r = new ReflectionClass($arguments['route_or_model']); + if (!$r->isSubclassOf('Doctrine_Record')) + { + throw new sfCommandException(sprintf('"%s" is not a Doctrine class.', $arguments['route_or_model'])); + } + + // create a route + $model = $arguments['route_or_model']; + $name = strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), '\\1_\\2', $model)); + $name = $options['module'] ? $name . '_' . $options['module'] : $name; + + $routing = sfConfig::get('sf_app_config_dir').'/routing.yml'; + $content = file_get_contents($routing); + $routesArray = sfYaml::load($content); + + if (!isset($routesArray[$name])) + { + $databaseManager = new sfDatabaseManager($this->configuration); + $primaryKey = Doctrine::getTable($model)->getIdentifier(); + $module = $options['module'] ? $options['module'] : $name; + $content = sprintf(<<getRouteFromName($name); + $arguments['route_name'] = $name; + + return $this->generateForRoute($arguments, $options); + } + + protected function generateForRoute($arguments, $options) + { + $routeOptions = $arguments['route']->getOptions(); + + if (!$arguments['route'] instanceof sfDoctrineRouteCollection) + { + throw new sfCommandException(sprintf('The route "%s" is not a Doctrine collection route.', $arguments['route_name'])); + } + + $module = $routeOptions['module']; + $model = $routeOptions['model']; + + // execute the doctrine:generate-module task + $task = new sfDoctrineGenerateModuleTask($this->dispatcher, $this->formatter); + $task->setCommandApplication($this->commandApplication); + + $taskOptions = array( + '--theme='.$options['theme'], + '--env='.$options['env'], + '--route-prefix='.$routeOptions['name'], + '--with-doctrine-route', + '--generate-in-cache', + '--non-verbose-templates', + ); + + if (!is_null($options['singular'])) + { + $taskOptions[] = '--singular='.$options['singular']; + } + + if (!is_null($options['plural'])) + { + $taskOptions[] = '--plural='.$options['plural']; + } + + $this->logSection('app', sprintf('Generating admin module "%s" for model "%s"', $module, $model)); + + return $task->run(array($arguments['application'], $module, $model), $taskOptions); + } + + protected function getRouteFromName($name) + { + $config = new sfRoutingConfigHandler(); + $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml')); + + if (isset($routes[$name])) + { + return $routes[$name]; + } + + return false; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,61 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Inserts SQL for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineGenerateMigrationTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineGenerateMigrationTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The name of the migration'), + )); + + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-generate-migration'); + $this->namespace = 'doctrine'; + $this->name = 'generate-migration'; + $this->briefDescription = 'Generate migration class'; + + $this->detailedDescription = <<logSection('doctrine', sprintf('generating migration class named "%s"', $arguments['name'])); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('generate-migration', array('name' => $arguments['name'])); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationsDbTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationsDbTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,57 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Generate migrations from database + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineGenerateMigrationsDbTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineGenerateMigrationsDbTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-generate-migrations-db', 'doctrine-gen-migrations-from-db'); + $this->namespace = 'doctrine'; + $this->name = 'generate-migrations-db'; + $this->briefDescription = 'Generate migration classes from existing database connections'; + + $this->detailedDescription = <<logSection('doctrine', 'generating migration classes from database'); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('generate-migrations-db'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationsModelsTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationsModelsTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,57 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Inserts SQL for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineGenerateMigrationsModelsTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineGenerateMigrationsModelsTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-generate-migrations-models', 'doctrine-gen-migrations-from-models'); + $this->namespace = 'doctrine'; + $this->name = 'generate-migrations-models'; + $this->briefDescription = 'Generate migration classes from an existing set of models'; + + $this->detailedDescription = <<logSection('doctrine', 'generating migration classes from models'); + + $databaseManager = new sfDatabaseManager($this->configuration); + $this->callDoctrineCli('generate-migrations-models'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateModuleForRouteTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateModuleForRouteTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Generates a Doctrine module for a route definition. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineGenerateModuleForRouteTask.class.php 12161 2008-10-13 07:42:25Z fabien $ + */ +class sfDoctrineGenerateModuleForRouteTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'), + new sfCommandArgument('route', sfCommandArgument::REQUIRED, 'The route name'), + )); + + $this->addOptions(array( + new sfCommandOption('theme', null, sfCommandOption::PARAMETER_REQUIRED, 'The theme name', 'default'), + new sfCommandOption('non-verbose-templates', null, sfCommandOption::PARAMETER_NONE, 'Generate non verbose templates'), + new sfCommandOption('singular', null, sfCommandOption::PARAMETER_REQUIRED, 'The singular name', null), + new sfCommandOption('plural', null, sfCommandOption::PARAMETER_REQUIRED, 'The plural name', null), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->namespace = 'doctrine'; + $this->name = 'generate-module-for-route'; + $this->briefDescription = 'Generates a Doctrine module for a route definition'; + + $this->detailedDescription = <<evaluate($this->configuration->getConfigPaths('config/routing.yml')); + + if (!isset($routes[$arguments['route']])) + { + throw new sfCommandException(sprintf('The route "%s" does not exist.', $arguments['route'])); + } + + $routeOptions = $routes[$arguments['route']]->getOptions(); + + if (!$routes[$arguments['route']] instanceof sfDoctrineRouteCollection) + { + throw new sfCommandException(sprintf('The route "%s" is not a Doctrine collection route.', $arguments['route'])); + } + + $module = $routeOptions['module']; + $model = $routeOptions['model']; + + // execute the doctrine:generate-module task + $task = new sfDoctrineGenerateModuleTask($this->dispatcher, $this->formatter); + $task->setCommandApplication($this->commandApplication); + + $taskOptions = array( + '--theme='.$options['theme'], + '--env='.$options['env'], + '--route-prefix='.$routeOptions['name'], + '--with-doctrine-route', + ); + + if ($routeOptions['with_show']) + { + $taskOptions[] = '--with-show'; + } + + if ($options['non-verbose-templates']) + { + $taskOptions[] = '--non-verbose-templates'; + } + + if (!is_null($options['singular'])) + { + $taskOptions[] = '--singular='.$options['singular']; + } + + if (!is_null($options['plural'])) + { + $taskOptions[] = '--plural='.$options['plural']; + } + + $this->logSection('app', sprintf('Generating module "%s" for model "%s"', $module, $model)); + + return $task->run(array($arguments['application'], $module, $model), $taskOptions); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateModuleTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineGenerateModuleTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,214 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Generates a Doctrine module. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @version SVN: $Id: sfDoctrineGenerateModuleTask.class.php 12474 2008-10-31 10:41:27Z fabien $ + */ +class sfDoctrineGenerateModuleTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'), + new sfCommandArgument('module', sfCommandArgument::REQUIRED, 'The module name'), + new sfCommandArgument('model', sfCommandArgument::REQUIRED, 'The model class name'), + )); + + $this->addOptions(array( + new sfCommandOption('theme', null, sfCommandOption::PARAMETER_REQUIRED, 'The theme name', 'default'), + new sfCommandOption('generate-in-cache', null, sfCommandOption::PARAMETER_NONE, 'Generate the module in cache'), + new sfCommandOption('non-verbose-templates', null, sfCommandOption::PARAMETER_NONE, 'Generate non verbose templates'), + new sfCommandOption('with-show', null, sfCommandOption::PARAMETER_NONE, 'Generate a show method'), + new sfCommandOption('singular', null, sfCommandOption::PARAMETER_REQUIRED, 'The singular name', null), + new sfCommandOption('plural', null, sfCommandOption::PARAMETER_REQUIRED, 'The plural name', null), + new sfCommandOption('route-prefix', null, sfCommandOption::PARAMETER_REQUIRED, 'The route prefix', null), + new sfCommandOption('with-doctrine-route', null, sfCommandOption::PARAMETER_NONE, 'Whether you will use a Doctrine route'), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-generate-crud', 'doctrine:generate-crud'); + $this->namespace = 'doctrine'; + $this->name = 'generate-module'; + $this->briefDescription = 'Generates a Doctrine module'; + + $this->detailedDescription = <<configuration); + + $properties = parse_ini_file(sfConfig::get('sf_config_dir').'/properties.ini', true); + + $this->constants = array( + 'PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', + 'APP_NAME' => $arguments['application'], + 'MODULE_NAME' => $arguments['module'], + 'UC_MODULE_NAME' => ucfirst($arguments['module']), + 'MODEL_CLASS' => $arguments['model'], + 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', + ); + + $method = $options['generate-in-cache'] ? 'executeInit' : 'executeGenerate'; + + $this->$method($arguments, $options); + } + + protected function executeGenerate($arguments = array(), $options = array()) + { + // generate module + $tmpDir = sfConfig::get('sf_cache_dir').DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true)); + $generatorManager = new sfGeneratorManager($this->configuration, $tmpDir); + $generatorManager->generate('sfDoctrineGenerator', array( + 'model_class' => $arguments['model'], + 'moduleName' => $arguments['module'], + 'theme' => $options['theme'], + 'non_verbose_templates' => $options['non-verbose-templates'], + 'with_show' => $options['with-show'], + 'singular' => $options['singular'], + 'plural' => $options['plural'], + 'route_prefix' => $options['route-prefix'], + 'with_doctrine_route' => $options['with-doctrine-route'], + )); + + $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$arguments['module']; + + // copy our generated module + $this->getFilesystem()->mirror($tmpDir.DIRECTORY_SEPARATOR.'auto'.ucfirst($arguments['module']), $moduleDir, sfFinder::type('any')); + + if (!$options['with-show']) + { + $this->getFilesystem()->remove($moduleDir.'/templates/showSuccess.php'); + } + + // change module name + $finder = sfFinder::type('file')->name('*.php'); + $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '', '', array('auto'.ucfirst($arguments['module']) => $arguments['module'])); + + // customize php and yml files + $finder = sfFinder::type('file')->name('*.php', '*.yml'); + $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); + + // create basic test + $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'task'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'skeleton'.DIRECTORY_SEPARATOR.'module'.DIRECTORY_SEPARATOR.'test'.DIRECTORY_SEPARATOR.'actionsTest.php', sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php'); + + // customize test file + $this->getFilesystem()->replaceTokens(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php', '##', '##', $this->constants); + + // delete temp files + $this->getFilesystem()->remove(sfFinder::type('any')->in($tmpDir)); + } + + protected function executeInit($arguments = array(), $options = array()) + { + $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$arguments['module']; + + // create basic application structure + $finder = sfFinder::type('any')->discard('.sf'); + $dirs = $this->configuration->getGeneratorSkeletonDirs('sfDoctrineModule', $options['theme']); + + foreach ($dirs as $dir) + { + if (is_dir($dir)) + { + $this->getFilesystem()->mirror($dir, $moduleDir, $finder); + break; + } + } + + // move configuration file + if (file_exists($config = $moduleDir.'/lib/configuration.php')) + { + if (file_exists($target = $moduleDir.'/lib/'.$arguments['module'].'GeneratorConfiguration.class.php')) + { + $this->getFilesystem()->remove($config); + } + else + { + $this->getFilesystem()->rename($config, $target); + } + } + + // move helper file + if (file_exists($config = $moduleDir.'/lib/helper.php')) + { + if (file_exists($target = $moduleDir.'/lib/'.$arguments['module'].'GeneratorHelper.class.php')) + { + $this->getFilesystem()->remove($config); + } + else + { + $this->getFilesystem()->rename($config, $target); + } + } + + // create basic test + $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'task'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'skeleton'.DIRECTORY_SEPARATOR.'module'.DIRECTORY_SEPARATOR.'test'.DIRECTORY_SEPARATOR.'actionsTest.php', sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php'); + + // customize test file + $this->getFilesystem()->replaceTokens(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php', '##', '##', $this->constants); + + // customize php and yml files + $finder = sfFinder::type('file')->name('*.php', '*.yml'); + $this->constants['CONFIG'] = sprintf(<<getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineInsertSqlTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineInsertSqlTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,61 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Inserts SQL for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineInsertSqlTask.class.php 14255 2008-12-22 19:41:42Z Jonathan.Wage $ + */ +class sfDoctrineInsertSqlTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-insert-sql'); + $this->namespace = 'doctrine'; + $this->name = 'insert-sql'; + $this->briefDescription = 'Inserts SQL for current model'; + + $this->detailedDescription = <<logSection('doctrine', 'created tables successfully'); + + $databaseManager = new sfDatabaseManager($this->configuration); + Doctrine::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE); + Doctrine::createTablesFromArray(Doctrine::getLoadedModels()); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineMigrateTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineMigrateTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,60 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Inserts SQL for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineMigrateTask.class.php 14213 2008-12-19 21:03:13Z Jonathan.Wage $ + */ +class sfDoctrineMigrateTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('version', sfCommandArgument::OPTIONAL, 'The version to migrate to', null), + )); + + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + )); + + $this->aliases = array('doctrine-migrate'); + $this->namespace = 'doctrine'; + $this->name = 'migrate'; + $this->briefDescription = 'Migrates database to current/specified version'; + + $this->detailedDescription = <<configuration); + + $this->callDoctrineCli('migrate', array('version' => $arguments['version'])); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineRebuildDbTask.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/task/sfDoctrineRebuildDbTask.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,74 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); + +/** + * Creates database for current model. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineRebuildDbTask.class.php 16087 2009-03-07 22:08:50Z Kris.Wallsmith $ + */ +class sfDoctrineRebuildDbTask extends sfDoctrineBaseTask +{ + /** + * @see sfTask + */ + protected function configure() + { + $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Whether to no-confirmation dropping of the database') + )); + + $this->aliases = array('doctrine-rebuild-db'); + $this->namespace = 'doctrine'; + $this->name = 'rebuild-db'; + $this->briefDescription = 'Creates database for current model'; + + $this->detailedDescription = <<configuration instanceof sfApplicationConfiguration ? array( + '--application='.$this->configuration->getApplication(), + '--env='.$options['env'], + ) : array(); + + $dropDbOptions = $baseOptions; + if (isset($options['no-confirmation']) && $options['no-confirmation']) + { + $dropDbOptions[] = '--no-confirmation'; + } + + $dropDb = new sfDoctrineDropDbTask($this->dispatcher, $this->formatter); + $dropDb->setCommandApplication($this->commandApplication); + $dropDb->run(array(), $dropDbOptions); + + $buildAll = new sfDoctrineBuildAllTask($this->dispatcher, $this->formatter); + $buildAll->setCommandApplication($this->commandApplication); + $buildAll->run(array(), $baseOptions); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/test/sfTesterDoctrine.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/test/sfTesterDoctrine.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfTesterDoctrine implements tests for Doctrine classes. + * + * @package symfony + * @subpackage test + * @author Fabien Potencier + * @version SVN: $Id: sfTesterDoctrine.class.php 12237 2008-10-17 22:25:25Z Kris.Wallsmith $ + */ +class sfTesterDoctrine extends sfTester +{ + /** + * Prepares the tester. + */ + public function prepare() + { + } + + /** + * Initializes the tester. + */ + public function initialize() + { + } + + /** + * Tests a model. + * + * @param string $model The model class name + * @param array|Doctrine_Query $query A Doctrine_Query object or an array of conditions + * @param string $value The value to test + * + * @return sfTestFunctionalBase|sfTester + */ + public function check($model, $query, $value = true) + { + if (is_null($query)) + { + $query = Doctrine::getTable($model) + ->createQuery('a'); + } + + if (is_array($query)) + { + $conditions = $query; + $query = $query = Doctrine::getTable($model) + ->createQuery('a'); + foreach ($conditions as $column => $condition) + { + $column = Doctrine::getTable($model)->getFieldName($column); + + if (is_null($condition)) + { + $query->andWhere('a.'.$column.' IS NULL'); + continue; + } + + $operator = '='; + if ('!' == $condition[0]) + { + $operator = false !== strpos($condition, '%') ? 'NOT LIKE' : '!='; + $condition = substr($condition, 1); + } + else if (false !== strpos($condition, '%')) + { + $operator = 'LIKE'; + } + + $query->andWhere('a.' . $column . ' ' . $operator . ' ?', $condition); + } + } + + $objects = $query->execute(); + + if (false === $value) + { + $this->tester->is(count($objects), 0, sprintf('no %s object that matches the criteria has been found', $model)); + } + else if (true === $value) + { + $this->tester->cmp_ok(count($objects), '>', 0, sprintf('%s objects that matches the criteria have been found', $model)); + } + else if (is_int($value)) + { + $this->tester->is(count($objects), $value, sprintf('"%s" %s objects have been found', $value, $model)); + } + else + { + throw new InvalidArgumentException('The "check()" method does not takes this kind of argument.'); + } + + return $this->getObjectToReturn(); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/validator/sfDoctrineUniqueValidator.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/validator/sfDoctrineUniqueValidator.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfDoctrineUniqueValidator validates that the value does not already exists + * + * Required parameters: + * + * # class - [none] - Doctrine class name. + * # column - [none] - Doctrine column name. + * + * Optional parameters: + * + * # unique_error - [Uniqueness error] - An error message to use when + * the value for this column already + * exists in the database. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfDoctrineUniqueValidator.class.php 11629 2008-09-17 22:22:25Z Jonathan.Wage $ + */ +class sfDoctrineUniqueValidator extends sfValidator +{ + /** + * execute + * + * @param string $value + * @param string $error + * @return void + */ + public function execute(&$value, &$error) + { + $className = $this->getParameter('class'); + $columnName = $className.'.'.$this->getParameter('column'); + + $primaryKeys = Doctrine::getTable($className)->getIdentifier(); + if (!is_array($primaryKeys)) + { + $primaryKeys = array($primaryKeys); + } + + // implied assumption: the is at least one primary key + foreach ($primaryKeys as $primaryKey) + { + if (is_null($primaryKeyValue = $this->getContext()->getRequest()->getParameter($primaryKey))) + { + break; + } + } + + $query = Doctrine_Query::create() + ->from($className); + + if ($primaryKeyValue == null) + { + $query->where($columnName.' = ?'); + $res = $query->execute(array($value)); + } else { + $query->where($columnName.' = ? AND '.$primaryKey.' != ?'); + $res = $query->execute(array($value, $primaryKeyValue)); + } + + if ($res->count()) + { + $error = $this->getParameterHolder()->get('unique_error'); + + return false; + } + + return true; + } + + /** + * Initialize this validator. + * + * @param sfContext The current application context. + * @param array An associative array of initialization parameters. + * + * @return bool true, if initialization completes successfully, otherwise false. + */ + public function initialize($context, $parameters = null) + { + // initialize parent + parent::initialize($context); + + // set defaults + $this->setParameter('unique_error', 'Uniqueness error'); + + $this->getParameterHolder()->add($parameters); + + // check parameters + if (!$this->getParameter('class')) + { + throw new sfValidatorException('The "class" parameter is mandatory for the sfDoctrineUniqueValidator validator.'); + } + + if (!$this->getParameter('column')) + { + throw new sfValidatorException('The "column" parameter is mandatory for the sfDoctrineUniqueValidator validator.'); + } + + return true; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,87 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfValidatorDoctrineChoice validates that the value is one of the rows of a table. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfValidatorDoctrineChoice.class.php 8804 2008-05-06 12:11:10Z fabien $ + */ +class sfValidatorDoctrineChoice extends sfValidatorBase +{ + /** + * Configures the current validator. + * + * Available options: + * + * * model: The model class (required) + * * alias: The alias of the root component used in the query + * * query: A query to use when retrieving objects + * * column: The column name (null by default which means we use the primary key) + * must be in field name format + * * connection: The Doctrine connection to use (null by default) + * + * @see sfValidatorBase + */ + protected function configure($options = array(), $messages = array()) + { + $this->addRequiredOption('model'); + $this->addOption('alias', 'a'); + $this->addOption('query', null); + $this->addOption('column', null); + $this->addOption('connection', null); + } + + /** + * @see sfValidatorBase + */ + protected function doClean($value) + { + $a = ($q = $this->getOption('query')) ? $q->getRootAlias():$this->getOption('alias'); + $q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model') . ' ' . $a) : $this->getOption('query'); + $q->addWhere($a . '.' . $this->getColumn() . ' = ?', $value); + + $object = $q->fetchOne(); + + if (!$object) + { + throw new sfValidatorError($this, 'invalid', array('value' => $value)); + } + + return $value; + } + + /** + * Returns the column to use for comparison. + * + * The primary key is used by default. + * + * @return string The column name + */ + protected function getColumn() + { + $table = Doctrine::getTable($this->getOption('model')); + if ($this->getOption('column')) + { + $columnName = $this->getOption('column'); + } + else + { + $identifier = (array) $table->getIdentifier(); + $columnName = current($identifier); + } + + return $table->getColumnName($columnName); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoiceMany.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoiceMany.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,51 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfValidatorDoctrineChoiceMany validates than an array of values is in the array of the existing rows of a table. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfValidatorDoctrineChoiceMany.class.php 7902 2008-03-15 13:17:33Z fabien $ + */ +class sfValidatorDoctrineChoiceMany extends sfValidatorDoctrineChoice +{ + /** + * @see sfValidatorBase + */ + protected function doClean($values) + { + if (!is_array($values)) + { + $values = array($values); + } + + if(isset($values[0]) && !$values[0]) + { + unset($values[0]); + } + + $a = $this->getOption('alias'); + $q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model') . ' ' . $a) : $this->getOption('query'); + $q = $q->andWhereIn($a . '.' . $this->getColumn(), $values); + + $objects = $q->execute(); + + if (count($objects) != count($values)) + { + throw new sfValidatorError($this, 'invalid', array('value' => $values)); + } + + return $values; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineUnique.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineUnique.class.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,163 @@ + + * (c) Jonathan H. Wage + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfValidatorDoctrineUnique validates that the uniqueness of a column. + * + * Warning: sfValidatorDoctrineUnique is susceptible to race conditions. + * To avoid this issue, wrap the validation process and the model saving + * inside a transaction. + * + * @package symfony + * @subpackage doctrine + * @author Fabien Potencier + * @author Jonathan H. Wage + * @version SVN: $Id: sfValidatorDoctrineUnique.class.php 8807 2008-05-06 14:12:28Z fabien $ + */ +class sfValidatorDoctrineUnique extends sfValidatorSchema +{ + /** + * Constructor. + * + * @param array An array of options + * @param array An array of error messages + * + * @see sfValidatorSchema + */ + public function __construct($options = array(), $messages = array()) + { + parent::__construct(null, $options, $messages); + } + + /** + * Configures the current validator. + * + * Available options: + * + * * model: The model class (required) + * * column: The unique column name in Doctrine field name format (required) + * If the uniquess is for several columns, you can pass an array of field names + * * primary_key: The primary key column name in Doctrine field name format (optional, will be introspected if not provided) + * You can also pass an array if the table has several primary keys + * * connection: The Doctrine connection to use (null by default) + * * throw_global_error: Whether to throw a global error (true by default) or an error tied to the first field related to the column option array + * + * @see sfValidatorBase + */ + protected function configure($options = array(), $messages = array()) + { + $this->addRequiredOption('model'); + $this->addRequiredOption('column'); + $this->addOption('primary_key', null); + $this->addOption('connection', null); + $this->addOption('throw_global_error', true); + + $this->setMessage('invalid', 'An object with the same "%column%" already exist.'); + } + + /** + * @see sfValidatorBase + */ + protected function doClean($values) + { + $originalValues = $values; + $table = Doctrine::getTable($this->getOption('model')); + if (!is_array($this->getOption('column'))) + { + $this->setOption('column', array($this->getOption('column'))); + } + + //if $values isn't an array, make it one + if (!is_array($values)) + { + //use first column for key + $columns = $this->getOption('column'); + $values = array($columns[0] => $values); + } + + $q = Doctrine_Query::create() + ->from($this->getOption('model') . ' a'); + + foreach ($this->getOption('column') as $column) + { + $colName = $table->getColumnName($column); + if (!array_key_exists($column, $values)) + { + // one of the column has be removed from the form + return $originalValues; + } + + $q->addWhere('a.' . $colName . ' = ?', $values[$column]); + } + + $object = $q->fetchOne(); + + // if no object or if we're updating the object, it's ok + if (!$object || $this->isUpdate($object, $values)) + { + return $originalValues; + } + + $error = new sfValidatorError($this, 'invalid', array('column' => implode(', ', $this->getOption('column')))); + + if ($this->getOption('throw_global_error')) + { + throw $error; + } + + $columns = $this->getOption('column'); + + throw new sfValidatorErrorSchema($this, array($columns[0] => $error)); + } + + /** + * Returns whether the object is being updated. + * + * @param BaseObject A Doctrine object + * @param array An array of values + * + * @param Boolean true if the object is being updated, false otherwise + */ + protected function isUpdate(Doctrine_Record $object, $values) + { + // check each primary key column + foreach ($this->getPrimaryKeys() as $column) + { + if (!isset($values[$column]) || $object->$column != $values[$column]) + { + return false; + } + } + + return true; + } + + /** + * Returns the primary keys for the model. + * + * @return array An array of primary keys + */ + protected function getPrimaryKeys() + { + if (is_null($this->getOption('primary_key'))) + { + $primaryKeys = Doctrine::getTable($this->getOption('model'))->getIdentifier(); + $this->setOption('primary_key', $primaryKeys); + } + + if (!is_array($this->getOption('primary_key'))) + { + $this->setOption('primary_key', array($this->getOption('primary_key'))); + } + + return $this->getOption('primary_key'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,1003 @@ +. + */ + +/** + * Doctrine + * the base class of Doctrine framework + * + * @package Doctrine + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5885 $ + */ +final class Doctrine +{ + /** + * VERSION + */ + const VERSION = '1.0.10'; + + /** + * ERROR CONSTANTS + */ + const ERR = -1; + const ERR_SYNTAX = -2; + const ERR_CONSTRAINT = -3; + const ERR_NOT_FOUND = -4; + const ERR_ALREADY_EXISTS = -5; + const ERR_UNSUPPORTED = -6; + const ERR_MISMATCH = -7; + const ERR_INVALID = -8; + const ERR_NOT_CAPABLE = -9; + const ERR_TRUNCATED = -10; + const ERR_INVALID_NUMBER = -11; + const ERR_INVALID_DATE = -12; + const ERR_DIVZERO = -13; + const ERR_NODBSELECTED = -14; + const ERR_CANNOT_CREATE = -15; + const ERR_CANNOT_DELETE = -16; + const ERR_CANNOT_DROP = -17; + const ERR_NOSUCHTABLE = -18; + const ERR_NOSUCHFIELD = -19; + const ERR_NEED_MORE_DATA = -20; + const ERR_NOT_LOCKED = -21; + const ERR_VALUE_COUNT_ON_ROW = -22; + const ERR_INVALID_DSN = -23; + const ERR_CONNECT_FAILED = -24; + const ERR_EXTENSION_NOT_FOUND = -25; + const ERR_NOSUCHDB = -26; + const ERR_ACCESS_VIOLATION = -27; + const ERR_CANNOT_REPLACE = -28; + const ERR_CONSTRAINT_NOT_NULL = -29; + const ERR_DEADLOCK = -30; + const ERR_CANNOT_ALTER = -31; + const ERR_MANAGER = -32; + const ERR_MANAGER_PARSE = -33; + const ERR_LOADMODULE = -34; + const ERR_INSUFFICIENT_DATA = -35; + const ERR_CLASS_NAME = -36; + + /** + * PDO derived constants + */ + const CASE_LOWER = 2; + const CASE_NATURAL = 0; + const CASE_UPPER = 1; + const CURSOR_FWDONLY = 0; + const CURSOR_SCROLL = 1; + const ERRMODE_EXCEPTION = 2; + const ERRMODE_SILENT = 0; + const ERRMODE_WARNING = 1; + const FETCH_ASSOC = 2; + const FETCH_BOTH = 4; + const FETCH_BOUND = 6; + const FETCH_CLASS = 8; + const FETCH_CLASSTYPE = 262144; + const FETCH_COLUMN = 7; + const FETCH_FUNC = 10; + const FETCH_GROUP = 65536; + const FETCH_INTO = 9; + const FETCH_LAZY = 1; + const FETCH_NAMED = 11; + const FETCH_NUM = 3; + const FETCH_OBJ = 5; + const FETCH_ORI_ABS = 4; + const FETCH_ORI_FIRST = 2; + const FETCH_ORI_LAST = 3; + const FETCH_ORI_NEXT = 0; + const FETCH_ORI_PRIOR = 1; + const FETCH_ORI_REL = 5; + const FETCH_SERIALIZE = 524288; + const FETCH_UNIQUE = 196608; + const NULL_EMPTY_STRING = 1; + const NULL_NATURAL = 0; + const NULL_TO_STRING = NULL; + const PARAM_BOOL = 5; + const PARAM_INPUT_OUTPUT = -2147483648; + const PARAM_INT = 1; + const PARAM_LOB = 3; + const PARAM_NULL = 0; + const PARAM_STMT = 4; + const PARAM_STR = 2; + + /** + * ATTRIBUTE CONSTANTS + */ + + /** + * PDO derived attributes + */ + const ATTR_AUTOCOMMIT = 0; + const ATTR_PREFETCH = 1; + const ATTR_TIMEOUT = 2; + const ATTR_ERRMODE = 3; + const ATTR_SERVER_VERSION = 4; + const ATTR_CLIENT_VERSION = 5; + const ATTR_SERVER_INFO = 6; + const ATTR_CONNECTION_STATUS = 7; + const ATTR_CASE = 8; + const ATTR_CURSOR_NAME = 9; + const ATTR_CURSOR = 10; + const ATTR_ORACLE_NULLS = 11; + const ATTR_PERSISTENT = 12; + const ATTR_STATEMENT_CLASS = 13; + const ATTR_FETCH_TABLE_NAMES = 14; + const ATTR_FETCH_CATALOG_NAMES = 15; + const ATTR_DRIVER_NAME = 16; + const ATTR_STRINGIFY_FETCHES = 17; + const ATTR_MAX_COLUMN_LEN = 18; + + /** + * Doctrine constants + */ + const ATTR_LISTENER = 100; + const ATTR_QUOTE_IDENTIFIER = 101; + const ATTR_FIELD_CASE = 102; + const ATTR_IDXNAME_FORMAT = 103; + const ATTR_SEQNAME_FORMAT = 104; + const ATTR_SEQCOL_NAME = 105; + const ATTR_CMPNAME_FORMAT = 118; + const ATTR_DBNAME_FORMAT = 117; + const ATTR_TBLCLASS_FORMAT = 119; + const ATTR_TBLNAME_FORMAT = 120; + const ATTR_EXPORT = 140; + const ATTR_DECIMAL_PLACES = 141; + + const ATTR_PORTABILITY = 106; + const ATTR_VALIDATE = 107; + const ATTR_COLL_KEY = 108; + const ATTR_QUERY_LIMIT = 109; + const ATTR_DEFAULT_TABLE_TYPE = 112; + const ATTR_DEF_TEXT_LENGTH = 113; + const ATTR_DEF_VARCHAR_LENGTH = 114; + const ATTR_DEF_TABLESPACE = 115; + const ATTR_EMULATE_DATABASE = 116; + const ATTR_USE_NATIVE_ENUM = 117; + const ATTR_DEFAULT_SEQUENCE = 133; + + const ATTR_FETCHMODE = 118; + const ATTR_NAME_PREFIX = 121; + const ATTR_CREATE_TABLES = 122; + const ATTR_COLL_LIMIT = 123; + + const ATTR_CACHE = 150; + const ATTR_RESULT_CACHE = 150; + const ATTR_CACHE_LIFESPAN = 151; + const ATTR_RESULT_CACHE_LIFESPAN = 151; + const ATTR_LOAD_REFERENCES = 153; + const ATTR_RECORD_LISTENER = 154; + const ATTR_THROW_EXCEPTIONS = 155; + const ATTR_DEFAULT_PARAM_NAMESPACE = 156; + const ATTR_QUERY_CACHE = 157; + const ATTR_QUERY_CACHE_LIFESPAN = 158; + const ATTR_AUTOLOAD_TABLE_CLASSES = 160; + const ATTR_MODEL_LOADING = 161; + const ATTR_RECURSIVE_MERGE_FIXTURES = 162; + const ATTR_USE_DQL_CALLBACKS = 164; + const ATTR_AUTO_ACCESSOR_OVERRIDE = 165; + const ATTR_HYDRATE_OVERWRITE = 166; + + /** + * LIMIT CONSTANTS + */ + + /** + * constant for row limiting + */ + const LIMIT_ROWS = 1; + const QUERY_LIMIT_ROWS = 1; + + /** + * constant for record limiting + */ + const LIMIT_RECORDS = 2; + const QUERY_LIMIT_RECORDS = 2; + + /** + * FETCHMODE CONSTANTS + */ + + + /** + * PORTABILITY CONSTANTS + */ + + /** + * Portability: turn off all portability features. + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_NONE = 0; + + /** + * Portability: convert names of tables and fields to case defined in the + * "field_case" option when using the query*(), fetch*() methods. + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_FIX_CASE = 1; + + /** + * Portability: right trim the data output by query*() and fetch*(). + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_RTRIM = 2; + + /** + * Portability: force reporting the number of rows deleted. + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_DELETE_COUNT = 4; + + /** + * Portability: convert empty values to null strings in data output by + * query*() and fetch*(). + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_EMPTY_TO_NULL = 8; + + /** + * Portability: removes database/table qualifiers from associative indexes + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_FIX_ASSOC_FIELD_NAMES = 16; + + /** + * Portability: makes Doctrine_Expression throw exception for unportable RDBMS expressions + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_EXPR = 32; + + /** + * Portability: turn on all portability features. + * @see self::ATTR_PORTABILITY + */ + const PORTABILITY_ALL = 63; + + /** + * LOCKMODE CONSTANTS + */ + + /** + * mode for optimistic locking + */ + const LOCK_OPTIMISTIC = 0; + + /** + * mode for pessimistic locking + */ + const LOCK_PESSIMISTIC = 1; + + /** + * EXPORT CONSTANTS + */ + + /** + * EXPORT_NONE + */ + const EXPORT_NONE = 0; + + /** + * EXPORT_TABLES + */ + const EXPORT_TABLES = 1; + + /** + * EXPORT_CONSTRAINTS + */ + const EXPORT_CONSTRAINTS = 2; + + /** + * EXPORT_PLUGINS + */ + const EXPORT_PLUGINS = 4; + + /** + * EXPORT_ALL + */ + const EXPORT_ALL = 7; + + /** + * HYDRATION CONSTANTS + */ + const HYDRATE_RECORD = 2; + + /** + * HYDRATE_ARRAY + */ + const HYDRATE_ARRAY = 3; + + /** + * HYDRATE_NONE + */ + const HYDRATE_NONE = 4; + + /** + * VALIDATION CONSTANTS + */ + const VALIDATE_NONE = 0; + + /** + * VALIDATE_LENGTHS + */ + const VALIDATE_LENGTHS = 1; + + /** + * VALIDATE_TYPES + */ + const VALIDATE_TYPES = 2; + + /** + * VALIDATE_CONSTRAINTS + */ + const VALIDATE_CONSTRAINTS = 4; + + /** + * VALIDATE_ALL + */ + const VALIDATE_ALL = 7; + + /** + * IDENTIFIER_AUTOINC + * + * constant for auto_increment identifier + */ + const IDENTIFIER_AUTOINC = 1; + + /** + * IDENTIFIER_SEQUENCE + * + * constant for sequence identifier + */ + const IDENTIFIER_SEQUENCE = 2; + + /** + * IDENTIFIER_NATURAL + * + * constant for normal identifier + */ + const IDENTIFIER_NATURAL = 3; + + /** + * IDENTIFIER_COMPOSITE + * + * constant for composite identifier + */ + const IDENTIFIER_COMPOSITE = 4; + + /** + * MODEL_LOADING_AGGRESSIVE + * + * Constant for agressive model loading + * Will require_once() all found model files + */ + const MODEL_LOADING_AGGRESSIVE = 1; + + /** + * MODEL_LOADING_CONSERVATIVE + * + * Constant for conservative model loading + * Will not require_once() found model files inititally instead it will build an array + * and reference it in autoload() when a class is needed it will require_once() it + */ + const MODEL_LOADING_CONSERVATIVE= 2; + + /** + * Path to Doctrine root + * + * @var string $path doctrine root directory + */ + private static $_path; + + /** + * Debug bool true/false option + * + * @var boolean $_debug + */ + private static $_debug = false; + + /** + * Array of all the loaded models and the path to each one for autoloading + * + * @var array + */ + private static $_loadedModelFiles = array(); + + /** + * Array of all the loaded validators + * + * @var array + */ + private static $_validators = array(); + + /** + * __construct + * + * @return void + * @throws Doctrine_Exception + */ + public function __construct() + { + throw new Doctrine_Exception('Doctrine is static class. No instances can be created.'); + } + + /** + * Returns an array of all the loaded models and the path where each of them exists + * + * @return array + */ + public static function getLoadedModelFiles() + { + return self::$_loadedModelFiles; + } + + /** + * Turn on/off the debugging setting + * + * @param string $bool + * @return void + */ + public static function debug($bool = null) + { + if ($bool !== null) { + self::$_debug = (bool) $bool; + } + + return self::$_debug; + } + + /** + * Get the root path to Doctrine + * + * @return string + */ + public static function getPath() + { + if ( ! self::$_path) { + self::$_path = dirname(__FILE__); + } + + return self::$_path; + } + + /** + * Load an individual model name and path in to the model loading registry + * + * @return null + */ + public static function loadModel($className, $path = null) + { + self::$_loadedModelFiles[$className] = $path; + } + + /** + * Recursively load all models from a directory or array of directories + * + * @param string $directory Path to directory of models or array of directory paths + * @param integer $modelLoading Pass value of Doctrine::ATTR_MODEL_LOADING to force a certain style of model loading + * Allowed Doctrine::MODEL_LOADING_AGGRESSIVE(default) or Doctrine::MODEL_LOADING_CONSERVATIVE + */ + public static function loadModels($directory, $modelLoading = null) + { + $manager = Doctrine_Manager::getInstance(); + + $modelLoading = $modelLoading === null ? $manager->getAttribute(Doctrine::ATTR_MODEL_LOADING):$modelLoading; + + $loadedModels = array(); + + if ($directory !== null) { + foreach ((array) $directory as $dir) { + if ( ! is_dir($dir)) { + throw new Doctrine_Exception('You must pass a valid path to a directory containing Doctrine models'); + } + + $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), + RecursiveIteratorIterator::LEAVES_ONLY); + foreach ($it as $file) { + $e = explode('.', $file->getFileName()); + if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { + $className = $e[0]; + + if ($modelLoading == Doctrine::MODEL_LOADING_CONSERVATIVE) { + self::loadModel($className, $file->getPathName()); + + $loadedModels[$className] = $className; + } else { + $declaredBefore = get_declared_classes(); + require_once($file->getPathName()); + + $declaredAfter = get_declared_classes(); + // Using array_slice because array_diff is broken is some PHP versions + $foundClasses = array_slice($declaredAfter, count($declaredBefore) - 1); + if ($foundClasses) { + foreach ($foundClasses as $className) { + if (self::isValidModelClass($className)) { + $loadedModels[$className] = $className; + + self::loadModel($className, $file->getPathName()); + } + } + } + $previouslyLoaded = array_keys(self::$_loadedModelFiles, $file->getPathName()); + if ( ! empty($previouslyLoaded)) { + $previouslyLoaded = array_combine(array_values($previouslyLoaded), array_values($previouslyLoaded)); + $loadedModels = array_merge($loadedModels, $previouslyLoaded); + } + } + } + } + } + } + + return $loadedModels; + } + + /** + * Get all the loaded models, you can provide an array of classes or it will use get_declared_classes() + * + * Will filter through an array of classes and return the Doctrine_Records out of them. + * If you do not specify $classes it will return all of the currently loaded Doctrine_Records + * + * @param classes Array of classes to filter through, otherwise uses get_declared_classes() + * @return array $loadedModels + */ + public static function getLoadedModels($classes = null) + { + if ($classes === null) { + $classes = get_declared_classes(); + $classes = array_merge($classes, array_keys(self::$_loadedModelFiles)); + } + + return self::filterInvalidModels($classes); + } + + /** + * Initialize all models so everything is present and loaded in to memory + * This will also inheritently initialize any model behaviors and add + * the models generated by Doctrine generators and add them to the $models + * array + * + * @param string $models + * @return array $models + */ + public static function initializeModels($models) + { + $models = self::filterInvalidModels($models); + + foreach ($models as $model) { + $declaredBefore = get_declared_classes(); + Doctrine::getTable($model); + + $declaredAfter = get_declared_classes(); + // Using array_slice because array_diff is broken is some PHP versions + $foundClasses = array_slice($declaredAfter, count($declaredBefore) - 1); + foreach ($foundClasses as $class) { + if (self::isValidModelClass($class)) { + $models[] = $class; + } + } + } + + $models = self::filterInvalidModels($models); + + return $models; + } + + /** + * Filter through an array of classes and return all the classes that are valid models. + * This will inflect the class, causing it to be loaded in to memory. + * + * @param classes Array of classes to filter through, otherwise uses get_declared_classes() + * @return array $loadedModels + */ + public static function filterInvalidModels($classes) + { + $validModels = array(); + + foreach ((array) $classes as $name) { + if (self::isValidModelClass($name) && ! in_array($name, $validModels)) { + $validModels[] = $name; + } + } + + return $validModels; + } + + /** + * Checks if what is passed is a valid Doctrine_Record + * Will load class in to memory in order to inflect it and find out information about the class + * + * @param mixed $class Can be a string named after the class, an instance of the class, or an instance of the class reflected + * @return boolean + */ + public static function isValidModelClass($class) + { + if ($class instanceof Doctrine_Record) { + $class = get_class($class); + } + + if (is_string($class) && class_exists($class)) { + $class = new ReflectionClass($class); + } + + if ($class instanceof ReflectionClass) { + // Skip the following classes + // - abstract classes + // - not a subclass of Doctrine_Record + if ( ! $class->isAbstract() && $class->isSubClassOf('Doctrine_Record')) { + + return true; + } + } + + return false; + } + + /** + * Get the connection object for a table by the actual table name + * FIXME: I think this method is flawed because a individual connections could have the same table name + * + * @param string $tableName + * @return Doctrine_Connection + */ + public static function getConnectionByTableName($tableName) + { + $loadedModels = self::getLoadedModels(); + + foreach ($loadedModels as $name) { + $table = Doctrine::getTable($name); + + if ($table->getTableName() == $tableName) { + return $table->getConnection(); + } + } + + return Doctrine_Manager::connection(); + } + + /** + * Method for importing existing schema to Doctrine_Record classes + * + * @param string $directory Directory to write your models to + * @param array $databases Array of databases to generate models for + * @param array $options Array of options + * @return boolean + * @throws Exception + */ + public static function generateModelsFromDb($directory, array $databases = array(), array $options = array()) + { + return Doctrine_Manager::connection()->import->importSchema($directory, $databases, $options); + } + + /** + * Generates models from database to temporary location then uses those models to generate a yaml schema file. + * This should probably be fixed. We should write something to generate a yaml schema file directly from the database. + * + * @param string $yamlPath Path to write oyur yaml schema file to + * @param array $options Array of options + * @return void + */ + public static function generateYamlFromDb($yamlPath, array $databases = array(), array $options = array()) + { + $directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models'; + + $options['generateBaseClasses'] = isset($options['generateBaseClasses']) ? $options['generateBaseClasses']:false; + $result = Doctrine::generateModelsFromDb($directory, $databases, $options); + + if ( empty($result) && ! is_dir($directory)) { + throw new Doctrine_Exception('No models generated from your databases'); + } + + $export = new Doctrine_Export_Schema(); + + $result = $export->exportSchema($yamlPath, 'yml', $directory); + + Doctrine_Lib::removeDirectories($directory); + + return $result; + } + + /** + * Generate a yaml schema file from an existing directory of models + * + * @param string $yamlPath Path to your yaml schema files + * @param string $directory Directory to generate your models in + * @param array $options Array of options to pass to the schema importer + * @return void + */ + public static function generateModelsFromYaml($yamlPath, $directory, $options = array()) + { + $import = new Doctrine_Import_Schema(); + $import->setOptions($options); + + return $import->importSchema($yamlPath, 'yml', $directory); + } + + /** + * Creates database tables for the models in the specified directory + * + * @param string $directory Directory containing your models + * @return void + */ + public static function createTablesFromModels($directory = null) + { + return Doctrine_Manager::connection()->export->exportSchema($directory); + } + + /** + * Creates database tables for the models in the supplied array + * + * @param array $array An array of models to be exported + * @return void + */ + public static function createTablesFromArray($array) + { + return Doctrine_Manager::connection()->export->exportClasses($array); + } + + /** + * Generate a array of sql for the passed array of models + * + * @param array $array + * @return array $sql + */ + public static function generateSqlFromArray($array) + { + return Doctrine_Manager::connection()->export->exportClassesSql($array); + } + + /** + * Generate a sql string to create the tables from all loaded models + * or the models found in the passed directory. + * + * @param string $directory + * @return string $build String of sql queries. One query per line + */ + public static function generateSqlFromModels($directory = null) + { + $conn = Doctrine_Manager::connection(); + $sql = $conn->export->exportSql($directory); + + $build = ''; + foreach ($sql as $query) { + $build .= $query.$conn->sql_file_delimiter; + } + + return $build; + } + + /** + * Generate yaml schema file for the models in the specified directory + * + * @param string $yamlPath Path to your yaml schema files + * @param string $directory Directory to generate your models in + * @return void + */ + public static function generateYamlFromModels($yamlPath, $directory) + { + $export = new Doctrine_Export_Schema(); + + return $export->exportSchema($yamlPath, 'yml', $directory); + } + + /** + * Creates databases for connections + * + * @param string $specifiedConnections Array of connections you wish to create the database for + * @return void + */ + public static function createDatabases($specifiedConnections = array()) + { + return Doctrine_Manager::getInstance()->createDatabases($specifiedConnections); + } + + /** + * Drops databases for connections + * + * @param string $specifiedConnections Array of connections you wish to drop the database for + * @return void + */ + public static function dropDatabases($specifiedConnections = array()) + { + return Doctrine_Manager::getInstance()->dropDatabases($specifiedConnections); + } + + /** + * Dump data to a yaml fixtures file + * + * @param string $yamlPath Path to write the yaml data fixtures to + * @param string $individualFiles Whether or not to dump data to individual fixtures files + * @return void + */ + public static function dumpData($yamlPath, $individualFiles = false) + { + $data = new Doctrine_Data(); + + return $data->exportData($yamlPath, 'yml', array(), $individualFiles); + } + + /** + * Load data from a yaml fixtures file. + * The output of dumpData can be fed to loadData + * + * @param string $yamlPath Path to your yaml data fixtures + * @param string $append Whether or not to append the data + * @return void + */ + public static function loadData($yamlPath, $append = false) + { + $data = new Doctrine_Data(); + + return $data->importData($yamlPath, 'yml', array(), $append); + } + + /** + * Migrate database to specified $to version. Migrates from current to latest if you do not specify. + * + * @param string $migrationsPath Path to migrations directory which contains your migration classes + * @param string $to Version you wish to migrate to. + * @return bool true + * @throws new Doctrine_Migration_Exception + */ + public static function migrate($migrationsPath, $to = null) + { + $migration = new Doctrine_Migration($migrationsPath); + + return $migration->migrate($to); + } + + /** + * Generate new migration class skeleton + * + * @param string $className Name of the Migration class to generate + * @param string $migrationsPath Path to directory which contains your migration classes + */ + public static function generateMigrationClass($className, $migrationsPath) + { + $builder = new Doctrine_Migration_Builder($migrationsPath); + + return $builder->generateMigrationClass($className); + } + + /** + * Generate a set of migration classes from an existing database + * + * @param string $migrationsPath + * @return void + * @throws new Doctrine_Migration_Exception + */ + public static function generateMigrationsFromDb($migrationsPath) + { + $builder = new Doctrine_Migration_Builder($migrationsPath); + + return $builder->generateMigrationsFromDb(); + } + + /** + * Generate a set of migration classes from an existing set of models + * + * @param string $migrationsPath Path to your Doctrine migration classes + * @param string $modelsPath Path to your Doctrine model classes + * @param integer $modelLoading Style of model loading to use for loading the models in order to generate migrations + * @return void + */ + public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null, $modelLoading = null) + { + $builder = new Doctrine_Migration_Builder($migrationsPath); + + return $builder->generateMigrationsFromModels($modelsPath, $modelLoading); + } + + /** + * Get the Doctrine_Table object for the passed model + * + * @param string $componentName + * @return Doctrine_Table + */ + public static function getTable($componentName) + { + return Doctrine_Manager::getInstance()->getConnectionForComponent($componentName)->getTable($componentName); + } + + /** + * Method for making a single file of most used doctrine runtime components + * including the compiled file instead of multiple files (in worst + * cases dozens of files) can improve performance by an order of magnitude + * + * @param string $target + * @param array $includedDrivers + * @throws Doctrine_Exception + * @return void + */ + public static function compile($target = null, $includedDrivers = array()) + { + return Doctrine_Compiler::compile($target, $includedDrivers); + } + + /** + * simple autoload function + * returns true if the class was loaded, otherwise false + * + * @param string $classname + * @return boolean + */ + public static function autoload($className) + { + if (class_exists($className, false) || interface_exists($className, false)) { + return false; + } + + $class = self::getPath() . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; + + if (file_exists($class)) { + require $class; + + return true; + } + + $loadedModels = self::$_loadedModelFiles; + + if (isset($loadedModels[$className]) && file_exists($loadedModels[$className])) { + require $loadedModels[$className]; + + return true; + } + + return false; + } + + /** + * dumps a given variable + * + * @param mixed $var a variable of any type + * @param boolean $output whether to output the content + * @param string $indent indention string + * @return void|string + */ + public static function dump($var, $output = true, $indent = "") + { + $ret = array(); + switch (gettype($var)) { + case 'array': + $ret[] = 'Array('; + $indent .= " "; + foreach ($var as $k => $v) { + + $ret[] = $indent . $k . ' : ' . self::dump($v, false, $indent); + } + $indent = substr($indent,0, -4); + $ret[] = $indent . ")"; + break; + case 'object': + $ret[] = 'Object(' . get_class($var) . ')'; + break; + default: + $ret[] = var_export($var, true); + } + + if ($output) { + print implode("\n", $ret); + } + + return implode("\n", $ret); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Access.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Access.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,203 @@ +. + */ + +/** + * Provides array access and property overload interface for Doctrine subclasses + * + * @package Doctrine + * @subpackage Access + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess +{ + /** + * Set an entire aray to the data + * + * @param array $array An array of key => value pairs + * @return Doctrine_Access + */ + public function setArray(array $array) + { + foreach ($array as $k => $v) { + $this->set($k, $v); + } + + return $this; + } + + /** + * Set key and value to data + * + * @see set, offsetSet + * @param $name + * @param $value + * @return void + */ + public function __set($name, $value) + { + $this->set($name, $value); + } + + /** + * Get key from data + * + * @see get, offsetGet + * @param mixed $name + * @return mixed + */ + public function __get($name) + { + return $this->get($name); + } + + /** + * Check if key exists in data + * + * @param string $name + * @return boolean whether or not this object contains $name + */ + public function __isset($name) + { + return $this->contains($name); + } + + /** + * Remove key from data + * + * @param string $name + * @return void + */ + public function __unset($name) + { + return $this->remove($name); + } + + /** + * Check if an offset axists + * + * @param mixed $offset + * @return boolean Whether or not this object contains $offset + */ + public function offsetExists($offset) + { + return $this->contains($offset); + } + + /** + * An alias of get() + * + * @see get, __get + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->get($offset); + } + + /** + * Sets $offset to $value + * + * @see set, __set + * @param mixed $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + if ( ! isset($offset)) { + $this->add($value); + } else { + $this->set($offset, $value); + } + } + + /** + * Unset a given offset + * + * @see set, offsetSet, __set + * @param mixed $offset + */ + public function offsetUnset($offset) + { + return $this->remove($offset); + } + + /** + * Remove the element with the specified offset + * + * @param mixed $offset The offset to remove + * @return boolean True if removed otherwise false + */ + public function remove($offset) + { + throw new Doctrine_Exception('Remove is not supported for ' . get_class($this)); + } + + /** + * Return the element with the specified offset + * + * @param mixed $offset The offset to return + * @return mixed The value of the return object + */ + public function get($offset) + { + throw new Doctrine_Exception('Get is not supported for ' . get_class($this)); + } + + /** + * Set the offset to the value + * + * @param mixed $offset The offset to set + * @param mixed $value The value to set the offset to + * + */ + public function set($offset, $value) + { + throw new Doctrine_Exception('Set is not supported for ' . get_class($this)); + } + + /** + * Check if the specified offset exists + * + * @param mixed $offset The offset to check + * @return boolean True if exists otherwise false + */ + public function contains($offset) + { + throw new Doctrine_Exception('Contains is not supported for ' . get_class($this)); + } + + /** + * Add the value + * + * @param mixed $value The value to add + * @return void + */ + public function add($value) + { + throw new Doctrine_Exception('Add is not supported for ' . get_class($this)); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,108 @@ +. + */ + +/** + * + * Doctrine_Adapter + * + * @package Doctrine + * @subpackage Adapter + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Adapter +{ + /** + * Adapter constant + */ + const ATTR_AUTOCOMMIT = 0; + const ATTR_CASE = 8; + const ATTR_CLIENT_VERSION = 5; + const ATTR_CONNECTION_STATUS = 7; + const ATTR_CURSOR = 10; + const ATTR_CURSOR_NAME = 9; + const ATTR_DRIVER_NAME = 16; + const ATTR_ERRMODE = 3; + const ATTR_FETCH_CATALOG_NAMES = 15; + const ATTR_FETCH_TABLE_NAMES = 14; + const ATTR_MAX_COLUMN_LEN = 18; + const ATTR_ORACLE_NULLS = 11; + const ATTR_PERSISTENT = 12; + const ATTR_PREFETCH = 1; + const ATTR_SERVER_INFO = 6; + const ATTR_SERVER_VERSION = 4; + const ATTR_STATEMENT_CLASS = 13; + const ATTR_STRINGIFY_FETCHES = 17; + const ATTR_TIMEOUT = 2; + const CASE_LOWER = 2; + const CASE_NATURAL = 0; + const CASE_UPPER = 1; + const CURSOR_FWDONLY = 0; + const CURSOR_SCROLL = 1; + const ERR_ALREADY_EXISTS = NULL; + const ERR_CANT_MAP = NULL; + const ERR_CONSTRAINT = NULL; + const ERR_DISCONNECTED = NULL; + const ERR_MISMATCH = NULL; + const ERR_NO_PERM = NULL; + const ERR_NONE = '00000'; + const ERR_NOT_FOUND = NULL; + const ERR_NOT_IMPLEMENTED = NULL; + const ERR_SYNTAX = NULL; + const ERR_TRUNCATED = NULL; + const ERRMODE_EXCEPTION = 2; + const ERRMODE_SILENT = 0; + const ERRMODE_WARNING = 1; + const FETCH_ASSOC = 2; + const FETCH_BOTH = 4; + const FETCH_BOUND = 6; + const FETCH_CLASS = 8; + const FETCH_CLASSTYPE = 262144; + const FETCH_COLUMN = 7; + const FETCH_FUNC = 10; + const FETCH_GROUP = 65536; + const FETCH_INTO = 9; + const FETCH_LAZY = 1; + const FETCH_NAMED = 11; + const FETCH_NUM = 3; + const FETCH_OBJ = 5; + const FETCH_ORI_ABS = 4; + const FETCH_ORI_FIRST = 2; + const FETCH_ORI_LAST = 3; + const FETCH_ORI_NEXT = 0; + const FETCH_ORI_PRIOR = 1; + const FETCH_ORI_REL = 5; + const FETCH_SERIALIZE = 524288; + const FETCH_UNIQUE = 196608; + const NULL_EMPTY_STRING = 1; + const NULL_NATURAL = 0; + const NULL_TO_STRING = NULL; + const PARAM_BOOL = 5; + const PARAM_INPUT_OUTPUT = -2147483648; + const PARAM_INT = 1; + const PARAM_LOB = 3; + const PARAM_NULL = 0; + const PARAM_STMT = 4; + const PARAM_STR = 2; +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Db2.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Db2.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,325 @@ +. + */ + +/** + * IBM DB2 Adapter. This class was ported from the Zend Framework + * + * @package Doctrine + * @subpackage Adapter + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 1080 $ + */ +class Doctrine_Adapter_Db2 extends Doctrine_Adapter +{ + /** + * User-provided configuration. + * + * Basic keys are: + * + * username => (string) Connect to the database as this username. + * password => (string) Password associated with the username. + * host => (string) What host to connect to (default 127.0.0.1) + * dbname => (string) The name of the database to user + * protocol => (string) Protocol to use, defaults to "TCPIP" + * port => (integer) Port number to use for TCP/IP if protocol is "TCPIP" + * persistent => (boolean) Set TRUE to use a persistent connection (db2_pconnect) + * + * @var array + */ + protected $_config = array( + 'dbname' => null, + 'username' => null, + 'password' => null, + 'host' => 'localhost', + 'port' => '50000', + 'protocol' => 'TCPIP', + 'persistent' => false + ); + + /** + * Stores the execution mode + * + * Possible values DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF + * + * @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF) + */ + protected $_executeMode = DB2_AUTOCOMMIT_ON; + + /** + * Table name of the last accessed table for an insert operation + * This is a DB2-Adapter-specific member variable with the utmost + * probability you might not find it in other adapters... + * + * @var string + */ + protected $_lastInsertTable = null; + + /** + * $config is an array of key/value pairs containing configuration + * options. These options are common to most adapters: + * + * dbname => (string) The name of the database to user + * username => (string) Connect to the database as this username. + * password => (string) Password associated with the username. + * host => (string) What host to connect to, defaults to localhost + * port => (string) The port of the database, defaults to 50000 + * persistent => (boolean) Whether to use a persistent connection or not, defaults to false + * protocol => (string) The network protocol, defaults to TCPIP + * options => (array) Other database options such as autocommit, case, and cursor options + * + * @param array $config An array of configuration keys. + */ + public function __construct(array $config) + { + if ( ! isset($config['password'])) { + throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'password' for login credentials."); + } + + if ( ! isset($config['username'])) { + throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'username' for login credentials."); + } + + if ( ! isset($config['dbname'])) { + throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance."); + } + + // keep the config + $this->_config = array_merge($this->_config, (array) $config); + } + + /** + * Creates the connection resource + * + * @return void + */ + protected function _connect() + { + if (is_resource($this->_connection)) { + // connection already exists + return; + } + + if ( ! extension_loaded('ibm_db2')) { + throw new Doctrine_Adapter_Exception('The IBM DB2 extension is required for this adapter but not loaded'); + } + + if ($this->_config['persistent']) { + // use persistent connection + $conn_func_name = 'db2_pconnect'; + } else { + // use "normal" connection + $conn_func_name = 'db2_connect'; + } + + if ( ! isset($this->_config['options'])) { + // config options were not set, so set it to an empty array + $this->_config['options'] = array(); + } + + if ( ! isset($this->_config['options']['autocommit'])) { + // set execution mode + $this->_config['options']['autocommit'] = &$this->_executeMode; + } + + if ($this->_config['host'] !== 'localhost') { + // if the host isn't localhost, use extended connection params + $dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' . + ';DATABASE=' . $this->_config['dbname'] . + ';HOSTNAME=' . $this->_config['host'] . + ';PORT=' . $this->_config['port'] . + ';PROTOCOL=' . $this->_config['protocol'] . + ';UID=' . $this->_config['username'] . + ';PWD=' . $this->_config['password'] .';'; + $this->_connection = $conn_func_name( + $dbname, + null, + null, + $this->_config['options'] + ); + } else { + // host is localhost, so use standard connection params + $this->_connection = $conn_func_name( + $this->_config['dbname'], + $this->_config['username'], + $this->_config['password'], + $this->_config['options'] + ); + } + + // check the connection + if ( ! $this->_connection) { + throw new Doctrine_Adapter_Exception(db2_conn_errormsg(), db2_conn_error()); + } + } + + /** + * Close the connection resource + * + * @return void + */ + public function closeConnection() + { + db2_close($this->_connection); + $this->_connection = null; + } + + /** + * Prepare a sql statement and return it + * + * @param string $sql The SQL statement with placeholders. + * @return Doctrine_Statement_Db2 + */ + public function prepare($sql) + { + $this->_connect(); + $stmt = new Doctrine_Statement_Db2($this, $sql); + $stmt->setFetchMode($this->_fetchMode); + return $stmt; + } + + /** + * Get the current execution mode + * + * @return int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF) + */ + public function _getExecuteMode() + { + return $this->_executeMode; + } + + /** + * Set the current execution mode + * + * @param integer $mode + * @return void + */ + public function _setExecuteMode($mode) + { + switch ($mode) { + case DB2_AUTOCOMMIT_OFF: + case DB2_AUTOCOMMIT_ON: + $this->_executeMode = $mode; + db2_autocommit($this->_connection, $mode); + break; + default: + throw new Doctrine_Adapter_Exception("execution mode not supported"); + break; + } + } + + /** + * Quote a raw string. + * + * @param string $value Raw string + * @return string Quoted string + */ + protected function _quote($value) + { + /** + * Some releases of the IBM DB2 extension appear + * to be missing the db2_escape_string() method. + * The method was added in ibm_db2.c revision 1.53 + * according to cvs.php.net. But the function is + * not present in my build of PHP 5.2.1. + */ + if (function_exists('db2_escape_string')) { + return db2_escape_string($value); + } + return parent::_quote($value); + } + + /** + * Get the symbol used for identifier quoting + * + * @return string + */ + public function getQuoteIdentifierSymbol() + { + $info = db2_server_info($this->_connection); + $identQuote = $info->IDENTIFIER_QUOTE_CHAR; + return $identQuote; + } + + /** + * Begin a transaction. + * + * @return void + */ + protected function _beginTransaction() + { + $this->_setExecuteMode(DB2_AUTOCOMMIT_OFF); + } + + /** + * Commit a transaction. + * + * @return void + */ + protected function _commit() + { + if ( ! db2_commit($this->_connection)) { + throw new Doctrine_Adapter_Exception( + db2_conn_errormsg($this->_connection), + db2_conn_error($this->_connection)); + } + + $this->_setExecuteMode(DB2_AUTOCOMMIT_ON); + } + + /** + * Rollback a transaction. + * + * @return void + */ + protected function _rollBack() + { + if ( ! db2_rollback($this->_connection)) { + throw new Doctrine_Adapter_Exception( + db2_conn_errormsg($this->_connection), + db2_conn_error($this->_connection)); + } + $this->_setExecuteMode(DB2_AUTOCOMMIT_ON); + } + + /** + * Set the fetch mode. + * + * @param integer $mode + * @return void + */ + public function setFetchMode($mode) + { + switch ($mode) { + case Doctrine::FETCH_NUM: // seq array + case Doctrine::FETCH_ASSOC: // assoc array + case Doctrine::FETCH_BOTH: // seq+assoc array + case Doctrine::FETCH_OBJ: // object + $this->_fetchMode = $mode; + break; + default: + throw new Doctrine_Adapter_Exception('Invalid fetch mode specified'); + break; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Adapter exception class + * + * @package Doctrine + * @subpackage Adapter + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Adapter_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Interface.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Interface.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,45 @@ +. + */ + +/** + * This adapter interface should be implemented by all custom adapters + * + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @package Doctrine + * @subpackage Adapter + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +interface Doctrine_Adapter_Interface +{ + public function prepare($prepareString); + public function query($queryString); + public function quote($input); + public function exec($statement); + public function lastInsertId(); + public function beginTransaction(); + public function commit(); + public function rollBack(); + public function errorCode(); + public function errorInfo(); +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Mock.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Mock.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,294 @@ +. + */ + +/** + * Doctrine mock connection adapter. This class is used for special testing purposes. + * + * @package Doctrine + * @subpackage Adapter + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable +{ + /** + * Name of the dbms to mock + * + * @var string + */ + private $_name; + + /** + * Array of queries executed through this instance of the mock adapter + * + * @var array $queries + */ + private $_queries = array(); + + /** + * Array of exceptions thrown + * + * @var array $exceptions + */ + private $_exception = array(); + + /** + * Bool true/false variable for whether or not the last insert failed + * + * @var boolean $lastInsertIdFail + */ + private $_lastInsertIdFail = false; + + /** + * Doctrine mock adapter constructor + * + * + * $conn = new Doctrine_Adapter_Mock('mysql'); + * + * + * @param string $name + * @return void + */ + public function __construct($name = null) + { + $this->_name = $name; + } + + /** + * Get the name of the dbms used in this instance of the mock adapter + * + * @return string $name Name of the dbms + */ + public function getName() + { + return $this->_name; + } + + /** + * Pop the last executed query from the array of executed queries and return it + * + * @return string $sql Last executed sql string + */ + public function pop() + { + return array_pop($this->_queries); + } + + /** + * Force an exception in to the array of exceptions + * + * @param string $name Name of exception + * @param string $message Message for the exception + * @param integer $code Code of the exception + * @return void + */ + public function forceException($name, $message = '', $code = 0) + { + $this->_exception = array($name, $message, $code); + } + + /** + * Prepare a query statement + * + * @param string $query Query to prepare + * @return Doctrine_Adapter_Statement_Mock $mock Mock prepared statement + */ + public function prepare($query) + { + $mock = new Doctrine_Adapter_Statement_Mock($this, $query); + $mock->queryString = $query; + + return $mock; + } + + /** + * Add query to the stack of executed queries + * + * @param string $query + * @return void + */ + public function addQuery($query) + { + $this->_queries[] = $query; + } + + /** + * Fake the execution of query and add it to the stack of executed queries + * + * @param string $query + * @return Doctrine_Adapter_Statement_Mock $stmt + */ + public function query($query) + { + $this->_queries[] = $query; + + $e = $this->_exception; + + if ( ! empty($e)) { + $name = $e[0]; + + $this->_exception = array(); + + throw new $name($e[1], $e[2]); + } + + $stmt = new Doctrine_Adapter_Statement_Mock($this, $query); + $stmt->queryString = $query; + + return $stmt; + } + + /** + * Get all the executed queries + * + * @return array $queries Array of all executed queries + */ + public function getAll() + { + return $this->_queries; + } + + /** + * Quote a value for the dbms + * + * @param string $input + * @return string $quoted + */ + public function quote($input) + { + return "'" . addslashes($input) . "'"; + } + + /** + * Execute a raw sql statement + * + * @param string $statement + * @return void + */ + public function exec($statement) + { + $this->_queries[] = $statement; + + $e = $this->_exception; + + if ( ! empty($e)) { + $name = $e[0]; + + $this->_exception = array(); + + throw new $name($e[1], $e[2]); + } + + return 0; + } + + /** + * Force last insert to be failed + * + * @param boolean $fail + * @return void + */ + public function forceLastInsertIdFail($fail = true) + { + if ($fail) { + $this->_lastInsertIdFail = true; + } else { + $this->_lastInsertIdFail = false; + } + } + + /** + * Get the id of the last inserted record + * + * @return integer $id + */ + public function lastInsertId() + { + $this->_queries[] = 'LAST_INSERT_ID()'; + if ($this->_lastInsertIdFail) { + return null; + } else { + return 1; + } + } + + /** + * Get the number of queries executed + * + * @return integer $count + */ + public function count() + { + return count($this->_queries); + } + + /** + * Begin a transaction + * + * @return void + */ + public function beginTransaction() + { + $this->_queries[] = 'BEGIN TRANSACTION'; + } + + /** + * Commit a transaction + * + * @return void + */ + public function commit() + { + $this->_queries[] = 'COMMIT'; + } + + /** + * Rollback a transaction + * + * @return void + */ + public function rollBack() + { + $this->_queries[] = 'ROLLBACK'; + } + + public function getAttribute($attribute) + { + if ($attribute == Doctrine::ATTR_DRIVER_NAME) { + return strtolower($this->_name); + } + } + + public function errorCode() + { } + + public function errorInfo() + { } + + public function setAttribute($attribute, $value) + { } + + public function sqliteCreateFunction() + { } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Mysqli.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Mysqli.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,142 @@ +. + */ + +/** + * Custom Doctrine connection adapter for mysqli + * + * @package Doctrine + * @subpackage Adapter + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 1080 $ + */ +class Doctrine_Adapter_Mysqli extends Doctrine_Adapter +{ + /** + * Creates a connection to the database. + * + * @return void + * @throws Doctrine_Adapter_Exception + */ + protected function _connect() + { + if ($this->_connection) { + return; + } + // Suppress connection warnings here. + // Throw an exception instead. + @$this->_connection = new mysqli( + $this->_config['host'], + $this->_config['username'], + $this->_config['password'], + $this->_config['dbname'] + ); + if ($this->_connection === false || mysqli_connect_errno()) { + throw new Doctrine_Adapter_Exception(mysqli_connect_error()); + } + } + + /** + * Force the connection to close. + * + * @return void + */ + public function closeConnection() + { + $this->_connection->close(); + $this->_connection = null; + } + + /** + * Prepare a statement and return a PDOStatement-like object. + * + * @param string $sql SQL query + * @return Doctrine_Statement_Mysqli + */ + public function prepare($sql) + { + $this->_connect(); + $stmt = new Doctrine_Statement_Mysqli($this, $sql); + $stmt->setFetchMode($this->_fetchMode); + return $stmt; + } + + /** + * lastInsertId + * + * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column. + * + * As a convention, on RDBMS brands that support sequences + * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence + * from the arguments and returns the last id generated by that sequence. + * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method + * returns the last value generated for such a column, and the table name + * argument is disregarded. + * + * MySQL does not support sequences, so $tableName and $primaryKey are ignored. + * + * @param string $tableName OPTIONAL Name of table. + * @param string $primaryKey OPTIONAL Name of primary key column. + * @return integer + */ + public function lastInsertId($tableName = null, $primaryKey = null) + { + $mysqli = $this->_connection; + return $mysqli->insert_id; + } + + /** + * Begin a transaction. + * + * @return void + */ + protected function _beginTransaction() + { + $this->_connect(); + $this->_connection->autocommit(false); + } + + /** + * Commit a transaction. + * + * @return void + */ + protected function _commit() + { + $this->_connect(); + $this->_connection->commit(); + $this->_connection->autocommit(true); + } + + /** + * Roll-back a transaction. + * + * @return void + */ + protected function _rollBack() + { + $this->_connect(); + $this->_connection->rollback(); + $this->_connection->autocommit(true); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Oracle.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Oracle.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,287 @@ +. + */ + +/** + * Custom Doctrine connection adapter for oracle + * + * @package Doctrine + * @subpackage Adapter + * @author Konsta Vesterinen + * @author vadik56 + * @author Miloslav Kmet + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + */ + +class Doctrine_Adapter_Oracle implements Doctrine_Adapter_Interface{ + /** + * execution mode + */ + protected $executeMode = OCI_COMMIT_ON_SUCCESS; + + /** + * Resource representing connection to database + */ + protected $connection = false; + + + protected $attributes = array(Doctrine::ATTR_DRIVER_NAME => "oci8", + Doctrine::ATTR_ERRMODE => Doctrine::ERRMODE_SILENT); + + /** + * User-provided configuration. + * + * Basic keys are: + * + * username => (string) Connect to the database as this username. + * password => (string) Password associated with the username. + * dbname => Either the name of the local Oracle instance, or the + * name of the entry in tnsnames.ora to which you want to connect. + * + * @var array + */ + protected $config = array('dbname' => null, + 'username' => null, + 'password' => null, + 'charset' => null); + + /** + * Doctrine Oracle adapter constructor + * + * + * $conn = new Doctrine_Adapter_Oracle(array('dbname'=>'db','username'=>'usr','password'=>'pass')); + * + * + * or + * + * + * Doctrine_Manager::connection(array('oracle:dbname=SID;charset=NLS_CHARACTERSET','usr', 'pass'),"doctrine_connection_name") + * + * + * @param string $name + * @return void + */ + public function __construct($config = array(), $username = null, $password = null) + { + if (is_string($config)) + { + $config = str_replace("oracle:","",$config); + $parts = explode(";", $config); + foreach($parts as $part) { + list($var, $value)=explode("=", $part); + switch($var) + { + case 'dbname': + $this->config['dbname'] = $value; + break; + case 'charset': + $this->config['charset'] = $value; + break; + } + } + + $this->config['username'] = $username; + $this->config['password'] = $password; + } else { + if ( ! isset($config['password']) || ! isset($config['username'])) { + throw new Doctrine_Adapter_Exception('config array must have at least a username and a password'); + } + + $this->config['username'] = $config['username']; + $this->config['password'] = $config['password']; + $this->config['dbname'] = $config['dbname']; + $this->config['charset'] = $config['charset']; + } + + $this->connection = @oci_connect($this->config['username'], $this->config['password'], + $this->config['dbname'], $this->config['charset']); + + if ($this->connection === false) { + throw new Doctrine_Adapter_Exception(sprintf("Unable to Connect to :'%s' as '%s'", $this->config['dbname'], $this->config['username'])); + } + } + + /** + * Prepare a query statement + * + * @param string $query Query to prepare + * @return Doctrine_Adapter_Statement_Oracle $stmt prepared statement + */ + public function prepare($query) + { + $stmt = new Doctrine_Adapter_Statement_Oracle($this, $query, $this->executeMode); + + return $stmt; + } + + /** + * Execute query and return results as statement object + * + * @param string $query + * @return Doctrine_Adapter_Statement_Oracle $stmt + */ + public function query($query) + { + $stmt = new Doctrine_Adapter_Statement_Oracle($this, $query, $this->executeMode); + $stmt->execute(); + + return $stmt; + } + + /** + * Quote a value for the dbms + * + * @param string $input + * @return string $quoted + */ + public function quote($input) + { + return "'" . str_replace("'","''",$input) . "'"; + } + + /** + * Execute a raw sql statement + * + * @param string $statement + * @return void + */ + public function exec($statement) + { + $stmt = new Doctrine_Adapter_Statement_Oracle($this, $statement, $this->executeMode); + $stmt->execute(); + $count = $stmt->rowCount(); + + return $count; + } + + /** + * Get the id of the last inserted record + * + * @return integer $id + */ + public function lastInsertId() + { + throw new Exception("unsupported"); + } + + /** + * Begin a transaction + * + * @return boolean + */ + public function beginTransaction() + { + $this->executeMode = OCI_DEFAULT; + return true; + } + + /** + * Commit a transaction + * + * @return void + */ + public function commit() + { + return @oci_commit($this->connection); + } + + /** + * Rollback a transaction + * + * @return boolean + */ + public function rollBack() + { + return @oci_rollback($this->connection); + } + + /** + * Set connection attribute + * + * @param integer $attribute + * @param mixed $value the value of given attribute + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function setAttribute($attribute, $value) + { + switch ($attribute) { + case Doctrine::ATTR_DRIVER_NAME: + //TODO throw an error since driver name can not be changed + case Doctrine::ATTR_ERRMODE: + break; + case Doctrine::ATTR_CASE: + if ($value == Doctrine::CASE_NATURAL) { + break; + } else { + throw new Doctrine_Adapter_Exception("Unsupported Option for ATTR_CASE: $value"); + } + default: + throw new Doctrine_Adapter_Exception("Unsupported Attribute: $attribute"); + return false; + } + $this->attributes[$attribute] = $value; + return true; + } + + /** + * Retrieve a statement attribute + * + * @param integer $attribute + * @see Doctrine::ATTR_* constants + * @return mixed the attribute value + */ + public function getAttribute($attribute) + { + return $this->attributes[$attribute]; + } + + /** + * Returns established OCI connection handler + * + * @return resource OCI connection handler + */ + public function getConnection() + { + return $this->connection; + } + + public function errorCode() + { + if (is_resource($this->connection)) { + $error = @oci_error($this->connection); + } else { + $error = @oci_error(); + } + return $error['code']; + } + + public function errorInfo() + { + if (is_resource($this->connection)) { + $error = @oci_error($this->connection); + } else { + $error = @oci_error(); + } + return $error['message']; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,131 @@ +. + */ + +/** + * Doctrine_Adapter_Statement + * + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @package Doctrine + * @subpackage Adapter + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +abstract class Doctrine_Adapter_Statement +{ + /** + * bindValue + * + * @param string $no + * @param string $value + * @return void + */ + public function bindValue($no, $value) + { } + + /** + * fetch + * + * @see Doctrine::FETCH_* constants + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor, + * this value determines which row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to + * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your + * Doctrine_Adapter_Statement_Interface object, + * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you + * prepare the SQL statement with Doctrine_Adapter_Interface->prepare(). + * + * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the + * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies + * the absolute number of the row in the result set that shall be fetched. + * + * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for + * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value + * specifies the row to fetch relative to the cursor position before + * Doctrine_Adapter_Statement_Interface->fetch() was called. + * + * @return mixed + */ + public function fetch() + { } + + /** + * nextRowSet + * + * @return void + */ + public function nextRowset() + { } + + /** + * execute() + * + * @return void + */ + public function execute() + { } + + /** + * errorCode + * + * @return void + */ + public function errorCode() + { } + + /** + * errorInfo + * + * @return void + */ + public function errorInfo() + { } + + /** + * rowCount + * + * @return void + */ + public function rowCount() + { } + + /** + * setFetchMode + * + * @param string $mode + * @return void + */ + public function setFetchMode($mode) + { } + + /** + * columnCount + * + * @return void + */ + public function columnCount() + { } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement/Interface.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement/Interface.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,276 @@ +. + */ + +/** + * Interface for Doctrine adapter statements + * + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @package Doctrine + * @subpackage Adapter + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +interface Doctrine_Adapter_Statement_Interface +{ + /** + * Bind a column to a PHP variable + * + * @param mixed $column Number of the column (1-indexed) or name of the column in the result set. + * If using the column name, be aware that the name should match + * the case of the column, as returned by the driver. + * @param string $param Name of the PHP variable to which the column will be bound. + * @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants. + * @return boolean Returns TRUE on success or FALSE on failure + */ + public function bindColumn($column, $param, $type = null); + + /** + * Binds a value to a corresponding named or question mark + * placeholder in the SQL statement that was use to prepare the statement. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindValue($param, $value, $type = null); + + /** + * Binds a PHP variable to a corresponding named or question mark placeholder in the + * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(), + * the variable is bound as a reference and will only be evaluated at the time + * that Doctrine_Adapter_Statement_Interface->execute() is called. + * + * Most parameters are input parameters, that is, parameters that are + * used in a read-only fashion to build up the query. Some drivers support the invocation + * of stored procedures that return data as output parameters, and some also as input/output + * parameters that both send in data and are updated to receive it. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return + * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the + * Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter. + * + * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter + * from a stored procedure, you must explicitly set the length. + * @param mixed $driverOptions + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()); + + /** + * Closes the cursor, enabling the statement to be executed again. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function closeCursor(); + + /** + * Returns the number of columns in the result set + * + * @return integer Returns the number of columns in the result set represented + * by the Doctrine_Adapter_Statement_Interface object. If there is no result set, + * this method should return 0. + */ + public function columnCount(); + + /** + * Fetch the SQLSTATE associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorCode() + * @return string error code string + */ + public function errorCode(); + + /** + * Fetch extended error information associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorInfo() + * @return array error info array + */ + public function errorInfo(); + + /** + * Executes a prepared statement + * + * If the prepared statement included parameter markers, you must either: + * call PDOStatement->bindParam() to bind PHP variables to the parameter markers: + * bound variables pass their value as input and receive the output value, + * if any, of their associated parameter markers or pass an array of input-only + * parameter values + * + * + * @param array $params An array of values with as many elements as there are + * bound parameters in the SQL statement being executed. + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function execute($params = null); + + /** + * fetch + * + * @see Doctrine::FETCH_* constants + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor, + * this value determines which row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to + * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your + * Doctrine_Adapter_Statement_Interface object, + * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you + * prepare the SQL statement with Doctrine_Adapter_Interface->prepare(). + * + * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the + * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies + * the absolute number of the row in the result set that shall be fetched. + * + * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for + * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value + * specifies the row to fetch relative to the cursor position before + * Doctrine_Adapter_Statement_Interface->fetch() was called. + * + * @return mixed + */ + public function fetch($fetchStyle = Doctrine::FETCH_BOTH, + $cursorOrientation = Doctrine::FETCH_ORI_NEXT, + $cursorOffset = null); + + /** + * Returns an array containing all of the result set rows + * + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is + * Doctrine::FETCH_COLUMN. Defaults to 0. + * + * @return array + */ + public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH); + + /** + * Returns a single column from the next row of a + * result set or FALSE if there are no more rows. + * + * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no + * value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn() + * fetches the first column. + * + * @return string returns a single column in the next row of a result set. + */ + public function fetchColumn($columnIndex = 0); + + /** + * Fetches the next row and returns it as an object. + * + * Fetches the next row and returns it as an object. This function is an alternative to + * Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style. + * + * @param string $className Name of the created class, defaults to stdClass. + * @param array $args Elements of this array are passed to the constructor. + * + * @return mixed an instance of the required class with property names that correspond + * to the column names or FALSE in case of an error. + */ + public function fetchObject($className = 'stdClass', $args = array()); + + /** + * Retrieve a statement attribute + * + * @param integer $attribute + * @see Doctrine::ATTR_* constants + * @return mixed the attribute value + */ + public function getAttribute($attribute); + + /** + * Returns metadata for a column in a result set + * + * @param integer $column The 0-indexed column in the result set. + * + * @return array Associative meta data array with the following structure: + * + * native_type The PHP native type used to represent the column value. + * driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta(). + * flags Any flags set for this column. + * name The name of this column as returned by the database. + * len The length of this column. Normally -1 for types other than floating point decimals. + * precision The numeric precision of this column. Normally 0 for types other than floating point decimals. + * pdo_type The type of this column as represented by the PDO::PARAM_* constants. + */ + public function getColumnMeta($column); + + /** + * Advances to the next rowset in a multi-rowset statement handle + * + * Some database servers support stored procedures that return more than one rowset + * (also known as a result set). The nextRowset() method enables you to access the second + * and subsequent rowsets associated with a PDOStatement object. Each rowset can have a + * different set of columns from the preceding rowset. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function nextRowset(); + + /** + * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement + * executed by the corresponding object. + * + * If the last SQL statement executed by the associated Statement object was a SELECT statement, + * some databases may return the number of rows returned by that statement. However, + * this behaviour is not guaranteed for all databases and should not be + * relied on for portable applications. + * + * @return integer Returns the number of rows. + */ + public function rowCount(); + + /** + * Set a statement attribute + * + * @param integer $attribute + * @param mixed $value the value of given attribute + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function setAttribute($attribute, $value); + + /** + * Set the default fetch mode for this statement + * + * @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants. + * @return boolean Returns 1 on success or FALSE on failure. + */ + public function setFetchMode($mode, $arg1 = null, $arg2 = null); +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement/Mock.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement/Mock.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,379 @@ +. + */ + +/** + * Mock connection adapter statement class. Used for special testing purposes + * + * @package Doctrine + * @subpackage Adapter + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Adapter_Statement_Mock implements Doctrine_Adapter_Statement_Interface +{ + /** + * Variable which stores instance of Doctrine_Adapter_Mock + * + * @var Doctrine_Adapter_Mock + */ + private $_mock; + + /** + * queryString + * + * @var string + */ + public $queryString; + + /** + * Constructor for mock adapter statements. Accepts instance of Doctrine_Adapter_Mock + * + * @param Doctrine_Adapter_Mock $mock + */ + public function __construct($mock) + { + $this->_mock = $mock; + } + + /** + * bindColumn + * + * Bind a column to a PHP variable + * + * @param mixed $column Number of the column (1-indexed) or name of the column in the result set. + * If using the column name, be aware that the name should match + * the case of the column, as returned by the driver. + * @param string $param Name of the PHP variable to which the column will be bound. + * @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants. + * @return boolean Returns TRUE on success or FALSE on failure + */ + public function bindColumn($column, $param, $type = null) + { } + + /** + * bindValue + * + * Binds a value to a corresponding named or question mark + * placeholder in the SQL statement that was use to prepare the statement. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindValue($param, $value, $type = null) + { } + + /** + * bindParam + * + * Binds a PHP variable to a corresponding named or question mark placeholder in the + * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(), + * the variable is bound as a reference and will only be evaluated at the time + * that Doctrine_Adapter_Statement_Interface->execute() is called. + * + * Most parameters are input parameters, that is, parameters that are + * used in a read-only fashion to build up the query. Some drivers support the invocation + * of stored procedures that return data as output parameters, and some also as input/output + * parameters that both send in data and are updated to receive it. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return + * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the + * Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter. + * + * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter + * from a stored procedure, you must explicitly set the length. + * @param mixed $driverOptions + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) + { + + } + + /** + * closeCursor + * + * Closes the cursor, enabling the statement to be executed again. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function closeCursor() + { + return true; + } + + /** + * columnCount + * + * Returns the number of columns in the result set + * + * @return integer Returns the number of columns in the result set represented + * by the Doctrine_Adapter_Statement_Interface object. If there is no result set, + * this method should return 0. + */ + public function columnCount() + { + return 0; + } + + /** + * errorCode + * + * Fetch the SQLSTATE associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorCode() + * @return string error code string + */ + public function errorCode() + { + return array(); + } + + /** + * errorInfo + * + * Fetch extended error information associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorInfo() + * @return array error info array + */ + public function errorInfo() + { + return array(); + } + + /** + * fetch + * + * @see Doctrine::FETCH_* constants + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor, + * this value determines which row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to + * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your + * Doctrine_Adapter_Statement_Interface object, + * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you + * prepare the SQL statement with Doctrine_Adapter_Interface->prepare(). + * + * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the + * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies + * the absolute number of the row in the result set that shall be fetched. + * + * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for + * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value + * specifies the row to fetch relative to the cursor position before + * Doctrine_Adapter_Statement_Interface->fetch() was called. + * + * @return mixed + */ + public function fetch($fetchStyle = Doctrine::FETCH_BOTH, + $cursorOrientation = Doctrine::FETCH_ORI_NEXT, + $cursorOffset = null) + { + return array(); + } + + /** + * fetchAll + * + * Returns an array containing all of the result set rows + * + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is + * Doctrine::FETCH_COLUMN. Defaults to 0. + * + * @return array + */ + public function fetchAll($fetchMode = Doctrine::FETCH_BOTH) + { + return array(); + } + + /** + * execute + * + * Executes a prepared statement + * + * If the prepared statement included parameter markers, you must either: + * call PDOStatement->bindParam() to bind PHP variables to the parameter markers: + * bound variables pass their value as input and receive the output value, + * if any, of their associated parameter markers or pass an array of input-only + * parameter values + * + * + * @param array $params An array of values with as many elements as there are + * bound parameters in the SQL statement being executed. + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function execute($params = null) + { + if (is_object($this->_mock)) { + $this->_mock->addQuery($this->queryString); + } + return true; + } + + /** + * fetchColumn + * + * Returns a single column from the next row of a + * result set or FALSE if there are no more rows. + * + * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no + * value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn() + * fetches the first column. + * + * @return string returns a single column in the next row of a result set. + */ + public function fetchColumn($columnIndex = 0) + { + return 0; + } + + /** + * fetchObject + * + * Fetches the next row and returns it as an object. + * + * Fetches the next row and returns it as an object. This function is an alternative to + * Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style. + * + * @param string $className Name of the created class, defaults to stdClass. + * @param array $args Elements of this array are passed to the constructor. + * + * @return mixed an instance of the required class with property names that correspond + * to the column names or FALSE in case of an error. + */ + public function fetchObject($className = 'stdClass', $args = array()) + { + return new $className(); + } + + /** + * nextRowset + * + * Advances to the next rowset in a multi-rowset statement handle + * + * Some database servers support stored procedures that return more than one rowset + * (also known as a result set). The nextRowset() method enables you to access the second + * and subsequent rowsets associated with a PDOStatement object. Each rowset can have a + * different set of columns from the preceding rowset. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function nextRowset() + { + return true; + } + + /** + * rowCount + * + * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement + * executed by the corresponding object. + * + * If the last SQL statement executed by the associated Statement object was a SELECT statement, + * some databases may return the number of rows returned by that statement. However, + * this behaviour is not guaranteed for all databases and should not be + * relied on for portable applications. + * + * @return integer Returns the number of rows. + */ + public function rowCount() + { + return 0; + } + + /** + * getColumnMeta + * + * Returns metadata for a column in a result set + * + * @param integer $column The 0-indexed column in the result set. + * + * @return array Associative meta data array with the following structure: + * + * native_type The PHP native type used to represent the column value. + * driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta(). + * flags Any flags set for this column. + * name The name of this column as returned by the database. + * len The length of this column. Normally -1 for types other than floating point decimals. + * precision The numeric precision of this column. Normally 0 for types other than floating point decimals. + * pdo_type The type of this column as represented by the PDO::PARAM_* constants. + */ + public function getColumnMeta($column) + { } + + /** + * getAttribute + * + * Retrieve a statement attribute + * + * @param integer $attribute + * @see Doctrine::ATTR_* constants + * @return mixed the attribute value + */ + public function getAttribute($attribute) + { } + + /** + * setAttribute + * + * Set a statement attribute + * + * @param integer $attribute + * @param mixed $value the value of given attribute + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function setAttribute($attribute, $value) + { } + + /** + * setFetchMode + * + * Set the default fetch mode for this statement + * + * @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants. + * @return boolean Returns 1 on success or FALSE on failure. + */ + public function setFetchMode($mode, $arg1 = null, $arg2 = null) + { } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement/Oracle.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Adapter/Statement/Oracle.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,586 @@ +. + */ + +/** + * Oracle connection adapter statement class. + * + * @package Doctrine + * @subpackage Adapter + * @author Konsta Vesterinen + * @author vadik56 + * @author Miloslav Kmet + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Rev$ + */ +class Doctrine_Adapter_Statement_Oracle implements Doctrine_Adapter_Statement_Interface +{ + /** + * @var string $queryString actual query string + */ + public $queryString; + + /** + * @var resource $connection OCI connection handler + */ + protected $connection; + + /** + * @var resource $statement OCI prepared statement + */ + protected $statement; + + /** + * @var integer $executeMode OCI statement execution mode + */ + protected $executeMode = OCI_COMMIT_ON_SUCCESS; + + /** + * @var array $bind_params Array of parameters bounded to a statement + */ + protected $bindParams = array(); + + /** + * @var array $attributes Array of attributes + */ + protected $attributes = array(); + + /** + * @var array $ociErrors Array of errors + */ + protected $ociErrors = array(); + + /** + * the constructor + * + * @param Doctrine_Adapter_Oracle $connection + * @param string $query Query string to be executed + * @param integer $executeMode OCI execute mode + */ + public function __construct( Doctrine_Adapter_Oracle $connection, $query, $executeMode) + { + $this->connection = $connection->getConnection(); + $this->queryString = $query; + $this->executeMode = $executeMode; + $this->attributes[Doctrine::ATTR_ERRMODE] = $connection->getAttribute(Doctrine::ATTR_ERRMODE); + + $this->parseQuery(); + } + + /** + * Bind a column to a PHP variable + * + * @param mixed $column Number of the column (1-indexed) or name of the column in the result set. + * If using the column name, be aware that the name should match + * the case of the column, as returned by the driver. + * @param string $param Name of the PHP variable to which the column will be bound. + * @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants. + * @return boolean Returns TRUE on success or FALSE on failure + */ + public function bindColumn($column, $param, $type = null) + { + throw new Exception("Unsupported"); + } + + /** + * Binds a value to a corresponding named or question mark + * placeholder in the SQL statement that was use to prepare the statement. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindValue($param, $value, $type = null){ + /** + * need to store the value internally since binding is done by reference + */ + $this->bindParams[] = $value; + $this->bindParam($param, $this->bindParams[count($this->bindParams) - 1], $type); + } + + /** + * Binds a PHP variable to a corresponding named or question mark placeholder in the + * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(), + * the variable is bound as a reference and will only be evaluated at the time + * that Doctrine_Adapter_Statement_Interface->execute() is called. + * + * Most parameters are input parameters, that is, parameters that are + * used in a read-only fashion to build up the query. Some drivers support the invocation + * of stored procedures that return data as output parameters, and some also as input/output + * parameters that both send in data and are updated to receive it. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return + * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the + * Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter. + * + * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter + * from a stored procedure, you must explicitly set the length. + * @param mixed $driverOptions + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()){ + if ($driverOptions || $length ) { + throw new Doctrine_Adapter_Exception('Unsupported parameters:$length, $driverOptions'); + } + + if ($length === null) { + $oci_length = -1; + } + $oci_type = SQLT_CHR; + + switch ($type) { + case Doctrine::PARAM_STR: + $oci_type = SQLT_CHR; + break; + } + + if (is_integer($column)) { + $variable_name = ":oci_b_var_$column"; + } else { + $variable_name = $column; + } + //print "Binding $variable to $variable_name".PHP_EOL; + $status = @oci_bind_by_name($this->statement, $variable_name, $variable, $oci_length, $oci_type); + if($status === false){ + $this->handleError(); + } + return $status; + } + + /** + * Closes the cursor, enabling the statement to be executed again. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function closeCursor(){ + $this->bind_params = array(); + return oci_free_statement($this->statement); + } + + /** + * Returns the number of columns in the result set + * + * @return integer Returns the number of columns in the result set represented + * by the Doctrine_Adapter_Statement_Interface object. If there is no result set, + * this method should return 0. + */ + public function columnCount(){ + return oci_num_fields ( $this->statement ); + } + + /** + * Fetch the SQLSTATE associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorCode() + * @return string error code string + */ + public function errorCode(){ + $oci_error = $this->getOciError(); + return $oci_error['code']; + } + + /** + * Fetch extended error information associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorInfo() + * @return array error info array + */ + public function errorInfo(){ + $oci_error = $this->getOciError(); + return $oci_error['message'] . " : " . $oci_error['sqltext']; + } + private function getOciError() + { + if (is_resource($this->statement)) { + $oci_error = oci_error ($this->statement); + } else { + $oci_error = oci_error (); + } + + if ($oci_error) { + //store the error + $this->oci_errors[] = $oci_error; + } else if (count($this->ociErrors) > 0) { + $oci_error = $this->ociErrors[count($this->ociErrors)-1]; + } + return $oci_error; + } + + /** + * Executes a prepared statement + * + * If the prepared statement included parameter markers, you must either: + * call PDOStatement->bindParam() to bind PHP variables to the parameter markers: + * bound variables pass their value as input and receive the output value, + * if any, of their associated parameter markers or pass an array of input-only + * parameter values + * + * + * @param array $params An array of values with as many elements as there are + * bound parameters in the SQL statement being executed. + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function execute($params = null) + { + if (is_array($params)) { + foreach ($params as $var => $value) { + $this->bindValue($var, $value); + } + } + + $result = @oci_execute($this->statement , $this->executeMode ); + + if ($result === false) { + $this->handleError(); + return false; + } + return true; + } + + /** + * fetch + * + * @see Doctrine::FETCH_* constants + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor, + * this value determines which row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to + * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your + * Doctrine_Adapter_Statement_Interface object, + * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you + * prepare the SQL statement with Doctrine_Adapter_Interface->prepare(). + * + * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the + * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies + * the absolute number of the row in the result set that shall be fetched. + * + * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for + * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value + * specifies the row to fetch relative to the cursor position before + * Doctrine_Adapter_Statement_Interface->fetch() was called. + * + * @return mixed + */ + public function fetch($fetchStyle = Doctrine::FETCH_BOTH, $cursorOrientation = Doctrine::FETCH_ORI_NEXT, $cursorOffset = null) + { + switch ($fetchStyle) { + case Doctrine::FETCH_BOTH : + return oci_fetch_array($this->statement, OCI_BOTH + OCI_RETURN_NULLS + OCI_RETURN_LOBS); + break; + case Doctrine::FETCH_ASSOC : + return oci_fetch_array($this->statement, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS); + break; + case Doctrine::FETCH_NUM : + return oci_fetch_array($this->statement, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); + break; + case FETCH_OBJ: + return oci_fetch_object($this->statement, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); + break; + default: + throw new Doctrine_Adapter_Exception("This type of fetch is not supported: ".$fetchStyle); +/* + case Doctrine::FETCH_BOUND: + case Doctrine::FETCH_CLASS: + case FETCH_CLASSTYPE: + case FETCH_COLUMN: + case FETCH_FUNC: + case FETCH_GROUP: + case FETCH_INTO: + case FETCH_LAZY: + case FETCH_NAMED: + case FETCH_SERIALIZE: + case FETCH_UNIQUE: + case FETCH_ORI_ABS: + case FETCH_ORI_FIRST: + case FETCH_ORI_LAST: + case FETCH_ORI_NEXT: + case FETCH_ORI_PRIOR: + case FETCH_ORI_REL: +*/ + } + } + + /** + * Returns an array containing all of the result set rows + * + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is + * Doctrine::FETCH_COLUMN. Defaults to 0. + * + * @return array + */ + public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH, $colnum=0) + { + $fetchColumn = false; + $skip = 0; + $maxrows = -1; + $data = array(); + $flags = OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC; + + $int = $fetchStyle & Doctrine::FETCH_COLUMN; + + if ($fetchStyle == Doctrine::FETCH_BOTH) { + $flags = OCI_BOTH; + } else if ($fetchStyle == Doctrine::FETCH_ASSOC) { + $numberOfRows = @oci_fetch_all($this->statement, $data, $skip, $maxrows, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC + OCI_RETURN_LOBS); + } else if ($fetchStyle == Doctrine::FETCH_NUM) { + $numberOfRows = @oci_fetch_all($this->statement, $data, $skip, $maxrows, OCI_FETCHSTATEMENT_BY_ROW + OCI_NUM + OCI_RETURN_LOBS); + } else if ($fetchStyle == Doctrine::FETCH_COLUMN) { + while ($row = @oci_fetch_array ($this->statement, OCI_NUM+OCI_RETURN_LOBS)) { + $data[] = $row[$colnum]; + } + } else { + throw new Exception("Unsupported mode: '" . $fetchStyle . "' "); + } + + return $data; + } + + /** + * Returns a single column from the next row of a + * result set or FALSE if there are no more rows. + * + * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no + * value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn() + * fetches the first column. + * + * @return string returns a single column in the next row of a result set. + */ + public function fetchColumn($columnIndex = 0) + { + if( ! is_integer($columnIndex)) { + $this->handleError(array('message'=>"columnIndex parameter should be numeric")); + } + $row = $this->fetch(Doctrine::FETCH_NUM); + return $row[$columnIndex]; + } + + /** + * Fetches the next row and returns it as an object. + * + * Fetches the next row and returns it as an object. This function is an alternative to + * Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style. + * + * @param string $className Name of the created class, defaults to stdClass. + * @param array $args Elements of this array are passed to the constructor. + * + * @return mixed an instance of the required class with property names that correspond + * to the column names or FALSE in case of an error. + */ + public function fetchObject($className = 'stdClass', $args = array()) + { + $row = $this->fetch(Doctrine::FETCH_ASSOC); + if ($row === false) { + return false; + } + + $instantiation_code = "\$object = new $className("; + $firstParam=true; + foreach ($args as $index=>$value) { + if ( ! $firstParam ) { + $instantiation_code = $instantiation_code . ","; + } else { + $firstParam= false; + } + if ( is_string($index)) { + $instantiation_code = $instantiation_code . " \$args['$index']"; + } else { + $instantiation_code = $instantiation_code . "\$args[$index]"; + } + } + + $instantiation_code = $instantiation_code . ");"; + + eval($instantiation_code); + + //initialize instance of $className class + foreach ($row as $col => $value) { + $object->$col = $value; + } + + return $object; + } + + /** + * Returns metadata for a column in a result set + * + * @param integer $column The 0-indexed column in the result set. + * + * @return array Associative meta data array with the following structure: + * + * native_type The PHP native type used to represent the column value. + * driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta(). + * flags Any flags set for this column. + * name The name of this column as returned by the database. + * len The length of this column. Normally -1 for types other than floating point decimals. + * precision The numeric precision of this column. Normally 0 for types other than floating point decimals. + * pdo_type The type of this column as represented by the PDO::PARAM_* constants. + */ + public function getColumnMeta($column) + { + if (is_integer($column)) { + $internal_column = $column +1; + } else { + $internal_column = $column; + } + + $data = array(); + $data['native_type'] = oci_field_type($this->statement, $internal_column); + $data['flags'] = ""; + $data['len'] = oci_field_size($this->statement, $internal_column); + $data['name'] = oci_field_name($this->statement, $internal_column); + $data['precision'] = oci_field_precision($this->statement, $internal_column); + + return $data; + } + + /** + * Advances to the next rowset in a multi-rowset statement handle + * + * Some database servers support stored procedures that return more than one rowset + * (also known as a result set). The nextRowset() method enables you to access the second + * and subsequent rowsets associated with a PDOStatement object. Each rowset can have a + * different set of columns from the preceding rowset. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function nextRowset() + { + throw new Exception("Unsupported"); + } + + /** + * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement + * executed by the corresponding object. + * + * If the last SQL statement executed by the associated Statement object was a SELECT statement, + * some databases may return the number of rows returned by that statement. However, + * this behaviour is not guaranteed for all databases and should not be + * relied on for portable applications. + * + * @return integer Returns the number of rows. + */ + public function rowCount() + { + return @oci_num_rows($this->statement); + } + + /** + * Set a statement attribute + * + * @param integer $attribute + * @param mixed $value the value of given attribute + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function setAttribute($attribute, $value) + { + switch ($attribute) { + case Doctrine::ATTR_ERRMODE; + break; + default: + throw new Doctrine_Adapter_Exception("Unsupported Attribute: $attribute"); + } + $this->attributes[$attribute] = $value; + } + + /** + * Retrieve a statement attribute + * + * @param integer $attribute + * @see Doctrine::ATTR_* constants + * @return mixed the attribute value + */ + public function getAttribute($attribute) + { + return $this->attributes[$attribute]; + } + /** + * Set the default fetch mode for this statement + * + * @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants. + * @return boolean Returns 1 on success or FALSE on failure. + */ + public function setFetchMode($mode, $arg1 = null, $arg2 = null) + { + throw new Exception("Unsupported"); + } + + private function handleError($params=array()) + { + + switch ($this->attributes[Doctrine::ATTR_ERRMODE]) { + case Doctrine::ERRMODE_EXCEPTION: + if (isset($params['message'])) { + throw new Doctrine_Adapter_Exception($params['message']); + } else { + throw new Doctrine_Adapter_Exception($this->errorInfo()); + } + + break; + case Doctrine::ERRMODE_WARNING: + case Doctrine::ERRMODE_SILENT: + break; + } + } + + /** + * Parse actual query from queryString and returns OCI statement handler + * @param string Query string to parse, if NULL, $this->queryString is used + * + * @return resource OCI statement handler + */ + private function parseQuery($query=null) + { + if (is_null($query)) { + $query = $this->queryString; + } + $bind_index = 0; + // Replace ? bind-placeholders with :oci_b_var_ variables + $query = preg_replace("/(\?)/e", '":oci_b_var_". $bind_index++' , $query); + + $this->statement = @oci_parse($this->connection, $query); + + if ( $this->statement == false ) + { + throw new Doctrine_Adapter_Exception($this->getOciError()); + } + + return $this->statement; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/AuditLog.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/AuditLog.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,146 @@ +. + */ + +/** + * Doctrine_AuditLog + * + * @package Doctrine + * @subpackage AuditLog + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_AuditLog extends Doctrine_Record_Generator +{ + /** + * Array of AuditLog Options + * + * @var string + */ + protected $_options = array( + 'className' => '%CLASS%Version', + 'versionColumn' => 'version', + 'tableName' => false, + 'generateFiles' => false, + 'table' => false, + 'pluginTable' => false, + 'children' => array(), + 'auditLog' => true, + ); + + /** + * Accepts array of options to configure the AuditLog + * + * @param array $options An array of options + * @return void + */ + public function __construct(array $options = array()) + { + $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); + } + + /** + * Set the table definition for the audit log table + * + * @return void + */ + public function setTableDefinition() + { + $name = $this->_options['table']->getComponentName(); + $columns = $this->_options['table']->getColumns(); + + // remove all sequence, autoincrement and unique constraint definitions and add to the behavior model + foreach ($columns as $column => $definition) { + unset($definition['autoincrement']); + unset($definition['sequence']); + unset($definition['unique']); + + $fieldName = $this->_options['table']->getFieldName($column); + if ($fieldName != $column) { + $name = $column . ' as ' . $fieldName; + } else { + $name = $fieldName; + } + + $this->hasColumn($name, $definition['type'], $definition['length'], $definition); + } + + // the version column should be part of the primary key definition + $this->hasColumn($this->_options['versionColumn'], 'integer', 8, array('primary' => true)); + } + + /** + * Get array of information for the passed record and the specified version + * + * @param Doctrine_Record $record + * @param integer $version + * @return array An array with version information + */ + public function getVersion(Doctrine_Record $record, $version) + { + $className = $this->_options['className']; + + $q = new Doctrine_Query(); + + $values = array(); + foreach ((array) $this->_options['table']->getIdentifier() as $id) { + $conditions[] = $className . '.' . $id . ' = ?'; + $values[] = $record->get($id); + } + + $where = implode(' AND ', $conditions) . ' AND ' . $className . '.' . $this->_options['versionColumn'] . ' = ?'; + + $values[] = $version; + + $q->from($className) + ->where($where); + + return $q->execute($values, Doctrine::HYDRATE_ARRAY); + } + + /** + * Get the max version number for a given Doctrine_Record + * + * @param Doctrine_Record $record + * @return Integer $versionnumber + */ + public function getMaxVersion(Doctrine_Record $record) + { + $className = $this->_options['className']; + $select = 'MAX(' . $className . '.' . $this->_options['versionColumn'] . ') max_version'; + + foreach ((array) $this->_options['table']->getIdentifier() as $id) { + $conditions[] = $className . '.' . $id . ' = ?'; + $values[] = $record->get($id); + } + + $q = Doctrine_Query::create() + ->select($select) + ->from($className) + ->where(implode(' AND ',$conditions)); + + $result = $q->execute($values, Doctrine::HYDRATE_ARRAY); + + return isset($result[0]['max_version']) ? $result[0]['max_version']:0; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/AuditLog/Listener.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/AuditLog/Listener.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,147 @@ +. + */ + +/** + * Doctrine_AuditLog_Listener + * + * @package Doctrine + * @subpackage AuditLog + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_AuditLog_Listener extends Doctrine_Record_Listener +{ + /** + * Instance of Doctrine_Auditlog + * + * @var Doctrine_AuditLog + */ + protected $_auditLog; + + /** + * Instantiate AuditLog listener and set the Doctrine_AuditLog instance to the class + * + * @param Doctrine_AuditLog $auditLog + * @return void + */ + public function __construct(Doctrine_AuditLog $auditLog) + { + $this->_auditLog = $auditLog; + } + + /** + * Pre insert event hook for incrementing version number + * + * @param Doctrine_Event $event + * @return void + */ + public function preInsert(Doctrine_Event $event) + { + $versionColumn = $this->_auditLog->getOption('versionColumn'); + + $event->getInvoker()->set($versionColumn, 1); + } + + /** + * Post insert event hook which creates the new version record + * This will only insert a version record if the auditLog is enabled + * + * @param Doctrine_Event $event + * @return void + */ + public function postInsert(Doctrine_Event $event) + { + if ($this->_auditLog->getOption('auditLog')) { + $class = $this->_auditLog->getOption('className'); + + $record = $event->getInvoker(); + $version = new $class(); + $version->merge($record->toArray()); + $version->save(); + } + } + + /** + * Pre delete event hook deletes all related versions + * This will only delete version records if the auditLog is enabled + * + * @param Doctrine_Event $event + * @return void + */ + public function preDelete(Doctrine_Event $event) + { + if ($this->_auditLog->getOption('auditLog')) { + $className = $this->_auditLog->getOption('className'); + $versionColumn = $this->_auditLog->getOption('versionColumn'); + $event->getInvoker()->set($versionColumn, null); + + $q = Doctrine_Query::create(); + foreach ((array) $this->_auditLog->getOption('table')->getIdentifier() as $id) { + $conditions[] = 'obj.' . $id . ' = ?'; + $values[] = $event->getInvoker()->get($id); + } + + $rows = $q->delete($className) + ->from($className.' obj') + ->where(implode(' AND ', $conditions)) + ->execute($values); + } + } + + /** + * Pre update event hook for inserting new version record + * This will only insert a version record if the auditLog is enabled + * + * @param Doctrine_Event $event + * @return void + */ + public function preUpdate(Doctrine_Event $event) + { + if ($this->_auditLog->getOption('auditLog')) { + $class = $this->_auditLog->getOption('className'); + $record = $event->getInvoker(); + + $versionColumn = $this->_auditLog->getOption('versionColumn'); + + $record->set($versionColumn, $this->_getNextVersion($record)); + + $version = new $class(); + $version->merge($record->toArray()); + $version->save(); + } + } + + /** + * Get the next version number for the audit log + * + * @param Doctrine_Record $record + * @return integer $nextVersion + */ + protected function _getNextVersion(Doctrine_Record $record) + { + if ($this->_auditLog->getOption('auditLog')) { + return ($this->_auditLog->getMaxVersion($record) + 1); + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Builder.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Builder.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,56 @@ +. + */ + +/** + * Base class for any code builders/generators for Doctrine + * + * @package Doctrine + * @subpackage Builder + * @link www.phpdoctrine.org + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @since 1.0 + * @version $Revision: 4593 $ + * @author Jonathan H. Wage + */ +class Doctrine_Builder +{ + /** + * Special function for var_export() + * The normal code which is returned is malformed and does not follow Doctrine standards + * So we do some string replacing to clean it up + * + * @param string $var + * @return void + */ + public function varExport($var) + { + $export = var_export($var, true); + $export = str_replace("\n", PHP_EOL . str_repeat(' ', 50), $export); + $export = str_replace(' ', ' ', $export); + $export = str_replace('array (', 'array(', $export); + $export = str_replace('array( ', 'array(', $export); + $export = str_replace(',)', ')', $export); + $export = str_replace(', )', ')', $export); + $export = str_replace(' ', ' ', $export); + + return $export; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,416 @@ +. + */ + +/** + * Doctrine_Cache + * + * @package Doctrine + * @subpackage Cache + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Cache extends Doctrine_EventListener implements Countable, IteratorAggregate +{ + /** + * @var array $_options an array of general caching options + */ + protected $_options = array('size' => 1000, + 'lifeTime' => 3600, + 'addStatsPropability' => 0.25, + 'savePropability' => 0.10, + 'cleanPropability' => 0.01, + 'statsFile' => '../data/stats.cache', + ); + + /** + * @var array $_queries query stack + */ + protected $_queries = array(); + + /** + * @var Doctrine_Cache_Interface $_driver the cache driver object + */ + protected $_driver; + + /** + * @var array $data current cache data array + */ + protected $_data = array(); + + /** + * @var boolean $success the success of last operation + */ + protected $_success = false; + + /** + * constructor + * + * @param Doctrine_Cache_Interface|string $driver cache driver name or a driver object + * @param array $options cache driver options + */ + public function __construct($driver, $options = array()) + { + if (is_object($driver)) { + if ( ! ($driver instanceof Doctrine_Cache_Interface)) { + throw new Doctrine_Cache_Exception('Driver should implement Doctrine_Cache_Interface.'); + } + + $this->_driver = $driver; + $this->_driver->setOptions($options); + } else { + $class = 'Doctrine_Cache_' . ucwords(strtolower($driver)); + + if ( ! class_exists($class)) { + throw new Doctrine_Cache_Exception('Cache driver ' . $driver . ' could not be found.'); + } + + $this->_driver = new $class($options); + } + } + + /** + * Get the current cache driver instance + * + * @return Doctrine_Cache_Driver $driver + */ + public function getDriver() + { + return $this->_driver; + } + + /** + * Set option name and value + * + * @param mixed $option the option name + * @param mixed $value option value + * @return boolean TRUE on success, FALSE on failure + */ + public function setOption($option, $value) + { + // sanity check (we need this since we are using isset() instead of array_key_exists()) + if ($value === null) { + throw new Doctrine_Cache_Exception('Null values not accepted for options.'); + } + + if (isset($this->_options[$option])) { + $this->_options[$option] = $value; + return true; + } + return false; + } + + /** + * Get value of option name + * + * @param mixed $option the option name + * @return mixed option value + */ + public function getOption($option) + { + if ( ! isset($this->_options[$option])) { + throw new Doctrine_Cache_Exception('Unknown option ' . $option); + } + + return $this->_options[$option]; + } + + /** + * Adds a query to internal query stack + * + * @param string|array $query sql query string + * @param string $namespace connection namespace + * @return void + */ + public function add($query, $namespace = null) + { + if (isset($namespace)) { + $this->_queries[$namespace][] = $query; + } else { + $this->_queries[] = $query; + } + } + + /** + * Get array of all executed queries + * + * @param string $namespace optional query namespace + * @return array an array of sql query strings + */ + public function getAll($namespace = null) + { + if (isset($namespace)) { + if ( ! isset($this->_queries[$namespace])) { + return array(); + } + + return $this->_queries[$namespace]; + } + + return $this->_queries; + } + + /** + * Pops a query from the stack + * + * @return string $query + */ + public function pop() + { + return array_pop($this->_queries); + } + + /** + * Removes all queries from the query stack + * + * @return void + */ + public function reset() + { + $this->_queries = array(); + } + + /** + * Count the number of queries on the stack + * + * @return integer the number of queries in the stack + */ + public function count() + { + return count($this->_queries); + } + + /** + * Get queries iterator + * + * @return ArrayIterator an iterator that iterates through the query stack + */ + public function getIterator() + { + return new ArrayIterator($this->_queries); + } + + /** + * Check whether or not the last cache opration was successful or not + * + * @return boolean whether or not the last cache operation was successful + */ + public function isSuccessful() + { + return $this->_success; + } + + /** + * Delete all cache + * + * @return void + */ + public function clean() + { + $rand = (mt_rand() / mt_getrandmax()); + + if ($rand <= $this->_options['cleanPropability']) { + $queries = $this->readStats(); + + $stats = array(); + + foreach ($queries as $query) { + if (isset($stats[$query])) { + $stats[$query]++; + } else { + $stats[$query] = 1; + } + } + sort($stats); + + $i = $this->_options['size']; + + while ($i--) { + $element = next($stats); + $query = key($stats); + + $hash = md5($query); + + $this->_driver->delete($hash); + } + } + } + + /** + * Read stats file from disk + * + * @return array $stats + */ + public function readStats() + { + if ($this->_options['statsFile'] !== false) { + $content = file_get_contents($this->_options['statsFile']); + + $e = explode("\n", $content); + + return array_map('unserialize', $e); + } + return array(); + } + + /** + * Append all queries to stats file + * @return void + */ + public function appendStats() + { + if ($this->_options['statsFile'] !== false) { + + if ( ! file_exists($this->_options['statsFile'])) { + throw new Doctrine_Cache_Exception("Couldn't save cache statistics. Cache statistics file doesn't exists!"); + } + + $rand = (mt_rand() / mt_getrandmax()); + + if ($rand <= $this->_options['addStatsPropability']) { + file_put_contents($this->_options['statsFile'], implode("\n", array_map('serialize', $this->_queries))); + } + } + } + + /** + * Listens on the Doctrine_Event preQuery event + * + * adds the issued query to internal query stack + * and checks if cached element exists + * + * @return boolean + */ + public function preQuery(Doctrine_Event $event) + { + $query = $event->getQuery(); + + $data = false; + // only process SELECT statements + if (strtoupper(substr(ltrim($query), 0, 6)) != 'SELECT') { + return false; + } + + $this->add($query, $event->getInvoker()->getName()); + + $data = $this->_driver->fetch(md5(serialize($query))); + + $this->success = ($data) ? true : false; + + if ( ! $data) { + $rand = (mt_rand() / mt_getrandmax()); + + if ($rand < $this->_options['savePropability']) { + $stmt = $event->getInvoker()->getAdapter()->query($query); + + $data = $stmt->fetchAll(Doctrine::FETCH_ASSOC); + + $this->success = true; + + $this->_driver->save(md5(serialize($query)), $data); + } + } + if ($this->success) + { + $this->_data = $data; + return true; + } + return false; + } + + /** + * Listens the preFetch event of Doctrine_Connection_Statement + * + * advances the internal pointer of cached data and returns + * the current element + * + * @return array + */ + public function preFetch(Doctrine_Event $event) + { + $ret = current($this->_data); + next($this->_data); + return $ret; + } + + /** + * Listens the preFetchAll event of Doctrine_Connection_Statement + * + * returns the current cache data array + * + * @return array + */ + public function preFetchAll(Doctrine_Event $event) + { + return $this->_data; + } + + /** + * Listens the preExecute event of Doctrine_Connection_Statement + * + * adds the issued query to internal query stack + * and checks if cached element exists + * + * @return boolean + */ + public function preExecute(Doctrine_Event $event) + { + $query = $event->getQuery(); + + $data = false; + + // only process SELECT statements + if (strtoupper(substr(ltrim($query), 0, 6)) != 'SELECT') { + return false; + } + + $this->add($query, $event->getInvoker()->getDbh()->getName()); + + $data = $this->_driver->fetch(md5(serialize(array($query, $event->getParams())))); + + $this->success = ($data) ? true : false; + + if ( ! $data) { + $rand = (mt_rand() / mt_getrandmax()); + + if ($rand <= $this->_options['savePropability']) { + + $stmt = $event->getInvoker()->getStatement(); + + $stmt->execute($event->getParams()); + + $data = $stmt->fetchAll(Doctrine::FETCH_ASSOC); + + $this->success = true; + + $this->_driver->save(md5(serialize(array($query, $event->getParams()))), $data); + } + } + if ($this->success) + { + $this->_data = $data; + return true; + } + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Apc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Apc.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,98 @@ +. + */ + +/** + * APC Cache Driver + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Cache_Apc extends Doctrine_Cache_Driver +{ + /** + * constructor + * + * @param array $options associative array of cache driver options + */ + public function __construct($options = array()) + { + if ( ! extension_loaded('apc')) { + throw new Doctrine_Cache_Exception('The apc extension must be loaded for using this backend !'); + } + parent::__construct($options); + } + + /** + * Test if a cache is available for the given id and (if yes) return it (false else). + * + * @param string $id cache id + * @param boolean $testCacheValidity if set to false, the cache validity won't be tested + * @return mixed The stored variable on success. FALSE on failure. + */ + public function fetch($id, $testCacheValidity = true) + { + $results = apc_fetch($id); + $results = (array) $results; + return $results[0]; + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id cache id + * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function contains($id) + { + return apc_fetch($id) === false ? false : true; + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always saved as a string + * + * @param string $data data to cache + * @param string $id cache id + * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) + * @return boolean true if no problem + */ + public function save($id, $data, $lifeTime = false) + { + return (bool) apc_store($id, $data, $lifeTime); + } + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function delete($id) + { + return apc_delete($id); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Array.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Array.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,113 @@ +. + */ + +/** + * Array cache driver + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Cache_Array implements Countable, Doctrine_Cache_Interface +{ + /** + * @var array $data an array of cached data + */ + protected $data; + + /** + * Test if a cache is available for the given id and (if yes) return it (false else) + * + * Note : return value is always "string" (unserialization is done by the core not by the backend) + * + * @param string $id cache id + * @param boolean $testCacheValidity if set to false, the cache validity won't be tested + * @return string cached datas (or false) + */ + public function fetch($id, $testCacheValidity = true) + { + if (isset($this->data[$id])) { + return $this->data[$id]; + } + return false; + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id cache id + * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function contains($id) + { + return isset($this->data[$id]); + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always saved as a string + * + * @param string $data data to cache + * @param string $id cache id + * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) + * @return boolean true if no problem + */ + public function save($id, $data, $lifeTime = false) + { + $this->data[$id] = $data; + } + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function delete($id) + { + unset($this->data[$id]); + } + + /** + * Remove all cache record + * + * @return boolean true if no problem + */ + public function deleteAll() + { + $this->data = array(); + } + + /** + * count + * + * @return integer + */ + public function count() + { + return count($this->data); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Db.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Db.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,234 @@ +. + */ + +/** + * Database cache driver + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Cache_Db extends Doctrine_Cache_Driver implements Countable +{ + /** + * Configure Database cache driver. Specify instance of Doctrine_Connection + * and tableName to store cache in + * + * @param array $_options an array of options + */ + public function __construct($options) + { + if ( ! isset($options['connection']) || + ! ($options['connection'] instanceof Doctrine_Connection)) { + + throw new Doctrine_Cache_Exception('Connection option not set.'); + } + + if ( ! isset($options['tableName']) || + ! is_string($options['tableName'])) { + + throw new Doctrine_Cache_Exception('Table name option not set.'); + } + + + $this->_options = $options; + } + + /** + * Get the connection object associated with this cache driver + * + * @return Doctrine_Connection $connection + */ + public function getConnection() + { + return $this->_options['connection']; + } + + /** + * Test if a cache is available for the given id and (if yes) return it (false else). + * + * @param string $id cache id + * @param boolean $testCacheValidity if set to false, the cache validity won't be tested + * @return string cached datas (or false) + */ + public function fetch($id, $testCacheValidity = true) + { + $sql = 'SELECT data, expire FROM ' . $this->_options['tableName'] + . ' WHERE id = ?'; + + if ($testCacheValidity) { + $sql .= " AND (expire is null OR expire > '" . date('Y-m-d H:i:s') . "')"; + } + + $result = $this->getConnection()->execute($sql, array($id))->fetchAll(Doctrine::FETCH_NUM); + + if ( ! isset($result[0])) { + return false; + } + + return unserialize($this->_hex2Bin($result[0][0])); + } + + protected function _hex2bin($hex) + { + if ( ! is_string($hex)) { + return null; + } + + $bin = ''; + for ($a = 0; $a < strlen($hex); $a += 2) { + $bin .= chr(hexdec($hex{$a} . $hex{($a + 1)})); + } + + return $bin; + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id cache id + * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function contains($id) + { + $sql = 'SELECT id, expire FROM ' . $this->_options['tableName'] + . ' WHERE id = ?'; + + $result = $this->getConnection()->fetchOne($sql, array($id)); + + if(isset($result[0] )){ + return time(); + } + return false; + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always saved as a string + * + * @param string $id cache id + * @param string $data data to cache + * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) + * @return boolean true if no problem + */ + public function save($id, $data, $lifeTime = false) + { + if ($this->contains($id)){ + //record is in database, do update + $sql = 'UPDATE ' . $this->_options['tableName'] + . ' SET data=?, expire=? ' + . ' WHERE id = ?'; + + if ($lifeTime) { + $expire = date('Y-m-d H:i:s',time() + $lifeTime); + } else { + $expire = NULL; + } + $params = array(bin2hex(serialize($data)), $expire, $id); + } else { + //record is not in database, do insert + $sql = 'INSERT INTO ' . $this->_options['tableName'] + . ' (id, data, expire) VALUES (?, ?, ?)'; + + if ($lifeTime) { + $expire = date('Y-m-d H:i:s', time() + $lifeTime); + } else { + $expire = NULL; + } + + $params = array($id, bin2hex(serialize($data)), $expire); + } + + return (bool) $this->getConnection()->exec($sql, $params); + } + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function delete($id) + { + $sql = 'DELETE FROM ' . $this->_options['tableName'] . ' WHERE id = ?'; + + return (bool) $this->getConnection()->exec($sql, array($id)); + } + + /** + * Removes all cache records + * + * $return bool true on success, false on failure + */ + public function deleteAll() + { + $sql = 'DELETE FROM ' . $this->_options['tableName']; + + return (bool) $this->getConnection()->exec($sql); + } + + /** + * count + * returns the number of cached elements + * + * @return integer + */ + public function count() + { + $sql = 'SELECT COUNT(*) FROM ' . $this->_options['tableName']; + + return (int) $this->getConnection()->fetchOne($sql); + } + + /** + * Create the cache table + * + * @return void + */ + public function createTable() + { + $name = $this->_options['tableName']; + + $fields = array( + 'id' => array( + 'type' => 'string', + 'length' => 255 + ), + 'data' => array( + 'type' => 'blob' + ), + 'expire' => array( + 'type' => 'timestamp' + ) + ); + + $options = array( + 'primary' => array('id') + ); + + $this->getConnection()->export->createTable($name, $fields, $options); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Driver.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Driver.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,80 @@ +. + */ + +/** + * Abstract cache driver class + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +abstract class Doctrine_Cache_Driver implements Doctrine_Cache_Interface +{ + /** + * @var array $_options an array of options + */ + protected $_options = array(); + + /** + * Configure cache driver with an array of options + * + * @param array $_options an array of options + */ + public function __construct($options) + { + $this->_options = $options; + } + + /** + * Set option name and value + * + * @param mixed $option the option name + * @param mixed $value option value + * @return boolean TRUE on success, FALSE on failure + */ + public function setOption($option, $value) + { + if (isset($this->_options[$option])) { + $this->_options[$option] = $value; + return true; + } + return false; + } + + /** + * Get value of option + * + * @param mixed $option the option name + * @return mixed option value + */ + public function getOption($option) + { + if ( ! isset($this->_options[$option])) { + return null; + } + + return $this->_options[$option]; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine cache exception class + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Cache_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Interface.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Interface.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,73 @@ +. + */ + +/** + * Doctrine cache driver interface + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +interface Doctrine_Cache_Interface +{ + /** + * Test if a cache is available for the given id and (if yes) return it (false else) + * + * Note : return value is always "string" (unserialization is done by the core not by the backend) + * + * @param string $id cache id + * @param boolean $testCacheValidity if set to false, the cache validity won't be tested + * @return string cached datas (or false) + */ + public function fetch($id, $testCacheValidity = true); + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id cache id + * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function contains($id); + + /** + * Save some string datas into a cache record + * + * Note : $data is always saved as a string + * + * @param string $id cache id + * @param string $data data to cache + * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) + * @return boolean true if no problem + */ + public function save($id, $data, $lifeTime = false); + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function delete($id); +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Memcache.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Memcache.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,128 @@ +. + */ + +/** + * Memcache cache driver + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Cache_Memcache extends Doctrine_Cache_Driver +{ + /** + * @var Memcache $_memcache memcache object + */ + protected $_memcache = null; + + /** + * constructor + * + * @param array $options associative array of cache driver options + */ + public function __construct($options = array()) + { + if ( ! extension_loaded('memcache')) { + throw new Doctrine_Cache_Exception('In order to use Memcache driver, the memcache extension must be loaded.'); + } + parent::__construct($options); + + if (isset($options['servers'])) { + $value= $options['servers']; + if (isset($value['host'])) { + // in this case, $value seems to be a simple associative array (one server only) + $value = array(0 => $value); // let's transform it into a classical array of associative arrays + } + $this->setOption('servers', $value); + } + + $this->_memcache = new Memcache; + + foreach ($this->_options['servers'] as $server) { + if ( ! array_key_exists('persistent', $server)) { + $server['persistent'] = true; + } + if ( ! array_key_exists('port', $server)) { + $server['port'] = 11211; + } + $this->_memcache->addServer($server['host'], $server['port'], $server['persistent']); + } + } + + /** + * Test if a cache is available for the given id and (if yes) return it (false else) + * + * @param string $id cache id + * @param boolean $testCacheValidity if set to false, the cache validity won't be tested + * @return mixed The stored variable on success. FALSE on failure. + */ + public function fetch($id, $testCacheValidity = true) + { + return $this->_memcache->get($id); + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id cache id + * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function contains($id) + { + return (bool) $this->_memcache->get($id); + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always saved as a string + * + * @param string $data data to cache + * @param string $id cache id + * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) + * @return boolean true if no problem + */ + public function save($id, $data, $lifeTime = false) + { + if ($this->_options['compression']) { + $flag = MEMCACHE_COMPRESSED; + } else { + $flag = 0; + } + + $result = $this->_memcache->set($id, $data, $flag, $lifeTime); + } + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function delete($id) + { + return $this->_memcache->delete($id); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Xcache.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cache/Xcache.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,97 @@ +. + */ + +/** + * Xcache cache driver + * + * @package Doctrine + * @subpackage Cache + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: $ + * @author Dmitry Bakaleinik (dima@snaiper.net) + */ +class Doctrine_Cache_Xcache extends Doctrine_Cache_Driver +{ + /** + * constructor + * + * @param array $options associative array of cache driver options + */ + public function __construct($options = array()) + { + if ( ! extension_loaded('xcache') ) { + throw new Doctrine_Cache_Exception('In order to use Xcache driver, the xcache extension must be loaded.'); + } + + parent::__construct($options); + } + + /** + * Test if a cache is available for the given id and (if yes) return it (false else). + * + * @param string $id cache id + * @param boolean $testCacheValidity if set to false, the cache validity won't be tested + * @return string cached datas (or false) + */ + public function fetch($id, $testCacheValidity = true) + { + return $this->contains($id) ? xcache_get($id) : false; + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id cache id + * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function contains($id) + { + return xcache_isset($id); + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always saved as a string + * + * @param string $data data to cache + * @param string $id cache id + * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) + * @return boolean true if no problem + */ + public function save($id, $data, $lifeTime = false) + { + return xcache_set($id, $data, $lifeTime); + } + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function delete($id) + { + return xcache_unset($id); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,356 @@ +. + */ + +/** + * Command line interface class + * Interface for easily executing Doctrine_Task classes from a + * command line interface + * + * @package Doctrine + * @subpackage Cli + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2761 $ + * @author Jonathan H. Wage + */ +class Doctrine_Cli +{ + protected $_tasks = array(), + $_taskInstance = null, + $_formatter = null, + $_scriptName = null, + $_message = null, + $_config = array(); + + /** + * __construct + * + * @param string $config + * @return void + */ + public function __construct($config = array()) + { + $this->_config = $config; + $this->_formatter = new Doctrine_Cli_AnsiColorFormatter(); + + $this->loadTasks(); + } + + /** + * Notify the formatter of a message + * + * @param string $notification The notification message + * @param string $style Style to format the notification with(INFO, ERROR) + * @return void + */ + public function notify($notification = null, $style = 'HEADER') + { + echo $this->_formatter->format($this->_taskInstance->getTaskName(), 'INFO') . ' - ' . $this->_formatter->format($notification, $style) . "\n"; + } + + /** + * Notify the formatter of an exception + * + * @param Exception $exception + * @return void + */ + public function notifyException($exception) + { + echo $this->_formatter->format($exception->getMessage(), 'ERROR') . "\n"; + } + + /** + * Public function to run the loaded task with the passed arguments + * + * @param array $args + * @return void + * @throws new Doctrine_Cli_Exception + */ + public function run($args) + { + try { + $this->_run($args); + } catch (Exception $exception) { + $this->notifyException($exception); + } + } + + /** + * Get the name of the task class based on the first argument + * which is always the task name. Do some inflection to determine the class name + * + * @param array $args Array of arguments from the cli + * @return string $taskClass Task class name + */ + protected function _getTaskClassFromArgs($args) + { + $taskName = str_replace('-', '_', $args[1]); + $taskClass = 'Doctrine_Task_' . Doctrine_Inflector::classify($taskName); + + return $taskClass; + } + + /** + * Run the actual task execution with the passed arguments + * + * @param array $args Array of arguments for this task being executed + * @return void + * @throws Doctrine_Cli_Exception $e + */ + protected function _run($args) + { + $this->_scriptName = $args[0]; + + $arg1 = isset($args[1]) ? $args[1]:null; + + if ( ! $arg1 || $arg1 == 'help') { + echo $this->printTasks(null, $arg1 == 'help' ? true:false); + return; + } + + if (isset($args[1]) && isset($args[2]) && $args[2] === 'help') { + echo $this->printTasks($args[1], true); + return; + } + + $taskClass = $this->_getTaskClassFromArgs($args); + + if ( ! class_exists($taskClass)) { + throw new Doctrine_Cli_Exception('Cli task could not be found: ' . $taskClass); + } + + unset($args[0]); + unset($args[1]); + + $this->_taskInstance = new $taskClass($this); + + $args = $this->prepareArgs($args); + + $this->_taskInstance->setArguments($args); + + try { + if ($this->_taskInstance->validate()) { + $this->_taskInstance->execute(); + } else { + echo $this->_formatter->format('Requires arguments missing!!', 'ERROR') . "\n\n"; + echo $this->printTasks($arg1, true); + } + } catch (Exception $e) { + throw new Doctrine_Cli_Exception($e->getMessage()); + } + } + + /** + * Prepare the raw arguments for execution. Combines with the required and optional argument + * list in order to determine a complete array of arguments for the task + * + * @param array $args Array of raw arguments + * @return array $prepared Array of prepared arguments + */ + protected function prepareArgs($args) + { + $taskInstance = $this->_taskInstance; + + $args = array_values($args); + + // First lets load populate an array with all the possible arguments. required and optional + $prepared = array(); + + $requiredArguments = $taskInstance->getRequiredArguments(); + foreach ($requiredArguments as $key => $arg) { + $prepared[$arg] = null; + } + + $optionalArguments = $taskInstance->getOptionalArguments(); + foreach ($optionalArguments as $key => $arg) { + $prepared[$arg] = null; + } + + // If we have a config array then lets try and fill some of the arguments with the config values + if (is_array($this->_config) && !empty($this->_config)) { + foreach ($this->_config as $key => $value) { + if (array_key_exists($key, $prepared)) { + $prepared[$key] = $value; + } + } + } + + // Now lets fill in the entered arguments to the prepared array + $copy = $args; + foreach ($prepared as $key => $value) { + if ( ! $value && !empty($copy)) { + $prepared[$key] = $copy[0]; + unset($copy[0]); + $copy = array_values($copy); + } + } + + return $prepared; + } + + /** + * Prints an index of all the available tasks in the CLI instance + * + * @return void + */ + public function printTasks($task = null, $full = false) + { + $task = Doctrine_Inflector::classify(str_replace('-', '_', $task)); + + $tasks = $this->getLoadedTasks(); + + echo $this->_formatter->format("Doctrine Command Line Interface", 'HEADER') . "\n\n"; + + foreach ($tasks as $taskName) + { + if ($task != null && strtolower($task) != strtolower($taskName)) { + continue; + } + + $className = 'Doctrine_Task_' . $taskName; + $taskInstance = new $className(); + $taskInstance->taskName = str_replace('_', '-', Doctrine_Inflector::tableize($taskName)); + + $syntax = $this->_scriptName . ' ' . $taskInstance->getTaskName(); + + echo $this->_formatter->format($syntax, 'INFO'); + + if ($full) { + echo " - " . $taskInstance->getDescription() . "\n"; + + $args = null; + + $requiredArguments = $taskInstance->getRequiredArgumentsDescriptions(); + + if ( ! empty($requiredArguments)) { + foreach ($requiredArguments as $name => $description) { + $args .= $this->_formatter->format($name, "ERROR"); + + if (isset($this->_config[$name])) { + $args .= " - " . $this->_formatter->format($this->_config[$name], 'COMMENT'); + } else { + $args .= " - " . $description; + } + + $args .= "\n"; + } + } + + $optionalArguments = $taskInstance->getOptionalArgumentsDescriptions(); + + if ( ! empty($optionalArguments)) { + foreach ($optionalArguments as $name => $description) { + $args .= $name . ' - ' . $description."\n"; + } + } + + if ($args) { + echo "\n" . $this->_formatter->format('Arguments:', 'HEADER') . "\n" . $args; + } + } + + echo "\n"; + } + } + + /** + * Load tasks from the passed directory. If no directory is given it looks in the default + * Doctrine/Task folder for the core tasks. + * + * @param mixed $directory Can be a string path or array of paths + * @return array $loadedTasks Array of tasks loaded + */ + public function loadTasks($directory = null) + { + if ($directory === null) { + $directory = Doctrine::getPath() . DIRECTORY_SEPARATOR . 'Doctrine' . DIRECTORY_SEPARATOR . 'Task'; + } + + $parent = new ReflectionClass('Doctrine_Task'); + + $tasks = array(); + + if (is_dir($directory)) { + foreach ((array) $directory as $dir) { + $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), + RecursiveIteratorIterator::LEAVES_ONLY); + + foreach ($it as $file) { + $e = explode('.', $file->getFileName()); + if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { + + $className = 'Doctrine_Task_' . $e[0]; + + if ( ! class_exists($className)) { + require_once($file->getPathName()); + + $class = new ReflectionClass($className); + + if ($class->isSubClassOf($parent)) { + $tasks[$e[0]] = $e[0]; + } + } + } + } + } + } + + $classes = get_declared_classes(); + foreach ($classes as $className) { + $class = new Reflectionclass($className); + if ($class->isSubClassOf($parent)) { + $task = str_replace('Doctrine_Task_', '', $className); + $tasks[$task] = $task; + } + } + + $this->_tasks = array_merge($this->_tasks, $tasks); + + return $this->_tasks; + } + + /** + * Get array of all the Doctrine_Task child classes that are loaded + * + * @return array $tasks + */ + public function getLoadedTasks() + { + $parent = new ReflectionClass('Doctrine_Task'); + + $classes = get_declared_classes(); + + $tasks = array(); + + foreach ($classes as $className) { + $class = new ReflectionClass($className); + + if ($class->isSubClassOf($parent)) { + $task = str_replace('Doctrine_Task_', '', $className); + + $tasks[$task] = $task; + } + } + + return array_merge($this->_tasks, $tasks); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli/AnsiColorFormatter.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli/AnsiColorFormatter.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,160 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/* + * $Id: AnsiColorFormatter.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $ + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information, see + * . + */ + +/** + * Doctrine_AnsiColorFormatter provides methods to colorize text to be displayed on a console. + * This class was taken from the symfony-project source + * + * @package Doctrine + * @subpackage Cli + * @author Fabien Potencier + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 4252 $ + */ +class Doctrine_Cli_AnsiColorFormatter extends Doctrine_Cli_Formatter +{ + protected + $_styles = array( + 'HEADER' => array('fg' => 'black', 'bold' => true), + 'ERROR' => array('bg' => 'red', 'fg' => 'white', 'bold' => true), + 'INFO' => array('fg' => 'green', 'bold' => true), + 'COMMENT' => array('fg' => 'yellow'), + ), + $_options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8), + $_foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37), + $_background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47); + + /** + * Sets a new style. + * + * @param string The style name + * @param array An array of options + */ + public function setStyle($name, $options = array()) + { + $this->_styles[$name] = $options; + } + + /** + * Formats a text according to the given style or parameters. + * + * @param string The test to style + * @param mixed An array of options or a style name + * + * @return string The styled text + */ + public function format($text = '', $parameters = array(), $stream = STDOUT) + { + if ( ! $this->supportsColors($stream)) { + return $text; + } + + if ( ! is_array($parameters) && 'NONE' == $parameters) { + return $text; + } + + if ( ! is_array($parameters) && isset($this->_styles[$parameters])) { + $parameters = $this->_styles[$parameters]; + } + + $codes = array(); + if (isset($parameters['fg'])) { + $codes[] = $this->_foreground[$parameters['fg']]; + } + + if (isset($parameters['bg'])) { + $codes[] = $this->_background[$parameters['bg']]; + } + + foreach ($this->_options as $option => $value) { + if (isset($parameters[$option]) && $parameters[$option]) { + $codes[] = $value; + } + } + + return "\033[".implode(';', $codes).'m'.$text."\033[0m"; + } + + /** + * Formats a message within a section. + * + * @param string The section name + * @param string The text message + * @param integer The maximum size allowed for a line (65 by default) + */ + public function formatSection($section, $text, $size = null) + { + $width = 9 + strlen($this->format('', 'INFO')); + + return sprintf(">> %-${width}s %s", $this->format($section, 'INFO'), $this->excerpt($text, $size)); + } + + /** + * Truncates a line. + * + * @param string The text + * @param integer The maximum size of the returned string (65 by default) + * + * @return string The truncated string + */ + public function excerpt($text, $size = null) + { + if ( ! $size) { + $size = $this->size; + } + + if (strlen($text) < $size) { + return $text; + } + + $subsize = floor(($size - 3) / 2); + + return substr($text, 0, $subsize) . $this->format('...', 'INFO').substr($text, -$subsize); + } + + /** + * Returns true if the stream supports colorization. + * + * Colorization is disabled if not supported by the stream: + * + * - windows + * - non tty consoles + * + * @param mixed A stream + * + * @return Boolean true if the stream supports colorization, false otherwise + */ + public function supportsColors($stream) + { + return DIRECTORY_SEPARATOR != '\\' && function_exists('posix_isatty') && @posix_isatty($stream); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Cli exception class + * + * @package Doctrine + * @subpackage Cli + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2761 $ + * @author Jonathan H. Wage + */ +class Doctrine_Cli_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli/Formatter.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Cli/Formatter.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/* + * $Id: Formatter.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $ + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information, see + * . + */ + +/** + * Doctrine_Cli_Formatter provides methods to format text to be displayed on a console. + * This class was taken from the symfony-project source + * + * @package Doctrine + * @subpackage Cli + * @author Fabien Potencier + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2761 $ + */ +class Doctrine_Cli_Formatter +{ + protected $_size = 65; + + /** + * __construct + * + * @param string $maxLineSize + * @return void + */ + function __construct($maxLineSize = 65) + { + $this->_size = $maxLineSize; + } + + /** + * Formats a text according to the given parameters. + * + * @param string The test to style + * @param mixed An array of parameters + * @param stream A stream (default to STDOUT) + * + * @return string The formatted text + */ + public function format($text = '', $parameters = array(), $stream = STDOUT) + { + return $text; + } + + /** + * Formats a message within a section. + * + * @param string The section name + * @param string The text message + * @param integer The maximum size allowed for a line (65 by default) + */ + public function formatSection($section, $text, $size = null) + { + return sprintf(">> %-$9s %s", $section, $this->excerpt($text, $size)); + } + + /** + * Truncates a line. + * + * @param string The text + * @param integer The maximum size of the returned string (65 by default) + * + * @return string The truncated string + */ + public function excerpt($text, $size = null) + { + if ( ! $size) { + $size = $this->_size; + } + + if (strlen($text) < $size) { + return $text; + } + + $subsize = floor(($size - 3) / 2); + + return substr($text, 0, $subsize).'...'.substr($text, -$subsize); + } + + /** + * Sets the maximum line size. + * + * @param integer The maximum line size for a message + */ + public function setMaxLineSize($size) + { + $this->_size = $size; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,934 @@ +. + */ + +/** + * Doctrine_Collection + * Collection of Doctrine_Record objects. + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Collection extends Doctrine_Access implements Countable, IteratorAggregate, Serializable +{ + /** + * @var array $data an array containing the records of this collection + */ + protected $data = array(); + + /** + * @var Doctrine_Table $table each collection has only records of specified table + */ + protected $_table; + + /** + * @var array $_snapshot a snapshot of the fetched data + */ + protected $_snapshot = array(); + + /** + * @var Doctrine_Record $reference collection can belong to a record + */ + protected $reference; + + /** + * @var string $referenceField the reference field of the collection + */ + protected $referenceField; + + /** + * @var Doctrine_Relation the record this collection is related to, if any + */ + protected $relation; + + /** + * @var string $keyColumn the name of the column that is used for collection key mapping + */ + protected $keyColumn; + + /** + * @var Doctrine_Null $null used for extremely fast null value testing + */ + protected static $null; + + /** + * constructor + * + * @param Doctrine_Table|string $table + */ + public function __construct($table, $keyColumn = null) + { + if ( ! ($table instanceof Doctrine_Table)) { + $table = Doctrine::getTable($table); + } + + $this->_table = $table; + + if ($keyColumn === null) { + $keyColumn = $table->getBoundQueryPart('indexBy'); + } + + if ($keyColumn === null) { + $keyColumn = $table->getAttribute(Doctrine::ATTR_COLL_KEY); + } + + if ($keyColumn !== null) { + $this->keyColumn = $keyColumn; + } + } + + /** + * Initializes the null object for this collection + * + * @return void + */ + public static function initNullObject(Doctrine_Null $null) + { + self::$null = $null; + } + + /** + * Get the table this collection belongs to + * + * @return Doctrine_Table + */ + public function getTable() + { + return $this->_table; + } + + /** + * Set the data for the Doctrin_Collection instance + * + * @param array $data + * @return Doctrine_Collection + */ + public function setData(array $data) + { + $this->data = $data; + } + + /** + * This method is automatically called when this Doctrine_Collection is serialized + * + * @return array + */ + public function serialize() + { + $vars = get_object_vars($this); + + unset($vars['reference']); + unset($vars['reference_field']); + unset($vars['relation']); + unset($vars['expandable']); + unset($vars['expanded']); + unset($vars['generator']); + + $vars['_table'] = $vars['_table']->getComponentName(); + + return serialize($vars); + } + + /** + * This method is automatically called everytime a Doctrine_Collection object is unserialized + * + * @return void + */ + public function unserialize($serialized) + { + $manager = Doctrine_Manager::getInstance(); + $connection = $manager->getCurrentConnection(); + + $array = unserialize($serialized); + + foreach ($array as $name => $values) { + $this->$name = $values; + } + + $this->_table = $connection->getTable($this->_table); + + $keyColumn = isset($array['keyColumn']) ? $array['keyColumn'] : null; + if ($keyColumn === null) { + $keyColumn = $this->_table->getBoundQueryPart('indexBy'); + } + + if ($keyColumn !== null) { + $this->keyColumn = $keyColumn; + } + } + + /** + * Sets the key column for this collection + * + * @param string $column + * @return Doctrine_Collection $this + */ + public function setKeyColumn($column) + { + $this->keyColumn = $column; + + return $this; + } + + /** + * Get the name of the key column + * + * @return string + */ + public function getKeyColumn() + { + return $this->keyColumn; + } + + /** + * Get all the records as an array + * + * @return array + */ + public function getData() + { + return $this->data; + } + + /** + * Get the first record in the collection + * + * @return mixed + */ + public function getFirst() + { + return reset($this->data); + } + + /** + * Get the last record in the collection + * + * @return mixed + */ + public function getLast() + { + return end($this->data); + } + + /** + * Get the last record in the collection + * + * @return mixed + */ + public function end() + { + return end($this->data); + } + + /** + * Get the current key + * + * @return mixed + */ + public function key() + { + return key($this->data); + } + + /** + * Sets a reference pointer + * + * @return void + */ + public function setReference(Doctrine_Record $record, Doctrine_Relation $relation) + { + $this->reference = $record; + $this->relation = $relation; + + if ($relation instanceof Doctrine_Relation_ForeignKey || + $relation instanceof Doctrine_Relation_LocalKey) { + $this->referenceField = $relation->getForeignFieldName(); + + $value = $record->get($relation->getLocalFieldName()); + + foreach ($this->data as $record) { + if ($value !== null) { + $record->set($this->referenceField, $value, false); + } else { + $record->set($this->referenceField, $this->reference, false); + } + } + } elseif ($relation instanceof Doctrine_Relation_Association) { + + } + } + + /** + * Get reference to Doctrine_Record instance + * + * @return Doctrine_Record $reference + */ + public function getReference() + { + return $this->reference; + } + + /** + * Removes a specified collection element + * + * @param mixed $key + * @return boolean + */ + public function remove($key) + { + $removed = $this->data[$key]; + + unset($this->data[$key]); + return $removed; + } + + /** + * Whether or not this collection contains a specified element + * + * @param mixed $key the key of the element + * @return boolean + */ + public function contains($key) + { + return isset($this->data[$key]); + } + + /** + * Search a Doctrine_Record instance + * + * @param string $Doctrine_Record + * @return void + */ + public function search(Doctrine_Record $record) + { + return array_search($record, $this->data, true); + } + + /** + * Gets a record for given key + * + * There are two special cases: + * + * 1. if null is given as a key a new record is created and attached + * at the end of the collection + * + * 2. if given key does not exist, then a new record is create and attached + * to the given key + * + * Collection also maps referential information to newly created records + * + * @param mixed $key the key of the element + * @return Doctrine_Record return a specified record + */ + public function get($key) + { + if ( ! isset($this->data[$key])) { + $record = $this->_table->create(); + + if (isset($this->referenceField)) { + $value = $this->reference->get($this->relation->getLocalFieldName()); + + if ($value !== null) { + $record->set($this->referenceField, $value, false); + } else { + $record->set($this->referenceField, $this->reference, false); + } + } + if ($key === null) { + $this->data[] = $record; + } else { + $this->data[$key] = $record; + } + + if (isset($this->keyColumn)) { + $record->set($this->keyColumn, $key); + } + + return $record; + } + + return $this->data[$key]; + } + + /** + * Get array of primary keys for all the records in the collection + * + * @return array an array containing all primary keys + */ + public function getPrimaryKeys() + { + $list = array(); + $name = $this->_table->getIdentifier(); + + foreach ($this->data as $record) { + if (is_array($record) && isset($record[$name])) { + $list[] = $record[$name]; + } else { + $list[] = $record->getIncremented(); + } + } + return $list; + } + + /** + * Get all keys of the data in the collection + * + * @return array + */ + public function getKeys() + { + return array_keys($this->data); + } + + /** + * Gets the number of records in this collection + * This class implements interface countable + * + * @return integer + */ + public function count() + { + return count($this->data); + } + + /** + * Set a Doctrine_Record instance to the collection + * + * @param integer $key + * @param Doctrine_Record $record + * @return void + */ + public function set($key, $record) + { + if (isset($this->referenceField)) { + $record->set($this->referenceField, $this->reference, false); + } + + $this->data[$key] = $record; + } + + /** + * Adds a record to collection + * + * @param Doctrine_Record $record record to be added + * @param string $key optional key for the record + * @return boolean + */ + public function add($record, $key = null) + { + if (isset($this->referenceField)) { + $value = $this->reference->get($this->relation->getLocalFieldName()); + if ($value !== null) { + $record->set($this->referenceField, $value, false); + } else { + $record->set($this->referenceField, $this->reference, false); + } + $relations = $this->relation['table']->getRelations(); + foreach ($relations as $relation) { + if ($this->relation['class'] == $relation['localTable']->getOption('name') && $relation->getLocal() == $this->relation->getForeignFieldName()) { + $record->$relation['alias'] = $this->reference; + break; + } + } + } + /** + * for some weird reason in_array cannot be used here (php bug ?) + * + * if used it results in fatal error : [ nesting level too deep ] + */ + foreach ($this->data as $val) { + if ($val === $record) { + return false; + } + } + + if (isset($key)) { + if (isset($this->data[$key])) { + return false; + } + $this->data[$key] = $record; + return true; + } + + if (isset($this->keyColumn)) { + $value = $record->get($this->keyColumn); + if ($value === null) { + throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '".$this->keyColumn."' was null."); + } + $this->data[$value] = $record; + } else { + $this->data[] = $record; + } + + return true; + } + + /** + * Merges collection into $this and returns merged collection + * + * @param Doctrine_Collection $coll + * @return Doctrine_Collection + */ + public function merge(Doctrine_Collection $coll) + { + $localBase = $this->getTable()->getComponentName(); + $otherBase = $coll->getTable()->getComponentName(); + + if ($otherBase != $localBase && !is_subclass_of($otherBase, $localBase) ) { + throw new Doctrine_Collection_Exception("Can't merge collections with incompatible record types"); + } + + foreach ($coll->getData() as $record) { + $this->add($record); + } + + return $this; + } + + /** + * Load all relationships or the named relationship passed + * + * @param mixed $name + * @return boolean + */ + public function loadRelated($name = null) + { + $list = array(); + $query = new Doctrine_Query($this->_table->getConnection()); + + if ( ! isset($name)) { + foreach ($this->data as $record) { + $value = $record->getIncremented(); + if ($value !== null) { + $list[] = $value; + } + } + $query->from($this->_table->getComponentName()); + $query->where($this->_table->getComponentName() . '.id IN (' . substr(str_repeat("?, ", count($list)),0,-2) . ')'); + + return $query; + } + + $rel = $this->_table->getRelation($name); + + if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) { + foreach ($this->data as $record) { + $list[] = $record[$rel->getLocal()]; + } + } else { + foreach ($this->data as $record) { + $value = $record->getIncremented(); + if ($value !== null) { + $list[] = $value; + } + } + } + + $dql = $rel->getRelationDql(count($list), 'collection'); + + $coll = $query->query($dql, $list); + + $this->populateRelated($name, $coll); + } + + /** + * Populate the relationship $name for all records in the passed collection + * + * @param string $name + * @param Doctrine_Collection $coll + * @return void + */ + public function populateRelated($name, Doctrine_Collection $coll) + { + $rel = $this->_table->getRelation($name); + $table = $rel->getTable(); + $foreign = $rel->getForeign(); + $local = $rel->getLocal(); + + if ($rel instanceof Doctrine_Relation_LocalKey) { + foreach ($this->data as $key => $record) { + foreach ($coll as $k => $related) { + if ($related[$foreign] == $record[$local]) { + $this->data[$key]->setRelated($name, $related); + } + } + } + } elseif ($rel instanceof Doctrine_Relation_ForeignKey) { + foreach ($this->data as $key => $record) { + if ( ! $record->exists()) { + continue; + } + $sub = new Doctrine_Collection($table); + + foreach ($coll as $k => $related) { + if ($related[$foreign] == $record[$local]) { + $sub->add($related); + $coll->remove($k); + } + } + + $this->data[$key]->setRelated($name, $sub); + } + } elseif ($rel instanceof Doctrine_Relation_Association) { + $identifier = $this->_table->getIdentifier(); + $asf = $rel->getAssociationFactory(); + $name = $table->getComponentName(); + + foreach ($this->data as $key => $record) { + if ( ! $record->exists()) { + continue; + } + $sub = new Doctrine_Collection($table); + foreach ($coll as $k => $related) { + if ($related->get($local) == $record[$identifier]) { + $sub->add($related->get($name)); + } + } + $this->data[$key]->setRelated($name, $sub); + + } + } + } + + /** + * Get normal iterator - an iterator that will not expand this collection + * + * @return Doctrine_Iterator_Normal $iterator + */ + public function getNormalIterator() + { + return new Doctrine_Collection_Iterator_Normal($this); + } + + /** + * Takes a snapshot from this collection + * + * snapshots are used for diff processing, for example + * when a fetched collection has three elements, then two of those + * are being removed the diff would contain one element + * + * Doctrine_Collection::save() attaches the diff with the help of last + * snapshot. + * + * @return Doctrine_Collection + */ + public function takeSnapshot() + { + $this->_snapshot = $this->data; + + return $this; + } + + /** + * Gets the data of the last snapshot + * + * @return array returns the data in last snapshot + */ + public function getSnapshot() + { + return $this->_snapshot; + } + + /** + * Processes the difference of the last snapshot and the current data + * + * an example: + * Snapshot with the objects 1, 2 and 4 + * Current data with objects 2, 3 and 5 + * + * The process would remove object 4 + * + * @return Doctrine_Collection + */ + public function processDiff() + { + foreach (array_udiff($this->_snapshot, $this->data, array($this, "compareRecords")) as $record) { + $record->delete(); + } + + return $this; + } + + /** + * Mimics the result of a $query->execute(array(), Doctrine::HYDRATE_ARRAY); + * + * @param boolean $deep + */ + public function toArray($deep = false, $prefixKey = false) + { + $data = array(); + foreach ($this as $key => $record) { + + $key = $prefixKey ? get_class($record) . '_' .$key:$key; + + $data[$key] = $record->toArray($deep, $prefixKey); + } + + return $data; + } + + /** + * Populate a Doctrine_Collection from an array of data + * + * @param string $array + * @return void + */ + public function fromArray($array, $deep = true) + { + $data = array(); + foreach ($array as $rowKey => $row) { + $this[$rowKey]->fromArray($row, $deep); + } + } + + /** + * synchronizes a Doctrine_Collection with data from an array + * + * it expects an array representation of a Doctrine_Collection similar to the return + * value of the toArray() method. It will create Dectrine_Records that don't exist + * on the collection, update the ones that do and remove the ones missing in the $array + * + * @param array $array representation of a Doctrine_Collection + */ + public function synchronizeWithArray(array $array) + { + foreach ($this as $key => $record) { + if (isset($array[$key])) { + $record->synchronizeWithArray($array[$key]); + unset($array[$key]); + } else { + // remove records that don't exist in the array + $this->remove($key); + } + } + // create new records for each new row in the array + foreach ($array as $rowKey => $row) { + $this[$rowKey]->fromArray($row); + } + } + public function synchronizeFromArray(array $array) + { + return $this->synchronizeWithArray($array); + } + + /** + * Export a Doctrine_Collection to one of the supported Doctrine_Parser formats + * + * @param string $type + * @param string $deep + * @return void + */ + public function exportTo($type, $deep = false) + { + if ($type == 'array') { + return $this->toArray($deep); + } else { + return Doctrine_Parser::dump($this->toArray($deep, true), $type); + } + } + + /** + * Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats + * + * @param string $type + * @param string $data + * @return void + */ + public function importFrom($type, $data) + { + if ($type == 'array') { + return $this->fromArray($data); + } else { + return $this->fromArray(Doctrine_Parser::load($data, $type)); + } + } + + /** + * Perform a delete diff between the last snapshot and the current data + * + * @return array $diff + */ + public function getDeleteDiff() + { + return array_udiff($this->_snapshot, $this->data, array($this, 'compareRecords')); + } + + /** + * Perform a insert diff between the last snapshot and the current data + * + * @return array $diff + */ + public function getInsertDiff() + { + return array_udiff($this->data, $this->_snapshot, array($this, "compareRecords")); + } + + /** + * Compares two records. To be used on _snapshot diffs using array_udiff + * + * @param Doctrine_Record $a + * @param Doctrine_Record $b + * @return integer + */ + protected function compareRecords($a, $b) + { + if ($a->getOid() == $b->getOid()) { + return 0; + } + + return ($a->getOid() > $b->getOid()) ? 1 : -1; + } + + /** + * Saves all records of this collection and processes the + * difference of the last snapshot and the current data + * + * @param Doctrine_Connection $conn optional connection parameter + * @return Doctrine_Collection + */ + public function save(Doctrine_Connection $conn = null, $processDiff = true) + { + if ($conn == null) { + $conn = $this->_table->getConnection(); + } + + try { + $conn->beginInternalTransaction(); + + $conn->transaction->addCollection($this); + + if ($processDiff) { + $this->processDiff(); + } + + foreach ($this->getData() as $key => $record) { + $record->save($conn); + } + + $conn->commit(); + } catch (Exception $e) { + $conn->rollback(); + throw $e; + } + + return $this; + } + + /** + * Deletes all records from this collection + * + * @return Doctrine_Collection + */ + public function delete(Doctrine_Connection $conn = null, $clearColl = true) + { + if ($conn == null) { + $conn = $this->_table->getConnection(); + } + + try { + $conn->beginInternalTransaction(); + $conn->transaction->addCollection($this); + + foreach ($this as $key => $record) { + $record->delete($conn); + } + + $conn->commit(); + } catch (Exception $e) { + $conn->rollback(); + throw $e; + } + + if ($clearColl) { + $this->clear(); + } + + return $this; + } + + /** + * Clears the collection. + * + * @return void + */ + public function clear() + { + $this->data = array(); + } + + /** + * Frees the resources used by the collection. + * WARNING: After invoking free() the collection is no longer considered to + * be in a useable state. Subsequent usage may result in unexpected behavior. + * + * @return void + */ + public function free($deep = false) + { + foreach ($this->getData() as $key => $record) { + if ( ! ($record instanceof Doctrine_Null)) { + $record->free($deep); + } + } + + $this->data = array(); + + if ($this->reference) { + $this->reference->free($deep); + $this->reference = null; + } + } + + /** + * Get collection data iterator + * + * @return object ArrayIterator + */ + public function getIterator() + { + $data = $this->data; + return new ArrayIterator($data); + } + + /** + * Returns a string representation of this object + * + * @return string $string + */ + public function __toString() + { + return Doctrine_Lib::getCollectionAsString($this); + } + + /** + * Returns the relation object + * + * @return object Doctrine_Relation + */ + public function getRelation() + { + return $this->relation; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Collection exception class + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Collection_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,119 @@ +. + */ + +/** + * Doctrine_Collection_Iterator + * iterates through Doctrine_Collection + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +abstract class Doctrine_Collection_Iterator implements Iterator +{ + /** + * @var Doctrine_Collection $collection + */ + protected $collection; + + /** + * @var array $keys + */ + protected $keys; + + /** + * @var mixed $key + */ + protected $key; + + /** + * @var integer $index + */ + protected $index; + + /** + * @var integer $count + */ + protected $count; + + /** + * constructor + * @var Doctrine_Collection $collection + */ + public function __construct($collection) + { + $this->collection = $collection; + $this->keys = $this->collection->getKeys(); + $this->count = $this->collection->count(); + } + + /** + * rewinds the iterator + * + * @return void + */ + public function rewind() + { + $this->index = 0; + $i = $this->index; + if (isset($this->keys[$i])) { + $this->key = $this->keys[$i]; + } + } + + /** + * returns the current key + * + * @return integer + */ + public function key() + { + return $this->key; + } + + /** + * returns the current record + * + * @return Doctrine_Record + */ + public function current() + { + return $this->collection->get($this->key); + } + + /** + * advances the internal pointer + * + * @return void + */ + public function next() + { + $this->index++; + $i = $this->index; + if (isset($this->keys[$i])) { + $this->key = $this->keys[$i]; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator/Expandable.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator/Expandable.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,54 @@ +. + */ + +/** + * Expandable collection iterator class + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator +{ + public function valid() + { + if ($this->index < $this->count) { + return true; + } elseif ($this->index == $this->count) { + $coll = $this->collection->expand($this->index); + + if ($coll instanceof Doctrine_Collection) { + $count = count($coll); + if ($count > 0) { + $this->keys = array_merge($this->keys, $coll->getKeys()); + $this->count += $count; + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator/Normal.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator/Normal.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,42 @@ +. + */ + +/** + * Doctrine_Collection_Iterator_Normal + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator +{ + /** + * @return boolean whether or not the iteration will continue + */ + public function valid() + { + return ($this->index < $this->count); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator/Offset.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Iterator/Offset.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,37 @@ +. + */ + +/** + * Doctrine_Collection_Iterator_Normal + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator +{ + public function valid() + { } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Offset.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection/Offset.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,65 @@ +. + */ + +/** + * Doctrine_Collection_Offset + * Collection of Doctrine_Record objects. + * + * @package Doctrine + * @subpackage Collection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Collection_Offset extends Doctrine_Collection +{ + /** + * @var integer $limit + */ + private $limit; + + /** + * @param Doctrine_Table $table + */ + public function __construct(Doctrine_Table $table) + { + parent::__construct($table); + $this->limit = $table->getAttribute(Doctrine::ATTR_COLL_LIMIT); + } + + /** + * @return integer + */ + public function getLimit() + { + return $this->limit; + } + + /** + * @return Doctrine_Collection_Iterator_Expandable + */ + public function getIterator() + { + return new Doctrine_Collection_Iterator_Expandable($this); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Column.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Column.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,158 @@ +. + */ + +/** + * Doctrine_Column + * This class represents a database column + * + * @author Konsta Vesterinen + * @package Doctrine + * @subpackage Column + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Column extends Doctrine_Access implements IteratorAggregate, Countable +{ + /** + * @var array $definition + */ + protected $_definition = array( + 'type' => null, + 'length' => 0, + ); + + /** + * @var array $definition + */ + public function __construct(array $definition = array()) + { + $this->_definition = $definition; + } + + /** + * @return array + */ + public function getDefinition() + { + return $this->_definition; + } + + /** + * contains + * + * @return boolean + */ + public function contains($name) + { + return isset($this->_definition[$name]); + } + + /** + * get + * + * @param string $name + * @return mixed + */ + public function get($name) + { + if ( ! isset($this->_definition[$name])) { + return null; + } + + return $this->_definition[$name]; + } + + /** + * set + * + * @param string $name + * @return mixed + */ + public function set($name, $value) + { + $this->_definition[$name] = $value; + } + + /** + * @param string $field + * @return array + */ + public function getEnumValues() + { + if (isset($this->_definition['values'])) { + return $this->_definition['values']; + } else { + return array(); + } + } + + /** + * enumValue + * + * @param string $field + * @param integer $index + * @return mixed + */ + public function enumValue($index) + { + if ($index instanceof Doctrine_Null) { + return $index; + } + + return isset($this->_definition['values'][$index]) ? $this->_definition['values'][$index] : $index; + } + + /** + * enumIndex + * + * @param string $field + * @param mixed $value + * @return mixed + */ + public function enumIndex($field, $value) + { + $values = $this->getEnumValues($field); + + return array_search($value, $values); + } + + /** + * count + * + * @return integer + */ + public function count() + { + return count($this->_definition); + } + + /** + * getIterator + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->_definition); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Compiler.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Compiler.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,139 @@ +. + */ + +/** + * Doctrine_Compiler + * This class can be used for compiling the entire Doctrine framework into a single file + * + * @package Doctrine + * @subpackage Compiler + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpllicense.php LGPL + * @link www.phpdoctrine. + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Compiler +{ + /** + * method for making a single file of most used doctrine runtime components + * including the compiled file instead of multiple files (in worst + * cases dozens of files) can improve performance by an order of magnitude + * + * @throws Doctrine_Compiler_Exception if something went wrong during the compile operation + * @return $target Path the compiled file was written to + */ + public static function compile($target = null, $includedDrivers = array()) + { + if ( ! is_array($includedDrivers)) { + $includedDrivers = array($includedDrivers); + } + + $excludedDrivers = array(); + + // If we have an array of specified drivers then lets determine which drivers we should exclude + if ( ! empty($includedDrivers)) { + $drivers = array('db2', + 'firebird', + 'informix', + 'mssql', + 'mysql', + 'oracle', + 'pgsql', + 'sqlite'); + + $excludedDrivers = array_diff($drivers, $includedDrivers); + } + + $path = Doctrine::getPath(); + $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY); + + foreach ($it as $file) { + $e = explode('.', $file->getFileName()); + + //@todo what is a versioning file? do we have these anymore? None + //exists in my version of doctrine from svn. + // we don't want to require versioning files + if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { + require_once $file->getPathName(); + } + } + + $classes = array_merge(get_declared_classes(), get_declared_interfaces()); + + $ret = array(); + + foreach ($classes as $class) { + $e = explode('_', $class); + + if ($e[0] !== 'Doctrine') { + continue; + } + + // Exclude drivers + if ( ! empty($excludedDrivers)) { + foreach ($excludedDrivers as $excludedDriver) { + $excludedDriver = ucfirst($excludedDriver); + + if (in_array($excludedDriver, $e)) { + continue(2); + } + } + } + + $refl = new ReflectionClass($class); + $file = $refl->getFileName(); + + $lines = file($file); + + $start = $refl->getStartLine() - 1; + $end = $refl->getEndLine(); + + $ret = array_merge($ret, array_slice($lines, $start, ($end - $start))); + } + + if ($target == null) { + $target = $path . DIRECTORY_SEPARATOR . 'Doctrine.compiled.php'; + } + + // first write the 'compiled' data to a text file, so + // that we can use php_strip_whitespace (which only works on files) + $fp = @fopen($target, 'w'); + + if ($fp === false) { + throw new Doctrine_Compiler_Exception("Couldn't write compiled data. Failed to open $target"); + } + + fwrite($fp, ". + */ + +/** + * Doctrine_Compiler_Exception + * + * @package Doctrine + * @subpackage Compiler + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Compiler_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Configurable.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Configurable.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,485 @@ +. + */ + +/** + * Doctrine_Configurable + * the base for Doctrine_Table, Doctrine_Manager and Doctrine_Connection + * + * @package Doctrine + * @subpackage Configurable + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable +{ + /** + * @var array $attributes an array of containing all attributes + */ + protected $attributes = array(); + + /** + * @var Doctrine_Configurable $parent the parent of this component + */ + protected $parent; + + /** + * @var array $_impl an array containing concrete implementations for class templates + * keys as template names and values as names of the concrete + * implementation classes + */ + protected $_impl = array(); + + /** + * @var array $_params an array of user defined parameters + */ + protected $_params = array(); + + /** + * getAttributeFromString + * + * Will accept the name of an attribute and return the attribute value + * Example: ->getAttributeFromString('portability') will be converted to Doctrine::ATTR_PORTABILITY + * and returned + * + * @param string $stringAttributeName + * @return void + */ + public function getAttributeFromString($stringAttributeName) + { + if (is_string($stringAttributeName)) { + $upper = strtoupper($stringAttributeName); + + $const = 'Doctrine::ATTR_' . $upper; + + if (defined($const)) { + return constant($const); + } else { + throw new Doctrine_Exception('Unknown attribute: "' . $stringAttributeName . '"'); + } + } else { + return false; + } + } + + /** + * getAttributeValueFromString + * + * Will get the value for an attribute by the string name + * Example: ->getAttributeFromString('portability', 'all') will return Doctrine::PORTABILITY_ALL + * + * @param string $stringAttributeName + * @param string $stringAttributeValueName + * @return void + */ + public function getAttributeValueFromString($stringAttributeName, $stringAttributeValueName) + { + $const = 'Doctrine::' . strtoupper($stringAttributeName) . '_' . strtoupper($stringAttributeValueName); + + if (defined($const)) { + return constant($const); + } else { + throw new Doctrine_Exception('Unknown attribute value: "' . $const . '"'); + } + } + + /** + * setAttribute + * sets a given attribute + * + * + * $manager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL); + * + * // or + * + * $manager->setAttribute('portability', Doctrine::PORTABILITY_ALL); + * + * // or + * + * $manager->setAttribute('portability', 'all'); + * + * + * @param mixed $attribute either a Doctrine::ATTR_* integer constant or a string + * corresponding to a constant + * @param mixed $value the value of the attribute + * @see Doctrine::ATTR_* constants + * @throws Doctrine_Exception if the value is invalid + * @return void + */ + public function setAttribute($attribute, $value) + { + if (is_string($attribute)) { + $stringAttribute = $attribute; + $attribute = $this->getAttributeFromString($attribute); + $this->_state = $attribute; + } + + if (is_string($value) && isset($stringAttribute)) { + $value = $this->getAttributeValueFromString($stringAttribute, $value); + } + + switch ($attribute) { + case Doctrine::ATTR_FETCHMODE: + throw new Doctrine_Exception('Deprecated attribute. See http://www.phpdoctrine.org/documentation/manual?chapter=configuration'); + case Doctrine::ATTR_LISTENER: + $this->setEventListener($value); + break; + case Doctrine::ATTR_COLL_KEY: + if ( ! ($this instanceof Doctrine_Table)) { + throw new Doctrine_Exception("This attribute can only be set at table level."); + } + if ($value !== null && ! $this->hasField($value)) { + throw new Doctrine_Exception("Couldn't set collection key attribute. No such field '$value'."); + } + break; + case Doctrine::ATTR_CACHE: + case Doctrine::ATTR_RESULT_CACHE: + case Doctrine::ATTR_QUERY_CACHE: + if ($value !== null) { + if ( ! ($value instanceof Doctrine_Cache_Interface)) { + throw new Doctrine_Exception('Cache driver should implement Doctrine_Cache_Interface'); + } + } + break; + case Doctrine::ATTR_VALIDATE: + case Doctrine::ATTR_QUERY_LIMIT: + case Doctrine::ATTR_QUOTE_IDENTIFIER: + case Doctrine::ATTR_PORTABILITY: + case Doctrine::ATTR_DEFAULT_TABLE_TYPE: + case Doctrine::ATTR_EMULATE_DATABASE: + case Doctrine::ATTR_USE_NATIVE_ENUM: + case Doctrine::ATTR_DEFAULT_SEQUENCE: + case Doctrine::ATTR_EXPORT: + case Doctrine::ATTR_DECIMAL_PLACES: + case Doctrine::ATTR_LOAD_REFERENCES: + case Doctrine::ATTR_RECORD_LISTENER: + case Doctrine::ATTR_THROW_EXCEPTIONS: + case Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE: + case Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES: + case Doctrine::ATTR_MODEL_LOADING: + case Doctrine::ATTR_RESULT_CACHE_LIFESPAN: + case Doctrine::ATTR_QUERY_CACHE_LIFESPAN: + case Doctrine::ATTR_RECURSIVE_MERGE_FIXTURES; + case Doctrine::ATTR_USE_DQL_CALLBACKS; + case Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE; + case Doctrine::ATTR_HYDRATE_OVERWRITE; + + break; + case Doctrine::ATTR_SEQCOL_NAME: + if ( ! is_string($value)) { + throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); + } + break; + case Doctrine::ATTR_FIELD_CASE: + if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) + throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); + break; + case Doctrine::ATTR_SEQNAME_FORMAT: + case Doctrine::ATTR_IDXNAME_FORMAT: + case Doctrine::ATTR_TBLNAME_FORMAT: + if ($this instanceof Doctrine_Table) { + throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' + . 'at table level (only at connection or global level).'); + } + break; + default: + throw new Doctrine_Exception("Unknown attribute."); + } + + $this->attributes[$attribute] = $value; + } + + public function getParams($namespace = null) + { + if ($namespace == null) { + $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); + } + + if ( ! isset($this->_params[$namespace])) { + return null; + } + + return $this->_params[$namespace]; + } + + public function getParamNamespaces() + { + return array_keys($this->_params); + } + + public function setParam($name, $value, $namespace = null) + { + if ($namespace == null) { + $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); + } + + $this->_params[$namespace][$name] = $value; + + return $this; + } + + public function getParam($name, $namespace = null) + { + if ($namespace == null) { + $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); + } + + if ( ! isset($this->_params[$namespace][$name])) { + if (isset($this->parent)) { + return $this->parent->getParam($name, $namespace); + } + return null; + } + + return $this->_params[$namespace][$name]; + } + /** + * setImpl + * binds given class to given template name + * + * this method is the base of Doctrine dependency injection + * + * @param string $template name of the class template + * @param string $class name of the class to be bound + * @return Doctrine_Configurable this object + */ + public function setImpl($template, $class) + { + $this->_impl[$template] = $class; + + return $this; + } + + /** + * getImpl + * returns the implementation for given class + * + * @return string name of the concrete implementation + */ + public function getImpl($template) + { + if ( ! isset($this->_impl[$template])) { + if (isset($this->parent)) { + return $this->parent->getImpl($template); + } + return null; + } + return $this->_impl[$template]; + } + + + public function hasImpl($template) + { + if ( ! isset($this->_impl[$template])) { + if (isset($this->parent)) { + return $this->parent->hasImpl($template); + } + return false; + } + return true; + } + + /** + * @param Doctrine_EventListener $listener + * @return void + */ + public function setEventListener($listener) + { + return $this->setListener($listener); + } + + /** + * addRecordListener + * + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return mixed this object + */ + public function addRecordListener($listener, $name = null) + { + if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER]) || + ! ($this->attributes[Doctrine::ATTR_RECORD_LISTENER] instanceof Doctrine_Record_Listener_Chain)) { + + $this->attributes[Doctrine::ATTR_RECORD_LISTENER] = new Doctrine_Record_Listener_Chain(); + } + $this->attributes[Doctrine::ATTR_RECORD_LISTENER]->add($listener, $name); + + return $this; + } + + /** + * getListener + * + * @return Doctrine_EventListener_Interface|Doctrine_Overloadable + */ + public function getRecordListener() + { + if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER])) { + if (isset($this->parent)) { + return $this->parent->getRecordListener(); + } + return null; + } + return $this->attributes[Doctrine::ATTR_RECORD_LISTENER]; + } + + /** + * setListener + * + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return Doctrine_Configurable this object + */ + public function setRecordListener($listener) + { + if ( ! ($listener instanceof Doctrine_Record_Listener_Interface) + && ! ($listener instanceof Doctrine_Overloadable) + ) { + throw new Doctrine_Exception("Couldn't set eventlistener. Record listeners should implement either Doctrine_Record_Listener_Interface or Doctrine_Overloadable"); + } + $this->attributes[Doctrine::ATTR_RECORD_LISTENER] = $listener; + + return $this; + } + + /** + * addListener + * + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return mixed this object + */ + public function addListener($listener, $name = null) + { + if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) || + ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) { + + $this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain(); + } + $this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name); + + return $this; + } + + /** + * getListener + * + * @return Doctrine_EventListener_Interface|Doctrine_Overloadable + */ + public function getListener() + { + if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER])) { + if (isset($this->parent)) { + return $this->parent->getListener(); + } + return null; + } + return $this->attributes[Doctrine::ATTR_LISTENER]; + } + + /** + * setListener + * + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return Doctrine_Configurable this object + */ + public function setListener($listener) + { + if ( ! ($listener instanceof Doctrine_EventListener_Interface) + && ! ($listener instanceof Doctrine_Overloadable) + ) { + throw new Doctrine_EventListener_Exception("Couldn't set eventlistener. EventListeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable"); + } + $this->attributes[Doctrine::ATTR_LISTENER] = $listener; + + return $this; + } + + /** + * returns the value of an attribute + * + * @param integer $attribute + * @return mixed + */ + public function getAttribute($attribute) + { + if (is_string($attribute)) { + $upper = strtoupper($attribute); + + $const = 'Doctrine::ATTR_' . $upper; + + if (defined($const)) { + $attribute = constant($const); + $this->_state = $attribute; + } else { + throw new Doctrine_Exception('Unknown attribute: "' . $attribute . '"'); + } + } + + $attribute = (int) $attribute; + + if ($attribute < 0) { + throw new Doctrine_Exception('Unknown attribute.'); + } + + if (isset($this->attributes[$attribute])) { + return $this->attributes[$attribute]; + } + + if (isset($this->parent)) { + return $this->parent->getAttribute($attribute); + } + return null; + } + + /** + * getAttributes + * returns all attributes as an array + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * sets a parent for this configurable component + * the parent must be configurable component itself + * + * @param Doctrine_Configurable $component + * @return void + */ + public function setParent(Doctrine_Configurable $component) + { + $this->parent = $component; + } + + /** + * getParent + * returns the parent of this component + * + * @return Doctrine_Configurable + */ + public function getParent() + { + return $this->parent; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,1596 @@ +. + */ + +/** + * Doctrine_Connection + * + * A wrapper layer on top of PDO / Doctrine_Adapter + * + * Doctrine_Connection is the heart of any Doctrine based application. + * + * 1. Event listeners + * An easy to use, pluggable eventlistener architecture. Aspects such as + * logging, query profiling and caching can be easily implemented through + * the use of these listeners + * + * 2. Lazy-connecting + * Creating an instance of Doctrine_Connection does not connect + * to database. Connecting to database is only invoked when actually needed + * (for example when query() is being called) + * + * 3. Convenience methods + * Doctrine_Connection provides many convenience methods such as fetchAll(), fetchOne() etc. + * + * 4. Modular structure + * Higher level functionality such as schema importing, exporting, sequence handling etc. + * is divided into modules. For a full list of connection modules see + * Doctrine_Connection::$_modules + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + * @author Lukas Smith (MDB2 library) + */ +abstract class Doctrine_Connection extends Doctrine_Configurable implements Countable, IteratorAggregate, Serializable +{ + /** + * @var $dbh the database handler + */ + protected $dbh; + + /** + * @var array $tables an array containing all the initialized Doctrine_Table objects + * keys representing Doctrine_Table component names and values as Doctrine_Table objects + */ + protected $tables = array(); + + /** + * $_name + * + * Name of the connection + * + * @var string $_name + */ + protected $_name; + + /** + * The name of this connection driver. + * + * @var string $driverName + */ + protected $driverName; + + /** + * @var boolean $isConnected whether or not a connection has been established + */ + protected $isConnected = false; + + /** + * @var array $supported an array containing all features this driver supports, + * keys representing feature names and values as + * one of the following (true, false, 'emulated') + */ + protected $supported = array(); + + /** + * @var array $pendingAttributes An array of pending attributes. When setting attributes + * no connection is needed. When connected all the pending + * attributes are passed to the underlying adapter (usually PDO) instance. + */ + protected $pendingAttributes = array(); + + /** + * @var array $modules an array containing all modules + * transaction Doctrine_Transaction driver, handles savepoint and transaction isolation abstraction + * + * expression Doctrine_Expression driver, handles expression abstraction + * + * dataDict Doctrine_DataDict driver, handles datatype abstraction + * + * export Doctrine_Export driver, handles db structure modification abstraction (contains + * methods such as alterTable, createConstraint etc.) + * import Doctrine_Import driver, handles db schema reading + * + * sequence Doctrine_Sequence driver, handles sequential id generation and retrieval + * + * unitOfWork Doctrine_Connection_UnitOfWork handles many orm functionalities such as object + * deletion and saving + * + * formatter Doctrine_Formatter handles data formatting, quoting and escaping + * + * @see Doctrine_Connection::__get() + * @see Doctrine_DataDict + * @see Doctrine_Expression + * @see Doctrine_Export + * @see Doctrine_Transaction + * @see Doctrine_Sequence + * @see Doctrine_Connection_UnitOfWork + * @see Doctrine_Formatter + */ + private $modules = array('transaction' => false, + 'expression' => false, + 'dataDict' => false, + 'export' => false, + 'import' => false, + 'sequence' => false, + 'unitOfWork' => false, + 'formatter' => false, + 'util' => false, + ); + + /** + * @var array $properties an array of connection properties + */ + protected $properties = array('sql_comments' => array(array('start' => '--', 'end' => "\n", 'escape' => false), + array('start' => '/*', 'end' => '*/', 'escape' => false)), + 'identifier_quoting' => array('start' => '"', 'end' => '"','escape' => '"'), + 'string_quoting' => array('start' => "'", + 'end' => "'", + 'escape' => false, + 'escape_pattern' => false), + 'wildcards' => array('%', '_'), + 'varchar_max_length' => 255, + 'sql_file_delimiter' => ";\n", + ); + + /** + * @var array $serverInfo + */ + protected $serverInfo = array(); + + protected $options = array(); + + /** + * @var array $supportedDrivers an array containing all supported drivers + */ + private static $supportedDrivers = array( + 'Mysql', + 'Pgsql', + 'Oracle', + 'Informix', + 'Mssql', + 'Sqlite', + 'Firebird' + ); + protected $_count = 0; + + /** + * the constructor + * + * @param Doctrine_Manager $manager the manager object + * @param PDO|Doctrine_Adapter_Interface $adapter database driver + */ + public function __construct(Doctrine_Manager $manager, $adapter, $user = null, $pass = null) + { + if (is_object($adapter)) { + if ( ! ($adapter instanceof PDO) && ! in_array('Doctrine_Adapter_Interface', class_implements($adapter))) { + throw new Doctrine_Connection_Exception('First argument should be an instance of PDO or implement Doctrine_Adapter_Interface'); + } + $this->dbh = $adapter; + + $this->isConnected = true; + + } else if (is_array($adapter)) { + $this->pendingAttributes[Doctrine::ATTR_DRIVER_NAME] = $adapter['scheme']; + + $this->options['dsn'] = $adapter['dsn']; + $this->options['username'] = $adapter['user']; + $this->options['password'] = $adapter['pass']; + + $this->options['other'] = array(); + if (isset($adapter['other'])) { + $this->options['other'] = array(Doctrine::ATTR_PERSISTENT => $adapter['persistent']); + } + + } + + $this->setParent($manager); + + $this->setAttribute(Doctrine::ATTR_CASE, Doctrine::CASE_NATURAL); + $this->setAttribute(Doctrine::ATTR_ERRMODE, Doctrine::ERRMODE_EXCEPTION); + + $this->getAttribute(Doctrine::ATTR_LISTENER)->onOpen($this); + } + + /** + * getOptions + * + * Get array of all options + * + * @return void + */ + public function getOptions() + { + return $this->options; + } + + /** + * getOption + * + * Retrieves option + * + * @param string $option + * @return void + */ + public function getOption($option) + { + if (isset($this->options[$option])) { + return $this->options[$option]; + } + } + + /** + * setOption + * + * Set option value + * + * @param string $option + * @return void + */ + public function setOption($option, $value) + { + return $this->options[$option] = $value; + } + + /** + * getAttribute + * retrieves a database connection attribute + * + * @param integer $attribute + * @return mixed + */ + public function getAttribute($attribute) + { + if (is_string($attribute)) { + $stringAttribute = $attribute; + $attribute = $this->getAttributeFromString($attribute); + } + + if ($attribute >= 100) { + if ( ! isset($this->attributes[$attribute])) { + return parent::getAttribute($attribute); + } + return $this->attributes[$attribute]; + } + + if ($this->isConnected) { + try { + return $this->dbh->getAttribute($attribute); + } catch (Exception $e) { + throw new Doctrine_Connection_Exception('Attribute ' . $attribute . ' not found.'); + } + } else { + if ( ! isset($this->pendingAttributes[$attribute])) { + $this->connect(); + $this->getAttribute($attribute); + } + + return $this->pendingAttributes[$attribute]; + } + } + + /** + * returns an array of available PDO drivers + */ + public static function getAvailableDrivers() + { + return PDO::getAvailableDrivers(); + } + + /** + * Returns an array of supported drivers by Doctrine + * + * @return array $supportedDrivers + */ + public static function getSupportedDrivers() + { + return self::$supportedDrivers; + } + + /** + * setAttribute + * sets an attribute + * + * @todo why check for >= 100? has this any special meaning when creating + * attributes? + * + * @param integer $attribute + * @param mixed $value + * @return boolean + */ + public function setAttribute($attribute, $value) + { + if (is_string($attribute)) { + $attributeString = $attribute; + $attribute = parent::getAttributeFromString($attribute); + } + + if (is_string($value) && isset($attributeString)) { + $value = parent::getAttributeValueFromString($attributeString, $value); + } + + if ($attribute >= 100) { + parent::setAttribute($attribute, $value); + } else { + if ($this->isConnected) { + $this->dbh->setAttribute($attribute, $value); + } else { + $this->pendingAttributes[$attribute] = $value; + } + } + + return $this; + } + + /** + * getName + * returns the name of this driver + * + * @return string the name of this driver + */ + public function getName() + { + return $this->_name; + } + + /** + * setName + * + * Sets the name of the connection + * + * @param string $name + * @return void + */ + public function setName($name) + { + $this->_name = $name; + } + + /** + * getDriverName + * + * Gets the name of the instance driver + * + * @return void + */ + public function getDriverName() + { + return $this->driverName; + } + + /** + * __get + * lazy loads given module and returns it + * + * @see Doctrine_DataDict + * @see Doctrine_Expression + * @see Doctrine_Export + * @see Doctrine_Transaction + * @see Doctrine_Connection::$modules all availible modules + * @param string $name the name of the module to get + * @throws Doctrine_Connection_Exception if trying to get an unknown module + * @return Doctrine_Connection_Module connection module + */ + public function __get($name) + { + if (isset($this->properties[$name])) { + return $this->properties[$name]; + } + + if ( ! isset($this->modules[$name])) { + throw new Doctrine_Connection_Exception('Unknown module / property ' . $name); + } + if ($this->modules[$name] === false) { + switch ($name) { + case 'unitOfWork': + $this->modules[$name] = new Doctrine_Connection_UnitOfWork($this); + break; + case 'formatter': + $this->modules[$name] = new Doctrine_Formatter($this); + break; + default: + $class = 'Doctrine_' . ucwords($name) . '_' . $this->getDriverName(); + $this->modules[$name] = new $class($this); + } + } + + return $this->modules[$name]; + } + + /** + * returns the manager that created this connection + * + * @return Doctrine_Manager + */ + public function getManager() + { + return $this->getParent(); + } + + /** + * returns the database handler of which this connection uses + * + * @return PDO the database handler + */ + public function getDbh() + { + $this->connect(); + + return $this->dbh; + } + + /** + * connect + * connects into database + * + * @return boolean + */ + public function connect() + { + if ($this->isConnected) { + return false; + } + + $event = new Doctrine_Event($this, Doctrine_Event::CONN_CONNECT); + + $this->getListener()->preConnect($event); + + $e = explode(':', $this->options['dsn']); + $found = false; + + if (extension_loaded('pdo')) { + if (in_array($e[0], self::getAvailableDrivers())) { + try { + $this->dbh = new PDO($this->options['dsn'], $this->options['username'], + (!$this->options['password'] ? '':$this->options['password']), $this->options['other']); + + $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (PDOException $e) { + throw new Doctrine_Connection_Exception('PDO Connection Error: ' . $e->getMessage()); + } + $found = true; + } + } + + if ( ! $found) { + $class = 'Doctrine_Adapter_' . ucwords($e[0]); + + if (class_exists($class)) { + $this->dbh = new $class($this->options['dsn'], $this->options['username'], $this->options['password']); + } else { + throw new Doctrine_Connection_Exception("Couldn't locate driver named " . $e[0]); + } + } + + // attach the pending attributes to adapter + foreach($this->pendingAttributes as $attr => $value) { + // some drivers don't support setting this so we just skip it + if ($attr == Doctrine::ATTR_DRIVER_NAME) { + continue; + } + $this->dbh->setAttribute($attr, $value); + } + + $this->isConnected = true; + + $this->getListener()->postConnect($event); + return true; + } + + public function incrementQueryCount() + { + $this->_count++; + } + + /** + * converts given driver name + * + * @param + */ + public function driverName($name) + { + } + + /** + * supports + * + * @param string $feature the name of the feature + * @return boolean whether or not this drivers supports given feature + */ + public function supports($feature) + { + return (isset($this->supported[$feature]) + && ($this->supported[$feature] === 'emulated' + || $this->supported[$feature])); + } + + /** + * Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT + * query, except that if there is already a row in the table with the same + * key field values, the REPLACE query just updates its values instead of + * inserting a new row. + * + * The REPLACE type of query does not make part of the SQL standards. Since + * practically only MySQL and SQLIte implement it natively, this type of + * query isemulated through this method for other DBMS using standard types + * of queries inside a transaction to assure the atomicity of the operation. + * + * @param string name of the table on which the REPLACE query will + * be executed. + * + * @param array an associative array that describes the fields and the + * values that will be inserted or updated in the specified table. The + * indexes of the array are the names of all the fields of the table. + * + * The values of the array are values to be assigned to the specified field. + * + * @param array $keys an array containing all key fields (primary key fields + * or unique index fields) for this table + * + * the uniqueness of a row will be determined according to + * the provided key fields + * + * this method will fail if no key fields are specified + * + * @throws Doctrine_Connection_Exception if this driver doesn't support replace + * @throws Doctrine_Connection_Exception if some of the key values was null + * @throws Doctrine_Connection_Exception if there were no key fields + * @throws PDOException if something fails at PDO level + * @ return integer number of rows affected + */ + public function replace(Doctrine_Table $table, array $fields, array $keys) + { + if (empty($keys)) { + throw new Doctrine_Connection_Exception('Not specified which fields are keys'); + } + $identifier = (array) $table->getIdentifier(); + $condition = array(); + + foreach ($fields as $fieldName => $value) { + if (in_array($fieldName, $keys)) { + if ($value !== null) { + $condition[] = $table->getColumnName($fieldName) . ' = ?'; + $conditionValues[] = $value; + } + } + } + + $affectedRows = 0; + if ( ! empty($condition) && ! empty($conditionValues)) { + $query = 'DELETE FROM ' . $this->quoteIdentifier($table->getTableName()) + . ' WHERE ' . implode(' AND ', $condition); + + $affectedRows = $this->exec($query, $conditionValues); + } + + $this->insert($table, $fields); + + $affectedRows++; + + return $affectedRows; + } + + /** + * deletes table row(s) matching the specified identifier + * + * @throws Doctrine_Connection_Exception if something went wrong at the database level + * @param string $table The table to delete data from + * @param array $identifier An associateve array containing identifier column-value pairs. + * @return integer The number of affected rows + */ + public function delete(Doctrine_Table $table, array $identifier) + { + $tmp = array(); + + foreach (array_keys($identifier) as $id) { + $tmp[] = $this->quoteIdentifier($table->getColumnName($id)) . ' = ?'; + } + + $query = 'DELETE FROM ' + . $this->quoteIdentifier($table->getTableName()) + . ' WHERE ' . implode(' AND ', $tmp); + + return $this->exec($query, array_values($identifier)); + } + + /** + * Updates table row(s) with specified data + * + * @throws Doctrine_Connection_Exception if something went wrong at the database level + * @param string $table The table to insert data into + * @param array $values An associateve array containing column-value pairs. + * @return mixed boolean false if empty value array was given, + * otherwise returns the number of affected rows + */ + public function update(Doctrine_Table $table, array $fields, array $identifier) + { + if (empty($fields)) { + return false; + } + + $set = array(); + foreach ($fields as $fieldName => $value) { + if ($value instanceof Doctrine_Expression) { + $set[] = $this->quoteIdentifier($table->getColumnName($fieldName)) . ' = ' . $value->getSql(); + unset($fields[$fieldName]); + } else { + $set[] = $this->quoteIdentifier($table->getColumnName($fieldName)) . ' = ?'; + } + } + + $params = array_merge(array_values($fields), array_values($identifier)); + + $sql = 'UPDATE ' . $this->quoteIdentifier($table->getTableName()) + . ' SET ' . implode(', ', $set) + . ' WHERE ' . implode(' = ? AND ', $this->quoteMultipleIdentifier($table->getIdentifierColumnNames())) + . ' = ?'; + + return $this->exec($sql, $params); + } + + /** + * Inserts a table row with specified data. + * + * @param string $table The table to insert data into. + * @param array $values An associateve array containing column-value pairs. + * @return mixed boolean false if empty value array was given, + * otherwise returns the number of affected rows + */ + public function insert(Doctrine_Table $table, array $fields) + { + $tableName = $table->getTableName(); + + // column names are specified as array keys + $cols = array(); + // the query VALUES will contain either expresions (eg 'NOW()') or ? + $a = array(); + foreach ($fields as $fieldName => $value) { + $cols[] = $this->quoteIdentifier($table->getColumnName($fieldName)); + if ($value instanceof Doctrine_Expression) { + $a[] = $value->getSql(); + unset($fields[$fieldName]); + } else { + $a[] = '?'; + } + } + + // build the statement + $query = 'INSERT INTO ' . $this->quoteIdentifier($tableName) + . ' (' . implode(', ', $cols) . ')' + . ' VALUES (' . implode(', ', $a) . ')'; + + return $this->exec($query, array_values($fields)); + } + + /** + * Set the charset on the current connection + * + * @param string charset + */ + public function setCharset($charset) + { + + } + + /** + * Quote a string so it can be safely used as a table or column name + * + * Delimiting style depends on which database driver is being used. + * + * NOTE: just because you CAN use delimited identifiers doesn't mean + * you SHOULD use them. In general, they end up causing way more + * problems than they solve. + * + * Portability is broken by using the following characters inside + * delimited identifiers: + * + backtick (`) -- due to MySQL + * + double quote (") -- due to Oracle + * + brackets ([ or ]) -- due to Access + * + * Delimited identifiers are known to generally work correctly under + * the following drivers: + * + mssql + * + mysql + * + mysqli + * + oci8 + * + pgsql + * + sqlite + * + * InterBase doesn't seem to be able to use delimited identifiers + * via PHP 4. They work fine under PHP 5. + * + * @param string $str identifier name to be quoted + * @param bool $checkOption check the 'quote_identifier' option + * + * @return string quoted identifier string + */ + public function quoteIdentifier($str, $checkOption = true) + { + // quick fix for the identifiers that contain a dot + if (strpos($str, '.')) { + $e = explode('.', $str); + + return $this->formatter->quoteIdentifier($e[0], $checkOption) . '.' + . $this->formatter->quoteIdentifier($e[1], $checkOption); + } + return $this->formatter->quoteIdentifier($str, $checkOption); + } + + /** + * quoteMultipleIdentifier + * Quotes multiple identifier strings + * + * @param array $arr identifiers array to be quoted + * @param bool $checkOption check the 'quote_identifier' option + * + * @return string quoted identifier string + */ + public function quoteMultipleIdentifier($arr, $checkOption = true) + { + foreach ($arr as $k => $v) { + $arr[$k] = $this->quoteIdentifier($v, $checkOption); + } + + return $arr; + } + + + /** + * convertBooleans + * some drivers need the boolean values to be converted into integers + * when using DQL API + * + * This method takes care of that conversion + * + * @param array $item + * @return void + */ + public function convertBooleans($item) + { + return $this->formatter->convertBooleans($item); + } + + /** + * quote + * quotes given input parameter + * + * @param mixed $input parameter to be quoted + * @param string $type + * @return mixed + */ + public function quote($input, $type = null) + { + return $this->formatter->quote($input, $type); + } + + /** + * Set the date/time format for the current connection + * + * @param string time format + * + * @return void + */ + public function setDateFormat($format = null) + { + } + + /** + * fetchAll + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @return array + */ + public function fetchAll($statement, array $params = array()) + { + return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC); + } + + /** + * fetchOne + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @param int $colnum 0-indexed column number to retrieve + * @return mixed + */ + public function fetchOne($statement, array $params = array(), $colnum = 0) + { + return $this->execute($statement, $params)->fetchColumn($colnum); + } + + /** + * fetchRow + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @return array + */ + public function fetchRow($statement, array $params = array()) + { + return $this->execute($statement, $params)->fetch(Doctrine::FETCH_ASSOC); + } + + /** + * fetchArray + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @return array + */ + public function fetchArray($statement, array $params = array()) + { + return $this->execute($statement, $params)->fetch(Doctrine::FETCH_NUM); + } + + /** + * fetchColumn + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @param int $colnum 0-indexed column number to retrieve + * @return array + */ + public function fetchColumn($statement, array $params = array(), $colnum = 0) + { + return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_COLUMN, $colnum); + } + + /** + * fetchAssoc + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @return array + */ + public function fetchAssoc($statement, array $params = array()) + { + return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC); + } + + /** + * fetchBoth + * + * @param string $statement sql query to be executed + * @param array $params prepared statement params + * @return array + */ + public function fetchBoth($statement, array $params = array()) + { + return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_BOTH); + } + + /** + * query + * queries the database using Doctrine Query Language + * returns a collection of Doctrine_Record objects + * + * + * $users = $conn->query('SELECT u.* FROM User u'); + * + * $users = $conn->query('SELECT u.* FROM User u WHERE u.name LIKE ?', array('someone')); + * + * + * @param string $query DQL query + * @param array $params query parameters + * @param int $hydrationMode Doctrine::HYDRATE_ARRAY or Doctrine::HYDRATE_RECORD + * @see Doctrine_Query + * @return Doctrine_Collection Collection of Doctrine_Record objects + */ + public function query($query, array $params = array(), $hydrationMode = null) + { + $parser = new Doctrine_Query($this); + $res = $parser->query($query, $params, $hydrationMode); + $parser->free(); + + return $res; + } + + /** + * prepare + * + * @param string $statement + */ + public function prepare($statement) + { + $this->connect(); + + try { + $event = new Doctrine_Event($this, Doctrine_Event::CONN_PREPARE, $statement); + + $this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event); + + $stmt = false; + + if ( ! $event->skipOperation) { + $stmt = $this->dbh->prepare($statement); + } + + $this->getAttribute(Doctrine::ATTR_LISTENER)->postPrepare($event); + + return new Doctrine_Connection_Statement($this, $stmt); + } catch(Doctrine_Adapter_Exception $e) { + } catch(PDOException $e) { } + + $this->rethrowException($e, $this); + } + + /** + * query + * queries the database using Doctrine Query Language and returns + * the first record found + * + * + * $user = $conn->queryOne('SELECT u.* FROM User u WHERE u.id = ?', array(1)); + * + * $user = $conn->queryOne('SELECT u.* FROM User u WHERE u.name LIKE ? AND u.password = ?', + * array('someone', 'password') + * ); + * + * + * @param string $query DQL query + * @param array $params query parameters + * @see Doctrine_Query + * @return Doctrine_Record|false Doctrine_Record object on success, + * boolean false on failure + */ + public function queryOne($query, array $params = array()) + { + $parser = new Doctrine_Query($this); + + $coll = $parser->query($query, $params); + if ( ! $coll->contains(0)) { + return false; + } + return $coll[0]; + } + + /** + * queries the database with limit and offset + * added to the query and returns a Doctrine_Connection_Statement object + * + * @param string $query + * @param integer $limit + * @param integer $offset + * @return Doctrine_Connection_Statement + */ + public function select($query, $limit = 0, $offset = 0) + { + if ($limit > 0 || $offset > 0) { + $query = $this->modifyLimitQuery($query, $limit, $offset); + } + return $this->execute($query); + } + + /** + * standaloneQuery + * + * @param string $query sql query + * @param array $params query parameters + * + * @return PDOStatement|Doctrine_Adapter_Statement + */ + public function standaloneQuery($query, $params = array()) + { + return $this->execute($query, $params); + } + + /** + * execute + * @param string $query sql query + * @param array $params query parameters + * + * @return PDOStatement|Doctrine_Adapter_Statement + */ + public function execute($query, array $params = array()) + { + $this->connect(); + + try { + if ( ! empty($params)) { + $stmt = $this->prepare($query); + $stmt->execute($params); + + return $stmt; + } else { + $event = new Doctrine_Event($this, Doctrine_Event::CONN_QUERY, $query, $params); + + $this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event); + + if ( ! $event->skipOperation) { + $stmt = $this->dbh->query($query); + $this->_count++; + } + $this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event); + + return $stmt; + } + } + catch (Doctrine_Adapter_Exception $e) { } + catch (PDOException $e) { } + + $this->rethrowException($e, $this); + } + + /** + * exec + * @param string $query sql query + * @param array $params query parameters + * + * @return PDOStatement|Doctrine_Adapter_Statement + */ + public function exec($query, array $params = array()) + { + $this->connect(); + + try { + if ( ! empty($params)) { + $stmt = $this->prepare($query); + $stmt->execute($params); + + return $stmt->rowCount(); + } else { + $event = new Doctrine_Event($this, Doctrine_Event::CONN_EXEC, $query, $params); + + $this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event); + if ( ! $event->skipOperation) { + $count = $this->dbh->exec($query); + + $this->_count++; + } + $this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event); + + return $count; + } + } catch (Doctrine_Adapter_Exception $e) { + } catch (PDOException $e) { } + + $this->rethrowException($e, $this); + } + + /** + * rethrowException + * + * @throws Doctrine_Connection_Exception + */ + public function rethrowException(Exception $e, $invoker) + { + $event = new Doctrine_Event($this, Doctrine_Event::CONN_ERROR); + + $this->getListener()->preError($event); + + $name = 'Doctrine_Connection_' . $this->driverName . '_Exception'; + + $exc = new $name($e->getMessage(), (int) $e->getCode()); + if ( ! isset($e->errorInfo) || ! is_array($e->errorInfo)) { + $e->errorInfo = array(null, null, null, null); + } + $exc->processErrorInfo($e->errorInfo); + + if ($this->getAttribute(Doctrine::ATTR_THROW_EXCEPTIONS)) { + throw $exc; + } + + $this->getListener()->postError($event); + } + + /** + * hasTable + * whether or not this connection has table $name initialized + * + * @param mixed $name + * @return boolean + */ + public function hasTable($name) + { + return isset($this->tables[$name]); + } + + /** + * returns a table object for given component name + * + * @param string $name component name + * @return object Doctrine_Table + */ + public function getTable($name) + { + if (isset($this->tables[$name])) { + return $this->tables[$name]; + } + $class = $name . 'Table'; + + if (class_exists($class, $this->getAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES)) && + in_array('Doctrine_Table', class_parents($class))) { + $table = new $class($name, $this, true); + } else { + $table = new Doctrine_Table($name, $this, true); + } + + $this->tables[$name] = $table; + + return $table; + } + + /** + * returns an array of all initialized tables + * + * @return array + */ + public function getTables() + { + return $this->tables; + } + + /** + * returns an iterator that iterators through all + * initialized table objects + * + * + * foreach ($conn as $index => $table) { + * print $table; // get a string representation of each table object + * } + * + * + * @return ArrayIterator SPL ArrayIterator object + */ + public function getIterator() + { + return new ArrayIterator($this->tables); + } + + /** + * returns the count of initialized table objects + * + * @return integer + */ + public function count() + { + return $this->_count; + } + + /** + * addTable + * adds a Doctrine_Table object into connection registry + * + * @param $table a Doctrine_Table object to be added into registry + * @return boolean + */ + public function addTable(Doctrine_Table $table) + { + $name = $table->getComponentName(); + + if (isset($this->tables[$name])) { + return false; + } + $this->tables[$name] = $table; + return true; + } + + /** + * create + * creates a record + * + * create creates a record + * @param string $name component name + * @return Doctrine_Record Doctrine_Record object + */ + public function create($name) + { + return $this->getTable($name)->create(); + } + + /** + * Creates a new Doctrine_Query object that operates on this connection. + * + * @return Doctrine_Query + */ + public function createQuery() + { + return new Doctrine_Query($this); + } + + /** + * flush + * saves all the records from all tables + * this operation is isolated using a transaction + * + * @throws PDOException if something went wrong at database level + * @return void + */ + public function flush() + { + try { + $this->beginInternalTransaction(); + $this->unitOfWork->saveAll(); + $this->commit(); + } catch (Exception $e) { + $this->rollback(); + throw $e; + } + } + + /** + * clear + * clears all repositories + * + * @return void + */ + public function clear() + { + foreach ($this->tables as $k => $table) { + $table->getRepository()->evictAll(); + $table->clear(); + } + } + + /** + * evictTables + * evicts all tables + * + * @return void + */ + public function evictTables() + { + $this->tables = array(); + $this->exported = array(); + } + + /** + * close + * closes the connection + * + * @return void + */ + public function close() + { + $event = new Doctrine_Event($this, Doctrine_Event::CONN_CLOSE); + + $this->getAttribute(Doctrine::ATTR_LISTENER)->preClose($event); + + $this->clear(); + + unset($this->dbh); + $this->isConnected = false; + + $this->getAttribute(Doctrine::ATTR_LISTENER)->postClose($event); + } + + /** + * get the current transaction nesting level + * + * @return integer + */ + public function getTransactionLevel() + { + return $this->transaction->getTransactionLevel(); + } + + /** + * errorCode + * Fetch the SQLSTATE associated with the last operation on the database handle + * + * @return integer + */ + public function errorCode() + { + $this->connect(); + + return $this->dbh->errorCode(); + } + + /** + * errorInfo + * Fetch extended error information associated with the last operation on the database handle + * + * @return array + */ + public function errorInfo() + { + $this->connect(); + + return $this->dbh->errorInfo(); + } + + /** + * getCacheDriver + * + * @return Doctrine_Cache_Interface + * @deprecated Use getResultCacheDriver() + */ + public function getCacheDriver() + { + return $this->getResultCacheDriver(); + } + + /** + * getResultCacheDriver + * + * @return Doctrine_Cache_Interface + */ + public function getResultCacheDriver() + { + if ( ! $this->getAttribute(Doctrine::ATTR_RESULT_CACHE)) { + throw new Doctrine_Exception('Result Cache driver not initialized.'); + } + + return $this->getAttribute(Doctrine::ATTR_RESULT_CACHE); + } + + /** + * getQueryCacheDriver + * + * @return Doctrine_Cache_Interface + */ + public function getQueryCacheDriver() + { + if ( ! $this->getAttribute(Doctrine::ATTR_QUERY_CACHE)) { + throw new Doctrine_Exception('Query Cache driver not initialized.'); + } + + return $this->getAttribute(Doctrine::ATTR_QUERY_CACHE); + } + + /** + * lastInsertId + * + * Returns the ID of the last inserted row, or the last value from a sequence object, + * depending on the underlying driver. + * + * Note: This method may not return a meaningful or consistent result across different drivers, + * because the underlying database may not even support the notion of auto-increment fields or sequences. + * + * @param string $table name of the table into which a new row was inserted + * @param string $field name of the field into which a new row was inserted + */ + public function lastInsertId($table = null, $field = null) + { + return $this->sequence->lastInsertId($table, $field); + } + + /** + * beginTransaction + * Start a transaction or set a savepoint. + * + * if trying to set a savepoint and there is no active transaction + * a new transaction is being started + * + * Listeners: onPreTransactionBegin, onTransactionBegin + * + * @param string $savepoint name of a savepoint to set + * @throws Doctrine_Transaction_Exception if the transaction fails at database level + * @return integer current transaction nesting level + */ + public function beginTransaction($savepoint = null) + { + return $this->transaction->beginTransaction($savepoint); + } + + public function beginInternalTransaction($savepoint = null) + { + return $this->transaction->beginInternalTransaction($savepoint); + } + + /** + * commit + * Commit the database changes done during a transaction that is in + * progress or release a savepoint. This function may only be called when + * auto-committing is disabled, otherwise it will fail. + * + * Listeners: onPreTransactionCommit, onTransactionCommit + * + * @param string $savepoint name of a savepoint to release + * @throws Doctrine_Transaction_Exception if the transaction fails at PDO level + * @throws Doctrine_Validator_Exception if the transaction fails due to record validations + * @return boolean false if commit couldn't be performed, true otherwise + */ + public function commit($savepoint = null) + { + return $this->transaction->commit($savepoint); + } + + /** + * rollback + * Cancel any database changes done during a transaction or since a specific + * savepoint that is in progress. This function may only be called when + * auto-committing is disabled, otherwise it will fail. Therefore, a new + * transaction is implicitly started after canceling the pending changes. + * + * this method can be listened with onPreTransactionRollback and onTransactionRollback + * eventlistener methods + * + * @param string $savepoint name of a savepoint to rollback to + * @throws Doctrine_Transaction_Exception if the rollback operation fails at database level + * @return boolean false if rollback couldn't be performed, true otherwise + */ + public function rollback($savepoint = null) + { + return $this->transaction->rollback($savepoint); + } + + /** + * createDatabase + * + * Issue create database command for this instance of Doctrine_Connection + * + * @return mixed Returns Doctrine_Exception or success string + */ + public function createDatabase() + { + if ( ! $dsn = $this->getOption('dsn')) { + throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); + } + + // Parse pdo dsn so we are aware of the connection information parts + $info = $this->getManager()->parsePdoDsn($dsn); + + // Get the temporary connection to issue the drop database command + $tmpConnection = $this->getTmpConnection($info); + + try { + // Issue create database command + $tmpConnection->export->createDatabase($info['dbname']); + } catch (Exception $e) {} + + // Close the temporary connection used to issue the drop database command + $this->getManager()->closeConnection($tmpConnection); + + if (isset($e)) { + return $e; + } else { + return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; + } + } + + /** + * dropDatabase + * + * Issue drop database command for this instance of Doctrine_Connection + * + * @return mixed Returns Doctrine_Exception or success string + */ + public function dropDatabase() + { + if ( ! $dsn = $this->getOption('dsn')) { + throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); + } + + // Parse pdo dsn so we are aware of the connection information parts + $info = $this->getManager()->parsePdoDsn($dsn); + + // Get the temporary connection to issue the drop database command + $tmpConnection = $this->getTmpConnection($info); + + try { + // Issue drop database command + $tmpConnection->export->dropDatabase($info['dbname']); + } catch (Exception $e) {} + + // Close the temporary connection used to issue the drop database command + $this->getManager()->closeConnection($tmpConnection); + + if (isset($e)) { + return $e; + } else { + return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; + } + } + + /** + * getTmpConnection + * + * Create a temporary connection to the database with the user credentials. + * This is so the user can make a connection to a db server. Some dbms allow + * connections with no database, but some do not. In that case we have a table + * which is always guaranteed to exist. Mysql: 'mysql', PostgreSQL: 'postgres', etc. + * This value is set in the Doctrine_Export_{DRIVER} classes if required + * + * @param string $info + * @return void + */ + public function getTmpConnection($info) + { + $pdoDsn = $info['scheme'] . ':'; + + if ($info['unix_socket']) { + $pdoDsn .= 'unix_socket=' . $info['unix_socket'] . ';'; + } + + $pdoDsn .= 'host=' . $info['host']; + + if ($info['port']) { + $pdoDsn .= ';port=' . $info['port']; + } + + if (isset($this->export->tmpConnectionDatabase) && $this->export->tmpConnectionDatabase) { + $pdoDsn .= ';dbname=' . $this->export->tmpConnectionDatabase; + } + + $username = $this->getOption('username'); + $password = $this->getOption('password'); + + return $this->getManager()->openConnection(new PDO($pdoDsn, $username, $password), 'doctrine_tmp_connection', false); + } + + /** + * modifyLimitQuery + * + * Some dbms require specific functionality for this. Check the other connection adapters for examples + * + * @return string + */ + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) + { + return $query; + } + + /** + * Creates dbms specific LIMIT/OFFSET SQL for the subqueries that are used in the + * context of the limit-subquery algorithm. + * + * @return string + */ + public function modifyLimitSubquery(Doctrine_Table $rootTable, $query, $limit = false, + $offset = false, $isManip = false) + { + return $this->modifyLimitQuery($query, $limit, $offset, $isManip); + } + + /** + * returns a string representation of this object + * @return string + */ + public function __toString() + { + return Doctrine_Lib::getConnectionAsString($this); + } + + /** + * Serialize. Remove database connection(pdo) since it cannot be serialized + * + * @return string $serialized + */ + public function serialize() + { + $vars = get_object_vars($this); + $vars['dbh'] = null; + $vars['isConnected'] = false; + return serialize($vars); + } + + /** + * Unserialize. Recreate connection from serialized content + * + * @param string $serialized + * @return void + */ + public function unserialize($serialized) + { + $array = unserialize($serialized); + + foreach ($array as $name => $values) { + $this->$name = $values; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Common.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Common.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,57 @@ +. + */ + +/** + * standard connection, the parent of pgsql, mysql and sqlite + * + * @package Doctrine + * @subpackage Connection + * @link www.phpdoctrine.org + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Common extends Doctrine_Connection +{ + /** + * Adds an driver-specific LIMIT clause to the query + * + * @param string $query + * @param mixed $limit + * @param mixed $offset + */ + public function modifyLimitQuery($query, $limit = false,$offset = false,$isManip=false) + { + $limit = (int) $limit; + $offset = (int) $offset; + + if ($limit && $offset) { + $query .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } elseif ($limit && ! $offset) { + $query .= ' LIMIT ' . $limit; + } elseif ( ! $limit && $offset) { + $query .= ' LIMIT 999999999999 OFFSET ' . $offset; + } + + return $query; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Db2.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Db2.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,64 @@ +. + */ + +/** + * Doctrine_Connection_Db2 + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Db2 extends Doctrine_Connection +{ + /** + * Adds an driver-specific LIMIT clause to the query + * + * @param string $query query to modify + * @param integer $limit limit the number of rows + * @param integer $offset start reading from given offset + * @return string the modified query + */ + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) + { + if ($limit <= 0) + return $query; + + if ($offset == 0) { + return $query . ' FETCH FIRST '. $limit .' ROWS ONLY'; + } else { + $sqlPieces = explode('from', $query); + $select = $sqlPieces[0]; + $table = $sqlPieces[1]; + + $col = explode('select', $select); + + $sql = 'WITH OFFSET AS(' . $select . ', ROW_NUMBER() ' . + 'OVER(ORDER BY ' . $col[1] . ') AS doctrine_rownum FROM ' . $table . ')' . + $select . 'FROM OFFSET WHERE doctrine_rownum BETWEEN ' . $offset . + 'AND ' . ($offset + $limit - 1); + return $sql; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,130 @@ +. + */ + +/** + * Doctrine_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Exception extends Doctrine_Exception +{ + /** + * @var array $errorMessages an array containing messages for portable error codes + */ + static protected $errorMessages = array( + Doctrine::ERR => 'unknown error', + Doctrine::ERR_ALREADY_EXISTS => 'already exists', + Doctrine::ERR_CANNOT_CREATE => 'can not create', + Doctrine::ERR_CANNOT_ALTER => 'can not alter', + Doctrine::ERR_CANNOT_REPLACE => 'can not replace', + Doctrine::ERR_CANNOT_DELETE => 'can not delete', + Doctrine::ERR_CANNOT_DROP => 'can not drop', + Doctrine::ERR_CONSTRAINT => 'constraint violation', + Doctrine::ERR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint', + Doctrine::ERR_DIVZERO => 'division by zero', + Doctrine::ERR_INVALID => 'invalid', + Doctrine::ERR_INVALID_DATE => 'invalid date or time', + Doctrine::ERR_INVALID_NUMBER => 'invalid number', + Doctrine::ERR_MISMATCH => 'mismatch', + Doctrine::ERR_NODBSELECTED => 'no database selected', + Doctrine::ERR_NOSUCHFIELD => 'no such field', + Doctrine::ERR_NOSUCHTABLE => 'no such table', + Doctrine::ERR_NOT_CAPABLE => 'Doctrine backend not capable', + Doctrine::ERR_NOT_FOUND => 'not found', + Doctrine::ERR_NOT_LOCKED => 'not locked', + Doctrine::ERR_SYNTAX => 'syntax error', + Doctrine::ERR_UNSUPPORTED => 'not supported', + Doctrine::ERR_VALUE_COUNT_ON_ROW => 'value count on row', + Doctrine::ERR_INVALID_DSN => 'invalid DSN', + Doctrine::ERR_CONNECT_FAILED => 'connect failed', + Doctrine::ERR_NEED_MORE_DATA => 'insufficient data supplied', + Doctrine::ERR_EXTENSION_NOT_FOUND=> 'extension not found', + Doctrine::ERR_NOSUCHDB => 'no such database', + Doctrine::ERR_ACCESS_VIOLATION => 'insufficient permissions', + Doctrine::ERR_LOADMODULE => 'error while including on demand module', + Doctrine::ERR_TRUNCATED => 'truncated', + Doctrine::ERR_DEADLOCK => 'deadlock detected', + ); + + /** + * @see Doctrine::ERR_* constants + * @since 1.0 + * @var integer $portableCode portable error code + */ + protected $portableCode; + + /** + * getPortableCode + * returns portable error code + * + * @return integer portable error code + */ + public function getPortableCode() + { + return $this->portableCode; + } + + /** + * getPortableMessage + * returns portable error message + * + * @return string portable error message + */ + public function getPortableMessage() + { + return self::errorMessage($this->portableCode); + } + + /** + * Return a textual error message for a Doctrine error code + * + * @param int|array integer error code, + * null to get the current error code-message map, + * or an array with a new error code-message map + * + * @return string error message, or false if the error code was + * not recognized + */ + public function errorMessage($value = null) + { + return isset(self::$errorMessages[$value]) ? + self::$errorMessages[$value] : self::$errorMessages[Doctrine::ERR]; + } + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to $portableCode field + * + * @param array $errorInfo error info array + * @since 1.0 + * @return boolean whether or not the error info processing was successfull + * (the process is successfull if portable error code was found) + */ + public function processErrorInfo(array $errorInfo) + { } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Firebird.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Firebird.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,114 @@ +. + */ + +/** + * Doctrine_Connection_Firebird + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Lorenzo Alberton (PEAR MDB2 Interbase driver) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Connection_Firebird extends Doctrine_Connection +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Firebird'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO $pdo database handle + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + + $this->supported = array( + 'sequences' => true, + 'indexes' => true, + 'affected_rows' => true, + 'summary_functions' => true, + 'order_by_text' => true, + 'transactions' => true, + 'savepoints' => true, + 'current_id' => true, + 'limit_queries' => 'emulated', + 'LOBs' => true, + 'replace' => 'emulated', + 'sub_selects' => true, + 'auto_increment' => true, + 'primary_key' => true, + 'result_introspection' => true, + 'prepared_statements' => true, + 'identifier_quoting' => false, + 'pattern_escaping' => true + ); + // initialize all driver options + /** + $this->options['DBA_username'] = false; + $this->options['DBA_password'] = false; + $this->options['database_path'] = ''; + $this->options['database_extension'] = '.gdb'; + $this->options['server_version'] = ''; + */ + parent::__construct($manager, $adapter); + } + + /** + * Set the charset on the current connection + * + * @param string charset + * + * @return void + */ + public function setCharset($charset) + { + $query = 'SET NAMES '.$this->dbh->quote($charset); + $this->exec($query); + } + + /** + * Adds an driver-specific LIMIT clause to the query + * + * @param string $query query to modify + * @param integer $limit limit the number of rows + * @param integer $offset start reading from given offset + * @return string modified query + */ + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) + { + if ( ! $offset) { + $offset = 0; + } + if ($limit > 0) { + $query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i', + "SELECT FIRST $limit SKIP $offset", $query); + } + return $query; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Firebird/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Firebird/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,136 @@ +. + */ + +/** + * Doctrine_Connection_Firebird_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + * @author Lorenzo Alberton (PEAR MDB2 Interbase driver) + * @author Lukas Smith (PEAR MDB2 library) + */ +class Doctrine_Connection_Firebird_Exception extends Doctrine_Connection_Exception +{ + /** + * @var array $errorCodeMap an array that is used for determining portable + * error code from a native database error code + */ + protected static $errorCodeMap = array( + -104 => Doctrine::ERR_SYNTAX, + -150 => Doctrine::ERR_ACCESS_VIOLATION, + -151 => Doctrine::ERR_ACCESS_VIOLATION, + -155 => Doctrine::ERR_NOSUCHTABLE, + -157 => Doctrine::ERR_NOSUCHFIELD, + -158 => Doctrine::ERR_VALUE_COUNT_ON_ROW, + -170 => Doctrine::ERR_MISMATCH, + -171 => Doctrine::ERR_MISMATCH, + -172 => Doctrine::ERR_INVALID, + // -204 => // Covers too many errors, need to use regex on msg + -205 => Doctrine::ERR_NOSUCHFIELD, + -206 => Doctrine::ERR_NOSUCHFIELD, + -208 => Doctrine::ERR_INVALID, + -219 => Doctrine::ERR_NOSUCHTABLE, + -297 => Doctrine::ERR_CONSTRAINT, + -303 => Doctrine::ERR_INVALID, + -413 => Doctrine::ERR_INVALID_NUMBER, + -530 => Doctrine::ERR_CONSTRAINT, + -551 => Doctrine::ERR_ACCESS_VIOLATION, + -552 => Doctrine::ERR_ACCESS_VIOLATION, + // -607 => // Covers too many errors, need to use regex on msg + -625 => Doctrine::ERR_CONSTRAINT_NOT_NULL, + -803 => Doctrine::ERR_CONSTRAINT, + -804 => Doctrine::ERR_VALUE_COUNT_ON_ROW, + -904 => Doctrine::ERR_CONNECT_FAILED, + -922 => Doctrine::ERR_NOSUCHDB, + -923 => Doctrine::ERR_CONNECT_FAILED, + -924 => Doctrine::ERR_CONNECT_FAILED + ); + + /** + * @var array $errorRegexps an array that is used for determining portable + * error code from a native database error message + */ + protected static $errorRegexps = array( + '/generator .* is not defined/' + => Doctrine::ERR_SYNTAX, // for compat. w ibase_errcode() + '/table.*(not exist|not found|unknown)/i' + => Doctrine::ERR_NOSUCHTABLE, + '/table .* already exists/i' + => Doctrine::ERR_ALREADY_EXISTS, + '/unsuccessful metadata update .* failed attempt to store duplicate value/i' + => Doctrine::ERR_ALREADY_EXISTS, + '/unsuccessful metadata update .* not found/i' + => Doctrine::ERR_NOT_FOUND, + '/validation error for column .* value "\*\*\* null/i' + => Doctrine::ERR_CONSTRAINT_NOT_NULL, + '/violation of [\w ]+ constraint/i' + => Doctrine::ERR_CONSTRAINT, + '/conversion error from string/i' + => Doctrine::ERR_INVALID_NUMBER, + '/no permission for/i' + => Doctrine::ERR_ACCESS_VIOLATION, + '/arithmetic exception, numeric overflow, or string truncation/i' + => Doctrine::ERR_INVALID, + '/table unknown/i' + => Doctrine::ERR_NOSUCHTABLE, + ); + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to errorInfo array and returns the modified array + * + * the portable error code is added at the end of array + * + * @param array $errorInfo error info array + * @since 1.0 + * @return array + */ + public function processErrorInfo(array $errorInfo) + { + /** + // todo: are the following lines needed? + // memo for the interbase php module hackers: we need something similar + // to mysql_errno() to retrieve error codes instead of this ugly hack + if (preg_match('/^([^0-9\-]+)([0-9\-]+)\s+(.*)$/', $native_msg, $m)) { + $native_code = (int)$m[2]; + } else { + $native_code = null; + } + */ + + foreach (self::$errorRegexps as $regexp => $code) { + if (preg_match($regexp, $errorInfo[2])) { + $errorInfo[3] = $code; + break; + } + } + if (isset(self::$errorCodeMap[$errorInfo[1]])) { + $errorInfo[3] = self::$errorCodeMap[$errorInfo[1]]; + } + return $errorInfo; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Informix.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Informix.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,62 @@ +. + */ + +/** + * Doctrine_Connection_Mysql + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Informix extends Doctrine_Connection +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Informix'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO $pdo database handle + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + parent::__construct($manager, $adapter); + } + + /** + * quoteIdentifier + * + * @param string $identifier + * @param string $checkOption + * @return void + */ + public function quoteIdentifier($identifier, $checkOption = false) + { + return $identifier; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Informix/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Informix/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Connection_Informix_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Informix_Exception extends Doctrine_Connection_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mock.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mock.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,51 @@ +. + */ + +/** + * Doctrine_Connection_Mysql + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Connection_Mock extends Doctrine_Connection_Common +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Mock'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO|Doctrine_Adapter $adapter database handler + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Module.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Module.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,83 @@ +. + */ + +/** + * Doctrine_Connection_Module + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Module +{ + /** + * @var Doctrine_Connection $conn Doctrine_Connection object, every connection + * module holds an instance of Doctrine_Connection + */ + protected $conn; + + /** + * @var string $moduleName the name of this module + */ + protected $moduleName; + + /** + * @param Doctrine_Connection $conn Doctrine_Connection object, every connection + * module holds an instance of Doctrine_Connection + */ + public function __construct($conn = null) + { + if ( ! ($conn instanceof Doctrine_Connection)) { + $conn = Doctrine_Manager::getInstance()->getCurrentConnection(); + } + $this->conn = $conn; + + $e = explode('_', get_class($this)); + + $this->moduleName = $e[1]; + } + + /** + * getConnection + * returns the connection object this module uses + * + * @return Doctrine_Connection + */ + public function getConnection() + { + return $this->conn; + } + + /** + * getModuleName + * returns the name of this module + * + * @return string the name of this module + */ + public function getModuleName() + { + return $this->moduleName; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mssql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mssql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,278 @@ +. + */ + +/** + * Doctrine_Connection_Mssql + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5804 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Connection_Mssql extends Doctrine_Connection +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Mssql'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO $pdo database handle + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + // initialize all driver options + $this->supported = array( + 'sequences' => 'emulated', + 'indexes' => true, + 'affected_rows' => true, + 'transactions' => true, + 'summary_functions' => true, + 'order_by_text' => true, + 'current_id' => 'emulated', + 'limit_queries' => 'emulated', + 'LOBs' => true, + 'replace' => 'emulated', + 'sub_selects' => true, + 'auto_increment' => true, + 'primary_key' => true, + 'result_introspection' => true, + 'prepared_statements' => 'emulated', + ); + + parent::__construct($manager, $adapter); + } + + /** + * quoteIdentifier + * Quote a string so it can be safely used as a table / column name + * + * Quoting style depends on which database driver is being used. + * + * @param string $identifier identifier name to be quoted + * @param bool $checkOption check the 'quote_identifier' option + * + * @return string quoted identifier string + */ + public function quoteIdentifier($identifier, $checkOption = false) + { + if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) { + return $identifier; + } + + if (strpos($identifier, '.') !== false) { + $parts = explode('.', $identifier); + $quotedParts = array(); + foreach ($parts as $p) { + $quotedParts[] = $this->quoteIdentifier($p); + } + + return implode('.', $quotedParts); + } + + return '[' . str_replace(']', ']]', $identifier) . ']'; + } + + /** + * Adds an adapter-specific LIMIT clause to the SELECT statement. + * [ original code borrowed from Zend Framework ] + * + * License available at: http://framework.zend.com/license + * + * Copyright (c) 2005-2008, Zend Technologies USA, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of Zend Technologies USA, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @param string $query + * @param mixed $limit + * @param mixed $offset + * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html + * @return string + */ + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) + { + if ($limit > 0) { + $count = intval($limit); + $offset = intval($offset); + + if ($offset < 0) { + throw new Doctrine_Connection_Exception("LIMIT argument offset=$offset is not valid"); + } + + $orderby = stristr($query, 'ORDER BY'); + + if ($orderby !== false) { + // Ticket #1835: Fix for ORDER BY alias + // Ticket #2050: Fix for multiple ORDER BY clause + $order = str_ireplace('ORDER BY', '', $orderby); + $orders = explode(',', $order); + + for ($i = 0; $i < count($orders); $i++) { + $sorts[$i] = (stripos($orders[$i], ' desc') !== false) ? 'desc' : 'asc'; + $orders[$i] = trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i])); + + // find alias in query string + $helper_string = stristr($query, $orders[$i]); + + $from_clause_pos = strpos($helper_string, ' FROM '); + $fields_string = substr($helper_string, 0, $from_clause_pos + 1); + + $field_array = explode(',', $fields_string); + $field_array = array_shift($field_array); + $aux2 = spliti(' as ', $field_array); + + $aliases[$i] = trim(end($aux2)); + } + } + + // Ticket #1259: Fix for limit-subquery in MSSQL + $selectRegExp = 'SELECT\s+'; + $selectReplace = 'SELECT '; + + if (preg_match('/^SELECT(\s+)DISTINCT/i', $query)) { + $selectRegExp .= 'DISTINCT\s+'; + $selectReplace .= 'DISTINCT '; + } + + $query = preg_replace('/^'.$selectRegExp.'/i', $selectReplace . 'TOP ' . ($count + $offset) . ' ', $query); + $query = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $query . ') AS ' . $this->quoteIdentifier('inner_tbl'); + + if ($orderby !== false) { + $query .= ' ORDER BY '; + + for ($i = 0, $l = count($orders); $i < $l; $i++) { + if ($i > 0) { // not first order clause + $query .= ', '; + } + + $query .= $this->quoteIdentifier('inner_tbl') . '.' . $aliases[$i] . ' '; + $query .= (stripos($sorts[$i], 'asc') !== false) ? 'DESC' : 'ASC'; + } + } + + $query .= ') AS ' . $this->quoteIdentifier('outer_tbl'); + + if ($orderby !== false) { + $query .= ' ORDER BY '; + + for ($i = 0, $l = count($orders); $i < $l; $i++) { + if ($i > 0) { // not first order clause + $query .= ', '; + } + + $query .= $this->quoteIdentifier('outer_tbl') . '.' . $aliases[$i] . ' ' . $sorts[$i]; + } + } + } + + return $query; + } + + /** + * return version information about the server + * + * @param bool $native determines if the raw version string should be returned + * @return mixed array/string with version information or MDB2 error object + */ + public function getServerVersion($native = false) + { + if ($this->serverInfo) { + $serverInfo = $this->serverInfo; + } else { + $query = 'SELECT @@VERSION'; + $serverInfo = $this->fetchOne($query); + } + // cache server_info + $this->serverInfo = $serverInfo; + if ( ! $native) { + if (preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $serverInfo, $tmp)) { + $serverInfo = array( + 'major' => $tmp[1], + 'minor' => $tmp[2], + 'patch' => $tmp[3], + 'extra' => null, + 'native' => $serverInfo, + ); + } else { + $serverInfo = array( + 'major' => null, + 'minor' => null, + 'patch' => null, + 'extra' => null, + 'native' => $serverInfo, + ); + } + } + return $serverInfo; + } + + /** + * Checks if there's a sequence that exists. + * + * @param string $seq_name The sequence name to verify. + * @return boolean The value if the table exists or not + */ + public function checkSequence($seqName) + { + $query = 'SELECT * FROM ' . $seqName; + try { + $this->exec($query); + } catch(Doctrine_Connection_Exception $e) { + if ($e->getPortableCode() == Doctrine::ERR_NOSUCHTABLE) { + return false; + } + + throw $e; + } + return true; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mssql/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mssql/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,75 @@ +. + */ + +/** + * Doctrine_Connection_Mssql_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @since 1.0 + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + */ +class Doctrine_Connection_Mssql_Exception extends Doctrine_Connection_Exception +{ + /** + * @var array $errorCodeMap an array that is used for determining portable + * error code from a native database error code + */ + protected static $errorCodeMap = array( + 110 => Doctrine::ERR_VALUE_COUNT_ON_ROW, + 155 => Doctrine::ERR_NOSUCHFIELD, + 170 => Doctrine::ERR_SYNTAX, + 207 => Doctrine::ERR_NOSUCHFIELD, + 208 => Doctrine::ERR_NOSUCHTABLE, + 245 => Doctrine::ERR_INVALID_NUMBER, + 515 => Doctrine::ERR_CONSTRAINT_NOT_NULL, + 547 => Doctrine::ERR_CONSTRAINT, + 1913 => Doctrine::ERR_ALREADY_EXISTS, + 2627 => Doctrine::ERR_CONSTRAINT, + 2714 => Doctrine::ERR_ALREADY_EXISTS, + 3701 => Doctrine::ERR_NOSUCHTABLE, + 8134 => Doctrine::ERR_DIVZERO, + ); + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to $portableCode field + * + * @param array $errorInfo error info array + * @since 1.0 + * @return boolean whether or not the error info processing was successfull + * (the process is successfull if portable error code was found) + */ + public function processErrorInfo(array $errorInfo) + { + $code = $errorInfo[1]; + if (isset(self::$errorCodeMap[$code])) { + $this->portableCode = self::$errorCodeMap[$code]; + return true; + } + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mysql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mysql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,213 @@ +. + */ + +/** + * Doctrine_Connection_Mysql + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Connection_Mysql extends Doctrine_Connection_Common +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Mysql'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO|Doctrine_Adapter $adapter database handler + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + $this->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE, 'INNODB'); + $this->supported = array( + 'sequences' => 'emulated', + 'indexes' => true, + 'affected_rows' => true, + 'transactions' => true, + 'savepoints' => false, + 'summary_functions' => true, + 'order_by_text' => true, + 'current_id' => 'emulated', + 'limit_queries' => true, + 'LOBs' => true, + 'replace' => true, + 'sub_selects' => true, + 'auto_increment' => true, + 'primary_key' => true, + 'result_introspection' => true, + 'prepared_statements' => 'emulated', + 'identifier_quoting' => true, + 'pattern_escaping' => true + ); + + $this->properties['string_quoting'] = array('start' => "'", + 'end' => "'", + 'escape' => '\\', + 'escape_pattern' => '\\'); + + $this->properties['identifier_quoting'] = array('start' => '`', + 'end' => '`', + 'escape' => '`'); + + $this->properties['sql_comments'] = array( + array('start' => '-- ', 'end' => "\n", 'escape' => false), + array('start' => '#', 'end' => "\n", 'escape' => false), + array('start' => '/*', 'end' => '*/', 'escape' => false), + ); + + $this->properties['varchar_max_length'] = 255; + + parent::__construct($manager, $adapter); + } + + /** + * Overrides connect Method, to add specific attributes + * PDO emulate prepares is required to avoid bugs on mysql < 5.1 + * when trying to prepare DROP DATABASE or CREATE DATABASE statements + * + * @see Doctrine_Connection :: connect(); + * @return boolean connected + */ + public function connect() + { + $connected = parent::connect(); + $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + + return $connected; + } + + + /** + * returns the name of the connected database + * + * @return string + */ + public function getDatabaseName() + { + return $this->fetchOne('SELECT DATABASE()'); + } + + /** + * Set the charset on the current connection + * + * @param string charset + */ + public function setCharset($charset) + { + $query = 'SET NAMES ' . $this->quote($charset); + + $this->exec($query); + } + + /** + * Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT + * query, except that if there is already a row in the table with the same + * key field values, the REPLACE query just updates its values instead of + * inserting a new row. + * + * The REPLACE type of query does not make part of the SQL standards. Since + * practically only MySQL implements it natively, this type of query is + * emulated through this method for other DBMS using standard types of + * queries inside a transaction to assure the atomicity of the operation. + * + * @access public + * + * @param string $table name of the table on which the REPLACE query will + * be executed. + * @param array $fields associative array that describes the fields and the + * values that will be inserted or updated in the specified table. The + * indexes of the array are the names of all the fields of the table. The + * values of the array are also associative arrays that describe the + * values and other properties of the table fields. + * + * Here follows a list of field properties that need to be specified: + * + * value: + * Value to be assigned to the specified field. This value may be + * of specified in database independent type format as this + * function can perform the necessary datatype conversions. + * + * Default: + * this property is required unless the Null property + * is set to 1. + * + * type + * Name of the type of the field. Currently, all types Metabase + * are supported except for clob and blob. + * + * Default: no type conversion + * + * null + * Boolean property that indicates that the value for this field + * should be set to null. + * + * The default value for fields missing in INSERT queries may be + * specified the definition of a table. Often, the default value + * is already null, but since the REPLACE may be emulated using + * an UPDATE query, make sure that all fields of the table are + * listed in this function argument array. + * + * Default: 0 + * + * key + * Boolean property that indicates that this field should be + * handled as a primary key or at least as part of the compound + * unique index of the table that will determine the row that will + * updated if it exists or inserted a new row otherwise. + * + * This function will fail if no key field is specified or if the + * value of a key field is set to null because fields that are + * part of unique index they may not be null. + * + * Default: 0 + * + * @return integer the number of affected rows + */ + public function replace(Doctrine_Table $table, array $fields, array $keys) + { + if (empty($keys)) { + throw new Doctrine_Connection_Exception('Not specified which fields are keys'); + } + + $columns = array(); + $values = array(); + $params = array(); + foreach ($fields as $fieldName => $value) { + $columns[] = $table->getColumnName($fieldName); + $values[] = '?'; + $params[] = $value; + } + + $query = 'REPLACE INTO ' . $table->getTableName() . ' (' . implode(',', $columns) . ') VALUES (' . implode(',', $values) . ')'; + + return $this->exec($query, $params); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mysql/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Mysql/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,86 @@ +. + */ + +/** + * Doctrine_Connection_Mysql_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @since 1.0 + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + */ +class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception +{ + /** + * @var array $errorCodeMap an array that is used for determining portable + * error code from a native database error code + */ + protected static $errorCodeMap = array( + 1004 => Doctrine::ERR_CANNOT_CREATE, + 1005 => Doctrine::ERR_CANNOT_CREATE, + 1006 => Doctrine::ERR_CANNOT_CREATE, + 1007 => Doctrine::ERR_ALREADY_EXISTS, + 1008 => Doctrine::ERR_CANNOT_DROP, + 1022 => Doctrine::ERR_ALREADY_EXISTS, + 1044 => Doctrine::ERR_ACCESS_VIOLATION, + 1046 => Doctrine::ERR_NODBSELECTED, + 1048 => Doctrine::ERR_CONSTRAINT, + 1049 => Doctrine::ERR_NOSUCHDB, + 1050 => Doctrine::ERR_ALREADY_EXISTS, + 1051 => Doctrine::ERR_NOSUCHTABLE, + 1054 => Doctrine::ERR_NOSUCHFIELD, + 1061 => Doctrine::ERR_ALREADY_EXISTS, + 1062 => Doctrine::ERR_ALREADY_EXISTS, + 1064 => Doctrine::ERR_SYNTAX, + 1091 => Doctrine::ERR_NOT_FOUND, + 1100 => Doctrine::ERR_NOT_LOCKED, + 1136 => Doctrine::ERR_VALUE_COUNT_ON_ROW, + 1142 => Doctrine::ERR_ACCESS_VIOLATION, + 1146 => Doctrine::ERR_NOSUCHTABLE, + 1216 => Doctrine::ERR_CONSTRAINT, + 1217 => Doctrine::ERR_CONSTRAINT, + 1451 => Doctrine::ERR_CONSTRAINT, + ); + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to $portableCode field + * + * @param array $errorInfo error info array + * @since 1.0 + * @return boolean whether or not the error info processing was successfull + * (the process is successfull if portable error code was found) + */ + public function processErrorInfo(array $errorInfo) + { + $code = $errorInfo[1]; + if (isset(self::$errorCodeMap[$code])) { + $this->portableCode = self::$errorCodeMap[$code]; + return true; + } + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Oracle.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Oracle.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,134 @@ +. + */ + +/** + * Doctrine_Connection_Oracle + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Oracle extends Doctrine_Connection +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Oracle'; + + public function __construct(Doctrine_Manager $manager, $adapter) + { + $this->supported = array( + 'sequences' => true, + 'indexes' => true, + 'summary_functions' => true, + 'order_by_text' => true, + 'current_id' => true, + 'affected_rows' => true, + 'transactions' => true, + 'savepoints' => true, + 'limit_queries' => true, + 'LOBs' => true, + 'replace' => 'emulated', + 'sub_selects' => true, + 'auto_increment' => false, // implementation is broken + 'primary_key' => true, + 'result_introspection' => true, + 'prepared_statements' => true, + 'identifier_quoting' => true, + 'pattern_escaping' => true, + ); + + $this->properties['sql_file_delimiter'] = "\n/\n"; + $this->properties['varchar2_max_length'] = 4000; + $this->properties['number_max_precision'] = 38; + + parent::__construct($manager, $adapter); + } + + /** + * Sets up the date/time format + * + */ + public function setDateFormat($format = 'YYYY-MM-DD HH24:MI:SS') + { + $this->exec('ALTER SESSION SET NLS_DATE_FORMAT = "' . $format . '"'); + } + + /** + * Adds an driver-specific LIMIT clause to the query + * + * @param string $query query to modify + * @param integer $limit limit the number of rows + * @param integer $offset start reading from given offset + * @return string the modified query + */ + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) + { + return $this->_createLimitSubquery($query, $limit, $offset); + } + + private function _createLimitSubquery($query, $limit, $offset, $column = null) + { + $limit = (int) $limit; + $offset = (int) $offset; + if (preg_match('/^\s*SELECT/i', $query)) { + if ( ! preg_match('/\sFROM\s/i', $query)) { + $query .= " FROM dual"; + } + if ($limit > 0) { + $max = $offset + $limit; + $column = $column === null ? '*' : $column; + if ($offset > 0) { + $min = $offset + 1; + $query = 'SELECT b.'.$column.' FROM ('. + 'SELECT a.*, ROWNUM AS doctrine_rownum FROM (' + . $query . ') a '. + ') b '. + 'WHERE doctrine_rownum BETWEEN ' . $min . ' AND ' . $max; + } else { + $query = 'SELECT a.'.$column.' FROM (' . $query .') a WHERE ROWNUM <= ' . $max; + } + } + } + return $query; + } + + /** + * Creates the SQL for Oracle that can be used in the subquery for the limit-subquery + * algorithm. + */ + public function modifyLimitSubquery(Doctrine_Table $rootTable, $query, $limit = false, + $offset = false, $isManip = false) + { + // NOTE: no composite key support + $columnNames = $rootTable->getIdentifierColumnNames(); + if (count($columnNames) > 1) { + throw new Doctrine_Connection_Exception("Composite keys in LIMIT queries are " + . "currently not supported."); + } + $column = $columnNames[0]; + return $this->_createLimitSubquery($query, $limit, $offset, $column); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Oracle/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Oracle/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,80 @@ +. + */ + +/** + * Doctrine_Connection_Oracle_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @since 1.0 + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + */ +class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception +{ + /** + * @var array $errorCodeMap an array that is used for determining portable + * error code from a native database error code + */ + protected static $errorCodeMap = array( + 1 => Doctrine::ERR_CONSTRAINT, + 900 => Doctrine::ERR_SYNTAX, + 904 => Doctrine::ERR_NOSUCHFIELD, + 913 => Doctrine::ERR_VALUE_COUNT_ON_ROW, + 921 => Doctrine::ERR_SYNTAX, + 923 => Doctrine::ERR_SYNTAX, + 942 => Doctrine::ERR_NOSUCHTABLE, + 955 => Doctrine::ERR_ALREADY_EXISTS, + 1400 => Doctrine::ERR_CONSTRAINT_NOT_NULL, + 1401 => Doctrine::ERR_INVALID, + 1407 => Doctrine::ERR_CONSTRAINT_NOT_NULL, + 1418 => Doctrine::ERR_NOT_FOUND, + 1476 => Doctrine::ERR_DIVZERO, + 1722 => Doctrine::ERR_INVALID_NUMBER, + 2289 => Doctrine::ERR_NOSUCHTABLE, + 2291 => Doctrine::ERR_CONSTRAINT, + 2292 => Doctrine::ERR_CONSTRAINT, + 2449 => Doctrine::ERR_CONSTRAINT, + ); + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to $portableCode field + * + * @param array $errorInfo error info array + * @since 1.0 + * @return boolean whether or not the error info processing was successfull + * (the process is successfull if portable error code was found) + */ + public function processErrorInfo(array $errorInfo) + { + $code = $errorInfo[1]; + if (isset(self::$errorCodeMap[$code])) { + $this->portableCode = self::$errorCodeMap[$code]; + return true; + } + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Pgsql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Pgsql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,195 @@ +. + */ + +/** + * Doctrine_Connection_Pgsql + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Pgsql'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO $pdo database handle + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + // initialize all driver options + $this->supported = array( + 'sequences' => true, + 'indexes' => true, + 'affected_rows' => true, + 'summary_functions' => true, + 'order_by_text' => true, + 'transactions' => true, + 'savepoints' => true, + 'current_id' => true, + 'limit_queries' => true, + 'LOBs' => true, + 'replace' => 'emulated', + 'sub_selects' => true, + 'auto_increment' => 'emulated', + 'primary_key' => true, + 'result_introspection' => true, + 'prepared_statements' => true, + 'identifier_quoting' => true, + 'pattern_escaping' => true, + ); + + $this->properties['string_quoting'] = array('start' => "'", + 'end' => "'", + 'escape' => "'", + 'escape_pattern' => '\\'); + + $this->properties['identifier_quoting'] = array('start' => '"', + 'end' => '"', + 'escape' => '"'); + parent::__construct($manager, $adapter); + } + + /** + * Set the charset on the current connection + * + * @param string charset + * + * @return void + */ + public function setCharset($charset) + { + $query = 'SET NAMES '.$this->quote($charset); + $this->exec($query); + } + + /** + * convertBoolean + * some drivers need the boolean values to be converted into integers + * when using DQL API + * + * This method takes care of that conversion + * + * @param array $item + * @return void + */ + public function convertBooleans($item) + { + if (is_array($item)) { + foreach ($item as $key => $value) { + if (is_bool($value)) { + $item[$key] = ($value) ? 'true' : 'false'; + } + } + } else { + if (is_bool($item) || is_numeric($item)) { + $item = ($item) ? 'true' : 'false'; + } + } + return $item; + } + + /** + * Changes a query string for various DBMS specific reasons + * + * @param string $query query to modify + * @param integer $limit limit the number of rows + * @param integer $offset start reading from given offset + * @param boolean $isManip if the query is a DML query + * @return string modified query + */ + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) + { + if ($limit > 0) { + $query = rtrim($query); + + if (substr($query, -1) == ';') { + $query = substr($query, 0, -1); + } + + if ($isManip) { + $manip = preg_replace('/^(DELETE FROM|UPDATE).*$/', '\\1', $query); + $from = $match[2]; + $where = $match[3]; + $query = $manip . ' ' . $from . ' WHERE ctid=(SELECT ctid FROM ' + . $from . ' ' . $where . ' LIMIT ' . $limit . ')'; + + } else { + if ( ! empty($limit)) { + $query .= ' LIMIT ' . $limit; + } + if ( ! empty($offset)) { + $query .= ' OFFSET ' . $offset; + } + } + } + return $query; + } + + /** + * return version information about the server + * + * @param string $native determines if the raw version string should be returned + * @return array|string an array or string with version information + */ + public function getServerVersion($native = false) + { + $query = 'SHOW SERVER_VERSION'; + + $serverInfo = $this->fetchOne($query); + + if ( ! $native) { + $tmp = explode('.', $serverInfo, 3); + + if (empty($tmp[2]) && isset($tmp[1]) + && preg_match('/(\d+)(.*)/', $tmp[1], $tmp2) + ) { + $serverInfo = array( + 'major' => $tmp[0], + 'minor' => $tmp2[1], + 'patch' => null, + 'extra' => $tmp2[2], + 'native' => $serverInfo, + ); + } else { + $serverInfo = array( + 'major' => isset($tmp[0]) ? $tmp[0] : null, + 'minor' => isset($tmp[1]) ? $tmp[1] : null, + 'patch' => isset($tmp[2]) ? $tmp[2] : null, + 'extra' => null, + 'native' => $serverInfo, + ); + } + } + return $serverInfo; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Pgsql/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Pgsql/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,108 @@ +. + */ + +/** + * Doctrine_Connection_Pgsql_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @author Konsta Vesterinen + * @author Paul Cooper (PEAR MDB2 Pgsql driver) + * @author Lukas Smith (PEAR MDB2 library) + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Connection_Pgsql_Exception extends Doctrine_Connection_Exception +{ + /** + * @var array $errorRegexps an array that is used for determining portable + * error code from a native database error message + */ + protected static $errorRegexps = array( + '/parser: parse error at or near/i' + => Doctrine::ERR_SYNTAX, + '/syntax error at/' + => Doctrine::ERR_SYNTAX, + '/column reference .* is ambiguous/i' + => Doctrine::ERR_SYNTAX, + '/column .* (of relation .*)?does not exist/i' + => Doctrine::ERR_NOSUCHFIELD, + '/attribute .* not found|relation .* does not have attribute/i' + => Doctrine::ERR_NOSUCHFIELD, + '/column .* specified in USING clause does not exist in (left|right) table/i' + => Doctrine::ERR_NOSUCHFIELD, + '/(relation|sequence|table).*does not exist|class .* not found/i' + => Doctrine::ERR_NOSUCHTABLE, + '/index .* does not exist/' + => Doctrine::ERR_NOT_FOUND, + '/relation .* already exists/i' + => Doctrine::ERR_ALREADY_EXISTS, + '/(divide|division) by zero$/i' + => Doctrine::ERR_DIVZERO, + '/pg_atoi: error in .*: can\'t parse /i' + => Doctrine::ERR_INVALID_NUMBER, + '/invalid input syntax for( type)? (integer|numeric)/i' + => Doctrine::ERR_INVALID_NUMBER, + '/value .* is out of range for type \w*int/i' + => Doctrine::ERR_INVALID_NUMBER, + '/integer out of range/i' + => Doctrine::ERR_INVALID_NUMBER, + '/value too long for type character/i' + => Doctrine::ERR_INVALID, + '/permission denied/' + => Doctrine::ERR_ACCESS_VIOLATION, + '/violates [\w ]+ constraint/' + => Doctrine::ERR_CONSTRAINT, + '/referential integrity violation/' + => Doctrine::ERR_CONSTRAINT, + '/violates not-null constraint/' + => Doctrine::ERR_CONSTRAINT_NOT_NULL, + '/more expressions than target columns/i' + => Doctrine::ERR_VALUE_COUNT_ON_ROW, + ); + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to $portableCode field + * + * the portable error code is added at the end of array + * + * @param array $errorInfo error info array + * @since 1.0 + * @see Doctrine::ERR_* constants + * @see Doctrine_Connection::$portableCode + * @return boolean whether or not the error info processing was successfull + * (the process is successfull if portable error code was found) + */ + public function processErrorInfo(array $errorInfo) + { + foreach (self::$errorRegexps as $regexp => $code) { + if (preg_match($regexp, $errorInfo[2])) { + $this->portableCode = $code; + return true; + } + } + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Profiler.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Profiler.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,182 @@ +. + */ + +/** + * Doctrine_Connection_Profiler + * + * @package Doctrine + * @subpackage Connection + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAggregate, Countable +{ + /** + * @param array $listeners an array containing all availible listeners + */ + private $listeners = array('query', + 'prepare', + 'commit', + 'rollback', + 'connect', + 'begintransaction', + 'exec', + 'execute'); + + /** + * @param array $events an array containing all listened events + */ + private $events = array(); + + /** + * constructor + */ + public function __construct() { + + } + + /** + * setFilterQueryType + * + * @param integer $filter + * @return boolean + */ + public function setFilterQueryType() { + + } + /** + * method overloader + * this method is used for invoking different listeners, for the full + * list of availible listeners, see Doctrine_EventListener + * + * @param string $m the name of the method + * @param array $a method arguments + * @see Doctrine_EventListener + * @return boolean + */ + public function __call($m, $a) + { + // first argument should be an instance of Doctrine_Event + if ( ! ($a[0] instanceof Doctrine_Event)) { + throw new Doctrine_Connection_Profiler_Exception("Couldn't listen event. Event should be an instance of Doctrine_Event."); + } + + + if (substr($m, 0, 3) === 'pre') { + // pre-event listener found + $a[0]->start(); + + if ( ! in_array($a[0], $this->events, true)) { + $this->events[] = $a[0]; + } + } else { + // after-event listener found + $a[0]->end(); + } + /** + * If filtering by query type is enabled, only keep the query if + * it was one of the allowed types. + */ + /** + if ( ! is_null($this->filterTypes)) { + if ( ! ($a[0]->getQueryType() & $this->_filterTypes)) { + + } + } + */ + + } + + /** + * get + * + * @param mixed $key + * @return Doctrine_Event + */ + public function get($key) + { + if (isset($this->events[$key])) { + return $this->events[$key]; + } + return null; + } + + /** + * getAll + * returns all profiled events as an array + * + * @return array all events in an array + */ + public function getAll() + { + return $this->events; + } + + /** + * getIterator + * returns an iterator that iterates through the logged events + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->events); + } + + /** + * count + * + * @return integer + */ + public function count() + { + return count($this->events); + } + + /** + * pop the last event from the event stack + * + * @return Doctrine_Event + */ + public function pop() + { + return array_pop($this->events); + } + + /** + * Get the Doctrine_Event object for the last query that was run, regardless if it has + * ended or not. If the event has not ended, it's end time will be Null. + * + * @return Doctrine_Event + */ + public function lastEvent() + { + if (empty($this->events)) { + return false; + } + + end($this->events); + return current($this->events); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Profiler/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Profiler/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,35 @@ +. + */ + +/** + * Doctrine_Connection_Profiler_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 1345 $ + * @author Konsta Vesterinen + */ +class Doctrine_Connection_Profiler_Exception extends Doctrine_Exception +{ +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Sqlite.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Sqlite.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,141 @@ +. + */ + +/** + * Doctrine_Connection_Sqlite + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common +{ + /** + * @var string $driverName the name of this connection driver + */ + protected $driverName = 'Sqlite'; + + /** + * the constructor + * + * @param Doctrine_Manager $manager + * @param PDO $pdo database handle + */ + public function __construct(Doctrine_Manager $manager, $adapter) + { + $this->supported = array('sequences' => 'emulated', + 'indexes' => true, + 'affected_rows' => true, + 'summary_functions' => true, + 'order_by_text' => true, + 'current_id' => 'emulated', + 'limit_queries' => true, + 'LOBs' => true, + 'replace' => true, + 'transactions' => true, + 'savepoints' => false, + 'sub_selects' => true, + 'auto_increment' => true, + 'primary_key' => true, + 'result_introspection' => false, // not implemented + 'prepared_statements' => 'emulated', + 'identifier_quoting' => true, + 'pattern_escaping' => false, + ); + parent::__construct($manager, $adapter); + + if ($this->isConnected) { + $this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2); + $this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl')); + $this->dbh->sqliteCreateFunction('md5', 'md5', 1); + $this->dbh->sqliteCreateFunction('now', 'time', 0); + } + } + + /** + * initializes database functions missing in sqlite + * + * @see Doctrine_Expression + * @return void + */ + public function connect() + { + if ($this->isConnected) { + return false; + } + + parent::connect(); + + $this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2); + $this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl')); + $this->dbh->sqliteCreateFunction('md5', 'md5', 1); + $this->dbh->sqliteCreateFunction('now', 'time', 0); + } + + /** + * createDatabase + * + * @return void + */ + public function createDatabase() + { + try { + if ( ! $dsn = $this->getOption('dsn')) { + throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); + } + + $info = $this->getManager()->parseDsn($dsn); + + $this->export->createDatabase($info['database']); + + return 'Successfully created database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; + } catch (Exception $e) { + return $e; + } + } + + /** + * dropDatabase + * + * @return void + */ + public function dropDatabase() + { + try { + if ( ! $dsn = $this->getOption('dsn')) { + throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); + } + + $info = $this->getManager()->parseDsn($dsn); + + $this->export->dropDatabase($info['database']); + + return 'Successfully dropped database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; + } catch (Exception $e) { + return $e; + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Sqlite/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Sqlite/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,78 @@ +. + */ + +/** + * Doctrine_Connection_Sqlite_Exception + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @since 1.0 + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + */ +class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception +{ + /** + * @var array $errorRegexps an array that is used for determining portable + * error code from a native database error message + */ + protected static $errorRegexps = array( + '/^no such table:/' => Doctrine::ERR_NOSUCHTABLE, + '/^no such index:/' => Doctrine::ERR_NOT_FOUND, + '/^(table|index) .* already exists$/' => Doctrine::ERR_ALREADY_EXISTS, + '/PRIMARY KEY must be unique/i' => Doctrine::ERR_CONSTRAINT, + '/is not unique/' => Doctrine::ERR_CONSTRAINT, + '/columns .* are not unique/i' => Doctrine::ERR_CONSTRAINT, + '/uniqueness constraint failed/' => Doctrine::ERR_CONSTRAINT, + '/may not be NULL/' => Doctrine::ERR_CONSTRAINT_NOT_NULL, + '/^no such column:/' => Doctrine::ERR_NOSUCHFIELD, + '/column not present in both tables/i' => Doctrine::ERR_NOSUCHFIELD, + '/^near ".*": syntax error$/' => Doctrine::ERR_SYNTAX, + '/[0-9]+ values for [0-9]+ columns/i' => Doctrine::ERR_VALUE_COUNT_ON_ROW, + ); + + /** + * This method checks if native error code/message can be + * converted into a portable code and then adds this + * portable error code to $portableCode field + * + * @param array $errorInfo error info array + * @since 1.0 + * @see Doctrine::ERR_* constants + * @see Doctrine_Connection::$portableCode + * @return boolean whether or not the error info processing was successfull + * (the process is successfull if portable error code was found) + */ + public function processErrorInfo(array $errorInfo) + { + foreach (self::$errorRegexps as $regexp => $code) { + if (preg_match($regexp, $errorInfo[2])) { + + $this->portableCode = $code; + return true; + } + } + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Statement.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Statement.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,468 @@ +. + */ + +/** + * Doctrine_Connection_Statement + * + * @package Doctrine + * @subpackage Connection + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 1532 $ + */ +class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interface +{ + /** + * @var Doctrine_Connection $conn Doctrine_Connection object, every connection + * statement holds an instance of Doctrine_Connection + */ + protected $_conn; + + /** + * @var mixed $_stmt PDOStatement object, boolean false or Doctrine_Adapter_Statement object + */ + protected $_stmt; + + /** + * constructor + * + * @param Doctrine_Connection $conn Doctrine_Connection object, every connection + * statement holds an instance of Doctrine_Connection + * @param mixed $stmt + */ + public function __construct(Doctrine_Connection $conn, $stmt) + { + $this->_conn = $conn; + $this->_stmt = $stmt; + + if ($stmt === false) { + throw new Doctrine_Exception('Unknown statement object given.'); + } + } + + /** + * getConnection + * returns the connection object this statement uses + * + * @return Doctrine_Connection + */ + public function getConnection() + { + return $this->_conn; + } + public function getStatement() + { + return $this->_stmt; + } + public function getQuery() + { + return $this->_stmt->queryString; + } + + /** + * bindColumn + * Bind a column to a PHP variable + * + * @param mixed $column Number of the column (1-indexed) or name of the column in the result set. + * If using the column name, be aware that the name should match + * the case of the column, as returned by the driver. + * + * @param string $param Name of the PHP variable to which the column will be bound. + * @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants. + * @return boolean Returns TRUE on success or FALSE on failure + */ + public function bindColumn($column, $param, $type = null) + { + if ($type === null) { + return $this->_stmt->bindColumn($column, $param); + } else { + return $this->_stmt->bindColumn($column, $param, $type); + } + } + + /** + * bindValue + * Binds a value to a corresponding named or question mark + * placeholder in the SQL statement that was use to prepare the statement. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindValue($param, $value, $type = null) + { + if ($type === null) { + return $this->_stmt->bindValue($param, $value); + } else { + return $this->_stmt->bindValue($param, $value, $type); + } + } + + /** + * bindParam + * Binds a PHP variable to a corresponding named or question mark placeholder in the + * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(), + * the variable is bound as a reference and will only be evaluated at the time + * that Doctrine_Adapter_Statement_Interface->execute() is called. + * + * Most parameters are input parameters, that is, parameters that are + * used in a read-only fashion to build up the query. Some drivers support the invocation + * of stored procedures that return data as output parameters, and some also as input/output + * parameters that both send in data and are updated to receive it. + * + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter + * + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * + * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return + * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the + * Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter. + * + * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter + * from a stored procedure, you must explicitly set the length. + * @param mixed $driverOptions + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) + { + if ($type === null) { + return $this->_stmt->bindParam($column, $variable); + } else { + return $this->_stmt->bindParam($column, $variable, $type, $length, $driverOptions); + } + } + + /** + * closeCursor + * Closes the cursor, enabling the statement to be executed again. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function closeCursor() + { + return $this->_stmt->closeCursor(); + } + + /** + * columnCount + * Returns the number of columns in the result set + * + * @return integer Returns the number of columns in the result set represented + * by the Doctrine_Adapter_Statement_Interface object. If there is no result set, + * this method should return 0. + */ + public function columnCount() + { + return $this->_stmt->columnCount(); + } + + /** + * errorCode + * Fetch the SQLSTATE associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorCode() + * @return string error code string + */ + public function errorCode() + { + return $this->_stmt->errorCode(); + } + + /** + * errorInfo + * Fetch extended error information associated with the last operation on the statement handle + * + * @see Doctrine_Adapter_Interface::errorInfo() + * @return array error info array + */ + public function errorInfo() + { + return $this->_stmt->errorInfo(); + } + + /** + * execute + * Executes a prepared statement + * + * If the prepared statement included parameter markers, you must either: + * call PDOStatement->bindParam() to bind PHP variables to the parameter markers: + * bound variables pass their value as input and receive the output value, + * if any, of their associated parameter markers or pass an array of input-only + * parameter values + * + * + * @param array $params An array of values with as many elements as there are + * bound parameters in the SQL statement being executed. + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function execute($params = null) + { + try { + $event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params); + $this->_conn->getListener()->preStmtExecute($event); + + $result = true; + if ( ! $event->skipOperation) { + + if ($this->_conn->getAttribute(Doctrine::PORTABILITY_EMPTY_TO_NULL)) { + foreach ($params as $key => $value) { + if ($value == '') { + $params[$key] = null; + } + } + } + + $result = $this->_stmt->execute($params); + $this->_conn->incrementQueryCount(); + } + + $this->_conn->getListener()->postStmtExecute($event); + + return $result; + } catch (PDOException $e) { + } catch (Doctrine_Adapter_Exception $e) { + } + + $this->_conn->rethrowException($e, $this); + + return false; + } + + /** + * fetch + * + * @see Doctrine::FETCH_* constants + * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor, + * this value determines which row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to + * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your + * Doctrine_Adapter_Statement_Interface object, + * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you + * prepare the SQL statement with Doctrine_Adapter_Interface->prepare(). + * + * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the + * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies + * the absolute number of the row in the result set that shall be fetched. + * + * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for + * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value + * specifies the row to fetch relative to the cursor position before + * Doctrine_Adapter_Statement_Interface->fetch() was called. + * + * @return mixed + */ + public function fetch($fetchMode = Doctrine::FETCH_BOTH, + $cursorOrientation = Doctrine::FETCH_ORI_NEXT, + $cursorOffset = null) + { + $event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, $this->getQuery()); + + $event->fetchMode = $fetchMode; + $event->cursorOrientation = $cursorOrientation; + $event->cursorOffset = $cursorOffset; + + $data = $this->_conn->getListener()->preFetch($event); + + if ( ! $event->skipOperation) { + $data = $this->_stmt->fetch($fetchMode, $cursorOrientation, $cursorOffset); + } + + $this->_conn->getListener()->postFetch($event); + + return $data; + } + + /** + * fetchAll + * Returns an array containing all of the result set rows + * + * @param integer $fetchMode Controls how the next row will be returned to the caller. + * This value must be one of the Doctrine::FETCH_* constants, + * defaulting to Doctrine::FETCH_BOTH + * + * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is + * Doctrine::FETCH_COLUMN. Defaults to 0. + * + * @return array + */ + public function fetchAll($fetchMode = Doctrine::FETCH_BOTH, + $columnIndex = null) + { + $event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCHALL, $this->getQuery()); + $event->fetchMode = $fetchMode; + $event->columnIndex = $columnIndex; + + $this->_conn->getListener()->preFetchAll($event); + + if ( ! $event->skipOperation) { + if ($columnIndex !== null) { + $data = $this->_stmt->fetchAll($fetchMode, $columnIndex); + } else { + $data = $this->_stmt->fetchAll($fetchMode); + } + + $event->data = $data; + } + + $this->_conn->getListener()->postFetchAll($event); + + return $data; + } + + /** + * fetchColumn + * Returns a single column from the next row of a + * result set or FALSE if there are no more rows. + * + * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no + * value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn() + * fetches the first column. + * + * @return string returns a single column in the next row of a result set. + */ + public function fetchColumn($columnIndex = 0) + { + return $this->_stmt->fetchColumn($columnIndex); + } + + /** + * fetchObject + * Fetches the next row and returns it as an object. + * + * Fetches the next row and returns it as an object. This function is an alternative to + * Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style. + * + * @param string $className Name of the created class, defaults to stdClass. + * @param array $args Elements of this array are passed to the constructor. + * + * @return mixed an instance of the required class with property names that correspond + * to the column names or FALSE in case of an error. + */ + public function fetchObject($className = 'stdClass', $args = array()) + { + return $this->_stmt->fetchObject($className, $args); + } + + /** + * getAttribute + * Retrieve a statement attribute + * + * @param integer $attribute + * @see Doctrine::ATTR_* constants + * @return mixed the attribute value + */ + public function getAttribute($attribute) + { + return $this->_stmt->getAttribute($attribute); + } + + /** + * getColumnMeta + * Returns metadata for a column in a result set + * + * @param integer $column The 0-indexed column in the result set. + * + * @return array Associative meta data array with the following structure: + * + * native_type The PHP native type used to represent the column value. + * driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta(). + * flags Any flags set for this column. + * name The name of this column as returned by the database. + * len The length of this column. Normally -1 for types other than floating point decimals. + * precision The numeric precision of this column. Normally 0 for types other than floating point decimals. + * pdo_type The type of this column as represented by the PDO::PARAM_* constants. + */ + public function getColumnMeta($column) + { + return $this->_stmt->getColumnMeta($column); + } + + /** + * nextRowset + * Advances to the next rowset in a multi-rowset statement handle + * + * Some database servers support stored procedures that return more than one rowset + * (also known as a result set). The nextRowset() method enables you to access the second + * and subsequent rowsets associated with a PDOStatement object. Each rowset can have a + * different set of columns from the preceding rowset. + * + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function nextRowset() + { + return $this->_stmt->nextRowset(); + } + + /** + * rowCount + * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement + * executed by the corresponding object. + * + * If the last SQL statement executed by the associated Statement object was a SELECT statement, + * some databases may return the number of rows returned by that statement. However, + * this behaviour is not guaranteed for all databases and should not be + * relied on for portable applications. + * + * @return integer Returns the number of rows. + */ + public function rowCount() + { + return $this->_stmt->rowCount(); + } + + /** + * setAttribute + * Set a statement attribute + * + * @param integer $attribute + * @param mixed $value the value of given attribute + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function setAttribute($attribute, $value) + { + return $this->_stmt->setAttribute($attribute, $value); + } + + /** + * setFetchMode + * Set the default fetch mode for this statement + * + * @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants. + * @return boolean Returns 1 on success or FALSE on failure. + */ + public function setFetchMode($mode, $arg1 = null, $arg2 = null) + { + return $this->_stmt->setFetchMode($mode, $arg1, $arg2); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,894 @@ +. + */ + +/** + * Doctrine_Connection_UnitOfWork + * + * Note: This class does not have the semantics of a real "Unit of Work" in 0.10/1.0. + * Database operations are not queued. All changes to objects are immediately written + * to the database. You can think of it as a unit of work in auto-flush mode. + * + * Referential integrity is currently not always ensured. + * + * @package Doctrine + * @subpackage Connection + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + * @author Roman Borschel + */ +class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module +{ + /** + * Saves the given record and all associated records. + * (The save() operation is always cascaded in 0.10/1.0). + * + * @param Doctrine_Record $record + * @return void + */ + public function saveGraph(Doctrine_Record $record) + { + $record->assignInheritanceValues(); + + $conn = $this->getConnection(); + + $state = $record->state(); + if ($state === Doctrine_Record::STATE_LOCKED || $state === Doctrine_Record::STATE_TLOCKED) { + return false; + } + + $record->state($record->exists() ? Doctrine_Record::STATE_LOCKED : Doctrine_Record::STATE_TLOCKED); + + try { + $conn->beginInternalTransaction(); + $this->saveRelatedLocalKeys($record); + + $record->state($state); + + $event = new Doctrine_Event($record, Doctrine_Event::RECORD_SAVE); + $record->preSave($event); + $record->getTable()->getRecordListener()->preSave($event); + $state = $record->state(); + + $isValid = true; + + if ( ! $event->skipOperation) { + switch ($state) { + case Doctrine_Record::STATE_TDIRTY: + case Doctrine_Record::STATE_TCLEAN: + $isValid = $this->insert($record); + break; + case Doctrine_Record::STATE_DIRTY: + case Doctrine_Record::STATE_PROXY: + $isValid = $this->update($record); + break; + case Doctrine_Record::STATE_CLEAN: + // do nothing + break; + } + } + + if ($isValid) { + // NOTE: what about referential integrity issues? + foreach ($record->getPendingDeletes() as $pendingDelete) { + $pendingDelete->delete(); + } + + $record->postSave($event); + $record->getTable()->getRecordListener()->postSave($event); + } else { + $conn->transaction->addInvalid($record); + } + + $state = $record->state(); + + $record->state($record->exists() ? Doctrine_Record::STATE_LOCKED : Doctrine_Record::STATE_TLOCKED); + + $saveLater = $this->saveRelatedForeignKeys($record); + foreach ($saveLater as $fk) { + $alias = $fk->getAlias(); + + if ($record->hasReference($alias)) { + $obj = $record->$alias; + + // check that the related object is not an instance of Doctrine_Null + if ($obj && ! ($obj instanceof Doctrine_Null)) { + $obj->save($conn); + } + } + } + + // save the MANY-TO-MANY associations + $this->saveAssociations($record); + + $record->state($state); + + $conn->commit(); + } catch (Exception $e) { + // Make sure we roll back our internal transaction + //$record->state($state); + $conn->rollback(); + throw $e; + } + + return true; + } + + /** + * saves the given record + * + * @param Doctrine_Record $record + * @return void + */ + public function save(Doctrine_Record $record) + { + $event = new Doctrine_Event($record, Doctrine_Event::RECORD_SAVE); + + $record->preSave($event); + + $record->getTable()->getRecordListener()->preSave($event); + + if ( ! $event->skipOperation) { + switch ($record->state()) { + case Doctrine_Record::STATE_TDIRTY: + case Doctrine_Record::STATE_TCLEAN: + $this->insert($record); + break; + case Doctrine_Record::STATE_DIRTY: + case Doctrine_Record::STATE_PROXY: + $this->update($record); + break; + case Doctrine_Record::STATE_CLEAN: + // do nothing + break; + } + } + + $record->getTable()->getRecordListener()->postSave($event); + + $record->postSave($event); + } + + /** + * Deletes the given record and all the related records that participate + * in an application-level delete cascade. + * + * this event can be listened by the onPreDelete and onDelete listeners + * + * @return boolean true on success, false on failure + */ + public function delete(Doctrine_Record $record) + { + $deletions = array(); + $this->_collectDeletions($record, $deletions); + return $this->_executeDeletions($deletions); + } + + /** + * Collects all records that need to be deleted by applying defined + * application-level delete cascades. + * + * @param array $deletions Map of the records to delete. Keys=Oids Values=Records. + */ + private function _collectDeletions(Doctrine_Record $record, array &$deletions) + { + if ( ! $record->exists()) { + return; + } + + $deletions[$record->getOid()] = $record; + $this->_cascadeDelete($record, $deletions); + } + + /** + * Executes the deletions for all collected records during a delete operation + * (usually triggered through $record->delete()). + * + * @param array $deletions Map of the records to delete. Keys=Oids Values=Records. + */ + private function _executeDeletions(array $deletions) + { + // collect class names + $classNames = array(); + foreach ($deletions as $record) { + $classNames[] = $record->getTable()->getComponentName(); + } + $classNames = array_unique($classNames); + + // order deletes + $executionOrder = $this->buildFlushTree($classNames); + + // execute + try { + $this->conn->beginInternalTransaction(); + + for ($i = count($executionOrder) - 1; $i >= 0; $i--) { + $className = $executionOrder[$i]; + $table = $this->conn->getTable($className); + + // collect identifiers + $identifierMaps = array(); + $deletedRecords = array(); + foreach ($deletions as $oid => $record) { + if ($record->getTable()->getComponentName() == $className) { + $veto = $this->_preDelete($record); + if ( ! $veto) { + $identifierMaps[] = $record->identifier(); + $deletedRecords[] = $record; + unset($deletions[$oid]); + } + } + } + + if (count($deletedRecords) < 1) { + continue; + } + + // extract query parameters (only the identifier values are of interest) + $params = array(); + $columnNames = array(); + foreach ($identifierMaps as $idMap) { + while (list($fieldName, $value) = each($idMap)) { + $params[] = $value; + $columnNames[] = $table->getColumnName($fieldName); + } + } + $columnNames = array_unique($columnNames); + + // delete + $tableName = $table->getTableName(); + $sql = "DELETE FROM " . $this->conn->quoteIdentifier($tableName) . " WHERE "; + + if ($table->isIdentifierComposite()) { + $sql .= $this->_buildSqlCompositeKeyCondition($columnNames, count($identifierMaps)); + $this->conn->exec($sql, $params); + } else { + $sql .= $this->_buildSqlSingleKeyCondition($columnNames, count($params)); + $this->conn->exec($sql, $params); + } + + // adjust state, remove from identity map and inform postDelete listeners + foreach ($deletedRecords as $record) { + // currently just for bc! + $this->_deleteCTIParents($table, $record); + //-- + $record->state(Doctrine_Record::STATE_TCLEAN); + $record->getTable()->removeRecord($record); + $this->_postDelete($record); + } + } + + // trigger postDelete for records skipped during the deletion (veto!) + foreach ($deletions as $skippedRecord) { + $this->_postDelete($skippedRecord); + } + + $this->conn->commit(); + + return true; + } catch (Exception $e) { + $this->conn->rollback(); + throw $e; + } + } + + /** + * Builds the SQL condition to target multiple records who have a single-column + * primary key. + * + * @param Doctrine_Table $table The table from which the records are going to be deleted. + * @param integer $numRecords The number of records that are going to be deleted. + * @return string The SQL condition "pk = ? OR pk = ? OR pk = ? ..." + */ + private function _buildSqlSingleKeyCondition($columnNames, $numRecords) + { + $idColumn = $this->conn->quoteIdentifier($columnNames[0]); + return implode(' OR ', array_fill(0, $numRecords, "$idColumn = ?")); + } + + /** + * Builds the SQL condition to target multiple records who have a composite primary key. + * + * @param Doctrine_Table $table The table from which the records are going to be deleted. + * @param integer $numRecords The number of records that are going to be deleted. + * @return string The SQL condition "(pk1 = ? AND pk2 = ?) OR (pk1 = ? AND pk2 = ?) ..." + */ + private function _buildSqlCompositeKeyCondition($columnNames, $numRecords) + { + $singleCondition = ""; + foreach ($columnNames as $columnName) { + $columnName = $this->conn->quoteIdentifier($columnName); + if ($singleCondition === "") { + $singleCondition .= "($columnName = ?"; + } else { + $singleCondition .= " AND $columnName = ?"; + } + } + $singleCondition .= ")"; + $fullCondition = implode(' OR ', array_fill(0, $numRecords, $singleCondition)); + + return $fullCondition; + } + + /** + * Cascades an ongoing delete operation to related objects. Applies only on relations + * that have 'delete' in their cascade options. + * This is an application-level cascade. Related objects that participate in the + * cascade and are not yet loaded are fetched from the database. + * Exception: many-valued relations are always (re-)fetched from the database to + * make sure we have all of them. + * + * @param Doctrine_Record The record for which the delete operation will be cascaded. + * @throws PDOException If something went wrong at database level + * @return void + */ + protected function _cascadeDelete(Doctrine_Record $record, array &$deletions) + { + foreach ($record->getTable()->getRelations() as $relation) { + if ($relation->isCascadeDelete()) { + $fieldName = $relation->getAlias(); + // if it's a xToOne relation and the related object is already loaded + // we don't need to refresh. + if ( ! ($relation->getType() == Doctrine_Relation::ONE && isset($record->$fieldName))) { + $record->refreshRelated($relation->getAlias()); + } + $relatedObjects = $record->get($relation->getAlias()); + if ($relatedObjects instanceof Doctrine_Record && $relatedObjects->exists() + && ! isset($deletions[$relatedObjects->getOid()])) { + $this->_collectDeletions($relatedObjects, $deletions); + } else if ($relatedObjects instanceof Doctrine_Collection && count($relatedObjects) > 0) { + // cascade the delete to the other objects + foreach ($relatedObjects as $object) { + if ( ! isset($deletions[$object->getOid()])) { + $this->_collectDeletions($object, $deletions); + } + } + } + } + } + } + + /** + * saveRelatedForeignKeys + * saves all related (through ForeignKey) records to $record + * + * @throws PDOException if something went wrong at database level + * @param Doctrine_Record $record + */ + public function saveRelatedForeignKeys(Doctrine_Record $record) + { + $saveLater = array(); + foreach ($record->getReferences() as $k => $v) { + $rel = $record->getTable()->getRelation($k); + if ($rel instanceof Doctrine_Relation_ForeignKey) { + $saveLater[$k] = $rel; + } + } + + return $saveLater; + } + + /** + * saveRelatedLocalKeys + * saves all related (through LocalKey) records to $record + * + * @throws PDOException if something went wrong at database level + * @param Doctrine_Record $record + */ + public function saveRelatedLocalKeys(Doctrine_Record $record) + { + foreach ($record->getReferences() as $k => $v) { + $rel = $record->getTable()->getRelation($k); + + $local = $rel->getLocal(); + $foreign = $rel->getForeign(); + + if ($rel instanceof Doctrine_Relation_LocalKey) { + // ONE-TO-ONE relationship + $obj = $record->get($rel->getAlias()); + + // Protection against infinite function recursion before attempting to save + if ($obj instanceof Doctrine_Record && $obj->isModified()) { + $obj->save($this->conn); + + $id = array_values($obj->identifier()); + + if ( ! empty($id)) { + foreach ((array) $rel->getLocal() as $k => $field) { + if (isset($id[$k]) && $id[$k] && $record->getTable()->hasField($field)) { + $record->set($field, $id[$k]); + } + } + } + } + } + } + } + + /** + * saveAssociations + * + * this method takes a diff of one-to-many / many-to-many original and + * current collections and applies the changes + * + * for example if original many-to-many related collection has records with + * primary keys 1,2 and 3 and the new collection has records with primary keys + * 3, 4 and 5, this method would first destroy the associations to 1 and 2 and then + * save new associations to 4 and 5 + * + * @throws Doctrine_Connection_Exception if something went wrong at database level + * @param Doctrine_Record $record + * @return void + */ + public function saveAssociations(Doctrine_Record $record) + { + foreach ($record->getReferences() as $k => $v) { + $rel = $record->getTable()->getRelation($k); + + if ($rel instanceof Doctrine_Relation_Association) { + $v->save($this->conn, false); + + $assocTable = $rel->getAssociationTable(); + foreach ($v->getDeleteDiff() as $r) { + $query = 'DELETE FROM ' . $assocTable->getTableName() + . ' WHERE ' . $rel->getForeign() . ' = ?' + . ' AND ' . $rel->getLocal() . ' = ?'; + + $this->conn->execute($query, array($r->getIncremented(), $record->getIncremented())); + } + + foreach ($v->getInsertDiff() as $r) { + $assocRecord = $assocTable->create(); + $assocRecord->set($assocTable->getFieldName($rel->getForeign()), $r); + $assocRecord->set($assocTable->getFieldName($rel->getLocal()), $record); + $this->saveGraph($assocRecord); + } + // take snapshot of collection state, so that we know when its modified again + $v->takeSnapshot(); + } + } + } + + /** + * Invokes preDelete event listeners. + * + * @return boolean Whether a listener has used it's veto (don't delete!). + */ + private function _preDelete(Doctrine_Record $record) + { + $event = new Doctrine_Event($record, Doctrine_Event::RECORD_DELETE); + $record->preDelete($event); + $record->getTable()->getRecordListener()->preDelete($event); + + return $event->skipOperation; + } + + /** + * Invokes postDelete event listeners. + */ + private function _postDelete(Doctrine_Record $record) + { + $event = new Doctrine_Event($record, Doctrine_Event::RECORD_DELETE); + $record->postDelete($event); + $record->getTable()->getRecordListener()->postDelete($event); + } + + /** + * saveAll + * persists all the pending records from all tables + * + * @throws PDOException if something went wrong at database level + * @return void + */ + public function saveAll() + { + // get the flush tree + $tree = $this->buildFlushTree($this->conn->getTables()); + + // save all records + foreach ($tree as $name) { + $table = $this->conn->getTable($name); + foreach ($table->getRepository() as $record) { + $this->saveGraph($record); + } + } + } + + /** + * updates given record + * + * @param Doctrine_Record $record record to be updated + * @return boolean whether or not the update was successful + */ + public function update(Doctrine_Record $record) + { + $event = new Doctrine_Event($record, Doctrine_Event::RECORD_UPDATE); + $record->preUpdate($event); + $table = $record->getTable(); + $table->getRecordListener()->preUpdate($event); + + if ($record->isValid()) { + if ( ! $event->skipOperation) { + $identifier = $record->identifier(); + if ($table->getOption('joinedParents')) { + // currrently just for bc! + $this->_updateCTIRecord($table, $record); + //-- + } else { + $array = $record->getPrepared(); + $this->conn->update($table, $array, $identifier); + } + $record->assignIdentifier(true); + } + + $table->getRecordListener()->postUpdate($event); + + $record->postUpdate($event); + + return true; + } + + return false; + } + + /** + * inserts a record into database + * + * @param Doctrine_Record $record record to be inserted + * @return boolean + */ + public function insert(Doctrine_Record $record) + { + // listen the onPreInsert event + $event = new Doctrine_Event($record, Doctrine_Event::RECORD_INSERT); + $record->preInsert($event); + $table = $record->getTable(); + $table->getRecordListener()->preInsert($event); + + if ($record->isValid()) { + if ( ! $event->skipOperation) { + if ($table->getOption('joinedParents')) { + // just for bc! + $this->_insertCTIRecord($table, $record); + //-- + } else { + $this->processSingleInsert($record); + } + } + + $table->addRecord($record); + $table->getRecordListener()->postInsert($event); + $record->postInsert($event); + + return true; + } + + return false; + } + + /** + * @todo DESCRIBE WHAT THIS METHOD DOES, PLEASE! + */ + public function processSingleInsert(Doctrine_Record $record) + { + $fields = $record->getPrepared(); + $table = $record->getTable(); + + // Populate fields with a blank array so that a blank records can be inserted + if (empty($fields)) { + foreach ($table->getFieldNames() as $field) { + $fields[$field] = null; + } + } + + $identifier = (array) $table->getIdentifier(); + + $seq = $record->getTable()->sequenceName; + + if ( ! empty($seq)) { + $id = $this->conn->sequence->nextId($seq); + $seqName = $table->getIdentifier(); + $fields[$seqName] = $id; + + $record->assignIdentifier($id); + } + + $this->conn->insert($table, $fields); + + if (empty($seq) && count($identifier) == 1 && $identifier[0] == $table->getIdentifier() && + $table->getIdentifierType() != Doctrine::IDENTIFIER_NATURAL) { + if (($driver = strtolower($this->conn->getDriverName())) == 'pgsql') { + $seq = $table->getTableName() . '_' . $identifier[0]; + } elseif ($driver == 'oracle') { + $seq = $table->getTableName(); + } + + $id = $this->conn->sequence->lastInsertId($seq); + + if ( ! $id) { + throw new Doctrine_Connection_Exception("Couldn't get last insert identifier."); + } + $record->assignIdentifier($id); + } else { + $record->assignIdentifier(true); + } + } + + /** + * buildFlushTree + * builds a flush tree that is used in transactions + * + * The returned array has all the initialized components in + * 'correct' order. Basically this means that the records of those + * components can be saved safely in the order specified by the returned array. + * + * @param array $tables an array of Doctrine_Table objects or component names + * @return array an array of component names in flushing order + */ + public function buildFlushTree(array $tables) + { + // determine classes to order. only necessary because the $tables param + // can contain strings or table objects... + $classesToOrder = array(); + foreach ($tables as $table) { + if ( ! ($table instanceof Doctrine_Table)) { + $table = $this->conn->getTable($table, false); + } + $classesToOrder[] = $table->getComponentName(); + } + $classesToOrder = array_unique($classesToOrder); + + if (count($classesToOrder) < 2) { + return $classesToOrder; + } + + // build the correct order + $flushList = array(); + foreach ($classesToOrder as $class) { + $table = $this->conn->getTable($class, false); + $currentClass = $table->getComponentName(); + + $index = array_search($currentClass, $flushList); + + if ($index === false) { + //echo "adding $currentClass to flushlist"; + $flushList[] = $currentClass; + $index = max(array_keys($flushList)); + } + + $rels = $table->getRelations(); + + // move all foreignkey relations to the beginning + foreach ($rels as $key => $rel) { + if ($rel instanceof Doctrine_Relation_ForeignKey) { + unset($rels[$key]); + array_unshift($rels, $rel); + } + } + + foreach ($rels as $rel) { + $relatedClassName = $rel->getTable()->getComponentName(); + + if ( ! in_array($relatedClassName, $classesToOrder)) { + continue; + } + + $relatedCompIndex = array_search($relatedClassName, $flushList); + $type = $rel->getType(); + + // skip self-referenced relations + if ($relatedClassName === $currentClass) { + continue; + } + + if ($rel instanceof Doctrine_Relation_ForeignKey) { + // the related component needs to come after this component in + // the list (since it holds the fk) + + if ($relatedCompIndex !== false) { + // the component is already in the list + if ($relatedCompIndex >= $index) { + // it's already in the right place + continue; + } + + unset($flushList[$index]); + // the related comp has the fk. so put "this" comp immediately + // before it in the list + array_splice($flushList, $relatedCompIndex, 0, $currentClass); + $index = $relatedCompIndex; + } else { + $flushList[] = $relatedClassName; + } + + } else if ($rel instanceof Doctrine_Relation_LocalKey) { + // the related component needs to come before the current component + // in the list (since this component holds the fk). + + if ($relatedCompIndex !== false) { + // already in flush list + if ($relatedCompIndex <= $index) { + // it's in the right place + continue; + } + + unset($flushList[$relatedCompIndex]); + // "this" comp has the fk. so put the related comp before it + // in the list + array_splice($flushList, $index, 0, $relatedClassName); + } else { + array_unshift($flushList, $relatedClassName); + $index++; + } + } else if ($rel instanceof Doctrine_Relation_Association) { + // the association class needs to come after both classes + // that are connected through it in the list (since it holds + // both fks) + + $assocTable = $rel->getAssociationFactory(); + $assocClassName = $assocTable->getComponentName(); + + if ($relatedCompIndex !== false) { + unset($flushList[$relatedCompIndex]); + } + + array_splice($flushList, $index, 0, $relatedClassName); + $index++; + + $index3 = array_search($assocClassName, $flushList); + + if ($index3 !== false) { + if ($index3 >= $index) { + continue; + } + + unset($flushList[$index]); + array_splice($flushList, $index3, 0, $assocClassName); + $index = $relatedCompIndex; + } else { + $flushList[] = $assocClassName; + } + } + } + } + + return array_values($flushList); + } + + + /* The following is all the Class Table Inheritance specific code. Support dropped + for 0.10/1.0. */ + + /** + * Class Table Inheritance code. + * Support dropped for 0.10/1.0. + * + * Note: This is flawed. We also need to delete from subclass tables. + */ + private function _deleteCTIParents(Doctrine_Table $table, $record) + { + if ($table->getOption('joinedParents')) { + foreach (array_reverse($table->getOption('joinedParents')) as $parent) { + $parentTable = $table->getConnection()->getTable($parent); + $this->conn->delete($parentTable, $record->identifier()); + } + } + } + + /** + * Class Table Inheritance code. + * Support dropped for 0.10/1.0. + */ + private function _insertCTIRecord(Doctrine_Table $table, Doctrine_Record $record) + { + $dataSet = $this->_formatDataSet($record); + $component = $table->getComponentName(); + + $classes = $table->getOption('joinedParents'); + $classes[] = $component; + + foreach ($classes as $k => $parent) { + if ($k === 0) { + $rootRecord = new $parent(); + $rootRecord->merge($dataSet[$parent]); + $this->processSingleInsert($rootRecord); + $record->assignIdentifier($rootRecord->identifier()); + } else { + foreach ((array) $rootRecord->identifier() as $id => $value) { + $dataSet[$parent][$id] = $value; + } + + $this->conn->insert($this->conn->getTable($parent), $dataSet[$parent]); + } + } + } + + /** + * Class Table Inheritance code. + * Support dropped for 0.10/1.0. + */ + private function _updateCTIRecord(Doctrine_Table $table, Doctrine_Record $record) + { + $identifier = $record->identifier(); + $dataSet = $this->_formatDataSet($record); + + $component = $table->getComponentName(); + + $classes = $table->getOption('joinedParents'); + $classes[] = $component; + + foreach ($record as $field => $value) { + if ($value instanceof Doctrine_Record) { + if ( ! $value->exists()) { + $value->save(); + } + $record->set($field, $value->getIncremented()); + } + } + + foreach ($classes as $class) { + $parentTable = $this->conn->getTable($class); + + if ( ! array_key_exists($class, $dataSet)) { + continue; + } + + $this->conn->update($this->conn->getTable($class), $dataSet[$class], $identifier); + } + } + + /** + * Class Table Inheritance code. + * Support dropped for 0.10/1.0. + */ + private function _formatDataSet(Doctrine_Record $record) + { + $table = $record->getTable(); + $dataSet = array(); + $component = $table->getComponentName(); + $array = $record->getPrepared(); + + foreach ($table->getColumns() as $columnName => $definition) { + if ( ! isset($dataSet[$component])) { + $dataSet[$component] = array(); + } + + $fieldName = $table->getFieldName($columnName); + if (isset($definition['primary']) && $definition['primary']) { + continue; + } + + if ( ! array_key_exists($fieldName, $array)) { + continue; + } + + if (isset($definition['owner'])) { + $dataSet[$definition['owner']][$fieldName] = $array[$fieldName]; + } else { + $dataSet[$component][$fieldName] = $array[$fieldName]; + } + } + + return $dataSet; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,279 @@ +. + */ + +/** + * Doctrine_Data + * + * Base Doctrine_Data class for dumping and loading data to and from fixtures files. + * Support formats are based on what formats are available in Doctrine_Parser such as yaml, xml, json, etc. + * + * @package Doctrine + * @subpackage Data + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2552 $ + */ +class Doctrine_Data +{ + /** + * formats + * + * array of formats data can be in + * + * @var string + */ + protected $_formats = array('csv', 'yml', 'xml'); + + /** + * format + * + * the default and current format we are working with + * + * @var string + */ + protected $_format = 'yml'; + + /** + * directory + * + * array of directory/yml paths or single directory/yml file + * + * @var string + */ + protected $_directory = null; + + /** + * models + * + * specified array of models to use + * + * @var string + */ + protected $_models = array(); + + /** + * _exportIndividualFiles + * + * whether or not to export data to individual files instead of 1 + * + * @var string + */ + protected $_exportIndividualFiles = false; + + /** + * setFormat + * + * Set the current format we are working with + * + * @param string $format + * @return void + */ + public function setFormat($format) + { + $this->_format = $format; + } + + /** + * getFormat + * + * Get the current format we are working with + * + * @return void + */ + public function getFormat() + { + return $this->_format; + } + + /** + * getFormats + * + * Get array of available formats + * + * @return void + */ + public function getFormats() + { + return $this->_formats; + } + + /** + * setDirectory + * + * Set the array/string of directories or yml file paths + * + * @return void + */ + public function setDirectory($directory) + { + $this->_directory = $directory; + } + + /** + * getDirectory + * + * Get directory for dumping/loading data from and to + * + * @return void + */ + public function getDirectory() + { + return $this->_directory; + } + + /** + * setModels + * + * Set the array of specified models to work with + * + * @param string $models + * @return void + */ + public function setModels($models) + { + $this->_models = $models; + } + + /** + * getModels + * + * Get the array of specified models to work with + * + * @return void + */ + public function getModels() + { + return $this->_models; + } + + /** + * _exportIndividualFiles + * + * Set/Get whether or not to export individual files + * + * @return bool $_exportIndividualFiles + */ + public function exportIndividualFiles($bool = null) + { + if ($bool !== null) { + $this->_exportIndividualFiles = $bool; + } + + return $this->_exportIndividualFiles; + } + + /** + * exportData + * + * Interface for exporting data to fixtures files from Doctrine models + * + * @param string $directory + * @param string $format + * @param string $models + * @param string $_exportIndividualFiles + * @return void + */ + public function exportData($directory, $format = 'yml', $models = array(), $_exportIndividualFiles = false) + { + $export = new Doctrine_Data_Export($directory); + $export->setFormat($format); + $export->setModels($models); + $export->exportIndividualFiles($_exportIndividualFiles); + + return $export->doExport(); + } + + /** + * importData + * + * Interface for importing data from fixture files to Doctrine models + * + * @param string $directory + * @param string $format + * @param string $models + * @return void + */ + public function importData($directory, $format = 'yml', $models = array(), $append = false) + { + $import = new Doctrine_Data_Import($directory); + $import->setFormat($format); + $import->setModels($models); + + return $import->doImport($append); + } + + /** + * isRelation + * + * Check if a fieldName on a Doctrine_Record is a relation, if it is we return that relationData + * + * @param string $Doctrine_Record + * @param string $fieldName + * @return void + */ + public function isRelation(Doctrine_Record $record, $fieldName) + { + $relations = $record->getTable()->getRelations(); + + foreach ($relations as $relation) { + $relationData = $relation->toArray(); + + if ($relationData['local'] === $fieldName) { + return $relationData; + } + + } + + return false; + } + + /** + * purge + * + * Purge all data for loaded models or for the passed array of Doctrine_Records + * + * @param string $models + * @return void + */ + public function purge($models = null) + { + if ($models) { + $models = Doctrine::filterInvalidModels($models); + } else { + $models = Doctrine::getLoadedModels(); + } + + $connections = array(); + foreach ($models as $model) { + $connections[Doctrine::getTable($model)->getConnection()->getName()][] = $model; + } + + foreach ($connections as $connection => $models) { + $models = Doctrine_Manager::getInstance()->getConnection($connection)->unitOfWork->buildFlushTree($models); + $models = array_reverse($models); + foreach ($models as $model) { + Doctrine::getTable($model)->createQuery()->delete()->execute(); + } + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Data_Exception + * + * @package Doctrine + * @subpackage Data + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2552 $ + */ +class Doctrine_Data_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data/Export.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data/Export.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,212 @@ +. + */ + +/** + * Doctrine_Data_Export + * + * @package Doctrine + * @subpackage Data + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2552 $ + */ +class Doctrine_Data_Export extends Doctrine_Data +{ + /** + * constructor + * + * @param string $directory + * @return void + */ + public function __construct($directory) + { + $this->setDirectory($directory); + } + + /** + * doExport + * + * FIXME: This function has ugly hacks in it for temporarily disabling INDEXBY query parts of tables + * to export. + * + * Update from jwage: I am not sure if their is any other better solution for this. It may be the correct + * solution to disable the indexBy settings for tables when exporting data fixtures. Maybe a better idea + * would be to extract this functionality to a pair of functions to enable/disable the index by settings + * so simply turn them on and off when they need to query for the translations standalone and don't need + * it to be indexed by the lang. + * + * @return void + */ + public function doExport() + { + $models = Doctrine::getLoadedModels(); + $specifiedModels = $this->getModels(); + + $data = array(); + + // for situation when the $models array is empty, but the $specifiedModels array isn't + if (empty($models)) { + $models = $specifiedModels; + } + + $models = Doctrine::initializeModels($models); + + // temporarily disable indexBy query parts of selected and related tables + $originalIndexBy = array(); + foreach ($models AS $name) { + $table = Doctrine::getTable($name); + if (!is_null($indexBy = $table->getBoundQueryPart('indexBy'))) { + $originalIndexBy[$name] = $indexBy; + $table->bindQueryPart('indexBy', null); + } + } + + foreach ($models AS $name) { + if ( ! empty($specifiedModels) AND ! in_array($name, $specifiedModels)) { + continue; + } + + $results = Doctrine::getTable($name)->findAll(); + + if ($results->count() > 0) { + $data[$name] = $results; + } + } + + // Restore the temporarily disabled indexBy query parts + foreach($originalIndexBy AS $name => $indexBy) { + Doctrine::getTable($name)->bindQueryPart('indexBy', $indexBy); + } + + $data = $this->prepareData($data); + + return $this->dumpData($data); + } + + /** + * dumpData + * + * Dump the prepared data to the fixtures files + * + * @param string $array + * @return void + */ + public function dumpData(array $data) + { + $directory = $this->getDirectory(); + $format = $this->getFormat(); + + if ($this->exportIndividualFiles()) { + if (is_array($directory)) { + throw new Doctrine_Data_Exception('You must specify a single path to a folder in order to export individual files.'); + } else if ( ! is_dir($directory) && is_file($directory)) { + $directory = dirname($directory); + } + + foreach ($data as $className => $classData) { + if ( ! empty($classData)) { + Doctrine_Parser::dump(array($className => $classData), $format, $directory.DIRECTORY_SEPARATOR.$className.'.'.$format); + } + } + } else { + if (is_dir($directory)) { + $directory .= DIRECTORY_SEPARATOR . 'data.' . $format; + } + + if ( ! empty($data)) { + return Doctrine_Parser::dump($data, $format, $directory); + } + } + } + + /** + * prepareData + * + * Prepare the raw data to be exported with the parser + * + * @param string $data + * @return array + */ + public function prepareData($data) + { + $preparedData = array(); + + foreach ($data AS $className => $classData) { + $preparedData[$className] = array(); + foreach ($classData as $record) { + $className = get_class($record); + $recordKey = $className . '_' . implode('_', $record->identifier()); + $preparedData[$className][$recordKey] = array(); + + // skip single primary keys, we need to maintain composite primary keys + $keys = $record->getTable()->getIdentifier(); + + $recordData = $record->toArray(false); + + foreach ($recordData as $key => $value) { + if ( ! is_array($keys)) { + $keys = array($keys); + } + + if (count($keys) <= 1 && in_array($key, $keys)) { + continue; + } + + if (is_object($record[$key])) { + // If the field is an object serialize it + $value = serialize($record[$key]); + } + + if ($relation = $this->isRelation($record, $key)) { + if ( ! $value) { + continue; + } + $relationAlias = $relation['alias']; + $relationRecord = $record->$relationAlias; + + // If collection then get first so we have an instance of the related record + if ($relationRecord instanceof Doctrine_Collection) { + $relationRecord = $relationRecord->getFirst(); + } + + // If relation is null or does not exist then continue + if ($relationRecord instanceof Doctrine_Null || ! $relationRecord) { + continue; + } + + // Get class name for relation + $relationClassName = get_class($relationRecord); + + $relationValue = $relationClassName . '_' . $value; + + $preparedData[$className][$recordKey][$relationAlias] = $relationValue; + } else if ($record->getTable()->hasField($key)) { + $preparedData[$className][$recordKey][$key] = $value; + } + } + } + } + + return $preparedData; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data/Import.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Data/Import.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,374 @@ +. + */ + +/** + * Doctrine_Data_Import + * + * @package Doctrine + * @package Data + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 2552 $ + */ +class Doctrine_Data_Import extends Doctrine_Data +{ + /** + * Array of imported objects for processing and saving + * + * @var array + */ + protected $_importedObjects = array(); + + /** + * Array of the raw data parsed from yaml + * + * @var array + */ + protected $_rows = array(); + + /** + * Optionally pass the directory/path to the yaml for importing + * + * @param string $directory + * @return void + */ + public function __construct($directory = null) + { + if ($directory !== null) { + $this->setDirectory($directory); + } + } + + /** + * Do the parsing of the yaml files and return the final parsed array + * + * @return array $array + */ + public function doParsing() + { + $recursiveMerge = Doctrine_Manager::getInstance()->getAttribute('recursive_merge_fixtures'); + $mergeFunction = $recursiveMerge === true ? 'array_merge_recursive':'array_merge'; + $directory = $this->getDirectory(); + + $array = array(); + + if ($directory !== null) { + foreach ((array) $directory as $dir) { + $e = explode('.', $dir); + + // If they specified a specific yml file + if (end($e) == 'yml') { + $array = $mergeFunction($array, Doctrine_Parser::load($dir, $this->getFormat())); + // If they specified a directory + } else if(is_dir($dir)) { + $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), + RecursiveIteratorIterator::LEAVES_ONLY); + + foreach ($it as $file) { + $e = explode('.', $file->getFileName()); + if (in_array(end($e), $this->getFormats())) { + $array = $mergeFunction($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat())); + } + } + } + } + } + + return $array; + } + + /** + * Do the importing of the data parsed from the fixtures + * + * @return void + */ + public function doImport($append = false) + { + $array = $this->doParsing(); + + if ( ! $append) { + $this->purge(array_reverse(array_keys($array))); + } + + $this->_loadData($array); + } + + /** + * Recursively loop over all data fixtures and build the array of className rows + * + * @return void + */ + protected function _buildRows($className, $data) + { + foreach ($data as $rowKey => $row) { + // do the same for the row information + $this->_rows[$className][$rowKey] = $row; + + foreach ((array) $row as $key => $value) { + if (Doctrine::getTable($className)->hasRelation($key) && is_array($value)) { + $keys = array_keys($value); + + // Skip associative arrays defining keys to relationships + if ( ! isset($keys[0])) { + $this->_buildRows(Doctrine::getTable($className)->getRelation($key)->getTable()->getOption('name'), $value); + } + } + } + } + } + + /** + * Build the rows for nested set models + * + * @return void + */ + protected function _buildNestedSetRows($className, $data) + { + foreach ($data as $rowKey => $row) { + $children = isset($row['children']) ? $row['children']:array(); + unset($row['children']); + $this->_rows[$className][$rowKey] = $row; + + $this->_buildNestedSetRows($className, $children); + } + } + + /** + * Get the unsaved object for a specified row key and validate that it is the valid object class + * for the passed record and relation name + * + * @param string $rowKey + * @param Doctrine_Record $record + * @param string $relationName + * @param string $referringRowKey + * @return Doctrine_Record + * @throws Doctrine_Data_Exception + */ + protected function _getImportedObject($rowKey, Doctrine_Record $record, $relationName, $referringRowKey) + { + if ( ! isset($this->_importedObjects[$rowKey])) { + throw new Doctrine_Data_Exception( + sprintf('Invalid row key specified: %s, referred to in %s', $rowKey, $referringRowKey) + ); + } + + $relatedRowKeyObject = $this->_importedObjects[$rowKey]; + + $relation = $record->getTable()->getRelation($relationName); + if ($relation->getClass() !== get_class($relatedRowKeyObject)) { + if ( ! is_subclass_of($relatedRowKeyObject, $relation->getClass())) { + throw new Doctrine_Data_Exception(sprintf( + 'Class referred to in "%s" is expected to be "%s" and "%s" was given', + $referringRowKey, $relation->getClass(), get_class($relatedRowKeyObject))); + } + } + + return $relatedRowKeyObject; + } + + /** + * Process a row and make all the appropriate relations between the imported data + * + * @param string $rowKey + * @param string $row + * @return void + */ + protected function _processRow($rowKey, $row) + { + $obj = $this->_importedObjects[$rowKey]; + + foreach ((array) $row as $key => $value) { + if (method_exists($obj, 'set' . Doctrine_Inflector::classify($key))) { + $func = 'set' . Doctrine_Inflector::classify($key); + $obj->$func($value); + } else if ($obj->getTable()->hasField($key)) { + if ($obj->getTable()->getTypeOf($key) == 'object') { + $value = unserialize($value); + } + $obj->set($key, $value); + } else if ($obj->getTable()->hasRelation($key)) { + if (is_array($value)) { + if (isset($value[0]) && ! is_array($value[0])) { + foreach ($value as $link) { + if ($obj->getTable()->getRelation($key)->getType() === Doctrine_Relation::ONE) { + $obj->set($key, $this->_getImportedObject($link, $obj, $key, $rowKey)); + } else if ($obj->getTable()->getRelation($key)->getType() === Doctrine_Relation::MANY) { + $relation = $obj->$key; + + $relation[] = $this->_getImportedObject($link, $obj, $key, $rowKey); + } + } + } else { + $obj->$key->fromArray($value); + } + } else { + $obj->set($key, $this->_getImportedObject($value, $obj, $key, $rowKey)); + } + } else { + try { + $obj->$key = $value; + } catch (Exception $e) { + // used for Doctrine plugin methods (Doctrine_Template) + if (is_callable(array($obj, 'set' . Doctrine_Inflector::classify($key)))) { + $func = 'set' . Doctrine_Inflector::classify($key); + $obj->$func($value); + } else { + throw new Doctrine_Data_Exception('Invalid fixture element "'. $key . '" under "' . $rowKey . '"'); + } + } + } + } + } + + /** + * NestedSet fixtures may come in a 'natural' format with nested children listed under a 'children' + * key or in a raw, non-nested format with lft/rgt values. + * + * This method returns true if the given $data is a nested set in 'natural' form. + * + * @param $className + * @param $data + * @return boolean + */ + protected function _hasNaturalNestedSetFormat($className, array &$data) + { + if (Doctrine::getTable($className)->isTree()) { + if (isset($data['NestedSet']) && $data['NestedSet'] == true) { + unset($data['NestedSet']); + return true; + } else { + $first = current($data); + return array_key_exists('children', $first); + } + } else { + return false; + } + } + + /** + * Perform the loading of the data from the passed array + * + * @param string $array + * @return void + */ + protected function _loadData(array $array) + { + $nestedSets = array(); + + $specifiedModels = $this->getModels(); + $rows = array(); + + foreach ($array as $className => $data) { + if ( ! empty($specifiedModels) && !in_array($className, $specifiedModels)) { + continue; + } + + // if loaded data is a nested set in natural format, process through _buildNestedSetRows. + // 'raw' nested sets and all other models are processed through _buildRows. + if ($this->_hasNaturalNestedSetFormat($className, $data)) { + $nestedSets[$className][] = $data; + $this->_buildNestedSetRows($className, $data); + } else { + $this->_buildRows($className, $data); + } + } + + $buildRows = array(); + foreach ($this->_rows as $className => $classRows) { + foreach ($classRows as $rowKey => $row) { + $buildRows[$rowKey] = $row; + $this->_importedObjects[$rowKey] = new $className(); + $this->_importedObjects[$rowKey]->state('TDIRTY'); + } + } + + foreach($buildRows as $rowKey => $row) { + $this->_processRow($rowKey, $row); + } + + // save natural nested set fixture data and unset from _importedObjects + foreach ($nestedSets as $className => $sets) { + foreach ($sets as $data) { + $this->_loadNestedSetData($className, $data); + } + } + + $objects = array(); + foreach ($this->_importedObjects as $object) { + $className = get_class($object); + $objects[$className] = $className; + } + + $manager = Doctrine_Manager::getInstance(); + foreach ($manager as $connection) { + $tree = $connection->unitOfWork->buildFlushTree($objects); + + foreach ($tree as $model) { + foreach ($this->_importedObjects as $obj) { + + if ($obj instanceof $model) { + $obj->save(); + } + } + } + } + + } + + /** + * Load nested set data for models with nested set enabled + * + * @param string $model + * @param string $nestedSetData + * @param string $parent + * @return void + */ + protected function _loadNestedSetData($model, $nestedSetData, $parent = null) + { + foreach($nestedSetData AS $rowKey => $nestedSet) { + $children = array(); + $data = array(); + + if (array_key_exists('children', $nestedSet)) { + $children = (array) $nestedSet['children']; + $children = array_reverse($children, true); + unset($nestedSet['children']); + } + + $record = $this->_importedObjects[$rowKey]; + // remove this nested set from _importedObjects so it's not processed in the save routine for normal objects + unset($this->_importedObjects[$rowKey]); + + if( ! $parent) { + $record->save(); // save, so that createRoot can do: root id = id + Doctrine::getTable($model)->getTree()->createRoot($record); + } else { + $parent->getNode()->addChild($record); + } + + if (is_array($children) AND !empty($children)) { + $this->_loadNestedSetData($model, $children, $record); + } + } + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,96 @@ +. + */ + +/** + * Doctrine_DataDict + * + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + */ +class Doctrine_DataDict extends Doctrine_Connection_Module +{ + /** + * Obtain an array of changes that may need to applied + * + * @param array $current new definition + * @param array $previous old definition + * @return array containing all changes that will need to be applied + */ + public function compareDefinition($current, $previous) + { + $type = !empty($current['type']) ? $current['type'] : null; + + if ( ! method_exists($this, "_compare{$type}Definition")) { + throw new Doctrine_DataDict_Exception('type "'.$current['type'].'" is not yet supported'); + } + + if (empty($previous['type']) || $previous['type'] != $type) { + return $current; + } + + $change = $this->{"_compare{$type}Definition"}($current, $previous); + + if ($previous['type'] != $type) { + $change['type'] = true; + } + + $previous_notnull = !empty($previous['notnull']) ? $previous['notnull'] : false; + $notnull = !empty($current['notnull']) ? $current['notnull'] : false; + if ($previous_notnull != $notnull) { + $change['notnull'] = true; + } + + $previous_default = array_key_exists('default', $previous) ? $previous['default'] : + ($previous_notnull ? '' : null); + $default = array_key_exists('default', $current) ? $current['default'] : + ($notnull ? '' : null); + if ($previous_default !== $default) { + $change['default'] = true; + } + + return $change; + } + + /** + * parseBoolean + * parses a literal boolean value and returns + * proper sql equivalent + * + * @param string $value boolean value to be parsed + * @return string parsed boolean value + */ + public function parseBoolean($value) + { + // parse booleans + if ($value == 'true') { + $value = 1; + } elseif ($value == 'false') { + $value = 0; + } + return $value; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_DataDict_Exception + * + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_DataDict_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Firebird.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Firebird.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,219 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lorenzo Alberton (PEAR MDB2 Interbase driver) + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Firebird extends Doctrine_DataDict +{ + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration($field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + switch ($field['type']) { + case 'enum': + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + case 'varchar': + case 'string': + case 'array': + case 'object': + case 'char': + case 'text': + case 'gzip': + $length = !empty($field['length']) + ? $field['length'] : 16777215; // TODO: $this->conn->options['default_text_field_length']; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')'; + case 'clob': + return 'BLOB SUB_TYPE 1'; + case 'blob': + return 'BLOB SUB_TYPE 0'; + case 'integer': + case 'int': + return 'INT'; + case 'boolean': + return 'SMALLINT'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME'; + case 'timestamp': + return 'TIMESTAMP'; + case 'float': + return 'DOUBLE PRECISION'; + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); + return 'DECIMAL('.$length.','.$scale.')'; + } + + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } + + /** + * Maps a native array description of a field to a Doctrine datatype and length + * + * @param array $field native field description + * @return array containing the various possible types, length, sign, fixed + */ + public function getPortableDeclaration($field) + { + $length = (isset($field['length']) && $field['length'] > 0) ? $field['length'] : null; + + $type = array(); + $unsigned = $fixed = null; + $dbType = strtolower($field['type']); + $field['field_sub_type'] = !empty($field['field_sub_type']) + ? strtolower($field['field_sub_type']) : null; + + if ( ! isset($field['name'])) { + $field['name'] = ''; + } + + switch ($dbType) { + case 'smallint': + case 'integer': + case 'int64': + //these may be 'numeric' or 'decimal' + if (isset($field['field_sub_type'])) { + $field['type'] = $field['field_sub_type']; + return $this->getPortableDeclaration($field); + } + case 'bigint': + case 'quad': + $type[] = 'integer'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } + break; + case 'varchar': + $fixed = false; + case 'char': + case 'cstring': + $type[] = 'string'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'date': + $type[] = 'date'; + $length = null; + break; + case 'timestamp': + $type[] = 'timestamp'; + $length = null; + break; + case 'time': + $type[] = 'time'; + $length = null; + break; + case 'float': + case 'double': + case 'double precision': + case 'd_float': + $type[] = 'float'; + break; + case 'decimal': + case 'numeric': + $type[] = 'decimal'; + break; + case 'blob': + $type[] = ($field['field_sub_type'] == 'text') ? 'clob' : 'blob'; + $length = null; + break; + default: + throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType); + } + + return array('type' => $type, + 'length' => $length, + 'unsigned' => $unsigned, + 'fixed' => $fixed); + } + + /** + * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $charset name of the charset + * @return string DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration. + */ + public function getCharsetFieldDeclaration($charset) + { + return 'CHARACTER SET ' . $charset; + } + + /** + * Obtain DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $collation name of the collation + * @return string DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration. + */ + public function getCollationFieldDeclaration($collation) + { + return 'COLLATE ' . $collation; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Informix.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Informix.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,112 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Informix extends Doctrine_DataDict +{ + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration($field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + switch ($field['type']) { + case 'char': + case 'enum': + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + case 'varchar': + case 'array': + case 'object': + case 'string': + if (empty($field['length']) && array_key_exists('default', $field)) { + $field['length'] = $this->conn->varchar_max_length; + } + + $length = ( ! empty($field['length'])) ? $field['length'] : false; + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)') + : ($length ? 'VARCHAR('.$length.')' : 'NVARCHAR'); + case 'clob': + return 'TEXT'; + case 'blob': + return 'BLOB'; + case 'integer': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 1) { + return 'SMALLINT'; + } elseif ($length == 2) { + return 'SMALLINT'; + } elseif ($length == 3 || $length == 4) { + return 'INTEGER'; + } elseif ($length > 4) { + return 'DECIMAL(20)'; + } + } + return 'INT'; + case 'boolean': + return 'SMALLINT'; + case 'date': + return 'DATE'; + case 'time': + return 'DATETIME YEAR TO SECOND'; + case 'timestamp': + return 'DATETIME'; + case 'float': + return 'FLOAT'; + case 'decimal': + return 'DECIMAL'; + } + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Mssql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Mssql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,254 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Frank M. Kromann (PEAR MDB2 Mssql driver) + * @author David Coallier (PEAR MDB2 Mssql driver) + * @version $Revision: 5848 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Mssql extends Doctrine_DataDict +{ + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration($field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + switch ($field['type']) { + case 'enum': + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + case 'array': + case 'object': + case 'text': + case 'char': + case 'varchar': + case 'string': + case 'gzip': + $length = !empty($field['length']) + ? $field['length'] : false; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$this->conn->options['default_text_field_length'].')') + : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); + case 'clob': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 8000) { + return 'VARCHAR('.$length.')'; + } + } + return 'TEXT'; + case 'blob': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 8000) { + return "VARBINARY($length)"; + } + } + return 'IMAGE'; + case 'integer': + case 'int': + return 'INT'; + case 'boolean': + return 'BIT'; + case 'date': + return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; + case 'time': + return 'CHAR(' . strlen('HH:MM:SS') . ')'; + case 'timestamp': + return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; + case 'float': + return 'FLOAT'; + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); + return 'DECIMAL('.$length.','.$scale.')'; + } + + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } + + /** + * Maps a native array description of a field to a MDB2 datatype and length + * + * @param array $field native field description + * @return array containing the various possible types, length, sign, fixed + */ + public function getPortableDeclaration($field) + { + $db_type = preg_replace('/[\d\(\)]/','', strtolower($field['type']) ); + $length = (isset($field['length']) && $field['length'] > 0) ? $field['length'] : null; + + $type = array(); + // todo: unsigned handling seems to be missing + $unsigned = $fixed = null; + + if ( ! isset($field['name'])) + $field['name'] = ''; + + switch ($db_type) { + case 'bit': + $type[0] = 'boolean'; + break; + case 'tinyint': + case 'smallint': + case 'bigint': + case 'int': + $type[0] = 'integer'; + if ($length == 1) { + $type[] = 'boolean'; + } + break; + case 'date': + $type[0] = 'date'; + break; + case 'datetime': + case 'timestamp': + case 'smalldatetime': + $type[0] = 'timestamp'; + break; + case 'float': + case 'real': + case 'numeric': + $type[0] = 'float'; + break; + case 'decimal': + case 'money': + case 'smallmoney': + $type[0] = 'decimal'; + break; + case 'text': + case 'varchar': + case 'ntext': + case 'nvarchar': + $fixed = false; + case 'char': + case 'nchar': + $type[0] = 'string'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($db_type, 'text')) { + $type[] = 'clob'; + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'image': + case 'varbinary': + $type[] = 'blob'; + $length = null; + break; + default: + throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$db_type); + } + + return array('type' => $type, + 'length' => $length, + 'unsigned' => $unsigned, + 'fixed' => $fixed); + } + + /** + * Obtain DBMS specific SQL code portion needed to declare an integer type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param string $field associative array with the name of the properties + * of the field being declared as array indexes. + * Currently, the types of supported field + * properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field + * should be declared as unsigned integer if + * possible. + * + * default + * Integer value to be used as default for this + * field. + * + * notnull + * Boolean flag that indicates whether this field is + * constrained to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getIntegerDeclaration($name, $field) + { + $default = $autoinc = ''; + if ( ! empty($field['autoincrement'])) { + $autoinc = ' identity'; + } elseif (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) ? null : 0; + } + + $default = ' DEFAULT ' . (is_null($field['default']) + ? 'NULL' + : $this->conn->quote($field['default'])); + } + + + $notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : ''; + $unsigned = (isset($field['unsigned']) && $field['unsigned']) ? ' UNSIGNED' : ''; + $comment = (isset($field['comment']) && $field['comment']) + ? " COMMENT '" . $field['comment'] . "'" : ''; + + $name = $this->conn->quoteIdentifier($name, true); + + return $name . ' ' . $this->getNativeDeclaration($field) . $unsigned + . $default . $notnull . $autoinc . $comment; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Mysql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Mysql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,499 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Mysql extends Doctrine_DataDict +{ + protected $keywords = array( + 'ADD', 'ALL', 'ALTER', + 'ANALYZE', 'AND', 'AS', + 'ASC', 'ASENSITIVE', 'BEFORE', + 'BETWEEN', 'BIGINT', 'BINARY', + 'BLOB', 'BOTH', 'BY', 'BIT', + 'CALL', 'CASCADE', 'CASE', + 'CHANGE', 'CHAR', 'CHARACTER', + 'CHECK', 'COLLATE', 'COLUMN', + 'CONDITION', 'CONNECTION', 'CONSTRAINT', + 'CONTINUE', 'CONVERT', 'CREATE', + 'CROSS', 'CURRENT_DATE', 'CURRENT_TIME', + 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURSOR', + 'DATABASE', 'DATABASES', 'DAY_HOUR', + 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', + 'DEC', 'DECIMAL', 'DECLARE', + 'DEFAULT', 'DELAYED', 'DELETE', + 'DESC', 'DESCRIBE', 'DETERMINISTIC', + 'DISTINCT', 'DISTINCTROW', 'DIV', + 'DOUBLE', 'DROP', 'DUAL', + 'EACH', 'ELSE', 'ELSEIF', + 'ENCLOSED', 'ESCAPED', 'EXISTS', + 'EXIT', 'EXPLAIN', 'FALSE', + 'FETCH', 'FLOAT', 'FLOAT4', + 'FLOAT8', 'FOR', 'FORCE', + 'FOREIGN', 'FROM', 'FULLTEXT', + 'GRANT', 'GROUP', 'HAVING', + 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', + 'HOUR_SECOND', 'IF', 'IGNORE', + 'IN', 'INDEX', 'INFILE', + 'INNER', 'INOUT', 'INSENSITIVE', + 'INSERT', 'INT', 'INT1', + 'INT2', 'INT3', 'INT4', + 'INT8', 'INTEGER', 'INTERVAL', + 'INTO', 'IS', 'ITERATE', + 'JOIN', 'KEY', 'KEYS', + 'KILL', 'LEADING', 'LEAVE', + 'LEFT', 'LIKE', 'LIMIT', + 'LINES', 'LOAD', 'LOCALTIME', + 'LOCALTIMESTAMP', 'LOCK', 'LONG', + 'LONGBLOB', 'LONGTEXT', 'LOOP', + 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', + 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', + 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', + 'MODIFIES', 'NATURAL', 'NOT', + 'NO_WRITE_TO_BINLOG', 'NULL', 'NUMERIC', + 'ON', 'OPTIMIZE', 'OPTION', + 'OPTIONALLY', 'OR', 'ORDER', + 'OUT', 'OUTER', 'OUTFILE', + 'PRECISION', 'PRIMARY', 'PROCEDURE', + 'PURGE', 'RAID0', 'READ', + 'READS', 'REAL', 'REFERENCES', + 'REGEXP', 'RELEASE', 'RENAME', + 'REPEAT', 'REPLACE', 'REQUIRE', + 'RESTRICT', 'RETURN', 'REVOKE', + 'RIGHT', 'RLIKE', 'SCHEMA', + 'SCHEMAS', 'SECOND_MICROSECOND', 'SELECT', + 'SENSITIVE', 'SEPARATOR', 'SET', + 'SHOW', 'SMALLINT', 'SONAME', + 'SPATIAL', 'SPECIFIC', 'SQL', + 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', + 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', + 'SSL', 'STARTING', 'STRAIGHT_JOIN', + 'TABLE', 'TERMINATED', 'THEN', + 'TINYBLOB', 'TINYINT', 'TINYTEXT', + 'TO', 'TRAILING', 'TRIGGER', + 'TRUE', 'UNDO', 'UNION', + 'UNIQUE', 'UNLOCK', 'UNSIGNED', + 'UPDATE', 'USAGE', 'USE', + 'USING', 'UTC_DATE', 'UTC_TIME', + 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', + 'VARCHAR', 'VARCHARACTER', 'VARYING', + 'WHEN', 'WHERE', 'WHILE', + 'WITH', 'WRITE', 'X509', + 'XOR', 'YEAR_MONTH', 'ZEROFILL' + ); + + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration($field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + + switch ($field['type']) { + case 'char': + $length = ( ! empty($field['length'])) ? $field['length'] : false; + + return $length ? 'CHAR('.$length.')' : 'CHAR(255)'; + case 'enum': + if ($this->conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) { + $values = array(); + foreach ($field['values'] as $value) { + $values[] = $this->conn->quote($value, 'varchar'); + } + return 'ENUM('.implode(', ', $values).')'; + } else { + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + } + case 'varchar': + case 'array': + case 'object': + case 'string': + case 'gzip': + if ( ! isset($field['length'])) { + if (array_key_exists('default', $field)) { + $field['length'] = $this->conn->varchar_max_length; + } else { + $field['length'] = false; + } + } + + $length = ($field['length'] <= $this->conn->varchar_max_length) ? $field['length'] : false; + $fixed = (isset($field['fixed'])) ? $field['fixed'] : false; + + return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)') + : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT'); + case 'clob': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYTEXT'; + } elseif ($length <= 65532) { + return 'TEXT'; + } elseif ($length <= 16777215) { + return 'MEDIUMTEXT'; + } + } + return 'LONGTEXT'; + case 'blob': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYBLOB'; + } elseif ($length <= 65532) { + return 'BLOB'; + } elseif ($length <= 16777215) { + return 'MEDIUMBLOB'; + } + } + return 'LONGBLOB'; + case 'integer': + case 'int': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 1) { + return 'TINYINT'; + } elseif ($length == 2) { + return 'SMALLINT'; + } elseif ($length == 3) { + return 'MEDIUMINT'; + } elseif ($length == 4) { + return 'INT'; + } elseif ($length > 4) { + return 'BIGINT'; + } + } + return 'INT'; + case 'boolean': + return 'TINYINT(1)'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME'; + case 'timestamp': + return 'DATETIME'; + case 'float': + case 'double': + return 'DOUBLE'; + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); + return 'DECIMAL('.$length.','.$scale.')'; + case 'bit': + return 'BIT'; + } + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } + + /** + * Maps a native array description of a field to a MDB2 datatype and length + * + * @param array $field native field description + * @return array containing the various possible types, length, sign, fixed + */ + public function getPortableDeclaration(array $field) + { + $dbType = strtolower($field['type']); + $dbType = strtok($dbType, '(), '); + if ($dbType == 'national') { + $dbType = strtok('(), '); + } + if (isset($field['length'])) { + $length = $field['length']; + $decimal = ''; + } else { + $length = strtok('(), '); + $decimal = strtok('(), ') ? strtok('(), '):null; + } + $type = array(); + $unsigned = $fixed = null; + + if ( ! isset($field['name'])) { + $field['name'] = ''; + } + + $values = null; + $scale = null; + + switch ($dbType) { + case 'tinyint': + $type[] = 'integer'; + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 1; + break; + case 'smallint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 2; + break; + case 'mediumint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 3; + break; + case 'int': + case 'integer': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 4; + break; + case 'bigint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 8; + break; + case 'tinytext': + case 'mediumtext': + case 'longtext': + case 'text': + case 'text': + case 'varchar': + $fixed = false; + case 'string': + case 'char': + $type[] = 'string'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($dbType, 'text')) { + $type[] = 'clob'; + if ($decimal == 'binary') { + $type[] = 'blob'; + } + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'enum': + $type[] = 'enum'; + preg_match_all('/\'((?:\'\'|[^\'])*)\'/', $field['type'], $matches); + $length = 0; + $fixed = false; + if (is_array($matches)) { + foreach ($matches[1] as &$value) { + $value = str_replace('\'\'', '\'', $value); + $length = max($length, strlen($value)); + } + if ($length == '1' && count($matches[1]) == 2) { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } + + $values = $matches[1]; + } + $type[] = 'integer'; + break; + case 'set': + $fixed = false; + $type[] = 'text'; + $type[] = 'integer'; + break; + case 'date': + $type[] = 'date'; + $length = null; + break; + case 'datetime': + case 'timestamp': + $type[] = 'timestamp'; + $length = null; + break; + case 'time': + $type[] = 'time'; + $length = null; + break; + case 'float': + case 'double': + case 'real': + $type[] = 'float'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + break; + case 'unknown': + case 'decimal': + if ($decimal !== null) { + $scale = $decimal; + } + case 'numeric': + $type[] = 'decimal'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + break; + case 'tinyblob': + case 'mediumblob': + case 'longblob': + case 'blob': + case 'binary': + case 'varbinary': + $type[] = 'blob'; + $length = null; + break; + case 'year': + $type[] = 'integer'; + $type[] = 'date'; + $length = null; + break; + case 'bit': + $type[] = 'bit'; + break; + case 'geometry': + case 'geometrycollection': + case 'point': + case 'multipoint': + case 'linestring': + case 'multilinestring': + case 'polygon': + case 'multipolygon': + $type[] = 'blob'; + $length = null; + break; + default: + throw new Doctrine_DataDict_Exception('unknown database attribute type: ' . $dbType); + } + + $length = ((int) $length == 0) ? null : (int) $length; + $def = array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); + if ($values !== null) { + $def['values'] = $values; + } + if ($scale !== null) { + $def['scale'] = $scale; + } + return $def; + } + + /** + * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $charset name of the charset + * @return string DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration. + */ + public function getCharsetFieldDeclaration($charset) + { + return 'CHARACTER SET ' . $charset; + } + + /** + * Obtain DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $collation name of the collation + * @return string DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration. + */ + public function getCollationFieldDeclaration($collation) + { + return 'COLLATE ' . $collation; + } + + /** + * Obtain DBMS specific SQL code portion needed to declare an integer type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param string $field associative array with the name of the properties + * of the field being declared as array indexes. + * Currently, the types of supported field + * properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field + * should be declared as unsigned integer if + * possible. + * + * default + * Integer value to be used as default for this + * field. + * + * notnull + * Boolean flag that indicates whether this field is + * constrained to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getIntegerDeclaration($name, $field) + { + $default = $autoinc = ''; + if ( ! empty($field['autoincrement'])) { + $autoinc = ' AUTO_INCREMENT'; + } elseif (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) ? null : 0; + } + + $default = ' DEFAULT ' . (is_null($field['default']) + ? 'NULL' + : $this->conn->quote($field['default'])); + } + /** + elseif (empty($field['notnull'])) { + $default = ' DEFAULT NULL'; + } + */ + + $notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : ''; + $unsigned = (isset($field['unsigned']) && $field['unsigned']) ? ' UNSIGNED' : ''; + $comment = (isset($field['comment']) && $field['comment']) + ? " COMMENT '" . $field['comment'] . "'" : ''; + + $name = $this->conn->quoteIdentifier($name, true); + + return $name . ' ' . $this->getNativeDeclaration($field) . $unsigned + . $default . $notnull . $autoinc . $comment; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Oracle.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Oracle.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,201 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Oracle extends Doctrine_DataDict +{ + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration(array $field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + switch ($field['type']) { + case 'enum': + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + case 'string': + case 'array': + case 'object': + case 'gzip': + case 'char': + case 'varchar': + $length = !empty($field['length']) ? $field['length'] : false; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + if ($length && $length <= $this->conn->varchar2_max_length) { + return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; + } + case 'clob': + return 'CLOB'; + case 'blob': + return 'BLOB'; + case 'integer': + case 'int': + if ( ! empty($field['length']) && $field['length'] <= $this->conn->number_max_precision) { + return 'NUMBER('.$field['length'].')'; + } + return 'INT'; + case 'boolean': + return 'NUMBER(1)'; + case 'date': + case 'time': + case 'timestamp': + return 'DATE'; + case 'float': + case 'double': + return 'NUMBER'; + case 'decimal': + $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); + return 'NUMBER(*,'.$scale.')'; + default: + } + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } + + /** + * Maps a native array description of a field to a doctrine datatype and length + * + * @param array $field native field description + * @return array containing the various possible types, length, sign, fixed + * @throws Doctrine_DataDict_Oracle_Exception + */ + public function getPortableDeclaration(array $field) + { + if ( ! isset($field['data_type'])) { + throw new Doctrine_DataDict_Exception('Native oracle definition must have a data_type key specified'); + } + + $dbType = strtolower($field['data_type']); + $type = array(); + $length = $unsigned = $fixed = null; + if ( ! empty($field['data_length'])) { + $length = $field['data_length']; + } + + if ( ! isset($field['column_name'])) { + $field['column_name'] = ''; + } + + switch ($dbType) { + case 'integer': + case 'pls_integer': + case 'binary_integer': + $type[] = 'integer'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['column_name'])) { + $type = array_reverse($type); + } + } + break; + case 'varchar': + case 'varchar2': + case 'nvarchar2': + $fixed = false; + case 'char': + case 'nchar': + $type[] = 'string'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['column_name'])) { + $type = array_reverse($type); + } + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'date': + case 'timestamp': + $type[] = 'timestamp'; + $length = null; + break; + case 'float': + $type[] = 'float'; + break; + case 'number': + if ( ! empty($field['data_scale'])) { + $type[] = 'decimal'; + } else { + $type[] = 'integer'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['column_name'])) { + $type = array_reverse($type); + } + } + } + break; + case 'long': + $type[] = 'string'; + case 'clob': + case 'nclob': + $type[] = 'clob'; + break; + case 'blob': + case 'raw': + case 'long raw': + case 'bfile': + $type[] = 'blob'; + $length = null; + break; + case 'rowid': + case 'urowid': + default: + throw new Doctrine_DataDict_Exception('unknown database attribute type: ' . $dbType); + } + + return array('type' => $type, + 'length' => $length, + 'unsigned' => $unsigned, + 'fixed' => $fixed); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Pgsql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Pgsql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,655 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Paul Cooper + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Pgsql extends Doctrine_DataDict +{ + /** + * @param array $reservedKeyWords an array of reserved keywords by pgsql + */ + protected static $reservedKeyWords = array( + 'abort', + 'absolute', + 'access', + 'action', + 'add', + 'after', + 'aggregate', + 'all', + 'alter', + 'analyse', + 'analyze', + 'and', + 'any', + 'as', + 'asc', + 'assertion', + 'assignment', + 'at', + 'authorization', + 'backward', + 'before', + 'begin', + 'between', + 'bigint', + 'binary', + 'bit', + 'boolean', + 'both', + 'by', + 'cache', + 'called', + 'cascade', + 'case', + 'cast', + 'chain', + 'char', + 'character', + 'characteristics', + 'check', + 'checkpoint', + 'class', + 'close', + 'cluster', + 'coalesce', + 'collate', + 'column', + 'comment', + 'commit', + 'committed', + 'constraint', + 'constraints', + 'conversion', + 'convert', + 'copy', + 'create', + 'createdb', + 'createuser', + 'cross', + 'current_date', + 'current_time', + 'current_timestamp', + 'current_user', + 'cursor', + 'cycle', + 'database', + 'day', + 'deallocate', + 'dec', + 'decimal', + 'declare', + 'default', + 'deferrable', + 'deferred', + 'definer', + 'delete', + 'delimiter', + 'delimiters', + 'desc', + 'distinct', + 'do', + 'domain', + 'double', + 'drop', + 'each', + 'else', + 'encoding', + 'encrypted', + 'end', + 'escape', + 'except', + 'exclusive', + 'execute', + 'exists', + 'explain', + 'external', + 'extract', + 'false', + 'fetch', + 'float', + 'for', + 'force', + 'foreign', + 'forward', + 'freeze', + 'from', + 'full', + 'function', + 'get', + 'global', + 'grant', + 'group', + 'handler', + 'having', + 'hour', + 'ilike', + 'immediate', + 'immutable', + 'implicit', + 'in', + 'increment', + 'index', + 'inherits', + 'initially', + 'inner', + 'inout', + 'input', + 'insensitive', + 'insert', + 'instead', + 'int', + 'integer', + 'intersect', + 'interval', + 'into', + 'invoker', + 'is', + 'isnull', + 'isolation', + 'join', + 'key', + 'lancompiler', + 'language', + 'leading', + 'left', + 'level', + 'like', + 'limit', + 'listen', + 'load', + 'local', + 'localtime', + 'localtimestamp', + 'location', + 'lock', + 'match', + 'maxvalue', + 'minute', + 'minvalue', + 'mode', + 'month', + 'move', + 'names', + 'national', + 'natural', + 'nchar', + 'new', + 'next', + 'no', + 'nocreatedb', + 'nocreateuser', + 'none', + 'not', + 'nothing', + 'notify', + 'notnull', + 'null', + 'nullif', + 'numeric', + 'of', + 'off', + 'offset', + 'oids', + 'old', + 'on', + 'only', + 'operator', + 'option', + 'or', + 'order', + 'out', + 'outer', + 'overlaps', + 'overlay', + 'owner', + 'partial', + 'password', + 'path', + 'pendant', + 'placing', + 'position', + 'precision', + 'prepare', + 'primary', + 'prior', + 'privileges', + 'procedural', + 'procedure', + 'read', + 'real', + 'recheck', + 'references', + 'reindex', + 'relative', + 'rename', + 'replace', + 'reset', + 'restrict', + 'returns', + 'revoke', + 'right', + 'rollback', + 'row', + 'rule', + 'schema', + 'scroll', + 'second', + 'security', + 'select', + 'sequence', + 'serializable', + 'session', + 'session_user', + 'set', + 'setof', + 'share', + 'show', + 'similar', + 'simple', + 'smallint', + 'some', + 'stable', + 'start', + 'statement', + 'statistics', + 'stdin', + 'stdout', + 'storage', + 'strict', + 'substring', + 'sysid', + 'table', + 'temp', + 'template', + 'temporary', + 'then', + 'time', + 'timestamp', + 'to', + 'toast', + 'trailing', + 'transaction', + 'treat', + 'trigger', + 'trim', + 'true', + 'truncate', + 'trusted', + 'type', + 'unencrypted', + 'union', + 'unique', + 'unknown', + 'unlisten', + 'until', + 'update', + 'usage', + 'user', + 'using', + 'vacuum', + 'valid', + 'validator', + 'values', + 'varchar', + 'varying', + 'verbose', + 'version', + 'view', + 'volatile', + 'when', + 'where', + 'with', + 'without', + 'work', + 'write', + 'year', + 'zone' + ); + + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration(array $field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + switch ($field['type']) { + case 'enum': + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + case 'char': + case 'string': + case 'array': + case 'object': + case 'varchar': + case 'gzip': + // TODO: what is the maximum VARCHAR length in pgsql ? + $length = (isset($field['length']) && $field['length'] && $field['length'] < 10000) ? $field['length'] : null; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR('.$this->conn->options['default_text_field_length'].')') + : ($length ? 'VARCHAR(' .$length . ')' : 'TEXT'); + + case 'clob': + return 'TEXT'; + case 'blob': + return 'BYTEA'; + case 'integer': + case 'int': + if ( ! empty($field['autoincrement'])) { + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length > 4) { + return 'BIGSERIAL'; + } + } + return 'SERIAL'; + } + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 2) { + return 'SMALLINT'; + } elseif ($length == 3 || $length == 4) { + return 'INT'; + } elseif ($length > 4) { + return 'BIGINT'; + } + } + return 'INT'; + case 'inet': + return 'INET'; + case 'bit': + case 'varbit': + return 'VARBIT'; + case 'boolean': + return 'BOOLEAN'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME without time zone'; + case 'timestamp': + return 'TIMESTAMP without time zone'; + case 'float': + case 'double': + return 'FLOAT'; + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); + return 'NUMERIC('.$length.','.$scale.')'; + } + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } + + /** + * Maps a native array description of a field to a portable Doctrine datatype and length + * + * @param array $field native field description + * + * @return array containing the various possible types, length, sign, fixed + */ + public function getPortableDeclaration(array $field) + { + + $length = (isset($field['length'])) ? $field['length'] : null; + if ($length == '-1' && isset($field['atttypmod'])) { + $length = $field['atttypmod'] - 4; + } + if ((int)$length <= 0) { + $length = null; + } + $type = array(); + $unsigned = $fixed = null; + + if ( ! isset($field['name'])) { + $field['name'] = ''; + } + + $dbType = strtolower($field['type']); + + switch ($dbType) { + case 'inet': + $type[] = 'inet'; + break; + case 'bit': + case 'varbit': + $type[] = 'bit'; + break; + case 'smallint': + case 'int2': + $type[] = 'integer'; + $unsigned = false; + $length = 2; + if ($length == '2') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } + break; + case 'int': + case 'int4': + case 'integer': + case 'serial': + case 'serial4': + $type[] = 'integer'; + $unsigned = false; + $length = 4; + break; + case 'bigint': + case 'int8': + case 'bigserial': + case 'serial8': + $type[] = 'integer'; + $unsigned = false; + $length = 8; + break; + case 'bool': + case 'boolean': + $type[] = 'boolean'; + $length = 1; + break; + case 'text': + case 'varchar': + case 'interval': + case '_varchar': + $fixed = false; + case 'tsvector': + case 'unknown': + case 'char': + case 'bpchar': + $type[] = 'string'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($dbType, 'text')) { + $type[] = 'clob'; + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'date': + $type[] = 'date'; + $length = null; + break; + case 'datetime': + case 'timestamp': + case 'timetz': + case 'timestamptz': + $type[] = 'timestamp'; + $length = null; + break; + case 'time': + $type[] = 'time'; + $length = null; + break; + case 'float': + case 'float4': + case 'float8': + case 'double': + case 'double precision': + case 'real': + $type[] = 'float'; + break; + case 'decimal': + case 'money': + case 'numeric': + $type[] = 'decimal'; + break; + case 'tinyblob': + case 'mediumblob': + case 'longblob': + case 'blob': + case 'bytea': + case 'geometry': + case 'geometrycollection': + case 'point': + case 'multipoint': + case 'linestring': + case 'multilinestring': + case 'polygon': + case 'multipolygon': + $type[] = 'blob'; + $length = null; + break; + case 'oid': + $type[] = 'blob'; + $type[] = 'clob'; + $length = null; + break; + case 'year': + $type[] = 'integer'; + $type[] = 'date'; + $length = null; + break; + default: + throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType); + } + + return array('type' => $type, + 'length' => $length, + 'unsigned' => $unsigned, + 'fixed' => $fixed); + } + + /** + * Obtain DBMS specific SQL code portion needed to declare an integer type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field should be + * declared as unsigned integer if possible. + * + * default + * Integer value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getIntegerDeclaration($name, $field) + { + /** + if ( ! empty($field['unsigned'])) { + $this->conn->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer"; + } + */ + + if ( ! empty($field['autoincrement'])) { + $name = $this->conn->quoteIdentifier($name, true); + return $name . ' ' . $this->getNativeDeclaration($field); + } + + $default = ''; + if (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) ? null : 0; + } + + $default = ' DEFAULT ' . (is_null($field['default']) + ? 'NULL' + : $this->conn->quote($field['default'], $field['type'])); + } + /** + TODO: is this needed ? + elseif (empty($field['notnull'])) { + $default = ' DEFAULT NULL'; + } + */ + + $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; + $name = $this->conn->quoteIdentifier($name, true); + return $name . ' ' . $this->getNativeDeclaration($field) . $default . $notnull; + } + + /** + * parseBoolean + * parses a literal boolean value and returns + * proper sql equivalent + * + * @param string $value boolean value to be parsed + * @return string parsed boolean value + */ + public function parseBoolean($value) + { + return $value; + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Sqlite.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Sqlite.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,320 @@ +. + */ + +/** + * @package Doctrine + * @subpackage DataDict + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @version $Revision: 5801 $ + * @link www.phpdoctrine.org + * @since 1.0 + */ +class Doctrine_DataDict_Sqlite extends Doctrine_DataDict +{ + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * @author Lukas Smith (PEAR MDB2 library) + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getNativeDeclaration(array $field) + { + if ( ! isset($field['type'])) { + throw new Doctrine_DataDict_Exception('Missing column type.'); + } + switch ($field['type']) { + case 'enum': + $field['length'] = isset($field['length']) && $field['length'] ? $field['length']:255; + case 'text': + case 'object': + case 'array': + case 'string': + case 'char': + case 'gzip': + case 'varchar': + $length = (isset($field['length']) && $field['length']) ? $field['length'] : null; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TEXTFLD_LENGTH).')') + : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); + case 'clob': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYTEXT'; + } elseif ($length <= 65535) { + return 'TEXT'; + } elseif ($length <= 16777215) { + return 'MEDIUMTEXT'; + } + } + return 'LONGTEXT'; + case 'blob': + if ( ! empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYBLOB'; + } elseif ($length <= 65535) { + return 'BLOB'; + } elseif ($length <= 16777215) { + return 'MEDIUMBLOB'; + } + } + return 'LONGBLOB'; + case 'integer': + case 'boolean': + case 'int': + return 'INTEGER'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME'; + case 'timestamp': + return 'DATETIME'; + case 'float': + case 'double': + return 'DOUBLE';//($this->conn->options['fixed_float'] ? '('. + //($this->conn->options['fixed_float']+2).','.$this->conn->options['fixed_float'].')' : ''); + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); + return 'DECIMAL('.$length.','.$scale.')'; + } + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); + } + + /** + * Maps a native array description of a field to Doctrine datatype and length + * + * @param array $field native field description + * @return array containing the various possible types, length, sign, fixed + */ + public function getPortableDeclaration(array $field) + { + $e = explode('(', $field['type']); + $field['type'] = $e[0]; + if (isset($e[1])) { + $length = trim($e[1], ')'); + $field['length'] = $length; + } + + $dbType = strtolower($field['type']); + + if ( ! $dbType) { + throw new Doctrine_DataDict_Exception('Missing "type" from field definition'); + } + + $length = (isset($field['length'])) ? $field['length'] : null; + $unsigned = (isset($field['unsigned'])) ? $field['unsigned'] : null; + $fixed = null; + $type = array(); + + if ( ! isset($field['name'])) { + $field['name'] = ''; + } + + switch ($dbType) { + case 'boolean': + $type[] = 'boolean'; + break; + case 'tinyint': + $type[] = 'integer'; + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 1; + break; + case 'smallint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 2; + break; + case 'mediumint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 3; + break; + case 'int': + case 'integer': + case 'serial': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 4; + break; + case 'bigint': + case 'bigserial': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 8; + break; + case 'clob': + case 'tinytext': + case 'mediumtext': + case 'longtext': + case 'text': + case 'varchar': + case 'varchar2': + case 'nvarchar': + case 'ntext': + case 'image': + case 'nchar': + $fixed = false; + case 'char': + $type[] = 'text'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($dbType, 'text')) { + $type[] = 'clob'; + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'date': + $type[] = 'date'; + $length = null; + break; + case 'datetime': + case 'timestamp': + $type[] = 'timestamp'; + $length = null; + break; + case 'time': + $type[] = 'time'; + $length = null; + break; + case 'float': + case 'double': + case 'real': + $type[] = 'float'; + $length = null; + break; + case 'decimal': + case 'numeric': + $type[] = 'decimal'; + $length = null; + break; + case 'tinyblob': + case 'mediumblob': + case 'longblob': + case 'blob': + $type[] = 'blob'; + $length = null; + break; + case 'year': + $type[] = 'integer'; + $type[] = 'date'; + $length = null; + break; + default: + throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType); + } + + return array('type' => $type, + 'length' => $length, + 'unsigned' => $unsigned, + 'fixed' => $fixed); + } + + /** + * Obtain DBMS specific SQL code portion needed to declare an integer type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. + * Currently, the types of supported field + * properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field + * should be declared as unsigned integer if + * possible. + * + * default + * Integer value to be used as default for this + * field. + * + * notnull + * Boolean flag that indicates whether this field is + * constrained to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + * @access protected + */ + public function getIntegerDeclaration($name, array $field) + { + $default = $autoinc = ''; + $type = $this->getNativeDeclaration($field); + + $autoincrement = isset($field['autoincrement']) && $field['autoincrement']; + + if ($autoincrement) { + $autoinc = ' PRIMARY KEY AUTOINCREMENT'; + $type = 'INTEGER'; + } elseif (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) ? null : 0; + } + + $default = ' DEFAULT ' . (is_null($field['default']) + ? 'NULL' + : $this->conn->quote($field['default'], $field['type'])); + }/** + elseif (empty($field['notnull'])) { + $default = ' DEFAULT NULL'; + } + */ + + $notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : ''; + + // sqlite does not support unsigned attribute for autoinremented fields + $unsigned = (isset($field['unsigned']) && $field['unsigned'] && !$autoincrement) ? ' UNSIGNED' : ''; + + $name = $this->conn->quoteIdentifier($name, true); + return $name . ' ' . $type . $unsigned . $default . $notnull . $autoinc; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataType.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataType.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,49 @@ +. + */ + +/** + * Doctrine_DataType + * + * @package Doctrine + * @subpackage DataType + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 1986 $ + * @author Konsta Vesterinen + */ +class Doctrine_DataType +{ + public function __construct() + { + + } + + public function getName() + { + + } + + public function getDefaultLength() + { + + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Event.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Event.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,354 @@ +. + */ + +/** + * Doctrine_Event + * + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @package Doctrine + * @subpackage Event + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Event +{ + /** + * CONNECTION EVENT CODES + */ + const CONN_QUERY = 1; + const CONN_EXEC = 2; + const CONN_PREPARE = 3; + const CONN_CONNECT = 4; + const CONN_CLOSE = 5; + const CONN_ERROR = 6; + + const STMT_EXECUTE = 10; + const STMT_FETCH = 11; + const STMT_FETCHALL = 12; + + const TX_BEGIN = 31; + const TX_COMMIT = 32; + const TX_ROLLBACK = 33; + const SAVEPOINT_CREATE = 34; + const SAVEPOINT_ROLLBACK = 35; + const SAVEPOINT_COMMIT = 36; + + const HYDRATE = 40; + + /* + * RECORD EVENT CODES + */ + const RECORD_DELETE = 21; + const RECORD_SAVE = 22; + const RECORD_UPDATE = 23; + const RECORD_INSERT = 24; + const RECORD_SERIALIZE = 25; + const RECORD_UNSERIALIZE = 26; + const RECORD_DQL_DELETE = 27; + const RECORD_DQL_SELECT = 28; + const RECORD_DQL_UPDATE = 29; + const RECORD_VALIDATE = 30; + + /** + * @var mixed $_invoker the handler which invoked this event + */ + protected $_invoker; + + /** + * @var string $_query the sql query associated with this event (if any) + */ + protected $_query; + + /** + * @var string $_params the parameters associated with the query (if any) + */ + protected $_params; + + /** + * @see Doctrine_Event constants + * @var integer $_code the event code + */ + protected $_code; + + /** + * @var integer $_startedMicrotime the time point in which this event was started + */ + protected $_startedMicrotime; + + /** + * @var integer $_endedMicrotime the time point in which this event was ended + */ + protected $_endedMicrotime; + + /** + * @var array $_options an array of options + */ + protected $_options = array(); + + /** + * constructor + * + * @param Doctrine_Connection|Doctrine_Connection_Statement| + Doctrine_Connection_UnitOfWork|Doctrine_Transaction $invoker the handler which invoked this event + * @param integer $code the event code + * @param string $query the sql query associated with this event (if any) + */ + public function __construct($invoker, $code, $query = null, $params = array()) + { + $this->_invoker = $invoker; + $this->_code = $code; + $this->_query = $query; + $this->_params = $params; + } + + /** + * getQuery + * + * @return Doctrine_Query returns the query associated with this event (if any) + */ + public function getQuery() + { + return $this->_query; + } + + /** + * getName + * returns the name of this event + * + * @return string the name of this event + */ + public function getName() + { + switch ($this->_code) { + case self::CONN_QUERY: + return 'query'; + case self::CONN_EXEC: + return 'exec'; + case self::CONN_PREPARE: + return 'prepare'; + case self::CONN_CONNECT: + return 'connect'; + case self::CONN_CLOSE: + return 'close'; + case self::CONN_ERROR: + return 'error'; + + case self::STMT_EXECUTE: + return 'execute'; + case self::STMT_FETCH: + return 'fetch'; + case self::STMT_FETCHALL: + return 'fetch all'; + + case self::TX_BEGIN: + return 'begin'; + case self::TX_COMMIT: + return 'commit'; + case self::TX_ROLLBACK: + return 'rollback'; + + case self::SAVEPOINT_CREATE: + return 'create savepoint'; + case self::SAVEPOINT_ROLLBACK: + return 'rollback savepoint'; + case self::SAVEPOINT_COMMIT: + return 'commit savepoint'; + + case self::RECORD_DELETE: + return 'delete record'; + case self::RECORD_SAVE: + return 'save record'; + case self::RECORD_UPDATE: + return 'update record'; + case self::RECORD_INSERT: + return 'insert record'; + case self::RECORD_SERIALIZE: + return 'serialize record'; + case self::RECORD_UNSERIALIZE: + return 'unserialize record'; + case self::RECORD_DQL_SELECT: + return 'select records'; + case self::RECORD_DQL_DELETE: + return 'delete records'; + case self::RECORD_DQL_UPDATE: + return 'update records'; + case self::RECORD_VALIDATE: + return 'validate record'; + } + } + + /** + * getCode + * + * @return integer returns the code associated with this event + */ + public function getCode() + { + return $this->_code; + } + + /** + * getOption + * returns the value of an option + * + * @param string $option the name of the option + * @return mixed + */ + public function __get($option) + { + if ( ! isset($this->_options[$option])) { + return null; + } + + return $this->_options[$option]; + } + + /** + * skipOperation + * skips the next operation + * an alias for __set('skipOperation', true) + * + * @return Doctrine_Event this object + */ + public function skipOperation() + { + $this->_options['skipOperation'] = true; + + return $this; + } + + /** + * setOption + * sets the value of an option + * + * @param string $option the name of the option + * @param mixed $value the value of the given option + * @return Doctrine_Event this object + */ + public function __set($option, $value) + { + $this->_options[$option] = $value; + + return $this; + } + + /** + * setOption + * sets the value of an option by reference + * + * @param string $option the name of the option + * @param mixed $value the value of the given option + * @return Doctrine_Event this object + */ + public function set($option, &$value) + { + $this->_options[$option] =& $value; + + return $this; + } + + /** + * start + * starts the internal timer of this event + * + * @return Doctrine_Event this object + */ + public function start() + { + $this->_startedMicrotime = microtime(true); + } + + /** + * hasEnded + * whether or not this event has ended + * + * @return boolean + */ + public function hasEnded() + { + return ($this->_endedMicrotime != null); + } + + /** + * end + * ends the internal timer of this event + * + * @return Doctrine_Event this object + */ + public function end() + { + $this->_endedMicrotime = microtime(true); + + return $this; + } + + /** + * getInvoker + * returns the handler that invoked this event + * + * @return Doctrine_Connection|Doctrine_Connection_Statement| + * Doctrine_Connection_UnitOfWork|Doctrine_Transaction the handler that invoked this event + */ + public function getInvoker() + { + return $this->_invoker; + } + + /** + * setInvoker + * Defines new invoker (used in Hydrator) + * + * @param mixed $invoker + * @return void + */ + public function setInvoker($invoker) + { + $this->_invoker = $invoker; + } + + + /** + * getParams + * returns the parameters of the query + * + * @return array parameters of the query + */ + public function getParams() + { + return $this->_params; + } + + /** + * Get the elapsed time (in microseconds) that the event ran. If the event has + * not yet ended, return false. + * + * @return mixed + */ + public function getElapsedSecs() + { + if (is_null($this->_endedMicrotime)) { + return false; + } + return ($this->_endedMicrotime - $this->_startedMicrotime); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,119 @@ +. + */ + +/** + * Doctrine_EventListener all event listeners extend this base class + * the empty methods allow child classes to only implement the methods they need to implement + * + * @author Konsta Vesterinen + * @package Doctrine + * @subpackage EventListener + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_EventListener implements Doctrine_EventListener_Interface +{ + public function preClose(Doctrine_Event $event) + { } + public function postClose(Doctrine_Event $event) + { } + + public function onCollectionDelete(Doctrine_Collection $collection) + { } + public function onPreCollectionDelete(Doctrine_Collection $collection) + { } + + public function onOpen(Doctrine_Connection $connection) + { } + + public function preTransactionCommit(Doctrine_Event $event) + { } + public function postTransactionCommit(Doctrine_Event $event) + { } + + public function preTransactionRollback(Doctrine_Event $event) + { } + public function postTransactionRollback(Doctrine_Event $event) + { } + + public function preTransactionBegin(Doctrine_Event $event) + { } + public function postTransactionBegin(Doctrine_Event $event) + { } + + + public function preSavepointCommit(Doctrine_Event $event) + { } + public function postSavepointCommit(Doctrine_Event $event) + { } + + public function preSavepointRollback(Doctrine_Event $event) + { } + public function postSavepointRollback(Doctrine_Event $event) + { } + + public function preSavepointCreate(Doctrine_Event $event) + { } + public function postSavepointCreate(Doctrine_Event $event) + { } + + public function postConnect(Doctrine_Event $event) + { } + public function preConnect(Doctrine_Event $event) + { } + + public function preQuery(Doctrine_Event $event) + { } + public function postQuery(Doctrine_Event $event) + { } + + public function prePrepare(Doctrine_Event $event) + { } + public function postPrepare(Doctrine_Event $event) + { } + + public function preExec(Doctrine_Event $event) + { } + public function postExec(Doctrine_Event $event) + { } + + public function preError(Doctrine_Event $event) + { } + public function postError(Doctrine_Event $event) + { } + + public function preFetch(Doctrine_Event $event) + { } + public function postFetch(Doctrine_Event $event) + { } + + public function preFetchAll(Doctrine_Event $event) + { } + public function postFetchAll(Doctrine_Event $event) + { } + + public function preStmtExecute(Doctrine_Event $event) + { } + public function postStmtExecute(Doctrine_Event $event) + { } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Chain.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Chain.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,405 @@ +. + */ + +/** + * Doctrine_EventListener_Chain + * this class represents a chain of different listeners, + * useful for having multiple listeners listening the events at the same time + * + * @author Konsta Vesterinen + * @package Doctrine + * @subpackage EventListener + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_EventListener_Interface +{ + /** + * @var array $listeners an array containing all listeners + */ + protected $_listeners = array(); + + /** + * add + * adds a listener to the chain of listeners + * + * @param object $listener + * @param string $name + * @return void + */ + public function add($listener, $name = null) + { + if ( ! ($listener instanceof Doctrine_EventListener_Interface) && + ! ($listener instanceof Doctrine_Overloadable)) { + + throw new Doctrine_EventListener_Exception("Couldn't add eventlistener. EventListeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable"); + } + if ($name === null) { + $this->_listeners[] = $listener; + } else { + $this->_listeners[$name] = $listener; + } + } + + /** + * returns a Doctrine_EventListener on success + * and null on failure + * + * @param mixed $key + * @return mixed + */ + public function get($key) + { + if ( ! isset($this->_listeners[$key])) { + return null; + } + return $this->_listeners[$key]; + } + + /** + * set + * + * @param mixed $key + * @param Doctrine_EventListener $listener + * @return void + */ + public function set($key, $listener) + { + $this->_listeners[$key] = $listener; + } + + /** + * onLoad + * an event invoked when Doctrine_Record is being loaded from database + * + * @param Doctrine_Record $record + * @return void + */ + public function onLoad(Doctrine_Record $record) + { + foreach ($this->_listeners as $listener) { + $listener->onLoad($record); + } + } + + /** + * onPreLoad + * an event invoked when Doctrine_Record is being loaded + * from database but not yet initialized + * + * @param Doctrine_Record $record + * @return void + */ + public function onPreLoad(Doctrine_Record $record) + { + foreach ($this->_listeners as $listener) { + $listener->onPreLoad($record); + } + } + + /** + * onSleep + * an event invoked when Doctrine_Record is serialized + * + * @param Doctrine_Record $record + * @return void + */ + public function onSleep(Doctrine_Record $record) + { + foreach ($this->_listeners as $listener) { + $listener->onSleep($record); + } + } + + /** + * onWakeUp + * an event invoked when Doctrine_Record is unserialized + * + * @param Doctrine_Record $record + * @return void + */ + public function onWakeUp(Doctrine_Record $record) + { + foreach ($this->_listeners as $listener) { + $listener->onWakeUp($record); + } + } + + /** + * postClose + * an event invoked after Doctrine_Connection is closed + * + * @param Doctrine_Event $event + * @return void + */ + public function postClose(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postClose($event); + } + } + + /** + * preClose + * an event invoked before Doctrine_Connection is closed + * + * @param Doctrine_Event $event + * @return void + */ + public function preClose(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preClose($event); + } + } + + /** + * onOpen + * an event invoked after Doctrine_Connection is opened + * + * @param Doctrine_Connection $connection + * @return void + */ + public function onOpen(Doctrine_Connection $connection) + { + foreach ($this->_listeners as $listener) { + $listener->onOpen($connection); + } + } + + /** + * onTransactionCommit + * an event invoked after a Doctrine_Connection transaction is committed + * + * @param Doctrine_Event $event + * @return void + */ + public function postTransactionCommit(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postTransactionCommit($event); + } + } + + /** + * onPreTransactionCommit + * an event invoked before a Doctrine_Connection transaction is committed + * + * @param Doctrine_Event $event + * @return void + */ + public function preTransactionCommit(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preTransactionCommit($event); + } + } + + /** + * onTransactionRollback + * an event invoked after a Doctrine_Connection transaction is being rolled back + * + * @param Doctrine_Event $event + * @return void + */ + public function postTransactionRollback(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postTransactionRollback($event); + } + } + + /** + * onPreTransactionRollback + * an event invoked before a Doctrine_Connection transaction is being rolled back + * + * @param Doctrine_Event $event + * @return void + */ + public function preTransactionRollback(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preTransactionRollback($event); + } + } + + /** + * onTransactionBegin + * an event invoked after a Doctrine_Connection transaction has been started + * + * @param Doctrine_Event $event + * @return void + */ + public function postTransactionBegin(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postTransactionBegin($event); + } + } + + /** + * onTransactionBegin + * an event invoked before a Doctrine_Connection transaction is being started + * + * @param Doctrine_Event $event + * @return void + */ + public function preTransactionBegin(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preTransactionBegin($event); + } + } + + /** + * onCollectionDelete + * an event invoked after a Doctrine_Collection is being deleted + * + * @param Doctrine_Collection $collection + * @return void + */ + public function onCollectionDelete(Doctrine_Collection $collection) + { + foreach ($this->_listeners as $listener) { + $listener->onCollectionDelete($collection); + } + } + + /** + * onCollectionDelete + * an event invoked after a Doctrine_Collection is being deleted + * + * @param Doctrine_Collection $collection + * @return void + */ + public function onPreCollectionDelete(Doctrine_Collection $collection) + { + foreach ($this->_listeners as $listener) { + $listener->onPreCollectionDelete($collection); + } + } + public function postConnect(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postConnect($event); + } + } + public function preConnect(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preConnect($event); + } + } + public function preQuery(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preQuery($event); + } + } + public function postQuery(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postQuery($event); + } + } + + public function prePrepare(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->prePrepare($event); + } + } + public function postPrepare(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postPrepare($event); + } + } + + public function preExec(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preExec($event); + } + } + public function postExec(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postExec($event); + } + } + + public function preError(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preError($event); + } + } + public function postError(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postError($event); + } + } + + public function preFetch(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preFetch($event); + } + } + public function postFetch(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postFetch($event); + } + } + + public function preFetchAll(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preFetchAll($event); + } + } + + public function postFetchAll(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postFetchAll($event); + } + } + + public function preStmtExecute(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->preStmtExecute($event); + } + } + + public function postStmtExecute(Doctrine_Event $event) + { + foreach ($this->_listeners as $listener) { + $listener->postStmtExecute($event); + } + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_EventListener_Exception + * + * @package Doctrine + * @subpackage EventListener + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 1344 $ + * @author Konsta Vesterinen + */ +class Doctrine_EventListener_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Interface.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Interface.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,68 @@ +. + */ + +/** + * Doctrine_EventListener all event listeners extend this base class + * the empty methods allow child classes to only implement the methods they need to implement + * + * @author Konsta Vesterinen + * @package Doctrine + * @subpackage EventListener + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +interface Doctrine_EventListener_Interface +{ + public function preTransactionCommit(Doctrine_Event $event); + public function postTransactionCommit(Doctrine_Event $event); + + public function preTransactionRollback(Doctrine_Event $event); + public function postTransactionRollback(Doctrine_Event $event); + + public function preTransactionBegin(Doctrine_Event $event); + public function postTransactionBegin(Doctrine_Event $event); + + public function postConnect(Doctrine_Event $event); + public function preConnect(Doctrine_Event $event); + + public function preQuery(Doctrine_Event $event); + public function postQuery(Doctrine_Event $event); + + public function prePrepare(Doctrine_Event $event); + public function postPrepare(Doctrine_Event $event); + + public function preExec(Doctrine_Event $event); + public function postExec(Doctrine_Event $event); + + public function preError(Doctrine_Event $event); + public function postError(Doctrine_Event $event); + + public function preFetch(Doctrine_Event $event); + public function postFetch(Doctrine_Event $event); + + public function preFetchAll(Doctrine_Event $event); + public function postFetchAll(Doctrine_Event $event); + + public function preStmtExecute(Doctrine_Event $event); + public function postStmtExecute(Doctrine_Event $event); +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,92 @@ +. + */ + +/** + * Doctrine_Exception + * + * @package Doctrine + * @subpackage Exception + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Exception extends Exception +{ + /** + * @var array $_errorMessages an array of error messages + */ + protected static $_errorMessages = array( + Doctrine::ERR => 'unknown error', + Doctrine::ERR_ALREADY_EXISTS => 'already exists', + Doctrine::ERR_CANNOT_CREATE => 'can not create', + Doctrine::ERR_CANNOT_ALTER => 'can not alter', + Doctrine::ERR_CANNOT_REPLACE => 'can not replace', + Doctrine::ERR_CANNOT_DELETE => 'can not delete', + Doctrine::ERR_CANNOT_DROP => 'can not drop', + Doctrine::ERR_CONSTRAINT => 'constraint violation', + Doctrine::ERR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint', + Doctrine::ERR_DIVZERO => 'division by zero', + Doctrine::ERR_INVALID => 'invalid', + Doctrine::ERR_INVALID_DATE => 'invalid date or time', + Doctrine::ERR_INVALID_NUMBER => 'invalid number', + Doctrine::ERR_MISMATCH => 'mismatch', + Doctrine::ERR_NODBSELECTED => 'no database selected', + Doctrine::ERR_NOSUCHFIELD => 'no such field', + Doctrine::ERR_NOSUCHTABLE => 'no such table', + Doctrine::ERR_NOT_CAPABLE => 'Doctrine backend not capable', + Doctrine::ERR_NOT_FOUND => 'not found', + Doctrine::ERR_NOT_LOCKED => 'not locked', + Doctrine::ERR_SYNTAX => 'syntax error', + Doctrine::ERR_UNSUPPORTED => 'not supported', + Doctrine::ERR_VALUE_COUNT_ON_ROW => 'value count on row', + Doctrine::ERR_INVALID_DSN => 'invalid DSN', + Doctrine::ERR_CONNECT_FAILED => 'connect failed', + Doctrine::ERR_NEED_MORE_DATA => 'insufficient data supplied', + Doctrine::ERR_EXTENSION_NOT_FOUND=> 'extension not found', + Doctrine::ERR_NOSUCHDB => 'no such database', + Doctrine::ERR_ACCESS_VIOLATION => 'insufficient permissions', + Doctrine::ERR_LOADMODULE => 'error while including on demand module', + Doctrine::ERR_TRUNCATED => 'truncated', + Doctrine::ERR_DEADLOCK => 'deadlock detected', + ); + + /** + * Return a textual error message for a Doctrine error code + * + * @param int|array integer error code, + * null to get the current error code-message map, + * or an array with a new error code-message map + * + * @return string error message + */ + public function errorMessage($value = null) + { + if (is_null($value)) { + return self::$_errorMessages; + } + + return isset(self::$_errorMessages[$value]) ? + self::$_errorMessages[$value] : self::$_errorMessages[Doctrine::ERR]; + } + +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,1377 @@ +. + */ + +/** + * Doctrine_Export + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export extends Doctrine_Connection_Module +{ + protected $valid_default_values = array( + 'text' => '', + 'boolean' => true, + 'integer' => 0, + 'decimal' => 0.0, + 'float' => 0.0, + 'timestamp' => '1970-01-01 00:00:00', + 'time' => '00:00:00', + 'date' => '1970-01-01', + 'clob' => '', + 'blob' => '', + 'string' => '' + ); + + /** + * drop an existing database + * (this method is implemented by the drivers) + * + * @param string $name name of the database that should be dropped + * @return void + */ + public function dropDatabase($database) + { + $this->conn->execute($this->dropDatabaseSql($database)); + } + + /** + * drop an existing database + * (this method is implemented by the drivers) + * + * @param string $name name of the database that should be dropped + * @return void + */ + public function dropDatabaseSql($database) + { + throw new Doctrine_Export_Exception('Drop database not supported by this driver.'); + } + + /** + * dropTableSql + * drop an existing table + * + * @param string $table name of table that should be dropped from the database + * @return string + */ + public function dropTableSql($table) + { + return 'DROP TABLE ' . $this->conn->quoteIdentifier($table); + } + + /** + * dropTable + * drop an existing table + * + * @param string $table name of table that should be dropped from the database + * @return void + */ + public function dropTable($table) + { + $this->conn->execute($this->dropTableSql($table)); + } + + /** + * drop existing index + * + * @param string $table name of table that should be used in method + * @param string $name name of the index to be dropped + * @return void + */ + public function dropIndex($table, $name) + { + return $this->conn->exec($this->dropIndexSql($table, $name)); + } + + /** + * dropIndexSql + * + * @param string $table name of table that should be used in method + * @param string $name name of the index to be dropped + * @return string SQL that is used for dropping an index + */ + public function dropIndexSql($table, $name) + { + $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name)); + + return 'DROP INDEX ' . $name; + } + + /** + * drop existing constraint + * + * @param string $table name of table that should be used in method + * @param string $name name of the constraint to be dropped + * @param string $primary hint if the constraint is primary + * @return void + */ + public function dropConstraint($table, $name, $primary = false) + { + $table = $this->conn->quoteIdentifier($table); + $name = $this->conn->quoteIdentifier($name); + + return $this->conn->exec('ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $name); + } + + /** + * drop existing foreign key + * + * @param string $table name of table that should be used in method + * @param string $name name of the foreign key to be dropped + * @return void + */ + public function dropForeignKey($table, $name) + { + return $this->dropConstraint($table, $name); + } + + /** + * dropSequenceSql + * drop existing sequence + * (this method is implemented by the drivers) + * + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $sequenceName name of the sequence to be dropped + * @return void + */ + public function dropSequence($sequenceName) + { + $this->conn->exec($this->dropSequenceSql($sequenceName)); + } + + /** + * dropSequenceSql + * drop existing sequence + * + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $sequenceName name of the sequence to be dropped + * @return void + */ + public function dropSequenceSql($sequenceName) + { + throw new Doctrine_Export_Exception('Drop sequence not supported by this driver.'); + } + + /** + * create a new database + * (this method is implemented by the drivers) + * + * @param string $name name of the database that should be created + * @return void + */ + public function createDatabase($database) + { + $this->conn->execute($this->createDatabaseSql($database)); + } + + /** + * create a new database + * (this method is implemented by the drivers) + * + * @param string $name name of the database that should be created + * @return string + */ + public function createDatabaseSql($database) + { + throw new Doctrine_Export_Exception('Create database not supported by this driver.'); + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * array( + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * 'notnull' => 1 + * 'default' => 0 + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12 + * ), + * 'password' => array( + * 'type' => 'text', + * 'length' => 12 + * ) + * ); + * @param array $options An associative array of table options: + * + * @return string + */ + public function createTableSql($name, array $fields, array $options = array()) + { + if ( ! $name) { + throw new Doctrine_Export_Exception('no valid table name specified'); + } + + if (empty($fields)) { + throw new Doctrine_Export_Exception('no fields specified for table ' . $name); + } + + $queryFields = $this->getFieldDeclarationList($fields); + + + if (isset($options['primary']) && ! empty($options['primary'])) { + $primaryKeys = array_map(array($this->conn, 'quoteIdentifier'), array_values($options['primary'])); + $queryFields .= ', PRIMARY KEY(' . implode(', ', $primaryKeys) . ')'; + } + + if (isset($options['indexes']) && ! empty($options['indexes'])) { + foreach($options['indexes'] as $index => $definition) { + $indexDeclaration = $this->getIndexDeclaration($index, $definition); + // append only created index declarations + if ( ! is_null($indexDeclaration)) { + $queryFields .= ', '.$indexDeclaration; + } + } + } + + $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields; + + $check = $this->getCheckDeclaration($fields); + + if ( ! empty($check)) { + $query .= ', ' . $check; + } + + $query .= ')'; + + $sql[] = $query; + + if (isset($options['foreignKeys'])) { + + foreach ((array) $options['foreignKeys'] as $k => $definition) { + if (is_array($definition)) { + $sql[] = $this->createForeignKeySql($name, $definition); + } + } + } + return $sql; + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * @param array $options An associative array of table options: + * @see Doctrine_Export::createTableSql() + * + * @return void + */ + public function createTable($name, array $fields, array $options = array()) + { + // Build array of the primary keys if any of the individual field definitions + // specify primary => true + $count = 0; + foreach ($fields as $fieldName => $field) { + if (isset($field['primary']) && $field['primary']) { + if ($count == 0) { + $options['primary'] = array(); + } + $count++; + $options['primary'][] = $fieldName; + } + } + + $sql = (array) $this->createTableSql($name, $fields, $options); + + foreach ($sql as $query) { + $this->conn->execute($query); + } + } + + /** + * create sequence + * + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return void + */ + public function createSequence($seqName, $start = 1, array $options = array()) + { + return $this->conn->execute($this->createSequenceSql($seqName, $start = 1, $options)); + } + + /** + * return RDBMS specific create sequence statement + * (this method is implemented by the drivers) + * + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string + */ + public function createSequenceSql($seqName, $start = 1, array $options = array()) + { + throw new Doctrine_Export_Exception('Create sequence not supported by this driver.'); + } + + /** + * create a constraint on a table + * + * @param string $table name of the table on which the constraint is to be created + * @param string $name name of the constraint to be created + * @param array $definition associative array that defines properties of the constraint to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the constraint fields as array + * constraints. Each entry of this array is set to another type of associative + * array that specifies properties of the constraint that are specific to + * each field. + * + * Example + * array( + * 'fields' => array( + * 'user_name' => array(), + * 'last_login' => array() + * ) + * ) + * @return void + */ + public function createConstraint($table, $name, $definition) + { + $sql = $this->createConstraintSql($table, $name, $definition); + + return $this->conn->exec($sql); + } + + /** + * create a constraint on a table + * + * @param string $table name of the table on which the constraint is to be created + * @param string $name name of the constraint to be created + * @param array $definition associative array that defines properties of the constraint to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the constraint fields as array + * constraints. Each entry of this array is set to another type of associative + * array that specifies properties of the constraint that are specific to + * each field. + * + * Example + * array( + * 'fields' => array( + * 'user_name' => array(), + * 'last_login' => array() + * ) + * ) + * @return void + */ + public function createConstraintSql($table, $name, $definition) + { + $table = $this->conn->quoteIdentifier($table); + $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name)); + $query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $name; + + if (isset($definition['primary']) && $definition['primary']) { + $query .= ' PRIMARY KEY'; + } elseif (isset($definition['unique']) && $definition['unique']) { + $query .= ' UNIQUE'; + } + + $fields = array(); + foreach (array_keys($definition['fields']) as $field) { + $fields[] = $this->conn->quoteIdentifier($field, true); + } + $query .= ' ('. implode(', ', $fields) . ')'; + + return $query; + } + + /** + * Get the stucture of a field into an array + * + * @param string $table name of the table on which the index is to be created + * @param string $name name of the index to be created + * @param array $definition associative array that defines properties of the index to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the index fields as array + * indexes. Each entry of this array is set to another type of associative + * array that specifies properties of the index that are specific to + * each field. + * + * Currently, only the sorting property is supported. It should be used + * to define the sorting direction of the index. It may be set to either + * ascending or descending. + * + * Not all DBMS support index sorting direction configuration. The DBMS + * drivers of those that do not support it ignore this property. Use the + * function supports() to determine whether the DBMS driver can manage indexes. + * + * Example + * array( + * 'fields' => array( + * 'user_name' => array( + * 'sorting' => 'ascending' + * ), + * 'last_login' => array() + * ) + * ) + * @return void + */ + public function createIndex($table, $name, array $definition) + { + return $this->conn->execute($this->createIndexSql($table, $name, $definition)); + } + + /** + * Get the stucture of a field into an array + * + * @param string $table name of the table on which the index is to be created + * @param string $name name of the index to be created + * @param array $definition associative array that defines properties of the index to be created. + * @see Doctrine_Export::createIndex() + * @return string + */ + public function createIndexSql($table, $name, array $definition) + { + $table = $this->conn->quoteIdentifier($table); + $name = $this->conn->quoteIdentifier($name); + $type = ''; + + if (isset($definition['type'])) { + switch (strtolower($definition['type'])) { + case 'unique': + $type = strtoupper($definition['type']) . ' '; + break; + default: + throw new Doctrine_Export_Exception( + 'Unknown type ' . $definition['type'] . ' for index ' . $name . ' in table ' . $table + ); + } + } + + $query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table; + + $fields = array(); + foreach ($definition['fields'] as $field) { + $fields[] = $this->conn->quoteIdentifier($field); + } + $query .= ' (' . implode(', ', $fields) . ')'; + + return $query; + } + /** + * createForeignKeySql + * + * @param string $table name of the table on which the foreign key is to be created + * @param array $definition associative array that defines properties of the foreign key to be created. + * @return string + */ + public function createForeignKeySql($table, array $definition) + { + $table = $this->conn->quoteIdentifier($table); + + $query = 'ALTER TABLE ' . $table . ' ADD ' . $this->getForeignKeyDeclaration($definition); + + return $query; + } + + /** + * createForeignKey + * + * @param string $table name of the table on which the foreign key is to be created + * @param array $definition associative array that defines properties of the foreign key to be created. + * @return string + */ + public function createForeignKey($table, array $definition) + { + $sql = $this->createForeignKeySql($table, $definition); + + return $this->conn->execute($sql); + } + + /** + * alter an existing table + * (this method is implemented by the drivers) + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the MDB2 parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the MDB2 parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @return void + */ + public function alterTable($name, array $changes, $check = false) + { + $sql = $this->alterTableSql($name, $changes, $check); + + if (is_string($sql) && $sql) { + $this->conn->execute($sql); + } + } + + /** + * generates the sql for altering an existing table + * (this method is implemented by the drivers) + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @see Doctrine_Export::alterTable() + * @return string + */ + public function alterTableSql($name, array $changes, $check = false) + { + throw new Doctrine_Export_Exception('Alter table not supported by this driver.'); + } + + /** + * Get declaration of a number of field in bulk + * + * @param array $fields a multidimensional associative array. + * The first dimension determines the field name, while the second + * dimension is keyed with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * charset + * Text value with the default CHARACTER SET for this field. + * collation + * Text value with the default COLLATION for this field. + * unique + * unique constraint + * + * @return string + */ + public function getFieldDeclarationList(array $fields) + { + foreach ($fields as $fieldName => $field) { + $query = $this->getDeclaration($fieldName, $field); + + $queryFields[] = $query; + } + return implode(', ', $queryFields); + } + + /** + * Obtain DBMS specific SQL code portion needed to declare a generic type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * + * charset + * Text value with the default CHARACTER SET for this field. + * + * collation + * Text value with the default COLLATION for this field. + * + * unique + * unique constraint + * + * check + * column check constraint + * + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getDeclaration($name, array $field) + { + + $default = $this->getDefaultFieldDeclaration($field); + + $charset = (isset($field['charset']) && $field['charset']) ? + ' ' . $this->getCharsetFieldDeclaration($field['charset']) : ''; + + $collation = (isset($field['collation']) && $field['collation']) ? + ' ' . $this->getCollationFieldDeclaration($field['collation']) : ''; + + $notnull = $this->getNotNullFieldDeclaration($field); + + $unique = (isset($field['unique']) && $field['unique']) ? + ' ' . $this->getUniqueFieldDeclaration() : ''; + + $check = (isset($field['check']) && $field['check']) ? + ' ' . $field['check'] : ''; + + $method = 'get' . $field['type'] . 'Declaration'; + + try { + if (method_exists($this->conn->dataDict, $method)) { + return $this->conn->dataDict->$method($name, $field); + } else { + $dec = $this->conn->dataDict->getNativeDeclaration($field); + } + + return $this->conn->quoteIdentifier($name, true) + . ' ' . $dec . $charset . $default . $notnull . $unique . $check . $collation; + } catch (Exception $e) { + throw new Doctrine_Exception('Around field ' . $name . ': ' . $e->getMessage()); + } + + } + + /** + * getDefaultDeclaration + * Obtain DBMS specific SQL code portion needed to set a default value + * declaration to be used in statements like CREATE TABLE. + * + * @param array $field field definition array + * @return string DBMS specific SQL code portion needed to set a default value + */ + public function getDefaultFieldDeclaration($field) + { + $default = ''; + + if (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) + ? null : $this->valid_default_values[$field['type']]; + + if ($field['default'] === '' && + ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EMPTY_TO_NULL)) { + $field['default'] = null; + } + } + + if ($field['type'] === 'boolean') { + $field['default'] = $this->conn->convertBooleans($field['default']); + } + $default = ' DEFAULT ' . (is_null($field['default']) + ? 'NULL' + : $this->conn->quote($field['default'], $field['type'])); + } + + return $default; + } + + + /** + * getNotNullFieldDeclaration + * Obtain DBMS specific SQL code portion needed to set a NOT NULL + * declaration to be used in statements like CREATE TABLE. + * + * @param array $field field definition array + * @return string DBMS specific SQL code portion needed to set a default value + */ + public function getNotNullFieldDeclaration(array $definition) + { + return (isset($definition['notnull']) && $definition['notnull']) ? ' NOT NULL' : ''; + } + + + /** + * Obtain DBMS specific SQL code portion needed to set a CHECK constraint + * declaration to be used in statements like CREATE TABLE. + * + * @param array $definition check definition + * @return string DBMS specific SQL code portion needed to set a CHECK constraint + */ + public function getCheckDeclaration(array $definition) + { + $constraints = array(); + foreach ($definition as $field => $def) { + if (is_string($def)) { + $constraints[] = 'CHECK (' . $def . ')'; + } else { + if (isset($def['min'])) { + $constraints[] = 'CHECK (' . $field . ' >= ' . $def['min'] . ')'; + } + + if (isset($def['max'])) { + $constraints[] = 'CHECK (' . $field . ' <= ' . $def['max'] . ')'; + } + } + } + + return implode(', ', $constraints); + } + + /** + * Obtain DBMS specific SQL code portion needed to set an index + * declaration to be used in statements like CREATE TABLE. + * + * @param string $name name of the index + * @param array $definition index definition + * @return string DBMS specific SQL code portion needed to set an index + */ + public function getIndexDeclaration($name, array $definition) + { + $name = $this->conn->quoteIdentifier($name); + $type = ''; + + if (isset($definition['type'])) { + if (strtolower($definition['type']) == 'unique') { + $type = strtoupper($definition['type']) . ' '; + } else { + throw new Doctrine_Export_Exception( + 'Unknown type ' . $definition['type'] . ' for index ' . $name + ); + } + } + + if ( ! isset($definition['fields']) || ! is_array($definition['fields'])) { + throw new Doctrine_Export_Exception('No columns given for index ' . $name); + } + + $query = $type . 'INDEX ' . $name; + + $query .= ' (' . $this->getIndexFieldDeclarationList($definition['fields']) . ')'; + + return $query; + } + + /** + * getIndexFieldDeclarationList + * Obtain DBMS specific SQL code portion needed to set an index + * declaration to be used in statements like CREATE TABLE. + * + * @return string + */ + public function getIndexFieldDeclarationList(array $fields) + { + $ret = array(); + foreach ($fields as $field => $definition) { + if (is_array($definition)) { + $ret[] = $this->conn->quoteIdentifier($field); + } else { + $ret[] = $this->conn->quoteIdentifier($definition); + } + } + return implode(', ', $ret); + } + + /** + * A method to return the required SQL string that fits between CREATE ... TABLE + * to create the table as a temporary table. + * + * Should be overridden in driver classes to return the correct string for the + * specific database type. + * + * The default is to return the string "TEMPORARY" - this will result in a + * SQL error for any database that does not support temporary tables, or that + * requires a different SQL command from "CREATE TEMPORARY TABLE". + * + * @return string The string required to be placed between "CREATE" and "TABLE" + * to generate a temporary table, if possible. + */ + public function getTemporaryTableQuery() + { + return 'TEMPORARY'; + } + + /** + * getForeignKeyDeclaration + * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param array $definition an associative array with the following structure: + * name optional constraint name + * + * local the local field(s) + * + * foreign the foreign reference field(s) + * + * foreignTable the name of the foreign table + * + * onDelete referential delete action + * + * onUpdate referential update action + * + * deferred deferred constraint checking + * + * The onDelete and onUpdate keys accept the following values: + * + * CASCADE: Delete or update the row from the parent table and automatically delete or + * update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported. + * Between two tables, you should not define several ON UPDATE CASCADE clauses that act on the same column + * in the parent table or in the child table. + * + * SET NULL: Delete or update the row from the parent table and set the foreign key column or columns in the + * child table to NULL. This is valid only if the foreign key columns do not have the NOT NULL qualifier + * specified. Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported. + * + * NO ACTION: In standard SQL, NO ACTION means no action in the sense that an attempt to delete or update a primary + * key value is not allowed to proceed if there is a related foreign key value in the referenced table. + * + * RESTRICT: Rejects the delete or update operation for the parent table. NO ACTION and RESTRICT are the same as + * omitting the ON DELETE or ON UPDATE clause. + * + * SET DEFAULT + * + * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint + * of a field declaration. + */ + public function getForeignKeyDeclaration(array $definition) + { + $sql = $this->getForeignKeyBaseDeclaration($definition); + $sql .= $this->getAdvancedForeignKeyOptions($definition); + + return $sql; + } + + /** + * getAdvancedForeignKeyOptions + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition foreign key definition + * @return string + */ + public function getAdvancedForeignKeyOptions(array $definition) + { + $query = ''; + if ( ! empty($definition['onUpdate'])) { + $query .= ' ON UPDATE ' . $this->getForeignKeyReferentialAction($definition['onUpdate']); + } + if ( ! empty($definition['onDelete'])) { + $query .= ' ON DELETE ' . $this->getForeignKeyReferentialAction($definition['onDelete']); + } + return $query; + } + + /** + * getForeignKeyReferentialAction + * + * returns given referential action in uppercase if valid, otherwise throws + * an exception + * + * @throws Doctrine_Exception_Exception if unknown referential action given + * @param string $action foreign key referential action + * @param string foreign key referential action in uppercase + */ + public function getForeignKeyReferentialAction($action) + { + $upper = strtoupper($action); + switch ($upper) { + case 'CASCADE': + case 'SET NULL': + case 'NO ACTION': + case 'RESTRICT': + case 'SET DEFAULT': + return $upper; + break; + default: + throw new Doctrine_Export_Exception('Unknown foreign key referential action \'' . $upper . '\' given.'); + } + } + + /** + * getForeignKeyBaseDeclaration + * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param array $definition + * @return string + */ + public function getForeignKeyBaseDeclaration(array $definition) + { + $sql = ''; + if (isset($definition['name'])) { + $sql .= ' CONSTRAINT ' . $this->conn->quoteIdentifier($definition['name']) . ' '; + } + $sql .= 'FOREIGN KEY ('; + + if ( ! isset($definition['local'])) { + throw new Doctrine_Export_Exception('Local reference field missing from definition.'); + } + if ( ! isset($definition['foreign'])) { + throw new Doctrine_Export_Exception('Foreign reference field missing from definition.'); + } + if ( ! isset($definition['foreignTable'])) { + throw new Doctrine_Export_Exception('Foreign reference table missing from definition.'); + } + + if ( ! is_array($definition['local'])) { + $definition['local'] = array($definition['local']); + } + if ( ! is_array($definition['foreign'])) { + $definition['foreign'] = array($definition['foreign']); + } + + $sql .= implode(', ', array_map(array($this->conn, 'quoteIdentifier'), $definition['local'])) + . ') REFERENCES ' + . $this->conn->quoteIdentifier($definition['foreignTable']) . '(' + . implode(', ', array_map(array($this->conn, 'quoteIdentifier'), $definition['foreign'])) . ')'; + + return $sql; + } + + /** + * Obtain DBMS specific SQL code portion needed to set the UNIQUE constraint + * of a field declaration to be used in statements like CREATE TABLE. + * + * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint + * of a field declaration. + */ + public function getUniqueFieldDeclaration() + { + return 'UNIQUE'; + } + + /** + * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $charset name of the charset + * @return string DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration. + */ + public function getCharsetFieldDeclaration($charset) + { + return ''; + } + + /** + * Obtain DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $collation name of the collation + * @return string DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration. + */ + public function getCollationFieldDeclaration($collation) + { + return ''; + } + + /** + * exportSchema + * method for exporting Doctrine_Record classes to a schema + * + * if the directory parameter is given this method first iterates + * recursively trhough the given directory in order to find any model classes + * + * Then it iterates through all declared classes and creates tables for the ones + * that extend Doctrine_Record and are not abstract classes + * + * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS + * occurred during the create table operation + * @param string $directory optional directory parameter + * @return void + */ + public function exportSchema($directory = null) + { + if ($directory !== null) { + $models = Doctrine::filterInvalidModels(Doctrine::loadModels($directory)); + } else { + $models = Doctrine::getLoadedModels(); + } + + $this->exportClasses($models); + } + + public function exportSortedClassesSql($classes, $groupByConnection = true) + { + $connections = array(); + foreach ($classes as $class) { + $connection = Doctrine_Manager::getInstance()->getConnectionForComponent($class); + $connectionName = $connection->getName(); + + if ( ! isset($connections[$connectionName])) { + $connections[$connectionName] = array( + 'create_tables' => array(), + 'create_sequences' => array(), + 'create_indexes' => array(), + 'alters' => array(), + 'create_triggers' => array(), + ); + } + + $sql = $connection->export->exportClassesSql(array($class)); + + // Build array of all the creates + // We need these to happen first + foreach ($sql as $key => $query) { + // If create table statement + if (substr($query, 0, strlen('CREATE TABLE')) == 'CREATE TABLE') { + $connections[$connectionName]['create_tables'][] = $query; + + unset($sql[$key]); + continue; + } + + // If create sequence statement + if (substr($query, 0, strlen('CREATE SEQUENCE')) == 'CREATE SEQUENCE') { + $connections[$connectionName]['create_sequences'][] = $query; + + unset($sql[$key]); + continue; + } + + // If create index statement + if (preg_grep("/CREATE ([^ ]* )?INDEX/", array($query))) { + $connections[$connectionName]['create_indexes'][] = $query; + + unset($sql[$key]); + continue; + } + + // If alter table statement or oracle anonymous block enclosing alter + if (substr($query, 0, strlen('ALTER TABLE')) == 'ALTER TABLE' + || substr($query, 0, strlen('DECLARE')) == 'DECLARE') { + $connections[$connectionName]['alters'][] = $query; + + unset($sql[$key]); + continue; + } + + // If create trgger statement + if (substr($query, 0, strlen('CREATE TRIGGER')) == 'CREATE TRIGGER') { + $connections[$connectionName]['create_triggers'][] = $query; + + unset($sql[$key]); + continue; + } + } + } + + // Loop over all the sql again to merge everything together so it is in the correct order + $build = array(); + foreach ($connections as $connectionName => $sql) { + $build[$connectionName] = array_unique(array_merge($sql['create_tables'], $sql['create_sequences'], $sql['create_indexes'], $sql['alters'], $sql['create_triggers'])); + } + + if ( ! $groupByConnection) { + $new = array(); + foreach($build as $connectionname => $sql) { + $new = array_unique(array_merge($new, $sql)); + } + $build = $new; + } + return $build; + } + + /** + * exportClasses + * method for exporting Doctrine_Record classes to a schema + * + * FIXME: This function has ugly hacks in it to make sure sql is inserted in the correct order. + * + * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS + * occurred during the create table operation + * @param array $classes + * @return void + */ + public function exportClasses(array $classes) + { + $queries = $this->exportSortedClassesSql($classes); + + foreach ($queries as $connectionName => $sql) { + $connection = Doctrine_Manager::getInstance()->getConnection($connectionName); + + $connection->beginTransaction(); + + foreach ($sql as $query) { + try { + $connection->exec($query); + } catch (Doctrine_Connection_Exception $e) { + // we only want to silence table already exists errors + if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { + $connection->rollback(); + throw new Doctrine_Export_Exception($e->getMessage() . '. Failing Query: ' . $query); + } + } + } + + $connection->commit(); + } + } + + /** + * exportClassesSql + * method for exporting Doctrine_Record classes to a schema + * + * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS + * occurred during the create table operation + * @param array $classes + * @return void + */ + public function exportClassesSql(array $classes) + { + $models = Doctrine::filterInvalidModels($classes); + + $sql = array(); + + foreach ($models as $name) { + try { + $record = new $name(); + $table = $record->getTable(); + + $parents = $table->getOption('joinedParents'); + + foreach ($parents as $parent) { + $data = $table->getConnection()->getTable($parent)->getExportableFormat(); + + $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']); + + $sql = array_merge($sql, (array) $query); + } + + $data = $table->getExportableFormat(); + + $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']); + + if (is_array($query)) { + $sql = array_merge($sql, $query); + } else { + $sql[] = $query; + } + + if ($table->getAttribute(Doctrine::ATTR_EXPORT) & Doctrine::EXPORT_PLUGINS) { + $sql = array_merge($sql, $this->exportGeneratorsSql($table)); + } + } catch (Exception $e) { + throw new Doctrine_Export_Exception("While exporting model class '$name' to SQL: " . $e->getMessage()); + } + + } + + $sql = array_unique($sql); + + rsort($sql); + + return $sql; + } + + /** + * fetches all generators recursively for given table + * + * @param Doctrine_Table $table table object to retrieve the generators from + * @return array an array of Doctrine_Record_Generator objects + */ + public function getAllGenerators(Doctrine_Table $table) + { + $generators = array(); + + foreach ($table->getGenerators() as $name => $generator) { + if ($generator === null) { + continue; + } + + $generators[] = $generator; + + $generatorTable = $generator->getTable(); + + if ($generatorTable instanceof Doctrine_Table) { + $generators = array_merge($generators, $this->getAllGenerators($generatorTable)); + } + } + + return $generators; + } + + /** + * exportGeneratorsSql + * exports plugin tables for given table + * + * @param Doctrine_Table $table the table in which the generators belong to + * @return array an array of sql strings + */ + public function exportGeneratorsSql(Doctrine_Table $table) + { + $sql = array(); + + foreach ($this->getAllGenerators($table) as $name => $generator) { + $table = $generator->getTable(); + + // Make sure plugin has a valid table + if ($table instanceof Doctrine_Table) { + $data = $table->getExportableFormat(); + + $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']); + + $sql = array_merge($sql, (array) $query); + } + } + + return $sql; + } + + /** + * exportSql + * returns the sql for exporting Doctrine_Record classes to a schema + * + * if the directory parameter is given this method first iterates + * recursively trhough the given directory in order to find any model classes + * + * Then it iterates through all declared classes and creates tables for the ones + * that extend Doctrine_Record and are not abstract classes + * + * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS + * occurred during the create table operation + * @param string $directory optional directory parameter + * @return void + */ + public function exportSql($directory = null) + { + if ($directory !== null) { + $models = Doctrine::filterInvalidModels(Doctrine::loadModels($directory)); + } else { + $models = Doctrine::getLoadedModels(); + } + + return $this->exportSortedClassesSql($models, false); + } + + /** + * exportTable + * exports given table into database based on column and option definitions + * + * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS + * occurred during the create table operation + * @return boolean whether or not the export operation was successful + * false if table already existed in the database + */ + public function exportTable(Doctrine_Table $table) + { + try { + $data = $table->getExportableFormat(); + + $this->conn->export->createTable($data['tableName'], $data['columns'], $data['options']); + } catch(Doctrine_Connection_Exception $e) { + // we only want to silence table already exists errors + if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { + throw $e; + } + } + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Export_Exception + * + * @package Doctrine + * @subpackage Export + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Export_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Firebird.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Firebird.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,551 @@ +. + */ + +/** + * Doctrine_Export_Sqlite + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Lorenzo Alberton (PEAR MDB2 Interbase driver) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export_Firebird extends Doctrine_Export +{ + /** + * create a new database + * + * @param string $name name of the database that should be created + * @return void + */ + public function createDatabase($name) + { + throw new Doctrine_Export_Exception( + 'PHP Interbase API does not support direct queries. You have to ' . + 'create the db manually by using isql command or a similar program'); + } + + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @return void + */ + public function dropDatabase($name) + { + throw new Doctrine_Export_Exception( + 'PHP Interbase API does not support direct queries. You have ' . + 'to drop the db manually by using isql command or a similar program'); + } + + /** + * add an autoincrement sequence + trigger + * + * @param string $name name of the PK field + * @param string $table name of the table + * @param string $start start value for the sequence + * @return void + */ + public function _makeAutoincrement($name, $table, $start = null) + { + if (is_null($start)) { + $this->conn->beginTransaction(); + $query = 'SELECT MAX(' . $this->conn->quoteIdentifier($name, true) . ') FROM ' . $this->conn->quoteIdentifier($table, true); + $start = $this->conn->fetchOne($query, 'integer'); + + ++$start; + $result = $this->createSequence($table, $start); + $this->conn->commit(); + } else { + $result = $this->createSequence($table, $start); + } + + $sequence_name = $this->conn->formatter->getSequenceName($table); + $trigger_name = $this->conn->quoteIdentifier($table . '_AUTOINCREMENT_PK', true); + + $table = $this->conn->quoteIdentifier($table, true); + $name = $this->conn->quoteIdentifier($name, true); + + $triggerSql = 'CREATE TRIGGER ' . $trigger_name . ' FOR ' . $table + . ' ACTIVE BEFORE INSERT POSITION 0 AS' + . ' BEGIN' + . ' IF (NEW.' . $name . ' IS NULL OR NEW.' . $name . ' = 0) THEN' + . ' NEW.' . $name . ' = GEN_ID('.$sequence_name.', 1)' + . ' END'; + $result = $this->conn->exec($triggerSql); + + // TODO ? $this->_silentCommit(); + + return $result; + } + + /** + * drop an existing autoincrement sequence + trigger + * + * @param string $table name of the table + * @return void + */ + public function _dropAutoincrement($table) + { + + $result = $this->dropSequence($table); + + //remove autoincrement trigger associated with the table + $table = $this->conn->quote(strtoupper($table)); + $triggerName = $this->conn->quote(strtoupper($table) . '_AUTOINCREMENT_PK'); + + return $this->conn->exec("DELETE FROM RDB\$TRIGGERS WHERE UPPER(RDB\$RELATION_NAME)=" . $table . " AND UPPER(RDB\$TRIGGER_NAME)=" . $triggerName); + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * + * Example + * array( + * + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1, + * 'notnull' => 1, + * 'default' => 0, + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12, + * ), + * 'description' => array( + * 'type' => 'text', + * 'length' => 12, + * ) + * ); + * @param array $options An associative array of table options: + * + * @return void + */ + public function createTable($name, array $fields, array $options = array()) { + parent::createTable($name, $fields, $options); + + // TODO ? $this->_silentCommit(); + foreach ($fields as $field_name => $field) { + if ( ! empty($field['autoincrement'])) { + //create PK constraint + $pk_definition = array( + 'fields' => array($field_name => array()), + 'primary' => true, + ); + //$pk_name = $name.'_PK'; + $pk_name = null; + $result = $this->createConstraint($name, $pk_name, $pk_definition); + + //create autoincrement sequence + trigger + return $this->_makeAutoincrement($field_name, $name, 1); + } + } + } + + /** + * Check if planned changes are supported + * + * @param string $name name of the database that should be dropped + * @return void + */ + public function checkSupportedChanges(&$changes) + { + foreach ($changes as $change_name => $change) { + switch ($change_name) { + case 'notnull': + throw new Doctrine_DataDict_Exception('it is not supported changes to field not null constraint'); + case 'default': + throw new Doctrine_DataDict_Exception('it is not supported changes to field default value'); + case 'length': + /* + return throw new Doctrine_DataDict_Firebird_Exception('it is not supported changes to field default length'); + */ + case 'unsigned': + case 'type': + case 'declaration': + case 'definition': + break; + default: + throw new Doctrine_DataDict_Exception('it is not supported change of type' . $change_name); + } + } + return true; + } + + /** + * drop an existing table + * + * @param string $name name of the table that should be dropped + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + public function dropTable($name) + { + $result = $this->_dropAutoincrement($name); + $result = parent::dropTable($name); + + //$this->_silentCommit(); + + return $result; + } + + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the Metabase parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the Metabase parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @return void + */ + public function alterTable($name, array $changes, $check = false) + { + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + case 'remove': + case 'rename': + break; + case 'change': + foreach ($changes['change'] as $field) { + $this->checkSupportedChanges($field); + } + break; + default: + throw new Doctrine_DataDict_Exception('change type ' . $changeName . ' not yet supported'); + } + } + if ($check) { + return true; + } + $query = ''; + if ( ! empty($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + $query.= 'ADD ' . $this->getDeclaration($fieldName, $field); + } + } + + if ( ! empty($changes['remove']) && is_array($changes['remove'])) { + foreach ($changes['remove'] as $field_name => $field) { + if ($query) { + $query.= ', '; + } + $field_name = $this->conn->quoteIdentifier($field_name, true); + $query.= 'DROP ' . $field_name; + } + } + + if ( ! empty($changes['rename']) && is_array($changes['rename'])) { + foreach ($changes['rename'] as $field_name => $field) { + if ($query) { + $query.= ', '; + } + $field_name = $this->conn->quoteIdentifier($field_name, true); + $query.= 'ALTER ' . $field_name . ' TO ' . $this->conn->quoteIdentifier($field['name'], true); + } + } + + if ( ! empty($changes['change']) && is_array($changes['change'])) { + // missing support to change DEFAULT and NULLability + foreach ($changes['change'] as $fieldName => $field) { + $this->checkSupportedChanges($field); + if ($query) { + $query.= ', '; + } + $this->conn->loadModule('Datatype', null, true); + $field_name = $this->conn->quoteIdentifier($fieldName, true); + $query.= 'ALTER ' . $field_name.' TYPE ' . $this->getTypeDeclaration($field['definition']); + } + } + + if ( ! strlen($query)) { + return false; + } + + $name = $this->conn->quoteIdentifier($name, true); + $result = $this->conn->exec('ALTER TABLE ' . $name . ' ' . $query); + $this->_silentCommit(); + return $result; + } + + /** + * Get the stucture of a field into an array + * + * @param string $table name of the table on which the index is to be created + * @param string $name name of the index to be created + * @param array $definition associative array that defines properties of the index to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the index fields as array + * indexes. Each entry of this array is set to another type of associative + * array that specifies properties of the index that are specific to + * each field. + * + * Currently, only the sorting property is supported. It should be used + * to define the sorting direction of the index. It may be set to either + * ascending or descending. + * + * Not all DBMS support index sorting direction configuration. The DBMS + * drivers of those that do not support it ignore this property. Use the + * function support() to determine whether the DBMS driver can manage indexes. + + * Example + * array( + * 'fields' => array( + * 'user_name' => array( + * 'sorting' => 'ascending' + * ), + * 'last_login' => array() + * ) + * ) + * @return void + */ + public function createIndexSql($table, $name, array $definition) + { + $query = 'CREATE'; + + $query_sort = ''; + foreach ($definition['fields'] as $field) { + if ( ! strcmp($query_sort, '') && isset($field['sorting'])) { + switch ($field['sorting']) { + case 'ascending': + $query_sort = ' ASC'; + break; + case 'descending': + $query_sort = ' DESC'; + break; + } + } + } + $table = $this->conn->quoteIdentifier($table, true); + $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name), true); + $query .= $query_sort. ' INDEX ' . $name . ' ON ' . $table; + $fields = array(); + foreach (array_keys($definition['fields']) as $field) { + $fields[] = $this->conn->quoteIdentifier($field, true); + } + $query .= ' ('.implode(', ', $fields) . ')'; + + return $query; + } + + /** + * create a constraint on a table + * + * @param string $table name of the table on which the constraint is to be created + * @param string $name name of the constraint to be created + * @param array $definition associative array that defines properties of the constraint to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the constraint fields as array + * constraints. Each entry of this array is set to another type of associative + * array that specifies properties of the constraint that are specific to + * each field. + * + * Example + * array( + * 'fields' => array( + * 'user_name' => array(), + * 'last_login' => array(), + * ) + * ) + * @return void + */ + public function createConstraint($table, $name, $definition) + { + $table = $this->conn->quoteIdentifier($table, true); + + if ( ! empty($name)) { + $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name), true); + } + $query = "ALTER TABLE $table ADD"; + if ( ! empty($definition['primary'])) { + if ( ! empty($name)) { + $query.= ' CONSTRAINT '.$name; + } + $query.= ' PRIMARY KEY'; + } else { + $query.= ' CONSTRAINT '. $name; + if ( ! empty($definition['unique'])) { + $query.= ' UNIQUE'; + } + } + $fields = array(); + foreach (array_keys($definition['fields']) as $field) { + $fields[] = $this->conn->quoteIdentifier($field, true); + } + $query .= ' ('. implode(', ', $fields) . ')'; + $result = $this->conn->exec($query); + // TODO ? $this->_silentCommit(); + return $result; + } + + /** + * A method to return the required SQL string that fits between CREATE ... TABLE + * to create the table as a temporary table. + * + * @return string The string required to be placed between "CREATE" and "TABLE" + * to generate a temporary table, if possible. + */ + public function getTemporaryTableQuery() + { + return 'GLOBAL TEMPORARY'; + } + + /** + * create sequence + * + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return boolean + */ + public function createSequence($seqName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->formatter->getSequenceName($seqName); + + $this->conn->exec('CREATE GENERATOR ' . $sequenceName); + + try { + $this->conn->exec('SET GENERATOR ' . $sequenceName . ' TO ' . ($start-1)); + + return true; + } catch (Doctrine_Connection_Exception $e) { + try { + $this->dropSequence($seqName); + } catch(Doctrine_Connection_Exception $e) { + throw new Doctrine_Export_Exception('Could not drop inconsistent sequence table'); + } + } + throw new Doctrine_Export_Exception('could not create sequence table'); + } + + /** + * drop existing sequence + * + * @param string $seqName name of the sequence to be dropped + * @return void + */ + public function dropSequenceSql($seqName) + { + $sequenceName = $this->conn->formatter->getSequenceName($seqName); + $sequenceName = $this->conn->quote($sequenceName); + $query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=" . $sequenceName; + + return $query; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Frontbase.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Frontbase.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,316 @@ +. + */ + +/** + * Doctrine_Export_Frontbase + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Export_Frontbase extends Doctrine_Export +{ + /** + * create a new database + * + * @param string $name name of the database that should be created + * @return string + */ + public function createDatabaseSql($name) + { + $name = $this->conn->quoteIdentifier($name, true); + return 'CREATE DATABASE ' . $name; + } + + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @return string + */ + public function dropDatabaseSql($name) + { + $name = $this->conn->quoteIdentifier($name, true); + return 'DELETE DATABASE ' . $name; + } + + /** + * drop an existing table + * + * @param object $this->conns database object that is extended by this class + * @param string $name name of the table that should be dropped + * @return string + */ + public function dropTableSql($name) + { + $name = $this->conn->quoteIdentifier($name, true); + return 'DROP TABLE ' . $name . ' CASCADE'; + } + + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the MDB2 parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the MDB2 parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @access public + * + * @return boolean + */ + public function alterTable($name, array $changes, $check = false) + { + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + case 'remove': + case 'change': + case 'rename': + case 'name': + break; + default: + throw new Doctrine_Export_Exception('change type "'.$changeName.'" not yet supported'); + } + } + + if ($check) { + return true; + } + + $query = ''; + if ( ! empty($changes['name'])) { + $changeName = $this->conn->quoteIdentifier($changes['name'], true); + $query .= 'RENAME TO ' . $changeName; + } + + if ( ! empty($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + $query.= 'ADD ' . $this->conn->getDeclaration($fieldName, $field); + } + } + + if ( ! empty($changes['remove']) && is_array($changes['remove'])) { + foreach ($changes['remove'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + $fieldName = $this->conn->quoteIdentifier($fieldName, true); + $query.= 'DROP ' . $fieldName; + } + } + + $rename = array(); + if ( ! empty($changes['rename']) && is_array($changes['rename'])) { + foreach ($changes['rename'] as $fieldName => $field) { + $rename[$field['name']] = $fieldName; + } + } + + if ( ! empty($changes['change']) && is_array($changes['change'])) { + foreach ($changes['change'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + if (isset($rename[$fieldName])) { + $oldFieldName = $rename[$fieldName]; + unset($rename[$fieldName]); + } else { + $oldFieldName = $fieldName; + } + $oldFieldName = $this->conn->quoteIdentifier($oldFieldName, true); + $query.= 'CHANGE ' . $oldFieldName . ' ' . $this->conn->getDeclaration($oldFieldName, $field['definition']); + } + } + + if ( ! empty($rename) && is_array($rename)) { + foreach ($rename as $renamedFieldName => $renamed_field) { + if ($query) { + $query.= ', '; + } + $oldFieldName = $rename[$renamedFieldName]; + $field = $changes['rename'][$oldFieldName]; + $query.= 'CHANGE ' . $this->conn->getDeclaration($oldFieldName, $field['definition']); + } + } + + if ( ! $query) { + return true; + } + + $name = $this->conn->quoteIdentifier($name, true); + return $this->conn->exec('ALTER TABLE ' . $name . ' ' . $query); + } + + /** + * create sequence + * + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return void + */ + public function createSequence($sequenceName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($sequenceName), true); + $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); + + $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . ' INTEGER DEFAULT UNIQUE, PRIMARY KEY(' . $seqcolName . '))'; + $res = $this->conn->exec($query); + $res = $this->conn->exec('SET UNIQUE = 1 FOR ' . $sequenceName); + + if ($start == 1) { + return true; + } + + try { + $this->conn->exec('INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (' . ($start-1) . ')'); + } catch(Doctrine_Connection_Exception $e) { + // Handle error + try { + $this->conn->exec('DROP TABLE ' . $sequenceName); + } catch(Doctrine_Connection_Exception $e) { + throw new Doctrine_Export_Exception('could not drop inconsistent sequence table'); + } + + throw new Doctrine_Export_Exception('could not create sequence table'); + } + } + + /** + * drop existing sequence + * + * @param string $seqName name of the sequence to be dropped + * @return string + */ + public function dropSequenceSql($seqName) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); + + return 'DROP TABLE ' . $sequenceName . ' CASCADE'; + } + + /** + * drop existing index + * + * @param string $table name of table that should be used in method + * @param string $name name of the index to be dropped + * @return boolean + */ + public function dropIndexSql($table, $name) + { + $table = $this->conn->quoteIdentifier($table, true); + $name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true); + + return 'ALTER TABLE ' . $table . ' DROP INDEX ' . $name; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Informix.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Informix.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,37 @@ +. + */ + +/** + * Doctrine_Export_Informix + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Lorenzo Alberton (PEAR MDB2 Interbase driver) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 3884 $ + */ +class Doctrine_Export_Informix extends Doctrine_Export +{ +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Mssql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Mssql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,349 @@ +. + */ + +/** + * Doctrine_Export_Mssql + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Frank M. Kromann (PEAR MDB2 Mssql driver) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5824 $ + */ +class Doctrine_Export_Mssql extends Doctrine_Export +{ + /** + * create a new database + * + * @param string $name name of the database that should be created + * @return void + */ + public function createDatabase($name) + { + $name = $this->conn->quoteIdentifier($name, true); + $query = "CREATE DATABASE $name"; + if ($this->conn->options['database_device']) { + $query.= ' ON '.$this->conn->options['database_device']; + $query.= $this->conn->options['database_size'] ? '=' . + $this->conn->options['database_size'] : ''; + } + return $this->conn->standaloneQuery($query, null, true); + } + + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @return void + */ + public function dropDatabase($name) + { + $name = $this->conn->quoteIdentifier($name, true); + return $this->conn->standaloneQuery('DROP DATABASE ' . $name, array(), true); + } + + /** + * Override the parent method. + * + * @return string The string required to be placed between "CREATE" and "TABLE" + * to generate a temporary table, if possible. + */ + public function getTemporaryTableQuery() + { + return ''; + } + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the Metabase parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the Metabase parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @return void + */ + public function alterTable($name, array $changes, $check = false) + { + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + break; + case 'remove': + break; + case 'name': + case 'rename': + case 'change': + default: + throw new Doctrine_Export_Exception('alterTable: change type "' . $changeName . '" not yet supported'); + } + } + + $query = ''; + if ( ! empty($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { + if ($query) { + $query .= ', '; + } + $query .= 'ADD ' . $this->getDeclaration($fieldName, $field); + } + } + + if ( ! empty($changes['remove']) && is_array($changes['remove'])) { + foreach ($changes['remove'] as $fieldName => $field) { + if ($query) { + $query .= ', '; + } + $field_name = $this->conn->quoteIdentifier($fieldName, true); + $query .= 'DROP COLUMN ' . $fieldName; + } + } + + if ( ! $query) { + return false; + } + + $name = $this->conn->quoteIdentifier($name, true); + return $this->conn->exec('ALTER TABLE ' . $name . ' ' . $query); + } + + /** + * create sequence + * + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string + */ + public function createSequence($seqName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); + $seqcolName = $this->conn->quoteIdentifier($this->conn->options['seqcol_name'], true); + $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . + ' INT PRIMARY KEY CLUSTERED IDENTITY(' . $start . ', 1) NOT NULL)'; + + $res = $this->conn->exec($query); + + if ($start == 1) { + return true; + } + + try { + $query = 'SET IDENTITY_INSERT ' . $sequenceName . ' ON ' . + 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES ( ' . $start . ')'; + $res = $this->conn->exec($query); + } catch (Exception $e) { + $result = $this->conn->exec('DROP TABLE ' . $sequenceName); + } + return true; + } + + /** + * This function drops an existing sequence + * + * @param string $seqName name of the sequence to be dropped + * @return void + */ + public function dropSequenceSql($seqName) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); + return 'DROP TABLE ' . $sequenceName; + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * array( + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * 'notnull' => 1 + * 'default' => 0 + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12 + * ), + * 'password' => array( + * 'type' => 'text', + * 'length' => 12 + * ) + * ); + * @param array $options An associative array of table options: + * + * @return string + */ + public function createTableSql($name, array $fields, array $options = array()) + { + if ( ! $name) { + throw new Doctrine_Export_Exception('no valid table name specified'); + } + + if (empty($fields)) { + throw new Doctrine_Export_Exception('no fields specified for table ' . $name); + } + + $queryFields = $this->getFieldDeclarationList($fields); + + + if (isset($options['primary']) && ! empty($options['primary'])) { + $primaryKeys = array_map(array($this->conn, 'quoteIdentifier'), array_values($options['primary'])); + $queryFields .= ', PRIMARY KEY(' . implode(', ', $primaryKeys) . ')'; + } + + $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields; + + $check = $this->getCheckDeclaration($fields); + + if ( ! empty($check)) { + $query .= ', ' . $check; + } + + $query .= ')'; + + $sql[] = $query; + + if (isset($options['indexes']) && ! empty($options['indexes'])) { + foreach($options['indexes'] as $index => $definition) { + if (is_array($definition)) { + $sql[] = $this->createIndexSql($name,$index, $definition); + } + } + } + + if (isset($options['foreignKeys'])) { + + foreach ((array) $options['foreignKeys'] as $k => $definition) { + if (is_array($definition)) { + $sql[] = $this->createForeignKeySql($name, $definition); + } + } + } + return $sql; + } + + /** + * getNotNullFieldDeclaration + * Obtain DBMS specific SQL code portion needed to set a NOT NULL + * declaration to be used in statements like CREATE TABLE. + * + * @param array $field field definition array + * @return string DBMS specific SQL code portion needed to set a default value + */ + public function getNotNullFieldDeclaration(array $definition) + { + return ( + (isset($definition['notnull']) && $definition['notnull']) || + (isset($definition['primary']) && $definition['primary']) + ) ? ' NOT NULL' : ' NULL'; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Mysql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Mysql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,778 @@ +. + */ + +/** + * Doctrine_Export_Mysql + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export_Mysql extends Doctrine_Export +{ + /** + * drop existing constraint + * + * @param string $table name of table that should be used in method + * @param string $name name of the constraint to be dropped + * @param string $primary hint if the constraint is primary + * @return void + */ + public function dropConstraint($table, $name, $primary = false) + { + $table = $this->conn->quoteIdentifier($table); + + if ( ! $primary) { + $name = 'CONSTRAINT ' . $this->conn->quoteIdentifier($name); + } else { + $name = 'PRIMARY KEY'; + } + + return $this->conn->exec('ALTER TABLE ' . $table . ' DROP ' . $name); + } + + /** + * createDatabaseSql + * + * @param string $name + * @return void + */ + public function createDatabaseSql($name) + { + return 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true); + } + + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @return string + */ + public function dropDatabaseSql($name) + { + return 'DROP DATABASE ' . $this->conn->quoteIdentifier($name); + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * array( + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * 'notnull' => 1 + * 'default' => 0 + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12 + * ), + * 'password' => array( + * 'type' => 'text', + * 'length' => 12 + * ) + * ); + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * 'type' => 'innodb', + * ); + * + * @return void + */ + public function createTableSql($name, array $fields, array $options = array()) + { + if ( ! $name) + throw new Doctrine_Export_Exception('no valid table name specified'); + + if (empty($fields)) { + throw new Doctrine_Export_Exception('no fields specified for table "'.$name.'"'); + } + $queryFields = $this->getFieldDeclarationList($fields); + + // build indexes for all foreign key fields (needed in MySQL!!) + if (isset($options['foreignKeys'])) { + foreach ($options['foreignKeys'] as $fk) { + $local = $fk['local']; + $found = false; + if (isset($options['indexes'])) { + foreach ($options['indexes'] as $definition) { + if (is_string($definition['fields'])) { + // Check if index already exists on the column + $found = ($local == $definition['fields']); + } else if (in_array($local, $definition['fields']) && count($definition['fields']) === 1) { + // Index already exists on the column + $found = true; + } + } + } + if (isset($options['primary']) && !empty($options['primary']) && + in_array($local, $options['primary'])) { + // field is part of the PK and therefore already indexed + $found = true; + } + + if ( ! $found) { + if (is_array($local)) { + foreach($local as $localidx) { + $options['indexes'][$localidx] = array('fields' => array($localidx => array())); + } + } else { + $options['indexes'][$local] = array('fields' => array($local => array())); + } + } + } + } + + // add all indexes + if (isset($options['indexes']) && ! empty($options['indexes'])) { + foreach($options['indexes'] as $index => $definition) { + $queryFields .= ', ' . $this->getIndexDeclaration($index, $definition); + } + } + + // attach all primary keys + if (isset($options['primary']) && ! empty($options['primary'])) { + $keyColumns = array_values($options['primary']); + $keyColumns = array_map(array($this->conn, 'quoteIdentifier'), $keyColumns); + $queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')'; + } + + $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields . ')'; + + $optionStrings = array(); + + if (isset($options['comment'])) { + $optionStrings['comment'] = 'COMMENT = ' . $this->conn->quote($options['comment'], 'text'); + } + if (isset($options['charset'])) { + $optionStrings['charset'] = 'DEFAULT CHARACTER SET ' . $options['charset']; + } + if (isset($options['collate'])) { + $optionStrings['collate'] = 'COLLATE ' . $options['collate']; + } + + $type = false; + + // get the type of the table + if (isset($options['type'])) { + $type = $options['type']; + } else { + $type = $this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE); + } + + if ($type) { + $optionStrings[] = 'ENGINE = ' . $type; + } + + if ( ! empty($optionStrings)) { + $query.= ' '.implode(' ', $optionStrings); + } + $sql[] = $query; + + if (isset($options['foreignKeys'])) { + + foreach ((array) $options['foreignKeys'] as $k => $definition) { + if (is_array($definition)) { + $sql[] = $this->createForeignKeySql($name, $definition); + } + } + } + return $sql; + } + + /** + * Obtain DBMS specific SQL code portion needed to declare a generic type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * charset + * Text value with the default CHARACTER SET for this field. + * collation + * Text value with the default COLLATION for this field. + * unique + * unique constraint + * check + * column check constraint + * + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + */ + public function getDeclaration($name, array $field) + { + + $default = $this->getDefaultFieldDeclaration($field); + + $charset = (isset($field['charset']) && $field['charset']) ? + ' ' . $this->getCharsetFieldDeclaration($field['charset']) : ''; + + $collation = (isset($field['collation']) && $field['collation']) ? + ' ' . $this->getCollationFieldDeclaration($field['collation']) : ''; + + $notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : ''; + + $unique = (isset($field['unique']) && $field['unique']) ? + ' ' . $this->getUniqueFieldDeclaration() : ''; + + $check = (isset($field['check']) && $field['check']) ? + ' ' . $field['check'] : ''; + + $comment = (isset($field['comment']) && $field['comment']) ? + " COMMENT '" . $field['comment'] . "'" : ''; + + $method = 'get' . $field['type'] . 'Declaration'; + + try { + if (method_exists($this->conn->dataDict, $method)) { + return $this->conn->dataDict->$method($name, $field); + } else { + $dec = $this->conn->dataDict->getNativeDeclaration($field); + } + + return $this->conn->quoteIdentifier($name, true) + . ' ' . $dec . $charset . $default . $notnull . $comment . $unique . $check . $collation; + } catch (Exception $e) { + throw new Doctrine_Exception('Around field ' . $name . ': ' . $e->getMessage()); + } + } + + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the Metabase parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the Metabase parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @return boolean + */ + public function alterTableSql($name, array $changes, $check = false) + { + if ( ! $name) { + throw new Doctrine_Export_Exception('no valid table name specified'); + } + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + case 'remove': + case 'change': + case 'rename': + case 'name': + break; + default: + throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported'); + } + } + + if ($check) { + return true; + } + + $query = ''; + if ( ! empty($changes['name'])) { + $change_name = $this->conn->quoteIdentifier($changes['name']); + $query .= 'RENAME TO ' . $change_name; + } + + if ( ! empty($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + $query.= 'ADD ' . $this->getDeclaration($fieldName, $field); + } + } + + if ( ! empty($changes['remove']) && is_array($changes['remove'])) { + foreach ($changes['remove'] as $fieldName => $field) { + if ($query) { + $query .= ', '; + } + $fieldName = $this->conn->quoteIdentifier($fieldName); + $query .= 'DROP ' . $fieldName; + } + } + + $rename = array(); + if ( ! empty($changes['rename']) && is_array($changes['rename'])) { + foreach ($changes['rename'] as $fieldName => $field) { + $rename[$field['name']] = $fieldName; + } + } + + if ( ! empty($changes['change']) && is_array($changes['change'])) { + foreach ($changes['change'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + if (isset($rename[$fieldName])) { + $oldFieldName = $rename[$fieldName]; + unset($rename[$fieldName]); + } else { + $oldFieldName = $fieldName; + } + $oldFieldName = $this->conn->quoteIdentifier($oldFieldName, true); + $query .= 'CHANGE ' . $oldFieldName . ' ' + . $this->getDeclaration($fieldName, $field['definition']); + } + } + + if ( ! empty($rename) && is_array($rename)) { + foreach ($rename as $renameName => $renamedField) { + if ($query) { + $query.= ', '; + } + $field = $changes['rename'][$renamedField]; + $renamedField = $this->conn->quoteIdentifier($renamedField, true); + $query .= 'CHANGE ' . $renamedField . ' ' + . $this->getDeclaration($field['name'], $field['definition']); + } + } + + if ( ! $query) { + return false; + } + + $name = $this->conn->quoteIdentifier($name, true); + + return 'ALTER TABLE ' . $name . ' ' . $query; + } + + /** + * create sequence + * + * @param string $sequenceName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * 'type' => 'innodb', + * ); + * @return boolean + */ + public function createSequence($sequenceName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->quoteIdentifier($sequenceName, true); + $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); + + $optionsStrings = array(); + + if (isset($options['comment']) && ! empty($options['comment'])) { + $optionsStrings['comment'] = 'COMMENT = ' . $this->conn->quote($options['comment'], 'string'); + } + + if (isset($options['charset']) && ! empty($options['charset'])) { + $optionsStrings['charset'] = 'DEFAULT CHARACTER SET ' . $options['charset']; + + if (isset($options['collate'])) { + $optionsStrings['charset'] .= ' COLLATE ' . $options['collate']; + } + } + + $type = false; + + if (isset($options['type'])) { + $type = $options['type']; + } else { + $type = $this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE); + } + if ($type) { + $optionsStrings[] = 'ENGINE = ' . $type; + } + + + try { + $query = 'CREATE TABLE ' . $sequenceName + . ' (' . $seqcolName . ' BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' + . $seqcolName . ')) ' . implode($optionsStrings, ' '); + + $res = $this->conn->exec($query); + } catch(Doctrine_Connection_Exception $e) { + throw new Doctrine_Export_Exception('could not create sequence table'); + } + + if ($start == 1 && $res == 1) + return true; + + $query = 'INSERT INTO ' . $sequenceName + . ' (' . $seqcolName . ') VALUES (' . ($start - 1) . ')'; + + $res = $this->conn->exec($query); + + if ($res == 1) + return true; + + // Handle error + try { + $result = $this->conn->exec('DROP TABLE ' . $sequenceName); + } catch(Doctrine_Connection_Exception $e) { + throw new Doctrine_Export_Exception('could not drop inconsistent sequence table'); + } + + + } + + /** + * Get the stucture of a field into an array + * + * @author Leoncx + * @param string $table name of the table on which the index is to be created + * @param string $name name of the index to be created + * @param array $definition associative array that defines properties of the index to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the index fields as array + * indexes. Each entry of this array is set to another type of associative + * array that specifies properties of the index that are specific to + * each field. + * + * Currently, only the sorting property is supported. It should be used + * to define the sorting direction of the index. It may be set to either + * ascending or descending. + * + * Not all DBMS support index sorting direction configuration. The DBMS + * drivers of those that do not support it ignore this property. Use the + * function supports() to determine whether the DBMS driver can manage indexes. + * + * Example + * array( + * 'fields' => array( + * 'user_name' => array( + * 'sorting' => 'ASC' + * 'length' => 10 + * ), + * 'last_login' => array() + * ) + * ) + * @throws PDOException + * @return void + */ + public function createIndexSql($table, $name, array $definition) + { + $table = $table; + $name = $this->conn->formatter->getIndexName($name); + $name = $this->conn->quoteIdentifier($name); + $type = ''; + if (isset($definition['type'])) { + switch (strtolower($definition['type'])) { + case 'fulltext': + case 'unique': + $type = strtoupper($definition['type']) . ' '; + break; + default: + throw new Doctrine_Export_Exception( + 'Unknown type ' . $definition['type'] . ' for index ' . $name . ' in table ' . $table + ); + } + } + $query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table; + $query .= ' (' . $this->getIndexFieldDeclarationList($definition['fields']) . ')'; + + return $query; + } + + /** + * getDefaultDeclaration + * Obtain DBMS specific SQL code portion needed to set a default value + * declaration to be used in statements like CREATE TABLE. + * + * @param array $field field definition array + * @return string DBMS specific SQL code portion needed to set a default value + */ + public function getDefaultFieldDeclaration($field) + { + $default = ''; + if (isset($field['default']) && ( ! isset($field['length']) || $field['length'] <= 255)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) + ? null : $this->valid_default_values[$field['type']]; + + if ($field['default'] === '' + && ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EMPTY_TO_NULL) + ) { + $field['default'] = ' '; + } + } + + // Proposed patch: + if ($field['type'] == 'enum' && $this->conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) { + $fieldType = 'varchar'; + } else { + $fieldType = $field['type']; + } + + $default = ' DEFAULT ' . (is_null($field['default']) + ? 'NULL' + : $this->conn->quote($field['default'], $fieldType)); + //$default = ' DEFAULT ' . $this->conn->quote($field['default'], $field['type']); + } + + return $default; + } + + /** + * Obtain DBMS specific SQL code portion needed to set an index + * declaration to be used in statements like CREATE TABLE. + * + * @param string $charset name of the index + * @param array $definition index definition + * @return string DBMS specific SQL code portion needed to set an index + */ + public function getIndexDeclaration($name, array $definition) + { + $name = $this->conn->formatter->getIndexName($name); + $type = ''; + if (isset($definition['type'])) { + switch (strtolower($definition['type'])) { + case 'fulltext': + case 'unique': + $type = strtoupper($definition['type']) . ' '; + break; + default: + throw new Doctrine_Export_Exception( + 'Unknown type ' . $definition['type'] . ' for index ' . $name + ); + } + } + + if ( ! isset($definition['fields'])) { + throw new Doctrine_Export_Exception('No columns given for index ' . $name); + } + if ( ! is_array($definition['fields'])) { + $definition['fields'] = array($definition['fields']); + } + + $query = $type . 'INDEX ' . $this->conn->quoteIdentifier($name); + + $query .= ' (' . $this->getIndexFieldDeclarationList($definition['fields']) . ')'; + + return $query; + } + + /** + * getIndexFieldDeclarationList + * Obtain DBMS specific SQL code portion needed to set an index + * declaration to be used in statements like CREATE TABLE. + * + * @return string + */ + public function getIndexFieldDeclarationList(array $fields) + { + $declFields = array(); + + foreach ($fields as $fieldName => $field) { + $fieldString = $this->conn->quoteIdentifier($fieldName); + + if (is_array($field)) { + if (isset($field['length'])) { + $fieldString .= '(' . $field['length'] . ')'; + } + + if (isset($field['sorting'])) { + $sort = strtoupper($field['sorting']); + switch ($sort) { + case 'ASC': + case 'DESC': + $fieldString .= ' ' . $sort; + break; + default: + throw new Doctrine_Export_Exception('Unknown index sorting option given.'); + } + } + } else { + $fieldString = $this->conn->quoteIdentifier($field); + } + $declFields[] = $fieldString; + } + return implode(', ', $declFields); + } + + /** + * getAdvancedForeignKeyOptions + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition + * @return string + */ + public function getAdvancedForeignKeyOptions(array $definition) + { + $query = ''; + if ( ! empty($definition['match'])) { + $query .= ' MATCH ' . $definition['match']; + } + if ( ! empty($definition['onUpdate'])) { + $query .= ' ON UPDATE ' . $this->getForeignKeyReferentialAction($definition['onUpdate']); + } + if ( ! empty($definition['onDelete'])) { + $query .= ' ON DELETE ' . $this->getForeignKeyReferentialAction($definition['onDelete']); + } + return $query; + } + + /** + * drop existing index + * + * @param string $table name of table that should be used in method + * @param string $name name of the index to be dropped + * @return void + */ + public function dropIndexSql($table, $name) + { + $table = $this->conn->quoteIdentifier($table, true); + $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name), true); + return 'DROP INDEX ' . $name . ' ON ' . $table; + } + + /** + * dropTable + * + * @param string $table name of table that should be dropped from the database + * @throws PDOException + * @return void + */ + public function dropTableSql($table) + { + $table = $this->conn->quoteIdentifier($table, true); + return 'DROP TABLE ' . $table; + } + + /** + * drop existing foreign key + * + * @param string $table name of table that should be used in method + * @param string $name name of the foreign key to be dropped + * @return void + */ + public function dropForeignKey($table, $name) + { + $table = $this->conn->quoteIdentifier($table); + $name = $this->conn->quoteIdentifier($name); + + return $this->conn->exec('ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $name); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Oracle.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Oracle.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,560 @@ +. + */ + +/** + * Doctrine_Export_Oracle + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export_Oracle extends Doctrine_Export +{ + /** + * create a new database + * + * @param object $db database object that is extended by this class + * @param string $name name of the database that should be created + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + public function createDatabase($name) + { + if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) + throw new Doctrine_Export_Exception('database creation is only supported if the "emulate_database" attribute is enabled'); + + $username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name); + $password = $this->conn->dsn['password'] ? $this->conn->dsn['password'] : $name; + + $tablespace = $this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT) + ? ' DEFAULT TABLESPACE '.$this->conn->options['default_tablespace'] : ''; + + $query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password . $tablespace; + $result = $this->conn->exec($query); + + try { + $query = 'GRANT CREATE SESSION, CREATE TABLE, UNLIMITED TABLESPACE, CREATE SEQUENCE, CREATE TRIGGER TO ' . $username; + $result = $this->conn->exec($query); + } catch (Exception $e) { + $query = 'DROP USER '.$username.' CASCADE'; + $result2 = $this->conn->exec($query); + } + return true; + } + + /** + * drop an existing database + * + * @param object $this->conn database object that is extended by this class + * @param string $name name of the database that should be dropped + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + public function dropDatabase($name) + { + if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) + throw new Doctrine_Export_Exception('database dropping is only supported if the + "emulate_database" option is enabled'); + + $username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name); + + return $this->conn->exec('DROP USER ' . $username . ' CASCADE'); + } + + /** + * add an autoincrement sequence + trigger + * + * @param string $name name of the PK field + * @param string $table name of the table + * @param string $start start value for the sequence + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access private + */ + public function _makeAutoincrement($name, $table, $start = 1) + { + $sql = array(); + + if ( ! $this->conn->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) { + $table = strtoupper($table); + } + $indexName = $table . '_AI_PK'; + $definition = array( + 'primary' => true, + 'fields' => array($name => true), + ); + + $sql[] = 'DECLARE + constraints_Count NUMBER; +BEGIN + SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = \''.$table.'\' AND CONSTRAINT_TYPE = \'P\'; + IF constraints_Count = 0 THEN + EXECUTE IMMEDIATE \''.$this->createConstraintSql($table, $indexName, $definition).'\'; + END IF; +END;'; + + if (is_null($start)) { + $query = 'SELECT MAX(' . $this->conn->quoteIdentifier($name, true) . ') FROM ' . $this->conn->quoteIdentifier($table, true); + $start = $this->conn->fetchOne($query); + + ++$start; + } + + $sql[] = $this->createSequenceSql($table, $start); + + $sequenceName = $this->conn->formatter->getSequenceName($table); + $triggerName = $this->conn->quoteIdentifier($table . '_AI_PK', true); + $table = $this->conn->quoteIdentifier($table, true); + $name = $this->conn->quoteIdentifier($name, true); + $sql[] = 'CREATE TRIGGER ' . $triggerName . ' + BEFORE INSERT + ON ' . $table . ' + FOR EACH ROW +DECLARE + last_Sequence NUMBER; + last_InsertID NUMBER; +BEGIN + SELECT ' . $this->conn->quoteIdentifier($sequenceName) . '.NEXTVAL INTO :NEW.' . $name . ' FROM DUAL; + IF (:NEW.' . $name . ' IS NULL OR :NEW.'.$name.' = 0) THEN + SELECT ' . $this->conn->quoteIdentifier($sequenceName) . '.NEXTVAL INTO :NEW.' . $name . ' FROM DUAL; + ELSE + SELECT NVL(Last_Number, 0) INTO last_Sequence + FROM User_Sequences + WHERE Sequence_Name = \'' . $sequenceName . '\'; + SELECT :NEW.' . $name . ' INTO last_InsertID FROM DUAL; + WHILE (last_InsertID > last_Sequence) LOOP + SELECT ' . $this->conn->quoteIdentifier($sequenceName) . '.NEXTVAL INTO last_Sequence FROM DUAL; + END LOOP; + END IF; +END;'; + return $sql; + } + + /** + * drop an existing autoincrement sequence + trigger + * + * @param string $table name of the table + * @return void + */ + public function dropAutoincrement($table) + { + $table = strtoupper($table); + $triggerName = $table . '_AI_PK'; + $trigger_name_quoted = $this->conn->quote($triggerName); + $query = 'SELECT trigger_name FROM user_triggers'; + $query.= ' WHERE trigger_name='.$trigger_name_quoted.' OR trigger_name='.strtoupper($trigger_name_quoted); + $trigger = $this->conn->fetchOne($query); + + if ($trigger) { + $trigger_name = $this->conn->quoteIdentifier($table . '_AI_PK', true); + $trigger_sql = 'DROP TRIGGER ' . $trigger_name; + + // if throws exception, trigger for autoincrement PK could not be dropped + $this->conn->exec($trigger_sql); + + // if throws exception, sequence for autoincrement PK could not be dropped + $this->dropSequence($table); + + $indexName = $table . '_AI_PK'; + + // if throws exception, primary key for autoincrement PK could not be dropped + $this->dropConstraint($table, $indexName); + } + } + /** + * A method to return the required SQL string that fits between CREATE ... TABLE + * to create the table as a temporary table. + * + * @return string The string required to be placed between "CREATE" and "TABLE" + * to generate a temporary table, if possible. + */ + public function getTemporaryTableQuery() + { + return 'GLOBAL TEMPORARY'; + } + + /** + * getAdvancedForeignKeyOptions + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition foreign key definition + * @return string + * @access protected + */ + public function getAdvancedForeignKeyOptions(array $definition) + { + $query = ''; + if (isset($definition['onDelete']) && strtoupper(trim($definition['onDelete'])) != 'NO ACTION') { + $query .= ' ON DELETE ' . $definition['onDelete']; + } + if (isset($definition['deferrable'])) { + $query .= ' DEFERRABLE'; + } else { + $query .= ' NOT DEFERRABLE'; + } + if (isset($definition['feferred'])) { + $query .= ' INITIALLY DEFERRED'; + } else { + $query .= ' INITIALLY IMMEDIATE'; + } + return $query; + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * + * Example + * array( + * + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * 'notnull' => 1 + * 'default' => 0 + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12 + * ), + * 'password' => array( + * 'type' => 'text', + * 'length' => 12 + * ) + * ); + * @param array $options An associative array of table options: + * + * @return void + */ + public function createTable($name, array $fields, array $options = array()) + { + $this->conn->beginTransaction(); + + foreach ($this->createTableSql($name, $fields, $options) as $sql) { + $this->conn->exec($sql); + } + + $this->conn->commit(); + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * + * Example + * array( + * + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * 'notnull' => 1 + * 'default' => 0 + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12 + * ), + * 'password' => array( + * 'type' => 'text', + * 'length' => 12 + * ) + * ); + * @param array $options An associative array of table options: + * + * @return void + */ + public function createTableSql($name, array $fields, array $options = array()) + { + $sql = parent::createTableSql($name, $fields, $options); + + foreach ($fields as $fieldName => $field) { + if (isset($field['sequence'])) { + $sql[] = $this->createSequenceSql($field['sequence'], 1); + } + + if (isset($field['autoincrement']) && $field['autoincrement'] || + (isset($field['autoinc']) && $fields['autoinc'])) { + $sql = array_merge($sql, $this->_makeAutoincrement($fieldName, $name)); + } + } + + if (isset($options['indexes']) && ! empty($options['indexes'])) { + foreach ($options['indexes'] as $indexName => $definition) { + // create nonunique indexes, as they are a part od CREATE TABLE DDL + if ( ! isset($definition['type']) || + (isset($definition['type']) && strtolower($definition['type']) != 'unique')) { + $sql[] = $this->createIndexSql($name, $indexName, $definition); + } + } + } + + return $sql; + } + + /** + * drop an existing table + * + * @param string $name name of the table that should be dropped + * @return void + */ + public function dropTable($name) + { + //$this->conn->beginNestedTransaction(); + $result = $this->dropAutoincrement($name); + $result = parent::dropTable($name); + //$this->conn->completeNestedTransaction(); + return $result; + } + + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the MDB2 parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the MDB2 parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @return void + */ + public function alterTable($name, array $changes, $check = false) + { + + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + case 'remove': + case 'change': + case 'name': + case 'rename': + break; + default: + throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported'); + } + } + + if ($check) { + return false; + } + + $name = $this->conn->quoteIdentifier($name, true); + + if ( ! empty($changes['add']) && is_array($changes['add'])) { + $fields = array(); + foreach ($changes['add'] as $fieldName => $field) { + $fields[] = $this->conn->getDeclaration($fieldName, $field); + } + $result = $this->conn->exec('ALTER TABLE ' . $name . ' ADD (' . implode(', ', $fields) . ')'); + } + + if ( ! empty($changes['change']) && is_array($changes['change'])) { + $fields = array(); + foreach ($changes['change'] as $fieldName => $field) { + $fields[] = $fieldName. ' ' . $this->conn->getDeclaration('', $field['definition']); + } + $result = $this->conn->exec('ALTER TABLE ' . $name . ' MODIFY (' . implode(', ', $fields) . ')'); + } + + if ( ! empty($changes['rename']) && is_array($changes['rename'])) { + foreach ($changes['rename'] as $fieldName => $field) { + $query = 'ALTER TABLE ' . $name . ' RENAME COLUMN ' . $this->conn->quoteIdentifier($fieldName, true) + . ' TO ' . $this->conn->quoteIdentifier($field['name']); + + $result = $this->conn->exec($query); + } + } + + if ( ! empty($changes['remove']) && is_array($changes['remove'])) { + $fields = array(); + foreach ($changes['remove'] as $fieldName => $field) { + $fields[] = $this->conn->quoteIdentifier($fieldName, true); + } + $result = $this->conn->exec('ALTER TABLE ' . $name . ' DROP COLUMN ' . implode(', ', $fields)); + } + + if ( ! empty($changes['name'])) { + $changeName = $this->conn->quoteIdentifier($changes['name'], true); + $result = $this->conn->exec('ALTER TABLE ' . $name . ' RENAME TO ' . $changeName); + } + } + + /** + * create sequence + * + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string + */ + public function createSequenceSql($seqName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); + $query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE'; + $query .= ($start < 1 ? ' MINVALUE ' . $start : ''); + return $query; + } + + /** + * drop existing sequence + * + * @param object $this->conn database object that is extended by this class + * @param string $seqName name of the sequence to be dropped + * @return string + */ + public function dropSequenceSql($seqName) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); + return 'DROP SEQUENCE ' . $sequenceName; + } + + /** + * return Oracle's SQL code portion needed to set an index + * declaration to be unsed in statements like CREATE TABLE. + * + * @param string $name name of the index + * @param array $definition index definition + * @return string Oracle's SQL code portion needed to set an index + */ + public function getIndexDeclaration($name, array $definition) + { + $name = $this->conn->quoteIdentifier($name); + $type = ''; + + if ( isset($definition['type'])) + { + if(strtolower($definition['type']) == 'unique') { + $type = strtoupper($definition['type']); + } else { + throw new Doctrine_Export_Exception( + 'Unknown type '.$definition['type'] .' for index '.$name + ); + } + } else { + // only unique indexes should be defined in create table statement + return null; + } + + if (!isset($definition['fields']) || !is_array($definition['fields'])) { + throw new Doctrine_Export_Exception('No columns given for index '.$name); + } + + $query = 'CONSTRAINT '.$name.' '.$type.' ('.$this->getIndexFieldDeclarationList($definition['fields']).')'; + + return $query; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Pgsql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Pgsql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,374 @@ +. + */ + +/** + * Doctrine_Export_Pgsql + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export_Pgsql extends Doctrine_Export +{ + public $tmpConnectionDatabase = 'postgres'; + + /** + * createDatabaseSql + * + * @param string $name + * @return void + */ + public function createDatabaseSql($name) + { + $query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name); + + return $query; + } + + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @throws PDOException + * @access public + */ + public function dropDatabaseSql($name) + { + $query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name); + + return $query; + } + + /** + * getAdvancedForeignKeyOptions + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition foreign key definition + * @return string + * @access protected + */ + public function getAdvancedForeignKeyOptions(array $definition) + { + $query = ''; + if (isset($definition['match'])) { + $query .= ' MATCH ' . $definition['match']; + } + if (isset($definition['onUpdate'])) { + $query .= ' ON UPDATE ' . $definition['onUpdate']; + } + if (isset($definition['onDelete'])) { + $query .= ' ON DELETE ' . $definition['onDelete']; + } + if (isset($definition['deferrable'])) { + $query .= ' DEFERRABLE'; + } else { + $query .= ' NOT DEFERRABLE'; + } + if (isset($definition['feferred'])) { + $query .= ' INITIALLY DEFERRED'; + } else { + $query .= ' INITIALLY IMMEDIATE'; + } + return $query; + } + + /** + * generates the sql for altering an existing table on postgresql + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @see Doctrine_Export::alterTable() + * @return array + */ + public function alterTableSql($name, array $changes, $check = false) + { + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + case 'remove': + case 'change': + case 'name': + case 'rename': + break; + default: + throw new Doctrine_Export_Exception('change type "' . $changeName . '\" not yet supported'); + } + } + + if ($check) { + return true; + } + + $sql = array(); + + if (isset($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { + $query = 'ADD ' . $this->getDeclaration($fieldName, $field); + $sql[] = 'ALTER TABLE ' . $name . ' ' . $query; + } + } + + if (isset($changes['remove']) && is_array($changes['remove'])) { + foreach ($changes['remove'] as $fieldName => $field) { + $fieldName = $this->conn->quoteIdentifier($fieldName, true); + $query = 'DROP ' . $fieldName; + $sql[] = 'ALTER TABLE ' . $name . ' ' . $query; + } + } + + if (isset($changes['change']) && is_array($changes['change'])) { + foreach ($changes['change'] as $fieldName => $field) { + $fieldName = $this->conn->quoteIdentifier($fieldName, true); + if (isset($field['type'])) { + $serverInfo = $this->conn->getServerVersion(); + + if (is_array($serverInfo) && $serverInfo['major'] < 8) { + throw new Doctrine_Export_Exception('changing column type for "'.$field['type'].'\" requires PostgreSQL 8.0 or above'); + } + $query = 'ALTER ' . $fieldName . ' TYPE ' . $this->conn->datatype->getTypeDeclaration($field['definition']); + $sql[] = 'ALTER TABLE ' . $name . ' ' . $query; + } + if (array_key_exists('default', $field)) { + $query = 'ALTER ' . $fieldName . ' SET DEFAULT ' . $this->conn->quote($field['definition']['default'], $field['definition']['type']); + $sql[] = 'ALTER TABLE ' . $name . ' ' . $query; + } + if ( ! empty($field['notnull'])) { + $query = 'ALTER ' . $fieldName . ' ' . ($field['definition']['notnull'] ? 'SET' : 'DROP') . ' NOT NULL'; + $sql[] = 'ALTER TABLE ' . $name . ' ' . $query; + } + } + } + + if (isset($changes['rename']) && is_array($changes['rename'])) { + foreach ($changes['rename'] as $fieldName => $field) { + $fieldName = $this->conn->quoteIdentifier($fieldName, true); + $sql[] = 'ALTER TABLE ' . $name . ' RENAME COLUMN ' . $fieldName . ' TO ' . $this->conn->quoteIdentifier($field['name'], true); + } + } + + $name = $this->conn->quoteIdentifier($name, true); + if (isset($changes['name'])) { + $changeName = $this->conn->quoteIdentifier($changes['name'], true); + $sql[] = 'ALTER TABLE ' . $name . ' RENAME TO ' . $changeName; + } + + return $sql; + } + + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the Metabase parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the Metabase parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @throws Doctrine_Connection_Exception + * @return boolean + */ + public function alterTable($name, array $changes, $check = false) + { + $sql = $this->alterTableSql($name, $changes, $check); + foreach ($sql as $query) { + $this->conn->exec($query); + } + return true; + } + + /** + * return RDBMS specific create sequence statement + * + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string + */ + public function createSequenceSql($sequenceName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($sequenceName), true); + return 'CREATE SEQUENCE ' . $sequenceName . ' INCREMENT 1' . + ($start < 1 ? ' MINVALUE ' . $start : '') . ' START ' . $start; + } + + /** + * drop existing sequence + * + * @param string $sequenceName name of the sequence to be dropped + */ + public function dropSequenceSql($sequenceName) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($sequenceName), true); + return 'DROP SEQUENCE ' . $sequenceName; + } + + /** + * Creates a table. + * + * @param unknown_type $name + * @param array $fields + * @param array $options + * @return unknown + */ + public function createTableSql($name, array $fields, array $options = array()) + { + if ( ! $name) { + throw new Doctrine_Export_Exception('no valid table name specified'); + } + + if (empty($fields)) { + throw new Doctrine_Export_Exception('no fields specified for table ' . $name); + } + + $queryFields = $this->getFieldDeclarationList($fields); + + + if (isset($options['primary']) && ! empty($options['primary'])) { + $keyColumns = array_values($options['primary']); + $keyColumns = array_map(array($this->conn, 'quoteIdentifier'), $keyColumns); + $queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')'; + } + + $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields; + + if ($check = $this->getCheckDeclaration($fields)) { + $query .= ', ' . $check; + } + + if (isset($options['checks']) && $check = $this->getCheckDeclaration($options['checks'])) { + $query .= ', ' . $check; + } + + $query .= ')'; + + $sql[] = $query; + + if (isset($options['indexes']) && ! empty($options['indexes'])) { + foreach($options['indexes'] as $index => $definition) { + $sql[] = $this->createIndexSql($name, $index, $definition); + } + } + + if (isset($options['foreignKeys'])) { + + foreach ((array) $options['foreignKeys'] as $k => $definition) { + if (is_array($definition)) { + $sql[] = $this->createForeignKeySql($name, $definition); + } + } + } + + return $sql; + } + +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Reporter.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Reporter.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,45 @@ +. + */ + +/** + * Doctrine_Export_Reporter + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export_Reporter implements IteratorAggregate { + protected $messages = array(); + + public function add($code, $message) { + $this->messages[] = array($code, $message); + } + public function pop() { + return array_pop($this->messages); + } + public function getIterator() { + return new ArrayIterator($this->messages); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Schema.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Schema.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,150 @@ +. + */ + +/** + * Doctrine_Export_Schema + * + * Used for exporting a schema to a yaml file + * + * @package Doctrine + * @subpackage Export + * @link www.phpdoctrine.org + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @version $Revision: 1838 $ + * @author Nicolas Bérard-Nault + * @author Jonathan H. Wage + */ +class Doctrine_Export_Schema +{ + /** + * buildSchema + * + * Build schema array that can be dumped to file + * + * @param string $directory + * @return void + */ + public function buildSchema($directory = null, $models = array()) + { + if ($directory !== null) { + $loadedModels = Doctrine::filterInvalidModels(Doctrine::loadModels($directory)); + } else { + $loadedModels = Doctrine::getLoadedModels(); + } + + $array = array(); + + $parent = new ReflectionClass('Doctrine_Record'); + + $sql = array(); + $fks = array(); + + // we iterate through the diff of previously declared classes + // and currently declared classes + foreach ($loadedModels as $className) { + if ( ! empty($models) && !in_array($className, $models)) { + continue; + } + + $recordTable = Doctrine::getTable($className); + + $data = $recordTable->getExportableFormat(); + + $table = array(); + $remove = array('ptype', 'ntype', 'alltypes'); + // Fix explicit length in schema, concat it to type in this format: type(length) + foreach ($data['columns'] AS $name => $column) { + if (isset($column['length']) && $column['length'] && isset($column['scale']) && $column['scale']) { + $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ', ' . $column['scale'] . ')'; + unset($data['columns'][$name]['length'], $data['columns'][$name]['scale']); + } else { + $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; + unset($data['columns'][$name]['length']); + } + // Strip out schema information which is not necessary to be dumped to the yaml schema file + foreach ($remove as $value) { + if (isset($data['columns'][$name][$value])) { + unset($data['columns'][$name][$value]); + } + } + + // If type is the only property of the column then lets abbreviate the syntax + // columns: { name: string(255) } + if (count($data['columns'][$name]) === 1 && isset($data['columns'][$name]['type'])) { + $type = $data['columns'][$name]['type']; + unset($data['columns'][$name]); + $data['columns'][$name] = $type; + } + } + $table['tableName'] = $data['tableName']; + $table['columns'] = $data['columns']; + + $relations = $recordTable->getRelations(); + foreach ($relations as $key => $relation) { + $relationData = $relation->toArray(); + + $relationKey = $relationData['alias']; + + if (isset($relationData['refTable']) && $relationData['refTable']) { + $table['relations'][$relationKey]['refClass'] = $relationData['refTable']->getComponentName(); + } + + if (isset($relationData['class']) && $relationData['class'] && $relation['class'] != $relationKey) { + $table['relations'][$relationKey]['class'] = $relationData['class']; + } + + $table['relations'][$relationKey]['local'] = $relationData['local']; + $table['relations'][$relationKey]['foreign'] = $relationData['foreign']; + + if ($relationData['type'] === Doctrine_Relation::ONE) { + $table['relations'][$relationKey]['type'] = 'one'; + } else if($relationData['type'] === Doctrine_Relation::MANY) { + $table['relations'][$relationKey]['type'] = 'many'; + } else { + $table['relations'][$relationKey]['type'] = 'one'; + } + } + + $array[$className] = $table; + } + + return $array; + } + + /** + * exportSchema + * + * @param string $schema + * @param string $directory + * @return string $string of data in the specified format + * @return void + */ + public function exportSchema($schema, $format = 'yml', $directory = null, $models = array()) + { + $array = $this->buildSchema($directory, $models); + + if (is_dir($schema)) { + $schema = $schema . DIRECTORY_SEPARATOR . 'schema.' . $format; + } + + return Doctrine_Parser::dump($array, $format, $schema); + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Sqlite.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Export/Sqlite.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,421 @@ +. + */ + +/** + * Doctrine_Export_Sqlite + * + * @package Doctrine + * @subpackage Export + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + */ +class Doctrine_Export_Sqlite extends Doctrine_Export +{ + /** + * dropDatabase + * + * drop an existing database + * + * @param string $databaseFile Path of the database that should be dropped + * @throws Doctrine_Export_Exception if the database file does not exist + * @throws Doctrine_Export_Exception if something failed during the removal of the database file + * @return void + */ + public function dropDatabase($databaseFile) + { + if ( ! @file_exists($databaseFile)) { + throw new Doctrine_Export_Exception('database does not exist'); + } + + $result = @unlink($databaseFile); + + if ( ! $result) { + throw new Doctrine_Export_Exception('could not remove the database file'); + } + } + + /** + * createDatabase + * + * Create sqlite database file + * + * @param string $databaseFile Path of the database that should be dropped + * @return void + */ + public function createDatabase($databaseFile) + { + return new PDO('sqlite:' . $databaseFile); + } + + /** + * Get the stucture of a field into an array + * + * @param string $table name of the table on which the index is to be created + * @param string $name name of the index to be created + * @param array $definition associative array that defines properties of the index to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the index fields as array + * indexes. Each entry of this array is set to another type of associative + * array that specifies properties of the index that are specific to + * each field. + * + * Currently, only the sorting property is supported. It should be used + * to define the sorting direction of the index. It may be set to either + * ascending or descending. + * + * Not all DBMS support index sorting direction configuration. The DBMS + * drivers of those that do not support it ignore this property. Use the + * function support() to determine whether the DBMS driver can manage indexes. + * Example + * array( + * 'fields' => array( + * 'user_name' => array( + * 'sorting' => 'ascending' + * ), + * 'last_login' => array() + * ) + * ) + * @throws PDOException + * @return void + */ + public function createIndexSql($table, $name, array $definition) + { + $name = $this->conn->formatter->getIndexName($name); + $name = $this->conn->quoteIdentifier($name); + $type = ''; + + if (isset($definition['type'])) { + switch (strtolower($definition['type'])) { + case 'unique': + $type = strtoupper($definition['type']) . ' '; + break; + default: + throw new Doctrine_Export_Exception( + 'Unknown type ' . $definition['type'] . ' for index ' . $name . ' in table ' . $table + ); + } + } + + $query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table; + $query .= ' (' . $this->getIndexFieldDeclarationList($definition['fields']) . ')'; + + return $query; + } + + /** + * getIndexFieldDeclarationList + * Obtain DBMS specific SQL code portion needed to set an index + * declaration to be used in statements like CREATE TABLE. + * + * @return string + */ + public function getIndexFieldDeclarationList(array $fields) + { + $declFields = array(); + + foreach ($fields as $fieldName => $field) { + $fieldString = $this->conn->quoteIdentifier($fieldName); + + if (is_array($field)) { + if (isset($field['sorting'])) { + $sort = strtoupper($field['sorting']); + switch ($sort) { + case 'ASC': + case 'DESC': + $fieldString .= ' ' . $sort; + break; + default: + throw new Doctrine_Export_Exception('Unknown index sorting option given.'); + } + } + } else { + $fieldString = $this->conn->quoteIdentifier($field); + } + $declFields[] = $fieldString; + } + return implode(', ', $declFields); + } + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * The indexes of the array entries are the names of the fields of the table an + * the array entry values are associative arrays like those that are meant to be + * passed with the field definitions to get[Type]Declaration() functions. + * array( + * 'id' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * 'notnull' => 1 + * 'default' => 0 + * ), + * 'name' => array( + * 'type' => 'text', + * 'length' => 12 + * ), + * 'password' => array( + * 'type' => 'text', + * 'length' => 12 + * ) + * ); + * @param array $options An associative array of table options: + * + * @return void + */ + public function createTableSql($name, array $fields, array $options = array()) + { + if ( ! $name) { + throw new Doctrine_Export_Exception('no valid table name specified'); + } + + if (empty($fields)) { + throw new Doctrine_Export_Exception('no fields specified for table '.$name); + } + $queryFields = $this->getFieldDeclarationList($fields); + + $autoinc = false; + foreach($fields as $field) { + if (isset($field['autoincrement']) && $field['autoincrement'] || + (isset($field['autoinc']) && $field['autoinc'])) { + $autoinc = true; + break; + } + } + + if ( ! $autoinc && isset($options['primary']) && ! empty($options['primary'])) { + $keyColumns = array_values($options['primary']); + $keyColumns = array_map(array($this->conn, 'quoteIdentifier'), $keyColumns); + $queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')'; + } + + $name = $this->conn->quoteIdentifier($name, true); + $sql = 'CREATE TABLE ' . $name . ' (' . $queryFields; + + if ($check = $this->getCheckDeclaration($fields)) { + $sql .= ', ' . $check; + } + + if (isset($options['checks']) && $check = $this->getCheckDeclaration($options['checks'])) { + $sql .= ', ' . $check; + } + + $sql .= ')'; + + $query[] = $sql; + + if (isset($options['indexes']) && ! empty($options['indexes'])) { + foreach ($options['indexes'] as $index => $definition) { + $query[] = $this->createIndexSql($name, $index, $definition); + } + } + + return $query; + } + + /** + * getAdvancedForeignKeyOptions + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition foreign key definition + * @return string + * @access protected + */ + public function getAdvancedForeignKeyOptions(array $definition) + { + $query = ''; + if (isset($definition['match'])) { + $query .= ' MATCH ' . $definition['match']; + } + if (isset($definition['onUpdate'])) { + $query .= ' ON UPDATE ' . $definition['onUpdate']; + } + if (isset($definition['onDelete'])) { + $query .= ' ON DELETE ' . $definition['onDelete']; + } + if (isset($definition['deferrable'])) { + $query .= ' DEFERRABLE'; + } else { + $query .= ' NOT DEFERRABLE'; + } + if (isset($definition['feferred'])) { + $query .= ' INITIALLY DEFERRED'; + } else { + $query .= ' INITIALLY IMMEDIATE'; + } + return $query; + } + + /** + * create sequence + * + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return boolean + */ + public function createSequence($seqName, $start = 1, array $options = array()) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); + $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); + $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . ' INTEGER PRIMARY KEY DEFAULT 0 NOT NULL)'; + + $this->conn->exec($query); + + if ($start == 1) { + return true; + } + + try { + $this->conn->exec('INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (' . ($start-1) . ')'); + return true; + } catch(Doctrine_Connection_Exception $e) { + // Handle error + + try { + $result = $db->exec('DROP TABLE ' . $sequenceName); + } catch(Doctrine_Connection_Exception $e) { + throw new Doctrine_Export_Exception('could not drop inconsistent sequence table'); + } + } + throw new Doctrine_Export_Exception('could not create sequence table'); + } + + /** + * drop existing sequence + * + * @param string $sequenceName name of the sequence to be dropped + * @return string + */ + public function dropSequenceSql($sequenceName) + { + $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($sequenceName), true); + + return 'DROP TABLE ' . $sequenceName; + } + + public function alterTableSql($name, array $changes, $check = false) + { + if ( ! $name) { + throw new Doctrine_Export_Exception('no valid table name specified'); + } + foreach ($changes as $changeName => $change) { + switch ($changeName) { + case 'add': + case 'change': + case 'rename': + case 'name': + break; + default: + throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported'); + } + } + + if ($check) { + return true; + } + + $query = ''; + if ( ! empty($changes['name'])) { + $change_name = $this->conn->quoteIdentifier($changes['name']); + $query .= 'RENAME TO ' . $change_name; + } + + if ( ! empty($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + $query.= 'ADD ' . $this->getDeclaration($fieldName, $field); + } + } + + $rename = array(); + if ( ! empty($changes['rename']) && is_array($changes['rename'])) { + foreach ($changes['rename'] as $fieldName => $field) { + $rename[$field['name']] = $fieldName; + } + } + + if ( ! empty($changes['change']) && is_array($changes['change'])) { + foreach ($changes['change'] as $fieldName => $field) { + if ($query) { + $query.= ', '; + } + if (isset($rename[$fieldName])) { + $oldFieldName = $rename[$fieldName]; + unset($rename[$fieldName]); + } else { + $oldFieldName = $fieldName; + } + $oldFieldName = $this->conn->quoteIdentifier($oldFieldName, true); + $query .= 'CHANGE ' . $oldFieldName . ' ' + . $this->getDeclaration($fieldName, $field['definition']); + } + } + + if ( ! empty($rename) && is_array($rename)) { + foreach ($rename as $renameName => $renamedField) { + if ($query) { + $query.= ', '; + } + $field = $changes['rename'][$renamedField]; + $renamedField = $this->conn->quoteIdentifier($renamedField, true); + $query .= 'CHANGE ' . $renamedField . ' ' + . $this->getDeclaration($field['name'], $field['definition']); + } + } + + if ( ! $query) { + return false; + } + + $name = $this->conn->quoteIdentifier($name, true); + + return 'ALTER TABLE ' . $name . ' ' . $query; + } + + /** + * createForeignKey + * + * Sqlite does not support foreign keys so we are not even going to do anything if this function is called + * to avoid any sql errors if a user tries to use this on sqlite + * + * @param string $table name of the table on which the foreign key is to be created + * @param array $definition associative array that defines properties of the foreign key to be created. + * @return string + */ + public function createForeignKey($table, array $definition) + { + return false; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,145 @@ +. + */ + +/** + * Doctrine_Expression + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression +{ + protected $_expression; + protected $_conn; + protected $_tokenizer; + + /** + * Create an expression + * + * @param string $expr The expression + * @param Doctrine_Connection $conn The connection (optional) + * @return void + */ + public function __construct($expr, $conn = null) + { + $this->_tokenizer = new Doctrine_Query_Tokenizer(); + $this->setExpression($expr); + if ($conn !== null) { + $this->_conn = $conn; + } + } + + /** + * getConnection + * + * @return Doctrine_Connection The connection + */ + public function getConnection() + { + if ( ! isset($this->_conn)) { + return Doctrine_Manager::connection(); + } + + return $this->_conn; + } + + /** + * setExpression + * + * @param string $clause The expression to set + * @return void + */ + public function setExpression($clause) + { + $this->_expression = $this->parseClause($clause); + } + + /** + * parseExpression + * + * @todo: What does this function do? + * + * @param string $expr The expression to parse + * @return void + */ + public function parseExpression($expr) + { + $pos = strpos($expr, '('); + $quoted = (substr($expr, 0, 1) === "'" && substr($expr, -1) === "'"); + if ($pos === false || $quoted) { + return $expr; + } + + // get the name of the function + $name = substr($expr, 0, $pos); + $argStr = substr($expr, ($pos + 1), -1); + + // parse args + foreach ($this->_tokenizer->bracketExplode($argStr, ',') as $arg) { + $args[] = $this->parseClause($arg); + } + + return call_user_func_array(array($this->getConnection()->expression, $name), $args); + } + + /** + * parseClause + * + * @param string $clause The clause + * @return string The parse clause + */ + public function parseClause($clause) + { + $e = $this->_tokenizer->bracketExplode($clause, ' '); + + foreach ($e as $k => $expr) { + $e[$k] = $this->parseExpression($expr); + } + + return implode(' ', $e); + } + + /** + * getSql + * + * @return string The expression + */ + public function getSql() + { + + return $this->_expression; + } + + /** + * __toString + * + * @return void + */ + public function __toString() + { + return $this->getSql(); + } +} diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Driver.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Driver.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,773 @@ +. + */ + +/** + * Doctrine_Expression_Driver + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Driver extends Doctrine_Connection_Module +{ + public function getIdentifier($column) + { + return $column; + } + public function getIdentifiers($columns) + { + return $columns; + } + + /** + * regexp + * returns the regular expression operator + * + * @return string + */ + public function regexp() + { + throw new Doctrine_Expression_Exception('Regular expression operator is not supported by this database driver.'); + } + + /** + * Returns the average value of a column + * + * @param string $column the column to use + * @return string generated sql including an AVG aggregate function + */ + public function avg($column) + { + $column = $this->getIdentifier($column); + return 'AVG(' . $column . ')'; + } + + /** + * Returns the number of rows (without a NULL value) of a column + * + * If a '*' is used instead of a column the number of selected rows + * is returned. + * + * @param string|integer $column the column to use + * @return string generated sql including a COUNT aggregate function + */ + public function count($column) + { + $column = $this->getIdentifier($column); + return 'COUNT(' . $column . ')'; + } + + /** + * Returns the highest value of a column + * + * @param string $column the column to use + * @return string generated sql including a MAX aggregate function + */ + public function max($column) + { + $column = $this->getIdentifier($column); + return 'MAX(' . $column . ')'; + } + + /** + * Returns the lowest value of a column + * + * @param string $column the column to use + * @return string + */ + public function min($column) + { + $column = $this->getIdentifier($column); + return 'MIN(' . $column . ')'; + } + + /** + * Returns the total sum of a column + * + * @param string $column the column to use + * @return string + */ + public function sum($column) + { + $column = $this->getIdentifier($column); + return 'SUM(' . $column . ')'; + } + + // scalar functions + + /** + * Returns the md5 sum of a field. + * + * Note: Not SQL92, but common functionality + * + * @return string + */ + public function md5($column) + { + $column = $this->getIdentifier($column); + return 'MD5(' . $column . ')'; + } + + /** + * Returns the length of a text field. + * + * @param string $expression1 + * @param string $expression2 + * @return string + */ + public function length($column) + { + $column = $this->getIdentifier($column); + return 'LENGTH(' . $column . ')'; + } + + /** + * Rounds a numeric field to the number of decimals specified. + * + * @param string $expression1 + * @param string $expression2 + * @return string + */ + public function round($column, $decimals = 0) + { + $column = $this->getIdentifier($column); + + return 'ROUND(' . $column . ', ' . $decimals . ')'; + } + + /** + * Returns the remainder of the division operation + * $expression1 / $expression2. + * + * @param string $expression1 + * @param string $expression2 + * @return string + */ + public function mod($expression1, $expression2) + { + $expression1 = $this->getIdentifier($expression1); + $expression2 = $this->getIdentifier($expression2); + return 'MOD(' . $expression1 . ', ' . $expression2 . ')'; + } + + /** + * trim + * returns the string $str with leading and proceeding space characters removed + * + * @param string $str literal string or column name + * @return string + */ + public function trim($str) + { + return 'TRIM(' . $str . ')'; + } + + /** + * rtrim + * returns the string $str with proceeding space characters removed + * + * @param string $str literal string or column name + * @return string + */ + public function rtrim($str) + { + return 'RTRIM(' . $str . ')'; + } + + /** + * ltrim + * returns the string $str with leading space characters removed + * + * @param string $str literal string or column name + * @return string + */ + public function ltrim($str) + { + return 'LTRIM(' . $str . ')'; + } + + /** + * upper + * Returns the string $str with all characters changed to + * uppercase according to the current character set mapping. + * + * @param string $str literal string or column name + * @return string + */ + public function upper($str) + { + return 'UPPER(' . $str . ')'; + } + + /** + * lower + * Returns the string $str with all characters changed to + * lowercase according to the current character set mapping. + * + * @param string $str literal string or column name + * @return string + */ + public function lower($str) + { + return 'LOWER(' . $str . ')'; + } + + /** + * locate + * returns the position of the first occurrence of substring $substr in string $str + * + * @param string $substr literal string to find + * @param string $str literal string + * @return integer + */ + public function locate($str, $substr) + { + return 'LOCATE(' . $str . ', ' . $substr . ')'; + } + + /** + * Returns the current system date. + * + * @return string + */ + public function now() + { + return 'NOW()'; + } + + /** + * soundex + * Returns a string to call a function to compute the + * soundex encoding of a string + * + * The string "?000" is returned if the argument is NULL. + * + * @param string $value + * @return string SQL soundex function with given parameter + */ + public function soundex($value) + { + throw new Doctrine_Expression_Exception('SQL soundex function not supported by this driver.'); + } + + /** + * return string to call a function to get a substring inside an SQL statement + * + * Note: Not SQL92, but common functionality. + * + * SQLite only supports the 2 parameter variant of this function + * + * @param string $value an sql string literal or column name/alias + * @param integer $position where to start the substring portion + * @param integer $length the substring portion length + * @return string SQL substring function with given parameters + */ + public function substring($value, $from, $len = null) + { + $value = $this->getIdentifier($value); + if ($len === null) + return 'SUBSTRING(' . $value . ' FROM ' . $from . ')'; + else { + $len = $this->getIdentifier($len); + return 'SUBSTRING(' . $value . ' FROM ' . $from . ' FOR ' . $len . ')'; + } + } + + /** + * Returns a series of strings concatinated + * + * concat() accepts an arbitrary number of parameters. Each parameter + * must contain an expression or an array with expressions. + * + * @param string|array(string) strings that will be concatinated. + */ + public function concat() + { + $args = func_get_args(); + + return 'CONCAT(' . join(', ', (array) $args) . ')'; + } + + /** + * Returns the SQL for a logical not. + * + * Example: + * + * $q = new Doctrine_Query(); + * $e = $q->expr; + * $q->select('*')->from('table') + * ->where($e->eq('id', $e->not('null')); + * + * + * @return string a logical expression + */ + public function not($expression) + { + $expression = $this->getIdentifier($expression); + return 'NOT(' . $expression . ')'; + } + + /** + * Returns the SQL to perform the same mathematical operation over an array + * of values or expressions. + * + * basicMath() accepts an arbitrary number of parameters. Each parameter + * must contain a value or an expression or an array with values or + * expressions. + * + * @param string $type the type of operation, can be '+', '-', '*' or '/'. + * @param string|array(string) + * @return string an expression + */ + private function basicMath($type, array $args) + { + $elements = $this->getIdentifiers($args); + if (count($elements) < 1) { + return ''; + } + if (count($elements) == 1) { + return $elements[0]; + } else { + return '(' . implode(' ' . $type . ' ', $elements) . ')'; + } + } + + /** + * Returns the SQL to add values or expressions together. + * + * add() accepts an arbitrary number of parameters. Each parameter + * must contain a value or an expression or an array with values or + * expressions. + * + * Example: + * + * $q = new Doctrine_Query(); + * $e = $q->expr; + * + * $q->select('u.*') + * ->from('User u') + * ->where($e->eq($e->add('id', 2), 12)); + * + * + * @param string|array(string) + * @return string an expression + */ + public function add(array $args) + { + return $this->basicMath('+', $args); + } + + /** + * Returns the SQL to subtract values or expressions from eachother. + * + * subtract() accepts an arbitrary number of parameters. Each parameter + * must contain a value or an expression or an array with values or + * expressions. + * + * Example: + * + * $q = new Doctrine_Query(); + * $e = $q->expr; + * + * $q->select('u.*') + * ->from('User u') + * ->where($e->eq($e->sub('id', 2), 12)); + * + * + * @param string|array(string) + * @return string an expression + */ + public function sub(array $args) + { + return $this->basicMath('-', $args ); + } + + /** + * Returns the SQL to multiply values or expressions by eachother. + * + * multiply() accepts an arbitrary number of parameters. Each parameter + * must contain a value or an expression or an array with values or + * expressions. + * + * Example: + * + * $q = new Doctrine_Query(); + * $e = $q->expr; + * + * $q->select('u.*') + * ->from('User u') + * ->where($e->eq($e->mul('id', 2), 12)); + * + * + * @param string|array(string) + * @return string an expression + */ + public function mul(array $args) + { + return $this->basicMath('*', $args); + } + + /** + * Returns the SQL to divide values or expressions by eachother. + * + * divide() accepts an arbitrary number of parameters. Each parameter + * must contain a value or an expression or an array with values or + * expressions. + * + * Example: + * + * $q = new Doctrine_Query(); + * $e = $q->expr; + * + * $q->select('u.*') + * ->from('User u') + * ->where($e->eq($e->div('id', 2), 12)); + * + * + * @param string|array(string) + * @return string an expression + */ + public function div(array $args) + { + return $this->basicMath('/', $args); + } + + /** + * Returns the SQL to check if two values are equal. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->eq('id', 1)); + * + * + * @param string $value1 logical expression to compare + * @param string $value2 logical expression to compare with + * @return string logical expression + */ + public function eq($value1, $value2) + { + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $value1 . ' = ' . $value2; + } + + /** + * Returns the SQL to check if two values are unequal. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->neq('id', 1)); + * + * + * @param string $value1 logical expression to compare + * @param string $value2 logical expression to compare with + * @return string logical expression + */ + public function neq($value1, $value2) + { + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $value1 . ' <> ' . $value2; + } + + /** + * Returns the SQL to check if one value is greater than another value. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->gt('id', 1)); + * + * + * @param string $value1 logical expression to compare + * @param string $value2 logical expression to compare with + * @return string logical expression + */ + public function gt($value1, $value2) + { + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $value1 . ' > ' . $value2; + } + + /** + * Returns the SQL to check if one value is greater than or equal to + * another value. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->gte('id', 1)); + * + * + * @param string $value1 logical expression to compare + * @param string $value2 logical expression to compare with + * @return string logical expression + */ + public function gte($value1, $value2) + { + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $value1 . ' >= ' . $value2; + } + + /** + * Returns the SQL to check if one value is less than another value. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->lt('id', 1)); + * + * + * @param string $value1 logical expression to compare + * @param string $value2 logical expression to compare with + * @return string logical expression + */ + public function lt($value1, $value2) + { + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $value1 . ' < ' . $value2; + } + + /** + * Returns the SQL to check if one value is less than or equal to + * another value. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->lte('id', 1)); + * + * + * @param string $value1 logical expression to compare + * @param string $value2 logical expression to compare with + * @return string logical expression + */ + public function lte($value1, $value2) + { + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $value1 . ' <= ' . $value2; + } + + /** + * Returns the SQL to check if a value is one in a set of + * given values.. + * + * in() accepts an arbitrary number of parameters. The first parameter + * must always specify the value that should be matched against. Successive + * must contain a logical expression or an array with logical expressions. + * These expressions will be matched against the first parameter. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->in( 'id', array(1,2,3))); + * + * + * @param string $column the value that should be matched against + * @param string|array(string) values that will be matched against $column + * @return string logical expression + */ + public function in($column, $values) + { + if ( ! is_array($values)) { + $values = array($values); + } + $values = $this->getIdentifiers($values); + $column = $this->getIdentifier($column); + + if (count($values) == 0) { + throw new Doctrine_Expression_Exception('Values array for IN operator should not be empty.'); + } + return $column . ' IN (' . implode(', ', $values) . ')'; + } + + /** + * Returns SQL that checks if a expression is null. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->isNull('id')); + * + * + * @param string $expression the expression that should be compared to null + * @return string logical expression + */ + public function isNull($expression) + { + $expression = $this->getIdentifier($expression); + return $expression . ' IS NULL'; + } + + /** + * Returns SQL that checks if a expression is not null. + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->isNotNull('id')); + * + * + * @param string $expression the expression that should be compared to null + * @return string logical expression + */ + public function isNotNull($expression) + { + $expression = $this->getIdentifier($expression); + return $expression . ' IS NOT NULL'; + } + + /** + * Returns SQL that checks if an expression evaluates to a value between + * two values. + * + * The parameter $expression is checked if it is between $value1 and $value2. + * + * Note: There is a slight difference in the way BETWEEN works on some databases. + * http://www.w3schools.com/sql/sql_between.asp. If you want complete database + * independence you should avoid using between(). + * + * Example: + * + * $q = new Doctrine_Query(); + * $q->select('u.*') + * ->from('User u') + * ->where($q->expr->between('id', 1, 5)); + * + * + * @param string $expression the value to compare to + * @param string $value1 the lower value to compare with + * @param string $value2 the higher value to compare with + * @return string logical expression + */ + public function between($expression, $value1, $value2) + { + $expression = $this->getIdentifier($expression); + $value1 = $this->getIdentifier($value1); + $value2 = $this->getIdentifier($value2); + return $expression . ' BETWEEN ' .$value1 . ' AND ' . $value2; + } + + /** + * Returns global unique identifier + * + * @return string to get global unique identifier + */ + public function guid() + { + throw new Doctrine_Expression_Exception('method not implemented'); + } + + /** + * returns arcus cosine SQL string + * + * @return string + */ + public function acos($value) + { + return 'ACOS(' . $value . ')'; + } + + /** + * sin + * + * @param string $value + * @return void + */ + public function sin($value) + { + return 'SIN(' . $value . ')'; + } + + /** + * pi + * + * @return void + */ + public function pi() + { + return 'PI()'; + } + + /** + * cos + * + * @param string $value + * @return void + */ + public function cos($value) + { + return 'COS(' . $value . ')'; + } + + /** + * coalesce + * + * @return string + */ + public function coalesce() + { + $args = func_get_args(); + + return 'COALESCE(' . join(', ', (array) $args) . ')'; + } + + /** + * __call + * + * for all native RDBMS functions the function name itself is returned + */ + public function __call($m, $a) + { + if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EXPR) { + throw new Doctrine_Expression_Exception('Unknown expression ' . $m); + } + return $m . '(' . implode(', ', $a) . ')'; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Exception.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Exception.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Expression_Exception + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Exception extends Doctrine_Exception +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Firebird.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Firebird.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,57 @@ +. + */ + +/** + * Doctrine_Expression_Firebird + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + * @author Lorenzo Alberton (PEAR MDB2 Interbase driver) + * @author Lukas Smith (PEAR MDB2 library) + */ +class Doctrine_Expression_Firebird extends Doctrine_Expression_Driver +{ + /** + * return string for internal table used when calling only a function + * + * @return string for internal table used when calling only a function + * @access public + */ + public function functionTable() + { + return ' FROM RDB$DATABASE'; + } + + /** + * build string to define escape pattern string + * + * @return string define escape pattern + */ + function patternEscapeString() + { + return " ESCAPE '". $this->conn->string_quoting['escape_pattern'] ."'"; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Informix.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Informix.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Expression_Informix + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Informix extends Doctrine_Expression +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Mock.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Mock.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,35 @@ +. + */ + +/** + * Doctrine_Expression_Mock + * Mock driver that is used for testing purposes + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Mock extends Doctrine_Expression_Driver +{ } \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Mssql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Mssql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,104 @@ +. + */ + +/** + * Doctrine_Expression_Mssql + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5836 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Mssql extends Doctrine_Expression_Driver +{ + /** + * Return string to call a variable with the current timestamp inside an SQL statement + * There are three special variables for current date and time: + * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type) + * - CURRENT_DATE (date, DATE type) + * - CURRENT_TIME (time, TIME type) + * + * @return string to call a variable with the current timestamp + * @access public + */ + public function now($type = 'timestamp') + { + switch ($type) { + case 'time': + case 'date': + case 'timestamp': + default: + return 'GETDATE()'; + } + } + + /** + * return string to call a function to get a substring inside an SQL statement + * + * @return string to call a function to get a substring + */ + public function substring($value, $position, $length = null) + { + if ( ! is_null($length)) { + return 'SUBSTRING(' . $value . ', ' . $position . ', ' . $length . ')'; + } + return 'SUBSTRING(' . $value . ', ' . $position . ', LEN(' . $value . ') - ' . $position . ' + 1)'; + } + + /** + * Returns string to concatenate two or more string parameters + * + * @param string $arg1 + * @param string $arg2 + * @param string $values... + * @return string to concatenate two strings + */ + public function concat() + { + $args = func_get_args(); + return '(' . implode(' + ', $args) . ')'; + } + + /** + * Returns global unique identifier + * + * @return string to get global unique identifier + */ + public function guid() + { + return 'NEWID()'; + } + + /** + * Returns the length of a text field + * + * @param string $column + * + * @return string + */ + public function length($column) + { + return 'LEN (' . $column . ')'; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Mysql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Mysql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,160 @@ +. + */ + +/** + * Doctrine_Expression_Mysql + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5837 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Mysql extends Doctrine_Expression_Driver +{ + /** + * returns the regular expression operator + * + * @return string + */ + public function regexp() + { + return 'RLIKE'; + } + + /** + * return string to call a function to get random value inside an SQL statement + * + * @return string to generate float between 0 and 1 + */ + public function random() + { + return 'RAND()'; + } + + /** + * build a pattern matching string + * + * EXPERIMENTAL + * + * WARNING: this function is experimental and may change signature at + * any time until labelled as non-experimental + * + * @access public + * + * @param array $pattern even keys are strings, odd are patterns (% and _) + * @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future) + * @param string $field optional field name that is being matched against + * (might be required when emulating ILIKE) + * + * @return string SQL pattern + */ + public function matchPattern($pattern, $operator = null, $field = null) + { + $match = ''; + if ( ! is_null($operator)) { + $field = is_null($field) ? '' : $field.' '; + $operator = strtoupper($operator); + switch ($operator) { + // case insensitive + case 'ILIKE': + $match = $field.'LIKE '; + break; + // case sensitive + case 'LIKE': + $match = $field.'LIKE BINARY '; + break; + default: + throw new Doctrine_Expression_Mysql_Exception('not a supported operator type:'. $operator); + } + } + $match.= "'"; + foreach ($pattern as $key => $value) { + if ($key % 2) { + $match .= $value; + } else { + $match .= $this->conn->escapePattern($this->conn->escape($value)); + } + } + $match.= "'"; + $match.= $this->patternEscapeString(); + return $match; + } + + /** + * Returns global unique identifier + * + * @return string to get global unique identifier + */ + public function guid() + { + return 'UUID()'; + } + + /** + * Returns the year from dbms + * + * @param string $column + * @return string to get year from dbms + */ + public function year($column) + { + $column = $this->getIdentifier($column); + return 'YEAR(' . $column . ')'; + } + + /** + * Returns the month from dbms + * + * @param string $column + * @return string to get month from dbms + */ + public function month($column) + { + $column = $this->getIdentifier($column); + return 'MONTH(' . $column . ')'; + } + + /** + * Returns day from dbms + * + * @param string $column + * @return string to get day from dbms + */ + public function day($column) + { + $column = $this->getIdentifier($column); + return 'DAY(' . $column . ')'; + } + + /** + * Returns soundex from dbms + * + * @param string $column + * @return string to get soundex from dbms + */ + public function soundex($column) + { + return 'SOUNDEX(' . $column . ')'; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Oracle.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Oracle.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,108 @@ +. + */ + +/** + * Doctrine_Expression_Sqlite + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Oracle extends Doctrine_Expression_Driver +{ + /** + * Returns a series of strings concatinated + * + * concat() accepts an arbitrary number of parameters. Each parameter + * must contain an expression + * + * @param string $arg1, $arg2 ... $argN strings that will be concatinated. + * @return string + */ + public function concat() + { + $args = func_get_args(); + + return join(' || ' , $args); + } + + /** + * return string to call a function to get a substring inside an SQL statement + * + * Note: Not SQL92, but common functionality. + * + * @param string $value an sql string literal or column name/alias + * @param integer $position where to start the substring portion + * @param integer $length the substring portion length + * @return string SQL substring function with given parameters + */ + public function substring($value, $position, $length = null) + { + if ($length !== null) + return "SUBSTR($value, $position, $length)"; + + return "SUBSTR($value, $position)"; + } + + /** + * Return string to call a variable with the current timestamp inside an SQL statement + * There are three special variables for current date and time: + * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type) + * - CURRENT_DATE (date, DATE type) + * - CURRENT_TIME (time, TIME type) + * + * @return string to call a variable with the current timestamp + */ + public function now($type = 'timestamp') + { + switch ($type) { + case 'date': + case 'time': + case 'timestamp': + default: + return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')'; + } + } + + /** + * random + * + * @return string an oracle SQL string that generates a float between 0 and 1 + */ + public function random() + { + return 'dbms_random.value'; + } + + /** + * Returns global unique identifier + * + * @return string to get global unique identifier + */ + public function guid() + { + return 'SYS_GUID()'; + } +} \ No newline at end of file diff -r 42c8da096ceb -r d17aa71a58e0 web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Pgsql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/web/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Expression/Pgsql.php Mon Oct 05 16:58:06 2009 +0200 @@ -0,0 +1,233 @@ +. + */ + +/** + * Doctrine_Expression_Pgsql + * + * @package Doctrine + * @subpackage Expression + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 5801 $ + * @author Konsta Vesterinen + */ +class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver +{ + /** + * Returns the md5 sum of a field. + * + * Note: Not SQL92, but common functionality + * + * md5() works with the default PostgreSQL 8 versions. + * + * If you are using PostgreSQL 7.x or older you need + * to make sure that the digest procedure is installed. + * If you use RPMS (Redhat and Mandrake) install the postgresql-contrib + * package. You must then install the procedure by running this shell command: + * + * psql [dbname] < /usr/share/pgsql/contrib/pgcrypto.sql + * + * You should make sure you run this as the postgres user. + * + * @return string + */ + public function md5($column) + { + $column = $this->getIdentifier($column); + + return 'MD5(' . $column . ')'; + } + + /** + * Returns part of a string. + * + * Note: Not SQL92, but common functionality. + * + * @param string $value the target $value the string or the string column. + * @param int $from extract from this characeter. + * @param int $len extract this amount of characters. + * @return string sql that extracts part of a string. + */ + public function substring($value, $from, $len = null) + { + $value = $this->getIdentifier($value); + + if ($len === null) { + $len = $this->getIdentifier($len); + return 'SUBSTR(' . $value . ', ' . $from . ')'; + } else { + return 'SUBSTR(' . $value . ', ' . $from . ', ' . $len . ')'; + } + } + + /** + * Returns a series of strings concatinated + * + * concat() accepts an arbitrary number of parameters. Each parameter + * must contain an expression or an array with expressions. + * + * @param string|array(string) strings that will be concatinated. + * @return string + */ + + + /** + * PostgreSQLs AGE( [, ]) function. + * + * @param string $timestamp1 timestamp to subtract from NOW() + * @param string $timestamp2 optional; if given: subtract arguments + * @return string + */ + public function age($timestamp1, $timestamp2 = null) { + if ( $timestamp2 == null ) { + return 'AGE(' . $timestamp1 . ')'; + } + return 'AGE(' . $timestamp1 . ', ' . $timestamp2 . ')'; + } + + /** + * PostgreSQLs DATE_PART( ,