Exemplo n.º 1
0
 public function test_constructor()
 {
     $upload = new Upload_File('default', 'file', 'filename1.txt');
     $this->assertInstanceOf('Flex\\Storage\\Server', $upload->server());
     $this->assertEquals('file', $upload->path());
     $this->assertEquals('filename1.txt', $upload->filename());
 }
Exemplo n.º 2
0
 /**
  * Process elements value from request
  *
  * @return
  */
 public function result()
 {
     $cogear = getInstance();
     $file = new Upload_File($this->name, $this->getAttributes(), $this->validators->findByValue('Required'));
     if ($value = $file->upload()) {
         $this->is_fetched = TRUE;
         $this->value = $value;
     } else {
         $this->errors = $file->errors;
     }
     return $this->value;
 }
Exemplo n.º 3
0
 /**
  * (non-PHPdoc)
  * @see Upload_File::upload()
  */
 public function upload(array $data, $path, $formUpload = true)
 {
     $data = parent::upload($data, $path, $formUpload);
     if (!empty($data) && !empty($this->_config['sizes'])) {
         foreach ($this->_config['sizes'] as $name => $xy) {
             $ext = File::getExt($data['path']);
             $replace = '-' . $name . $ext;
             $newName = str_replace($ext, $replace, $data['path']);
             if ($this->_config['thumb_types'][$name] == 'crop') {
                 Image_Resize::resize($data['path'], $xy[0], $xy[1], $newName, true, true);
             } else {
                 Image_Resize::resize($data['path'], $xy[0], $xy[1], $newName, true, false);
             }
             if ($name == 'icon') {
                 $data['thumb'] = $newName;
             }
         }
     }
     return $data;
 }
Exemplo n.º 4
0
 /**
  * Get upload file object for a given model
  *
  * @param  Jam_Model $model
  * @return Upload_File
  */
 public function upload_file(Jam_Model $model)
 {
     $upload_file = new Upload_File($this->server, $this->path($model));
     if ($this->transformations) {
         $upload_file->transformations($this->transformations);
     }
     if ($this->thumbnails) {
         $upload_file->thumbnails($this->thumbnails);
     }
     return $upload_file;
 }
Exemplo n.º 5
0
 /**
  * Process upload
  *
  * @return boolean|string
  */
 protected function processUpload()
 {
     $this->getInfo($this->file->tmp_name);
     if ($this->options->max && !$this->checkMax($this->options->max->width, $this->options->max->height) or $this->options->min && !$this->checkMin($this->options->max->width, $this->options->max->height)) {
         return FALSE;
     }
     return parent::processUpload();
 }