コード例 #1
0
ファイル: Restaurant.php プロジェクト: nightraiser/rdine
 public function uploadFirmDetails($form, $request, $baseurl)
 {
     try {
         $postData = $request->getPost();
         $restaurantModel = new Restaurant_Model_Restaurant();
         $restaurantModel->setOptions($postData);
         $restaurantMapper = new Restaurant_Model_RestaurantMapper();
         $locationMapper = new Application_Model_LocationboundariesMapper();
         $location_name = $locationMapper->getLocationName($restaurantModel->getReslocation_id());
         $resid = $restaurantMapper->saveRestaurantData($restaurantModel, $location_name);
         if (is_numeric($resid)) {
             $image_path = null;
             $logopath = null;
             $uploadpath = $_SERVER['DOCUMENT_ROOT'] . $baseurl . "/uploads/Restaurant_images/{$resid}/";
             if (!file_exists($uploadpath)) {
                 $dir = mkdir($uploadpath, 0777, true);
             }
             $uploadpath .= "resimages/";
             if (!file_exists($uploadpath)) {
                 $dir = mkdir($uploadpath, 0777, true);
             }
             $imageName = null;
             $imagepath = array();
             $imageAdapter = $form->res_image_button->getTransferAdapter();
             if (file_exists($uploadpath)) {
                 if ($imageAdapter && $resid) {
                     $i = -1;
                     foreach ($imageAdapter->getFileInfo() as $info) {
                         if ($i != -1) {
                             if ($info['name'] != null) {
                                 $namearr = explode(".", $info['name']);
                                 $ext = $namearr[sizeof($namearr) - 1];
                                 $fileName = 'image' . $i . '.' . $ext;
                                 foreach ($info as $filenames) {
                                     $imageAdapter->setFilters(array(new Zend_Filter_File_Rename(array('target' => $uploadpath . $fileName, $filenames, 'overwrite' => true))));
                                 }
                                 if ($imageAdapter->receive($info['name'])) {
                                     $image_path = $uploadpath . $fileName;
                                     $imagepath[] = $image_path;
                                 }
                                 $i++;
                             } else {
                                 $i++;
                                 $imagepath[] = "";
                             }
                         } else {
                             $i++;
                         }
                     }
                 }
             }
         }
         return $resid;
     } catch (Exception $ex) {
         Rdine_Logger_FileLogger::info($ex->getMessage());
         throw new Exception($ex->getMessage());
     }
 }