芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/minscoop.com/app/Controllers/FileController.php
fileModel = new FileModel(); } /* * -------------------------------------------------------------------- * IMAGES * -------------------------------------------------------------------- */ /** * Upload Image */ public function uploadImage() { $this->fileModel->uploadImage(); } /** * Get Images */ public function getImages() { $this->printImages($this->fileModel->getImages()); } /** * Select Image File */ public function selectImage() { $fileId = inputPost('file_id'); $file = $this->fileModel->getImage($fileId); if (!empty($file)) { echo base_url($file->image_mid); } } /** * Laod More Images */ public function loadMoreImages() { $lastId = inputPost('min'); $this->printImages($this->fileModel->getMoreImages($lastId)); } /** * Search Images */ public function searchImage() { $search = inputPost('search'); $this->printImages($this->fileModel->searchImages($search)); } /** * Print Images */ public function printImages($images) { $data = [ 'result' => 0, 'content' => '' ]; if (!empty($images)) { foreach ($images as $image) { $imgBaseURL = getBaseURLByStorage($image->storage); $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; if (!empty($image->file_name)): $data['content'] .= '
' . esc($image->file_name) . '
'; endif; $data['content'] .= '
'; } } $data['result'] = 1; echo json_encode($data); } /** * Delete Image */ public function deleteImage() { $fileId = inputPost('file_id'); $this->fileModel->deleteImage($fileId); } /* *------------------------------------------------------------------------------------------ * QUIZ IMAGES *------------------------------------------------------------------------------------------ */ /** * Upload Quiz Image File */ public function uploadQuizImageFile() { $this->fileModel->uploadQuizImage(); } /** * Get Quiz Images */ public function getQuizImages() { $quizImages = $this->fileModel->getQuizImages(); $this->printQuizImages($quizImages); } /** * Laod More Quiz Images */ public function loadMoreQuizImages() { $min = inputPost('min'); $quizImages = $this->fileModel->getMoreQuizImages($min); $this->printQuizImages($quizImages); } /** * Search Quiz Images */ public function searchQuizImage() { $search = inputPost('search'); $quizImages = $this->fileModel->searchQuizImages($search); $this->printQuizImages($quizImages); } /** * Print Quiz Images */ public function printQuizImages($quizImages) { $data = [ 'result' => 0, 'content' => '' ]; if (!empty($quizImages)) { foreach ($quizImages as $image) { $imgBaseURL = getBaseURLByStorage($image->storage); $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; if (!empty($image->file_name)) { $data['content'] .= '
' . esc($image->file_name) . '
'; } $data['content'] .= '
'; } } $data['result'] = 1; echo json_encode($data); } /** * Delete Quiz Image File */ public function deleteQuizImage() { $fileId = inputPost('file_id'); $this->fileModel->deleteQuizImage($fileId); } /* *------------------------------------------------------------------------------------------ * FILES *------------------------------------------------------------------------------------------ */ /** * Upload File */ public function uploadFile() { $this->fileModel->uploadFile(); } /** * Get Files */ public function getFiles() { $files = $this->fileModel->getFiles(); $this->printFiles($files); } /** * Laod More Files */ public function loadMoreFiles() { $min = inputPost('min'); $files = $this->fileModel->getMoreFiles($min); $this->printFiles($files); } /** * Search Files */ public function searchFiles() { $search = inputPost('search'); $files = $this->fileModel->searchFiles($search); $this->printFiles($files); } /** * Print Files */ public function printFiles($files) { $data = [ 'result' => 0, 'content' => '' ]; if (!empty($files)) { foreach ($files as $file) { $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
' . esc($file->file_name) . '
'; $data['content'] .= '
'; } } $data['result'] = 1; echo json_encode($data); } /** * Delete File */ public function deleteFile() { $fileId = inputPost('file_id'); $this->fileModel->deleteFile($fileId); } /* *------------------------------------------------------------------------------------------ * VIDEOS *------------------------------------------------------------------------------------------ */ /** * Upload Video */ public function uploadVideo() { $this->fileModel->uploadVideo(); } /** * Get Videos */ public function getVideos() { $videos = $this->fileModel->getVideos(); $this->printVideos($videos); } /** * Laod More Videos */ public function loadMoreVideos() { $min = inputPost('min'); $videos = $this->fileModel->getMoreVideos($min); $this->printVideos($videos); } /** * Search Videos */ public function searchVideos() { $search = inputPost('search'); $videos = $this->fileModel->searchVideos($search); $this->printVideos($videos); } /** * Print Videos */ public function printVideos($videos) { $data = [ 'result' => 0, 'content' => '' ]; if (!empty($videos)) { foreach ($videos as $video) { $videoBaseURL = getBaseURLByStorage($video->storage); $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
' . esc($video->video_name) . '
'; $data['content'] .= '
'; } } $data['result'] = 1; echo json_encode($data); } /** * Delete Video */ public function deleteVideo() { $videoId = inputPost('video_id'); $this->fileModel->deleteVideo($videoId); } /* *------------------------------------------------------------------------------------------ * AUDIOS *------------------------------------------------------------------------------------------ */ /** * Upload Audio */ public function uploadAudio() { $this->fileModel->uploadAudio(); } /** * Get Audios */ public function getAudios() { $audios = $this->fileModel->getAudios(); $this->printAudios($audios); } /** * Laod More Audios */ public function loadMoreAudios() { $min = inputPost('min'); $audios = $this->fileModel->getMoreAudios($min); $this->printAudios($audios); } /** * Search Audios */ public function searchAudios() { $search = inputPost('search'); $audios = $this->fileModel->searchAudios($search); $this->printAudios($audios); } /** * Print Audios */ public function printAudios($audios) { $data = [ 'result' => 0, 'content' => '' ]; if (!empty($audios)) { foreach ($audios as $audio) { $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
'; $data['content'] .= '
' . esc($audio->audio_name) . '
'; $data['content'] .= '
'; } } $data['result'] = 1; echo json_encode($data); } /** * Delete Audio */ public function deleteAudio() { $audioId = inputPost('audio_id'); $this->fileModel->deleteAudio($audioId); } }