Guest User

quick-fix

a guest
Dec 19th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.13 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Slider
  4.  * Shortcode that allows to display a simple slideshow
  5.  */
  6.  
  7. if ( !class_exists( 'avia_sc_slider_fullscreen' ) )
  8. {
  9.     class avia_sc_slider_fullscreen extends aviaShortcodeTemplate
  10.     {
  11.             static $slide_count = 0;
  12.    
  13.             /**
  14.              * Create the config array for the shortcode button
  15.              */
  16.             function shortcode_insert_button()
  17.             {
  18.                 $this->config['name']           = __('Fullscreen Slider', 'avia_framework' );
  19.                 $this->config['tab']            = __('Media Elements', 'avia_framework' );
  20.                 $this->config['icon']           = AviaBuilder::$path['imagesURL']."sc-fullscreen.png";
  21.                 $this->config['order']          = 60;
  22.                 $this->config['target']         = 'avia-target-insert';
  23.                 $this->config['shortcode']      = 'av_fullscreen';
  24.                 $this->config['shortcode_nested'] = array('av_fullscreen_slide');
  25.                 $this->config['tooltip']        = __('Display a fullscreen slideshow element', 'avia_framework' );
  26.                 $this->config['tinyMCE']        = array('disable' => "true");
  27.                 $this->config['drag-level']     = 1;
  28.             }
  29.  
  30.             /**
  31.              * Popup Elements
  32.              *
  33.              * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  34.              * opens a modal window that allows to edit the element properties
  35.              *
  36.              * @return void
  37.              */
  38.             function popup_elements()
  39.             {
  40.                 $this->elements = array(
  41.            
  42.                     array( 
  43.                             "type"          => "modal_group",
  44.                             "id"            => "content",
  45.                             'container_class' =>"avia-element-fullwidth avia-multi-img",
  46.                             "modal_title"   => __("Edit Form Element", 'avia_framework' ),
  47.                             //"add_label"       =>  __("Add single image or video", 'avia_framework' ),
  48.                             "add_label"     =>  __("Add single image", 'avia_framework' ),
  49.                             "std"           => array(),
  50.                            
  51.                             'creator'       =>array(
  52.                                
  53.                                         "name" => __("Add Images", 'avia_framework' ),
  54.                                         "desc" => __("Here you can add new Images to the slideshow.", 'avia_framework' ),
  55.                                         "id"    => "id",
  56.                                         "type"  => "multi_image",
  57.                                         "title" => __("Add multiple Images",'avia_framework' ),
  58.                                         "button" => __("Insert Images",'avia_framework' ),
  59.                                         "std"   => ""
  60.                                         ),
  61.                                                            
  62.                             'subelements'   => array(
  63.                                    
  64.                                     /*
  65.                                     array( 
  66.                                         "name"  => __("Which type of slide is this?",'avia_framework' ),
  67.                                         "id"    => "slide_type",
  68.                                         "type"  => "select",
  69.                                         "std"   => "",
  70.                                         "subtype" => array(   __('Image Slide','avia_framework' )   =>'image',
  71.                                                               __('Video Slide','avia_framework' )   =>'video',
  72.                                                               )
  73.                                     ),
  74.                                     */
  75.                                    
  76.                                     array( 
  77.                                     "name"  => __("Choose another Image",'avia_framework' ),
  78.                                     "desc"  => __("Either upload a new, or choose an existing image from your media library",'avia_framework' ),
  79.                                     "id"    => "id",
  80.                                     "fetch" => "id",
  81.                                     "type"  => "image",
  82.                                     //"required"=> array('slide_type','is_empty_or','image'),
  83.                                     "title" => __("Change Image",'avia_framework' ),
  84.                                     "button" => __("Change Image",'avia_framework' ),
  85.                                     "std"   => ""),
  86.                                    
  87.                                    
  88.                                     array( 
  89.                                         "name"  => __("Image Position",'avia_framework' ),
  90.                                         "id"    => "position",
  91.                                         "type"  => "select",
  92.                                         "std"   => "Center Center",
  93.                                         "required" => array('id','not',''),
  94.                                         "subtype" => array(   __('Top Left','avia_framework' )       =>'top left',
  95.                                                               __('Top Center','avia_framework' )     =>'top center',
  96.                                                               __('Top Right','avia_framework' )      =>'top right',
  97.                                                               __('Bottom Left','avia_framework' )    =>'bottom left',
  98.                                                               __('Bottom Center','avia_framework' )  =>'bottom center',
  99.                                                               __('Bottom Right','avia_framework' )   =>'bottom right',
  100.                                                               __('Center Left','avia_framework' )    =>'center left',
  101.                                                               __('Center Center','avia_framework' )  =>'center center',
  102.                                                               __('Center Right','avia_framework' )   =>'center right'
  103.                                                               )
  104.                                     ),
  105.                                    
  106.                                     /*
  107. array( 
  108.                                     "name"  => __("Video URL", 'avia_framework' ),
  109.                                     "desc"  => __('Enter the URL to the Video. A list of all supported Video Services can be found here:', 'avia_framework' ) .
  110.                                     ' <a href="http://codex.wordpress.org/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F" target="_blank">Wordpress &amp; Videos</a><br/> <br/>'.
  111.                                     __('Working examples:', 'avia_framework' ).'<br/>
  112.                                 <strong>http://vimeo.com/64927358</strong><br/>
  113.                                 <strong>http://www.youtube.com/watch?v=G0k3kHtyoqc</strong><br/>',
  114.                                     "required"=> array('slide_type','equals','video'),
  115.                                     "id"    => "video",
  116.                                     "std"   => "http://",
  117.                                     "type"  => "input"),
  118.                                    
  119.                                      array(
  120.                                         "name"  => __("Video Display",'avia_framework' ),
  121.                                         "desc"  => __('You can either make sure that the whole video is visible and no cropping occurs or that the video is stretched to display full screen', 'avia_framework' ),
  122.                                         "id"    => "video_cover",
  123.                                         "type"  => "select",
  124.                                         "std"   => "",
  125.                                     "   required"=> array('slide_type','equals','video'),
  126.                                         "subtype" => array(  
  127.                                                             __('Display Video in default mode, borders may occur but the whole video will be visible','avia_framework' )       =>'',
  128.                                                             __('Stretch Video so it covers the whole slideshow (Video must be 16:9 for this option to work properly)','avia_framework' )     =>'av-element-cover',
  129.                                                               )
  130.                                     ),
  131. */
  132.                                    
  133.                                    
  134.                                    
  135.                                    
  136.                                    
  137.                                     array( 
  138.                                     "name"  => __("Caption Title", 'avia_framework' ),
  139.                                     "desc"  => __("Enter a caption title for the slide here", 'avia_framework' ) ,
  140.                                     "id"    => "title",
  141.                                     "std"   => "",
  142.                                     "type"  => "input"),
  143.                                    
  144.                                      array(
  145.                                     "name"  => __("Caption Text", 'avia_framework' ),
  146.                                     "desc"  => __("Enter some additional caption text", 'avia_framework' ) ,
  147.                                     "id"    => "content",
  148.                                     "type"  => "textarea",
  149.                                     "std"   => "",
  150.                                     ),
  151.                                    
  152.                                     array( 
  153.                                     "name"  => __("Caption Positioning",'avia_framework' ),
  154.                                     "id"    => "caption_pos",
  155.                                     "type"  => "select",
  156.                                     "std"   => "caption_bottom",
  157.                                     "subtype" => array(
  158.                                                 'Right Framed'=>'caption_right caption_right_framed caption_framed',
  159.                                                 'Left Framed'=>'caption_left caption_left_framed caption_framed',
  160.                                                 'Bottom Framed'=>'caption_bottom caption_bottom_framed caption_framed',
  161.                                                 'Center Framed'=>'caption_center caption_center_framed caption_framed',
  162.                                                 'Right without Frame'=>'caption_right',
  163.                                                 'Left without Frame'=>'caption_left',
  164.                                                 'Bottom without Frame'=>'caption_bottom',
  165.                                                 'Center without Frame'=>'caption_center'
  166.                                             ),
  167.                                     ),
  168.                                    
  169.                                     array( 
  170.                                     "name"  => __("Slide Link?", 'avia_framework' ),
  171.                                     "desc"  => __("Where should the Slide link to?", 'avia_framework' ),
  172.                                     "id"    => "link",
  173.                                     "type"  => "linkpicker",
  174.                                     "fetchTMPL" => true,
  175.                                     "subtype" => array(
  176.                                                         __('No Link', 'avia_framework' ) =>'',
  177.                                                         __('Lightbox', 'avia_framework' ) =>'lightbox',
  178.                                                         __('Set Manually', 'avia_framework' ) =>'manually',
  179.                                                         __('Single Entry', 'avia_framework' ) => 'single',
  180.                                                         __('Taxonomy Overview Page',  'avia_framework' ) => 'taxonomy',
  181.                                                         ),
  182.                                     "std"   => ""),
  183.                            
  184.                                     array( 
  185.                                     "name"  => __("Open Link in new Window?", 'avia_framework' ),
  186.                                     "desc"  => __("Select here if you want to open the linked page in a new window", 'avia_framework' ),
  187.                                     "id"    => "link_target",
  188.                                     "type"  => "select",
  189.                                     "std"   => "",
  190.                                     "required"=> array('link','not_empty_and','lightbox'),
  191.                                     "subtype" => AviaHtmlHelper::linking_options()),  
  192.                                        
  193.                                     array( 
  194.                                     "name"  => __("Where do you want to apply the link?", 'avia_framework' ),
  195.                                     "desc"  => __("You can choose to apply the link to the whole image or to a 'Call to Action Button' that gets appended to the caption", 'avia_framework' ),
  196.                                     "id"    => "link_apply",
  197.                                     "type"  => "select",
  198.                                     "std"   => "",
  199.                                     "required"=> array('link','not',''),
  200.                                     "subtype" => array(
  201.                                         __('Apply Link to Image',  'avia_framework' ) =>'',
  202.                                         __('Attach a button and apply link to button',  'avia_framework' ) =>'button')),
  203.                                        
  204.                                     array(  "name"  => __("Button Label", 'avia_framework' ),
  205.                                             "desc"  => __("This is the text that appears on your button.", 'avia_framework' ),
  206.                                             "id"    => "button_label",
  207.                                             "type"  => "input",
  208.                                             "container_class" => 'av_half av_half_first',
  209.                                             "required"=> array('link_apply','not',''),
  210.                                             "std"   => "Click me"),
  211.                                            
  212.                                     array( 
  213.                                     "name"  => __("Button Color", 'avia_framework' ),
  214.                                     "desc"  => __("Choose a color for your button here", 'avia_framework' ),
  215.                                     "id"    => "button_color",
  216.                                     "type"  => "select",
  217.                                     "std"   => "light",
  218.                                     "container_class" => 'av_half',
  219.                                     "required"=> array('link_apply','not',''),
  220.                                     "subtype" => array(
  221.                                                         __('Light Transparent', 'avia_framework' )=>'light',
  222.                                                         __('Dark Transparent', 'avia_framework' )=>'dark',
  223.                                                         )),
  224.                                        
  225.                         )              
  226.                     ),
  227.                            
  228.                     array( 
  229.                             "name"  => __("Slideshow Image Size", 'avia_framework' ),
  230.                             "desc"  => __("Choose image size for your slideshow.", 'avia_framework' ),
  231.                             "id"    => "size",
  232.                             "type"  => "select",
  233.                             "std"   => "extra_large",
  234.                             "subtype" =>  AviaHelper::get_registered_image_sizes(1000, true)       
  235.                             ),
  236.                                
  237.                     array( 
  238.                             "name"  => __("Slideshow Transition", 'avia_framework' ),
  239.                             "desc"  => __("Choose the transition for your Slideshow.", 'avia_framework' ),
  240.                             "id"    => "animation",
  241.                             "type"  => "select",
  242.                             "std"   => "slide",
  243.                             "subtype" => array(__('Slide','avia_framework' ) =>'slide',__('Fade','avia_framework' ) =>'fade'), 
  244.                             ),
  245.                            
  246.                     array( 
  247.                         "name"  => __("Autorotation active?",'avia_framework' ),
  248.                         "desc"  => __("Check if the slideshow should rotate by default",'avia_framework' ),
  249.                         "id"    => "autoplay",
  250.                         "type"  => "select",
  251.                         "std"   => "false",
  252.                         "subtype" => array(__('Yes','avia_framework' ) =>'true',__('No','avia_framework' ) =>'false')),
  253.            
  254.                     array( 
  255.                         "name"  => __("Slideshow autorotation duration",'avia_framework' ),
  256.                         "desc"  => __("Images will be shown the selected amount of seconds.",'avia_framework' ),
  257.                         "id"    => "interval",
  258.                         "type"  => "select",
  259.                         "std"   => "5",
  260.                         "subtype" =>
  261.                         array('3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9','10'=>'10','15'=>'15','20'=>'20','30'=>'30','40'=>'40','60'=>'60','100'=>'100')),
  262.                    
  263.                     /*
  264.                     array( 
  265.                         "name"  => __("Slideshow custom height",'avia_framework' ),
  266.                         "desc"  => __("Slideshow height is by default 100%. You can select a different size here.",'avia_framework' ),
  267.                         "id"    => "slide_height",
  268.                         "type"  => "select",
  269.                         "std"   => "100",
  270.                         "subtype" =>
  271.                         array('100%'=>'100', '75%'=>'75', '66%'=>'66', '50%'=>'50')),
  272.                 */
  273.                    
  274.                 );
  275.  
  276.             }
  277.            
  278.             /**
  279.              * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  280.              * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  281.              * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  282.              *
  283.              *
  284.              * @param array $params this array holds the default values for $content and $args.
  285.              * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  286.              */
  287.             function editor_element($params)
  288.             {  
  289.                 $params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />";
  290.                 $params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
  291.                 return $params;
  292.             }
  293.            
  294.             /**
  295.              * Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window
  296.              * Works in the same way as Editor Element
  297.              * @param array $params this array holds the default values for $content and $args.
  298.              * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  299.              */
  300.             function editor_sub_element($params)
  301.             {  
  302.                 $img_template       = $this->update_template("img_fakeArg", "{{img_fakeArg}}");
  303.                 $template           = $this->update_template("title", "{{title}}");
  304.                 $content            = $this->update_template("content", "{{content}}");
  305.                
  306.                 $thumbnail = isset($params['args']['id']) ? wp_get_attachment_image($params['args']['id']) : "";
  307.                
  308.        
  309.                 $params['innerHtml']  = "";
  310.                 $params['innerHtml'] .= "<div class='avia_title_container'>";
  311.                 $params['innerHtml'] .= "   <span class='avia_slideshow_image' {$img_template} >{$thumbnail}</span>";
  312.                 $params['innerHtml'] .= "   <div class='avia_slideshow_content'>";
  313.                 $params['innerHtml'] .= "       <h4 class='avia_title_container_inner' {$template} >".$params['args']['title']."</h4>";
  314.                 $params['innerHtml'] .= "       <p class='avia_content_container' {$content}>".stripslashes($params['content'])."</p>";
  315.                 $params['innerHtml'] .= "   </div>";
  316.                 $params['innerHtml'] .= "</div>";
  317.                
  318.                
  319.                
  320.                 return $params;
  321.             }
  322.            
  323.            
  324.            
  325.             /**
  326.              * Frontend Shortcode Handler
  327.              *
  328.              * @param array $atts array of attributes
  329.              * @param string $content text within enclosing form of shortcode element
  330.              * @param string $shortcodename the shortcode found, when == callback name
  331.              * @return string $output returns the modified html string
  332.              */
  333.             function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  334.             {
  335.                 $atts = shortcode_atts(array(
  336.                 'size'          => 'featured',
  337.                 'animation'     => 'slide',
  338.                 'ids'           => '',
  339.                 'autoplay'      => 'false',
  340.                 'interval'      => 5,
  341.                 'handle'        => $shortcodename,
  342.                 'stretch'       => '',
  343.                 'bg_slider'     => 'true',
  344.                 'slide_height'  => "100",
  345.                 'content'       => ShortcodeHelper::shortcode2array($content)
  346.                
  347.                 ), $atts);
  348.                
  349.                
  350.                 extract($atts);
  351.                 $output     = "";
  352.                 $class = "";
  353.                
  354.                
  355.                 $skipSecond = false;
  356.                 avia_sc_slider_full::$slide_count++;
  357.                
  358.                 $params['class'] = "avia-fullscreen-slider main_color ".$meta['el_class'].$class;
  359.                 $params['open_structure'] = false;
  360.                 if($meta['index'] == 0) $params['close'] = false;
  361.                 if($meta['index'] != 0) $params['class'] .= " slider-not-first";
  362.                 if($meta['index'] == 0 && get_post_meta(get_the_ID(), 'header', true) != "no") $params['class'] .= " slider-not-first";
  363.                
  364.                 $params['id'] = $atts['css_id']  = "fullscreen_slider_".avia_sc_slider_fullscreen::$slide_count;
  365.                
  366.                 $output .=  avia_new_section($params);
  367.                
  368.                 $slider  = new avia_slideshow($atts);
  369.                 $slider->set_extra_class($stretch);
  370.                 $output .= $slider->html();
  371.                
  372.                 $output .= "</div>"; //close section
  373.                
  374.                
  375.                 //if the next tag is a section dont create a new section from this shortcode
  376.                 if(!empty($meta['siblings']['next']['tag']) && in_array($meta['siblings']['next']['tag'],  AviaBuilder::$full_el ))
  377.                 {
  378.                     $skipSecond = true;
  379.                 }
  380.  
  381.                 //if there is no next element dont create a new section.
  382.                 if(empty($meta['siblings']['next']['tag']))
  383.                 {
  384.                     $skipSecond = true;
  385.                 }
  386.                
  387.                 if(empty($skipSecond)) {
  388.                
  389.                 $output .= avia_new_section(array('close'=>false, 'id' => "after_full_slider_".avia_sc_slider_fullscreen::$slide_count));
  390.                
  391.                 }
  392.                
  393.                 return $output;
  394.  
  395.             }
  396.            
  397.     }
  398. }
Advertisement
Add Comment
Please, Sign In to add comment