예제 #1
0
 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())));
 }
예제 #2
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');
     }
 }
예제 #3
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));
 }
예제 #4
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');
     }
 }
예제 #5
0
 public function configure()
 {
     $years = range(1920, date('Y'));
     $this->setWidgets(array('fecha_nacimiento' => new sfWidgetFormDate(array('format' => '%day%/%month%/%year%', 'years' => array_combine($years, $years))), 'vanity' => new sfWidgetFormInputText(array()), 'imagen' => new sfWidgetFormInputFileEditable(array('label' => sfContext::getInstance()->getI18N()->__('Imagen Principal', array(), 'notices'), 'file_src' => $this->getObject()->getProfile()->getImagen() ? '' . S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $this->getObject()->getProfile()->getImagen() : '', 'is_image' => false, 'edit_mode' => !$this->isNew(), 'template' => '<div>' . ($this->getObject()->getProfile()->getImagen() ? '<p><img src="%file%" alt="' . $this->getObject()->getProfile()->getNombre() . ' ' . $this->getObject()->getProfile()->getApellidos() . '" /> %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>')), 'username' => new sfWidgetFormInputText(array()), 'mails_comentarios' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'mails_noticias' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'mails_contacto' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'mails_seguidor' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'fb_publish_votos' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'fb_publish_votos_otros' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'fb_publish_cambios_perfil' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'tw_publish_votos' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'tw_publish_votos_otros' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'tw_publish_cambios_perfil' => new sfWidgetVoFormInputCheckbox(array('value_attribute_value' => '1')), 'nombre' => new sfWidgetFormInputText(array()), 'apellidos' => new sfWidgetFormInputText(array()), 'anonymous' => new sfWidgetFormInputCheckbox(array(), array()), 'presentacion' => new sfWidgetFormTextarea(array()), 'passwordNew' => new sfWidgetFormInputText(array('type' => 'password')), 'passwordBis' => new sfWidgetFormInputText(array('type' => 'password')), 'passwordOld' => new sfWidgetFormInputText(array('type' => 'password'))));
     $this->widgetSchema->setNameFormat('profile[%s]');
     $this->setValidators(array('fecha_nacimiento' => new sfValidatorDate(array('required' => false), sfVoForm::getDateMessages()), 'vanity' => new sfValidatorString(array("min_length" => SfVoUtil::VANITY_MIN_LENGTH, 'required' => true), sfVoForm::getStringMessages()), 'imagen' => new sfValidatorFile(array('required' => false, 'mime_types' => 'web_images', 'path' => sfConfig::get('sf_upload_dir') . '/usuarios', 'validated_file_class' => 'sfResizedFile'), sfVoForm::getImageMessages()), 'imagen_delete' => new sfValidatorString(array('required' => false)), 'username' => new sfValidatorEmail(array('required' => true), sfVoForm::getEmailMessages()), 'mails_comentarios' => new sfValidatorBoolean(), 'mails_noticias' => new sfValidatorBoolean(), 'mails_contacto' => new sfValidatorBoolean(), 'mails_seguidor' => new sfValidatorBoolean(), 'fb_publish_votos' => new sfValidatorBoolean(), 'fb_publish_votos_otros' => new sfValidatorBoolean(), 'fb_publish_cambios_perfil' => new sfValidatorBoolean(), 'tw_publish_votos' => new sfValidatorBoolean(), 'tw_publish_votos_otros' => new sfValidatorBoolean(), 'tw_publish_cambios_perfil' => new sfValidatorBoolean(), 'nombre' => new sfValidatorString(array('required' => true), sfVoForm::getStringMessages()), 'apellidos' => new sfValidatorString(array('required' => false)), 'anonymous' => new sfValidatorString(array('required' => false), sfVoForm::getStringMessages()), 'presentacion' => new sfValidatorStringCut(array("max_length" => 280, 'required' => false), sfVoForm::getStringMessages()), 'passwordNew' => new sfValidatorPassword(array('required' => false), sfVoForm::getStringMessages()), 'passwordBis' => new sfValidatorPassword(array('required' => false), sfVoForm::getStringMessages()), 'passwordOld' => new sfValidatorPasswordValid(array('required' => false), sfVoForm::getPasswordMessages())));
     $uniqValidator = new sfValidatorAnd(array(new sfValidatorPropelUniqueUpdater(array('model' => 'sfGuardUser', 'column' => array('username')), sfVoForm::getUniqueMessages()), new sfValidatorPropelUniqueUpdater(array('model' => 'sfGuardUserProfile', 'column' => array('vanity')), sfVoForm::getUniqueMessages())));
     $postValidator = new sfValidatorAnd(array(new sfValidatorAnd(array($uniqValidator, new sfValidatorSchemaCompare('passwordNew', sfValidatorSchemaCompare::EQUAL, 'passwordBis', array(), sfVoForm::getCompareMessages()))), new sfValidatorRequiredIfField('passwordOld', 'passwordNew', array(), sfVoForm::getRequiredMessages())));
     $this->validatorSchema->setPostValidator($postValidator);
     if (!$this->isNew()) {
         // embed all enlace forms
         $idx = 0;
         foreach ($this->getObject()->getEnlaces() as $enlace) {
             $idx++;
             // create a new enlace form for the current enlace model object
             $enlaceForm = new UsuarioEnlaceForm($enlace);
             // embed the enlace form in the main politico form
             $this->embedForm("enlace_n{$idx}", $enlaceForm);
             // set a custom label for the embedded form
             $this->widgetSchema["enlace_n{$idx}"]->setLabel('Enlace ' . $enlace->getId());
             // change the name widget to sfWidgetFormInputDelete
             $this->widgetSchema["enlace_n{$idx}"]['url'] = new sfWidgetFormInputText(array());
             $this->widgetSchema["enlace_n{$idx}"]['orden'] = new sfWidgetFormInputHidden();
         }
         // Vacíos
         while ($idx < 5) {
             $idx++;
             // create a new enlace form for a new enlace model object
             $enlaceForm = new UsuarioEnlaceForm();
             // 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');
         }
     }
 }