<?php

    if ( ! defined( 'ABSPATH' ) ) exit;

    require_once __DIR__ . "/../Classes/DigitalSignage4_Tools.php";
    require_once __DIR__ . "/../Kernel/Translations/DigitalSignage4_Translate.php";
    require_once __DIR__ . "/../Classes/DigitalSignage4_caller.php";
    require_once __DIR__ . "/../Kernel/API/Entity/DigitalSignage4_DemandeEntity.php";
    require_once __DIR__ . "/../Kernel/API/Entity/DigitalSignage4_PlaylistEntity.php";
    require_once __DIR__ . "/../Kernel/API/Manager/DigitalSignage4_DemandeManager.php";
    require_once __DIR__ . "/../Kernel/API/Manager/DigitalSignage4_Exception.php";
    require_once __DIR__ . "/../Kernel/API/Manager/DigitalSignage4_PlaylistManager.php";
    require_once __DIR__ ."/../Kernel/API/Manager/DigitalSignage4_GabaritManager.php";
	
    class DigitalSignage4_GabaritController extends DigitalSignage4_Controller
    {
        public function generatePage()
        {
            $this->route();
        }

        private function route()
        {
            
            if (isset($_GET['id_gabarit'])) {
                $this->display_gabarit();
            } else {
                $this->display_gabarits();
            }
        }

        private function display_gabarit()
        {
        }



        private function display_gabarits()
        {
            $gabarits = DigitalSignage4_GabaritManager::instance()->getGabarits();

			$clean_path=plugin_dir_path(__DIR__)."Files/no.png";
			
            $clean_path=str_replace('\\', "/", $clean_path);

            
            $this->assign(array(
                'gabarits' => $gabarits,
                //'urlSpecialData' => DigitalSignage4_Tools::getModuleUrl()."Classes/DigitalSignage4_CreationVideoSpecialDataProviderAjaxHandler.php?digitalSignageSpecialData=",
                'urlSpecialData' => admin_url( 'admin-ajax.php' ),
                'urlAjax' => admin_url( 'admin-ajax.php' ),
                'urlTraitement' => DigitalSignage4_Tools::getModuleUrl().'controllers/override/DigitalSignage4_AddGabaritCustomizeHandler.php',
                'urlLoadingImg' => DigitalSignage4_Tools::getModuleUrl()."Kernel/Views/img/loadingChamp.gif",
                'urlnoImg' => DigitalSignage4_Tools::getModuleUrl()."Files/no.png",
                'pathnoImg' => $clean_path,
                'logosite' => DigitalSignage4_Tools::get_site_logo_url(),//get_site_icon_url(),
                'urlChangeDisplayedVideo' =>  DigitalSignage4_Tools::getModuleUrl()."Classes/DigitalSignage4_DisplayedVideoProduct.php",
                'form_nonce' => wp_nonce_field( 'ds4_form_nonce' ),
                'ajax_nonce' => wp_create_nonce( 'ds4_ajax_nonce' ),
            ));


            $this->setWPTemplate("../hook/front/adminGabaritCustomizeForm");
        }
    }
