Skip to content
Code-Schnipsel Gruppen Projekte
index.php 4,36 KiB
Newer Older
  • Learn to ignore specific revisions
  • Henning Leutz's avatar
    Henning Leutz committed
    <?php
    
    /**
     * Emotion
     */
    
    QUI\Utils\Site::setRecursiveAttribute($Site, 'image_emotion');
    QUI\Utils\Site::setRecursiveAttribute($Site, 'layout');
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    /**
     * Template config
     */
    $templateSettings = QUI\TemplateCologne\Utils::getConfig([
        'Project' => $Project,
    
    Henning Leutz's avatar
    Henning Leutz committed
    /**
    
    Henning Leutz's avatar
    Henning Leutz committed
     */
    
    $menuParams = [
        'showStart'                   => false,
        'data-show-button-on-desktop' => 1,
        'Project'                     => $Site->getProject()
    ];
    
    
    if (isset($templateSettings['homeLink']) && $templateSettings['homeLink']) {
    
        $menuParams['showStart'] = true;
    
    }
    
    if (isset($templateSettings['homeLinkText']) && $templateSettings['homeLinkText'] !== '') {
    
        $menuParams['startText'] = $templateSettings['homeLinkText'];
    
    if ($Project->getConfig('templateCologne.settings.enableIndependentMenu') && $Project->getConfig('templateCologne.settings.menuId')) {
        $menuParams['menuId']              = $Project->getConfig('templateCologne.settings.menuId');
        $menuParams['showFirstLevelIcons'] = $Project->getConfig('templateCologne.settings.showFirstLevelIcons');
        $menuParams['showStart']           = false;
    }
    
    // Site own / independent menu
    if ($Site->getAttribute('templateCologne.independentMenuId')) {
        $menuParams['menuId'] = $Site->getAttribute('templateCologne.independentMenuId');
    }
    
    $Menu = new QUI\Menu\MegaMenu($menuParams);
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    /**
     * Basket button
     */
    $Currency = QUI\ERP\Currency\Handler::getUserCurrency();
    
    if (!$Currency) {
        $Currency = QUI\ERP\Currency\Handler::getDefaultCurrency();
    }
    
    
    $createBasketButton = true;
    
    if ($Site->getAttribute('type') == 'quiqqer/order:types/orderingProcess' ||
        $Site->getAttribute('type') == 'quiqqer/order:types/shoppingCart') {
        $createBasketButton = false;
    
    
        $Template->setAttribute('content-header', false);
    
    $InitialBasketPrice = new QUI\ERP\Money\Price(0, $Currency);
    
    
    $Logo       = $Project->getMedia()->getLogoImage();
    
    $logoHeight = $templateSettings['logoHeight'];
    
        if ($Logo) {
            $logoWidth = $Logo->getResizeSize(false, $logoHeight)['width'];
        }
    
    } catch (QUI\Exception $Exception) {
        QUI\System\Log::addNotice($Exception->getMessage());
    }
    
    $templateSettings['Logo']               = $Logo;
    $templateSettings['logoHeight']         = $logoHeight;
    $templateSettings['logoWidth']          = $logoWidth;
    
    $templateSettings['initialBasketPrice'] = $InitialBasketPrice->getDisplayPrice();
    
    $templateSettings['createBasketButton'] = $createBasketButton;
    
    /* user avatar */
    $Avatar = new QUI\FrontendUsers\Controls\UserIcon([
    
        'showLogout' => false, // template cologne use own logout popup (see bin/javascript/init.js)
        'User'       => QUI::getUserBySession()
    
    /* product page - for layouts */
    $productPage = false;
    switch ($Site->getAttribute('type')) {
        case 'quiqqer/products:types/category':
    
        case 'quiqqer/productsearch:types/search':
    
            $productPage = true;
    
            break;
    
    /**
     * Flags
     */
    $Flags = new QUI\Bricks\Controls\LanguageSwitches\Flags([
        'Site'      => $Site,
        'showFlags' => true,
        'showText'  => true,
        'all'       => true
    
    //$LangCurrencySwitch = new \QUI\TemplateCologne\Controls\LangCurrencySwitch();
    $LangCurrencySwitch = null;
    
    /**
     * Sign up / registration page
     */
    $registerSiteUrl = false;
    
    
    $types = [
        'quiqqer/frontend-users:types/registrationSignUp',
        'quiqqer/frontend-users:types/registration',
    ];
    
    $registerSite = $Project->getSites([
    
        'where' => [
            'type' => [
    
    if (count($registerSite)) {
        $registerSiteUrl = $registerSite[0]->getUrlRewritten();
    }
    
    // array to assign
    $templateSettings['BricksManager']      = QUI\Bricks\Manager::init();
    $templateSettings['Project']            = $Project;
    $templateSettings['Menu']               = $Menu;
    $templateSettings['Avatar']             = $Avatar;
    $templateSettings['productPage']        = $productPage;
    $templateSettings['Flags']              = $Flags;
    $templateSettings['LangCurrencySwitch'] = $LangCurrencySwitch;
    
    $templateSettings['countLanguages']     = \count($Project->getLanguages());
    
    $templateSettings['Search']             = new QUI\ERP\Products\Search\Controls\Suggest([
    
    $templateSettings['registerSiteUrl']    = $registerSiteUrl;
    
    $Template->setAttributes($templateSettings);