Beispiel #1
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);
 }
Beispiel #2
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 Enlaces 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 getEnlacesJoinConvocatoria($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->collEnlaces === null) {
         if ($this->isNew()) {
             $this->collEnlaces = array();
         } else {
             $criteria->add(EnlacePeer::SF_GUARD_USER_ID, $this->id);
             $this->collEnlaces = EnlacePeer::doSelectJoinConvocatoria($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(EnlacePeer::SF_GUARD_USER_ID, $this->id);
         if (!isset($this->lastEnlaceCriteria) || !$this->lastEnlaceCriteria->equals($criteria)) {
             $this->collEnlaces = EnlacePeer::doSelectJoinConvocatoria($criteria, $con, $join_behavior);
         }
     }
     $this->lastEnlaceCriteria = $criteria;
     return $this->collEnlaces;
 }
Beispiel #3
0
 public function executeDeleteEnlace(sfWebRequest $request)
 {
     $enlace = EnlacePeer::retrieveByPk($request->getParameter('id'));
     $enlace->delete();
     $this->redirect('@politico_edit?id=' . $enlace->getPolitico()->getId());
 }
Beispiel #4
0
 public function executeShow(sfWebRequest $request)
 {
     $vanity = $request->getParameter('username');
     $this->f = $request->getParameter('f');
     $culture = $this->getUser()->getCulture();
     $this->sfReviewType = $request->getParameter("type_id", false);
     $this->text = $request->getParameter("t", false);
     $c = new Criteria();
     $c->add(SfGuardUserProfilePeer::VANITY, $vanity, Criteria::EQUAL);
     $userProfile = SfGuardUserProfilePeer::doSelectOne($c);
     $this->forward404Unless($userProfile);
     $this->user = $userProfile->getsfGuardUser();
     if (!$this->user->getIsActive() && is_numeric($userProfile->getFacebookUid())) {
         $user = SfGuardUserPeer::retrieveByPK($userProfile->getFacebookUid());
         $this->forward404Unless($user);
         $this->redirect('perfil/show?username='******'perfil/show?username='******'', Criteria::NOT_EQUAL);
     $this->enlaces = EnlacePeer::doSelect($c);
     $c = new Criteria();
     $c->add(PropuestaPeer::SF_GUARD_USER_ID, $userProfile->getUserId());
     $c->addDescendingOrderByColumn('created_at');
     $this->propuestas = PropuestaPeer::doSelect($c);
     //$this->reviews = SfReviewManager::getReviewsByUser($this->user->getId(), $this->f);
     $filterText = '';
     switch ($this->sfReviewType) {
         case '1':
             $filterText = sfContext::getInstance()->getI18N()->__('políticos');
             break;
         case '2':
             $filterText = sfContext::getInstance()->getI18N()->__('partidos');
             break;
         case '3':
             $filterText = sfContext::getInstance()->getI18N()->__('propuestas políticas');
             break;
         case 'null':
             $filterText = sfContext::getInstance()->getI18N()->__('otros comentarios');
             break;
     }
     //if (!$filterText){
     $this->title = sfContext::getInstance()->getI18N()->__('Página de usuario de %1% en Voota', array('%1%' => trim($this->user) ? $this->user : $this->user->getProfile()->getVanity()));
     /*}
       else {
        $this->title = sfContext::getInstance()->getI18N()->__('Opiniones de %1% sobre %2% en Voota', array(
        	'%1%' => trim($this->user)?$this->user:$this->user->getProfile()->getVanity()
        	, '%2%' => $filterText
        )); 
       }*/
     $this->response->setTitle($this->title);
     $filter = array();
     if (isset($this->sfReviewType)) {
         $filter['type_id'] = $this->sfReviewType;
         $filter['textFilter'] = $this->text ? 'text' : false;
         $filter['userId'] = $userProfile->getUserId();
         $filter['culture'] = $culture;
     }
     $this->reviewsPager = SfReviewManager::getReviews($filter, 1, 3);
     //if (!$filterText){
     $descripcion = SfVoUtil::cutToLength($userProfile->getPresentacion(), 155, '...', true);
     /*}
         else {
     			
         	if ($this->reviewsPager->getNbResults() == 0){
     		    $descripcion = sfContext::getInstance()->getI18N()->__('%1% aún no se ha animado a comentar', trim($this->user)?$this->user:$this->user->getProfile()->getVanity());
            	}   
         	else { 	
     		    $descripcion = sfContext::getInstance()->getI18N()->__('%1% ha comentado sobre', array('%1%' => trim($this->user)?$this->user:$this->user->getProfile()->getVanity())). ': ';
     		    			    
         		foreach ($this->reviewsPager->getResults() as $idx => $review){
         			$type = $review->getSfReviewTypeId();
     	  			if (! $type){
     	  				$parentReview = $review->getSfReviewRelatedBySfReviewId();
     	  				$aEntityId = $parentReview->getEntityId();
     	  				$aTypeId = $parentReview->getSfReviewTypeId();
     	  				
     	  			}
     	  			else {
     	  				$aTypeId = $type;
     	  				$aEntityId = $review->getEntityId();
     	  			}
     	  			
     	  			$reviewType = SfReviewTypePeer::retrieveByPK ( $aTypeId );
     	  			$peer = $reviewType->getModel() .'Peer';
     	  			
     	  			//$entity = $peer::retrieveByPK($aEntityId);
     	  			$entity = call_user_func("$peer::retrieveByPK", $aEntityId);
     
     	  			$descripcion .= ($idx != 0?', ':'').(!$type?sfContext::getInstance()->getI18N()->__('otro comentario sobre'). ' ':'').($aTypeId==Propuesta::NUM_ENTITY?"\"$entity\"":$entity);
     	    	}
         	}
         }*/
     $this->response->addMeta('Description', $descripcion ? $descripcion : sfContext::getInstance()->getI18N()->__('Votos y opiniones de %1% sobre políticos y partidos de España', array('%1%' => trim($this->user) ? $this->user : $this->user->getProfile()->getVanity())));
     // Feed
     $request->setAttribute('rssTitle', $this->title . " Feed RSS");
     $request->setAttribute('rssFeed', 'perfil/feed?username=' . $this->user->getProfile()->getVanity());
 }
Beispiel #5
0
 private function getEnlaces($propuesta)
 {
     $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(EnlacePeer::PROPUESTA_ID, $propuesta->getId());
     $c->add(EnlacePeer::URL, '', Criteria::NOT_EQUAL);
     $c->addAscendingOrderByColumn(EnlacePeer::ORDEN);
     return EnlacePeer::doSelect($c);
 }
Beispiel #6
0
 public function executeShow(sfWebRequest $request)
 {
     $abreviatura = $request->getParameter('id');
     $culture = $this->getUser()->getCulture("es");
     $this->institucion = $request->getParameter("institucion");
     if ($this->institucion == '') {
         $this->institucion = "0";
     }
     $c = new Criteria();
     $c->add(PartidoPeer::ABREVIATURA, $abreviatura, Criteria::EQUAL);
     $this->partido = PartidoPeer::doSelectOne($c);
     $this->forward404Unless($this->partido);
     $this->forward404Unless($this->partido->getIsActive());
     if ($this->partido->getAbreviatura() != $abreviatura) {
         $this->redirect('partido/show?id=' . $this->partido->getAbreviatura(), 301);
     }
     // Estabamos vootando antes del login ?
     $sfr_status = $this->getUser()->getAttribute('sfr_status', false, 'sf_review');
     if ($sfr_status) {
         $aSfrStatus = array();
         foreach ($sfr_status as $key => $value) {
             $aSfrStatus[$key] = $value;
         }
         $this->sfr_status = $aSfrStatus;
         $request->setAttribute('sfr_status', $aSfrStatus);
         $this->getUser()->setAttribute('sfr_status', false, 'sf_review');
     } else {
         $this->getUser()->setAttribute('sfr_status', false, 'sf_review');
         $this->sfr_status = false;
     }
     if ($this->partido->getImagen() != '') {
         $imageFileName = $this->partido->getImagen();
     } else {
         $imageFileName = "p_unknown.png";
     }
     $this->image = "cc_{$imageFileName}";
     $pu = $this->getUser()->getAttribute('pageU');
     $pd = $this->getUser()->getAttribute('pageD');
     $c = $this->getUser()->getAttribute('review_c');
     if ($c != '' && $pu != '') {
         $resU = BaseSfReviewManager::NUM_REVIEWS * ($pu - 1);
         $this->pageU = $pu;
     } else {
         $resU = BaseSfReviewManager::NUM_REVIEWS;
         $this->pageU = 2;
     }
     if ($c != '' && $pd != '') {
         $resD = BaseSfReviewManager::NUM_REVIEWS * ($pd - 1);
         $this->pageD = $pd;
     } else {
         $resD = BaseSfReviewManager::NUM_REVIEWS;
         $this->pageD = 2;
     }
     $id = $this->partido->getId();
     $this->positives = SfReviewManager::getReviewsByEntityAndValue($request, Partido::NUM_ENTITY, $id, 1, $resU);
     $this->negatives = SfReviewManager::getReviewsByEntityAndValue($request, Partido::NUM_ENTITY, $id, -1, $resD);
     $positiveCount = $this->positives->getNbResults();
     $negativeCount = $this->negatives->getNbResults();
     $this->getUser()->setAttribute('pageU', '');
     $this->getUser()->setAttribute('pageD', '');
     $this->totalCount = $positiveCount + $negativeCount;
     if ($this->totalCount > 0) {
         $this->positivePerc = intval($positiveCount * 100 / $this->totalCount);
         $this->negativePerc = 100 - $this->positivePerc;
     } else {
         $this->positivePerc = 0;
         $this->negativePerc = 0;
     }
     // 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::PARTIDO_ID, $id);
     $c->addAscendingOrderByColumn(EnlacePeer::ORDEN);
     $this->activeEnlaces = EnlacePeer::doSelect($c);
     $this->twitterUser = FALSE;
     foreach ($this->activeEnlaces as $enlace) {
         if (preg_match("/twitter\\.com\\/#!\\/(.*)\$/is", $enlace->getUrl(), $matches)) {
             $this->twitterUser = $matches[1];
             break;
         }
         if (preg_match("/twitter\\.com\\/(.*)\$/is", $enlace->getUrl(), $matches)) {
             $this->twitterUser = $matches[1];
             break;
         }
     }
     // Politicos mas votados
     $c = new Criteria();
     $c->addJoin(array(PoliticoPeer::ID, PoliticoI18nPeer::CULTURE), array(PoliticoI18nPeer::ID, "'{$culture}'"), Criteria::LEFT_JOIN);
     $c->add(PoliticoPeer::VANITY, null, Criteria::ISNOTNULL);
     $c->add(PoliticoPeer::PARTIDO_ID, $this->partido->getId());
     $c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
     $c->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     $this->politicos = new sfPropelPager('Politico', 6);
     $this->politicos->setCriteria($c);
     $this->politicos->init();
     // Lista de instituciones
     $c = new Criteria();
     $c->addJoin(InstitucionPeer::ID, PoliticoInstitucionPeer::INSTITUCION_ID);
     $c->addJoin(PoliticoInstitucionPeer::POLITICO_ID, PoliticoPeer::ID);
     $c->addJoin(PoliticoPeer::PARTIDO_ID, PartidoPeer::ID);
     $c->add(PoliticoPeer::PARTIDO_ID, $this->partido->getId());
     $c->add(InstitucionPeer::IS_MAIN, true);
     $c->setDistinct();
     $c->addAscendingOrderByColumn(InstitucionPeer::ORDEN);
     $this->instituciones = InstitucionPeer::doSelect($c);
     // Lista de listas
     $this->listasGenerales = false;
     $this->listasAutonomicas = false;
     $this->listasMunicipales = false;
     foreach ($this->partido->getListas() as $lista) {
         //$lista->getCircunscripcion()->getGeo()
         foreach ($lista->getConvocatoria()->getEleccion()->getEleccionInstitucions() as $insti) {
             $geo = $insti->getInstitucion()->getGeo();
             if ($geo->getId() == 1) {
                 $this->listasGenerales = true;
             } elseif ($geo->getGeoRelatedByGeoId()->getId() == 1) {
                 $this->listasAutonomicas = true;
             } elseif ($geo->getGeoRelatedByGeoId()->getGeoRelatedByGeoId()->getId() == 1) {
             } elseif ($geo->getGeoRelatedByGeoId()->getGeoRelatedByGeoId()->getGeoRelatedByGeoId()->getId() == 1) {
                 $this->listasMunicipales = true;
             }
         }
     }
     $this->pageTitle = $this->partido->getNombre() . " (" . $this->partido->getAbreviatura() . ")";
     $this->title = $this->pageTitle . ' - Voota';
     $this->response->addMeta('Title', $this->title);
     $descripcion = $this->partido->getAbreviatura() . ": " . sfContext::getInstance()->getI18N()->__('presentación, opiniones de usuarios a favor y en contra, políticos mejor valorados y enlaces. ', array()) . SfVoUtil::cutToLength($this->partido->getPresentacion(), 140, '...', true);
     $this->response->addMeta('Descripcion', $descripcion);
     // Listas de electorales
     $convocatoriaActiva = sfConfig::get('sf_convocatoria_activa');
     $this->convocatoria = ConvocatoriaPeer::retrieveByPk($convocatoriaActiva);
     $c = new Criteria();
     $c->add(ListaPeer::PARTIDO_ID, $this->partido->getId());
     $c->add(ListaPeer::CONVOCATORIA_ID, $convocatoriaActiva);
     $c->addJoin(ListaPeer::CIRCUNSCRIPCION_ID, CircunscripcionPeer::ID);
     $c->addJoin(CircunscripcionPeer::GEO_ID, GeoPeer::ID);
     $c->addAscendingOrderByColumn(GeoPeer::NOMBRE);
     $this->listas = ListaPeer::doSelect($c);
     /* paginador */
     $this->partidosPager = EntityManager::getPager($this->partido);
     /* / paginador */
     // Feed
     $request->setAttribute('rssTitle', $this->title . " Feed RSS");
     $request->setAttribute('rssFeed', 'partido/feed?id=' . $this->partido->getVanity());
 }
Beispiel #7
0
 public function executeShow(sfWebRequest $request)
 {
     $vanity = $request->getParameter('id');
     $s = $request->getParameter('s', 0);
     $f = $request->getParameter('f', 'none');
     $F = $request->getParameter('F', 'none');
     $culture = $this->getUser()->getCulture();
     $c = new Criteria();
     $c->add(PoliticoPeer::VANITY, $vanity, Criteria::EQUAL);
     $politico = PoliticoPeer::doSelectOne($c);
     $this->forward404Unless($politico);
     if ($f != 'none' || $F != 'none') {
         $this->redirect('politico/show?id=' . $politico->getVanity(), 301);
     }
     $this->partido = $request->getParameter("partido");
     $this->institucion = $request->getParameter("institucion");
     $this->rankingUrl = $this->generateRankingUrl($this->partido, $this->institucion);
     $this->politico = $politico;
     $id = $this->politico->getId();
     $this->forward404Unless($this->politico);
     if ($this->politico->getVanity() != $vanity) {
         $this->redirect('politico/show?id=' . $this->politico->getVanity(), 301);
     }
     // Estabamos vootando antes del login ?
     $sfr_status = $this->getUser()->getAttribute('sfr_status', false, 'sf_review');
     if ($sfr_status) {
         $aSfrStatus = array();
         foreach ($sfr_status as $key => $value) {
             $aSfrStatus[$key] = $value;
         }
         $this->sfr_status = $aSfrStatus;
         $request->setAttribute('sfr_status', $aSfrStatus);
         $this->getUser()->setAttribute('sfr_status', false, 'sf_review');
     } else {
         $this->getUser()->setAttribute('sfr_status', false, 'sf_review');
         $this->sfr_status = false;
     }
     if ($this->politico->getImagen() != '') {
         $imageFileName = $this->politico->getImagen();
     } else {
         $imageFileName = "p_unknown.png";
     }
     $this->image = "bw_{$imageFileName}";
     $pu = $this->getUser()->getAttribute('pageU');
     $pd = $this->getUser()->getAttribute('pageD');
     $c = $this->getUser()->getAttribute('review_c');
     if ($c != '' && $pu != '') {
         $resU = BaseSfReviewManager::NUM_REVIEWS * ($pu - 1);
         $this->pageU = $pu;
     } else {
         $resU = BaseSfReviewManager::NUM_REVIEWS;
         $this->pageU = 2;
     }
     if ($c != '' && $pd != '') {
         $resD = BaseSfReviewManager::NUM_REVIEWS * ($pd - 1);
         $this->pageD = $pd;
     } else {
         $resD = BaseSfReviewManager::NUM_REVIEWS;
         $this->pageD = 2;
     }
     $exclude = array();
     $this->positives = SfReviewManager::getReviewsByEntityAndValue($request, 1, $id, 1, $resU);
     $this->negatives = SfReviewManager::getReviewsByEntityAndValue($request, 1, $id, -1, $resD);
     $positiveCount = $this->positives->getNbResults();
     $negativeCount = $this->negatives->getNbResults();
     $this->getUser()->setAttribute('pageU', '');
     $this->getUser()->setAttribute('pageD', '');
     $this->totalCount = $positiveCount + $negativeCount;
     if ($this->totalCount > 0) {
         $this->positivePerc = intval($positiveCount * 100 / $this->totalCount);
         $this->negativePerc = 100 - $this->positivePerc;
     } else {
         $this->positivePerc = 0;
         $this->negativePerc = 0;
     }
     $this->title = sfContext::getInstance()->getI18N()->__('%1%, opiniones a favor y en contra en Voota', array('%1%' => $this->politico->getNombre() . ' ' . $this->politico->getApellidos()));
     $description = sfContext::getInstance()->getI18N()->__('Página de %1%', array('%1%' => $this->politico->getNombre() . ' ' . $this->politico->getApellidos()));
     if (count($this->politico->getPoliticoInstitucions()) > 0) {
         $description .= " (";
         //instituciones
         foreach ($this->politico->getPoliticoInstitucions() as $idx => $politicoInstitucion) {
             if ($idx > 0) {
                 $description .= ', ';
             }
             $description .= $politicoInstitucion->getInstitucion()->getNombre();
         }
         $description .= ")";
     }
     $description .= ", " . $this->politico->getPartido() . ", ";
     //partido
     $description .= sfContext::getInstance()->getI18N()->__('%1% votos a favor y %2% votos en contra.', array('%1%' => $positiveCount, '%2%' => $negativeCount));
     $this->response->addMeta('Description', $description);
     $this->response->setTitle($this->title);
     // 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);
     if ($politico->getsfGuardUser()) {
         $c->add(EnlacePeer::SF_GUARD_USER_ID, $politico->getsfGuardUser()->getId());
     } else {
         $c->add(EnlacePeer::POLITICO_ID, $id);
     }
     $c->add(EnlacePeer::URL, '', Criteria::NOT_EQUAL);
     $c->addAscendingOrderByColumn(EnlacePeer::ORDEN);
     $this->activeEnlaces = EnlacePeer::doSelect($c);
     if ($politico->getsfGuardUser() && count($this->activeEnlaces) == 0) {
         $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::POLITICO_ID, $id);
         $c->add(EnlacePeer::URL, '', Criteria::NOT_EQUAL);
         $c->addAscendingOrderByColumn(EnlacePeer::ORDEN);
         $this->activeEnlaces = EnlacePeer::doSelect($c);
     }
     $this->twitterUser = FALSE;
     foreach ($this->activeEnlaces as $enlace) {
         if (preg_match("/twitter\\.com\\/#!\\/(.*)\$/is", $enlace->getUrl(), $matches)) {
             $this->twitterUser = $matches[1];
             break;
         }
         if (preg_match("/twitter\\.com\\/(.*)\$/is", $enlace->getUrl(), $matches)) {
             $this->twitterUser = $matches[1];
             break;
         }
     }
     /* paginador */
     $this->politicosPager = EntityManager::getPager($this->politico);
     /* / paginador */
     // Feed
     $request->setAttribute('rssTitle', $this->title . " Feed RSS");
     $request->setAttribute('rssFeed', 'politico/feed?id=' . $this->politico->getVanity());
     $this->listas = false;
     $c = new Criteria();
     $c->add(PoliticoListaPeer::POLITICO_ID, $this->politico->getId());
     $c->addJoin(PoliticoListaPeer::LISTA_ID, ListaPeer::ID);
     $c->addJoin(ConvocatoriaPeer::ID, ListaPeer::CONVOCATORIA_ID);
     $c->add(ConvocatoriaPeer::FECHA, time(), Criteria::GREATER_THAN);
     $this->listas = PoliticoListaPeer::doSelect($c);
 }
Beispiel #8
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(EnlacePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EnlacePeer::DATABASE_NAME);
         $criteria->add(EnlacePeer::ID, $pks, Criteria::IN);
         $objs = EnlacePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Beispiel #9
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 = EnlacePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUrl($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setTipo($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPartidoId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setPoliticoId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPropuestaId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setConvocatoriaId($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setSfGuardUserId($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setOrden($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setMostrar($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setCreatedAt($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setCulture($arr[$keys[11]]);
     }
 }