Example #1
0
 public function doavatarAction()
 {
     $uid = (int) $this->getInput('uid', 'get');
     Wind::import('WINDID:service.upload.action.WindidAvatarUpload');
     Wind::import('WINDID:service.upload.WindidUpload');
     $bhv = new WindidAvatarUpload($uid);
     $upload = new WindidUpload($bhv);
     if (($result = $upload->check()) === true) {
         $result = $upload->execute();
     }
     if ($result !== true) {
         $array = array("isSuccess" => false, "msg" => WindConvert::convert('上传失败', 'utf8', Wekit::app()->charset), "erCode" => "000");
         //$this->showMessage($result->getMessage());
     } else {
         //用户上传头像之后的钩子
         PwSimpleHook::getInstance('update_avatar')->runDo($uid);
         $array = array("isSuccess" => true, "msg" => WindConvert::convert('上传成功', 'utf8', Wekit::app()->charset), "erCode" => "000");
     }
     echo WindJson::encode($array, Windid::client()->clientCharser);
     exit;
 }
Example #2
0
 public function defaultAvatar($uid, $type = 'face')
 {
     Wind::import('WINDID:service.upload.WindidUpload');
     $_avatar = array('.jpg' => '_big.jpg', '_middle.jpg' => '_middle.jpg', '_small.jpg' => '_small.jpg');
     $defaultBanDir = Wind::getRealDir('PUBLIC:') . 'res/images/face/';
     Wind::import('WINDID:service.config.srv.WindidStoreService');
     $srv = new WindidStoreService();
     $store = $srv->getStore();
     $fileDir = '/avatar/' . Windid::getUserDir($uid) . '/';
     foreach ($_avatar as $des => $org) {
         $toPath = $store->getAbsolutePath($uid . $des, $fileDir);
         $fromPath = $defaultBanDir . $type . $org;
         WindidUpload::createFolder(dirname($toPath));
         WindidUpload::copyFile($fromPath, $toPath);
         $store->save($toPath, $fileDir . $uid . $des);
     }
     return true;
 }
Example #3
0
 public function doavatarAction()
 {
     $uid = (int) $this->getInput('uid', 'get');
     Wind::import('WINDID:service.upload.action.WindidAvatarUpload');
     Wind::import('WINDID:service.upload.WindidUpload');
     $bhv = new WindidAvatarUpload($uid);
     $upload = new WindidUpload($bhv);
     if (($result = $upload->check()) === true) {
         $result = $upload->execute();
     }
     if ($result instanceof WindidError) {
         $this->output($result->getCode());
     } else {
         $this->_getNotifyClient()->send('uploadAvatar', $uid, true);
         $this->output(1);
     }
 }
Example #4
0
 /**
  * 生成缩略图
  *
  * @param PwImage $image 图片对象
  * @param array $thumbInfo 缩略图配置
  * @param object 存储对象
  */
 public function makeThumb(WindidImage $image, $thumbInfo, $store)
 {
     $quality = 80;
     foreach ($thumbInfo as $key => $value) {
         $thumburl = $store->getAbsolutePath($value[0], $value[1]);
         WindidUpload::createFolder(dirname($thumburl));
         $result = $image->makeThumb($thumburl, $value[2], $value[3], $quality, $value[4], $value[5]);
         if ($result === true && $image->filename != $thumburl) {
             $this->ifthumb |= 1 << $key;
             $this->_thumb[] = array($thumburl, $value[1] . $value[0]);
         }
     }
 }