From fc73459731969c52d808080a9dd607902e35eb34 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 1 Aug 2016 01:01:10 +0200 Subject: [PATCH] Use template includes --- controllers/FrontController.php | 50 ++++++--------------------------- templates/error.tpl | 6 ++-- templates/extractors.tpl | 6 +++- templates/{ => inc}/footer.tpl | 0 templates/{ => inc}/head.tpl | 0 templates/{ => inc}/header.tpl | 0 templates/{ => inc}/logo.tpl | 0 templates/index.tpl | 5 +++- templates/video.tpl | 4 ++- 9 files changed, 24 insertions(+), 47 deletions(-) rename templates/{ => inc}/footer.tpl (100%) rename templates/{ => inc}/head.tpl (100%) rename templates/{ => inc}/header.tpl (100%) rename templates/{ => inc}/logo.tpl (100%) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 17f28ac..cbedd12 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -50,24 +50,13 @@ class FrontController { $this->container->view->render( $response, - 'head.tpl', + 'index.tpl', array( + 'convert'=>$this->config->convert, 'class'=>'index', 'description'=>'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.' ) ); - $this->container->view->render( - $response, - 'header.tpl' - ); - $this->container->view->render( - $response, - 'index.tpl', - array( - 'convert'=>$this->config->convert - ) - ); - $this->container->view->render($response, 'footer.tpl'); } /** @@ -82,24 +71,15 @@ class FrontController { $this->container->view->render( $response, - 'head.tpl', + 'extractors.tpl', array( + 'extractors'=>$this->download->listExtractors(), 'class'=>'extractors', 'title'=>'Supported websites', 'description' =>'List of all supported websites from which Alltube Download can extract video or audio files' ) ); - $this->container->view->render($response, 'header.tpl'); - $this->container->view->render($response, 'logo.tpl'); - $this->container->view->render( - $response, - 'extractors.tpl', - array( - 'extractors'=>$this->download->listExtractors() - ) - ); - $this->container->view->render($response, 'footer.tpl'); } /** @@ -137,21 +117,14 @@ class FrontController $video = $this->download->getJSON($params["url"]); $this->container->view->render( $response, - 'head.tpl', + 'video.tpl', array( + 'video'=>$video, 'class'=>'video', 'title'=>$video->title, 'description'=>'Download "'.$video->title.'" from '.$video->extractor_key ) ); - $this->container->view->render( - $response, - 'video.tpl', - array( - 'video'=>$video - ) - ); - $this->container->view->render($response, 'footer.tpl'); } } else { return $response->withRedirect($this->container->get('router')->pathFor('index')); @@ -162,20 +135,13 @@ class FrontController { $this->container->view->render( $response, - 'head.tpl', + 'error.tpl', array( + 'errors'=>$exception->getMessage(), 'class'=>'video', 'title'=>'Error' ) ); - $this->container->view->render( - $response, - 'error.tpl', - array( - 'errors'=>$exception->getMessage() - ) - ); - $this->container->view->render($response, 'footer.tpl'); return $response->withStatus(500); } diff --git a/templates/error.tpl b/templates/error.tpl index d000ab3..67a0fae 100644 --- a/templates/error.tpl +++ b/templates/error.tpl @@ -1,6 +1,7 @@ +{include file='inc/head.tpl'}
- {include file="logo.tpl"} + {include file="inc/logo.tpl"}

An error occured

Please check the URL of your video.

@@ -9,4 +10,5 @@
{/foreach}

-
+
+{include file='inc/footer.tpl'} diff --git a/templates/extractors.tpl b/templates/extractors.tpl index 076f99e..4944193 100644 --- a/templates/extractors.tpl +++ b/templates/extractors.tpl @@ -1,8 +1,12 @@ +{include file='inc/head.tpl'} +{include file='inc/header.tpl'} +{include file='inc/logo.tpl'}

Supported websites

-
+{include file='inc/footer.tpl'} diff --git a/templates/footer.tpl b/templates/inc/footer.tpl similarity index 100% rename from templates/footer.tpl rename to templates/inc/footer.tpl diff --git a/templates/head.tpl b/templates/inc/head.tpl similarity index 100% rename from templates/head.tpl rename to templates/inc/head.tpl diff --git a/templates/header.tpl b/templates/inc/header.tpl similarity index 100% rename from templates/header.tpl rename to templates/inc/header.tpl diff --git a/templates/logo.tpl b/templates/inc/logo.tpl similarity index 100% rename from templates/logo.tpl rename to templates/inc/logo.tpl diff --git a/templates/index.tpl b/templates/index.tpl index 5d046e6..93f44eb 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,4 +1,6 @@ -
+{include file='inc/head.tpl'} +{include file='inc/header.tpl'} +
@@ -27,3 +29,4 @@
+{include file='inc/footer.tpl'} diff --git a/templates/video.tpl b/templates/video.tpl index daaf3cc..e3790b1 100644 --- a/templates/video.tpl +++ b/templates/video.tpl @@ -1,7 +1,8 @@ +{include file="inc/head.tpl"}
-{include file="logo.tpl"} +{include file="inc/logo.tpl"}

You are going to download