예제 #1
1
파일: _review.php 프로젝트: voota/voota
$dc->add(SfReviewPeer::IS_ACTIVE, true);
$listValue = isset($listValue) ? $listValue : '';
?>

<li class="review" id="<?php 
echo "sf_review_c_m" . $review->getId();
?>
">

  <?php 
include_partial('sfReviewFront/user_header', array('review' => $review));
?>

	<p class="review-date">
	  <?php 
echo link_to(ago(strtotime($review->getModifiedAt() ? $review->getModifiedAt() : $review->getCreatedAt())), 'sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
?>
	</p>
  <p class="review-body">
    <?php 
echo review_text($review);
?>
  </p>
  
	<?php 
if ($reviewable) {
    ?>
    <?php 
    include_partial('sfReviewFront/add_subreview', array('sf_user' => $sf_user, 'review' => $review, 'uc' => $uc, 'dc' => $dc, 'listValue' => $listValue));
    ?>
    <?php 
예제 #2
1
 public function executeFeed(sfWebRequest $request)
 {
     $vanity = $request->getParameter('id');
     $s = $request->getParameter('s', 0);
     $culture = $this->getUser()->getCulture();
     $c = new Criteria();
     $c->add(PropuestaPeer::VANITY, $vanity);
     $entity = PropuestaPeer::doSelectOne($c);
     $this->forward404Unless($entity);
     if ($entity->getCulture() != $culture) {
         $this->redirect("@homepage");
     }
     $filter = array();
     $filter['type_id'] = Propuesta::NUM_ENTITY;
     $filter['entity_id'] = $entity->getId();
     $reviews = SfReviewManager::getReviews($filter);
     $title = sfContext::getInstance()->getI18N()->__('%1% en Voota.es', array('%1%' => $entity));
     $description = sfContext::getInstance()->getI18N()->__('Opiniones sobre %1%, %2% votos a favor y %3% votos en contra', array('%1%' => $entity, '%2%' => $entity->getSumu(), '%3%' => $entity->getSumd()));
     $feed = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $feed->setLink('propuesta/show?id=' . $entity->getVanity());
     $domainExt = $culture == 'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     $feedImage = new sfFeedImage();
     $feedImage->setLink('propuesta/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;
 }
예제 #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();
     }
 }
예제 #4
0
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     $taintedValues['abreviatura'] = SfVoUtil::fixVanityChars($taintedValues['abreviatura']);
     if (!$this->isNew()) {
         if (is_null($taintedValues['enlace']['url']) || strlen($taintedValues['enlace']['url']) === 0) {
             unset($this->embeddedForms['enlace'], $taintedValues['enlace']);
             $this->validatorSchema['enlace'] = new sfValidatorPass();
         } else {
             $this->embeddedForms['enlace']->getObject()->setPartido($this->getObject());
         }
     }
     parent::bind($taintedValues, $taintedFiles);
 }
예제 #5
0
 public function bind(array $taintedValues = null, array $taintedFiles = null, $img = false)
 {
     // remove the embedded new form if the name field was not provided
     $taintedValues['vanity'] = SfVoUtil::fixVanityChars($taintedValues['vanity']);
     for ($idx = 1; $idx <= 5; $idx++) {
         if (is_null($taintedValues["enlace_n{$idx}"]['url'])) {
             unset($this->embeddedForms["enlace_n{$idx}"], $taintedValues["enlace_n{$idx}"]);
             $this->validatorSchema["enlace_n{$idx}"]['url'] = new sfValidatorUrl(array('required' => false));
         } else {
             $this->validatorSchema["enlace_n{$idx}"]['url'] = new sfVoValidatorUrl(array('required' => false), sfVoForm::getUrlMessages());
             $this->embeddedForms["enlace_n{$idx}"]->getObject()->setSfGuardUser($this->getObject());
         }
     }
     // call parent bind method
     parent::bind($taintedValues, $taintedFiles);
 }
예제 #6
0
 protected function doSave($con = null)
 {
     $institucion = $this->getObject();
     if ($this->getValue('vanity') == '') {
         $vanityUrl = SfVoUtil::encodeVanity($this->getValue('nombre_corto'));
         $c2 = new Criteria();
         $c2->add(InstitucionI18nPeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
         $c2->add(InstitucionPeer::ID, $institucion->getId(), Criteria::NOT_EQUAL);
         $usuariosLikeMe = InstitucionPeer::doSelect($c2);
         $counter = 0;
         foreach ($usuariosLikeMe as $usuarioLikeMe) {
             $counter++;
         }
         $this->setValue('vanity', "{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}"));
     }
     parent::doSave($con);
 }
 public function executeShow(sfWebRequest $request)
 {
     $id = $request->getParameter("id");
     $this->review = SfReviewPeer::retrieveByPK($id);
     // Mmovido aqui para fix de #848
     $this->forward404Unless($this->review);
     if (($goodVanity = SfVoUtil::reviewPermalink($this->review)) != $id) {
         //echo "$goodVanity == $id";
         $this->redirect('sfReviewFront/show?id=' . $goodVanity, 301);
     }
     if ($this->review->getSfReviewTypeId()) {
         $c = new Criteria();
         $c->add(SfReviewTypePeer::ID, $this->review->getSfReviewTypeId());
         $reviewType = SfReviewTypePeer::doSelectOne($c);
         $peer = $reviewType->getModel() . 'Peer';
         $c = new Criteria();
         $c->add($peer::ID, $this->review->getEntityId());
         $this->entity = new Entity($peer::doSelectOne($c));
     }
 }
예제 #8
0
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     $vanity = isset($taintedValues['vanity']) ? $taintedValues['vanity'] : false;
     $titulo = isset($taintedValues['titulo']) ? $taintedValues['titulo'] : false;
     $descripcion = isset($taintedValues['descripcion']) ? $taintedValues['descripcion'] : false;
     $id = isset($taintedValues['id']) ? $taintedValues['id'] : false;
     if ($titulo) {
         $taintedValues['titulo'] = SfVoUtil::cutToLength($taintedValues['titulo'], 80);
     }
     if ($descripcion) {
         $taintedValues['descripcion'] = SfVoUtil::cutToLength($taintedValues['descripcion'], 600);
     }
     if ($vanity) {
         $taintedValues['vanity'] = SfVoUtil::fixVanityChars($vanity);
     } else {
         if (!$id) {
             $taintedValues['vanity'] = SfVoUtil::fixVanityChars($taintedValues['titulo']);
         }
     }
     if (!$this->isNew()) {
         if (isset($taintedValues['enlace'])) {
             if (is_null($taintedValues['enlace']['url']) || strlen($taintedValues['enlace']['url']) === 0) {
                 unset($this->embeddedForms['enlace'], $taintedValues['enlace']);
                 $this->validatorSchema['enlace'] = new sfValidatorPass();
             } else {
                 $this->embeddedForms['enlace']->getObject()->setPropuesta($this->getObject());
             }
         }
         if (isset($taintedValues['institucion'])) {
             if (is_null($taintedValues['institucion']['institucion_id']) || strlen($taintedValues['institucion']['institucion_id']) === 0) {
                 unset($this->embeddedForms['institucion'], $taintedValues['institucion']);
                 $this->validatorSchema['institucion'] = new sfValidatorPass();
             } else {
                 $this->embeddedForms['institucion']->getObject()->setPropuesta($this->getObject());
             }
         }
     }
     parent::bind($taintedValues, $taintedFiles);
 }
예제 #9
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++;
                     }
                 }
             }
         }
     }
 }
예제 #10
0
파일: showSuccess.php 프로젝트: voota/voota
            ?>
</li>
            	<?php 
        }
        ?>
            <?php 
    }
    ?>
          </ul>
        </div>
      <?php 
}
?>

	  <?php 
if ($user->getProfile()->getMailsContacto() && SfVoUtil::isEmail($user->getUsername())) {
    ?>
      <p class="contact">
        <img src="/images/email.png" width="16" height="16" alt="email" />
        <?php 
    echo link_to(__('Mandar un mensaje a') . ' ' . fullName($user), '@usuario_contact?username=' . $user->getProfile()->getVanity());
    ?>
      </p>
	  <?php 
}
?>
    </div>
  </div>

  <div class="propuestas">
    <?php 
예제 #11
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->hasDeepUpdates = false;
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $this->propuestasCount = PropuestaPeer::doCount($c);
     $this->isCanonicalVootaUser = SfVoUtil::isCanonicalVootaUser($this->getUser()->getGuardUser());
     if ($this->getUser()->isAuthenticated()) {
         $this->lastReview = SfReviewManager::getLastReviewByUserId($this->getUser()->getGuardUser()->getId());
         $this->lastReviewOnReview = SfReviewManager::getLastReviewOnReviewByUserId($this->getUser()->getGuardUser()->getId());
     }
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     $formData = sfGuardUserPeer::retrieveByPk($this->getUser()->getGuardUser()->getId());
     if (!SfVoUtil::isEmail($formData->getUsername())) {
         $formData->setUsername('');
     }
     $this->profileEditForm = new ProfileEditForm($formData);
     $this->politico = false;
     $politicos = $this->getUser()->getGuardUser()->getPoliticos();
     if ($politicos && count($politicos) != 0) {
         $this->politico = $politicos[0];
         unset($this->profileEditForm['nombre'], $this->profileEditForm['apellidos']);
     }
     $imagenOri = $formData->getProfile()->getImagen();
     $criteria = new Criteria();
     $criteria->add(SfReviewPeer::IS_ACTIVE, true);
     $criteria->add(SfReviewPeer::SF_GUARD_USER_ID, $this->getUser()->getGuardUser()->getId());
     $this->numReviews = SfReviewPeer::doCount($criteria);
     if ($request->isMethod('post')) {
         $this->profileEditForm->bind($request->getParameter('profile'), $request->getFiles('profile'));
         if ($this->profileEditForm->isValid()) {
             /*if ($this->politico){
             		  	$cacheManager = $this->getContext()->getViewCacheManager();
             		  	if ($cacheManager != null) {
             		  		$politico = $this->getRoute()->getObject();
             		    	$cacheManager->remove("politico/show?id=".$politico->getVanity()."");
             		  	}				
             		}*/
             $profile = $request->getParameter('profile');
             $this->hasDeepUpdates = $profile['presentacion'] != $formData->getProfile()->getPresentacion();
             if ($this->profileEditForm->getValue('imagen_delete') != "") {
                 // Si se elimina la imagen, hay que recargar el formulario para que se refresque
                 $formData->getProfile()->setImagen("");
                 //$formData->getProfile()->save();
                 $this->profileEditForm->setImageSrc("");
                 $this->profileEditForm->resetImageWidget();
                 //$this->profileEditForm = new ProfileEditForm( $formData );
             } else {
                 $imageOri = $this->profileEditForm->getObject()->getProfile()->getImagen();
                 $imagen = $this->profileEditForm->getValue('imagen');
                 $this->profileEditForm->save();
                 if ($imagen) {
                     $arr = array_reverse(explode(".", $imagen->getOriginalName()));
                     $ext = strtolower($arr[0]);
                     if (!$ext || $ext == "") {
                         $ext = "png";
                     }
                     $imageName = $this->profileEditForm->getValue('nombre') ? $this->profileEditForm->getValue('nombre') : $arr[1];
                     if ($this->profileEditForm->getValue('apellidos') != '') {
                         $imageName .= "-" . $this->profileEditForm->getValue('apellidos');
                     }
                     $imageName .= "-" . sprintf("%04d", rand(0, 999));
                     $imageName .= ".{$ext}";
                     $imagen->save(sfConfig::get('sf_upload_dir') . '/usuarios/' . $imageName);
                     $this->profileEditForm->getObject()->getProfile()->setImagen($imageName);
                     $this->profileEditForm->setImageSrc($imageName);
                     $this->profileEditForm->resetImageWidget();
                     $this->hasDeepUpdates = true;
                 } else {
                     $this->profileEditForm->getObject()->getProfile()->setImagen($imagenOri);
                     $this->profileEditForm->setImageSrc($imagenOri);
                 }
             }
             if ($profile['passwordNew'] != '') {
                 // Check old password
                 if ($this->getUser()->checkPassword($profile['passwordOld'])) {
                     $this->getUser()->setPassword($profile['passwordNew']);
                 } else {
                     $this->getUser()->setFlash('notice_type', 'error', false);
                     $this->getUser()->setFlash('notice', sfVoForm::getMissingPasswordMessage(), false);
                     return;
                 }
             }
             $this->getUser()->setFlash('notice_type', 'notice', false);
             $this->getUser()->setFlash('notice', sfVoForm::getFormSavesMessage(), false);
             $this->profileEditForm->save();
             $profile = $this->profileEditForm->getObject()->getProfile();
             $profile->save();
             $aText = utf8_decode($this->profileEditForm->getValue('presentacion'));
             $aText = strip_tags(substr($aText, 0, 280));
             $aText = utf8_encode($aText);
             $profile->setPresentacion($aText);
             $profile->save();
             if ($profile->isColumnModified(SfGuardUserProfileI18nPeer::PRESENTACION)) {
                 $this->hasDeepUpdates = true;
             }
             $this->presentacionValue = $aText;
         } else {
             $this->getUser()->setFlash('notice_type', 'error', false);
             $this->getUser()->setFlash('notice', sfVoForm::getFormNotValidMessage(), false);
         }
     }
     if (!$this->presentacionValue) {
         $this->presentacionValue = $politicos = $this->getUser()->getGuardUser()->getProfile()->getPresentacion();
     }
 }
예제 #12
0
 protected function institucion($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();
     $instituciones = InstitucionPeer::doSelect($c);
     foreach ($instituciones as $institucion) {
         if ($institucion->getVanity('es') == null || $institucion->getVanity('es') == '') {
             echo "Setting vanity to  " . $institucion->getId() . " ...\n";
             $vanityUrl = SfVoUtil::encodeVanity($institucion->getNombreCorto('es'));
             $c2 = new Criteria();
             $c2->addJoin(InstitucionPeer::ID, InstitucionI18nPeer::ID, Criteria::LEFT_JOIN);
             $c2->add(InstitucionI18nPeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
             $c2->add(InstitucionPeer::ID, $institucion->getId(), Criteria::NOT_EQUAL);
             $institucionesLikeMe = InstitucionPeer::doSelect($c2);
             $counter = 0;
             foreach ($institucionesLikeMe as $institucionLikeMe) {
                 $counter++;
             }
             $institucion->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}"), 'es');
             $institucion->save();
         }
     }
 }
예제 #13
0
 public function sendTasks(sfWebRequest $request)
 {
     $tw_publish = $request->getParameter("tw_publish", 0);
     $t = $request->getParameter("t", false);
     $v = $request->getParameter("v", false);
     $e = $request->getParameter("e", false);
     $review_text = $request->getParameter("review_text", false);
     $this->updateSums($request);
     if ($t) {
         $type = SfReviewTypePeer::retrieveByPk($t);
         $peer = $type->getModel() . "Peer";
         $entity = call_user_func("{$peer}::retrieveByPk", $e);
     } else {
         $review = SfReviewPeer::retrieveByPk($request->getParameter('e'));
         if ($typeId = $review->getSfReviewTypeId()) {
             $type = SfReviewTypePeer::retrieveByPK($typeId);
             $peer = $type->getModule() . 'Peer';
             $entity = call_user_func("{$peer}::retrieveByPk", $review->getEntityId());
         }
     }
     $msg = "";
     if ($tw_publish && TwitterManager::verify($this->getUser())) {
         switch ($t) {
             case Politico::NUM_ENTITY:
                 $entityUrl = sfContext::getInstance()->getController()->genUrl("politico/show?id=" . $entity->getVanity(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Voto  %1% de %2% en @Voota:  %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => $entity, '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
             case Partido::NUM_ENTITY:
                 $entityUrl = sfContext::getInstance()->getController()->genUrl("partido/show?id=" . $entity->getAbreviatura(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Voto %1% del partido %2% en @Voota: %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => $entity->getAbreviatura(), '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
             case Propuesta::NUM_ENTITY:
                 $entityUrl = sfContext::getInstance()->getController()->genUrl("propuesta/show?id=" . $entity->getVanity(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Voto %1% de la propuesta "%2%" en @Voota: %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => SfVoUtil::cutToLength($entity->getTitulo(), 60, '...', true), '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
             case "":
                 $entityUrl = sfContext::getInstance()->getController()->genUrl($type->getModule() . "/show?id=" . $entity->getVanity(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Vooto %1% de una opinión sobre %2% en @Voota: %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => $entity, '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
         }
         TwitterManager::post($this->getUser(), $msg);
     }
     // Enviar email
     if (!$t) {
         //echo $request->getParameter('i');
         $user = $review->getsfGuardUser();
         if ($user->getProfile()->getMailsComentarios()) {
             if ($typeId) {
                 $user->getProfile()->setCodigo(util::generateUID());
                 $user->getProfile()->save();
                 $mailBody = $this->getPartial('reviewLeftMailBody', array('nombre' => $user->getProfile()->getNombre(), 'usuario' => $review->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo (está en su derecho)') : $this->getUser()->getProfile()->getNombre() . ' ' . $this->getUser()->getProfile()->getApellidos(), 'entity' => $typeId == Propuesta::NUM_ENTITY ? "\"{$entity}\"" : $entity, 'texto_ori' => $review->getText(), 'comentario' => $request->getParameter('review_text'), 'vanity' => $entity->getVanity(), 'codigo' => $user->getProfile()->getCodigo(), 'voto' => $request->getParameter('v'), 'module' => $entity->getModule()));
                 VoMail::send(sfContext::getInstance()->getI18N()->__('Tu vooto sobre %1% tiene un comentario', array('%1%' => $entity)), $mailBody, $user->getUsername(), array('*****@*****.**' => 'no-reply Voota'), true);
             }
         }
     }
 }
예제 #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";
         }
     }
 }
예제 #15
0
</span>
		<?php 
}
?>
	</div>
              
	<div class="body">
  	<?php 
echo review_text($review, array(), false);
?>
  </div>
    
	<div class="actions">
		<?php 
if ($sf_user->isAuthenticated() && $sf_user->getGuardUser()->getId() == $review->getSfGuardUser()->getId()) {
    ?>
      <?php 
    echo link_to(__('Hacer cambios'), "@usuario_votos?o=e&t=" . $review->getSfReviewTypeId() . "&e=" . ($review->getSfReviewType() ? $review->getEntityId() : $review->getSfReviewRelatedBySfReviewId()->getId()) . "&r=" . $review->getId());
    ?>
    <?php 
} else {
    ?>
      <?php 
    echo link_to(__('Ir a su comentario'), 'sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
    ?>
    <?php 
}
?>
	</div>
</li>  
예제 #16
0
 public static function postReview($userId, $typeId, $entityId, $value, $text = false, $entity = false, $rm = false, $fb = '?', $source = '', $anonymous = '?', $tw = '?')
 {
     $prevValue = false;
     $guessAnonymous = $anonymous && $anonymous == '?' ? true : false;
     $guessFB = $fb && $fb == '?' ? true : false;
     $guessTW = $tw && $tw == '?' ? true : false;
     if ($guessAnonymous) {
         $user = sfGuardUserPeer::retrieveByPK($userId);
         if ($user) {
             $anonymous = $user->getProfile()->getAnonymous();
         }
     }
     if (!$entityId || !$value) {
         throw new Exception("Not enough parameters.");
     }
     if ($value != -1 && $value != 1) {
         throw new Exception("Invalid data for 'value'.");
     }
     // Check if already exists
     $c = new Criteria();
     if (!$typeId) {
         $c->add(SfReviewPeer::SF_REVIEW_ID, $entityId);
     } else {
         $c->add(SfReviewPeer::ENTITY_ID, $entityId);
     }
     $c->add(SfReviewPeer::SF_GUARD_USER_ID, $userId);
     $c->add(SfReviewPeer::SF_REVIEW_TYPE_ID, $typeId ? $typeId : null);
     $review = SfReviewPeer::doSelectOne($c);
     if (!$review) {
         $review = new SfReview();
         if (!$typeId) {
             $review->setSfReviewId($entityId);
         } else {
             $review->setEntityId($entityId);
         }
         $review->setSfReviewTypeId($typeId ? $typeId : null);
         $review->setSfGuardUserId($userId);
         $review->setCreatedAt(new DateTime());
         $review->setSource($source);
     } else {
         if ($rm && $value == $review->getValue() && $review->getIsActive()) {
             $review->setIsActive(false);
         } else {
             $review->setIsActive(true);
         }
         $review->setModifiedAt(new DateTime());
     }
     $review->setValue($value);
     if ($text) {
         $aText = SfVoUtil::cutToLength($text, self::MAX_LENGTH, '');
         $aText = strip_tags($aText);
         $review->setText($aText);
     }
     $review->setSfReviewStatusId(1);
     $review->setIpAddress($_SERVER['REMOTE_ADDR']);
     $review->setCookie(sfContext::getInstance()->getRequest()->getCookie('symfony'));
     $review->setCulture(sfContext::getInstance()->getUser()->getCulture());
     if (!$guessFB) {
         $review->setToFb($fb);
     }
     if (!$guessTW) {
         $review->setToTw($tw);
     }
     if (!$guessAnonymous || $review->isNew()) {
         $review->setAnonymous($anonymous);
     }
     try {
         $review->save();
         if (!$typeId) {
             $parentReview = SfReviewPeer::retrieveByPk($entityId);
             $parentReview->setBalance(SfReviewManager::getBalanceByReviewId($entityId));
             $parentReview->save();
         }
         if (!$entity) {
             if (!$typeId) {
                 $aEntityId = $parentReview->getEntityId();
                 $aTypeId = $parentReview->getSfReviewTypeId();
             } else {
                 $aTypeId = $typeId;
                 $aEntityId = $entityId;
             }
             $reviewType = SfReviewTypePeer::retrieveByPK($aTypeId);
             $peer = $reviewType->getModel() . 'Peer';
             $entity = $peer::retrieveByPK($aEntityId);
         }
         $entity->updateCalcs();
         $entity->save();
     } catch (Exception $e) {
         throw new Exception('Error writing review.');
     }
     return $review->getIsActive() ? $review : false;
 }
예제 #17
0
 private function search($data)
 {
     $q = $this->getRequestParameter("q", '');
     if (!$q) {
         throw new BadRequestException('A search string must be provided.');
     }
     $page = $this->getRequestParameter("page", '1');
     $limit = $this->getRequestParameter("limit", self::PAGE_SIZE);
     $culture = $this->getRequestParameter("culture", 'es');
     $type = $this->getRequestParameter("type", false);
     $cl = new SphinxClient();
     $dbConf = Propel::getConfiguration();
     $dsn = $dbConf['datasources']['propel']['connection']['dsn'];
     $sphinxServer = sfConfig::get('sf_sphinx_server');
     $cl->SetServer($sphinxServer, 3312);
     $this->limit = 1000;
     $cl->SetLimits(0, $this->limit, $this->limit);
     $cl->SetArrayResult(true);
     $entities = array();
     $cl->SetArrayResult(true);
     if ($type && $type != 'party' && $type != 'politician' && $type != 'proposal') {
         throw new BadRequestException('Invalid type.');
     }
     if (!$type || $type == 'party') {
         $this->res = $cl->Query(SfVoUtil::stripAccents($q), "partido_{$culture}");
         if ($this->res !== false) {
             if (isset($this->res["matches"]) && is_array($this->res["matches"])) {
                 $c = new Criteria();
                 $list = array();
                 foreach ($this->res["matches"] as $idx => $match) {
                     $list[] = $match['id'];
                 }
                 $c->add(PartidoPeer::ID, $list, Criteria::IN);
                 //$c->addDescendingOrderByColumn(PartidoPeer::SUMU);
                 $pager = new sfPropelPager('Partido', $limit);
                 $pager->setCriteria($c);
                 $pager->setPage($this->getRequestParameter('page', $page));
                 $pager->init();
                 foreach ($pager->getResults() as $partido) {
                     $entities[] = new Entity($partido);
                 }
             }
         }
     }
     if (!$type || $type == 'politician') {
         $this->res = $cl->Query(SfVoUtil::stripAccents($q), "politico_{$culture}");
         if ($this->res !== false) {
             if (isset($this->res["matches"]) && is_array($this->res["matches"])) {
                 $c = new Criteria();
                 $list = array();
                 foreach ($this->res["matches"] as $idx => $match) {
                     $list[] = $match['id'];
                 }
                 $c = new Criteria();
                 $c->add(PoliticoPeer::ID, $list, Criteria::IN);
                 //$c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
                 $pager = new sfPropelPager('Politico', $limit);
                 $pager->setCriteria($c);
                 $pager->setPage($this->getRequestParameter('page', $page));
                 $pager->init();
                 foreach ($pager->getResults() as $politico) {
                     $entities[] = new Entity($politico);
                 }
             }
         }
     }
     if (!$type || $type == 'proposal') {
         $this->res = $cl->Query(SfVoUtil::stripAccents($q), "propuesta_{$culture}");
         if ($this->res !== false) {
             if (isset($this->res["matches"]) && is_array($this->res["matches"])) {
                 $c = new Criteria();
                 $list = array();
                 foreach ($this->res["matches"] as $idx => $match) {
                     $list[] = $match['id'];
                 }
                 $c = new Criteria();
                 $c->add(PropuestaPeer::ID, $list, Criteria::IN);
                 //$c->addDescendingOrderByColumn(PropuestaPeer::SUMU);
                 $pager = new sfPropelPager('Propuesta', $limit);
                 $pager->setCriteria($c);
                 $pager->setPage($this->getRequestParameter('page', $page));
                 $pager->init();
                 foreach ($pager->getResults() as $propuesta) {
                     $entities[] = new Entity($propuesta);
                 }
             }
         }
     }
     return $entities;
 }
예제 #18
0
파일: sfCutTest.php 프로젝트: voota/voota
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$tests = array('ábcd' => array('length' => 10, 'ext' => '', 'fullWords' => false), 'ábcd2' => array('length' => 1, 'ext' => '', 'fullWords' => false), 'ábcd3' => array('length' => 2, 'ext' => '', 'fullWords' => false), 'ábcd4' => array('length' => 3, 'ext' => '', 'fullWords' => false), 'aácd5' => array('length' => 1, 'ext' => '', 'fullWords' => false), 'La nueva reforma de la ley de tráfico pretende, en palabras de Rubalcaba (al menos eso dice la carta de mi buzón), conseguir que nuestras carreteras sean cada vez más seguras.
  
  Para ello basan su campaña en tres pilares básicos:
  
  - Más sencilla
  - Más fácil
  - Más justa
  
  Adjunto la la ley en pdf y enlace a la página correspondiente.
  
  La nueva reforma de la ley de tráfico pretende, en palabras de Rubalcaba (al menos eso dice la carta de mi buzón), conseguir que nuestras carreteras sean cada vez más seguras.
  
  Para ello basan su campaña en tres pilares básicos:
  
  - Más sencilla
  - Más fácil
  - Más justa
  
  Adjunto la la ley en pdf y enlace a la página correspondiente.' => array('length' => 182, 'ext' => '', 'fullWords' => false));
foreach ($tests as $string => $attributes) {
    echo "{$string} (" . $attributes['length'] . "): [" . SfVoUtil::cutToLength($string, $attributes['length'], $attributes['ext'], $attributes['fullWords']) . "]\n";
}
예제 #19
0
 public function executeSearch(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $this->page = $this->getRequestParameter('page', 1);
     $tag = $request->getParameter("tag", false);
     $tag = str_replace("_2E_", ".", $tag);
     if ($tag) {
         $this->q = "#{$tag}";
     } else {
         $this->q = $request->getParameter("q");
     }
     $request->setAttribute("q", $this->q);
     $resultsArray = array();
     $cl = $this->resetSphinxClient();
     $needle = $this->q;
     $this->ext = "";
     if (strlen($needle) > 0 && strpos($needle, '#') === 0) {
         $this->ext = "_tag";
         $needle = substr($needle, 1);
     } else {
         $needle = SfVoUtil::stripAccents($this->q);
     }
     $this->politicoCounts = false;
     $this->partidoCounts = false;
     $this->propuestaCounts = false;
     if ($needle) {
         if ($this->ext == "_tag") {
             $cl->SetMatchMode(SPH_MATCH_PHRASE);
             $cl->SetSortMode(SPH_SORT_EXTENDED, "cnt DESC");
             $this->politicoCounts = array();
             $this->partidoCounts = array();
             $this->propuestaCounts = array();
             $indexes = "partido_tag_{$culture}, politico_tag_{$culture}, propuesta_tag_{$culture}";
             $this->res = $cl->Query($needle, $indexes);
             if ($this->res !== false) {
                 $this->total = $this->res['total'];
                 $this->totalFound = $this->res['total_found'];
                 $cl->SetLimits(($this->page - 1) * $this->limit, $this->limit);
                 $this->res = $cl->Query($needle, $indexes);
             }
         } else {
             $cl->SetFieldWeights(array('abreviatura_partido' => 5, 'nombre' => 5, 'apellidos' => 5, 'alias' => 5, 'titulo' => 5, 'nombre_insti' => 8, 'nombre_ele' => 9));
             $cl->SetSortMode(SPH_SORT_EXPR, "@weight + ( 1 * votes/max_votes )");
             $indexes = "politico_{$culture}, partido_{$culture},propuesta_{$culture}, institucion_{$culture}, usuario, eleccion_{$culture}";
             $this->res = $cl->Query($needle, $indexes);
             if ($this->res !== false) {
                 $this->total = $this->res['total'];
                 $this->totalFound = $this->res['total_found'];
                 $cl->SetLimits(($this->page - 1) * $this->limit, $this->limit);
                 $this->res = $cl->Query($needle, $indexes);
             }
         }
         if ($this->res !== false && isset($this->res["matches"]) && is_array($this->res["matches"])) {
             foreach ($this->res["matches"] as $match) {
                 //echo "<pre>";print_r( $match );echo "</pre>";
                 switch ($match['attrs']['type']) {
                     case 1:
                         if ($this->ext == "_tag") {
                             $this->politicoCounts[$match['attrs']['politico_id']] = $match['attrs']['cnt'];
                             $resultsArray[] = PoliticoPeer::retrieveByPK($match['attrs']['politico_id']);
                         } else {
                             $resultsArray[] = PoliticoPeer::retrieveByPK($match['id']);
                         }
                         break;
                     case 2:
                         if ($this->ext == "_tag") {
                             $this->partidoCounts[$match['attrs']['partido_id']] = $match['attrs']['cnt'];
                             $resultsArray[] = PartidoPeer::retrieveByPK($match['attrs']['partido_id']);
                         } else {
                             $resultsArray[] = PartidoPeer::retrieveByPK($match['id']);
                         }
                         break;
                     case 3:
                         if ($this->ext == "_tag") {
                             $this->propuestaCounts[$match['attrs']['propuesta_id']] = $match['attrs']['cnt'];
                             $resultsArray[] = PropuestaPeer::retrieveByPK($match['attrs']['propuesta_id']);
                         } else {
                             $resultsArray[] = PropuestaPeer::retrieveByPK($match['id']);
                         }
                         break;
                     case 101:
                         $resultsArray[] = InstitucionPeer::retrieveByPK($match['id']);
                         break;
                     case 102:
                         $resultsArray[] = SfGuardUserPeer::retrieveByPK($match['id']);
                         break;
                     case 103:
                         $resultsArray[] = ConvocatoriaPeer::retrieveByPK($match['id']);
                         break;
                 }
             }
         }
     }
     $this->results = $resultsArray;
     $this->title = sfContext::getInstance()->getI18N()->__('"%1%" en Voota', array('%1%' => $this->q));
     $descStr = "";
     foreach ($resultsArray as $idx => $result) {
         if ($idx < 3) {
             $descStr .= ($descStr ? ', ' : '') . $result;
         }
     }
     $this->response->addMeta('Description', sfContext::getInstance()->getI18N()->__('Resultados de la búsqueda "%1%" en Voota: %2%, ...', array('%1%' => $this->q, '%2%' => $descStr)));
     $this->response->setTitle($this->title);
 }
예제 #20
0
  <h3>
    <img src="/images/icoFacebookPref.png" alt="Facebook Connect" />
    <?php 
    echo __('Conectado a Facebook como:');
    ?>
 <strong><?php 
    echo jsWrite('fb:name', array('uid' => $sf_user->getProfile()->getFacebookUid(), 'useyou' => 'false', 'linked' => 'false'));
    ?>
</strong>
    (<a id="facebook-disconnect" href="#"><?php 
    echo __('Desconectar');
    ?>
</a>)
    <script type="text/javascript">
      <?php 
    if (SfVoUtil::isCanonicalVootaUser($sf_user->getGuardUser())) {
        ?>
  	    $('#facebook-disconnect').click(function() {
  	      facebookDisconnectAccount('<?php 
        echo url_for('@usuario_fb_edit?op=dis');
        ?>
');
  	      return false;
  	    });
      <?php 
    } else {
        ?>
        $('#facebook-disconnect').click(function() {
  	      facebookLogoutAndRedirect('<?php 
        echo url_for('@usuario_fb_edit?op=dis');
        ?>
예제 #21
0
 public function executeFeed(sfWebRequest $request)
 {
     $vanity = $request->getParameter('username');
     $this->f = $request->getParameter('f');
     $culture = $this->getUser()->getCulture();
     $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='******'%1% en Voota.es', array('%1%' => $this->user));
     $descripcion = SfVoUtil::cutToLength($userProfile->getPresentacion(), 155, '...', true);
     $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 = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $feed->setLink('perfil/show?username='******'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     $feedImage = new sfFeedImage();
     $feedImage->setLink('perfil/show?username='******'/usuarios/cc_' . $this->user->getProfile()->getImagen());
     $feedImage->setTitle($this->user);
     $feed->setImage($feedImage);
     foreach ($reviews as $review) {
         $item = new sfFeedItem();
         $entityText = "";
         if (!$review->getSfReviewType()) {
             $tmpReview = $review->getSfReviewRelatedBySfReviewId();
             $entityText = sfContext::getInstance()->getI18N()->__('Otra opinión sobre') . ' ';
         } else {
             $tmpReview = $review;
         }
         $sfReviewType = SfReviewTypePeer::retrieveByPk($tmpReview->getSfReviewTypeId());
         $peer = $sfReviewType->getModel() . 'Peer';
         $entity = $peer::retrieveByPk($tmpReview->getEntityId());
         $entityText .= $entity;
         $item->setTitle(sfContext::getInstance()->getI18N()->__('%1%, voota %2%.', array('%1%' => $entityText, '%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;
 }
예제 #22
0
파일: newPreview.php 프로젝트: voota/voota
',
							'href': '<?php 
echo url_for('propuesta/show?id=' . SfVoUtil::fixVanityChars($form['titulo']->getValue()), true);
?>
',
						  'media': [{
				  			'type': 'image',
				  			'src': '<?php 
echo S3Voota::getImagesUrl();
?>
/propuestas/cc_s_<?php 
echo $form['imagen']->getValue();
?>
',
						  	'href': '<?php 
echo url_for('propuesta/show?id=' . SfVoUtil::fixVanityChars($form['titulo']->getValue()), true);
?>
'
						  }]
						};
					  try {
					    publishFaceBook("<?php 
echo __('He dejado una nueva propuesta en Voota: \\"%1\\"', array('%1' => $form['titulo']->getValue()));
?>
", attachment, [{'text':'<?php 
echo __('Ir a Voota');
?>
', 'href':'http://voota.es'}], '<?php 
echo __('Vamos a publicar esto en Facebook, ¿que te parece?');
?>
');
예제 #23
0
파일: layout.php 프로젝트: voota/voota
            	    <?php 
        echo vo_facebook_connect_associate_button(__('Sincronizar tu cuenta en Voota con Facebook'), 'lo_fb_conn');
        ?>
                <span class="close">(<a href="#" onclick="close_sync_tip('<?php 
        echo url_for('sfGuardAuth/removeTip');
        ?>
'); return false"><?php 
        echo __('Cerrar');
        ?>
</a>)</span>
              </span>
              <?php 
    }
    ?>
              <?php 
    if ($sf_user->getProfile() && $sf_user->getProfile()->getFbTip() && $sf_user->getProfile()->getFacebookUid() && !SfVoUtil::isCanonicalVootaUser($sf_user->getGuardUser())) {
        ?>
              <span id="lo_fb_conn">
            	  <strong><?php 
        echo __('Tip:');
        ?>
 </strong>
            	  	<a href="<?php 
        echo url_for('sfGuardAuth/signin?op=fb');
        ?>
"><?php 
        echo __('¿Ya tenías cuenta en Voota? Sincronizar con tu Facebook');
        ?>
</a>
                <span class="close">(<a href="#" onclick="close_sync_tip('<?php 
        echo url_for('sfGuardAuth/removeTip');
예제 #24
0
파일: Politico.php 프로젝트: voota/voota
 public function getLongName()
 {
     return SfVoUtil::cutToLength("" . $this->__toString(), 35) . ($this->getPartido() ? " (" . $this->getPartido() . ")" : '');
 }
예제 #25
0
function highlightWords($str, $q)
{
    return SfVoUtil::highlightWords($str, $q);
}
예제 #26
0
    ?>
<a title='<?php 
    echo sfVoUtil::secureString($activity->getEntity(), "&#39;");
    ?>
' href="<?php 
    echo url_for($activity->getEntity()->getModule() . '/show?id=' . $activity->getEntity()->getVanity());
    ?>
"><?php 
    echo trim(sfVoUtil::cutToLength(sfVoUtil::secureString($activity->getEntity(), "&#39;"), 32, '...'));
    ?>
</a><?php 
    echo $activity->getEntity()->getType() == Politico::NUM_ENTITY && $activity->getEntity()->getPartido() ? " (" . $activity->getEntity()->getPartido() . ")" : '';
    ?>
.
	    <span class="review-date"><?php 
    echo link_to(ago(strtotime($activity->getDate())), 'sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($activity));
    ?>
.</span>
  	<?php 
}
?>
  	<?php 
if ($activity->getMode() == 2) {
    ?>
	  		<?php 
    echo __('A %1% le han puesto la etiqueta "%2%".', array('%1%' => "<a title='" . sfVoUtil::secureString($activity->getEntity(), "&#39;") . "' href= \"" . url_for($activity->getEntity()->getModule() . '/show?id=' . $activity->getEntity()->getVanity()) . "\">" . trim(sfVoUtil::cutToLength(sfVoUtil::secureString($activity->getEntity(), "&#39;"), 32, '...')) . "</a>" . ($activity->getEntity()->getType() == Politico::NUM_ENTITY && $activity->getEntity()->getPartido() ? " (" . $activity->getEntity()->getPartido() . ")" : ''), '%2%' => review_text($activity)));
    ?>
	<?php 
}
?>
  </div>
예제 #27
0
파일: SfVoUtil.php 프로젝트: voota/voota
 public static function isCanonicalVootaUser($user)
 {
     return $user && $user->getProfile()->getNombre() && $user->getProfile()->getNombre() != '' && SfVoUtil::isEmail($user->getUsername());
 }
예제 #28
0
function changeCulture($culture)
{
    $extensions = array('es' => 'es', 'ca' => 'cat');
    $sf_context = sfContext::getInstance();
    $request = $sf_context->getRequest();
    $module = $request->getParameter('module');
    $action = $request->getParameter('action');
    $parameters = $request->getParameterHolder()->getAll();
    $curCulture = $sf_context->getUser()->getCulture('es');
    $routeName = $sf_context->getRouting()->getCurrentRouteName();
    $routeName = preg_replace("/_{$curCulture}\$/", "_{$culture}", $routeName);
    $params = "";
    foreach ($parameters as $name => $value) {
        if ($name != 'module' && $name != 'action') {
            if ($name == 'institucion') {
                $c = new Criteria();
                $c->addJoin(InstitucionPeer::ID, InstitucionI18nPeer::ID);
                $c->addJoin(array(InstitucionPeer::ID, InstitucionI18nPeer::CULTURE), array(InstitucionI18nPeer::ID, "'{$curCulture}'"), Criteria::INNER_JOIN);
                $c->add(InstitucionI18nPeer::VANITY, $value);
                $aInstitucion = InstitucionPeer::doSelectOne($c);
                if ($aInstitucion) {
                    $value = $aInstitucion->getVanity($culture);
                }
            }
            if ($module == 'sfReviewFront' && $action == 'show' && $name == 'id') {
                $review = SfReviewPeer::retrieveByPk($request->getParameter('id'));
                $value = SfVoUtil::reviewPermalink($review, $culture);
            }
            $params .= ($params == "" ? '?' : '&') . "{$name}={$value}";
        }
    }
    $route = sfContext::getInstance()->getController()->genUrl("@{$routeName}{$params}");
    $host = preg_replace("/\\.[a-zA-Z]*\$/is", "." . $extensions[$culture], $_SERVER['HTTP_HOST']);
    return "http://{$host}{$route}";
}
예제 #29
0
 public function executeUsuarioResult()
 {
     $this->quote = '';
     if (SfVoUtil::matches($this->obj->getProfile()->getNombre(), $this->q)) {
     } else {
         if (SfVoUtil::matches($this->obj->getProfile()->getApellidos(), $this->q)) {
         } else {
             if (SfVoUtil::matches($this->obj->getProfile()->getPresentacion(), $this->q)) {
                 $this->quote = $this->obj->getProfile()->getPresentacion();
             }
         }
     }
     $c = new Criteria();
     $c->add(SfReviewPeer::SF_GUARD_USER_ID, $this->obj->getId());
     $c->add(SfReviewPeer::IS_ACTIVE, true);
     $this->numReviews = SfReviewPeer::doCount($c);
     $this->quote = SfVoUtil::highlightWords($this->quote, $this->q);
 }
예제 #30
0
 public static function newTag($entity, $texto)
 {
     $user = sfContext::getInstance()->getUser();
     if ($user->isAuthenticated() && $texto) {
         $tags = preg_split("/[\\s,]+/", $texto);
         foreach ($tags as $tag) {
             $c = new Criteria();
             $c1 = new VoCriterion($c, EtiquetaPeer::TEXTO, SfVoUtil::strtolowerEs($tag));
             $c1->setIgnoreAccent(true);
             //$c->add(EtiquetaPeer::TEXTO, strtolower($tag) . ' collate utf8_bin');
             $c->add($c1);
             $c->add(EtiquetaPeer::CULTURE, $user->getCulture());
             $etiqueta = EtiquetaPeer::doSelectOne($c);
             if (!$etiqueta) {
                 $etiqueta = new Etiqueta();
                 $etiqueta->setTexto(SfVoUtil::strtolowerEs($tag));
                 $etiqueta->setCulture($user->getCulture());
                 $etiqueta->save();
             }
             if ($entity->getType() == Politico::NUM_ENTITY) {
                 $c->add(EtiquetaPoliticoPeer::ETIQUETA_ID, $etiqueta->getId());
                 $c->add(EtiquetaPoliticoPeer::CULTURE, $user->getCulture());
                 $c->add(EtiquetaPoliticoPeer::POLITICO_ID, $entity->getId());
                 $c->add(EtiquetaPoliticoPeer::SF_GUARD_USER_ID, $user->getGuardUser()->getId());
                 $etiquetaPolitico = EtiquetaPoliticoPeer::doSelectOne($c);
                 if (!$etiquetaPolitico) {
                     $etiquetaPolitico = new EtiquetaPolitico();
                     $etiquetaPolitico->setPoliticoId($entity->getId());
                     $etiquetaPolitico->setEtiquetaId($etiqueta->getId());
                     $etiquetaPolitico->setCulture($user->getCulture());
                     $etiquetaPolitico->setFecha(time());
                     $etiquetaPolitico->setSfGuardUserId($user->getGuardUser()->getId());
                     $etiquetaPolitico->save();
                 } else {
                     $etiquetaPolitico->setFecha(time());
                     $etiquetaPolitico->save();
                 }
             } elseif ($entity->getType() == Partido::NUM_ENTITY) {
                 $c->add(EtiquetaPartidoPeer::ETIQUETA_ID, $etiqueta->getId());
                 $c->add(EtiquetaPartidoPeer::CULTURE, $user->getCulture());
                 $c->add(EtiquetaPartidoPeer::PARTIDO_ID, $entity->getId());
                 $c->add(EtiquetaPartidoPeer::SF_GUARD_USER_ID, $user->getGuardUser()->getId());
                 $etiquetaPartido = EtiquetaPartidoPeer::doSelectOne($c);
                 if (!$etiquetaPartido) {
                     $etiquetaPartido = new EtiquetaPartido();
                     $etiquetaPartido->setPartidoId($entity->getId());
                     $etiquetaPartido->setEtiquetaId($etiqueta->getId());
                     $etiquetaPartido->setCulture($user->getCulture());
                     $etiquetaPartido->setFecha(time());
                     $etiquetaPartido->setSfGuardUserId($user->getGuardUser()->getId());
                     $etiquetaPartido->save();
                 } else {
                     $etiquetaPartido->setFecha(time());
                     $etiquetaPartido->save();
                 }
             } elseif ($entity->getType() == Propuesta::NUM_ENTITY) {
                 $c->add(EtiquetaPropuestaPeer::ETIQUETA_ID, $etiqueta->getId());
                 $c->add(EtiquetaPropuestaPeer::CULTURE, $user->getCulture());
                 $c->add(EtiquetaPropuestaPeer::PROPUESTA_ID, $entity->getId());
                 $c->add(EtiquetaPropuestaPeer::SF_GUARD_USER_ID, $user->getGuardUser()->getId());
                 $etiquetaPropuesta = EtiquetaPropuestaPeer::doSelectOne($c);
                 if (!$etiquetaPropuesta) {
                     $etiquetaPropuesta = new EtiquetaPropuesta();
                     $etiquetaPropuesta->setPropuestaId($entity->getId());
                     $etiquetaPropuesta->setEtiquetaId($etiqueta->getId());
                     $etiquetaPropuesta->setCulture($user->getCulture());
                     $etiquetaPropuesta->setFecha(time());
                     $etiquetaPropuesta->setSfGuardUserId($user->getGuardUser()->getId());
                     $etiquetaPropuesta->save();
                 } else {
                     $etiquetaPropuesta->setFecha(time());
                     $etiquetaPropuesta->save();
                 }
             }
         }
     }
 }