function admin_edit($id = null) { if(!empty($this->data)) { $file = $this->data['Winery']['logo']; $srcExt = substr($file['name'], -3, 3); if(is_uploaded_file($file["tmp_name"])) { $tmpDir = ROOT . DS . APP_DIR . DS . "tmp"; $imgDir = ROOT . DS . APP_DIR . DS . 'webroot' . DS . 'img' . DS . 'wineries' . DS; $srcTemp = $file['tmp_name']; list($srcWidth, $srcHeight) = getimagesize($srcTemp); if($srcWidth > 200) { $img = $this->ImageToolbox->makeToolbox(addslashes($srcTemp)); $img->setResizeMethod("resample"); $img->newOutputSize(200,0,1); $img->save($imgDir.$file['name']); } else { move_uploaded_file($file["tmp_name"], $imgDir.$file['name']); } $this->data['Winery']['logo_path'] = $file['name']; } /* $myAmenity = $this->data['Amenity']['Amenity']; unset($this->data['Amenity']['Amenity']); $this->data['Amenity'] = $myAmenity; $myVarietal = $this->data['Varietal']['Varietal']; unset($this->data['Varietal']['Varietal']); $this->data['Varietal'] = $myVarietal; */ unset($this->data['Winery']['logo']); $this->Winery->save($this->data); pr($this->data); die(); $this->Session->setFlash("Winery has been edited"); if($this->data['backTo'] == 1) { $this->redirect('/admin/wineries/edit/'.$this->data['Winery']['id']); } else { $this->redirect('/admin/wineries/'); } } else { $this->Winery->id = $id; $myData = $this->Winery->read(); $this->data = $myData; $this->set('myData', $myData); $operatingPolicy = array('Closed to the public'=>'Closed to the public', 'Open to the public'=>'Open to the public', 'Open by appointment only'=>'Open by appointment only', 'Open by appointment only and open to the public'=>'Open by appointment only and open to the public'); $this->set('operatingSelect', $operatingPolicy); $this->set('varietal', $this->Varietal->find('list')); $this->set('amenity', $this->Amenity->find('list')); } }