Exemplo n.º 1
0
 public function executeSendStmt()
 {
     if ($this->reviewType == Politico::NUM_ENTITY) {
         $this->politico = PoliticoPeer::retrieveByPK($this->reviewEntityId);
     } else {
         if ($this->reviewType == Partido::NUM_ENTITY) {
             $this->partido = PartidoPeer::retrieveByPK($this->reviewEntityId);
         } else {
             if ($this->reviewType != null) {
                 $type = SfReviewTypePeer::retrieveByPk($this->reviewType);
                 $peer = $type->getModel() . 'Peer';
                 $this->entity = $peer::retrieveByPK($this->reviewEntityId);
             } else {
                 if ($this->reviewType == null) {
                     $review_ = SfReviewPeer::retrieveByPK($this->reviewEntityId);
                     if ($review_) {
                         $this->review = $review_;
                         if ($this->review->getSfReviewTypeId() == Politico::NUM_ENTITY) {
                             $this->politico = PoliticoPeer::retrieveByPK($this->review->getEntityId());
                         } else {
                             if ($this->review->getSfReviewTypeId() == Partido::NUM_ENTITY) {
                                 $this->partido = PartidoPeer::retrieveByPK($this->review->getEntityId());
                             } else {
                                 $type = SfReviewTypePeer::retrieveByPk($this->review->getSfReviewTypeId());
                                 $peer = $type->getModel() . 'Peer';
                                 $this->entity = $peer::retrieveByPK($this->review->getEntityId());
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
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) {
         if ($politico->getImagen() != '') {
             echo "Fixing  " . $politico->getId() . " ...\n";
             $bio = $politico->getBio();
             if (preg_match("/<li class=\"correo_dip\">(.*)>(.*)<(.*)<\\/li>/", $bio)) {
                 $bio = preg_replace("/&lt;/", '<', $bio);
                 $bio = preg_replace("/&gt;/", '>', $bio);
             }
             if (preg_match("/<li class=\"correo_dip\">(.*)>(.*)<(.*)<\\/li>/", $bio, $regs)) {
                 $bio = preg_replace("/<li class=\"correo_dip\">(.*)>(.*)<(.*)<\\/li>/", '', $bio);
                 $email = $regs[2];
             }
             $bio = strip_tags($bio);
             $bio = preg_replace("/[  ]+/", ' ', $bio);
             $bio = preg_replace("/[  ]+/", ' ', $bio);
             if ($politico->getEmail() == '' && $email != '') {
                 //echo "Cambiando email\n";
                 $politico->setEmail($email);
             }
             $politico->setBio($bio);
             if ($politico->isModified()) {
                 PoliticoPeer::doUpdate($politico);
             }
         }
     }
 }
Exemplo n.º 3
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();
     }
 }
Exemplo n.º 4
0
 public function executeIndex(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $cpos = new Criteria();
     $cpos->add(SfReviewPeer::VALUE, 1);
     $cpos->add(SfReviewPeer::IS_ACTIVE, 1);
     //$cpos->add(SfReviewPeer::CULTURE, $culture);
     $this->totalUpReviews = SfReviewPeer::doCount($cpos);
     $cneg = new Criteria();
     $cneg->add(SfReviewPeer::VALUE, -1);
     $cneg->add(SfReviewPeer::IS_ACTIVE, 1);
     //$cneg->add(SfReviewPeer::CULTURE, $culture);
     $this->totalDownReviews = SfReviewPeer::doCount($cneg);
     $exclude = "";
     $this->reviewables = EntityManager::getTopEntities(6, $exclude, "WebEntity", true);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
     $c->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     $c->setLimit(5);
     $this->topPoliticos = PoliticoPeer::doSelect($c);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PartidoPeer::SUMU);
     $c->addAscendingOrderByColumn(PartidoPeer::SUMD);
     $c->setLimit(5);
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $this->partidosMasVotados = PartidoPeer::doSelect($c);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PropuestaPeer::SUMU);
     $c->addAscendingOrderByColumn(PropuestaPeer::SUMD);
     $c->setLimit(5);
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $this->propuestasMasVotadas = PropuestaPeer::doSelect($c);
     //Totales
     /*
     $c = new Criteria();
     $this->totalPoliticos = PoliticoPeer::doCount($c);
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $this->totalPartidos = PartidoPeer::doCount($c);
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $this->totalPropuestas = PropuestaPeer::doCount($c);
     */
     $this->response->addMeta('Description', sfContext::getInstance()->getI18N()->__('Comparte opiniones sobre políticos y partidos de España. Ranking de los políticos y partidos más votados.'));
     // Ultimos comentarios
     $filter = array();
     $filter['culture'] = $culture;
     //$this->topReviews = SfReviewManager::getReviews($filter, 1, 5);
     $this->activities = SfReviewManager::getActivities($filter, 1, 5);
     // elecciones destacadas
     $convocatoriaActiva = sfConfig::get('sf_convocatoria_activa');
     $this->convocatoria = ConvocatoriaPeer::retrieveByPk($convocatoriaActiva);
 }
Exemplo n.º 5
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeShow(sfWebRequest $request)
 {
     $vanity = $request->getParameter('vanity');
     $convocatoria = $request->getParameter('convocatoria');
     $this->geoName = $request->getParameter('geo', false);
     $c = new Criteria();
     $c->addJoin(ConvocatoriaPeer::ELECCION_ID, EleccionPeer::ID);
     $c->add(ConvocatoriaPeer::NOMBRE, $convocatoria);
     $c->add(EleccionPeer::VANITY, $vanity);
     $this->convocatoria = ConvocatoriaPeer::doSelectOne($c);
     $this->forward404Unless($this->convocatoria);
     // Enlaces
     $c = new Criteria();
     $rCriterion = $c->getNewCriterion(EnlacePeer::CULTURE, null, Criteria::ISNULL);
     $rCriterion->addOr($c->getNewCriterion(EnlacePeer::CULTURE, $this->getUser()->getCulture()));
     $rCriterion->addOr($c->getNewCriterion(EnlacePeer::CULTURE, ''));
     $c->add($rCriterion);
     $c->add(EnlacePeer::CONVOCATORIA_ID, $this->convocatoria->getId());
     $c->addAscendingOrderByColumn(EnlacePeer::ORDEN);
     $this->activeEnlaces = EnlacePeer::doSelect($c);
     $ret = $this->convocatoria->getResults($this->geoName);
     $this->partidos = $ret['partidos'];
     $this->totalEscanyos = $ret['totalEscanyos'];
     $this->minSumu = $ret['minSumu'];
     $this->minSumd = $ret['minSumd'];
     $this->lastDate = $ret['lastDate'];
     $this->apellidos = $ret['apellidos'];
     $this->institucionName = $ret['institucionName'];
     $this->circus = $ret['circus'];
     // Politicos
     $criteria = new Criteria();
     $criteria->addJoin(PoliticoListaPeer::POLITICO_ID, PoliticoPeer::ID);
     $criteria->addJoin(PoliticoListaPeer::LISTA_ID, ListaPeer::ID);
     $criteria->add(ListaPeer::CONVOCATORIA_ID, $this->convocatoria->getId());
     if ($this->geoName) {
         $criteria->addJoin(ListaPeer::CIRCUNSCRIPCION_ID, CircunscripcionPeer::ID);
         $criteria->addJoin(CircunscripcionPeer::GEO_ID, GeoPeer::ID);
         $criteria->add(GeoPeer::NOMBRE, $this->geoName);
     }
     $criteria->addDescendingOrderByColumn(PoliticoPeer::SUMU);
     $criteria->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     $criteria->setLimit(5);
     $this->topPoliticos = PoliticoPeer::doSelect($criteria);
     // Metas
     $this->title = ($this->geoName ? $this->geoName . ': ' : '') . $this->convocatoria->getEleccion()->getNombre() . " " . $this->convocatoria->getNombre();
     $this->response->setTitle($this->title);
     $description = sfContext::getInstance()->getI18N()->__("%1%.%2%: listas%3%, partidos, candidatos, previsión de escaños, votos de los usuarios, ...", array('%1%' => $this->convocatoria->getEleccion()->getNombre(), '%2%' => sfContext::getInstance()->getI18N()->__("%dia% de %mes%", array('%dia%' => format_date($this->convocatoria->getFecha(), ' d'), '%mes%' => format_date($this->convocatoria->getFecha(), 'MMMM'))), '%3%' => $this->geoName ? ' ' . $this->geoName : ''));
     $this->response->addMeta('Description', $description);
 }
Exemplo n.º 6
0
 public function executeUpdate(sfWebRequest $request)
 {
     $cacheManager = $this->getContext()->getViewCacheManager();
     if ($cacheManager != null) {
         $reviewOri = $this->getRoute()->getObject();
         if ($reviewOri->getSfReviewType() == null) {
             $review = $reviewOri->getSfReviewRelatedBySfReviewId();
         } else {
             $review = $reviewOri;
         }
         if ($review->getSfReviewTypeId() == 1) {
             $politico = PoliticoPeer::retrieveByPK($review->getEntityId());
             $cacheManager->remove("politico/show?id=" . $politico->getVanity() . "");
         }
     }
     parent::executeUpdate($request);
 }
Exemplo n.º 7
0
 protected function politico($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, 1, Criteria::EQUAL);
     if ($options['min-id'] != "0") {
         $c->add(PoliticoPeer::ID, $options['min-id'], Criteria::GREATER_EQUAL);
     }
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         if ($politico->getVanity() == '' || $options['force'] == '1') {
             if ($options['with-name'] == "1") {
                 $newVanityString = $politico->getNombre() . '-' . $politico->getApellidos();
             } else {
                 $newVanityString = $politico->getApellidos();
             }
             $vanityUrl = SfVoUtil::encodeVanity($newVanityString);
             $c2 = new Criteria();
             $c2->add(PoliticoPeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
             $c2->add(PoliticoPeer::ID, $politico->getId(), Criteria::NOT_EQUAL);
             $politicosLikeMe = PoliticoPeer::doSelect($c2);
             $counter = 0;
             foreach ($politicosLikeMe as $politicoLikeMe) {
                 $aVanity = str_replace("-", "\\-", $vanityUrl);
                 if (preg_match(SfVoUtil::voDecode("/^{$vanityUrl}\\-([0-9]*)\$/is"), SfVoUtil::voDecode($politicoLikeMe->getVanity()), $matches)) {
                     if ($counter < 1 + $matches[1]) {
                         $counter = 1 + $matches[1];
                     } else {
                         $counter++;
                     }
                 } else {
                     $counter++;
                 }
             }
             $newVanity = "{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}");
             echo "Setting vanity from " . $politico->getVanity() . " to  " . $newVanity . " ...\n";
             $politico->setVanity($newVanity);
             $politico->save();
         }
     }
 }
Exemplo n.º 8
0
 public static function retrieveForAutoSelect($q, $limit)
 {
     $criteria = new Criteria();
     $pieces = explode(" ", $q);
     $criterions = array();
     $idx = 0;
     foreach ($pieces as $piece) {
         sfContext::getInstance()->getLogger()->debug("A SEARCH PIECE {$piece}");
         $criterions[$idx] = $criteria->getNewCriterion(PoliticoPeer::APELLIDOS, '%' . $piece . '%', Criteria::LIKE);
         $criterions[$idx]->addOr($criteria->getNewCriterion(PoliticoPeer::NOMBRE, '%' . $piece . '%', Criteria::LIKE));
         $criteria->addAnd($criterions[$idx]);
         $idx++;
     }
     $criteria->addAscendingOrderByColumn(PoliticoPeer::APELLIDOS);
     $criteria->setLimit($limit);
     $instituciones = array();
     foreach (PoliticoPeer::doSelect($criteria) as $politico) {
         $politicos[$politico->getId()] = (string) $politico;
     }
     return $politicos;
 }
Exemplo n.º 9
0
 public static function countPoliticosReviewed()
 {
     $cache = sfcontext::getInstance()->getViewCacheManager() ? sfcontext::getInstance()->getViewCacheManager()->getCache() : false;
     if ($cache) {
         $key = md5("politicos_reviewed_counter");
         $data = unserialize($cache->get($key));
     } else {
         $data = false;
     }
     if (!$data) {
         $cpol = new Criteria();
         $cpol->addJoin(PoliticoPeer::ID, SfReviewPeer::ENTITY_ID, Criteria::INNER_JOIN);
         $cpol->add(SfReviewPeer::SF_REVIEW_TYPE_ID, Politico::NUM_ENTITY);
         $cpol->add(SfReviewPeer::IS_ACTIVE, TRUE);
         //$cpol->add(SfReviewPeer::CULTURE, $culture);
         $cpol->setDistinct();
         $data = PoliticoPeer::doCount($cpol);
         if ($cache) {
             $cache->set($key, serialize($data), 360);
         }
     }
     return $data;
 }
Exemplo n.º 10
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();
     $handle = fopen("php://stdin", "r");
     $line = fgets($handle);
     while ($line = fgets($handle)) {
         $data = explode(";", "{$line}");
         $c = new Criteria();
         $c->add(PartidoPeer::ABREVIATURA, $data[5]);
         $partido = PartidoPeer::doSelectOne($c);
         if (!$partido) {
             echo "Not found: (" . $data[5] . ")\n";
             continue;
         }
         $circu = CircunscripcionPeer::retrieveByPK($data[4]);
         $convocatoria = ConvocatoriaPeer::retrieveByPK($data[3]);
         $c = new Criteria();
         $c->add(ListaPeer::CONVOCATORIA_ID, $data[3]);
         $c->add(ListaPeer::CIRCUNSCRIPCION_ID, $data[4]);
         $c->add(ListaPeer::PARTIDO_ID, $partido->getId());
         $lista = ListaPeer::doSelectOne($c);
         if (!$lista) {
             $lista = new Lista();
             $lista->setPartido($partido);
             $lista->setCircunscripcion($circu);
             $lista->setConvocatoria($convocatoria);
             $lista->save();
             echo "Created lista ({$partido}, {$circu})\n";
         }
         $politicos = false;
         $c = new Criteria();
         $c->add("concat(nombre, ' ', apellidos)", trim($data[2]));
         //$c->add('fullname', utf8_encode( trim($data[2]) ), Criteria::EQUAL);
         $politicos = PoliticoPeer::doSelect($c);
         if (count($politicos) != 0) {
             echo "(ASIGNADO) " . $data[2] . "\n";
             $politico = $politicos[0];
         } else {
             echo "(NUEVO) " . $data[2] . "\n";
             $politico = new Politico();
             $nombreApellidos = explode(" ", $data[2]);
             $nombre = array_shift($nombreApellidos);
             $apellidos = implode(" ", $nombreApellidos);
             $politico->setNombre($nombre);
             $politico->setApellidos($apellidos);
             if ($data[7] != '1') {
                 if (count($data) > 10 && trim($data[10]) != '') {
                     $c = new Criteria();
                     $c->add(PartidoPeer::ABREVIATURA, $data[5]);
                     $partido = PartidoPeer::doSelectOne($c);
                     if ($partido) {
                         $politico->setPartido($partido);
                     }
                 } else {
                     $politico->setPartido($lista->getPartido());
                 }
             }
             if ($data[1] && trim($data[1]) != '') {
                 $politico->setSexo($data[1] == "hombre" ? 'H' : 'M');
             }
             $politico->save();
             $politicoI18n = new PoliticoI18n();
             $politicoI18n->setPolitico($politico);
             $politicoI18n->setCulture('es');
             $politicoI18n->save();
             $politicoI18n = new PoliticoI18n();
             $politicoI18n->setPolitico($politico);
             $politicoI18n->setCulture('ca');
             $politicoI18n->save();
         }
         $c = new Criteria();
         $c->add(PoliticoListaPeer::LISTA_ID, $lista->getId());
         $c->add(PoliticoListaPeer::POLITICO_ID, $politico->getId());
         $pl = PoliticoListaPeer::doSelectOne($c);
         if (!$pl) {
             $pl = new PoliticoLista();
             $pl->setLista($lista);
             $pl->setPolitico($politico);
         } else {
             echo "Ya estaba.\n";
         }
         if ($data[6] != '1') {
             $pl->setOrden($data[0]);
         }
         $pl->save();
         //echo $data[2];
     }
     fclose($handle);
 }
Exemplo n.º 11
0
 protected function execute($arguments = array(), $options = array())
 {
     $sfContext = sfContext::createInstance($this->configuration);
     $controller = $sfContext->getController();
     $this->cultures = array('ca' => 'cat', 'es' => 'es');
     $culture = $options['culture'];
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     //foreach($this->cultures as $culture => $ext){
     $sfContext->getUser()->setCulture($culture);
     // **************** HOME **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@homepage", true), $culture);
     // **************** Ultimas opiniones **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_feed_{$culture}", true), $culture);
     // **************** varias **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@about", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@rules", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@search", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@contact", true), $culture);
     // **************** Fichas POLITICOS **********************
     $c = new Criteria();
     //$c->setLimit(5);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $this->writeToSitemap("politico-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** Fichas PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-{$culture}", $controller->genUrl("partido/show?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** Fichas PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-{$culture}", $controller->genUrl("propuesta/show?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** Fichas USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-{$culture}", $controller->genUrl("perfil/show?username="******"politico-feed-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** feeds PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-feed-{$culture}", $controller->genUrl("partido/feed?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** feeds PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-feed-{$culture}", $controller->genUrl("propuesta/feed?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** feeds USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-feed-{$culture}", $controller->genUrl("perfil/feed?username="******"propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking", true), $culture);
     $pager = EntityManager::getPropuestas($culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking?page={$idx}", true), $culture);
     }
     // **************** ranking POLITICOS **********************
     $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking", true), $culture);
     $pager = EntityManager::getPoliticos(false, false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?page={$idx}", true), $culture);
     }
     # ranking de polis filtrados por partido
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura(), true), $culture);
         $pager = EntityManager::getPoliticos($partido->getAbreviatura(), false, $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&page={$idx}", true), $culture);
         }
         # ranking de polis filtrados por partido e insti
         $c = new Criteria();
         $c->add(InstitucionPeer::IS_ACTIVE, true);
         $c->addJoin(PoliticoInstitucionPeer::INSTITUCION_ID, InstitucionPeer::ID);
         $c->addJoin(PoliticoPeer::ID, PoliticoInstitucionPeer::POLITICO_ID);
         $c->add(PoliticoPeer::PARTIDO_ID, $partido->getId());
         $instis = InstitucionPeer::doSelect($c);
         foreach ($instis as $insti) {
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity(), true), $culture);
             $pager = EntityManager::getPoliticos($partido->getAbreviatura(), $insti->getVanity(), $culture);
             $idx = 1;
             while ($idx < $pager->getLastPage()) {
                 $idx++;
                 $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
             }
         }
     }
     # ranking de polis filtrados por insti
     $c = new Criteria();
     $c->add(InstitucionPeer::IS_ACTIVE, true);
     $instis = InstitucionPeer::doSelect($c);
     foreach ($instis as $insti) {
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity(), true), $culture);
         $pager = EntityManager::getPoliticos(false, $insti->getVanity(), $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
         }
     }
     // **************** ranking PARTIDOS **********************
     $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking", true), $culture);
     $pager = EntityManager::getPartidos(false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?page={$idx}", true), $culture);
     }
     $c = new Criteria();
     $c->add(InstitucionPeer::IS_ACTIVE, true);
     $instis = InstitucionPeer::doSelect($c);
     foreach ($instis as $insti) {
         $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity(), true), $culture);
         $pager = EntityManager::getPartidos($insti->getVanity(), $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
         }
     }
     // **************** elecciones **********************
     $c = new Criteria();
     $convocatorias = ConvocatoriaPeer::doSelect($c);
     foreach ($convocatorias as $convocatoria) {
         $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
         $used = array();
         foreach ($convocatoria->getListasJoinCircunscripcion() as $geoLista) {
             if (!in_array($geoLista->getCircunscripcion()->getGeo(), $used)) {
                 $used[] = $geoLista->getCircunscripcion()->getGeo();
                 $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
             }
             $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('lista/show?partido=' . $geoLista->getPartido()->getAbreviatura() . '&geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
         }
     }
     //}
     $this->closeAll($culture);
 }
Exemplo n.º 12
0
 /**
  * Selects a collection of Imagen objects pre-filled with all related objects except Partido.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Imagen objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptPartido(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     ImagenPeer::addSelectColumns($criteria);
     $startcol2 = ImagenPeer::NUM_COLUMNS - ImagenPeer::NUM_LAZY_LOAD_COLUMNS;
     PoliticoPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (PoliticoPeer::NUM_COLUMNS - PoliticoPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(ImagenPeer::POLITICO_ID, PoliticoPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseImagenPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ImagenPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ImagenPeer::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 = ImagenPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ImagenPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Politico rows
         $key2 = PoliticoPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = PoliticoPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = PoliticoPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 PoliticoPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Imagen) to the collection in $obj2 (Politico)
             $obj2->addImagen($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemplo n.º 13
0
 /**
  * Get the associated Politico object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Politico The associated Politico object.
  * @throws     PropelException
  */
 public function getPolitico(PropelPDO $con = null)
 {
     if ($this->aPolitico === null && $this->politico_id !== null) {
         $this->aPolitico = PoliticoPeer::retrieveByPk($this->politico_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aPolitico->addPoliticoInstitucions($this);
         		 */
     }
     return $this->aPolitico;
 }
Exemplo n.º 14
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";
         }
     }
 }
Exemplo n.º 15
0
 public function executeFeed(sfWebRequest $request)
 {
     $vanity = $request->getParameter('id');
     $culture = $this->getUser()->getCulture();
     $c = new Criteria();
     $c->add(PoliticoPeer::VANITY, $vanity, Criteria::EQUAL);
     $entity = PoliticoPeer::doSelectOne($c);
     $this->forward404Unless($entity);
     $filter = array();
     $filter['type_id'] = Politico::NUM_ENTITY;
     $filter['entity_id'] = $entity->getId();
     $reviews = SfReviewManager::getReviews($filter);
     $title = sfContext::getInstance()->getI18N()->__('%1% en Voota.es', array('%1%' => $entity->getNombre() . ' ' . $entity->getApellidos()));
     $instis = "";
     foreach ($entity->getPoliticoInstitucions() as $idx => $politicoInstitucion) {
         $instis .= ($instis ? ", " : "") . $politicoInstitucion->getInstitucion();
     }
     $description = sfContext::getInstance()->getI18N()->__('Opiniones sobre %1%, %2% votos a favor y %3% votos en contra', array('%1%' => $entity->getNombre() . ' ' . $entity->getApellidos() . ($instis ? " ({$instis})" : "") . ($entity->getPartido() ? ", " . $entity->getPartido() . "" : ""), '%2%' => $entity->getSumu(), '%3%' => $entity->getSumd()));
     $feed = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $feed->setLink('politico/show?id=' . $entity->getVanity());
     $domainExt = $culture == 'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     $feedImage = new sfFeedImage();
     $feedImage->setLink('politico/show?id=' . $entity->getVanity());
     $feedImage->setImage(S3Voota::getImagesUrl() . '/' . $entity->getImagePath() . '/cc_' . $entity->getImagen());
     $feedImage->setTitle($entity);
     $feed->setImage($feedImage);
     foreach ($reviews as $review) {
         $item = new sfFeedItem();
         $item->setTitle(sfContext::getInstance()->getI18N()->__('%1%, voota %2%.', array('%1%' => $review->getSfGuardUser(), '%2%' => $review->getValue() == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'))));
         $item->setLink('sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
         $item->setAuthorName($review->getSfGuardUser());
         $item->setPubdate($review->getCreatedAt('U'));
         $item->setUniqueId($review->getId());
         $avatar = S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $review->getSfGuardUser()->getProfile()->getImagen();
         $text = $culture == $review->getCulture() || !$review->getCulture() ? $review->getText() : '';
         $img = $review->getSfGuardUser()->getProfile()->getImagen() ? "<img src=\"{$avatar}\" alt =\"" . $review->getSfGuardUser() . "\" /> " : "";
         $content = "{$text}";
         $item->setDescription($content);
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Exemplo n.º 16
0
 /**
  * Selects a collection of Enlace objects pre-filled with all related objects except sfGuardUser.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Enlace objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptsfGuardUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     EnlacePeer::addSelectColumns($criteria);
     $startcol2 = EnlacePeer::NUM_COLUMNS - EnlacePeer::NUM_LAZY_LOAD_COLUMNS;
     PartidoPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (PartidoPeer::NUM_COLUMNS - PartidoPeer::NUM_LAZY_LOAD_COLUMNS);
     PoliticoPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + (PoliticoPeer::NUM_COLUMNS - PoliticoPeer::NUM_LAZY_LOAD_COLUMNS);
     PropuestaPeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + (PropuestaPeer::NUM_COLUMNS - PropuestaPeer::NUM_LAZY_LOAD_COLUMNS);
     ConvocatoriaPeer::addSelectColumns($criteria);
     $startcol6 = $startcol5 + (ConvocatoriaPeer::NUM_COLUMNS - ConvocatoriaPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(EnlacePeer::PARTIDO_ID, PartidoPeer::ID, $join_behavior);
     $criteria->addJoin(EnlacePeer::POLITICO_ID, PoliticoPeer::ID, $join_behavior);
     $criteria->addJoin(EnlacePeer::PROPUESTA_ID, PropuestaPeer::ID, $join_behavior);
     $criteria->addJoin(EnlacePeer::CONVOCATORIA_ID, ConvocatoriaPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseEnlacePeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = EnlacePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = EnlacePeer::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 = EnlacePeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             EnlacePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Partido rows
         $key2 = PartidoPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = PartidoPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = PartidoPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 PartidoPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Enlace) to the collection in $obj2 (Partido)
             $obj2->addEnlace($obj1);
         }
         // if joined row is not null
         // Add objects for joined Politico rows
         $key3 = PoliticoPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = PoliticoPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = PoliticoPeer::getOMClass(false);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 PoliticoPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Enlace) to the collection in $obj3 (Politico)
             $obj3->addEnlace($obj1);
         }
         // if joined row is not null
         // Add objects for joined Propuesta rows
         $key4 = PropuestaPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = PropuestaPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = PropuestaPeer::getOMClass(false);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 PropuestaPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (Enlace) to the collection in $obj4 (Propuesta)
             $obj4->addEnlace($obj1);
         }
         // if joined row is not null
         // Add objects for joined Convocatoria rows
         $key5 = ConvocatoriaPeer::getPrimaryKeyHashFromRow($row, $startcol5);
         if ($key5 !== null) {
             $obj5 = ConvocatoriaPeer::getInstanceFromPool($key5);
             if (!$obj5) {
                 $cls = ConvocatoriaPeer::getOMClass(false);
                 $obj5 = new $cls();
                 $obj5->hydrate($row, $startcol5);
                 ConvocatoriaPeer::addInstanceToPool($obj5, $key5);
             }
             // if $obj5 already loaded
             // Add the $obj1 (Enlace) to the collection in $obj5 (Convocatoria)
             $obj5->addEnlace($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemplo n.º 17
0
 /**
  * Selects a collection of {@link Politico} objects with a {@link PoliticoI18n} 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);
     }
     PoliticoPeer::addSelectColumns($criteria);
     $startcol = PoliticoPeer::NUM_COLUMNS - PoliticoPeer::NUM_LAZY_LOAD_COLUMNS;
     PoliticoI18nPeer::addSelectColumns($criteria);
     $criteria->addJoin(PoliticoPeer::ID, PoliticoI18nPeer::ID, $join_behavior);
     $criteria->add(PoliticoI18nPeer::CULTURE, $culture);
     foreach (sfMixer::getCallables('BasePolitico:doSelectJoin:doSelectJoin') as $sf_hook) {
         call_user_func($sf_hook, 'Politico', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = PoliticoPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = PoliticoPeer::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 = PoliticoPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             PoliticoPeer::addInstanceToPool($obj1, $key1);
         }
         // if $obj1 already loaded
         $key2 = PoliticoI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
         if ($key2 !== null) {
             $obj2 = PoliticoI18nPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = PoliticoI18nPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol);
                 PoliticoI18nPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 already loaded
             $obj1->setPoliticoI18nForCulture($obj2, $culture);
         }
         // if joined row was not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemplo n.º 18
0
 private function post_review($data)
 {
     try {
         $userId = oauthSecurityManager::checkAuthorized();
     } catch (Exception $e) {
         throw new NotAuthorizedException($e->getMessage());
     }
     $entityId = $this->getRequestParameter("entity");
     $value = $this->getRequestParameter("value");
     $text = $this->getRequestParameter("text", false);
     $type = $this->getRequestParameter("type");
     $key = oauthSecurityManager::getConsummerKey();
     if (!$entityId || !$value || !$type) {
         throw new BadRequestException("Not enough parameters.");
     }
     if ($value != -1 && $value != 1) {
         throw new BadRequestException("Invalid data for 'value'.");
     }
     $typeId = -1;
     switch ($type) {
         case 'politician':
             $typeId = Politico::NUM_ENTITY;
             $entity = PoliticoPeer::retrieveByPK($entityId);
             break;
         case 'party':
             $typeId = Partido::NUM_ENTITY;
             $entity = PartidoPeer::retrieveByPK($entityId);
             break;
         case 'proposal':
             $typeId = Propuesta::NUM_ENTITY;
             $entity = PropuestaPeer::retrieveByPK($entityId);
             break;
         default:
             throw new BadRequestException('Invalid type.');
     }
     try {
         $this->review = SfReviewManager::postReview($userId, $typeId, $entityId, $value, $text, $entity, false, 0, $key);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return "saved.";
 }
Exemplo n.º 19
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 = PoliticoPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setAlias($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setNombre($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setApellidos($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEmail($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setSexo($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setFechaNacimiento($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setPais($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setResidencia($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setSfGuardUserId($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setCreatedAt($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setModifiedAt($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setPartidoId($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setPartidoTxt($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setImagen($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setVanity($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setLugarNacimiento($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setSumu($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setSumd($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setRelacion($arr[$keys[19]]);
     }
     if (array_key_exists($keys[20], $arr)) {
         $this->setHijos($arr[$keys[20]]);
     }
     if (array_key_exists($keys[21], $arr)) {
         $this->setHijas($arr[$keys[21]]);
     }
 }
Exemplo n.º 20
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();
         # Los que acaban en -
         if (preg_match("/(.*)([\\-]+)\$/is", $vanity, $matches, PREG_OFFSET_CAPTURE)) {
             if ($matches[2][0] != '') {
                 #echo "politico:$vanity (".$matches[0][0].", ".$matches[1][0].", ".$matches[2][0].", ".$matches[3][0].")";
                 $vanityUrl = SfVoUtil::encodeVanity($matches[1][0]);
                 #echo "($vanityUrl)";
                 $c2 = new Criteria();
                 $c2->add(PoliticoPeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
                 $c2->add(PoliticoPeer::ID, $politico->getId(), Criteria::NOT_EQUAL);
                 $politicosLikeMe = PoliticoPeer::doSelect($c2);
                 $counter = 0;
                 foreach ($politicosLikeMe as $politicoLikeMe) {
                     $counter++;
                 }
                 //$profile->setVanity( "$vanityUrl". ($counter==0?'':"-$counter") );
                 #echo "->". "$vanityUrl". ($counter==0?'':"-$counter") ."\n";
                 //if ($counter != 0){
                 echo "politico:{$vanity} (" . $matches[0][0] . ", " . $matches[1][0] . ", " . $matches[2][0] . ")";
                 #echo "politico:$vanity (".$matches[0][0].", ".$matches[1][0].", ".$matches[2][0].", ".$matches[3][0].")";
                 echo "->" . "{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}") . "\n";
                 $politico->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}"));
                 $politico->save();
                 //}
             }
         }
         # Los que acaban en --n
         if (preg_match("/(.*)--([0-9]*)\$/is", $vanity, $matches, PREG_OFFSET_CAPTURE)) {
             if ($matches[2][0] != '') {
                 #echo "politico:$vanity (".$matches[0][0].", ".$matches[1][0].", ".$matches[2][0].", ".$matches[3][0].")";
                 $vanityUrl = SfVoUtil::encodeVanity($matches[1][0]);
                 #echo "($vanityUrl)";
                 $c2 = new Criteria();
                 $c2->add(PoliticoPeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
                 $c2->add(PoliticoPeer::ID, $politico->getId(), Criteria::NOT_EQUAL);
                 $politicosLikeMe = PoliticoPeer::doSelect($c2);
                 $counter = 0;
                 foreach ($politicosLikeMe as $politicoLikeMe) {
                     if (preg_match("/(.*)-([0-9]*)\$/is", $politicoLikeMe->getVanity(), $m, PREG_OFFSET_CAPTURE)) {
                         if ($m[2][0] >= $counter) {
                             $counter = intval($m[2][0]) + 1;
                         }
                     } elseif ($counter == 0) {
                         $counter = 1;
                     }
                 }
                 //$profile->setVanity( "$vanityUrl". ($counter==0?'':"-$counter") );
                 #echo "->". "$vanityUrl". ($counter==0?'':"-$counter") ."\n";
                 echo "politico:{$vanity} (" . $matches[0][0] . ", " . $matches[1][0] . ", " . $matches[2][0] . ")";
                 #echo "politico:$vanity (".$matches[0][0].", ".$matches[1][0].", ".$matches[2][0].", ".$matches[3][0].")";
                 echo "->" . "{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}") . "\n";
                 $idx = 0;
                 $done = false;
                 while (!$done && $idx < 15) {
                     try {
                         $politico->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}"));
                         $politico->save();
                         $done = true;
                     } catch (Exception $e) {
                         echo ".";
                         $done = false;
                         $counter++;
                         $idx++;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 21
0
 public function executeRmtag(sfWebRequest $request)
 {
     $e = $request->getParameter('e', false);
     $id = $request->getParameter('id', false);
     $type = $request->getParameter('type', false);
     TagManager::removeTag($id, $e, $type);
     switch ($type) {
         case Politico::NUM_ENTITY:
             $this->entity = PoliticoPeer::retrieveByPK($e);
             break;
         case Partido::NUM_ENTITY:
             $this->entity = PartidoPeer::retrieveByPK($e);
             break;
         case Propuesta::NUM_ENTITY:
             $this->entity = PropuestaPeer::retrieveByPK($e);
             break;
     }
 }
Exemplo n.º 22
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();
     $handle = fopen("php://stdin", "r");
     $line = fgets($handle);
     while ($line = fgets($handle)) {
         $data = explode(";", "{$line}");
         $c = new Criteria();
         $c->add(GeoPeer::NOMBRE, $data[3]);
         $geos = GeoPeer::doSelect($c);
         $aGeo = false;
         foreach ($geos as $geo) {
             if ($geo->getGeoRelatedByGeoId() != null && $geo->getGeoRelatedByGeoId()->getCodigo() && $geo->getGeoRelatedByGeoId()->getCodigo() != '') {
                 //echo 'geo: ' . $geo->getNombre() . "\n";
                 $aGeo = $geo;
             }
         }
         if (!$aGeo) {
             echo 'Geo not found: (' . $data[3] . ")\n";
             continue;
         }
         $c = new Criteria();
         $c->add(PartidoPeer::ABREVIATURA, $data[5]);
         $partido = PartidoPeer::doSelectOne($c);
         if (!$partido) {
             $partido = new Partido();
             $partido->setAbreviatura($data[5]);
             $partido->setIsActive(true);
             $partido->setNombre($data[5], 'es');
             $partido->setNombre($data[5], 'ca');
             $partido->save();
             echo "Created partido ({$partido})\n";
         }
         $c = new Criteria();
         $c->add(CircunscripcionPeer::GEO_ID, $aGeo->getId());
         $circu = CircunscripcionPeer::doSelectOne($c);
         $c = new Criteria();
         $c->addJoin(ConvocatoriaPeer::ELECCION_ID, EleccionPeer::ID);
         $c->addJoin(EleccionInstitucionPeer::ELECCION_ID, EleccionPeer::ID);
         $c->addJoin(InstitucionPeer::ID, EleccionInstitucionPeer::INSTITUCION_ID);
         $c->add(InstitucionPeer::GEO_ID, $aGeo->getId());
         $convocatoria = ConvocatoriaPeer::doSelectOne($c);
         if (!$convocatoria) {
             echo "Convocatoria not found: ({$geo})\n";
             continue;
         }
         $c = new Criteria();
         $c->add(ListaPeer::CONVOCATORIA_ID, $convocatoria->getId());
         $c->add(ListaPeer::CIRCUNSCRIPCION_ID, $circu->getId());
         $c->add(ListaPeer::PARTIDO_ID, $partido->getId());
         $lista = ListaPeer::doSelectOne($c);
         if (!$lista) {
             $lista = new Lista();
             $lista->setPartido($partido);
             $lista->setCircunscripcion($circu);
             $lista->setConvocatoria($convocatoria);
             $lista->save();
             echo "Created lista ({$partido}, {$circu})\n";
         }
         $politicos = false;
         $c = new Criteria();
         $c->add("concat(nombre, ' ', apellidos)", trim($data[2]));
         //$c->add('fullname', utf8_encode( trim($data[2]) ), Criteria::EQUAL);
         $politicos = PoliticoPeer::doSelect($c);
         if (count($politicos) != 0) {
             echo "(ASIGNADO) " . $data[2] . "\n";
             $politico = $politicos[0];
         } else {
             echo "(NUEVO) " . $data[2] . "\n";
             $politico = new Politico();
             $nombreApellidos = explode(" ", $data[2]);
             $nombre = array_shift($nombreApellidos);
             $apellidos = implode(" ", $nombreApellidos);
             $politico->setNombre($nombre);
             $politico->setApellidos($apellidos);
             if ($data[7] != '1') {
                 if (trim($data[10]) != '') {
                     $c = new Criteria();
                     $c->add(PartidoPeer::ABREVIATURA, $data[5]);
                     $partido = PartidoPeer::doSelectOne($c);
                     if ($partido) {
                         $politico->setPartido($partido);
                     }
                 } else {
                     $politico->setPartido($lista->getPartido());
                 }
             }
             $politico->setSexo($data[1] == "hombre" ? 'H' : 'M');
             $politico->save();
             $politicoI18n = new PoliticoI18n();
             $politicoI18n->setPolitico($politico);
             $politicoI18n->setCulture('es');
             $politicoI18n->save();
             $politicoI18n = new PoliticoI18n();
             $politicoI18n->setPolitico($politico);
             $politicoI18n->setCulture('ca');
             $politicoI18n->save();
         }
         $c = new Criteria();
         $c->add(PoliticoListaPeer::LISTA_ID, $lista->getId());
         $c->add(PoliticoListaPeer::POLITICO_ID, $politico->getId());
         $pl = PoliticoListaPeer::doSelectOne($c);
         if (!$pl) {
             $pl = new PoliticoLista();
             $pl->setLista($lista);
             $pl->setPolitico($politico);
         } else {
             echo "Ya estaba.\n";
         }
         $pl->setOrden($data[0]);
         $pl->save();
     }
     fclose($handle);
 }
Exemplo n.º 23
0
 private function updateSums(sfWebRequest $request)
 {
     // Actualizar cache y puntos en politicos
     if ($request->getParameter("t") == Politico::NUM_ENTITY) {
         $this->politico = PoliticoPeer::retrieveByPk($request->getParameter('e'));
         $this->politico->setSumu($this->politico->getPositives());
         $this->politico->setSumd($this->politico->getNegatives());
         if ($this->politico->isModified()) {
             PoliticoPeer::doUpdate($this->politico);
         }
         $this->clearCache($this->politico);
     } else {
         if ($request->getParameter("t") == Partido::NUM_ENTITY) {
             $this->partido = PartidoPeer::retrieveByPk($request->getParameter('e'));
             $this->partido->setSumu($this->partido->getPositives());
             $this->partido->setSumd($this->partido->getNegatives());
             if ($this->partido->isModified()) {
                 PartidoPeer::doUpdate($this->partido);
             }
             $this->clearCachePartido($this->partido);
         } else {
             if ($request->getParameter("t") == '') {
                 $review = SfReviewPeer::retrieveByPk($request->getParameter('e'));
                 if ($review->getSfReviewType()->getId() == Politico::NUM_ENTITY) {
                     $politico = PoliticoPeer::retrieveByPk($review->getEntityId());
                     $this->clearCache($politico);
                 } else {
                     if ($review->getSfReviewType()->getId() == Partido::NUM_ENTITY) {
                         $partido = PartidoPeer::retrieveByPk($review->getEntityId());
                         $this->clearCachePartido($partido);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 24
0
 private function politico($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, $options['minid'], Criteria::GREATER_EQUAL);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         if ($politico->getImagen() != '') {
             echo "Creating " . $politico->getImagen() . " ...\n";
             $s3->createPoliticoFromOri($politico->getImagen());
         }
     }
 }
Exemplo n.º 25
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeShow(sfWebRequest $request)
 {
     $vanity = $request->getParameter('vanity');
     $convocatoria = $request->getParameter('convocatoria');
     $this->geoName = $request->getParameter('geo');
     $partido = $request->getParameter('partido');
     $order = $request->getParameter("o", "");
     $c = new Criteria();
     $c->addJoin(ListaPeer::CIRCUNSCRIPCION_ID, CircunscripcionPeer::ID);
     $c->addJoin(CircunscripcionPeer::GEO_ID, GeoPeer::ID);
     $c->addJoin(ListaPeer::PARTIDO_ID, PartidoPeer::ID);
     $c->addJoin(ListaPeer::CONVOCATORIA_ID, ConvocatoriaPeer::ID);
     $c->addJoin(ConvocatoriaPeer::ELECCION_ID, EleccionPeer::ID);
     $c->add(ConvocatoriaPeer::NOMBRE, $convocatoria);
     $c->add(GeoPeer::NOMBRE, $this->geoName);
     $c->add(PartidoPeer::ABREVIATURA, $partido);
     $c->add(EleccionPeer::VANITY, $vanity);
     $this->lista = ListaPeer::doSelectOne($c);
     $this->forward404Unless($this->lista);
     // Geos
     $c = new Criteria();
     $c->addJoin(ListaPeer::CIRCUNSCRIPCION_ID, CircunscripcionPeer::ID);
     $c->addJoin(CircunscripcionPeer::GEO_ID, GeoPeer::ID);
     $c->add(ListaPeer::CONVOCATORIA_ID, $this->lista->getConvocatoria()->getId());
     $c->add(ListaPeer::PARTIDO_ID, $this->lista->getPartido()->getId());
     $c->addAscendingOrderByColumn(GeoPeer::NOMBRE);
     $c->setDistinct();
     $this->geos = GeoPeer::doSelect($c);
     $instituciones = $this->lista->getConvocatoria()->getEleccion()->getEleccionInstitucions();
     $this->institucionName = $instituciones[0]->getInstitucion();
     // Lista Voota
     $c = new Criteria();
     $c->add(ConvocatoriaPeer::NOMBRE, $convocatoria);
     $this->convocatoria = ConvocatoriaPeer::doSelectOne($c);
     $this->order = $order ? $order : 'pd';
     /*
       	if ($this->convocatoria->getClosedAt()){
     $c = new Criteria();
     $c->addJoin(ListaCallePeer::POLITICO_ID, PoliticoPeer::ID);
     $c->addJoin(PoliticoListaPeer::POLITICO_ID, PoliticoPeer::ID);
     $c->add(PoliticoListaPeer::LISTA_ID, $this->lista->getId());
     
     if ($this->order == "pa"){
     	$c->addAscendingOrderByColumn(ListaCallePeer::SUMU);
     }
     else if ($this->order == "pd") {
     	$c->addDescendingOrderByColumn(ListaCallePeer::SUMU);
     	$c->addAscendingOrderByColumn(ListaCallePeer::SUMD);
     }
     else if ($this->order == "na"){
     	$c->addAscendingOrderByColumn(ListaCallePeer::SUMD);
     }
     else if ($this->order == "nd") {
     	$c->addDescendingOrderByColumn(ListaCallePeer::SUMD);
     	$c->addAscendingOrderByColumn(ListaCallePeer::SUMU);
     }
     $c->setDistinct();
     $this->politicosListaVoota = PoliticoPeer::doSelect( $c );
       	}
       	else {
     $c = new Criteria();
     $c->addJoin(PoliticoListaPeer::POLITICO_ID, PoliticoPeer::ID);
     $c->add(PoliticoListaPeer::LISTA_ID, $this->lista->getId());
     if ($this->order == "pa"){
     	$c->addAscendingOrderByColumn(PoliticoPeer::SUMU);
     }
     else if ($this->order == "pd") {
     	$c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
     	$c->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     }
     else if ($this->order == "na"){
     	$c->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     }
     else if ($this->order == "nd") {
     	$c->addDescendingOrderByColumn(PoliticoPeer::SUMD);
     	$c->addAscendingOrderByColumn(PoliticoPeer::SUMU);
     }
     $this->politicosListaVoota = PoliticoPeer::doSelect( $c );
     
       	}
     */
     $listaElectoral = new ListaElectoral($this->lista->getConvocatoriaId(), $this->lista->getPartidoId(), $this->lista->getCircunscripcion()->getGeo()->getNombre(), $this->order);
     $this->politicosListaVoota = $listaElectoral->getPoliticos();
     // Lista oficial
     $c = new Criteria();
     $c->addJoin(PoliticoListaPeer::POLITICO_ID, PoliticoPeer::ID);
     $c->add(PoliticoListaPeer::LISTA_ID, $this->lista->getId());
     $c->add(PoliticoListaPeer::ORDEN, null, Criteria::ISNOTNULL);
     $c->add(PoliticoListaPeer::ORDEN, 0, Criteria::GREATER_THAN);
     $c->addAscendingOrderByColumn(PoliticoListaPeer::ORDEN);
     $this->politicosListaOficial = PoliticoPeer::doSelect($c);
     // Metas
     $this->title = sfContext::getInstance()->getI18N()->__("Lista electoral %1% %2% %3%, %4%", array('%1%' => $this->lista->getPartido(), '%2%' => $this->lista->getConvocatoria()->getEleccion()->getNombre(), '%3%' => $this->lista->getConvocatoria()->getNombre(), '%4%' => $this->lista->getCircunscripcion()->getGeo()));
     $this->response->setTitle($this->title);
     $description = sfContext::getInstance()->getI18N()->__("Lista oficial del partido vs Lo que dice la calle: %1%, circunscripcón de %2%, %3% %4%", array('%1%' => $this->lista->getPartido()->getNombre(), '%2%' => $this->lista->getCircunscripcion()->getGeo(), '%3%' => $this->lista->getConvocatoria()->getEleccion()->getNombre(), '%4%' => $this->lista->getConvocatoria()->getNombre()));
     $this->response->addMeta('Description', $description);
 }
Exemplo n.º 26
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this sfGuardUser is new, it will return
  * an empty collection; or if this sfGuardUser has previously
  * been saved, it will retrieve related Politicos from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in sfGuardUser.
  */
 public function getPoliticosJoinPartido($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collPoliticos === null) {
         if ($this->isNew()) {
             $this->collPoliticos = array();
         } else {
             $criteria->add(PoliticoPeer::SF_GUARD_USER_ID, $this->id);
             $this->collPoliticos = PoliticoPeer::doSelectJoinPartido($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(PoliticoPeer::SF_GUARD_USER_ID, $this->id);
         if (!isset($this->lastPoliticoCriteria) || !$this->lastPoliticoCriteria->equals($criteria)) {
             $this->collPoliticos = PoliticoPeer::doSelectJoinPartido($criteria, $con, $join_behavior);
         }
     }
     $this->lastPoliticoCriteria = $criteria;
     return $this->collPoliticos;
 }
Exemplo n.º 27
0
 public function executeAutoComplete($request)
 {
     $this->getResponse()->setContentType('application/json');
     $politicos = PoliticoPeer::retrieveForAutoSelect($request->getParameter('q'), $request->getParameter('limit'));
     return $this->renderText(json_encode($politicos));
 }