src/Controller/Traits/IconTrait.php line 61

Open in your IDE?
  1. <?php
  2. /***************************************************************
  3.  *
  4.  *  Copyright notice
  5.  *
  6.  *  (c) 14.12.21 Paul Bönisch <p.boenisch@saint-elmos.com>, Saint Elmo's
  7.  *
  8.  *  All rights reserved
  9.  *
  10.  *  This script is part of the TYPO3 project. The TYPO3 project is
  11.  *  free software; you can redistribute it and/or modify
  12.  *  it under the terms of the GNU General Public License as published by
  13.  *  the Free Software Foundation; either version 3 of the License, or
  14.  *  (at your option) any later version.
  15.  *
  16.  *  The GNU General Public License can be found at
  17.  *  http://www.gnu.org/copyleft/gpl.html.
  18.  *
  19.  *  This script is distributed in the hope that it will be useful,
  20.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  *  GNU General Public License for more details.
  23.  *
  24.  *  This copyright notice MUST APPEAR in all copies of the script!
  25.  ***************************************************************/
  26. namespace App\Controller\Traits;
  27. use App\AppBundle;
  28. use SaintElmos\BaseBundle\Templating\Helper\FrontendHelper;
  29. use \Pimcore\Model\WebsiteSetting;
  30. use Pimcore\Model\Asset\Document;
  31. use Pimcore\Model\Asset\Image;
  32. trait IconTrait
  33. {
  34.     public function getFooterObject()
  35.     {
  36.         $theme AppBundle::getTheme($this->document'theme_doc');
  37.         switch ($theme) {
  38.             case 'rent':
  39.                 $footer_obj WebsiteSetting::getByName('footer_rent')->getData();
  40.                 break;
  41.             case 'homes':
  42.                 $footer_obj WebsiteSetting::getByName('footer_homes')->getData();
  43.                 break;
  44.             case 'shops':
  45.                 $footer_obj WebsiteSetting::getByName('footer_shops')->getData();
  46.                 break;
  47.             default:
  48.                 //neutral
  49.                 $footer_obj WebsiteSetting::getByName('footer_neutral')->getData();
  50.         }
  51.         return $footer_obj;
  52.     }
  53.     public function getContactLinks()
  54.     {
  55.         $frontendhelper = new FrontendHelper();
  56.         $bugfiximageurl AppBundle::getBugfiximageurl();
  57.         $footer_obj $this->getFooterObject();
  58.         if(is_object($footer_obj))
  59.         {
  60.             $tel_icon_path =  AppBundle::getValue($footer_obj'getTelefonicon');
  61.             if (is_file($_SERVER["DOCUMENT_ROOT"] . '/var/assets' $tel_icon_path))
  62.             {
  63.                 if (is_object(\Pimcore\Model\Asset::getByPath($tel_icon_path)))
  64.                 {
  65.                     $tel_icon_obj \Pimcore\Model\Asset::getByPath($tel_icon_path);
  66.                     $tel_icon_alttag $tel_icon_obj->getMetadata("alt");
  67.                 }
  68.                 $tel_icon_img = (trim($tel_icon_path != ''))? '<img width="25" height="25" src="'.$bugfiximageurl.$tel_icon_path.'" alt="'.$tel_icon_alttag.'"/>':'';
  69.             }
  70.             else
  71.             {
  72.                 $tel_icon_img =  '';
  73.             }
  74.             $tel =  AppBundle::getValue($footer_obj'getTelefonnummer');
  75.             $tel_num $frontendhelper->clearTelnumber($tel);
  76.             $telefonnummer '<a href="tel:'.$tel_num.'">' $tel_icon_img .  '<label>' .$tel '</label></a>';
  77.         }
  78.         if(is_object($footer_obj))
  79.         {
  80.             $email_icon_path =  AppBundle::getValue($footer_obj'getEmailicon');
  81.             if (is_file($_SERVER["DOCUMENT_ROOT"] . '/var/assets' $email_icon_path))
  82.             {
  83.                 if (is_object(\Pimcore\Model\Asset::getByPath($email_icon_path)))
  84.                 {
  85.                     $email_icon_obj \Pimcore\Model\Asset::getByPath($email_icon_path);
  86.                     $email_icon_alttag $email_icon_obj->getMetadata("alt");
  87.                 }
  88.                 $email_icon_img = (trim($email_icon_path != ''))? '<img width="25" height="25" src="'.$bugfiximageurl.$email_icon_path.'" alt="'.$email_icon_alttag.'"/>':'';
  89.             }
  90.             else
  91.             {
  92.                 $email_icon_img =  '';
  93.             }
  94.             $email_adresse =  AppBundle::getValue($footer_obj'getEmail');
  95.             $email '<a href="mailto:'.$email_adresse.'">' $email_icon_img '<label>' $email_adresse '</label></a>';
  96.         }
  97.         return array(
  98.             'email'           => $email,
  99.             'telefonnummer'   => $telefonnummer
  100.         );
  101.     }
  102.     public function getWetter($language) {
  103.         $bugfiximageurl AppBundle::getBugfiximageurl();
  104.         $lg $this->document->getProperty('language');
  105.         $lg_trimmed trim($lg);
  106.         $footer_obj $this->getFooterObject($this->document);
  107.         $wetter_icon AppBundle::getValue($footer_obj'getWettericon');
  108.         $wetter_link AppBundle::getValue($footer_obj'getWetterlink');
  109.         $wetterFullImage Image::getById($wetter_icon->getId());
  110.         $wetterFullLink null;
  111.         if ($wetter_link) {
  112.             $wetterFullLink $wetter_link->getHref();
  113.         }
  114.         if ($language === 'en')
  115.         {
  116.             $baseLink = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' "https" "http") . "://$_SERVER[HTTP_HOST]".'/en'.$wetterFullLink;
  117.         } else {
  118.             $baseLink = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' "https" "http") . "://$_SERVER[HTTP_HOST]".$wetterFullLink;
  119.         }
  120.         $wetterFullLink $baseLink;
  121.         return [
  122.             "link" => $wetterFullLink,
  123.             "icon" => $wetterFullImage->getFrontendPath()
  124.         ];
  125.     }
  126. }