Esempio n. 1
0
 /**
  * <Jason>
  * <Email: pmhai90@gmail.com>
  */
 public static function resizeCover($model)
 {
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = '/upload/admin/' . self::$folderUpload . '/' . $model->id;
     $ImageProcessing->file = $model->cover;
     $ImageProcessing->thumbs = Memodule::$aSizeCover;
     $ImageProcessing->create_thumbs();
 }
Esempio n. 2
0
  * <Jason>
  * HaiPM - 20130723
  */
 public function validateLink($attribute, $params)
 {
     if (trim($this->link) != '') {
         $label = $this->getAttributeLabel('link');
         $tempUrl = strtolower($this->link);
         if (strpos($tempUrl, 'http://') !== false || strpos($tempUrl, 'https://') !== false) {
             $a = 1;
         } else {
             $this->addError("link", "{$label} must have http:// OR https://");
         }
     }
 }
 public function getBannerByType($type)
 {
     $model = Banners::model()->find('status=1 AND banner_type="' . (int) $type . '" ORDER BY `order`');
     return $model;
 }
 public function activate()
 {
     $this->status = 1;
Esempio n. 3
0
 /**
  * @Author: ANH DUNG Jan 16, 2015
  * @Todo: re resize some small photo not have water mark
  * @Param: $model model ProListingPhotos
  */
 public static function ResizePhotoListingSmall($model)
 {
     //        ProListingPhotos::RemovePhotoListingSmall($model);
     //        sleep(1);
     self::RootImageClone($model);
     $NewNameImage = self::CopyImageHaveWaterMarkToRoot($model);
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = "/" . ProListingPhotos::$folderUpload . "/{$model->listing_id}";
     //        $ImageProcessing->file = ProListingPhotos::SIZE_WATER_MARK."/".$model->image;
     $ImageProcessing->file = $model->image;
     $ImageProcessing->thumbs = ProListingPhotos::GetSmallSizeToProcessWaterMark();
     $ImageProcessing->create_thumbs();
     self::RootImageRestore($model);
     self::DeleteTempImageClone($model);
 }
Esempio n. 4
0
 public function actionAjax_upload_photo_by_ku_toan($id)
 {
     echo '<pre>';
     print_r($_FILES);
     echo '</pre>';
     die;
     $model = $this->loadModel($id);
     if ($model) {
         $totalImgupload = ProListingPhotos::model()->countByAttributes(array('listing_id' => $id));
         if (!ProListingPhotos::checkLimitFileUpload($id)) {
             $result['errorMesage'] = 'Limit ' . LIMIT_PHOTO_UPLOAD . ' photos upload';
             die(json_encode($result));
         }
         //upload file ajax
         Yii::import("ext.EAjaxUpload.qqFileUploader");
         $ImageProcessing = new ImageProcessing();
         $ImageProcessing->createSingleDirectoryByPath("/upload/listing/{$id}");
         $ImageProcessing->createSingleDirectoryByPath("/upload/listing/{$id}/root");
         //           $folder="upload/listing/$id/root/";
         $folder = "upload/listing/{$id}/";
         $allowedExtensions = array("jpg", "jpeg", "gif", "png");
         $sizeLimit = 5 * 1024 * 1024;
         // maximum file size in bytes
         $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
         $result = $uploader->handleUpload($folder, true);
         $return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
         $fileSize = filesize($folder . $result['filename']);
         //GETTING FILE SIZE
         $fileName = $result['filename'];
         //GETTING FILE NAME
         if (isset($result['success']) && $result['success'] == true) {
             $photo = new ProListingPhotos();
             $photo->listing_id = $id;
             $photo->image = $fileName;
             $photo->created_date = date('Y-m-d h:i:s');
             $photo->default = $totalImgupload == 0 ? 1 : 0;
             if ($photo->save()) {
                 //warter mark
                 //rezie image
                 //                    Listing::ResizePhotoOfListing($photo);
                 //ANH DUNG CLOSE AUG 11, 2014
                 $ImageProcessing->folder = "/upload/listing/{$id}";
                 $ImageProcessing->file = $fileName;
                 $ImageProcessing->thumbs = ProListingPhotos::$szie;
                 $ImageProcessing->create_thumbs();
                 foreach (ProListingPhotos::$szie as $folder => $item) {
                     ImageProcessing::addWarterMark(YII_UPLOAD_DIR . "/listing/{$id}/{$folder}/{$fileName}", YII_UPLOAD_DIR . "/listing/{$id}/{$folder}/{$fileName}");
                 }
                 ImageProcessing::addWarterMark(YII_UPLOAD_DIR . "/listing/{$id}/root/{$fileName}", YII_UPLOAD_DIR . "/listing/{$id}/{$fileName}");
             }
         }
         echo $return;
         // it's array
         //            if (isset($_FILES['Listing'])) {
         //                $totalImgupload = ProListingPhotos::model()->countByAttributes(array('listing_id' => $id));
         //                if (!ProListingPhotos::checkLimitFileUpload($id)) {
         //                    echo "limit";
         //                    die();
         //                }
         ////
         ////                $error = Listing::model()->validateFileUpload($_FILES['Listing'], 'image_photo', 'image');
         ////                if (empty($error)) {
         ////                    $type = explode("/", $_FILES['Listing']["type"]['image_photo'][0]);
         ////                    $name = date('d-m-Y h-i-s') . "." . $type[1];
         ////
         ////                    $photo = new ProListingPhotos();
         ////                    $photo->listing_id = $id;
         ////                    $photo->image = $name;
         ////                    $photo->created_date = date('Y-m-d h:i:s');
         ////                    $photo->default = ($totalImgupload == 0) ? 1 : 0;
         ////                    if ($photo->save()) {
         ////                        //create folder
         ////                        $ImageProcessing = new ImageProcessing();
         ////                        $ImageProcessing->createSingleDirectoryByPath("/upload/listing/$id");
         ////                        //save file
         ////                        move_uploaded_file($_FILES['Listing']["tmp_name"]['image_photo'][0], YII_UPLOAD_DIR . "/listing/$id/$name");
         ////                        //rezie image =
         ////                        $ImageProcessing->folder = "/upload/listing/$id";
         ////                        $ImageProcessing->file = $name;
         ////                        $ImageProcessing->thumbs = ProListingPhotos::$szie;
         ////                        $ImageProcessing->create_thumbs();
         ////                    }
         ////                }
         ////
         //                    $data = CUploadedFile::getInstances($model, 'image_photo');
         //                   if(!empty($data)&& is_array($data) && count($data)>0){
         //                       foreach ($data as $k => $file) {
         //                            $name = date('d-m-Y-h-i-s') . "." . $file->getExtensionName();
         //                            $photo = new ProListingPhotos();
         //                            $photo->listing_id = $id;
         //                            $photo->image = $file;
         //                            $photo->created_date = date('Y-m-d h:i:s');
         //                            $photo->default = ($totalImgupload == 0) ? 1 : 0;
         //                            $photo->validate();
         //                            if($photo->hasErrors()){
         //                                die('maxsize');
         //                            }else{
         //                                 $photo->image = $name;
         //                                 if ($photo->save()) {
         //            //                         //create folder
         //                                       $ImageProcessing = new ImageProcessing();
         //                                       $ImageProcessing->createSingleDirectoryByPath("/upload/listing/$id");
         //                                       $ImageProcessing->createSingleDirectoryByPath("/upload/listing/$id/root");
         //                                       //save file
         //                                       $file->saveAs(YII_UPLOAD_DIR . "/listing/$id/root/$name");
         //                                       //warter mark
         //                                       ImageProcessing::addWarterMark(YII_UPLOAD_DIR . "/listing/$id/root/$name",YII_UPLOAD_DIR . "/listing/$id/$name");
         //
         //                                        //rezie image
         //                                       $ImageProcessing->folder = "/upload/listing/$id";
         //                                       $ImageProcessing->file = $name;
         //                                       $ImageProcessing->thumbs = ProListingPhotos::$szie;
         //                                       $ImageProcessing->create_thumbs();
         //                                 }
         //                            }
         //                       }
         //                   }
         //            }
     }
 }
Esempio n. 5
0
 /**
  * <Jason>
  * 20131112
  * @param type $oldHomePageFileName
  */
 public function resizeHomePages($oldHomePageFileName = null)
 {
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = '/upload/admin/pages/' . $this->id;
     //delete all old images before resize
     if ($oldHomePageFileName) {
         if ($this->thumb_image != $oldHomePageFileName) {
             $ImageProcessing->delete($ImageProcessing->folder . '/' . $oldHomePageFileName);
             foreach (self::$aSizeHomePage as $key => $value) {
                 $ImageProcessing->delete($ImageProcessing->folder . '/' . $key . '/' . $oldHomePageFileName);
             }
             $ImageProcessing->file = $this->thumb_image;
             $ImageProcessing->thumbs = self::$aSizeHomePage;
             //resize Of banner
             $ImageProcessing->create_thumbs();
         }
     } else {
         $ImageProcessing->file = $this->thumb_image;
         $ImageProcessing->thumbs = self::$aSizeHomePage;
         //resize Of banner
         $ImageProcessing->create_thumbs();
     }
 }
Esempio n. 6
0
 public function actionAjax_upload_photo_by_ku_toan($id)
 {
     $model = $this->loadModel($id);
     if ($model) {
         if (isset($_FILES['Listing'])) {
             $totalImgupload = ProListingPhotos::model()->countByAttributes(array('listing_id' => $id));
             if (!ProListingPhotos::checkLimitFileUpload($id)) {
                 die("limit");
             }
             //                $error = Listing::model()->validateFileUpload($_FILES['Listing'], 'image_photo', 'image');
             //                if (empty($error)) {
             //                    $type = explode("/", $_FILES['Listing']["type"]['image_photo'][0]);
             //                    $name = date('d-m-Y h-i-s') . "." . $type[1];
             //
             //                    $photo = new ProListingPhotos();
             //                    $photo->listing_id = $id;
             //                    $photo->image = $name;
             //                    $photo->created_date = date('Y-m-d h:i:s');
             //                    $photo->default = ($totalImgupload == 0) ? 1 : 0;
             //                    if ($photo->save()) {
             //                        //create folder
             //                        $ImageProcessing = new ImageProcessing();
             //                        $ImageProcessing->createSingleDirectoryByPath("/upload/listing/$id");
             //                        //save file
             //                        move_uploaded_file($_FILES['Listing']["tmp_name"]['image_photo'][0], YII_UPLOAD_DIR . "/listing/$id/$name");
             //                        //rezie image =
             //                        $ImageProcessing->folder = "/upload/listing/$id";
             //                        $ImageProcessing->file = $name;
             //                        $ImageProcessing->thumbs = ProListingPhotos::$szie;
             //                        $ImageProcessing->create_thumbs();
             //                    }
             //                }
             $data = CUploadedFile::getInstances($model, 'image_photo');
             if (!empty($data) && is_array($data) && count($data) > 0) {
                 foreach ($data as $k => $file) {
                     $name = date('d-m-Y-h-i-s') . "." . $file->getExtensionName();
                     $photo = new ProListingPhotos();
                     $photo->listing_id = $id;
                     $photo->image = $file;
                     $photo->created_date = date('Y-m-d h:i:s');
                     $photo->default = $totalImgupload == 0 ? 1 : 0;
                     $photo->validate();
                     if ($photo->hasErrors()) {
                         die('maxsize');
                     } else {
                         $photo->image = $name;
                         if ($photo->save()) {
                             //create folder
                             $ImageProcessing = new ImageProcessing();
                             $ImageProcessing->createSingleDirectoryByPath("/upload/listing/{$id}");
                             $ImageProcessing->createSingleDirectoryByPath("/upload/listing/{$id}/root");
                             //save file
                             $file->saveAs(YII_UPLOAD_DIR . "/listing/{$id}/{$name}");
                             //warter mark
                             ImageProcessing::addWarterMark(YII_UPLOAD_DIR . "/listing/{$id}/root/{$name}", YII_UPLOAD_DIR . "/listing/{$id}/{$name}");
                             //rezie image
                             $ImageProcessing->folder = "/upload/listing/{$id}";
                             $ImageProcessing->file = $name;
                             $ImageProcessing->thumbs = ProListingPhotos::$szie;
                             $ImageProcessing->create_thumbs();
                         }
                     }
                 }
             }
         }
     }
 }