Merge branch 'develop' into feature/stream

This commit is contained in:
Pierre Rudloff 2016-10-13 17:30:30 +02:00
commit b3632ccd69

View file

@ -47,9 +47,7 @@ class FrontController
{ {
$this->config = Config::getInstance(); $this->config = Config::getInstance();
$this->download = new VideoDownload(); $this->download = new VideoDownload();
if ($container instanceof Container) { $this->container = $container;
$this->container = $container;
}
} }
/** /**
@ -62,15 +60,17 @@ class FrontController
*/ */
public function index(Request $request, Response $response) public function index(Request $request, Response $response)
{ {
$this->container->view->render( if ($this->container instanceof Container) {
$response, $this->container->view->render(
'index.tpl', $response,
[ 'index.tpl',
'convert' => $this->config->convert, [
'class' => 'index', 'convert' => $this->config->convert,
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.', 'class' => 'index',
] 'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
); ]
);
}
} }
/** /**
@ -83,17 +83,19 @@ class FrontController
*/ */
public function extractors(Request $request, Response $response) public function extractors(Request $request, Response $response)
{ {
$this->container->view->render( if ($this->container instanceof Container) {
$response, $this->container->view->render(
'extractors.tpl', $response,
[ 'extractors.tpl',
'extractors' => $this->download->listExtractors(), [
'class' => 'extractors', 'extractors' => $this->download->listExtractors(),
'title' => 'Supported websites', 'class' => 'extractors',
'description' => 'List of all supported websites from which Alltube Download '. 'title' => 'Supported websites',
'can extract video or audio files', 'description' => 'List of all supported websites from which Alltube Download '.
] 'can extract video or audio files',
); ]
);
}
} }
/** /**
@ -129,16 +131,18 @@ class FrontController
} }
} else { } else {
$video = $this->download->getJSON($params['url']); $video = $this->download->getJSON($params['url']);
$this->container->view->render( if ($this->container instanceof Container) {
$response, $this->container->view->render(
'video.tpl', $response,
[ 'video.tpl',
'video' => $video, [
'class' => 'video', 'video' => $video,
'title' => $video->title, 'class' => 'video',
'description' => 'Download "'.$video->title.'" from '.$video->extractor_key, 'title' => $video->title,
] 'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
); ]
);
}
} }
} else { } else {
return $response->withRedirect($this->container->get('router')->pathFor('index')); return $response->withRedirect($this->container->get('router')->pathFor('index'));
@ -156,15 +160,17 @@ class FrontController
*/ */
public function error(Request $request, Response $response, \Exception $exception) public function error(Request $request, Response $response, \Exception $exception)
{ {
$this->container->view->render( if ($this->container instanceof Container) {
$response, $this->container->view->render(
'error.tpl', $response,
[ 'error.tpl',
'errors' => $exception->getMessage(), [
'class' => 'video', 'errors' => $exception->getMessage(),
'title' => 'Error', 'class' => 'video',
] 'title' => 'Error',
); ]
);
}
return $response->withStatus(500); return $response->withStatus(500);
} }