public function show($category, $id, $name) { $this->medialib = new Library\Media\Media(); $modelMedia = new Library\Media\Model\Media(); $user = sentinel()->getUser(); $name = urldecode($name); $media = $this->medialib->getMedia()->where('file_name', 'like', $name . '%')->findOrFail($id); $data = ['category' => $media->category, 'media' => $media]; $modelMedia->resolveVisitorUnique($user, $media->id); $this->template->build('single', $data); }
public function getmedia() { $media_id = $this->input->get('media_id'); $media_id = explode(',', $media_id); if (count($media_id) > 1) { $metadata = []; foreach ($media_id as $id) { try { $metadata[$id] = Library\Media\Model\Media::wuthDrafts()->findOrFail($id); } catch (Exception $e) { } } } else { try { $metadata = Library\Media\Model\Media::wuthDrafts()->find($media_id[0]); } catch (Exception $e) { } } $this->output->set_content_type('application/json')->set_output(json_encode($metadata)); }
public function delete($media_id) { try { $user = sentinel()->getUser(); $media = Library\Media\Model\Media::withDrafts()->userId($user->id)->findOrFail($media_id); $this->medialib->setMedia($media); $category = $media->category; $this->medialib->deleteMedia($media_id); redirect('media/show/' . $category->id, 'refresh'); } catch (\Exception $e) { set_message_error('Media tidak tersedia.'); redirect('media', 'refresh'); } }
public function fillMeta($files) { $mediaFiles = array(); for ($i = 0; $i < count($files); $i++) { $name = $files[$i]['file_name']; $created_at = $files[$i]['created_at']; $status = $files[$i]['status']; $userId = $files[$i]['user_id']; $mediaFiles[$i] = $this->media_model->getFileData($name, $created_at, $userId, $status); foreach ($mediaFiles[$i] as $m) { $media = Library\Media\Model\Media::withDrafts()->userId($userId)->findOrFail($m->id); } $data['media'][$i] = $media; } $data['files'] = $mediaFiles; $this->template->build('add_meta', $data); }