Esempio n. 1
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $c = new Criteria();
     #$c->add(PoliticoPeer::ID, 18256, Criteria::EQUAL);
     $politicos = PoliticoPeer::doSelect($c);
     #echo SfVoUtil::myUcfirst("Casilda")."\n";die;
     foreach ($politicos as $politico) {
         $vanity = $politico->getVanity();
         $nombre = $politico->getNombre();
         $apellidos = $politico->getApellidos();
         if (strcmp($vanity, $newVanity = SfVoUtil::fixCase($vanity))) {
             echo "politico:{$vanity} -> {$newVanity}\n";
             $politico->setVanity($newVanity);
         }
         if ($nombre != ($newNombre = SfVoUtil::fixCase($nombre))) {
             echo "politico:{$nombre} -> {$newNombre}\n";
             $politico->setNombre($newNombre);
         }
         if ($apellidos != ($newApellidos = SfVoUtil::fixCase($apellidos))) {
             echo "politico:{$apellidos} -> {$newApellidos}\n";
             $politico->setApellidos($newApellidos);
         }
         $politico->save();
     }
     $instituciones = InstitucionI18nPeer::doSelect($c);
     foreach ($instituciones as $institucion) {
         $vanity = $institucion->getVanity();
         $nombreCorto = $institucion->getNombreCorto();
         $nombre = $institucion->getNombre();
         if (strcmp($vanity, $newVanity = SfVoUtil::fixCase($vanity))) {
             echo "institucion:{$vanity} -> {$newVanity}\n";
             $institucion->setVanity($newVanity);
         }
         if (strcmp($nombreCorto, $newNombreCorto = SfVoUtil::fixCase($nombreCorto))) {
             echo "institucion:{$nombreCorto} -> {$newNombreCorto}\n";
             $institucion->setNombreCorto($newNombreCorto);
         }
         if (strcmp($nombre, $newNombre = SfVoUtil::fixCase($nombre))) {
             echo "institucion:{$nombre} -> {$newNombre}\n";
             $institucion->setNombre($newNombre);
         }
         $institucion->save();
     }
     $geos = GeoPeer::doSelect($c);
     foreach ($geos as $geo) {
         $nombre = $geo->getNombre();
         if (strcmp($nombre, $newNombre = SfVoUtil::fixCase($nombre))) {
             echo "geo:{$nombre} -> {$newNombre}\n";
             $geo->setNombre($newNombre);
         }
         $geo->save();
     }
 }
Esempio n. 2
0
 public static function retrieveForAutoSelect($q, $limit)
 {
     $criteria = new Criteria();
     $criteria->add(InstitucionI18nPeer::NOMBRE, '%' . $q . '%', Criteria::LIKE);
     $criteria->addAscendingOrderByColumn(InstitucionI18nPeer::NOMBRE);
     $criteria->setLimit($limit);
     $instituciones = array();
     foreach (InstitucionI18nPeer::doSelect($criteria) as $institucion) {
         $instituciones[$institucion->getId()] = (string) $institucion->getNombre();
     }
     return $instituciones;
 }
Esempio n. 3
0
 public function executeDelete(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     $criteria = new Criteria();
     $criteria->add(InstitucionI18nPeer::ID, $id);
     InstitucionI18nPeer::doDelete($criteria);
     $criteria = new Criteria();
     $criteria->add(PoliticoInstitucionPeer::INSTITUCION_ID, $id);
     PoliticoInstitucionPeer::doDelete($criteria);
     /*
     	    $criteria = new Criteria();
     $criteria->add(EnlacePeer::POLITICO_ID, $id);
     EnlacePeer::doDelete( $criteria );
     */
     parent::executeDelete($request);
 }
Esempio n. 4
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $s3 = new S3Voota();
     $c = new Criteria();
     //$c->add(PoliticoPeer::ID, 1, Criteria::EQUAL);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $vanity = $politico->getVanity();
         if ($vanity != ($new = SfVoUtil::fixVanityChars($vanity))) {
             while (preg_match("/(.*)-\$/is", $new, $m, PREG_OFFSET_CAPTURE)) {
                 $new = $m[1][0];
             }
             $c2 = new Criteria();
             $c2->add(PoliticoPeer::VANITY, "{$new}%", Criteria::LIKE);
             $c2->add(PoliticoPeer::ID, $politico->getId(), Criteria::NOT_EQUAL);
             $politicosLikeMe = PoliticoPeer::doSelect($c2);
             $counter = 0;
             foreach ($politicosLikeMe as $politicoLikeMe) {
                 $aVanity = str_replace("-", "\\-", $new);
                 if (preg_match(SfVoUtil::voDecode("/^{$new}\\-([0-9]*)\$/is"), SfVoUtil::voDecode($politicoLikeMe->getVanity()), $matches)) {
                     if ($counter < 1 + $matches[1]) {
                         $counter = 1 + $matches[1];
                     } else {
                         $counter++;
                     }
                 } else {
                     $counter++;
                 }
             }
             $new = "{$new}" . ($counter == 0 ? '' : "-{$counter}");
             echo "politico:{$vanity} ";
             echo "cambia a:{$new}\n";
             $politico->setVanity($new);
             $politico->save();
         }
     }
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $vanity = $usuario->getProfile()->getVanity();
         if ($vanity != SfVoUtil::fixVanityChars($vanity)) {
             echo "usuario:{$vanity} ({$usuario})\n";
             $usuario->getProfile()->setVanity(SfVoUtil::fixVanityChars($vanity));
             $usuario->getProfile()->save();
         }
     }
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $vanity = $partido->getAbreviatura();
         if ($vanity != SfVoUtil::fixVanityChars($vanity)) {
             echo "partido:{$vanity}\n";
         }
     }
     // Instituciones
     $instituciones = InstitucionI18nPeer::doSelect($c);
     foreach ($instituciones as $institucion) {
         $vanity = $institucion->getVanity();
         if ($vanity != ($new = SfVoUtil::fixVanityChars($vanity))) {
             echo "institucion:{$vanity}\n";
             $institucion->setVanity($new);
             $institucion->save();
             echo "cambia a:{$new}\n";
         }
     }
 }
Esempio n. 5
0
 public function executeAutoComplete($request)
 {
     $this->getResponse()->setContentType('application/json');
     $instituciones = InstitucionI18nPeer::retrieveForAutoSelect($request->getParameter('q'), $request->getParameter('limit'));
     return $this->renderText(json_encode($instituciones));
 }
Esempio n. 6
0
 /**
  * Retrieve object using using composite pkey values.
  * @param      int $id
  * @param      string $culture
  * @param      PropelPDO $con
  * @return     InstitucionI18n
  */
 public static function retrieveByPK($id, $culture, PropelPDO $con = null)
 {
     $key = serialize(array((string) $id, (string) $culture));
     if (null !== ($obj = InstitucionI18nPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(InstitucionI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(InstitucionI18nPeer::DATABASE_NAME);
     $criteria->add(InstitucionI18nPeer::ID, $id);
     $criteria->add(InstitucionI18nPeer::CULTURE, $culture);
     $v = InstitucionI18nPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Esempio n. 7
0
 /**
  * Returns the current translation.
  *
  * @return InstitucionI18n
  */
 public function getCurrentInstitucionI18n($culture = null)
 {
     if (null === $culture) {
         $culture = null === $this->culture ? sfPropel::getDefaultCulture() : $this->culture;
     }
     if (!isset($this->current_i18n[$culture])) {
         $object = $this->isNew() ? null : InstitucionI18nPeer::retrieveByPK($this->getPrimaryKey(), $culture);
         if ($object) {
             $this->setInstitucionI18nForCulture($object, $culture);
         } else {
             $this->setInstitucionI18nForCulture(new InstitucionI18n(), $culture);
             $this->current_i18n[$culture]->setCulture($culture);
         }
     }
     return $this->current_i18n[$culture];
 }
Esempio n. 8
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = InstitucionI18nPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCulture($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setVanity($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setNombreCorto($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setNombre($arr[$keys[4]]);
     }
 }
Esempio n. 9
0
 /**
  * Selects a collection of {@link Institucion} objects with a {@link InstitucionI18n} 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);
     }
     InstitucionPeer::addSelectColumns($criteria);
     $startcol = InstitucionPeer::NUM_COLUMNS - InstitucionPeer::NUM_LAZY_LOAD_COLUMNS;
     InstitucionI18nPeer::addSelectColumns($criteria);
     $criteria->addJoin(InstitucionPeer::ID, InstitucionI18nPeer::ID, $join_behavior);
     $criteria->add(InstitucionI18nPeer::CULTURE, $culture);
     foreach (sfMixer::getCallables('BaseInstitucion:doSelectJoin:doSelectJoin') as $sf_hook) {
         call_user_func($sf_hook, 'Institucion', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = InstitucionPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = InstitucionPeer::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 = InstitucionPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             InstitucionPeer::addInstanceToPool($obj1, $key1);
         }
         // if $obj1 already loaded
         $key2 = InstitucionI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
         if ($key2 !== null) {
             $obj2 = InstitucionI18nPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = InstitucionI18nPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol);
                 InstitucionI18nPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 already loaded
             $obj1->setInstitucionI18nForCulture($obj2, $culture);
         }
         // if joined row was not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }