<?php
use Pmb\Animations\Orm\AnimationOrm;
use Pmb\Animations\Opac\Models\AnimationModel;
use Pmb\Animations\Opac\Models\RegistrationModel;
use Pmb\Animations\Opac\Controller\AnimationsController;

// +-------------------------------------------------+
// | 2002-2007 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: elements_animations_list_ui.class.php,v 1.1.8.1.2.1 2026/04/30 08:45:10 tsamson Exp $

if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access");

require_once($class_path.'/elements_list/elements_list_ui.class.php');

/**
 * Classe d'affichage d'un onglet qui affiche une liste rubrique du contenu éditorial
 * @author ngantier
 *
 */
class elements_animations_list_ui extends elements_list_ui {

    protected function generate_elements_list(){
        $elements_list = '';
        foreach($this->contents as $element_id){
            $elements_list.= $this->generate_element($element_id);
        }
        return $elements_list;
    }

    protected function generate_element($element_id, $recherche_ajax_mode=0){
        $empr_id = intval($_SESSION['id_empr_session']);
        $animation_controller = new AnimationsController();
        $context = $animation_controller->getAnimationRenderContext($element_id, $empr_id);
        return static::render($this->get_template_path(),$context);
    }
    
    private function get_template_path() {
        global $opac_authorities_templates_folder, $include_path, $opac_rgaa_active;
        
        $template_directory = $opac_authorities_templates_folder ?? "common";
        $template_base_name = (!empty($opac_rgaa_active) ? "rgaa_animation_in_result_display" : "animation_in_result_display");
        switch (true) {
            case file_exists($include_path.'/templates/animations/'.$template_directory.'/'.$template_base_name.'_subst.tpl.html'):
                return $include_path.'/templates/animations/'.$template_directory.'/'.$template_base_name.'_subst.tpl.html';
            case file_exists($include_path.'/templates/animations/'.$template_directory.'/'.$template_base_name.'.tpl.html'):
                return $include_path.'/templates/animations/'.$template_directory.'/'.$template_base_name.'.tpl.html';
            case file_exists($include_path.'/templates/animations/common/'.$template_base_name.'_subst.tpl.html'):
                return $include_path.'/templates/animations/common/'.$template_base_name.'_subst.tpl.html';
            case file_exists($include_path.'/templates/animations/common/'.$template_base_name.'.tpl.html'):
                return $include_path.'/templates/animations/common/'.$template_base_name.'.tpl.html';
        }
        return "";
    }
}