/**
  * 设置用户头像设置
  * @param integer $id
  */
 public function actionCropFace($id)
 {
     $model = $this->loadModel($id);
     if ($model->face == $model->defaultFace) {
         $this->redirect(array('uploadFace', 'id' => $id));
         Yii::app()->end();
     }
     if (isset($_POST['imageId_x'])) {
         Yii::import('ext.jcrop.EJCropper');
         $jcropper = new EJCropper();
         $jcropper->thumbPath = dirname($model->face) . "/thumbs";
         if (!file_exists($jcropper->thumbPath)) {
             DxdUtil::createFolders($jcropper->thumbPath);
         }
         // get the image cropping coordinates (or implement your own method)
         $coords = $jcropper->getCoordsFromPost('imageId');
         // returns the path of the cropped image, source must be an absolute path.
         $thumbnail = $jcropper->crop($model->face, $coords);
         if ($thumbnail) {
             unlink($model->face);
             $model->face = $thumbnail;
             $model->save();
         }
         $this->redirect(array('uploadFace', 'id' => $id));
     }
     $this->render('crop_face', array('model' => $model));
 }
 /**
  * 关注或取消关注
  * @param unknown_type $id
  */
 public function run($id)
 {
     $model = $this->controller->loadModel($id);
     if (isset($_POST['imageId_x'])) {
         Yii::import('ext.jcrop.EJCropper');
         $jcropper = new EJCropper();
         $jcropper->thumbPath = dirname($model->{$this->attribute}) . "/thumbs";
         if (!file_exists($jcropper->thumbPath)) {
             DxdUtil::createFolders($jcropper->thumbPath);
         }
         // get the image cropping coordinates (or implement your own method)
         $coords = $jcropper->getCoordsFromPost('imageId');
         // returns the path of the cropped image, source must be an absolute path.
         $thumbnail = $jcropper->crop($model->face, $coords);
         if ($thumbnail) {
             unlink($model->face);
             $model->face = $thumbnail;
             $model->save();
         }
         $this->controller->redirect($this->returnUrl);
     }
     $this->controller->render($this->cropViewFile, array('model' => $model));
 }
 /**
  * 裁剪封面图页面和处理方法
  * @param integer $id 文章ID
  */
 public function actionCropFace($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['imageId_x'])) {
         Yii::import('ext.jcrop.EJCropper');
         $jcropper = new EJCropper();
         $jcropper->thumbPath = $this->facePath;
         if (!file_exists($jcropper->thumbPath)) {
             DxdUtil::createFolders($jcropper->thumbPath);
         }
         $coords = $jcropper->getCoordsFromPost('imageId');
         $thumbnail = $jcropper->crop($model->face, $coords);
         if ($thumbnail) {
             $oldFace = $model->face;
             $model->face = $thumbnail;
             if ($model->save()) {
                 if ($model->face != $oldFace) {
                     @unlink($oldFace);
                 }
                 Yii::app()->user->setFlash('success', '更新成功');
                 $this->redirect(array('index'));
             } else {
                 Yii::app()->user->setFlash('error', '更新失败');
             }
         }
     }
     $this->render('crop_face', array('model' => $model));
 }
Beispiel #4
0
 public function actionCropFace()
 {
     $user = UserInfo::model()->findByAttributes(array('id' => Yii::app()->user->id));
     if (!$user->face || $user->face == $user->defaultFace) {
         Yii::app()->user->setFlash('success', Yii::t('app', "欢迎{name}加入!", array('{name}' => $user->name)));
         $this->redirect(Yii::app()->baseUrl . "/");
         Yii::app()->end();
     }
     if (isset($_POST['imageId_x'])) {
         Yii::import('ext.jcrop.EJCropper');
         $jcropper = new EJCropper();
         $jcropper->thumbPath = dirname($user->face) . "/thumbs";
         if (!file_exists($jcropper->thumbPath)) {
             DxdUtil::createFolders($jcropper->thumbPath);
         }
         // get the image cropping coordinates (or implement your own method)
         $coords = $jcropper->getCoordsFromPost('imageId');
         // returns the path of the cropped image, source must be an absolute path.
         $thumbnail = $jcropper->crop($user->face, $coords);
         if ($thumbnail) {
             unlink($user->face);
             $user->face = $thumbnail;
             $user->save();
         }
         Yii::app()->user->setFlash('success', Yii::t('app', "欢迎{name}加入!", array('{name}' => $user->name)));
         $this->redirect(Yii::app()->baseUrl . "/");
         //	echo $jcropper->thumbPath;
         //	echo $thumbnail;
     }
     $this->render('register_crop_face', array('user' => $user));
 }
Beispiel #5
0
 public function actionDocrop()
 {
     Yii::import('ext.jcrop.EJCropper');
     $assetsDir = dirname(__FILE__) . '/../assets';
     // $imagetobecroped='689x1000.jpg';
     $imagetobecroped = 'images.jpeg';
     //print_r($_REQUEST);
     //exit;
     $jcropper = new EJCropper();
     $jcropper->thumbPath = $assetsDir . "/cropedimage";
     // some settings ...
     $jcropper->jpeg_quality = 95;
     $jcropper->png_compression = 8;
     // get the image cropping coordinates (or implement your own method)
     $coords = $jcropper->getCoordsFromPost('imageId');
     // returns the path of the cropped image, source must be an absolute path.
     $thumbnail = $jcropper->crop($assetsDir . "/" . $imagetobecroped, $coords);
 }