Exemple #1
0
 public function save(PropelPDO $con = null, $value = null)
 {
     if ($this->getFileType() == 1) {
         if (!file_exists(sfConfig::get('upload_dir') . '/original')) {
             mkdir(sfConfig::get('upload_dir') . '/original', 0777);
         }
         move_uploaded_file($value['tmp_name'], sfConfig::get('upload_dir') . '/original/' . $this->getName());
         if ($value) {
             list($width, $height) = getimagesize(sfConfig::get('upload_dir') . '/original/' . $this->getName());
             foreach (sfConfig::get('images_format') as $format) {
                 @(list($new_width, $new_height) = explode('x', $format));
                 if ($width > $new_width) {
                     if (!file_exists(sfConfig::get('upload_dir') . '/' . $format)) {
                         mkdir(sfConfig::get('upload_dir') . '/' . $format, 0777);
                     }
                     if (isset($new_height)) {
                         $thumbnail = new sfThumbnail($new_width, $new_height, false, false, 75, 'sfImageMagickAdapter', array('method' => 'shave_all'));
                     } else {
                         $thumbnail = new sfThumbnail($new_width);
                     }
                     $thumbnail->loadFile(sfConfig::get('upload_dir') . '/original/' . $this->getName());
                     $thumbnail->save(sfConfig::get('upload_dir') . '/' . $format . '/' . $this->getName());
                 }
             }
         }
     } else {
         if (!file_exists(sfConfig::get('upload_dir') . '/doc')) {
             mkdir(sfConfig::get('upload_dir') . '/doc', 0777);
         }
         move_uploaded_file($value['tmp_name'], sfConfig::get('upload_dir') . '/doc/' . $this->getName());
     }
     parent::save();
 }
Exemple #2
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     ElementFilePeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new ElementFilePeer();
     }
     return self::$peer;
 }