예제 #1
0
파일: Lab.php 프로젝트: eellak/gredu_labs
 public function __construct($uploadTmpPath, LabServiceInterface $labService, $attachmentSize)
 {
     $id = new Input('id');
     $id->setRequired(false)->getValidatorChain()->attach(new Validator\Digits());
     $name = new Input('name');
     $name->setRequired(true)->getFilterChain()->attach(new Filter\StringTrim());
     $name->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\StringLength(['min' => 3]));
     $labTypeId = new Input('labtype_id');
     $labTypeId->setRequired(true);
     $labTypeId->getValidatorChain()->attach(new Validator\NotEmpty());
     $isNew = new Input('is_new');
     $isNew->setRequired(false)->getFilterChain()->attach(new Filter\ToInt());
     $responsibleId = new Input('responsible_id');
     $responsibleId->setRequired(false)->getValidatorChain()->attach(new Validator\Digits());
     $area = new Input('area');
     $area->setRequired(true)->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Digits());
     $lessons = new Input('lessons');
     $lessons->setRequired(false);
     $lessons->getValidatorChain()->attach(new Validator\NotEmpty());
     $attachment = new FileInput('attachment');
     $attachment->setRequired(false)->getFilterChain()->attach(new Filter\File\RenameUpload(['target' => $uploadTmpPath, 'randomize' => true]));
     $attachment->getValidatorChain()->attach(new Validator\File\UploadFile())->attach(new Validator\File\MimeType(['application/zip', 'application/x-rar-compressed', 'application/octet-stream', 'application/pdf', 'image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff', 'image/svg+xml', 'image/svg+xml', 'image/vnd.adobe.photoshop']))->attach(new Validator\File\Size(['max' => $attachmentSize]));
     $use_ext_program = new Input('use_ext_program');
     $use_ext_program->setRequired(false);
     $use_in_program = new Input('use_in_program');
     $use_in_program->setRequired(false);
     $has_network = new Input('has_network');
     $has_network->setRequired(false);
     $has_network->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\InArray(['haystack' => $labService->getHasNetworkValues()]));
     $has_server = new Input('has_server');
     $has_server->setRequired(false);
     $has_server->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\InArray(['haystack' => $labService->getHasServerValues()]));
     $this->inputFilter = new InputFilter();
     $this->inputFilter->add($id)->add($name)->add($labTypeId)->add($isNew)->add($responsibleId)->add($area)->add($lessons)->add($attachment)->add($use_in_program)->add($use_ext_program)->add($has_server)->add($has_network);
 }
예제 #2
0
 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $title = sprintf("%.0f ", microtime(true) * 20000);
     $title = str_replace(' ', '', $title);
     //$title=(float) microtime(true)*20000;
     $fileInput = new InputFilter\FileInput('seriecode');
     $fileInput->setRequired(true);
     // You only need to define validators and filters
     // as if only one file was being uploaded. All files
     // will be run through the same validators and filters
     // automatically.
     $fileInput->getValidatorChain()->attachByName('filesize', array('max' => 500000000))->attachByName('filemimetype', array('mimeType' => 'video/mp4'));
     // All files will be renamed, i.e.:
     //   ./data/tmpuploads/avatar_4b3403665fea6.png,
     //   ./data/tmpuploads/avatar_5c45147660fb7.png
     $name = md5(date('ymd'));
     if (!file_exists('temp/data/tmpuploads/videos/' . $name)) {
         mkdir('temp/data/tmpuploads/videos/' . $name, 0777, true);
     }
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => './temp/data/tmpuploads/videos/' . $name . '/', 'randomize' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
예제 #3
0
 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     //$title=microtime(true)*20000;
     $fileInput = new InputFilter\FileInput('imagefile');
     $fileInput->setRequired(true);
     // You only need to define validators and filters
     // as if only one file was being uploaded. All files
     // will be run through the same validators and filters
     // automatically.
     //$validator = new \Zend\Validator\File\MimeType('image/gif,image/jpg,image/png');
     $fileInput->getValidatorChain()->attachByName('filesize', array('max' => 5480000))->attachByName('filemimetype', array('mimeType' => 'image/png'));
     // All files will be renamed, i.e.:
     //   ./data/tmpuploads/avatar_4b3403665fea6.png,
     //   ./data/tmpuploads/avatar_5c45147660fb7.png
     /* $fileInput->getFilterChain()->attachByName(
            'filerenameupload',
            array(
                'target'    => './data/tmpuploads/123/',
                'randomize' => true,
            )
        );*/
     $name = 1;
     if (!file_exists('eclip.tv/data/uploads/user/' . $name)) {
         mkdir('eclip.tv/data/uploads/user/' . $name, 0777, true);
     }
     $fileInput->getFilterChain()->attach(new \Zend\Filter\File\Rename("eclip.tv/data/uploads/user/" . $name . '/' . $title . ".png"));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
예제 #4
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $nombre = new Input('nome');
     $nombre->setRequired(true);
     $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($nombre);
     $password = new Input('password');
     $password->setRequired(true);
     $password->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($password);
     $confirmarPassword = new Input('confirmarPassword');
     $confirmarPassword->setRequired(true);
     $confirmarPassword->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum))->addValidator(new Identical(array('token' => 'password', 'messages' => array('notSame' => 'I dati sono errati, riprova.'))));
     $this->add($confirmarPassword);
     $imagen = new FileInput('immagine');
     $imagen->setRequired(false);
     $imagen->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/utenti/utenti_', 'use_upload_extension' => true, 'randomize' => true)));
     $imagen->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
     /*
      $imagen->getValidatorChain()->attach(new MimeType(array(
      'mimeType' => 'image/png,image/x-png,image/gif,image/jpeg,image/pjpeg', 'enableHeaderCheck' => true
      )));
     */
     $this->add($imagen);
 }
예제 #5
0
 public function __construct()
 {
     $logo = new FileInput('logo');
     $logo->setRequired(false)->setAllowEmpty(false);
     $logo->getValidatorChain()->attach(new Size(array('messageTemplates' => array(Size::TOO_BIG => 'The file TOO_BIG', Size::TOO_SMALL => 'The file TOO_SMALL', Size::NOT_FOUND => 'The NOT_FOUND', NotEmpty::IS_EMPTY => 'Mail no debe ser vacía.'), 'options' => array('max' => 40000))));
     // Validator File Type //
     $mimeType = new MimeType();
     $mimeType->setMimeType(array('image/gif', 'image/jpg', 'image/jpeg', 'image/png'));
     $logo->getValidatorChain()->attach($mimeType);
     /** Move File to Uploads/product **/
     $nameFile = sprintf("%simg_%s", './public/assets/images/providers/', time());
     $rename = new RenameUpload($nameFile);
     //$rename->setTarget($nameFile);
     $rename->setUseUploadExtension(true);
     //$rename->setUseUploadName(true);
     $rename->setRandomize(true);
     $rename->setOverwrite(true);
     $logo->getFilterChain()->attach($rename);
     $this->add($logo);
     $this->add(array('name' => 'company', 'required' => true, 'validators' => array(array('name' => 'Alnum', 'options' => $this->opcionesAlnum)), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     $this->add(array('name' => 'company_id', 'required' => true, 'validators' => array(array('name' => 'Alnum', 'options' => $this->opcionesAlnum)), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     $this->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'EmailAddress', 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Email address format is not invalid'))), array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Email address is required'))))));
     $this->add(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Password is required'))))));
     $this->add(array('name' => 'confirmarPassword', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'identical', 'options' => array('token' => 'password')))));
 }
예제 #6
0
 /**
  * Class constructor.
  */
 public function __construct()
 {
     $this->add(['name' => 'item', 'required' => false, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => 'StringLength', 'options' => ['encoding' => 'UTF-8', 'min' => 5, 'max' => 15]]]]);
     $fileUpload = new FileInput('file');
     $fileUpload->setRequired(true);
     $fileUpload->getValidatorChain()->attachByName('File\\Size', ['min' => '20kB', 'max' => '8MB']);
     $this->add($fileUpload);
 }
예제 #7
0
 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     $fileInput = new InputFilter\FileInput('image-file');
     $fileInput->setRequired(true);
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => __DIR__ . '/../../../public/tmpuploads', 'randomize' => false, 'use_upload_name' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
 public function createInputFilter($options)
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(true);
     $file->getFilterChain()->attachByName('filerenameupload', array('target' => $options['galleryDir'], 'overwrite' => true, 'use_upload_name' => true));
     $inputFilter->add($file);
     return $inputFilter;
 }
예제 #9
0
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(false);
     $file->getFilterChain()->attachByName('filerenameupload', array('target' => './public/files/', 'overwrite' => false, 'use_upload_name' => false, 'randomize' => true));
     $inputFilter->add($file);
     return $inputFilter;
 }
예제 #10
0
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(true);
     $file->getFilterChain()->attachByName('filerenameupload', array('target' => '/ginosi/data/tmpuploads/', 'overwrite' => true, 'use_upload_name' => true));
     $inputFilter->add($file);
     return $inputFilter;
 }
예제 #11
0
 public function setupInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $fileInput = new InputFilter\FileInput('url');
     $fileInput->setRequired(true);
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => getcwd() . '/public/data/docs/file', 'randomize' => true, 'use_upload_extension' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(true);
     $file->getFilterChain()->attachByName('filerenameupload', array('target' => './data/tmpuploads/file', 'randomize' => true));
     $inputFilter->add($file);
     return $inputFilter;
 }
예제 #13
0
 /**
  * Adding a RenameUpload filter to our form’s file input, with details on where the valid files should be stored
  */
 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $fileInput = new InputFilter\FileInput('image-file');
     $fileInput->setRequired(true);
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => $this->_dir, 'randomize' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
예제 #14
0
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(true);
     $file->getFilterChain()->attachByName('filerenameupload', ['target' => DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_TEMP_PATH, 'overwrite' => true, 'randomize' => true, 'use_upload_name' => true]);
     // Allowed extensions
     $file->getValidatorChain()->attachByName('fileextension', ['png', 'jpg', 'gif']);
     $inputFilter->add($file);
     return $inputFilter;
 }
예제 #15
0
파일: TaskUpload.php 프로젝트: arbi/MyCode
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(true);
     $file->getFilterChain()->attachByName('filerenameupload', ['target' => DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_TMP . 'attachment', 'overwrite' => true, 'randomize' => true, 'use_upload_name' => true]);
     // Allowed extensions
     $file->getValidatorChain()->attachByName('fileextension', ['doc', 'docx', 'xls', 'xlsx', 'pdf', 'csv', 'png', 'jpg', 'gif', 'ods', 'odt', 'ott', 'txt', 'zip', 'rar', '7z', 'tar']);
     $inputFilter->add($file);
     return $inputFilter;
 }
 public function __construct()
 {
     // Validações do titulo
     $titulo = new Input('titulo');
     $titulo->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
     $titulo->getValidatorChain()->attach(new NotEmpty());
     // Validação do campo midia
     $file = new FileInput('midia');
     $file->setRequired(false);
     $file->getFilterChain()->attach(new RenameUpload(array("target" => \Base\Constant\Src::UPLOAD_PATH . \Base\Constant\Src::LIVRE_PARA_CRIAR, "randomize" => false, "overwrite" => true, "use_upload_name" => true)));
     $file->getValidatorChain()->attach(new Size(\Base\Constant\Upload::LIVRE_PARA_CRIAR_SIZE))->attach(new ImageSize(array('minWidth' => \Base\Constant\Upload::LIVRE_PARA_CRIAR_WIDTH, 'minHeight' => \Base\Constant\Upload::LIVRE_PARA_CRIAR_HEIGTH, 'maxWidth' => \Base\Constant\Upload::LIVRE_PARA_CRIAR_WIDTH, 'maxHeight' => \Base\Constant\Upload::LIVRE_PARA_CRIAR_HEIGTH)))->attach(new MimeType(array('image/gif', 'image/jpeg', 'image/png', 'image/x-png', 'enableHeaderCheck' => true)));
     //** Adicionando filtros **//
     $this->add($titulo)->add($file);
 }
예제 #17
0
파일: EventForm.php 프로젝트: hopealive/ds
 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     $eventFolder = '/public/uploads/events/' . date('Y-m-d');
     if (!file_exists(getcwd() . $eventFolder)) {
         mkdir(getcwd() . $eventFolder, 0777, TRUE);
     }
     // File Input
     $fileInput = new InputFilter\FileInput('thumb');
     $fileInput->setRequired(false);
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => '.' . $eventFolder . '/event.jpg', 'randomize' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
 public function getInputFilter($contractId = 0, $code = "")
 {
     if (!$this->inputFilter) {
         $filter = new InputFilter();
         $filter->add(array('name' => 'contractId', 'required' => true, 'filters' => array(array('name' => 'Int'))));
         $filter->add(array('name' => 'contactID', 'required' => false, 'filters' => array(array('name' => 'Int'))));
         $filter->add(array('name' => 'code', 'required' => true, 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 50, 'min' => 1, 'encoding' => 'UTF-8')))));
         $filter->add(array('name' => 'notes', 'required' => true, 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 500, 'min' => 1, 'encoding' => 'UTF-8')))));
         $fileInput = new FileInput('contractFile');
         $fileInput->setRequired(false);
         $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => sprintf('./data/uploads/contract/%s', $code), 'use_upload_extension' => true, 'overwrite' => true));
         $filter->add($fileInput);
         $this->InputFilter = $filter;
     }
     return $this->InputFilter;
 }
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $file = new InputFilter\FileInput('file');
     $file->setRequired(true);
     $file->getFilterChain()->attachByName('filerenameupload', array('target' => './data/tmpuploads/', 'overwrite' => true, 'use_upload_name' => true));
     //$file->getValidatorChain()->addByName(
     //    'fileextension', array('extension' => 'txt')
     //);
     $inputFilter->add($file);
     // Text Input
     $text = new InputFilter\Input('text');
     $text->setRequired(true);
     $inputFilter->add($text);
     return $inputFilter;
 }
 public function createInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Collection
     $fileCollection = new InputFilter\InputFilter();
     for ($i = 0; $i < $this->numFileElements; $i++) {
         $file = new InputFilter\FileInput($i);
         $file->setRequired(true);
         $file->getFilterChain()->attachByName('filerenameupload', array('target' => './data/tmpuploads/', 'overwrite' => true, 'use_upload_name' => true));
         $fileCollection->add($file);
     }
     $inputFilter->add($fileCollection, 'file-collection');
     // Text Input
     $text = new InputFilter\Input('text');
     $text->setRequired(true);
     $inputFilter->add($text);
     return $inputFilter;
 }
예제 #21
0
 public function getInputFilter($userId = 0, $userName = "")
 {
     if (!$this->inputFilter) {
         $filter = new InputFilter();
         $filter->add(array('name' => 'userId', 'required' => true, 'filters' => array(array('name' => 'Int'))));
         $filter->add(array('name' => 'userName', 'required' => true, 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 200, 'min' => 1, 'encoding' => 'UTF-8')), array('name' => 'Db\\NoRecordExists', 'options' => array('table' => 'tbl_user', 'field' => 'userName', 'adapter' => $this->dbAdapter, 'exclude' => array('field' => 'userId', 'value' => $userId), 'message' => 'This user name is already exist.')))));
         $filter->add(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('min' => 4, 'max' => 50)))));
         $filter->add(array('name' => 'confirmPassword', 'required' => true, 'validators' => array(array('name' => 'Identical', 'options' => array('token' => 'password')))));
         $fileInput = new FileInput('image');
         $fileInput->setRequired(false);
         $fileInput->getValidatorChain()->attachByName('filesize', array('max' => 204800))->attachByName('fileimagesize', array('maxWidth' => 256, 'maxHeight' => 256))->attach(new IsImage());
         //->attachByName('filemimetype', array('mimetype' => ''))
         $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => sprintf('./data/uploads/avatar/%s', $userName), 'use_upload_extension' => true, 'overwrite' => true));
         $filter->add($fileInput);
         $this->inputFilter = $filter;
     }
     return $this->inputFilter;
 }
 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $fileInput = new InputFilter\FileInput('image-file');
     $fileInput->setRequired(true);
     // You only need to define validators and filters
     // as if only one file was being uploaded. All files
     // will be run through the same validators and filters
     // automatically.
     $fileInput->getValidatorChain()->attachByName('filesize', array('max' => 204800))->attachByName('filemimetype', array('mimeType' => 'image/png,image/x-png'))->attachByName('fileimagesize', array('maxWidth' => 100, 'maxHeight' => 100));
     // All files will be renamed, i.e.:
     //   ./data/tmpuploads/avatar_4b3403665fea6.png,
     //   ./data/tmpuploads/avatar_5c45147660fb7.png
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => './data/tmpuploads/avatar.png', 'randomize' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
예제 #23
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Contenuti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $titolo = new Input('titolo');
     $titolo->setRequired(true);
     $titolo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $titolo->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($titolo);
     $this->add(array('name' => 'posterlab', 'required' => true, 'validators' => array(array('name' => 'Int'))));
     $this->add(array('name' => 'tipo', 'required' => true, 'validators' => array(array('name' => 'Int'))));
     $background = new FileInput('background');
     $background->setRequired(true);
     $background->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/contenuto/contenuto_', 'use_upload_extension' => true, 'randomize' => true)));
     $background->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
     $this->add($background);
 }
예제 #24
0
 public function addInputFilter($user = null)
 {
     $inputFilter = new InputFilter\InputFilter();
     $factory = new InputFactory();
     $inputFilter->add($factory->createInput(array('name' => 'fileUpload', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\File\\Extension', 'break_chain_on_failure' => true, 'options' => $this->getAllowedExts(), 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'File upload phải là file png,jpeg,jpg,gif'))))));
     // File Path
     $uri = new \Home\Service\Uri();
     $targetFolder = $uri->getSavePath($user);
     if (!file_exists($targetFolder)) {
         $oldmask = umask(0);
         mkdir($targetFolder, 0777, true);
         umask($oldmask);
     }
     $fileInput = new InputFilter\FileInput('fileUpload');
     $fileInput->setRequired(true);
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => $targetFolder, 'use_upload_name' => true, 'overwrite' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
예제 #25
0
 public function __construct()
 {
     // echo sprintf("%s/data/uploads/attachment.%s.txt", __DIR__ . '/../../../../..', time());die;
     $productImage = new FileInput('productImage');
     $productImage->setRequired(true)->setAllowEmpty(false);
     $productImage->getValidatorChain()->attach(new Size(array('messageTemplates' => array(Size::TOO_BIG => 'The file TOO_BIG', Size::TOO_SMALL => 'The file TOO_SMALL', Size::NOT_FOUND => 'The NOT_FOUND'), 'options' => array('max' => 40000))));
     // Validator File Type //
     $mimeType = new MimeType();
     $mimeType->setMimeType(array('image/gif', 'image/jpg', 'image/jpeg', 'image/png'));
     $productImage->getValidatorChain()->attach($mimeType);
     /** Move File to Uploads/product **/
     $nameFile = sprintf("%simg_%s", './public/assets/images/products/catalog/', time());
     $rename = new RenameUpload($nameFile);
     //$rename->setTarget($nameFile);
     $rename->setUseUploadExtension(true);
     //$rename->setUseUploadName(true);
     $rename->setRandomize(true);
     $rename->setOverwrite(true);
     $productImage->getFilterChain()->attach($rename);
     $this->add($productImage);
 }
예제 #26
0
 public function __construct()
 {
     // echo sprintf("%s/data/uploads/attachment.%s.txt", __DIR__ . '/../../../../..', time());die;
     $productImage = new FileInput('productImage');
     $productImage->setRequired(false)->setAllowEmpty(false);
     $productImage->getValidatorChain()->attach(new Size(array('messageTemplates' => array(Size::TOO_BIG => 'The file TOO_BIG', Size::TOO_SMALL => 'The file TOO_SMALL', Size::NOT_FOUND => 'The NOT_FOUND', NotEmpty::IS_EMPTY => 'Mail no debe ser vacía.'), 'options' => array('max' => 40000))));
     // Validator File Type //
     $mimeType = new MimeType();
     $mimeType->setMimeType(array('image/gif', 'image/jpg', 'image/jpeg', 'image/png'));
     $productImage->getValidatorChain()->attach($mimeType);
     /** Move File to Uploads/product **/
     $nameFile = sprintf("%simg_%s", './public/assets/images/products/catalog/', time());
     $rename = new RenameUpload($nameFile);
     //$rename->setTarget($nameFile);
     $rename->setUseUploadExtension(true);
     //$rename->setUseUploadName(true);
     $rename->setRandomize(true);
     $rename->setOverwrite(true);
     $productImage->getFilterChain()->attach($rename);
     $this->add($productImage);
     $this->add(array('name' => 'productName', 'required' => true, 'validators' => array(array('name' => 'Alnum', 'options' => $this->opcionesAlnum)), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     $this->add(array('name' => 'productDescription', 'required' => true, 'validators' => array(array('name' => 'not_empty')), 'filters' => $this->filterGeneric));
     $this->add(array('name' => 'productModel', 'required' => true, 'validators' => array(array('name' => 'Alnum', 'options' => $this->opcionesAlnum2))));
     $this->add(array('name' => 'productPrice', 'required' => true, 'validators' => array(array('name' => 'float', 'options' => array('locale' => 'en_US')), array('name' => 'stringLength', 'options' => array('min' => 1, 'max' => 10))), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     //         $productQuantity = new Input('productQuantity');
     //         $productQuantity->setAllowEmpty(true);
     //         $productQuantity->getValidatorChain()
     //             ->attach(new Digits());
     //         $this->add($productQuantity);
     $this->add(array('name' => 'productMinimun', 'required' => false, 'validators' => array(array('name' => 'Digits'))));
     // Meta-Data Form
     $this->add(array('name' => 'productMetaTittle', 'required' => true, 'validators' => array(array('name' => 'Alnum', 'options' => $this->opcionesAlnum)), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     $this->add(array('name' => 'productSeoUrl', 'required' => true, 'validators' => array(array('name' => 'not_empty')), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'), array('name' => 'StringToLower'))));
     $this->add(array('name' => 'productMetaDescription', 'continue_if_empty' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     $this->add(array('name' => 'productMetaKeywords', 'continue_if_empty' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
 }
예제 #27
0
 /**
  * @return \Zend\InputFilter\InputFilter|\Zend\InputFilter\InputFilterInterface
  */
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         $inputFilter->add($factory->createInput(['name' => 'document', 'required' => false, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => 'StringLength', 'options' => ['encoding' => 'UTF-8', 'min' => 5, 'max' => 100]]]]));
         $inputFilter->add($factory->createInput(['name' => 'workpackage', 'required' => true]));
         $inputFilter->add($factory->createInput(['name' => 'contact', 'required' => false]));
         $inputFilter->add($factory->createInput(['name' => 'public', 'required' => true]));
         $inputFilter->add($factory->createInput(['name' => 'projectCalendar', 'required' => false]));
         $fileUpload = new FileInput('file');
         $fileUpload->setRequired(true);
         $fileUpload->getValidatorChain()->attachByName('File\\Size', ['min' => '20kB', 'max' => '64MB']);
         $inputFilter->add($fileUpload);
         $this->inputFilter = $inputFilter;
     }
     return $this->inputFilter;
 }
예제 #28
0
 /**
  * @return \Zend\InputFilter\InputFilter|\Zend\InputFilter\InputFilterInterface
  */
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         $inputFilter->add($factory->createInput(['name' => 'document', 'required' => false, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => 'StringLength', 'options' => ['encoding' => 'UTF-8', 'min' => 5, 'max' => 100]]]]));
         $inputFilter->add($factory->createInput(['name' => 'type', 'required' => true]));
         /*
          * Contact is not strictly needed in the form element as they will be added later
          */
         $inputFilter->add($factory->createInput(['name' => 'contact', 'required' => false]));
         /*
          * Project is not strictly needed in the form element as they will be added later
          */
         $inputFilter->add($factory->createInput(['name' => 'project', 'required' => false]));
         $fileUpload = new FileInput('file');
         $fileUpload->setRequired(true);
         $fileUpload->getValidatorChain()->attachByName('File\\Size', ['min' => '20kB', 'max' => '64MB']);
         $inputFilter->add($fileUpload);
         $this->inputFilter = $inputFilter;
     }
     return $this->inputFilter;
 }
 public function getInputFilter($proposalId = 0, $code = "")
 {
     if (!$this->inputFilter) {
         $filter = new InputFilter();
         $filter->add(array('name' => 'proposalId', 'required' => true, 'filters' => array(array('name' => 'Int'))));
         $filter->add(array('name' => 'code', 'required' => true, 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 50, 'min' => 1, 'encoding' => 'UTF-8')), array('name' => 'Db\\NoRecordExists', 'options' => array('table' => 'tbl_cr_proposal', 'field' => 'code', 'adapter' => $this->dbAdapter, 'exclude' => array('field' => 'proposalId', 'value' => $proposalId), 'message' => 'This proposal code is already exists.')))));
         $filter->add(array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255, 'min' => 1, 'encoding' => 'UTF-8')))));
         $filter->add(array('name' => 'amount', 'required' => true));
         $filter->add(array('name' => 'proposalDate', 'required' => true));
         $filter->add(array('name' => 'notes', 'required' => false));
         $filter->add(array('name' => 'group_code', 'required' => false));
         $fileInput = new FileInput('proposalFile');
         $fileInput->setRequired(false);
         $fileInput->getValidatorChain()->attach(new Extension(array('doc', 'docx', 'pdf')))->attachByName('filesize', array('max' => '50MB'));
         $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => sprintf('./data/uploads/proposal/%s', $code), 'use_upload_extension' => true, 'overwrite' => true));
         $filter->add($fileInput);
         $this->inputFilter = $filter;
     }
     return $this->inputFilter;
 }
예제 #30
0
파일: Doa.php 프로젝트: debranova/program
 /**
  * @return \Zend\InputFilter\InputFilter|\Zend\InputFilter\InputFilterInterface
  */
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         $inputFilter->add($factory->createInput(['name' => 'dateApproved', 'required' => false]));
         $inputFilter->add($factory->createInput(['name' => 'dateSigned', 'required' => false]));
         $inputFilter->add($factory->createInput(['name' => 'branch', 'required' => false]));
         $inputFilter->add($factory->createInput(['name' => 'contact', 'required' => false]));
         $inputFilter->add($factory->createInput(['name' => 'organisation', 'required' => false]));
         $inputFilter->add($factory->createInput(['name' => 'program', 'required' => false]));
         $fileUpload = new FileInput('file');
         $fileUpload->setRequired(true);
         $fileUpload->getValidatorChain()->attachByName('File\\Size', ['min' => '20kB', 'max' => '8MB']);
         $inputFilter->add($fileUpload);
         $this->inputFilter = $inputFilter;
     }
     return $this->inputFilter;
 }