コード例 #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
ファイル: Api.php プロジェクト: firaga/operation
 public function getPhotoListBySeq($uid, $albumid, $boundary, $num, &$next, &$next_boundary, $decorate)
 {
     $next = 0;
     if (!$uid) {
         return array();
     }
     $albumkey = compact('uid', 'albumid');
     $album = $this->albumDao->aGet($albumkey);
     if (empty($album)) {
         return array();
     }
     list($boundary_photoid, $boundary_sort, $boundary_pos) = explode('_', $boundary);
     $option = new Ko_Tool_SQL();
     if ($boundary_photoid) {
         $option->oAnd('sort < ? OR (sort = ? AND photoid < ?)', $boundary_sort, $boundary_sort, $boundary_photoid);
     }
     $limit = $num + 1;
     $option->oAnd('albumid = ?', $albumid)->oLimit($limit)->oOrderBy('sort desc, photoid desc');
     $photolist = $this->photoDao->aGetList($option);
     if ($count = count($photolist)) {
         if ($count > $num) {
             $next = array_pop($photolist);
             $count--;
             $next = $next['photoid'];
         }
     }
     $photoids = Ko_Tool_Utils::AObjs2ids($photolist, 'photoid');
     $contentApi = new KContent_Api();
     $aText = $contentApi->aGetText(KContent_Api::PHOTO_TITLE, $photoids);
     $api = new KStorage_Api();
     $images = Ko_Tool_Utils::AObjs2ids($photolist, 'image');
     $sizes = $api->aGetImagesSize($images);
     foreach ($photolist as $k => &$v) {
         $v['size'] = $sizes[$v['image']];
         $v['image'] = $api->sGetUrl($v['image'], $decorate);
         $v['title'] = $aText[$v['photoid']];
         $update = array();
         if ($boundary_pos + $k + 1 != $v['pos']) {
             $update['pos'] = $v['pos'] = $boundary_pos + $k + 1;
         }
         if ($k != 0) {
             if ($photolist[$k - 1]['photoid'] != $v['prev']) {
                 $update['prev'] = $v['prev'] = $photolist[$k - 1]['photoid'];
             }
         } else {
             if ($boundary_photoid != $v['prev']) {
                 $update['prev'] = $v['prev'] = $boundary_photoid;
             }
         }
         if ($k != $count - 1) {
             if ($photolist[$k + 1]['photoid'] != $v['next']) {
                 $update['next'] = $v['next'] = $photolist[$k + 1]['photoid'];
             }
         } else {
             if ($next != $v['next']) {
                 $update['next'] = $v['next'] = $next;
             }
             $next_boundary = $v['photoid'] . '_' . $v['sort'] . '_' . $v['pos'];
         }
         if (!empty($update)) {
             $this->photoDao->iUpdate($v, $update);
         }
     }
     unset($v);
     if (!$next && $album['pcount'] != $boundary_pos + $count) {
         $this->albumDao->iUpdate($albumkey, array('pcount' => $boundary_pos + $count));
     }
     return $photolist;
 }