public function save($con = null)
 {
     if (!file_exists(sfConfig::get('sf_upload_dir') . '/sfCart/products/')) {
         mkdir(sfConfig::get('sf_upload_dir') . '/sfCart/products/');
     }
     $return = parent::save($con);
     $fullpath = $this->getValue('photo_path');
     $genFileName = basename($fullpath);
     $thumbpath1 = sfConfig::get('sf_upload_dir') . '/sfCart/products/48x48/' . $genFileName;
     $thumbpath2 = sfConfig::get('sf_upload_dir') . '/sfCart/products/172x129/' . $genFileName;
     $thumbpath3 = sfConfig::get('sf_upload_dir') . '/sfCart/products/300x200/' . $genFileName;
     if (!file_exists(sfConfig::get('sf_upload_dir') . '/sfCart/products/48x48/')) {
         mkdir(sfConfig::get('sf_upload_dir') . '/sfCart/products/48x48/');
     }
     if (!file_exists(sfConfig::get('sf_upload_dir') . '/sfCart/products/172x129/')) {
         mkdir(sfConfig::get('sf_upload_dir') . '/sfCart/products/172x129/');
     }
     if (!file_exists(sfConfig::get('sf_upload_dir') . '/sfCart/products/300x200/')) {
         mkdir(sfConfig::get('sf_upload_dir') . '/sfCart/products/300x200/');
     }
     //not handling if file already exists
     if (file_exists($fullpath)) {
         $thumbnail = new Thumb(48, 48);
         $thumbnail->loadFile($fullpath);
         $thumbnail->cropImage(48, 48, $fullpath, $thumbpath1);
         $thumbnail = new Thumb(172, 129);
         $thumbnail->loadFile($fullpath);
         $thumbnail->cropImage(172, 129, $fullpath, $thumbpath2);
         $thumbnail = new Thumb(300, 200);
         $thumbnail->loadFile($fullpath);
         $thumbnail->cropImage(300, 200, $fullpath, $thumbpath3);
     }
     return $return;
 }
Exemple #2
0
 public function configure()
 {
     parent::configure();
 }
Exemple #3
0
 public function updateObject($values = null)
 {
     $object = parent::updateObject($values);
     if ($this->getValue('brand_picture')) {
         $object->setBrandPicture('/product/' . $object->getBrandPicture());
     }
     return $object;
 }
 /**
  * call our saveImagesToAlbum method while saving form
  */
 protected function doSave($con = null)
 {
     parent::doSave($con);
     $this->saveImagesToProduct();
     //ImagesPeer::cleanImagesWithoutConnections();
 }