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; }
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; }
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); }
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; }
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; } } }
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; }
$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 { $photoinfo['image'] = $storageApi->sGetUrl($photoinfo['image'], 'imageView2/2/w/800/h/800'); $photoinfo['imagesize'] = 800; } $albuminfo = $photoApi->getAlbumInfo($uid, $photoinfo['albumid']); if ($albuminfo['isrecycle'] && $uid != $loginuid) { Ko_Web_Response::VSetRedirect('/'); Ko_Web_Response::VSend(); exit;
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; }
public function aGetBlogInfos($list) { $blogids = Ko_Tool_Utils::AObjs2ids($list, 'blogid'); $infos = $this->blogDao->aGetDetails($list); $contentApi = new KContent_Api(); $aText = $contentApi->aGetTextEx(array(KContent_Api::BLOG_TITLE => $blogids, KContent_Api::BLOG_CONTENT => array('ids' => $blogids, 'maxlength' => 1000, 'ext' => '...'))); $storageApi = new KStorage_Api(); foreach ($infos as &$v) { if ('回收站' === $v['tags']) { $v = array(); } if (!empty($v)) { $v['title'] = $aText[KContent_Api::BLOG_TITLE][$v['blogid']]; $v['content'] = $aText[KContent_Api::BLOG_CONTENT][$v['blogid']]; if (strlen($v['cover'])) { $v['cover'] = $storageApi->sGetUrl($v['cover'], 'imageView2/1/w/300/h/200'); } } } unset($v); return $infos; }