示例#1
0
 public function configure()
 {
     $this->setWidgets(array('username' => new sfWidgetFormInputText(array())));
     $this->widgetSchema->setNameFormat('reminder[%s]');
     $this->widgetSchema->setLabels(array('username' => 'Email'));
     $this->setValidators(array('username' => new sfValidatorEmail(array('required' => true), sfVoForm::getEmailMessages())));
 }
 public function configure()
 {
     unset($this['id'], $this['vanity'], $this['titulo'], $this['descripcion'], $this['imagen']);
     $this->setWidgets(array('doc' => new sfWidgetFormInputFileEditable(array('label' => sfContext::getInstance()->getI18N()->__('Imagen', array(), 'notices'), 'file_src' => $this->getObject() ? '' . S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $this->getObject()->getDoc() : '', 'is_image' => false, 'edit_mode' => !$this->isNew(), 'template' => '%input%'))));
     $this->widgetSchema->setNameFormat('propuesta[%s]');
     $this->setValidators(array('doc' => new sfValidatorFile(array('required' => false, 'max_size' => '512000', 'path' => sfConfig::get('sf_upload_dir') . '/docs', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages())));
 }
示例#3
0
 public function configure()
 {
     unset($this['created_at'], $this['total_escanyos'], $this['min_sumu'], $this['min_sumd'], $this['lista_calle_list']);
     $this->embedI18n(array('es', 'ca'));
     $this->widgetSchema['imagen'] = new sfWidgetFormInputFileEditable(array('label' => 'Imagen Principal', 'file_src' => S3Voota::getImagesUrl() . '/elecciones/cc_' . $this->getObject()->getImagen(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file% <br /> %input%<br />%delete% Eliminar imagen actual</div>'));
     $this->validatorSchema['imagen'] = new sfValidatorFile(array('required' => false, 'max_size' => '512000', 'mime_types' => 'web_images', 'path' => sfConfig::get('sf_upload_dir') . '/elecciones', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages("500K"));
     $this->validatorSchema['imagen_delete'] = new sfValidatorBoolean();
     if (!$this->isNew()) {
         // embed all enlace forms
         foreach ($this->getObject()->getEnlaces() as $enlace) {
             // create a new enlace form for the current enlace model object
             $enlaceForm = new ConvocatoriaEnlaceForm($enlace);
             // embed the enlace form in the main Eleccion form
             $this->embedForm('enlace' . $enlace->getId(), $enlaceForm);
             // set a custom label for the embedded form
             $this->widgetSchema['enlace' . $enlace->getId()]->setLabel('Enlace ' . $enlace->getId());
             // change the name widget to sfWidgetFormInputDelete
             $this->widgetSchema['enlace' . $enlace->getId()]['url'] = new sfWidgetFormInputDelete(array('url' => 'convocatoria/deleteEnlace', 'model_id' => $enlace->getId(), 'confirm' => 'Sure???'));
         }
         // create a new enlace form for a new enlace model object
         $enlaceForm = new ConvocatoriaEnlaceForm();
         // embed the enlace form in the main convocatoria form
         $this->embedForm('enlace', $enlaceForm);
         // set a custom label for the embedded form
         $this->widgetSchema['enlace']->setLabel('Nuevo enlace');
     }
 }
示例#4
0
 public function configure()
 {
     $years = range(1920, date('Y'));
     $this->setWidgets(array('passwordNew' => new sfWidgetFormInputText(array('type' => 'password')), 'password_again' => new sfWidgetFormInputText(array('type' => 'password'))));
     $this->widgetSchema->setNameFormat('changer[%s]');
     $this->widgetSchema->setLabels(array('passwordNew' => sfContext::getInstance()->getI18N()->__('Password', array(), 'notices'), 'password_again' => sfContext::getInstance()->getI18N()->__('Password (otra vez)', array(), 'notices')));
     $this->setValidators(array('passwordNew' => new sfValidatorPassword(array('required' => true), sfVoForm::getStringMessages()), 'password_again' => new sfValidatorPassword(array('required' => true), sfVoForm::getStringMessages())));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('passwordNew', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), sfVoForm::getCompareMessages()));
 }
示例#5
0
 public function configure()
 {
     if (!$this->mensajeWidget) {
         $this->mensajeWidget = new sfWidgetFormTextarea(array());
     }
     $this->setWidgets(array('nombre' => new sfWidgetFormInputText(array()), 'email' => new sfWidgetFormInputText(array()), 'tipo' => new sfWidgetFormSelect(array('choices' => self::$tipos)), 'mensaje' => $this->mensajeWidget));
     $this->widgetSchema->setNameFormat('contact[%s]');
     $this->setValidators(array('nombre' => new sfValidatorString(array('required' => false), sfVoForm::getStringMessages()), 'email' => new sfValidatorEmail(array('required' => true), sfVoForm::getEmailMessages()), 'tipo' => new sfValidatorString(array('required' => false), sfVoForm::getStringMessages()), 'mensaje' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages())));
 }
示例#6
0
 public function configure()
 {
     $this->setWidgets(array('op' => new sfWidgetFormInputHidden(), 'username' => new sfWidgetFormInputText(array()), 'nombre' => new sfWidgetFormInputText(array()), 'anonymous' => new sfWidgetFormInputCheckbox(array(), array()), 'apellidos' => new sfWidgetFormInputText(array()), 'password' => new sfWidgetFormInputText(array('type' => 'password')), 'accept' => new sfWidgetFormInputCheckbox(array(), array())));
     $this->widgetSchema->setNameFormat('registration[%s]');
     $this->widgetSchema->setLabels(array('username' => 'Email', 'nombre' => sfContext::getInstance()->getI18N()->__('Nombre', array(), 'notices'), 'apellidos' => sfContext::getInstance()->getI18N()->__('Apellidos', array(), 'notices'), 'password' => sfContext::getInstance()->getI18N()->__('Password', array(), 'notices')));
     $this->setValidators(array('op' => new sfValidatorString(array('required' => false)), 'username' => new sfValidatorEmail(array('required' => true), sfVoForm::getEmailMessages()), 'nombre' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages()), 'anonymous' => new sfValidatorString(array('required' => false), sfVoForm::getStringMessages()), 'accept' => new sfValidatorBoolean(array('required' => true), sfVoForm::getRequiredMessages()), 'apellidos' => new sfValidatorString(array('required' => false), sfVoForm::getStringMessages()), 'password' => new sfValidatorPassword(array('required' => true), sfVoForm::getStringMessages()), 'accept' => new sfValidatorBoolean(array('required' => true), sfVoForm::getRequiredMessages())));
     //$this->validatorSchema->setPostValidator(new sfValidatorPropelUnique(array('model'=>'sfGuardUser', 'column'=>array('username'))));
     $this->validatorSchema->setPostValidator(new sfValidatorPropelUnique(array('model' => 'sfGuardUser', 'column' => array('username')), sfVoForm::getUniqueEmailMessages()));
 }
示例#7
0
 public function configure()
 {
     unset($this['sumu'], $this['sumd'], $this['created_at'], $this['modified_at'], $this['doc'], $this['doc_size'], $this['etiqueta_propuesta_list']);
     $this->widgetSchema['descripcion'] = new sfWidgetFormTextarea(array(), array('style' => "width: 500px; height:200px"));
     $this->widgetSchema['imagen'] = new sfWidgetFormInputFileEditable(array('label' => 'Imagen Principal', 'file_src' => S3Voota::getImagesUrl() . '/propuestas/cc_' . $this->getObject()->getImagen(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file% <br /> %input%<br />%delete% Eliminar imagen actual</div>'));
     $this->widgetSchema['doc'] = new sfWidgetFormInputFileEditable(array('label' => sfContext::getInstance()->getI18N()->__('Doc', array(), 'notices'), 'file_src' => $this->getObject() ? '' . S3Voota::getImagesUrl() . '/docs/' . $this->getObject()->getDoc() : '', 'is_image' => false, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file% <br /> %input% <span class="hints">' . sfContext::getInstance()->getI18N()->__('(opcional)') . '<br />' . ($this->getObject()->getDoc() ? '%delete% Eliminar documento actual' : '') . '</div>'));
     $this->validatorSchema['imagen'] = new sfValidatorFile(array('required' => false, 'max_size' => '512000', 'mime_types' => 'web_images', 'path' => sfConfig::get('sf_upload_dir') . '/propuestas', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages("500K"));
     $this->validatorSchema['doc'] = new sfValidatorFile(array('required' => false, 'max_size' => '2048000', 'path' => sfConfig::get('sf_upload_dir') . '/docs', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages("2M"));
     $this->validatorSchema['imagen_delete'] = new sfValidatorBoolean();
     $this->validatorSchema['doc_delete'] = new sfValidatorBoolean();
     $this->validatorSchema['url_video_1'] = new sfValidatorUrl(array('required' => false));
     $this->validatorSchema['url_video_2'] = new sfValidatorUrl(array('required' => false));
 }
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     for ($idx = 1; $idx <= 5; $idx++) {
         $this->validatorSchema["enlace_n{$idx}"]['url'] = new sfVoValidatorUrl(array('required' => false), sfVoForm::getUrlMessages());
         $this->validatorSchema["enlace_n{$idx}"]['culture'] = new sfValidatorString(array('required' => false));
         if (is_null($taintedValues["enlace_n{$idx}"]['url'])) {
             unset($this->embeddedForms["enlace_n{$idx}"], $taintedValues["enlace_n{$idx}"]);
         } else {
             $enlace = $this->embeddedForms["enlace_n{$idx}"]->getObject();
             $taintedValues["enlace_n{$idx}"]['culture'] = sfContext::getInstance()->getUser()->getCulture();
         }
     }
     parent::bind($taintedValues, $taintedFiles);
 }
示例#9
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);
 }
示例#10
0
 public function configure()
 {
     unset($this['sumu'], $this['sumd'], $this['created_at'], $this['modified_at'], $this['id'], $this['vanity']);
     $this->setWidgets(array('op' => new sfWidgetFormInputHidden(), 'titulo' => new sfWidgetFormInputHidden(array()), 'descripcion' => new sfWidgetFormInputHidden(array()), 'imagen' => new sfWidgetFormInputHidden(array()), 'doc' => new sfWidgetFormInputHidden(array()), 'culture' => new sfWidgetFormInputHidden(array())));
     $this->widgetSchema->setNameFormat('propuesta[%s]');
     $this->setValidators(array('titulo' => new sfValidatorString(array("min_length" => SfVoUtil::VANITY_MIN_LENGTH, 'required' => true), sfVoForm::getStringMessages()), 'descripcion' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages()), 'vanity' => new sfValidatorString(array('required' => true)), 'sf_guard_user_id' => new sfValidatorInteger(array('required' => true)), 'imagen' => new sfValidatorString(array('required' => false)), 'doc' => new sfValidatorString(array('required' => false)), 'culture' => new sfValidatorString(array('required' => false))));
     // Vacíos
     $idx = 0;
     while ($idx < 5) {
         $idx++;
         // create a new enlace form for a new enlace model object
         $enlaceForm = new PropuestaEnlaceForm();
         // embed the enlace form in the main politico form
         $this->embedForm("enlace_n{$idx}", $enlaceForm);
         $this->widgetSchema["enlace_n{$idx}"]['orden'] = new sfWidgetFormInputHidden();
         $this->widgetSchema["enlace_n{$idx}"]['url'] = new sfWidgetFormInputHidden();
     }
 }
示例#11
0
 public function configure()
 {
     unset($this['id'], $this['vanity']);
     $this->setWidgets(array('op' => new sfWidgetFormInputHidden(), 'titulo' => new sfWidgetFormTextArea(array()), 'descripcion' => new sfWidgetFormTextArea(array(), array('rows' => 20, 'cols' => 30)), 'imagen' => new sfWidgetFormInputFileEditable(array('label' => sfContext::getInstance()->getI18N()->__('Imagen', array(), 'notices'), 'file_src' => $this->getObject() ? '' . S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $this->getObject()->getImagen() : '', 'is_image' => false, 'edit_mode' => !$this->isNew(), 'template' => '<div>' . ($this->getObject()->getImagen() ? '<p><img src="%file%" alt="' . $this->getObject()->getTitulo() . '" /> %delete% <label for="profile_imagen_delete">' . sfContext::getInstance()->getI18N()->__('Eliminar imagen actual', array(), 'notices') . '</label></p>' : '') . '%input% <span class="hints">' . sfContext::getInstance()->getI18N()->__('(opcional)') . '</span></div>')), 'doc' => new sfWidgetFormInputFileEditable(array('label' => sfContext::getInstance()->getI18N()->__('Imagen', array(), 'notices'), 'file_src' => $this->getObject() ? '' . S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $this->getObject()->getDoc() : '', 'is_image' => false, 'edit_mode' => !$this->isNew(), 'template' => '<div>' . ($this->getObject()->getImagen() ? '<p>' . $this->getObject()->getTitulo() . ' %delete% <label for="profile_imagen_delete">' . sfContext::getInstance()->getI18N()->__('Eliminar documento actual', array(), 'notices') . '</label></p>' : '') . '%input% <span class="hints">' . sfContext::getInstance()->getI18N()->__('(opcional)') . '</span></div>'))));
     $this->widgetSchema->setNameFormat('propuesta[%s]');
     $this->widgetSchema->setLabels(array('titulo' => sfContext::getInstance()->getI18N()->__('Título', array(), 'notices'), 'descripcion' => sfContext::getInstance()->getI18N()->__('Descripción', array(), 'notices')));
     $this->setValidators(array('titulo' => new sfValidatorString(array("min_length" => SfVoUtil::VANITY_MIN_LENGTH, 'required' => true), sfVoForm::getStringMessages()), 'descripcion' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages()), 'vanity' => new sfValidatorString(array('required' => true)), 'sf_guard_user_id' => new sfValidatorInteger(array('required' => true)), 'imagen' => new sfValidatorFile(array('required' => false, 'max_size' => '512000', 'mime_types' => 'web_images', 'path' => sfConfig::get('sf_upload_dir') . '/propuestas', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages("500K")), 'doc' => new sfValidatorFile(array('required' => false, 'max_size' => '2048000', 'path' => sfConfig::get('sf_upload_dir') . '/docs', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages("2M"))));
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorPropelUnique(array('model' => 'Propuesta', 'column' => array('vanity')), sfVoForm::getUniqueMessages()), new sfValidatorPropelUnique(array('model' => 'Propuesta', 'column' => array('titulo')), sfVoForm::getUniqueMessages()))));
     // Vacíos
     $idx = 0;
     while ($idx < 5) {
         $idx++;
         // create a new enlace form for a new enlace model object
         $enlaceForm = new PropuestaEnlaceForm();
         // embed the enlace form in the main politico form
         $this->embedForm("enlace_n{$idx}", $enlaceForm);
         $this->widgetSchema["enlace_n{$idx}"]['orden'] = new sfWidgetFormInputHidden();
         // set a custom label for the embedded form
         $this->widgetSchema["enlace_n{$idx}"]->setLabel('Nuevo enlace');
     }
 }
示例#12
0
 public function addPostValidation()
 {
     $this->validatorSchema->setPostValidator(new sfGuardValidatorUser(array(), sfVoForm::getUserMessages()));
 }
示例#13
0
 public function configure()
 {
     $this->setWidgets(array('mensaje' => new sfWidgetFormTextarea(array())));
     $this->widgetSchema->setNameFormat('contact[%s]');
     $this->setValidators(array('mensaje' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages())));
 }
示例#14
0
 public function configure()
 {
     $this->setWidgets(array('q' => new sfWidgetFormInputText(array())));
     $this->widgetSchema->setNameFormat('search[%s]');
     $this->setValidators(array('q' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages())));
 }
示例#15
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();
     }
 }