Merge branch 'develop' of github.com:Rudloff/alltube into develop

This commit is contained in:
Pierre Rudloff 2016-10-26 17:16:36 +02:00
commit bd26756246

View file

@ -46,6 +46,13 @@ class FrontController
*/ */
private $sessionSegment; private $sessionSegment;
/**
* Smarty view.
*
* @var \Slim\Views\Smarty
*/
private $view;
/** /**
* FrontController constructor. * FrontController constructor.
* *
@ -56,6 +63,7 @@ class FrontController
$this->config = Config::getInstance(); $this->config = Config::getInstance();
$this->download = new VideoDownload(); $this->download = new VideoDownload();
$this->container = $container; $this->container = $container;
$this->view = $this->container->get('view');
$session_factory = new \Aura\Session\SessionFactory(); $session_factory = new \Aura\Session\SessionFactory();
$session = $session_factory->newInstance($_COOKIE); $session = $session_factory->newInstance($_COOKIE);
$this->sessionSegment = $session->getSegment('Alltube\Controller\FrontController'); $this->sessionSegment = $session->getSegment('Alltube\Controller\FrontController');
@ -71,17 +79,15 @@ class FrontController
*/ */
public function index(Request $request, Response $response) public function index(Request $request, Response $response)
{ {
if ($this->container instanceof Container) { $this->view->render(
$this->container->view->render( $response,
$response, 'index.tpl',
'index.tpl', [
[ 'convert' => $this->config->convert,
'convert' => $this->config->convert, 'class' => 'index',
'class' => 'index', 'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.', ]
] );
);
}
} }
/** /**
@ -94,19 +100,17 @@ class FrontController
*/ */
public function extractors(Request $request, Response $response) public function extractors(Request $request, Response $response)
{ {
if ($this->container instanceof Container) { $this->view->render(
$this->container->view->render( $response,
$response, 'extractors.tpl',
'extractors.tpl', [
[ 'extractors' => $this->download->listExtractors(),
'extractors' => $this->download->listExtractors(), 'class' => 'extractors',
'class' => 'extractors', 'title' => 'Supported websites',
'title' => 'Supported websites', 'description' => 'List of all supported websites from which Alltube Download '.
'description' => 'List of all supported websites from which Alltube Download '. 'can extract video or audio files',
'can extract video or audio files', ]
] );
);
}
} }
/** /**
@ -119,17 +123,15 @@ class FrontController
*/ */
public function password(Request $request, Response $response) public function password(Request $request, Response $response)
{ {
if ($this->container instanceof Container) { $this->view->render(
$this->container->view->render( $response,
$response, 'password.tpl',
'password.tpl', [
[ 'class' => 'password',
'class' => 'password', 'title' => 'Password prompt',
'title' => 'Password prompt', 'description' => 'You need a password in order to download this video with Alltube Download',
'description' => 'You need a password in order to download this video with Alltube Download', ]
] );
);
}
} }
/** /**
@ -176,18 +178,16 @@ class FrontController
} catch (PasswordException $e) { } catch (PasswordException $e) {
return $this->password($request, $response); return $this->password($request, $response);
} }
if ($this->container instanceof Container) { $this->view->render(
$this->container->view->render( $response,
$response, 'video.tpl',
'video.tpl', [
[ 'video' => $video,
'video' => $video, 'class' => 'video',
'class' => 'video', 'title' => $video->title,
'title' => $video->title, 'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
'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'));
@ -205,17 +205,15 @@ class FrontController
*/ */
public function error(Request $request, Response $response, \Exception $exception) public function error(Request $request, Response $response, \Exception $exception)
{ {
if ($this->container instanceof Container) { $this->view->render(
$this->container->view->render( $response,
$response, 'error.tpl',
'error.tpl', [
[ 'errors' => $exception->getMessage(),
'errors' => $exception->getMessage(), 'class' => 'video',
'class' => 'video', 'title' => 'Error',
'title' => 'Error', ]
] );
);
}
return $response->withStatus(500); return $response->withStatus(500);
} }