Beispiel #1
0
 public function bookArticleImageAction($bid, $mid, $action = 'upload')
 {
     $data = $this->getRequest();
     $rest = Restful::instance();
     $members = MembersManage::instance();
     $app = $members->getCurrentSession();
     if (!$app) {
         exit;
     }
     $image = new ImagesManage();
     if ($action == 'upload' and $data->isPost()) {
         if ($filepath = $image->saveImagesBookArticle($data->getFiles('file'), $bid, $mid, $app['uid'], true, 1, true)) {
             $rest->assign('filelink', ImagesManage::getRelativeImage($filepath));
             $rest->response();
         }
     } elseif ($action == 'list') {
         $list = $image->getImagesBookArticleForID($bid);
         if ($list) {
             $images = array();
             foreach ($list as $key => $value) {
                 $thumb = $value['thumb'] > 0 ? $image->getRealCoverSize($value['path'], 'small', 'jpg') : '';
                 $images[] = array('thumb' => $thumb, 'image' => ImagesManage::getRelativeImage($value['path']), 'title' => $value['filename'], 'folder' => $mid);
             }
             echo stripslashes(json_encode($images));
             exit;
         }
     }
     exit;
 }