From 4278e110fcf0d335fb70a589d1c0549a23c0acaf Mon Sep 17 00:00:00 2001 From: uli Date: Tue, 21 Feb 2017 20:09:46 +0000 Subject: [PATCH] =?UTF-8?q?*=20Startseite=20*=20Sidebar-Widgets:=20Reisema?= =?UTF-8?q?gazin,=20Reisef=C3=BChrer,=20Angebote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3301 f459cee4-fb09-11de-96c3-f9c5f16c3c76 --- trunk/app/Resources/views/base.html.twig | 1 + .../views/default/components/footer.html.twig | 4 +- .../components/multiPageBoxCarousel.html.twig | 37 +++ .../default/components/pageBox.html.twig | 12 +- .../default/components/pageBoxImage.html.twig | 11 + .../default/components/sidebar.html.twig | 95 +------ .../sidebar/pageSliderSidebarWidget.html.twig | 41 +++ .../sidebar/textSliderSidebarWidget.html.twig | 25 ++ .../views/default/pages/home.html.twig | 266 +----------------- .../Controller/DefaultController.php | 62 ++-- trunk/src/AppBundle/Entity/PageRepository.php | 69 +++++ .../AppBundle/Resources/public/js/custom.js | 63 ++++- 12 files changed, 305 insertions(+), 381 deletions(-) create mode 100644 trunk/app/Resources/views/default/components/multiPageBoxCarousel.html.twig create mode 100644 trunk/app/Resources/views/default/components/pageBoxImage.html.twig create mode 100644 trunk/app/Resources/views/default/components/sidebar/pageSliderSidebarWidget.html.twig create mode 100644 trunk/app/Resources/views/default/components/sidebar/textSliderSidebarWidget.html.twig diff --git a/trunk/app/Resources/views/base.html.twig b/trunk/app/Resources/views/base.html.twig index 6bf30fa5..e2fb3444 100644 --- a/trunk/app/Resources/views/base.html.twig +++ b/trunk/app/Resources/views/base.html.twig @@ -49,6 +49,7 @@ %} {% endstylesheets %} + {# TODO Move to custom.css #} {% endblock stylesheets %} diff --git a/trunk/app/Resources/views/default/components/footer.html.twig b/trunk/app/Resources/views/default/components/footer.html.twig index 63332552..c19572aa 100644 --- a/trunk/app/Resources/views/default/components/footer.html.twig +++ b/trunk/app/Resources/views/default/components/footer.html.twig @@ -11,11 +11,11 @@
- Kontaktformular + Kontaktformular
diff --git a/trunk/app/Resources/views/default/components/multiPageBoxCarousel.html.twig b/trunk/app/Resources/views/default/components/multiPageBoxCarousel.html.twig new file mode 100644 index 00000000..e0555899 --- /dev/null +++ b/trunk/app/Resources/views/default/components/multiPageBoxCarousel.html.twig @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/trunk/app/Resources/views/default/components/pageBox.html.twig b/trunk/app/Resources/views/default/components/pageBox.html.twig index 00ede503..a728fd9d 100644 --- a/trunk/app/Resources/views/default/components/pageBox.html.twig +++ b/trunk/app/Resources/views/default/components/pageBox.html.twig @@ -15,17 +15,7 @@ {% endif %}
- {% if child_page.boxImageUrl is not empty %} - {% set image_url = child_page.boxImageUrl %} - {% set image_alt = child_page.travelProgram.title|default(child_page.title) %} - {% elseif child_page.travelProgram is not empty and child_page.travelProgram.previewImage is not empty %} - {% set image_url = '/uploads/travel_program/' ~ child_page.travelProgram.previewImage.fileNameWithExtension %} - {% set image_alt = child_page.title %} - {% else %} - {% set image_url = '/bundles/app/images/no-picture.png' %} - {% set image_alt = 'Kein Vorschaubild vorhanden' %} - {% endif %} - {{ image_alt  }} + {% include 'default/components/pageBoxImage.html.twig' with {page: child_page} %}
diff --git a/trunk/app/Resources/views/default/components/pageBoxImage.html.twig b/trunk/app/Resources/views/default/components/pageBoxImage.html.twig new file mode 100644 index 00000000..17498a64 --- /dev/null +++ b/trunk/app/Resources/views/default/components/pageBoxImage.html.twig @@ -0,0 +1,11 @@ +{% if page.boxImageUrl is not empty %} + {% set image_url = page.boxImageUrl %} + {% set image_alt = page.travelProgram.title|default(page.title) %} +{% elseif page.travelProgram is not empty and page.travelProgram.previewImage is not empty %} + {% set image_url = '/uploads/travel_program/' ~ page.travelProgram.previewImage.fileNameWithExtension %} + {% set image_alt = page.title %} +{% else %} + {% set image_url = '/bundles/app/images/no-picture.png' %} + {% set image_alt = 'Kein Vorschaubild vorhanden' %} +{% endif %} +{{ image_alt  }} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/components/sidebar.html.twig b/trunk/app/Resources/views/default/components/sidebar.html.twig index 72b29519..36618857 100644 --- a/trunk/app/Resources/views/default/components/sidebar.html.twig +++ b/trunk/app/Resources/views/default/components/sidebar.html.twig @@ -47,93 +47,16 @@
+ {% if (show_travel_guide_sidebar_widget ?? true) and page is defined and page.country is not empty %} + {{ render(controller('AppBundle:Default:travelGuideSidebarWidget', {country: page.country})) }} + {% endif %} -
-
- Video -
-
-
-
-
- - - - - - -
-
-
Unser Video des Tages
-

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

-
-
-
-
+ {% if (show_travel_magazine_sidebar_widget ?? true) and page is defined and page.country is not empty %} + {{ render(controller('AppBundle:Default:travelMagazineSidebarWidget', {country: page.country})) }} + {% endif %} -
- zurück - weiter -
- -
- - - - -
-
- Reiseführer -
- -
- - -
-
- Reisemagazin -
- -
- -
-
- Angebote -
- - -
- zurück - weiter -
- -
+ {% if (show_offers_sidebar_widget ?? true) and page is defined and page.country is not empty %} + {{ render(controller('AppBundle:Default:offersSidebarWidget', {country: page.country})) }} + {% endif %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/components/sidebar/pageSliderSidebarWidget.html.twig b/trunk/app/Resources/views/default/components/sidebar/pageSliderSidebarWidget.html.twig new file mode 100644 index 00000000..abbbdd1b --- /dev/null +++ b/trunk/app/Resources/views/default/components/sidebar/pageSliderSidebarWidget.html.twig @@ -0,0 +1,41 @@ +{% if pages is not empty %} +
+ +
+ {{ slider_title }} +
+ + + +
+{% endif %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/components/sidebar/textSliderSidebarWidget.html.twig b/trunk/app/Resources/views/default/components/sidebar/textSliderSidebarWidget.html.twig new file mode 100644 index 00000000..c365bec0 --- /dev/null +++ b/trunk/app/Resources/views/default/components/sidebar/textSliderSidebarWidget.html.twig @@ -0,0 +1,25 @@ +{% if slides is not empty %} +
+ +
+ {{ slider_title }} +
+ +
+ + {% for slide in slides %} + +
{{ slide.title }}
+

{{ slide.boxBody|default(slide.description) }}

+
+ {% endfor %} + +
+ zurück + weiter +
+ +
+ +
+{% endif %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/home.html.twig b/trunk/app/Resources/views/default/pages/home.html.twig index 705ef305..08299c76 100644 --- a/trunk/app/Resources/views/default/pages/home.html.twig +++ b/trunk/app/Resources/views/default/pages/home.html.twig @@ -12,141 +12,14 @@ {% block body %}
Unsere beliebtesten Kulturreisen
- + {% include 'default/components/multiPageBoxCarousel.html.twig' with {pages: offers} %}
Alle Reisekategorien auf einem Blick
- + {% include 'default/components/multiPageBoxCarousel.html.twig' with {pages: country_pages} %}
@@ -162,139 +35,4 @@
- -
-

Weiterführende Links

- -
{% endblock body %} \ No newline at end of file diff --git a/trunk/src/AppBundle/Controller/DefaultController.php b/trunk/src/AppBundle/Controller/DefaultController.php index 3bcce590..d62d8838 100644 --- a/trunk/src/AppBundle/Controller/DefaultController.php +++ b/trunk/src/AppBundle/Controller/DefaultController.php @@ -5,7 +5,7 @@ namespace AppBundle\Controller; use AppBundle\Entity\BreadcrumbEntry; use AppBundle\Entity\ContactRequest; use AppBundle\Entity\Page; -use AppBundle\Entity\TravelProgram; +use AppBundle\Entity\TravelCountry; use AppBundle\Form\ContactRequestType; use AppBundle\Form\SearchRequestType; use AppBundle\Form\TtSearchRequestType; @@ -16,7 +16,6 @@ use Gedmo\Tree\TreeListener; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Stopwatch\Stopwatch; class DefaultController extends Controller { @@ -44,6 +43,8 @@ class DefaultController extends Controller 'show_search_sidebar_widget' => false, 'search_form' => $this->createForm(SearchRequestType::class)->createView(), 'tt_search_form' => $this->createForm(TtSearchRequestType::class)->createView(), + 'offers' => $this->getEntityManager()->getRepository('AppBundle:Page')->findOffers(), + 'country_pages' => $this->getEntityManager()->getRepository('AppBundle:Page')->findCountryPages(), ]); } @@ -256,7 +257,7 @@ class DefaultController extends Controller $this->get('mailer')->send(\Swift_Message::newInstance() ->setSubject('Kontaktformular (stern-tours.de)') ->setFrom('stern@stern-tours.de', 'STERN TOURS') - ->setTo('ulrich.hecht@hecht-software.de') + ->setTo('stern@stern-tours.de') ->setBody( $this->renderView('default/email/contactServiceEmail.txt.twig', [ 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, @@ -284,19 +285,7 @@ class DefaultController extends Controller public function headerAction() { - $qb = $this->getEntityManager()->createQueryBuilder(); - $navPages = $qb - ->from('AppBundle:Page', 'page') - ->select('page') - ->leftJoin('page.children', 'childPage', Expr\Join::WITH, 'childPage.status > 0') - ->addSelect('childPage') - ->where('page.status > 0') - ->andWhere('page.template = \'overview\'') - ->andWhere('page.lvl = 0') - ->orderBy('page.lft,page.title,childPage.lft,childPage.title') - ->getQuery() - ->execute() - ; + $navPages = $this->getEntityManager()->getRepository('AppBundle:Page')->findTopCountryNavPages(); return $this->render('default/components/header.html.twig', [ 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, 'nav_pages' => $navPages, @@ -383,6 +372,47 @@ class DefaultController extends Controller ]); } + public function travelGuideSidebarWidgetAction(TravelCountry $country) + { + $repo = $this->getEntityManager()->getRepository('AppBundle:Page'); + $rootPage = $repo->find(13); + $pages = $repo->getChildrenQueryBuilder($rootPage) + ->andWhere('IDENTITY(node.country) = '. $country->getId()) + ->setMaxResults(3) + ->getQuery() + ->execute() + ; + return $this->render('default/components/sidebar/textSliderSidebarWidget.html.twig', [ + 'slider_title' => 'Reiseführer', + 'slides' => $pages + ]); + } + + public function travelMagazineSidebarWidgetAction(TravelCountry $country) + { + $repo = $this->getEntityManager()->getRepository('AppBundle:Page'); + $rootPage = $repo->find(2803); + $pages = $repo->getChildrenQueryBuilder($rootPage) + ->andWhere('IDENTITY(node.country) = '. $country->getId()) + ->setMaxResults(3) + ->getQuery() + ->execute() + ; + return $this->render('default/components/sidebar/textSliderSidebarWidget.html.twig', [ + 'slider_title' => 'Reisemagazin', + 'slides' => $pages + ]); + } + + public function offersSidebarWidgetAction(TravelCountry $country) + { + $pages = $this->getEntityManager()->getRepository('AppBundle:Page')->findWithTravelProgramsOfCountry($country); + return $this->render('default/components/sidebar/pageSliderSidebarWidget.html.twig', [ + 'slider_title' => 'Angebote', + 'pages' => $pages + ]); + } + /* Suche Kindknoten Für jeden Kindknoten diff --git a/trunk/src/AppBundle/Entity/PageRepository.php b/trunk/src/AppBundle/Entity/PageRepository.php index 1f3f788b..7016cda0 100644 --- a/trunk/src/AppBundle/Entity/PageRepository.php +++ b/trunk/src/AppBundle/Entity/PageRepository.php @@ -1,7 +1,9 @@ createQueryBuilder('node') + ->innerJoin('node.travelProgram', 'tp') + ->innerJoin('tp.countries', 'c') + ->where('c.id = '. $country->getId()) + ->getQuery() + ->execute() + ; + } + + /** + * @return Page[] + */ + public function findOffers() + { + $ret = []; + $countries = $this->getEntityManager()->getRepository('AppBundle:TravelCountry')->findAll(); + foreach ($countries as $country) + { + $ret = array_merge($ret, $this->createQueryBuilder('node') + ->innerJoin('node.travelProgram', 'tp') + ->addSelect('tp') + ->innerJoin('tp.countries', 'c') + ->where('c.id = '. $country->getId()) + ->andWhere('node.status > 0') + ->andWhere('tp.status > 0') + ->orderBy('node.order') + ->addOrderBy('tp.position') + ->addOrderBy('node.title') + ->setMaxResults(3) + ->getQuery() + ->execute() + ); + } + shuffle($ret); + return $ret; + } + + public function findCountryPages() + { + return $this->createQueryBuilder('node') + ->innerJoin('node.country', 'country') + ->where('node.status > 0') + ->andWhere('node.template = \'overview\'') + ->andWhere('node.lvl = 0') + ->orderBy('node.lft,node.title') + ->getQuery() + ->execute() + ; + } + + public function findTopCountryNavPages() + { + return $this->createQueryBuilder('node') + ->innerJoin('node.country', 'country') + ->leftJoin('node.children', 'childPage', Expr\Join::WITH, 'childPage.status > 0') + ->addSelect('childPage') + ->where('node.status > 0') + ->andWhere('node.template = \'overview\'') + ->andWhere('node.lvl = 0') + ->orderBy('node.lft,node.title,childPage.lft,childPage.title') + ->getQuery() + ->execute() + ; + } + /** * @param Page $page * diff --git a/trunk/src/AppBundle/Resources/public/js/custom.js b/trunk/src/AppBundle/Resources/public/js/custom.js index d2426d6d..af17c78e 100644 --- a/trunk/src/AppBundle/Resources/public/js/custom.js +++ b/trunk/src/AppBundle/Resources/public/js/custom.js @@ -2,7 +2,7 @@ jQuery(document).ready(function($) { "use strict"; /* ============================================== - VIDEOS + VIDEOS --> =============================================== */ var videos$ = $('a[id^="video_"]'); @@ -61,7 +61,7 @@ jQuery(document).ready(function($) { }); /* ============================================== - KEYWORDS + KEYWORDS --> =============================================== */ var modal$ = $('#st-default-modal'); @@ -77,6 +77,65 @@ jQuery(document).ready(function($) { return false; }); + /* ============================================== + SIDEBAR BOX SLIDER --> + =============================================== */ + + function createSlider(ctx$) + { + function setSlideInterval() + { + if(slideInterval) + { + clearInterval(slideInterval); + } + slideInterval = setInterval(function() { + + jumpToNextSlide(); + }, 5000); + } + + function jumpToNextSlide() + { + setActiveSlide(slideIndex === slideCount - 1 ? 0 : slideIndex + 1); + setSlideInterval(); + } + + function setActiveSlide(newIndex) + { + slide$s[slideIndex].removeClass('active'); + slideIndex = newIndex; + slide$s[slideIndex].addClass('active'); + } + + var slides$ = $('.slide', ctx$); + var slideCount = slides$.length; + if(slideCount > 1) + { + var slideInterval; + + var slide$s = []; + for(var i = 0; i < slideCount; ++i) + { + slide$s.push($(slides$.get(i))); + } + + var slideIndex = 0; + setSlideInterval(); + + $('.item-button-next', ctx$).click(function() { + jumpToNextSlide(); + }); + $('.item-button-prev', ctx$).click(function() { + setActiveSlide(slideIndex === 0 ? slideCount - 1 : slideIndex - 1); + setSlideInterval(); + }); + } + } + $('.box-slider').each(function() { + createSlider($(this)); + }); + /* ============================================== HEADER STICKY --> =============================================== */