diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb3dd2f..d4d769b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick coverage: none - name: Install composer - run: composer create-project juzaweb/juzacms cms "${{ matrix.cms }}" + run: composer create-project juzaweb/cms cms "${{ matrix.cms }}" - name: Copy .env run: php -r "copy('.env.testing.example', '.env');" working-directory: cms diff --git a/composer.json b/composer.json index 9f3c9f9..e081012 100644 --- a/composer.json +++ b/composer.json @@ -7,14 +7,14 @@ "juzaweb.com", "Movie plugin" ], - "description": "MyMo Core Plugin help you easily create movie website. It is a powerful, flexible and User friendly movie & Video Steaming Theme with advance video contents management system. It’s easy to use & install. It has been created to provide unique experience to movie lover & movie site owner. To observe of ISP needed we have made MYMO to use as multipurpose video website. It was created to run with MyMo Theme.", + "description": "Movie Juzaweb Plugin help you easily create movie website. It is a powerful, flexible and User friendly movie & Video Steaming Theme with advance video contents management system. It’s easy to use & install. It has been created to provide unique experience to movie lover & movie site owner. To observe of ISP needed we have made MYMO to use as multipurpose video website. It was created to run with MyMo Theme.", "extra": { "juzaweb": { + "name": "Movie Plugin - Easily create movie website", + "domain": "mymo", "providers": [ "Juzaweb\\Movie\\Providers\\MovieServiceProvider" - ], - "name": "Movie plugin", - "domain": "mymo" + ] } }, "autoload": { @@ -24,5 +24,12 @@ "files": [ "src/Helpers/helpers.php" ] + }, + "require": { + "juzaweb/subscription": "@dev|^1.0" + }, + "require-dev": { + "juzaweb/modules": "^1.0", + "juzaweb/dev-tool": "^1.0" } } diff --git a/src/Helpers/TmdbImport.php b/src/Helpers/TmdbImport.php index a342569..a5920f1 100644 --- a/src/Helpers/TmdbImport.php +++ b/src/Helpers/TmdbImport.php @@ -2,7 +2,7 @@ /** * JUZAWEB CMS - The Best CMS for Laravel Project * - * @package juzaweb/juzacms + * @package juzaweb/cms * @author Juzaweb Team * @link https://juzaweb.com * @license MIT diff --git a/src/Helpers/VideoFile.php b/src/Helpers/VideoFile.php index 9873775..2f43734 100644 --- a/src/Helpers/VideoFile.php +++ b/src/Helpers/VideoFile.php @@ -2,7 +2,7 @@ /** * JUZAWEB CMS - The Best CMS for Laravel Project * - * @package juzaweb/juzacms + * @package juzaweb/cms * @author The Anh Dang * @link https://juzaweb.com/cms * @license MIT @@ -14,7 +14,7 @@ class VideoFile { - public static function isSourceEmbed($source) + public static function isSourceEmbed($source): bool { $embed_source = ['embed', 'youtube', 'vimeo']; @@ -29,7 +29,12 @@ public function getFiles(Resource $video): array { $url = $video->getMeta('url'); - return match ($video->getMeta('source')) { + return $this->getFilesBySourceAndUrl($video->getMeta('source'), $url); + } + + public function getFilesBySourceAndUrl(string $source, string $url): array + { + return match ($source) { 'youtube' => $this->getVideoYoutube($url), 'vimeo' => $this->getVideoVimeo($url), 'upload' => $this->getVideoUpload(), @@ -43,17 +48,29 @@ public function getFiles(Resource $video): array }; } - protected function getVideoYoutube($url) + public function getSourceByUrl(string $url): string + { + $domain = get_domain_by_url($url, true); + + return match ($domain) { + 'youtube.com' => 'youtube', + 'vimeo.com' => 'vimeo', + 'drive.google.com' => 'gdrive', + default => 'mp4', + }; + } + + protected function getVideoYoutube($url): array { return [ (object) [ 'file' => 'https://www.youtube.com/embed/' . get_youtube_id($url), - 'type' => 'mp4', + 'type' => 'youtube', ] ]; } - protected function getVideoVimeo($url) + protected function getVideoVimeo($url): array { return [ (object) [ @@ -63,7 +80,7 @@ protected function getVideoVimeo($url) ]; } - protected function getVideoUrl($type, $url) + protected function getVideoUrl($type, $url): array { /*if (!is_url($url)) { return $this->getVideoUpload(); @@ -96,7 +113,7 @@ protected function getVideoUrl($type, $url) ]; } - protected function getVideoUpload() + protected function getVideoUpload(): array { if ($this->converted == 1) { $files = []; @@ -169,7 +186,7 @@ protected function getVideoUpload() ]; } - protected function getVideoGoogleDrive() + protected function getVideoGoogleDrive(): array { $use_stream = get_config('use_stream', 1); @@ -207,7 +224,7 @@ protected function getVideoGoogleDrive() return []; } - protected function getVideoGoogleDriveEmbed() + protected function getVideoGoogleDriveEmbed(): array { $files[] = (object) [ 'file' => 'https://drive.google.com/file/d/'. get_google_drive_id($this->url) .'/preview', @@ -217,7 +234,7 @@ protected function getVideoGoogleDriveEmbed() return $files; } - protected function generateStreamUrl($path) + protected function generateStreamUrl($path): string { $token = generate_token(basename($path)); $file = json_encode(['path' => $path]); @@ -225,14 +242,15 @@ protected function generateStreamUrl($path) return $this->getStreamLink($token, $file, basename($path)); } - protected function getStreamLink($token, $file, $name) + protected function getStreamLink($token, $file, $name): string { return route('stream.video', [$token, base64_encode($file), $name]); } - protected function getExtension() + protected function getExtension(): string { $file_name = basename($this->url); + return explode('.', $file_name)[count(explode('.', $file_name)) - 1]; } } diff --git a/src/Http/Controllers/AjaxController.php b/src/Http/Controllers/AjaxController.php index c20a6b8..b4c25f5 100644 --- a/src/Http/Controllers/AjaxController.php +++ b/src/Http/Controllers/AjaxController.php @@ -2,7 +2,7 @@ /** * JUZAWEB CMS - The Best CMS for Laravel Project * - * @package juzaweb/juzacms + * @package juzaweb/cms * @author The Anh Dang * @link https://juzaweb.com/cms * @license MIT diff --git a/src/Http/Controllers/Backend/SubtitleController.php b/src/Http/Controllers/Backend/SubtitleController.php index a742dd8..e6eb593 100644 --- a/src/Http/Controllers/Backend/SubtitleController.php +++ b/src/Http/Controllers/Backend/SubtitleController.php @@ -2,6 +2,7 @@ namespace Juzaweb\Movie\Http\Controllers\Backend; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Validator; use Juzaweb\Movie\Http\Datatables\SubtitleDatatable; use Juzaweb\CMS\Http\Controllers\BackendController; @@ -71,11 +72,11 @@ protected function getTitle($page_type, $file_id) return trans('mymo::app.subtitle'); } - protected function getDataForForm($model, $page_type, $file_id) + protected function getDataForForm(Model $model, ...$params, $file_id) { - $data = $this->DataForForm($model, $page_type, $file_id); + $data = $this->DataForForm($model, $params, $file_id); $file = VideoFile::findOrFail($file_id); - $data['page_type'] = $page_type; + $data['page_type'] = $params; $data['file_id'] = $file_id; $data['file'] = $file; return $data; diff --git a/src/Http/Requests/ReportRequest.php b/src/Http/Requests/ReportRequest.php index 61975ad..56b742f 100644 --- a/src/Http/Requests/ReportRequest.php +++ b/src/Http/Requests/ReportRequest.php @@ -2,7 +2,7 @@ /** * JUZAWEB CMS - The Best CMS for Laravel Project * - * @package juzaweb/juzacms + * @package juzaweb/cms * @author Juzaweb Team * @link https://juzaweb.com * @license GNU General Public License v2.0 @@ -30,14 +30,10 @@ public function rules(): array ], 'post_id' => [ 'required', - Rule::modelExists( - Post::class, - 'id', - fn($q) => $q->where('type', 'movies') - ), + Rule::modelExists(Post::class), ], 'video_id' => [ - 'required', + 'nullable', Rule::modelExists( Resource::class, 'id', diff --git a/src/MovieAction.php b/src/MovieAction.php index 50b7a64..1bdd6ec 100644 --- a/src/MovieAction.php +++ b/src/MovieAction.php @@ -4,12 +4,11 @@ use Juzaweb\CMS\Abstracts\Action; use Juzaweb\CMS\Facades\HookAction; -use Juzaweb\Movie\Http\Controllers\AjaxController; use Juzaweb\Movie\Http\Controllers\Backend\TmdbController; class MovieAction extends Action { - public function handle() + public function handle(): void { $this->addAction( Action::INIT_ACTION, @@ -27,10 +26,6 @@ public function handle() Action::INIT_ACTION, [$this, 'registerResources'] ); - $this->addAction( - Action::FRONTEND_CALL_ACTION, - [$this, 'addAjaxTheme'] - ); $this->addAction( 'post_type.movies.btn_group', [$this, 'addImportButton'] @@ -49,7 +44,7 @@ public function handle() ); } - public function registerMovie() + public function registerMovie(): void { HookAction::registerPostType( 'movies', @@ -60,7 +55,7 @@ public function registerMovie() 'supports' => ['tag'], 'metas' => [ 'origin_title' => [ - 'label' => trans('mymo::app.other_name') + 'label' => trans('mymo::app.other_name'), ], 'tv_series' => [ 'label' => trans('mymo::app.type'), @@ -73,6 +68,17 @@ public function registerMovie() ] ], ], + 'is_paid' => [ + 'label' => trans('mymo::app.is_paid'), + 'type' => 'select', + 'sidebar' => true, + 'data' => [ + 'options' => [ + '0' => trans('mymo::app.disabled'), + '1' => trans('mymo::app.enabled'), + ] + ], + ], 'poster' => [ 'label' => trans('mymo::app.poster'), 'type' => 'image', @@ -120,7 +126,7 @@ public function registerMovie() );*/ } - public function registerTaxonomies() + public function registerTaxonomies(): void { HookAction::registerTaxonomy( 'genres', @@ -197,7 +203,7 @@ public function registerTaxonomies() ); } - public function addSettingForm() + public function addSettingForm(): void { HookAction::registerConfig( [ @@ -218,53 +224,7 @@ public function addSettingForm() ); } - public function addAjaxTheme() - { - HookAction::registerFrontendAjax( - 'movie-download', - [ - 'callback' => [AjaxController::class, 'download'] - ] - ); - - HookAction::registerFrontendAjax( - 'get-player', - [ - 'callback' => [AjaxController::class, 'getPlayer'] - ] - ); - - HookAction::registerFrontendAjax( - 'popular-movies', - [ - 'callback' => [AjaxController::class, 'getPopularMovies'] - ] - ); - - HookAction::registerFrontendAjax( - 'movies-genre', - [ - 'callback' => [AjaxController::class, 'getMoviesByGenre'] - ] - ); - - HookAction::registerFrontendAjax( - 'mymo-filter-form', - [ - 'callback' => [AjaxController::class, 'getFilterForm'], - ] - ); - - HookAction::registerFrontendAjax( - 'movie-report', - [ - 'callback' => [AjaxController::class, 'report'], - 'method' => 'post', - ] - ); - } - - public function registerResources() + public function registerResources(): void { HookAction::registerResource( 'servers', @@ -370,20 +330,19 @@ public function registerResources() ); } - public function addImportButton() + public function addImportButton(): void { echo ' '. trans('mymo::app.add_from_tmdb') .' '; } - public function addModalImport() + public function addModalImport(): void { - echo view('mymo::tmdb_import') - ->render(); + echo view('mymo::tmdb_import')->render(); } - public function addAjaxAdmin() + public function addAjaxAdmin(): void { HookAction::registerAdminAjax( 'tmdb-add_movie', diff --git a/src/resources/lang/en/app.php b/src/resources/lang/en/app.php index ca6612e..8d4d1eb 100644 --- a/src/resources/lang/en/app.php +++ b/src/resources/lang/en/app.php @@ -83,10 +83,12 @@ 'you_must_be_logged_in_to_comment' => 'You must be logged in to comment', 'click_to_play' => 'Click to Play', 'show_only_once' => 'Show only once', - 'to_continue_watching_click_reload_player_button' => 'To continue watching, please click \\"Reload Player\\" button', + 'to_continue_watching_click_reload_player_button' => 'To continue watching'. + ', please click \\"Reload Player\\" button', 'replay_from_begin' => 'Replay from begin?', 'automatically_replay_the_movie' => 'Automatically replay movie from the moment you most recently watched at', - 'thank_you_for_submitting_error_message' => 'Thank you for submitting error message. We will fix errors as soon as possible', + 'thank_you_for_submitting_error_message' => 'Thank you for submitting error message.' + .' We will fix errors as soon as possible', 'or_click_on_buttons_listed_below' => 'or click on buttons listed below', 'adult_content_warning' => 'Adult Content Warning!', 'movies_banner' => 'Movies page banner', @@ -143,4 +145,5 @@ 'import' => 'Import', 'subtitles' => 'Subtitles', 'movie_reports' => 'Reports', + 'is_paid' => 'Is Paid', ]; diff --git a/src/routes/admin.php b/src/routes/admin.php index 5f508ef..1dd4a44 100644 --- a/src/routes/admin.php +++ b/src/routes/admin.php @@ -2,7 +2,7 @@ /** * JUZAWEB CMS - The Best CMS for Laravel Project * - * @package juzaweb/juzacms + * @package juzaweb/cms * @author The Anh Dang * @link https://juzaweb.com/cms * @license MIT