예제 #1
0
파일: Api.php 프로젝트: firaga/operation
 public static function AAdapter($datalist)
 {
     $api = new KStorage_Api();
     $newdatalist = array();
     $dests_withsize = array();
     foreach ($datalist as $v) {
         if (strlen($v[0]) && isset($v[1]['withsize']) && $v[1]['withsize']) {
             $dests_withsize[] = $v[0];
         }
     }
     $sizes = $api->aGetImagesSize($dests_withsize);
     foreach ($datalist as $k => $v) {
         $newdatalist[$k] = array();
         if (strlen($v[0])) {
             if (isset($sizes[$v[0]])) {
                 $newdatalist[$k]['size'] = $sizes[$v[0]];
             }
             if (isset($v[1]['brief'])) {
                 $newdatalist[$k]['brief'] = $api->sGetUrl($v[0], $v[1]['brief']);
             } else {
                 if (isset($v[1]['briefCallback'])) {
                     $brief = call_user_func($v[1]['briefCallback'], $newdatalist[$k]);
                     $newdatalist[$k]['brief'] = $api->sGetUrl($v[0], $brief);
                 }
             }
         }
     }
     return $newdatalist;
 }
예제 #2
0
파일: item.php 프로젝트: firaga/operation
 public function post($update, $after = null, $post_style = 'default')
 {
     $file = Ko_Web_Request::AFile('file');
     $api = new KStorage_Api();
     if (!$api->bUpload2Storage($file, $image)) {
         throw new Exception('文件上传失败', 1);
     }
     $title = $file['name'];
     $loginApi = new KUser_loginApi();
     $uid = $loginApi->iGetLoginUid();
     $photoApi = new KPhoto_Api();
     switch ($post_style) {
         case 'album':
             $albumid = $update;
             break;
         default:
             $albumid = 0;
             break;
     }
     $photoid = $photoApi->addPhoto($albumid, $uid, $image, $title);
     $this->_sendSysmsg($uid, $albumid, $photoid);
     $data = array('key' => compact('uid', 'photoid'));
     if (is_array($after)) {
         switch ($after['style']) {
             default:
                 $data['after'] = $photoApi->getPhotoInfo($uid, $photoid);
                 $data['after']['image'] = $api->sGetUrl($image, $after['decorate']);
                 break;
         }
     }
     return $data;
 }
예제 #3
0
파일: Api.php 프로젝트: firaga/operation
 protected function _sDataUrl2Link($sData)
 {
     $api = new KStorage_Api();
     if ($api->bContent2Storage($sData, $sDest)) {
         return $api->sGetUrl($sDest, 'imageView2/2/w/600/h/600');
     }
     return parent::_sDataUrl2Link($sData);
 }
예제 #4
0
파일: Api.php 프로젝트: firaga/operation
 public function getIndexList($boundary, $num, &$next, &$next_boundary)
 {
     $msglist = $this->aGetListSeq(0, 'index', $boundary, $num, $next, $next_boundary);
     $userlist = $albumlist = $photolist = $bloglist = array();
     foreach ($msglist as $v) {
         if (self::PHOTO == $v['msgtype']) {
             $userlist[$v['content']['uid']] = $v['content']['uid'];
             $albumlist[] = array('uid' => $v['content']['uid'], 'albumid' => $v['content']['albumid']);
             $photolist = array_merge($photolist, $v['content']['photolist']);
         } else {
             if (self::BLOG == $v['msgtype']) {
                 $userlist[$v['content']['uid']] = $v['content']['uid'];
                 $bloglist[] = array('uid' => $v['content']['uid'], 'blogid' => $v['content']['blogid']);
             }
         }
     }
     $userlist = Ko_Tool_Adapter::VConv($userlist, array('list', array('user_baseinfo', array('logo80'))));
     $storageApi = new KStorage_Api();
     $photoApi = new KPhoto_Api();
     $blogApi = new KBlog_Api();
     $photoinfos = $photoApi->getPhotoInfos($photolist);
     $albuminfos = $photoApi->getAlbumInfos($albumlist);
     $bloginfos = $blogApi->aGetBlogInfos($bloglist);
     foreach ($msglist as $k => &$v) {
         if (self::PHOTO == $v['msgtype']) {
             $v['content']['userinfo'] = $userlist[$v['content']['uid']];
             $v['content']['albuminfo'] = $albuminfos[$v['content']['albumid']];
             if (empty($v['content']['albuminfo'])) {
                 $this->vDelete(0, $v['msgid']);
                 unset($msglist[$k]);
             } else {
                 $photolist = array();
                 foreach ($v['content']['photolist'] as $photo) {
                     if (!empty($photoinfos[$photo['photoid']]) && $photoinfos[$photo['photoid']]['albumid'] == $photo['albumid']) {
                         $photo['image'] = $storageApi->sGetUrl($photoinfos[$photo['photoid']]['image'], 'imageView2/2/w/480/h/240');
                         $photolist[] = $photo;
                     }
                 }
                 $v['content']['photolist'] = $photolist;
                 if (empty($photolist)) {
                     $this->vDelete(0, $v['msgid']);
                     unset($msglist[$k]);
                 }
             }
         } else {
             if (self::BLOG == $v['msgtype']) {
                 $v['content']['userinfo'] = $userlist[$v['content']['uid']];
                 $v['content']['bloginfo'] = $bloginfos[$v['content']['blogid']];
                 if (empty($v['content']['bloginfo'])) {
                     $this->vDelete(0, $v['msgid']);
                     unset($msglist[$k]);
                 }
             }
         }
     }
     unset($v);
     return $msglist;
 }
예제 #5
0
파일: item.php 프로젝트: firaga/operation
 public function post($update, $after = null)
 {
     $file = Ko_Web_Request::AFile('file');
     $api = new KStorage_Api();
     if (!$api->bUpload2Storage($file, $sDest)) {
         throw new Exception('文件上传失败', 1);
     }
     $data = array('key' => $sDest);
     if (is_array($after)) {
         switch ($after['style']) {
             default:
                 $data['after'] = $api->sGetUrl($sDest, $after['decorate']);
                 break;
         }
     }
     return $data;
 }
예제 #6
0
 private static function _VFillMoreInfo(&$info, $aMore)
 {
     $api = new KStorage_Api();
     foreach ($aMore as $more) {
         switch ($more) {
             case 'logo16':
                 $info['logo16'] = '' === $info['logo'] ? 'http://' . IMG_DOMAIN . '/logo/16.png' : $api->sGetUrl($info['logo'], 'imageView2/1/w/16');
                 break;
             case 'logo32':
                 $info['logo32'] = '' === $info['logo'] ? 'http://' . IMG_DOMAIN . '/logo/32.png' : $api->sGetUrl($info['logo'], 'imageView2/1/w/32');
                 break;
             case 'logo48':
                 $info['logo48'] = '' === $info['logo'] ? 'http://' . IMG_DOMAIN . '/logo/48.png' : $api->sGetUrl($info['logo'], 'imageView2/1/w/48');
                 break;
             case 'logo80':
                 $info['logo80'] = '' === $info['logo'] ? 'http://' . IMG_DOMAIN . '/logo/80.png' : $api->sGetUrl($info['logo'], 'imageView2/1/w/80');
                 break;
             case 'logo120':
                 $info['logo120'] = '' === $info['logo'] ? 'http://' . IMG_DOMAIN . '/logo/120.png' : $api->sGetUrl($info['logo'], 'imageView2/1/w/120');
                 break;
             case 'logo200':
                 $info['logo200'] = '' === $info['logo'] ? 'http://' . IMG_DOMAIN . '/logo/200.png' : $api->sGetUrl($info['logo'], 'imageView2/1/w/200');
                 break;
         }
     }
 }
예제 #7
0
파일: logo.php 프로젝트: firaga/operation
 public function post($update, $after = null)
 {
     $api = new KStorage_Api();
     $content = $api->sRead($update['fileid']);
     if ('' === $content) {
         throw new Exception('获取原文件失败', 1);
     }
     if (false === ($info = Ko_Tool_Image::VInfo($content, Ko_Tool_Image::FLAG_SRC_BLOB))) {
         throw new Exception('获取原文件信息失败', 2);
     }
     $zoom = $info['width'] / $update['width'];
     $aOption = array('srcx' => $zoom * $update['left'], 'srcy' => $zoom * $update['top'], 'srcw' => $zoom * $update['w'], 'srch' => $zoom * $update['h'], 'quality' => 98, 'strip' => true);
     if (false === ($dst = Ko_Tool_Image::VCrop($content, '1.' . $info['type'], $update['w'], $update['h'], Ko_Tool_Image::FLAG_SRC_BLOB | Ko_Tool_Image::FLAG_DST_BLOB, $aOption))) {
         throw new Exception('文件转换失败', 3);
     }
     if (!$api->bContent2Storage($dst, $logoid)) {
         throw new Exception('文件保存失败', 3);
     }
     $loginApi = new KUser_loginApi();
     $baseinfoApi = new KUser_baseinfoApi();
     $baseinfoApi->bUpdateLogo($loginApi->iGetLoginUid(), $logoid);
     return array('key' => $logoid);
 }
예제 #8
0
파일: photo.php 프로젝트: firaga/operation
    }
    $userinfo = Ko_Tool_Adapter::VConv($uid, array('user_baseinfo', array('logo80')));
    $photolist = $photoApi->getPhotoListBySeq($uid, $albumid, '0_0_0', $num, $next, $next_boundary, 'imageView2/2/w/240');
    $render = new KRender_www();
    if ($loginuid == $uid) {
        $allalbumlist = $photoApi->getAllAlbumList($uid);
        $render->oSetData('allalbumlist', $allalbumlist);
    }
    $render->oSetTemplate('www/photo/album.html')->oSetData('userinfo', $userinfo)->oSetData('albuminfo', $albuminfo)->oSetData('photolist', $photolist)->oSetData('page', array('num' => $num, 'next' => $next, 'next_boundary' => $next_boundary))->oSend();
});
Ko_Web_Route::VGet('item', function () {
    $loginApi = new KUser_loginApi();
    $loginuid = $loginApi->iGetLoginUid();
    $uid = Ko_Web_Request::IGet('uid');
    $photoid = Ko_Web_Request::IGet('photoid');
    $storageApi = new KStorage_Api();
    $photoApi = new KPhoto_Api();
    $photoinfo = $photoApi->getPhotoInfo($uid, $photoid);
    if (empty($photoinfo)) {
        Ko_Web_Response::VSetRedirect('/');
        Ko_Web_Response::VSend();
        exit;
    }
    $photoinfo['image_src'] = $storageApi->sGetUrl($photoinfo['image'], '');
    $photoinfo['image_small'] = $storageApi->sGetUrl($photoinfo['image'], 'imageView2/1/w/60');
    $photoinfo['image_exif'] = $storageApi->aGetImageExif($photoinfo['image']);
    $agentinfo = KUser_agentApi::get();
    if ($agentinfo['screen']['height'] < 1000) {
        $photoinfo['image'] = $storageApi->sGetUrl($photoinfo['image'], 'imageView2/2/w/600/h/600');
        $photoinfo['imagesize'] = 600;
    } else {
예제 #9
0
파일: Api.php 프로젝트: firaga/operation
 public function getAllAlbumDigest($uid)
 {
     if (!$uid) {
         return array();
     }
     $option = new Ko_Tool_SQL();
     $option->oWhere('uid = ?', $uid)->oOrderBy('sort desc');
     $albumlist = $this->albumDao->aGetList($option);
     $albumids = Ko_Tool_Utils::AObjs2ids($albumlist, 'albumid');
     $digest = $this->_getDigest($albumids);
     $allphotoids = array();
     foreach ($digest as &$v) {
         $v = array_slice($v, 0, 45);
         $allphotoids = array_merge($allphotoids, $v);
     }
     unset($v);
     foreach ($allphotoids as &$v) {
         $v = array('uid' => $uid, 'photoid' => $v);
     }
     unset($v);
     $photoinfos = $this->photoDao->aGetDetails($allphotoids);
     $contentApi = new KContent_Api();
     $aText = $contentApi->aGetText(KContent_Api::PHOTO_ALBUM_TITLE, $albumids);
     $recycleid = $this->_getRecycleAlbumid($uid);
     $storageApi = new KStorage_Api();
     foreach ($albumlist as &$v) {
         $v['title'] = $aText[$v['albumid']];
         $v['isrecycle'] = $v['albumid'] == $recycleid;
         $v['digest'] = $digest[$v['albumid']];
         foreach ($v['digest'] as &$vv) {
             $vv = $photoinfos[$vv];
             $vv['image'] = $storageApi->sGetUrl($vv['image'], 'imageView2/1/w/60');
         }
         unset($vv);
     }
     unset($v);
     return $albumlist;
 }
예제 #10
0
파일: Api.php 프로젝트: firaga/operation
 private function _sGetCover($content)
 {
     $offset = 0;
     $storage = new KStorage_Api();
     while (1) {
         $url = $this->_sGetImageUrl($content, $offset);
         if ('' === $url) {
             break;
         }
         list($dest, $brief) = $storage->aParseUrl($url);
         if ('' !== $dest) {
             return $dest;
         }
     }
     return '';
 }