/**
  * Looks for tables marked as I18N and adds behaviors.
  */
 public function modifyDatabase()
 {
     $translationBehavior = sfPropel::importClass($this->getBuildProperty('propel.behavior.symfony_i18n_translation.class'));
     foreach ($this->getDatabase()->getTables() as $table) {
         $behaviors = $table->getBehaviors();
         if (!isset($behaviors['symfony_i18n']) && 'true' == $table->getAttribute('isI18N')) {
             $i18nTable = $this->getDatabase()->getTable($table->getAttribute('i18nTable'));
             // add the current behavior to the translatable model
             $behavior = clone $this;
             $behavior->setParameters(array('i18n_table' => $i18nTable->getName()));
             $table->addBehavior($behavior);
             // add the translation behavior to the translation model
             $behavior = new $translationBehavior();
             $behavior->setName('symfony_i18n_translation');
             $behavior->setParameters(array('culture_column' => $this->getCultureColumn($i18nTable)->getName()));
             $i18nTable->addBehavior($behavior);
         }
     }
 }
 public function modifyDatabase()
 {
     foreach ($this->getDatabase()->getTables() as $table) {
         $behaviors = $table->getBehaviors();
         if (!isset($behaviors['symfony'])) {
             $behavior = clone $this;
             $table->addBehavior($behavior);
         }
         // symfony behaviors
         if (!isset($behaviors['symfony_behaviors']) && $this->getBuildProperty('propel.builder.addBehaviors')) {
             $class = sfPropel::importClass($this->getBuildProperty('propel.behavior.symfony_behaviors.class'));
             $behavior = new $class();
             $behavior->setName('symfony_behaviors');
             $table->addBehavior($behavior);
         }
         // timestampable
         if (!isset($behaviors['symfony_timestampable'])) {
             $parameters = array();
             foreach ($table->getColumns() as $column) {
                 if (!isset($parameters['create_column']) && in_array($column->getName(), array('created_at', 'created_on'))) {
                     $parameters['create_column'] = $column->getName();
                 }
                 if (!isset($parameters['update_column']) && in_array($column->getName(), array('updated_at', 'updated_on'))) {
                     $parameters['update_column'] = $column->getName();
                 }
             }
             if ($parameters) {
                 $class = sfPropel::importClass($this->getBuildProperty('propel.behavior.symfony_timestampable.class'));
                 $behavior = new $class();
                 $behavior->setName('symfony_timestampable');
                 $behavior->setParameters($parameters);
                 $table->addBehavior($behavior);
             }
         }
     }
 }
 public static function setDefaultCulture($culture)
 {
     self::$defaultCulture = $culture;
 }
 /**
  * Selects a collection of {@link Product} objects with a {@link ProductI18n} translation populated.
  *
  * @param Criteria  $criteria
  * @param string    $culture
  * @param PropelPDO $con
  * @param string    $join_behavior
  *
  * @return array
  */
 public static function doSelectWithI18n(Criteria $criteria, $culture = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     if (null === $culture) {
         $culture = sfPropel::getDefaultCulture();
     }
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     ProductPeer::addSelectColumns($criteria);
     $startcol = ProductPeer::NUM_COLUMNS - ProductPeer::NUM_LAZY_LOAD_COLUMNS;
     ProductI18nPeer::addSelectColumns($criteria);
     $criteria->addJoin(ProductPeer::ID, ProductI18nPeer::ID, $join_behavior);
     $criteria->add(ProductI18nPeer::CULTURE, $culture);
     foreach (sfMixer::getCallables('BaseProduct:doSelectJoin:doSelectJoin') as $sf_hook) {
         call_user_func($sf_hook, 'Product', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = ProductPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ProductPeer::addInstanceToPool($obj1, $key1);
         }
         // if $obj1 already loaded
         $key2 = ProductI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
         if ($key2 !== null) {
             $obj2 = ProductI18nPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = ProductI18nPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol);
                 ProductI18nPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 already loaded
             $obj1->setTranslationForCulture($obj2, $culture);
         }
         // if joined row was not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
 public function getCurrentphysicalObjectI18n(array $options = array())
 {
     if (!empty($options['sourceCulture'])) {
         $options['culture'] = $this->sourceCulture;
     }
     if (!isset($options['culture'])) {
         $options['culture'] = sfPropel::getDefaultCulture();
     }
     $physicalObjectI18ns = $this->physicalObjectI18ns->indexBy('culture');
     if (!isset($physicalObjectI18ns[$options['culture']])) {
         $physicalObjectI18ns[$options['culture']] = new QubitPhysicalObjectI18n();
     }
     return $physicalObjectI18ns[$options['culture']];
 }
 public function getCurrentaccessionI18n(array $options = array())
 {
     if (!empty($options['sourceCulture'])) {
         $options['culture'] = $this->sourceCulture;
     }
     if (!isset($options['culture'])) {
         $options['culture'] = sfPropel::getDefaultCulture();
     }
     $accessionI18ns = $this->accessionI18ns->indexBy('culture');
     if (!isset($accessionI18ns[$options['culture']])) {
         $accessionI18ns[$options['culture']] = new QubitAccessionI18n();
     }
     return $accessionI18ns[$options['culture']];
 }
Exemple #7
0
 public function getCurrentMovieI18n($culture = null)
 {
     if (is_null($culture)) {
         $culture = is_null($this->culture) ? sfPropel::getDefaultCulture() : $this->culture;
     }
     if (!isset($this->current_i18n[$culture])) {
         $obj = MovieI18nPeer::retrieveByPK($this->getId(), $culture);
         if ($obj) {
             $this->setMovieI18nForCulture($obj, $culture);
         } else {
             $this->setMovieI18nForCulture(new MovieI18n(), $culture);
             $this->current_i18n[$culture]->setCulture($culture);
         }
     }
     return $this->current_i18n[$culture];
 }
 public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
 {
     if ($culture === null) {
         $culture = sfPropel::getDefaultCulture();
     }
     foreach (sfMixer::getCallables('BaseFakeForumPeer:doSelectJoin:doSelectJoin') as $callable) {
         call_user_func($callable, 'BaseFakeForumPeer', $c, $con);
     }
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     FakeForumPeer::addSelectColumns($c);
     $startcol = FakeForumPeer::NUM_COLUMNS - FakeForumPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     FakeForumI18nPeer::addSelectColumns($c);
     $c->addJoin(FakeForumPeer::ID, FakeForumI18nPeer::ID);
     $c->add(FakeForumI18nPeer::CULTURE, $culture);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = FakeForumPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $obj1->setCulture($culture);
         $omClass = FakeForumI18nPeer::getOMClass($rs, $startcol);
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol);
         $obj1->setFakeForumI18nForCulture($obj2, $culture);
         $obj2->setFakeForum($obj1);
         $results[] = $obj1;
     }
     return $results;
 }
 public function getCurrentrepositoryI18n(array $options = array())
 {
     if (!empty($options['sourceCulture'])) {
         $options['culture'] = $this->sourceCulture;
     }
     if (!isset($options['culture'])) {
         $options['culture'] = sfPropel::getDefaultCulture();
     }
     $repositoryI18ns = $this->repositoryI18ns->indexBy('culture');
     if (!isset($repositoryI18ns[$options['culture']])) {
         $repositoryI18ns[$options['culture']] = new QubitRepositoryI18n();
     }
     return $repositoryI18ns[$options['culture']];
 }
Exemple #10
0
 public function getContext($forceReload = false)
 {
     parent::getContext($forceReload);
     sfPropel::initialize($this->context->getEventDispatcher());
     return $this->context;
 }
 public function getCurrentstaticPageI18n(array $options = array())
 {
     if (!empty($options['sourceCulture'])) {
         $options['culture'] = $this->sourceCulture;
     }
     if (!isset($options['culture'])) {
         $options['culture'] = sfPropel::getDefaultCulture();
     }
     $staticPageI18ns = $this->staticPageI18ns->indexBy('culture');
     if (!isset($staticPageI18ns[$options['culture']])) {
         $staticPageI18ns[$options['culture']] = new QubitStaticPageI18n();
     }
     return $staticPageI18ns[$options['culture']];
 }
 /**
  * Determine if a property matching passed values already exists.
  *
  * @param integer $objectId foreign key to QubitObject::ID
  * @param string $name  name of property
  * @param string $value value of property
  * @param string $options array of optional parameters
  * @return boolean true if QubitProperty exists
  */
 public static function isExistent($objectId, $name, $value, $options = array())
 {
     $propertyExists = false;
     $criteria = new Criteria();
     $criteria->addJoin(QubitProperty::ID, QubitPropertyI18n::ID);
     $criteria->add(QubitProperty::OBJECT_ID, $objectId);
     $criteria->add(QubitProperty::NAME, $name);
     $criteria->add(QubitPropertyI18n::VALUE, $value);
     if (isset($options['culture'])) {
         $criteria->add(QubitPropertyI18n::CULTURE, $options['culture']);
     } else {
         if (isset($options['sourceCulture'])) {
             $criteria->add(QubitPropertyI18n::CULTURE, QubitProperty::SOURCE_CULTURE . ' = ' . QubitPropertyI18n::CULTURE, Criteria::CUSTOM);
         } else {
             $criteria->add(QubitPropertyI18n::CULTURE, sfPropel::getDefaultCulture());
         }
     }
     if (isset($options['scope'])) {
         $criteria->add(QubitProperty::SCOPE, $options['scope']);
     }
     // See if search returns a hit.
     if (($property = QubitProperty::getOne($criteria)) !== null) {
         $propertyExists = true;
     }
     return $propertyExists;
 }
Exemple #13
0
 public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
 {
     if ($culture === null) {
         $culture = sfPropel::getDefaultCulture();
     }
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     MoviePeer::addSelectColumns($c);
     $startcol = MoviePeer::NUM_COLUMNS - MoviePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     MovieI18nPeer::addSelectColumns($c);
     $c->addJoin(MoviePeer::ID, MovieI18nPeer::ID);
     $c->add(MovieI18nPeer::CULTURE, $culture);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = MoviePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $obj1->setCulture($culture);
         $omClass = MovieI18nPeer::getOMClass($rs, $startcol);
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol);
         $obj1->setMovieI18nForCulture($obj2, $culture);
         $obj2->setMovie($obj1);
         $results[] = $obj1;
     }
     return $results;
 }
 protected function insert($connection = null)
 {
     if (!isset($connection)) {
         $connection = QubitTransactionFilter::getConnection(QubitOaiHarvest::DATABASE_NAME);
     }
     $offset = 0;
     foreach ($this->tables as $table) {
         $criteria = new Criteria();
         foreach ($table->getColumns() as $column) {
             if (!array_key_exists($column->getPhpName(), $this->values)) {
                 if ('createdAt' == $column->getPhpName() || 'updatedAt' == $column->getPhpName()) {
                     $this->values[$column->getPhpName()] = new DateTime();
                 }
                 if ('sourceCulture' == $column->getPhpName()) {
                     $this->values['sourceCulture'] = sfPropel::getDefaultCulture();
                 }
             }
             if (array_key_exists($column->getPhpName(), $this->values)) {
                 if (null !== ($param = $this->param($column))) {
                     $criteria->add($column->getFullyQualifiedName(), $param);
                 }
             }
             $offset++;
         }
         if (null !== ($id = BasePeer::doInsert($criteria, $connection))) {
             // Guess that the first primary key of the first table is auto
             // incremented
             if ($this->tables[0] == $table) {
                 $columns = $table->getPrimaryKeyColumns();
                 $this->values[$columns[0]->getPhpName()] = $this->keys[$columns[0]->getPhpName()] = $id;
             }
         }
     }
     return $this;
 }
Exemple #15
0
 public static function doSelectWithI18n(Criteria $c, $culture = null, PropelPDO $con = null)
 {
     $c = clone $c;
     if ($culture === null) {
         $culture = sfPropel::getDefaultCulture();
     }
     foreach (sfMixer::getCallables('BaseProductPeer:doSelectJoin:doSelectJoin') as $callable) {
         call_user_func($callable, 'BaseProductPeer', $c, $con);
     }
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ProductPeer::addSelectColumns($c);
     $startcol = ProductPeer::NUM_COLUMNS - ProductPeer::NUM_LAZY_LOAD_COLUMNS;
     ProductI18nPeer::addSelectColumns($c);
     $c->addJoin(ProductPeer::ID, ProductI18nPeer::ID);
     $c->add(ProductI18nPeer::CULTURE, $culture);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $omClass = ProductPeer::getOMClass();
         $cls = Propel::importClass($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($row);
         $obj1->setCulture($culture);
         $omClass = ProductI18nPeer::getOMClass();
         $cls = Propel::importClass($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($row, $startcol);
         $obj1->setProductI18nForCulture($obj2, $culture);
         $obj2->setProduct($obj1);
         $results[] = $obj1;
     }
     return $results;
 }
Exemple #16
0
 /**
  * Returns the current translation.
  *
  * @return MovieI18n
  */
 public function getCurrentMovieI18n($culture = null)
 {
     if (null === $culture) {
         $culture = null === $this->culture ? sfPropel::getDefaultCulture() : $this->culture;
     }
     if (!isset($this->current_i18n[$culture])) {
         $object = $this->isNew() ? null : MovieI18nPeer::retrieveByPK($this->getPrimaryKey(), $culture);
         if ($object) {
             $this->setMovieI18nForCulture($object, $culture);
         } else {
             $this->setMovieI18nForCulture(new MovieI18n(), $culture);
             $this->current_i18n[$culture]->setCulture($culture);
         }
     }
     return $this->current_i18n[$culture];
 }
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * Autoloading and initialization for propel.
 *
 * @package    symfony
 * @subpackage propel
 * @author     Fabien Potencier <*****@*****.**>
 * @version    SVN: $Id: sfPropelAutoload.php 12170 2008-10-13 16:35:40Z Kris.Wallsmith $
 */
sfToolkit::addIncludePath(realpath(dirname(__FILE__) . '/../vendor'));
require_once 'propel/Propel.php';
sfPropel::initialize(sfProjectConfiguration::getActive()->getEventDispatcher());