post_id = $post_id;
$this->slides = avia_post_meta($this->post_id, 'slideshow');
$this->slidecount = count($this->slides);
if(!$this->slidecount) return;
$this->type = avia_post_meta($this->post_id, '_slideshow_type');
if($overwrite_small && (empty($this->type) || $this->type == 'small_caption'))
{
$this->type = $overwrite_small;
}
$this->autoplay = avia_post_meta($this->post_id, '_slideshow_autoplay');
$this->slide_duration = avia_post_meta($this->post_id, '_slideshow_duration');
switch($this->type)
{
case '2D_small_caption_welcome': $this->imagesize = "portfolio2"; break;
case '2D_caption': $this->imagesize = "featured"; break;
}
}
function description()
{
$output = "";
$buttonclass = 'dual_buttons';
global $avia_config;
$title = avia_post_meta('_slideshow_welcome_title');
$text = avia_post_meta('_slideshow_welcome_text');
$linktext1 = avia_post_meta('_slideshow_welcome_button_1');
if($linktext1)
{
$link1 = avia_get_link($avia_config['meta'], '_slideshow_welcome_button_1_', $linktext1, $this->post_id);
}
$linktext2 = avia_post_meta('_slideshow_welcome_button_2');
if($linktext2)
{
$link2 = avia_get_link($avia_config['meta'], '_slideshow_welcome_button_2_', $linktext2, $this->post_id);
}
if(!$linktext1 || $linktext1 == $link1 || !$linktext2 || $linktext2 == $link2)
{
$buttonclass = 'single_buttons';
}
$output .= "
";
$output .= "
";
$output .= "
".$title." ";
$output .= "
". wpautop( avia_remove_autop( nl2br( $text )))."
";
if($linktext1 || $linktext2) $output .= "
";
if($linktext1 && $linktext1 != $link1) $output .= "
".$link1." ";
if($linktext2 && $linktext2 != $link2) $output .= "
".$link2." ";
$output .= "
";
$output .= "
";
return $output;
}
function display()
{
$this->showcaption = true;
if(!$this->type || $this->type == 'small_caption') return;
$output = $shadow = '';
//add the cu3er javascript
if(strpos($this->type, '3D') !== false)
{
//set fallback imagesize based on selected 3D slider
if(strpos($this->type, 'welcome') !== false )
{
$this->imagesize = 'portfolio2';
}
else
{
$this->imagesize = 'featured';
}
$output = $this->activate_cu3er();
}
else
{
$shadow = ' ';
}
//add the slide container
$output .= "";
//if a small slider with static text was choosen render the static text
if(strpos($this->type, 'welcome') !== false)
{
$output .= $this->description();
}
//add javascript slider eiter because the user chose it and also as fallback if the user doesnt have flash
$output .= "
";
$output .= $this->slideshow();
$output .= $shadow;
$output .= "
";
return $output;
}
function display_small($size = 'page', $force_display = false, $showcaption = true)
{
if(($force_display || $this->type == 'small_caption'|| $this->type == '' ) && is_array($this->slides) && !empty($this->slides[0]['slideshow_image']))
{
$this->type = 'small_caption';
$this->imagesize = $size;
$this->showcaption = $showcaption;
return $this->slideshow();
}
}
function slideshow()
{
$counter = 1;
$js_controller = 'autoslide_'.$this->autoplay;
$js_controller .= ' autoslidedelay__'.$this->slide_duration;
$output = "";
$output .= "
";
if(is_array($this->slides) && !empty($this->slides[0]['slideshow_image']))
{
foreach($this->slides as $slide)
{
if($slide['slideshow_image'] != "")
{
//check if we got an image or a video
if(!is_numeric($slide['slideshow_image']))
{
### render a video ###
$output .= "";
if(avia_backend_is_file($slide['slideshow_image'], 'html5video'))
{
$output .= avia_html5_video_embed($slide['slideshow_image']);
}
else
{
global $avia_config, $wp_embed;
$width = "";
if(isset($avia_config['imgSize'][$this->imagesize]['width']))
{
$width = "width='".$avia_config['imgSize'][$this->imagesize]['width']."'";
}
$output .= $wp_embed->run_shortcode("[embed $width ]".$slide['slideshow_image']."[/embed]");
}
$output .= " ";
}
else
{
### render an image ###
//get the image by passing the attachment id.
$image_string = avia_image_by_id($slide['slideshow_image'], $this->imagesize);
//if we didnt get a valid image from the above function set it directly
if(!$image_string) $image_string = $slide['slideshow_image'];
//apply links to the image if thats what the user wanted
$image = avia_get_link($slide, 'slideshow_', $image_string, $this->post_id);
$output .= "";
$output .= "
";
$output .= $image;
//check if the user has set either a title or a caption that we can display
if($this->showcaption)
{
if((!empty($slide['slideshow_caption_title']) || !empty($slide['slideshow_caption']) || (!empty($slideshow_options_show_controlls) && !empty($slides[1]['slideshow_image']))))
{
$output .= '';
if(!empty($slide['slideshow_caption_title'])) $output .= '
'.$slide['slideshow_caption_title'].' ';
if(!empty($slide['slideshow_caption'])) $output .= '
'.$slide['slideshow_caption'].'
';
$output .= '
';
}
}
$output .= " ";
}
}
}
}
$output .= " ";
$output .= '
';
return $output;
}
######################################################################
# XML & cu3er related functions
######################################################################
function generate_xml()
{
if(strpos($this->type, '3D') !== false)
{
$this->_build_xml_header();
foreach($this->slides as $slide_element)
{
$this->_build_xml_slides($slide_element);
}
$this->slideshow_xml .='';
}
}
function activate_cu3er()
{
$output = "";
$output .= ''."\n";
$output .= ''."\n";
$output .= '
';
return $output;
}
function _build_xml_slides($element)
{
if(is_numeric($element['slideshow_image']))
{
$this->slideshow_xml .= '
imagesize3D, 'url').']]>
'.avia_get_link($element, 'slideshow_', false, $this->post_id).'
'
;
$this->_build_xml_transition($element);
}
}
function _build_xml_transition($element)
{
$this->slideshow_xml .= 'slideshow_xml .= 'columns="'.$element['slice_vertical'].'" ';
if(!empty($element['slice_horizontal'])) $this->slideshow_xml .= 'rows="'.$element['slice_horizontal'].'" ';
if(!empty($element['direction'])) $this->slideshow_xml .= 'flipDirection="'.$element['direction'].'" ';
if(!empty($element['order'])) $this->slideshow_xml .= 'flipOrder="'.$element['order'].'" ';
if(!empty($element['element_depth'])) $this->slideshow_xml .= 'flipBoxDepth="'.$element['element_depth'].'" ';
if(!empty($element['flip_depth'])) $this->slideshow_xml .= 'flipDepth="'.$element['flip_depth'].'" ';
if(!empty($element['slideshow_transition']))
{
switch($element['slideshow_transition'])
{
case "slide":
$this->slideshow_xml .= 'type="2D" ';
$this->slideshow_xml .= 'type2D="slide" ';
$this->slideshow_xml .= 'flipEasing="Expo.easeInOut" ';
break;
case "90d":
$this->slideshow_xml .= 'type="3D" ';
$this->slideshow_xml .= 'flipAngle="90" ';
$this->slideshow_xml .= 'flipEasing="Sine.easeOut" ';
break;
case "180d":
$this->slideshow_xml .= 'type="3D" ';
$this->slideshow_xml .= 'flipAngle="180" ';
$this->slideshow_xml .= 'flipEasing="Sine.easeOut" ';
break;
case "fade":
$this->slideshow_xml .= 'type="2D" ';
$this->slideshow_xml .= 'type2D="fade" ';
$this->slideshow_xml .= 'flipEasing="Expo.easeInOut" ';
break;
}
}
$this->slideshow_xml .='flipColor="0x878787" flipShader="none" flipOrderFromCenter="false" flipDuration=".6" flipDelay=".15" flipDelayRandomize=".5" />';
}
function _build_xml_header()
{
$bg_image = $shadow = $camera = $slides = $branding = $controlls = $autoplayer = $prevnext = $description ='';
$color_1 = substr(avia_get_option('color_1','#555555'),1);
switch ($this->type)
{
case 'tablet_3D_welcome': //tablet 3D slider
$bg_image ='
';
$prevnext = '
false
false
false
false
';
$camera = ' ';
$this->imagesize3D = $this->type;
$slides = '';
$branding = '';
$autoplayer = '';
$controlls = ' ';
break;
case '3D_small_welcome': //small 3D slider
$this->imagesize3D = 'portfolio2';
$camera = ' ';
$shadow = ' ';
$slides = '';
$branding = '';
$autoplayer = '';
$controlls = ' ';
break;
case '3D_caption': //fullsize 3D slider
$color_1 = "000000";
$this->imagesize3D = 'featured';
$prevnext = '
true
true
true
true
';
$camera = ' ';
$shadow = ' ';
$slides = '';
$branding = '';
$autoplayer = '';
$controlls = ' ';
$description = '
true
true
true
';
break;
}
//gerneric mask with defaults. the slider specific vars are filled in here
$this->slideshow_xml .= '
0
502
472
0xffffff
'.$bg_image.'
1
'.$this->autoplay.'
false
'.$branding.'
true
true
true
'.$camera.$shadow.'
'.$autoplayer.'
true
false
'.$prevnext.'
'.$controlls.'
false
false
'.$description.'
'.$slides;
}
}