HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/controllers/AjaxController.php
<?php

/**
 * This controller will be used for non specific ajax calls ef. cookiebar
 *
 * @author      Tim Van Samang <timvansamang@komma.pro>
 * @copyright   (c) 2012-2015, Komma Mediadesign
 */


use KommaApp\Shop\Countries\CountryService;
use KommaApp\Shop\Pages\PageService;

class AjaxController extends BaseController
{

    /**
     * This function will create an disableCookieBar cookie
     * This will disable the cookiebar block every page.
     * // /ajax/disable-cookies
     *
     * * @return Json
     */
    public function disableCookieBar()
    {
        //Is it an Ajax request
        if (Request::ajax()) {

            //create an cookie that last forever (5 years)

            $cookie = Cookie::make('disableCookieBar', 'disable', 2628000);

            App::after(function ($request, $response) use ($cookie) {
                $response->headers->setCookie($cookie);
            });

            return Response::json(['disableCookieBar' => 'disable']);

        }
    }

    /**
     * his function will create an disableAdditionalBar cookie
     * his will disable the cookiebar block every page.
     */
    public function disableAdditionalBar()
    {
        //Is it an Ajax request
        if (Request::ajax()) {

            //create an cookie that last forever (5 years)
            $cookie = Cookie::make('disableAdditionalBar', 'disable', 10080);

            App::after(function ($request, $response) use ($cookie) {
                $response->headers->setCookie($cookie);
            });

            return Response::json(['disableAdditionalBar' => 'disable']);

        }
    }

    /**
     * This function will create an disableLanguageSwitch cookie
     * This will disable the languageSwitch block every page.
     * // /ajax/disable-cookies
     *
     * * @return Json
     */
    public function disableLanguageSwitch()
    {
        //Is it an Ajax request
        if (Request::ajax()) {

            //create an cookie that last forever (5 years)

            $cookie = Cookie::make('disableLanguageSwitch', 'disable', 2628000);

            App::after(function ($request, $response) use ($cookie) {
                $response->headers->setCookie($cookie);
            });

            return Response::json(['disableLanguageSwitch' => 'disable']);


        }

    }


    /**
     * This function will collect the desired translations for the Angular files
     * // {lang}/ajax/translations
     * // /ajax/translations
     *
     * @return Json
     */
    public function angularTranslations($lang = null)
    {
        //Is it an Ajax request
        if (!Request::ajax()) {
            return;
        }
        //Set the language form the uri, if it exist
        if ($lang) \Shop::getLanguageService()->bootFromUri(\Shop::getId());
        //else set the default language from the shop
        else \Shop::getLanguageService()->bootFromLangId(\Shop::getShop()->default_language_id);



        $translations = array();

        //Load language file angular.php
        if ($angular = \Lang::get('angular')) {
            if (is_array($angular)) {
                //Merge the loaded array with the existing translation array
                $translations = array_merge($translations, $angular);
            }
        }
        //Load language file countries.php
        if ($countries = \Lang::get('countries')) {
            if (is_array($countries)) {
                //Merge the loaded array with the existing translation array
                $translations = array_merge($translations, $countries);
            }
        }

        $translations['search_url'] = \Shop::getPageService()->page('search')->route;

        //return the array as an Json
        return Response::json($translations);
    }
}