use_jquery = true;
$this->default_template = "
{% for record in records %}
{{ record.content }}
{% endfor %}
";
parent::__construct($id);
}
public function get_form(){
if (!isset($this->parameters["used_template"])) $this->parameters["used_template"] = "";
if (!isset($this->parameters["no_image"])) $this->parameters["no_image"] = "";
if (!isset($this->parameters["arrows"])) $this->parameters["arrows"] = true;
if (!isset($this->parameters["dotnav"])) $this->parameters["dotnav"] = true;
if (!isset($this->parameters["animation"])) $this->parameters["animation"] = 'fade';
if (!isset($this->parameters["duration"])) $this->parameters["duration"] = 500;
if (!isset($this->parameters["height"])) $this->parameters["height"] = 'auto';
if (!isset($this->parameters["start"])) $this->parameters["start"] = 0;
if (!isset($this->parameters["autoplay"])) $this->parameters["autoplay"] = false;
if (!isset($this->parameters["pauseonhover"])) $this->parameters["pauseonhover"] = true;
if (!isset($this->parameters["autoplayinterval"])) $this->parameters["autoplayinterval"] = 7000;
if (!isset($this->parameters["videoautoplay"])) $this->parameters["videoautoplay"] = true;
if (!isset($this->parameters["videomute"])) $this->parameters["videomute"] = true;
if (!isset($this->parameters["kenburns"])) $this->parameters["kenburns"] = false;
if (!isset($this->parameters["kenburnsanimations"])) $this->parameters["kenburnsanimations"] = '';
if (!isset($this->parameters["slices"])) $this->parameters["slices"] = 15;
$general_form = "
";
$advanced_parameters = "
".$this->format_text($this->msg['cms_module_common_view_slideshow_animation'])."
".$this->get_animations_list()."
";
$form = gen_plus("general_parameters", $this->format_text($this->msg['cms_module_common_view_slideshow_general_parameters']),$general_form,true);
$form.= gen_plus("advanced_parameters", $this->format_text($this->msg['cms_module_common_view_slideshow_advanced_parameters']),$advanced_parameters);
$form.= parent::get_form() . $this->get_view_django_template_record();
return $form;
}
public function get_view_django_template_record ()
{
return "
".$this->format_text($this->msg['cms_module_common_view_django_template_record_content'])."
".notice_tpl::gen_tpl_select("cms_module_common_view_django_template_record_content",$this->parameters['used_template'])."
";
}
public function get_animations_list() {
$animations = ['fade', 'scroll', 'scale', 'swipe', 'slice-down', 'slice-up', 'slice-up-down', 'fold', 'puzzle', 'boxes', 'boxes-reverse', 'random-fx'];
$select = "";
foreach ($animations as $animation) {
$selected = $this->parameters['animation'] == $animation ? 'selected' : '';
$select .= "".$this->format_text($this->msg["cms_module_common_view_slideshow_$animation"])." ";
}
$select .= " ";
return $select;
}
public function save_form() {
global $cms_module_common_view_django_template_record_content;
global $cms_module_common_view_slideshow_no_image;
global $cms_module_common_view_slideshow_arrows;
global $cms_module_common_view_slideshow_dotnav;
global $cms_module_common_view_slideshow_animation;
global $cms_module_common_view_slideshow_duration;
global $cms_module_common_view_slideshow_height;
global $cms_module_common_view_slideshow_start;
global $cms_module_common_view_slideshow_autoplay;
global $cms_module_common_view_slideshow_pauseonhover;
global $cms_module_common_view_slideshow_autoplayinterval;
global $cms_module_common_view_slideshow_videoautoplay;
global $cms_module_common_view_slideshow_videomute;
global $cms_module_common_view_slideshow_kenburns;
global $cms_module_common_view_slideshow_kenburnsanimations;
global $cms_module_common_view_slideshow_slices;
$this->parameters['used_template'] = $cms_module_common_view_django_template_record_content;
$this->parameters['no_image'] = $cms_module_common_view_slideshow_no_image;
$this->parameters["arrows"] = ($cms_module_common_view_slideshow_arrows == 1 ? true : false);
$this->parameters["dotnav"] = ($cms_module_common_view_slideshow_dotnav == 1 ? true : false);
$this->parameters["animation"] = $cms_module_common_view_slideshow_animation;
$this->parameters["duration"] = $cms_module_common_view_slideshow_duration;
$this->parameters["height"] = $cms_module_common_view_slideshow_height;
$this->parameters["start"] = $cms_module_common_view_slideshow_start;
$this->parameters["autoplay"] = ($cms_module_common_view_slideshow_autoplay == 1 ? true : false);
$this->parameters["pauseonhover"] = ($cms_module_common_view_slideshow_pauseonhover == 1 ? true : false);
$this->parameters["autoplayinterval"] = $cms_module_common_view_slideshow_autoplayinterval;
$this->parameters["videoautoplay"] = ($cms_module_common_view_slideshow_videoautoplay == 1 ? true : false);
$this->parameters["videomute"] = ($cms_module_common_view_slideshow_videomute == 1 ? true : false);
$this->parameters["kenburns"] = ($cms_module_common_view_slideshow_kenburns == 1 ? true : false);
$this->parameters["kenburnsanimations"] = $cms_module_common_view_slideshow_kenburnsanimations;
$this->parameters["slices"] = $cms_module_common_view_slideshow_slices;
return parent::save_form();
}
public function get_headers($datas = array()) {
$headers = parent::get_headers($datas);
return $headers;
}
public function render($datas){
global $base_path;
$html2return = '';
if (!empty($datas['records']) && count($datas['records'])) {
$datas['id'] = $this->get_module_dom_id();
if(!isset($datas['get_vars']) || !$datas['get_vars']){
$datas['get_vars'] = $_GET;
}
if(!isset($datas['post_vars']) || !$datas['post_vars']){
$datas['post_vars'] = $_POST;
}
$datas['id'] = $this->get_module_dom_id();
$id = "carousel_".$datas['id'];
$datas['no_image_url'] = $this->get_no_image_url();
$template_path = $base_path.'/temp/'.LOCATION.'_cms_slideshow_view_'.$this->id;
if(!file_exists($template_path) || (md5($this->parameters['active_template']) != md5_file($template_path))){
file_put_contents($template_path, $this->parameters['active_template']);
}
try{
$H2o = H2o_collection::get_instance($template_path);
$html2return = $H2o->render($datas);
$html2return .= $this->get_script_slider($id);
}catch(Exception $e){
$html2return = '';
$html2return .= '';
$html2return .= $this->msg["cms_module_common_view_error_template"];
$html2return .= '
';
}
}
return $html2return;
}
public function get_no_image_url() {
global $opac_default_style;
$path = "./styles/$opac_default_style/images/";
if (!file_exists(realpath($path)."/".$this->parameters['no_image'])) {
$path = "./styles/common/images/";
if (!file_exists(realpath($path)."/".$this->parameters['no_image'])) {
$path = "./images/";
if (!file_exists(realpath($path)."/".$this->parameters['no_image'])) {
$path = "./images/";
$this->parameters['no_image'] = "no_image_carousel.jpg";
}
}
}
return $path.$this->parameters['no_image'];
}
public function get_script_slider($id) {
return "
";
}
protected function get_managed_template_form($cms_template){
global $opac_url_base;
$form ="";
if($cms_template != "new"){
$infos = $this->managed_datas['templates'][$cms_template];
}else{
$infos = array(
'name' => "Nouveau Template",
'content' => $this->default_template
);
}
if(!$this->managed_datas) $this->managed_datas = array();
//nom
$form.="
";
//contenu
$form.="
".$this->format_text($this->msg['cms_module_common_view_template_item'])."
".$this->get_format_data_structure_tree("cms_module_common_view_django_template_content")."
";
return $form;
}
public function save_manage_form($managed_datas){
global $cms_template;
global $cms_template_delete;
global $cms_module_common_view_django_template_name,$cms_module_common_view_django_template_content;
if($cms_template_delete){
unset($managed_datas['templates'][$cms_template_delete]);
}else{
if($cms_template == "new"){
$cms_template = "template".(cms_module_common_view_django::get_max_template_id($managed_datas['templates'])+1);
}
$managed_datas['templates'][$cms_template] = array(
'name' => stripslashes($cms_module_common_view_django_template_name),
'content' => stripslashes($cms_module_common_view_django_template_content)
);
}
return $managed_datas;
}
public function get_format_data_structure(){
$format_datas = array();
$format_datas[] = array(
'var' => "no_image_url",
'desc'=> $this->msg['cms_module_common_view_slideshow_no_image_desc']
);
$format_datas = array_merge($format_datas, parent::get_format_data_structure());
return $format_datas;
}
}