<?php
namespace App\Controller;
use App\AppBundle;
use App\Controller\Traits\IconTrait;
use Pimcore\Config\Config;
use Pimcore\Model\DataObject\Configset;
use SaintElmos\BaseBundle\Services\RemoteData;
use App\Controller\PageBaseController as BasePagecontentController;
use Psr\Container\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use \Pimcore\Model\WebsiteSetting;
use Pimcore\Controller\FrontendController;
//class PagecontentController extends BasePagecontentController
class PagecontentController extends FrontendController
{
use IconTrait;
public $baseParam = [];
public $region_homes_doc;
public function __construct(ContainerInterface $container, RequestStack $requestStack)
{
//echo "<pre>"; print_r($this->baseparams); die;
//parent::__construct($container, $requestStack);
$konfiguration_set_obj = WebsiteSetting::getByName('konfiguration_set')->getData();
$this->baseParam['konfiguration_set_obj'] = $konfiguration_set_obj;
$this->baseParam['startseite'] = AppBundle::getValue($konfiguration_set_obj, 'getStartseite');
// $konfiguration_projekt_obj = \Pimcore\Config::getWebsiteConfig()->get('konfiguration_projekt');
$konfiguration_projekt_obj = WebsiteSetting::getByName('konfiguration_projekt')->getData();
$this->baseParam['konfiguration_projekt_obj'] = $konfiguration_projekt_obj;
$server_protocol = 'http' . ($_SERVER['REQUEST_SCHEME'] == 'https' ? 's' : '');
//$canonical_base = $server_protocol . '://' . $_SERVER['HTTP_HOST'] . $this->document->getFullpath();
//$this->baseParam['path_info'] = $server_protocol . '://' . $_SERVER['HTTP_HOST'] . $this->document->getRealFullpath();
//$this->baseParam['canonical_base'] = $canonical_base;
$this->baseParam['kundenLogoUrl'] = AppBundle::getValue($konfiguration_projekt_obj, 'getLogodomain');
$this->baseParam['domain'] = $server_protocol . '://' . $_SERVER['HTTP_HOST'];
if( method_exists($konfiguration_set_obj,'getStartseite' ) )
{
$startseiteEN = $server_protocol . '://' . $_SERVER['HTTP_HOST'] . $konfiguration_set_obj->getStartseite('en');
}
$this->baseParam['startseiteEN'] = $startseiteEN;
$this->baseParam['sprachweiche_title'] = AppBundle::getValue($konfiguration_projekt_obj, 'getSprachweiche_title');
$this->baseParam['sprachweiche_text'] = AppBundle::getValue($konfiguration_projekt_obj, 'getSprachweiche_text');
$this->baseParam['sprachweiche_button_yes'] = AppBundle::getValue($konfiguration_projekt_obj, 'getSprachweiche_button_yes');
$this->baseParam['sprachweiche_button_no'] = AppBundle::getValue($konfiguration_projekt_obj, 'getSprachweiche_button_no');
/* ********************************************************************************************************************* */
/*
* S P R A C H A U S W A H L
*/
$SprachauswahlArray = array();
// $SprachauswahlBlock = \Pimcore\Config::getWebsiteConfig()->get('konfiguration_projekt')->getSprachauswahl_block();
$SprachauswahlBlock = WebsiteSetting::getByName('konfiguration_projekt')->getData()->getSprachauswahl_block();
$att_text = 'en';
/* $lg = $this->document->getProperty('language');
switch ($lg) {
case 'de':
$att_text = 'en';
break;
case 'en':
$att_text = 'de';
break;
} */
if (count($SprachauswahlBlock) > 0) {
foreach ($SprachauswahlBlock as $key => $element) {
$languageurlArr = $element['languageurl'];
$languageurlObj = $languageurlArr->getData();
$url = $languageurlObj->getHref();
$SprachauswahlArray[$key] = array(
'languagetitle' => $element['languagetitle']->getData(),
'languageurl' => $url,
'att_text' => $att_text
);
}
$this->baseParam['sprachauswahl'] = $SprachauswahlArray;
$this->baseParam['show_sprachauswahl'] = true;
} else {
$this->baseParam['sprachauswahl'] = array();
$this->baseParam['show_sprachauswahl'] = false;
}
/* ********************************************************************************************************************* */
/*
* L O C A T I O N
*/
$this->baseParam['server_protocol'] = $server_protocol;
$this->baseParam['startseite'] = $konfiguration_set_obj->getStartseite();
/* ********************************************************************************************************************* */
/*
* T H E M E
*/
/* $theme = AppBundle::getTheme($this->document, 'theme_doc');
$this->baseParam['theme'] = $theme; */
/* ********************************************************************************************************************* */
/*
* N A V I G A T I O N
*/
$this->baseParam['url_rent'] = AppBundle::getValue($konfiguration_projekt_obj, 'getUrl_rent');
$this->baseParam['text_rent'] = AppBundle::getValue($konfiguration_projekt_obj, 'getText_rent');
$this->baseParam['url_homes'] = AppBundle::getValue($konfiguration_projekt_obj, 'getUrl_homes');
$this->baseParam['text_homes'] = AppBundle::getValue($konfiguration_projekt_obj, 'getText_homes');
$this->baseParam['url_shops'] = AppBundle::getValue($konfiguration_projekt_obj, 'getUrl_shopping');
$this->baseParam['text_shops'] = AppBundle::getValue($konfiguration_projekt_obj, 'getText_shopping');
}
public function __init(){
$theme = AppBundle::getTheme($this->document, 'theme_doc');
$region_homes_doc = AppBundle::getTheme($this->document, 'region_homes_doc');
$this->baseParam['theme'] = $theme;
$this->baseParam['page'] = $region_homes_doc;
$bugfiximageurl = AppBundle::getBugfiximageurl();
/* ********************************************************************************************************************* */
/*
* G L A N Z E R L O G O
*/
$server_protocol = 'http' . ($_SERVER['REQUEST_SCHEME'] == 'https' ? 's' : '');
$logo_link = AppBundle::getValue($this->baseParam['konfiguration_projekt_obj'], 'getLogodomain');
$canonical_base = $server_protocol . '://' . $_SERVER['HTTP_HOST'] . $this->document->getFullpath();
$this->baseParam['path_info'] = $server_protocol . '://' . $_SERVER['HTTP_HOST'] . $this->document->getRealFullpath();
$this->baseParam['canonical_base'] = $canonical_base;
if ($region_homes_doc === 'hochsoelden')
{
$theme = "hochsoelden";
}
switch ($theme) {
case 'homes':
$glanzerLogo = AppBundle::getValue($this->baseParam['konfiguration_projekt_obj'], 'getLogo_homes');
break;
case 'rent':
$glanzerLogo = AppBundle::getValue($this->baseParam['konfiguration_projekt_obj'], 'getLogo_rent');
break;
case 'hochsoelden':
$glanzerLogo = AppBundle::getValue($this->baseParam['konfiguration_projekt_obj'], 'getLogo_hochsoelden');
break;
default:
$glanzerLogo = AppBundle::getValue($this->baseParam['konfiguration_projekt_obj'], 'getLogo_default');
}
$glanzerLogoAlt = "";
if (is_file($_SERVER["DOCUMENT_ROOT"] . '/var/assets' . $glanzerLogo) != '')
{
$glanzer_logo_asset_obj = \Pimcore\Model\Asset::getByPath($glanzerLogo);
$glanzerLogoAlt = $glanzer_logo_asset_obj->getMetadata("alt");
}
$this->baseParam['frontendParam'] = isset($_GET['load']) ? $_GET['load'] : "";
$this->baseParam['logo_link'] = $logo_link;
$this->baseParam['glanzerLogo'] = $bugfiximageurl.$glanzerLogo;
$this->baseParam['glanzerLogoAlt'] = $glanzerLogoAlt;
$this->baseParam['contacts'] = $this->getContactLinks();
}
public function contentAction(Request $request)
{
$locale = $request->getLocale();
$this->baseParam['wetterLink'] = $this->getWetter($locale)['link'];
$this->baseParam['wetterIcon'] = $this->getWetter($locale)['icon'];
$this->__init();
$param = (count($_GET) > 0) ? '?' : '';
$param .= http_build_query($_GET, '', '&');
//echo "<pre>"; print_r($this->baseParam); die;
// $this->view->canonical = $this->view->canonical_base . $param;
// $this->view->remotedata = $this->get(RemoteData::class);
//return $this->render('pagecontent/sample.html.twig', $params);
return $this->render('pagecontent/pagecontent.html.twig', $this->baseParam);
}
public function packageDetailAction(Request $request)
{
$region = $request->get('region');
$GLOBALS['region_param'] = $region;
$urlaubsangebot = $request->get('nameangebot');
$this->__init();
/* ********************************************************************************************************************* */
$canonical = $this->baseParam['canonical_base'] . '/' . $urlaubsangebot;
// $this->view->canonical = $canonical;
/* ********************************************************************************************************************* */
$items = new \Pimcore\Model\DataObject\Packages\Listing();
foreach ($items as $item) {
if ((string)$item->getPrettyurl() == $urlaubsangebot) {
$special_description = AppBundle::getValue($item, 'getMetabeschreibung');
$special_title = AppBundle::getValue($item, 'getMetatitel');
$package_objekt_id = $item->getId();
break;
}
}
$GLOBALS['packageObjectId'] = $package_objekt_id;
//$this->view->special_title = $special_title;
//$this->view->special_description = $special_description;
/* ********************************************************************************************************************* */
$vars = array(
'region' => $region,
'urlaubsangebot' => $urlaubsangebot,
'special_title' => $special_title,
'canonical' => $canonical,
'special_description' => $special_description
);
//return $this->renderTemplate('AppBundle::Pagecontent/content.html.php', $vars);
return $this->render('pagecontent/pagecontent.html.twig', $vars);
}
public function jobDetailAction(Request $request)
{
$jobangebot = $request->get('jobangebot');
/* ********************************************************************************************************************* */
$canonical = $this->view->canonical_base . '/' . $jobangebot ;
$this->view->canonical = $canonical;
/* ********************************************************************************************************************* */
$items = new \Pimcore\Model\DataObject\Jobs\Listing();
foreach ($items as $item) {
if ((string)$item->getPrettyurl() == $jobangebot) {
$special_description = AppBundle::getValue($item, 'getMetabeschreibung');
$special_title = AppBundle::getValue($item, 'getMetatitel');
$jobs_objekt_id = $item->getId();
break;
}
}
$GLOBALS['jobsObjectId'] = $jobs_objekt_id;
$this->view->special_title = $special_title;
$this->view->special_description = $special_description;
/* ********************************************************************************************************************* */
$vars = array();
return $this->renderTemplate('AppBundle::Pagecontent/content.html.php', $vars);
}
}