public function lessonArticleImageAction($cid, $ccid, $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->saveImagesCourseArticle($data->getFiles('file'), $cid, $ccid, $app['uid'], true, 1, true)) { $rest->assign('filelink', ImagesManage::getRelativeImage($filepath)); $rest->response(); } } elseif ($action == 'list') { $list = $image->getImagesCourseArticleForID($cid); 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' => $ccid); } echo stripslashes(json_encode($images)); exit; } } exit; }