Esempio n. 1
0
 protected function afterSave()
 {
     // Set new uploaded file
     if ($this->cUploadedFile !== null && $this->cUploadedFile instanceof CUploadedFile) {
         $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename();
         if (is_uploaded_file($this->cUploadedFile->getTempName())) {
             move_uploaded_file($this->cUploadedFile->getTempName(), $newFilename);
             @chmod($newFilename, 0744);
         }
         /**
          * For uploaded jpeg files convert them again - to handle special
          * exif attributes (e.g. orientation)
          */
         if ($this->cUploadedFile->getType() == 'image/jpeg') {
             ImageConverter::TransformToJpeg($newFilename, $newFilename);
         }
     }
     // Set file by given contents
     if ($this->newFileContent != null) {
         $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename();
         file_put_contents($newFilename, $this->newFileContent);
         @chmod($newFilename, 0744);
     }
     return parent::afterSave();
 }
Esempio n. 2
0
 /**
  * Sets a new profile image by given temp file
  *
  * @param CUploadedFile $file
  */
 public function setNew($file)
 {
     $this->delete();
     ImageConverter::TransformToJpeg($file->getTempName(), $this->getPath('_org'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 850, 'mode' => 'max'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
 }
Esempio n. 3
0
 /**
  * Sets a new profile image by given temp file
  *
  * @param mixed $file CUploadedFile or file path
  */
 public function setNew($file)
 {
     if ($file instanceof CUploadedFile) {
         $file = $file->getTempName();
     }
     $this->delete();
     ImageConverter::TransformToJpeg($file, $this->getPath('_org'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 400, 'mode' => 'max'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
 }