20 <div class="text-gray-400 opacity-25">
21 <svg xmlns="http://www.w3.org/2000/svg" class="w-10/12" viewBox="0 0 24 24">
22 <path fill="currentColor" d="M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm.001 6c-.001 0-.001 0 0 0h-.466l-2.667-4H20l.001 4zm-5.466 0-2.667-4h2.596l2.667 4h-2.596zm-2.404 0H9.535L6.869 5h2.596l2.666 4zM4 5h.465l2.667 4H4V5z"></path>
27 <div class="w-9/12 md:w-10/12 px-3 md:px-4 flex flex-col justify-between text-sm">
29 <a fire title="watch <?= $isTv ? $video->name : $video->title ?> online HD" href="<?= $slug ?>" class="flex items-start text-gray-200 font-semibold"><?= $isTv ? $video->name : $video->title ?></a>
30 <span style="cursor:default" class="text-gray-400 block my-[2px]"><?= Time::dateFormat($isTv ? $video->first_air_date : $video->release_date) ?></span>
32 <?= $video->genres(fn ($genres) => join(', ', array_map(fn ($id, $title) => sprintf('<a fire href="%s" title="watch %s videos online HD">%s</a>', url('genre', ['type' => $isTv ? 'tv' : 'movie', 'slug' => Str::slugif($title ?? '') . '-' . $id]), htmlspecialchars($title, ENT_QUOTES, 'UTF-8'), htmlspecialchars($title, ENT_QUOTES, 'UTF-8')), array_keys($genres), array_values($genres)))) ?>
36 <?php if (isset($key)) : ?>
37 <span class="text-gray-400 text-2xl font-light mr-1"><?= $key ?></span>
20 <div class="text-gray-400 opacity-25">
21 <svg xmlns="http://www.w3.org/2000/svg" class="w-10/12" viewBox="0 0 24 24">
22 <path fill="currentColor" d="M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm.001 6c-.001 0-.001 0 0 0h-.466l-2.667-4H20l.001 4zm-5.466 0-2.667-4h2.596l2.667 4h-2.596zm-2.404 0H9.535L6.869 5h2.596l2.666 4zM4 5h.465l2.667 4H4V5z"></path>
27 <div class="w-9/12 md:w-10/12 px-3 md:px-4 flex flex-col justify-between text-sm">
29 <a fire title="watch <?= $isTv ? $video->name : $video->title ?> online HD" href="<?= $slug ?>" class="flex items-start text-gray-200 font-semibold"><?= $isTv ? $video->name : $video->title ?></a>
30 <span style="cursor:default" class="text-gray-400 block my-[2px]"><?= Time::dateFormat($isTv ? $video->first_air_date : $video->release_date) ?></span>
32 <?= $video->genres(fn ($genres) => join(', ', array_map(fn ($id, $title) => sprintf('<a fire href="%s" title="watch %s videos online HD">%s</a>', url('genre', ['type' => $isTv ? 'tv' : 'movie', 'slug' => Str::slugif($title ?? '') . '-' . $id]), htmlspecialchars($title, ENT_QUOTES, 'UTF-8'), htmlspecialchars($title, ENT_QUOTES, 'UTF-8')), array_keys($genres), array_values($genres)))) ?>
36 <?php if (isset($key)) : ?>
37 <span class="text-gray-400 text-2xl font-light mr-1"><?= $key ?></span>
20 <div class="text-gray-400 opacity-25">
21 <svg xmlns="http://www.w3.org/2000/svg" class="w-10/12" viewBox="0 0 24 24">
22 <path fill="currentColor" d="M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm.001 6c-.001 0-.001 0 0 0h-.466l-2.667-4H20l.001 4zm-5.466 0-2.667-4h2.596l2.667 4h-2.596zm-2.404 0H9.535L6.869 5h2.596l2.666 4zM4 5h.465l2.667 4H4V5z"></path>
27 <div class="w-9/12 md:w-10/12 px-3 md:px-4 flex flex-col justify-between text-sm">
29 <a fire title="watch <?= $isTv ? $video->name : $video->title ?> online HD" href="<?= $slug ?>" class="flex items-start text-gray-200 font-semibold"><?= $isTv ? $video->name : $video->title ?></a>
30 <span style="cursor:default" class="text-gray-400 block my-[2px]"><?= Time::dateFormat($isTv ? $video->first_air_date : $video->release_date) ?></span>
32 <?= $video->genres(fn ($genres) => join(', ', array_map(fn ($id, $title) => sprintf('<a fire href="%s" title="watch %s videos online HD">%s</a>', url('genre', ['type' => $isTv ? 'tv' : 'movie', 'slug' => Str::slugif($title ?? '') . '-' . $id]), htmlspecialchars($title, ENT_QUOTES, 'UTF-8'), htmlspecialchars($title, ENT_QUOTES, 'UTF-8')), array_keys($genres), array_values($genres)))) ?>
36 <?php if (isset($key)) : ?>
37 <span class="text-gray-400 text-2xl font-light mr-1"><?= $key ?></span>
54 public function __set($name, $value)
56 $this->data[$name] = $value;
59 public function __call($name, $arguments)
61 $callback = array_shift($arguments);
63 if (isset($callback)) {
64 array_unshift($arguments, $this->get($name));
66 return call_user_func($callback, ...$arguments);
69 return $this->get($name);
20 <div class="text-gray-400 opacity-25">
21 <svg xmlns="http://www.w3.org/2000/svg" class="w-10/12" viewBox="0 0 24 24">
22 <path fill="currentColor" d="M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm.001 6c-.001 0-.001 0 0 0h-.466l-2.667-4H20l.001 4zm-5.466 0-2.667-4h2.596l2.667 4h-2.596zm-2.404 0H9.535L6.869 5h2.596l2.666 4zM4 5h.465l2.667 4H4V5z"></path>
27 <div class="w-9/12 md:w-10/12 px-3 md:px-4 flex flex-col justify-between text-sm">
29 <a fire title="watch <?= $isTv ? $video->name : $video->title ?> online HD" href="<?= $slug ?>" class="flex items-start text-gray-200 font-semibold"><?= $isTv ? $video->name : $video->title ?></a>
30 <span style="cursor:default" class="text-gray-400 block my-[2px]"><?= Time::dateFormat($isTv ? $video->first_air_date : $video->release_date) ?></span>
32 <?= $video->genres(fn ($genres) => join(', ', array_map(fn ($id, $title) => sprintf('<a fire href="%s" title="watch %s videos online HD">%s</a>', url('genre', ['type' => $isTv ? 'tv' : 'movie', 'slug' => Str::slugif($title ?? '') . '-' . $id]), htmlspecialchars($title, ENT_QUOTES, 'UTF-8'), htmlspecialchars($title, ENT_QUOTES, 'UTF-8')), array_keys($genres), array_values($genres)))) ?>
36 <?php if (isset($key)) : ?>
37 <span class="text-gray-400 text-2xl font-light mr-1"><?= $key ?></span>
135 public function requireOnce(...$args)
137 return $this->selfLoad('require_once', ...$args);
140 public function component(string $component, array $params = []): self
145 include $this->viewLocation($component);
149 protected function selfLoad(string $type, string $file, array $params = []): self
151 $params = array_merge($this->params, $params);
157 include_once $this->viewLocation($file);
1
<?php if (isset($similar) && !empty($similar)) : ?>
2 <div class="mt-10 text-left">
3 <h2 class="font-semibold text-xl md:text-2xl border-amber-400 border-b-4 inline-block leading-10 mb-2"><?= translate($isTv ? 'Recommended Tv Series' : 'Recommended Movies') ?></h2>
4 <div class="mt-3 grid grid-cols-1 lg:grid-cols-2 gap-5">
5 <?php foreach (array_slice($similar, 0, 20) as $video) {
6 $this->component('components.video-list', ['video' => $video]);
157 include_once $this->viewLocation($file);
160 require_once $this->viewLocation($file);
163 require $this->viewLocation($file);
166 include $this->viewLocation($file);
172 protected function viewLocation(string $file): string
174 return $this->directoryParse(sprintf('%s/%s', stripos($file, sweet_view_root_dir()) === false ? ($this->resource_dir ?? '') : sweet_view_root_dir(), str_replace(['.'], '/', str_ireplace(sweet_view_root_dir(), '', $this->removeExtension($file))))) . $this->getExtension();
177 protected function directoryParse(string $path): string
179 return rtrim(str_replace(['///', '//', '/', (DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR)], DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR);
111 $this->extension = $extension;
115 public function getExtension(): string
117 return $this->extension ?? '.php';
120 public function include(...$args)
122 return $this->selfLoad('include', ...$args);
125 public function require(...$args)
127 return $this->selfLoad('require', ...$args);
130 public function includeOnce(...$args)
132 return $this->selfLoad('include_once', ...$args);
135 public function requireOnce(...$args)
6 <span class="text-gray-400 font-semibold">(<?= date('Y', strtotime($isTv ? $video->first_air_date : $video->release_date)) ?>)</span>
8 <?php $this->include('includes.video.parts.share') ?>
10 <section x-data="{tabOpen: 'details'}" class="mt-5 text-center sm:text-left">
12 ->include('includes.video.parts.tabs')
13 ->include('includes.video.parts.details')
14 ->include('includes.video.parts.season')
15 ->include('includes.video.parts.clip')
16 ->include('includes.video.parts.people')
17 ->include('includes.video.similar')
157 include_once $this->viewLocation($file);
160 require_once $this->viewLocation($file);
163 require $this->viewLocation($file);
166 include $this->viewLocation($file);
172 protected function viewLocation(string $file): string
174 return $this->directoryParse(sprintf('%s/%s', stripos($file, sweet_view_root_dir()) === false ? ($this->resource_dir ?? '') : sweet_view_root_dir(), str_replace(['.'], '/', str_ireplace(sweet_view_root_dir(), '', $this->removeExtension($file))))) . $this->getExtension();
177 protected function directoryParse(string $path): string
179 return rtrim(str_replace(['///', '//', '/', (DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR)], DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR);
111 $this->extension = $extension;
115 public function getExtension(): string
117 return $this->extension ?? '.php';
120 public function include(...$args)
122 return $this->selfLoad('include', ...$args);
125 public function require(...$args)
127 return $this->selfLoad('require', ...$args);
130 public function includeOnce(...$args)
132 return $this->selfLoad('include_once', ...$args);
135 public function requireOnce(...$args)
68 this.isWatchLater = (this.watchlater.filter((vid) => vid.id == <?= $video->id ?>).length == 1)
72 <?php $this->include('includes.video.player') ?>
74 <div :class="!isPlaying && 'md:mt-[-50px]'" class="container relative z-30 rounded-xl bg-primary-800">
75 <div class="flex py-5" :class="!isPlaying && 'md:px-1'">
77 ->include('includes.video.sidebar')
78 ->include('includes.video.info')
208 public function getContent(string $path, array $params = []): string
210 if (!file_exists($path)) {
211 throw new Exception('view file: ' . $path . ' does not exists');
214 $params = array_merge($this->params, $params);
222 return ob_get_clean();
187 public function templateLocation(): string
189 return $this->viewLocation($this->getTemplate());
192 public function layoutLocation(): string
194 return $this->viewLocation($this->getLayout());
197 public function render(array $params = []): string
199 $content = $this->getContent($this->templateLocation(), $params);
201 if ($this->getLayout() !== null) {
202 $content = str_ireplace('{{content}}', $content, $this->getContent($this->layoutLocation()));
205 return $this->isMinified() ? minify_text($content) : $content;
208 public function getContent(string $path, array $params = []): string
210 if (!file_exists($path)) {
211 throw new Exception('view file: ' . $path . ' does not exists');
21 public function isFireAgent(): bool
23 return strtolower($_SERVER['HTTP_CONTENT_AGENT'] ?? '') === 'fire-view';
26 public function render(array $params = []): string
28 if ($this->isFireAgent()) {
29 return FireBlock::render($this->html, $params);
32 return $this->html->render($params);
35 public function getHtml(): Html
40 public function getContent(string $path, array $params = []): string
42 return $this->html->getContent($path, $params);
45 public function __call($name, $arguments): self
14 public function __construct()
16 $this->engine = new FireView(
22 public function dispatchView(string $template, array $parameters = []): string
24 return $this->getEngine()
26 ->render($parameters);
29 public function getEngine(): FireView
20 return new SweetView(...$args);
23 public function setDriver(IViewDriver $Driver): self
25 $this->Driver = $Driver;
29 public function render(...$args): string
31 return $this->getDriver()->dispatchView(...$args);
34 public function getDriver(): IViewDriver
10 return (defined('ROOT_DIR') ? ROOT_DIR : (function_exists('root_dir') ? root_dir() : getcwd())) . $path;
14 if (!function_exists('view')) {
15 function view(...$args)
17 $engine = SweetView::create(new FireDriver);
22 return func_num_args() == 0 ? $engine : $engine->render(...$args);
26 if (!function_exists('minify_text')) {
27 function minify_text($text = '')
29 return preg_replace(['/^ {2,}/m', '/^\t{2,}/m', '~[\r\n]+~'], '', $text);
33 if (!function_exists('fire_view')) {
34 function fire_view(...$args)
91 $viewModel = new TmdbCollection(
93 $cache->load('genres', fn () => $tmdb->getGenre())
98 $id = substr($slug, strrpos($slug, '-') + 1);
100 $viewModel->addToCollection('similar', TmdbClient::create('tv')->getRelatedVideos($id));
102 return view('video', [
103 'video' => $this->findOrFail($id, 'tv'),
104 'similar' => $viewModel->cut('similar')
109 ->addToCollection('airing-today', $cache->load('airingtoday', fn () => $tmdb->getAiringToday(), '12 hours'))
110 ->addToCollection('popular', $cache->load('popular', fn () => $tmdb->getPopular(), '12 hours'))
111 ->addToCollection('this-week', $cache->load('ontheair', fn () => $tmdb->getOnTheAir(), '12 hours'))
112 ->addToCollection('toprated', $cache->load('toprated', fn () => $tmdb->getTopRated(), '12 hours'));
114 return view('videos', [
115 'top' => $viewModel->cut('toprated'),
68 (is_string($callback) && function_exists($callback))
69 || (is_object($callback) && ($callback instanceof Closure))
71 || (is_array($callback) && method_exists($callback[0], $callback[1]));
74 public static function load($callback, ...$params)
76 if (!self::exists($callback)) {
77 throw new UndefinedMethod((is_array($callback) ? (!is_string($callback[0]) ? get_class($callback[0]) : (string) $callback[0]) . '->' . $callback[1] : $callback) . '() does not exists');
80 return call_user_func($callback, ...array_values($params));
83 public static function create(string $class, ...$args)
85 if (!class_exists($class)) {
86 throw new UndefinedClass('Class: ' . $class . ' does not exists');
89 return new $class(...array_values($args));
92 public static function name($callback): string
107 // set new callback method
108 $route->setCallback([$route->getCallback()[0], $call_method]);
111 // escape grouped/nested named parameter
112 $route->setParameters($this->escapeNestedParameters($route->getParameters()));
114 // trigger route middleware event
115 $this->triggerEvent(IRoute::EVENTS['callback'], $route);
117 // load router callback
118 return CallbackHandler::load(
119 $route->getCallback(),
120 ...CallbackHandler::reflect(
121 $route->getParameters(),
122 $route->getCallback(),
123 array_merge($this->getReflectionParameters(), [$route])
128 public function callMiddlewares($middlewares): void
130 foreach ((array) $middlewares as $middleware) {
131 $class = CallbackHandler::create($middleware);
90 // utilize method required paramiters
91 $route->setParameters(
92 $this->applyFilters(self::FILTER['parameters'], $this->utilizeRouteParam($matches, $route))
98 // create route dispatcher
99 $dispatcher = new RouteDispatcher($this);
101 // dispatch route callback
102 return $dispatcher->dispatch($route);
107 if (isset($this->fallback) && CallbackHandler::exists($this->fallback)) {
108 CallbackHandler::load($this->fallback);
111 // not found any route for this path
112 throw new NotFoundException('the route does not matched..');
97 public static function run(): void
99 // load application initial kernels
100 self::$app->loadKernels('boot');
102 // render router result
103 echo self::$app->router->resolve();
105 // load application initial kernels
106 self::$app->loadKernels('shutdown');
110 * Check Anu Component added to the Application
114 public static function hasComponent(string $key): bool
116 return isset(self::$app->components[$key]);
14 'tmp_dir' => config('app.tmp_dir'),
15 'except' => ['/admin/*', '/embed/*', '/search/*'],
18 // serve from cache if production mode
23 // create a new application instance for this http request
24 Application::create(__DIR__)
25 ->registerKernel(App\Http\Kernels\AppKernel::class)
28 // stop the application execution process