Advertisement
emcniece

WP JAD Theme slider.php fix

Jan 7th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 19.72 KB | None | 0 0
  1. <?php
  2.  
  3. class SG_Slider_Module extends SG_Module {
  4.  
  5.     const moduleName = 'Slider';
  6.  
  7.     protected static $instance;
  8.     protected static $_vars = NULL;
  9.     protected static $_params = array();
  10.     protected static $_fields = array();
  11.     protected static $_description = NULL;
  12.  
  13.     private function __construct()
  14.     {
  15.         self::$_fields = array(
  16.             'show' => array(
  17.                 'name' => __('Slider Visibility', SG_TDN),
  18.                 'type' => 'select',
  19.                 'options' => array(
  20.                     'main' => __('Regular', SG_TDN),
  21.                     'full' => __('Full', SG_TDN),
  22.                     'no' => __('Hide', SG_TDN),
  23.                 ),
  24.                 'default' => 'no',
  25.                 'change' => array(
  26.                     'slider' => '["main"]',
  27.                     'slider2' => '["full"]',
  28.                 ),
  29.                 'help' => __('Show or hide the slider on the page', SG_TDN),
  30.             ),
  31.             'effect' => array(
  32.                 'name' => __('Effect', SG_TDN),
  33.                 'type' => 'select',
  34.                 'options' => array(
  35.                     'slide' => __('Slide', SG_TDN),
  36.                     'fade' => __('Fade', SG_TDN),
  37.                 ),
  38.                 'default' => 'slider',
  39.                 'group' => 'slider',
  40.                 'help' => __('Animation effect', SG_TDN),
  41.             ),
  42.             'animation_time' => array(
  43.                 'name' => __('Animation Time', SG_TDN),
  44.                 'type' => 'select',
  45.                 'options' => array(
  46.                     '300' => '300 mc',
  47.                     '400' => '400 mc',
  48.                     '500' => '500 mc',
  49.                     '600' => '600 mc',
  50.                     '700' => '700 mc',
  51.                     '800' => '800 mc',
  52.                     '900' => '900 mc',
  53.                 ),
  54.                 'default' => '500',
  55.                 'group' => 'slider',
  56.                 'help' => __('Select the duration value of sliding animation (milliseconds)', SG_TDN),
  57.             ),
  58.             'effect2' => array(
  59.                 'name' => __('Effect', SG_TDN),
  60.                 'type' => 'select',
  61.                 'options' => array(
  62.                     'fade' => __('Fade', SG_TDN),
  63.                     'slideTop' => __('Slide in from top', SG_TDN),
  64.                     'slideRight' => __('Slide in from right', SG_TDN),
  65.                     'slideBottom' => __('Slide in from bottom', SG_TDN),
  66.                     'slideLeft' => __('Slide in from left', SG_TDN),
  67.                     'carouselLeft' => __('Carousel from left to right', SG_TDN),
  68.                     'carouselRight' => __('Carousel from right to left', SG_TDN),
  69.                 ),
  70.                 'default' => 'fade',
  71.                 'group' => 'slider2',
  72.                 'help' => __('Animation effect', SG_TDN),
  73.             ),
  74.             'delay2' => array(
  75.                 'name' => __('Delay', SG_TDN),
  76.                 'type' => 'select',
  77.                 'options' => array(
  78.                     '3000' => '3000 mc',
  79.                     '4000' => '4000 mc',
  80.                     '5000' => '5000 mc',
  81.                     '6000' => '6000 mc',
  82.                     '7000' => '7000 mc',
  83.                     '8000' => '8000 mc',
  84.                     '9000' => '9000 mc',
  85.                 ),
  86.                 'default' => '3000',
  87.                 'group' => 'slider2',
  88.                 'help' => __('Select the delay value before slide changing (milliseconds)', SG_TDN),
  89.             ),
  90.             'animation_time2' => array(
  91.                 'name' => __('Animation Time', SG_TDN),
  92.                 'type' => 'select',
  93.                 'options' => array(
  94.                     '300' => '300 mc',
  95.                     '400' => '400 mc',
  96.                     '500' => '500 mc',
  97.                     '600' => '600 mc',
  98.                     '700' => '700 mc',
  99.                     '800' => '800 mc',
  100.                     '900' => '900 mc',
  101.                 ),
  102.                 'default' => '700',
  103.                 'group' => 'slider2',
  104.                 'help' => __('Select the duration value of sliding animation (milliseconds)', SG_TDN),
  105.             ),
  106.             'slides' => array(
  107.                 'name' => __('Slides', SG_TDN),
  108.                 'type' => 'slides',
  109.                 'class' => 'sg-metabox-field sg-metabox-slides',
  110.                 'default' => array(
  111.                     'slides' => array(),
  112.                     'value' => 0,
  113.                 ),
  114.                 'help' => __('Add your images in the slider. Add link (no link if left "#"), button value and html caption for the slider (h1, p, img)', SG_TDN),
  115.             ),
  116.         );
  117.     }
  118.  
  119.     private function __clone() {}
  120.  
  121.     public static function getInstance()
  122.     {
  123.         if (is_null(self::$instance)) {
  124.             self::$instance = new SG_Slider_Module;
  125.         }
  126.         return self::$instance;
  127.     }
  128.  
  129.     public function inited()
  130.     {
  131.         return !is_null(self::$_vars);
  132.     }
  133.  
  134.     public function initVars($uniq, $params, $defaults, $global, $post_id)
  135.     {
  136.         self::$_vars = self::_initVars(self::moduleName, $uniq, self::$_params, self::$_fields, $params, $defaults, $global, $post_id);
  137.         return TRUE;
  138.     }
  139.  
  140.     public function setVars($uniq, $post_data, $post_id = NULL)
  141.     {
  142.         $px = self::_getPx($uniq, self::moduleName);
  143.  
  144.         if (isset($post_data[$px . '_slides']['slides'])) {
  145.             $slides = $post_data[$px . '_slides']['slides'];
  146.             foreach ($slides as $id => $slide) {
  147.                 if (!isset($slide['img']) OR empty($slide['img']) OR $slide['img'] == -1) {
  148.                     unset($post_data[$px . '_slides']['slides'][$id]);
  149.                 } else {
  150.                     $img = load_image_to_edit($slide['img'], get_post_mime_type($slide['img']), 'post-thumbnail');
  151.                     $w = imagesx($img);
  152.                     $h = imagesy($img);
  153.                     $h13 = round($h / 3);
  154.                     $h23 = round($h * 2 / 3) + 1;
  155.                     $ct = $cc = $cb = 0;
  156.                     for ($i = 0; $i < $h; $i++) {
  157.                         for ($j = 0; $j < $w; $j++) {
  158.                             $rgb = imagecolorat($img, $j, $i);
  159.                             $r = ($rgb >> 16) & 0xFF;
  160.                             $g = ($rgb >> 8) & 0xFF;
  161.                             $b = $rgb & 0xFF;
  162.                             if ($i < $h13) {
  163.                                 $ct += round(($r + $g + $b) / 3);
  164.                             } elseif ($i < $h23) {
  165.                                 $cc += round(($r + $g + $b) / 3);
  166.                             } else {
  167.                                 $cb += round(($r + $g + $b) / 3);
  168.                             }
  169.                         }
  170.                     }
  171.                     imagedestroy($img);
  172.                     $ct = round($ct / ($w * $h13));
  173.                     $cc = round($cc / ($w * ($h23 - $h13)));
  174.                     $cb = round($cb / ($w * ($h - $h23)));
  175.                     $post_data[$px . '_slides']['slides'][$id]['colors'] = $ct . ';' . $cc . ';' . $cb;
  176.                 }
  177.             }
  178.             if (empty($post_data[$px . '_slides']['slides'])) {
  179.                 $post_data[$px . '_slides']['value'] = 0;
  180.             }
  181.         }
  182.  
  183.         return self::_setVars(self::moduleName, $uniq, self::$_fields, $post_data, $post_id);
  184.     }
  185.  
  186.     public function resetVars($uniq, $post_id = NULL)
  187.     {
  188.         return self::_resetVars(self::moduleName, $uniq, $post_id);
  189.     }
  190.  
  191.     public function getMenuItem()
  192.     {
  193.         return __('Slider', SG_TDN);
  194.     }
  195.  
  196.     protected function _getSlidesField($uid, $params, $value, $default, $ug)
  197.     {
  198.         global $post_ID;
  199.         $nonce = wp_create_nonce('set_post_thumbnail-' . $post_ID);
  200.         $btn_name = __('Get Image', SG_TDN);
  201.         $ajax_url = get_template_directory_uri() . '/functions/modules/includes/image/ajax.php';
  202.  
  203.         $slides = (isset($value['slides'])) ? $value['slides'] : array();
  204.         $last = (isset($value['value'])) ? $value['value'] : 0;
  205.  
  206.         $c = '';
  207.  
  208.         foreach ($slides as $id => $slide) {
  209.             $c .= '<div class="sg-slide">';
  210.                 $c .= '<div class="sg-slide-in" id="' . $uid . '-' . $id . '" rel="' . $uid . '[slides][' . $id . ']">';
  211.                     $c .= '<a class="button sg-slide-rm ' . $uid . '-rm" href="#">-</a>';
  212.                     $c .= '<a class="button sg-slide-tt ' . $uid . '-tt" href="#">&#8593;</a>';
  213.                     $c .= '<a class="button sg-slide-tb ' . $uid . '-tb" href="#">&#8595;</a>';
  214.                     $c .= '<div class="sg-slide-img ' . $uid . '">';
  215.                         $c .= wp_get_attachment_image($slide['img'], 'post-thumbnail');
  216.                         $c .= SG_Form::hidden($uid . '[slides][' . $id . '][img]', $slide['img']);
  217.                     $c .= '</div>';
  218.                     $c .= '<div class="sg-slide-txt">';
  219.                         $ip = array('onfocus' => 'if (this.value==\'#\') this.value=\'\';',
  220.                                     'onblur' => 'if (this.value==\'\'){this.value=\'#\'}');
  221.                         $iv = (empty($slide['url']) OR $slide['url'] == '#') ? '#' : $slide['url'];
  222.                         $c .= SG_Form::input($uid . '[slides][' . $id . '][url]', $iv, $ip);
  223.                         $c .= SG_Form::input($uid . '[slides][' . $id . '][title]', $slide['title']);
  224.                         $c .= SG_Form::textarea($uid . '[slides][' . $id . '][txt]', $slide['txt']);
  225.                     $c .= '</div>';
  226.                 $c .= '</div>';
  227.             $c .= '</div>';
  228.         }
  229.  
  230.         $c .= '<div class="sg-slide">';
  231.             $c .= '<div class="sg-slide-in-add">';
  232.                 $c .= '<a id="' . $uid . '-add" class="button sg-slide-add" href="#">+</a>';
  233.                 $c .= SG_Form::hidden($uid . '[value]', $last, array('id' => $uid . '-last'));
  234.             $c .= '</div>';
  235.         $c .= '</div>';
  236.  
  237.         $c .= '<script type="text/javascript">';
  238.         $c .= '
  239. //<![CDATA[
  240. jQuery(document).ready(function($){
  241.     function ' . $uid . 'sg_get_slide(cur){
  242.         sg_post_nonce = "' . $nonce . '";
  243.         sg_slider_btn_name = "' . $btn_name . '";
  244.         sg_slider_ajaxurl = "' . $ajax_url . '";
  245.         var pID = jQuery("#post_ID").val();
  246.         window.sg_current_upload_slide = $(cur).parent().attr("id");
  247.         tb_show("Insert", "media-upload.php?post_id=" + pID + "&custom-media-upload=SI&type=image&TB_iframe=true");
  248.     }
  249.  
  250.     $("#' . $uid . '-add").click(function(e){
  251.         var i = $("#' . $uid . '-last").val();
  252.         $("<div class=\"sg-slide\"><div class=\"sg-slide-in\" id=\"' . $uid . '-" + i + "\" rel=\"' . $uid . '[slides][" + i + "]\"><a href=\"#\" class=\"button sg-slide-rm ' . $uid . '-rm\">-</a><a class=\"button sg-slide-tt ' . $uid . '-tt\" href=\"#\">&#8593;</a><a class=\"button sg-slide-tb ' . $uid . '-tb\" href=\"#\">&#8595;</a><div class=\"sg-slide-img ' . $uid . '\"></div><div class=\"sg-slide-txt\"><input type=\"text\" onblur=\"if (this.value==\'\'){this.value=\'#\'}\" onfocus=\"if (this.value==\'#\') this.value=\'\';\" value=\"#\" name=\"' . $uid . '[slides][" + i + "][url]\"><input type=\"text\" value=\"\" name=\"' . $uid . '[slides][" + i + "][title]\"> <textarea name=\"' . $uid . '[slides][" + i + "][txt]\"></textarea></div></div></div>").insertBefore($("#' . $uid . '-add").parent().parent());
  253.         $("#' . $uid . '-last").val(++i);
  254.         $(".' . $uid . ':last").click(function(){' . $uid . 'sg_get_slide(this);return false;});
  255.         $(".' . $uid . '-rm:last").click(function(e){$(this).parent().parent().remove();' . $uid . '_change();return false;});
  256.         $(".' . $uid . '-tt:last").click(function(e){' . $uid . '_tt_click(this);' . $uid . '_change();return false;});
  257.         $(".' . $uid . '-tb:last").click(function(e){' . $uid . '_tb_click(this);' . $uid . '_change();return false;});
  258.         ' . $uid . '_change();
  259.         return false;
  260.     });
  261.  
  262.     $(".' . $uid . '").click(function(){
  263.         ' . $uid . 'sg_get_slide(this);
  264.         return false;
  265.     });
  266.  
  267.     $(".' . $uid . '-rm").click(function(e){
  268.         $(this).parent().parent().remove();
  269.         ' . $uid . '_change();
  270.         return false;
  271.     });
  272.  
  273.     $(".' . $uid . '-tt").click(function(e){
  274.         ' . $uid . '_tt_click(this);
  275.         ' . $uid . '_change();
  276.         return false;
  277.     });
  278.  
  279.     $(".' . $uid . '-tb").click(function(e){
  280.         ' . $uid . '_tb_click(this);
  281.         ' . $uid . '_change();
  282.         return false;
  283.     });
  284.  
  285.     function ' . $uid . '_tt_click(a) {
  286.         var slides = $(".sg-slide > .sg-slide-in", $("#' . $uid . '-add").parent().parent().parent()).parent();
  287.         if ($(slides).length < 2) return false;
  288.         var slide = $(a).parent().parent();
  289.         var prev = $(slide).prev(".sg-slide");
  290.         if (!$(prev).length) return false;
  291.  
  292.         var slidea = $(".sg-slide-in input, .sg-slide-in textarea", $(slide));
  293.         var preva = $(".sg-slide-in input, .sg-slide-in textarea", $(prev));
  294.         var cp = $(prev).clone();
  295.         $(".' . $uid . ':last", $(cp)).click(function(){' . $uid . 'sg_get_slide(this);return false;});
  296.         $(".' . $uid . '-rm", $(cp)).click(function(e){$(this).parent().parent().remove();' . $uid . '_change();return false;});
  297.         $(".' . $uid . '-tt", $(cp)).click(function(e){' . $uid . '_tt_click(this);' . $uid . '_change();return false;});
  298.         $(".' . $uid . '-tb", $(cp)).click(function(e){' . $uid . '_tb_click(this);' . $uid . '_change();return false;});
  299.  
  300.         $(".sg-slide-in", $(cp)).attr("id", $(".sg-slide-in", $(slide)).attr("id"));
  301.         $(".sg-slide-in", $(cp)).attr("rel", $(".sg-slide-in", $(slide)).attr("rel"));
  302.         $(".sg-slide-in input, .sg-slide-in textarea", $(cp)).each(function(i){
  303.             $(this).attr("name", $(slidea[i]).attr("name"));
  304.         });
  305.         $(".sg-slide-in", $(slide)).attr("id", $(".sg-slide-in", $(prev)).attr("id"));
  306.         $(".sg-slide-in", $(slide)).attr("rel", $(".sg-slide-in", $(prev)).attr("rel"));
  307.         $(".sg-slide-in input, .sg-slide-in textarea", $(slide)).each(function(i){
  308.             $(this).attr("name", $(preva[i]).attr("name"));
  309.         });
  310.         $(prev).remove();
  311.         $(slide).after(cp);
  312.         return false;
  313.     }
  314.  
  315.     function ' . $uid . '_tb_click(a) {
  316.         var slides = $(".sg-slide > .sg-slide-in", $("#' . $uid . '-add").parent().parent().parent()).parent();
  317.         if ($(slides).length < 2) return false;
  318.         var slide = $(a).parent().parent();
  319.         var next = $(slide).next(".sg-slide");
  320.         if ($("#' . $uid . '-add", $(next)).length) return false;
  321.  
  322.         var slidea = $(".sg-slide-in input, .sg-slide-in textarea", $(slide));
  323.         var nexta = $(".sg-slide-in input, .sg-slide-in textarea", $(next));
  324.         var cp = $(next).clone();
  325.         $(".' . $uid . ':last", $(cp)).click(function(){' . $uid . 'sg_get_slide(this);return false;});
  326.         $(".' . $uid . '-rm", $(cp)).click(function(e){$(this).parent().parent().remove();' . $uid . '_change();return false;});
  327.         $(".' . $uid . '-tt", $(cp)).click(function(e){' . $uid . '_tt_click(this);' . $uid . '_change();return false;});
  328.         $(".' . $uid . '-tb", $(cp)).click(function(e){' . $uid . '_tb_click(this);' . $uid . '_change();return false;});
  329.  
  330.         $(".sg-slide-in", $(cp)).attr("id", $(".sg-slide-in", $(slide)).attr("id"));
  331.         $(".sg-slide-in", $(cp)).attr("rel", $(".sg-slide-in", $(slide)).attr("rel"));
  332.         $(".sg-slide-in input, .sg-slide-in textarea", $(cp)).each(function(i){
  333.             $(this).attr("name", $(slidea[i]).attr("name"));
  334.         });
  335.         $(".sg-slide-in", $(slide)).attr("id", $(".sg-slide-in", $(next)).attr("id"));
  336.         $(".sg-slide-in", $(slide)).attr("rel", $(".sg-slide-in", $(next)).attr("rel"));
  337.         $(".sg-slide-in input, .sg-slide-in textarea", $(slide)).each(function(i){
  338.             $(this).attr("name", $(nexta[i]).attr("name"));
  339.         });
  340.         $(next).remove();
  341.         $(slide).before(cp);
  342.         return false;
  343.     }
  344.  
  345.     function ' . $uid . '_change() {
  346.         var slides = $(".sg-slide > .sg-slide-in", $("#' . $uid . '-add").parent().parent().parent()).parent();
  347.         if ($(slides).length) {
  348.             $("a.button", $("#' . $uid . '-add").parent().parent().parent()).removeClass("disabled");
  349.             $("a.sg-slide-tt:first, a.sg-slide-tb:last", $("#' . $uid . '-add").parent().parent().parent()).addClass("disabled");
  350.         }
  351.         return false;
  352.     }
  353.  
  354.     ' . $uid . '_change();
  355. });
  356. //]]>
  357.             ';
  358.         $c .= '</script>';
  359.  
  360.         return $c;
  361.     }
  362.  
  363.     public function getAdminContent($uniq, $params, $defaults, $global = NULL, $post_id = NULL)
  364.     {
  365.         $c = self::_getAdminContent(self::moduleName, $uniq, self::$_params, self::$_fields, self::$_description, $params, $defaults, $global, $post_id);
  366.  
  367.         return $c;
  368.     }
  369.  
  370.     public function getSlidesCount()
  371.     {
  372.         return isset(self::$_vars['slides']['slides']) ? count(self::$_vars['slides']['slides']) : 0;
  373.     }
  374.  
  375.     public function showSlider()
  376.     {
  377.         return (self::$_vars['show'] != 'no');
  378.     }
  379.  
  380.     public function getSliderType()
  381.     {
  382.         return self::$_vars['show'];
  383.     }
  384.  
  385.     public function eSlider()
  386.     {
  387.         if (self::$_vars['show'] == 'main') {
  388.             if ($this->getSlidesCount() > 0) {
  389.  
  390.                 $js = '<script type="text/javascript">';
  391.                 $js .= '
  392. //<![CDATA[
  393. jQuery(window).load(function() {
  394.     var $ = jQuery;
  395.     jQuery("#main-slider").flexslider({
  396.         animation: "' . self::$_vars['effect'] . '",
  397.         animationSpeed: ' . self::$_vars['animation_time'] . ',
  398.         controlsContainer: ".main-ctrl-container",
  399.         easing: "swing",
  400.         slideshow: false,
  401.         controlNav: false,
  402.         directionNav: true,
  403.         start: function(slider) {
  404.             $(".slider-preloader").remove();
  405.  
  406.             slider.fadeIn()
  407.             .css({top: ( $(".main-ctrl-container").height() - $(".flex-viewport").height() ) / 2 })
  408.             .parent().find("a.flex-prev").delay(500)
  409.             .animate({marginLeft: "2em"});
  410.  
  411.             slider.parent().find("a.flex-next")
  412.             .delay(500)
  413.             .animate({marginRight: "2em"});
  414.  
  415.             var flexViewport = $(".flex-viewport").height();
  416.             var slideContent = $(".ef-slide-content").parent();
  417.  
  418.             slideContent.each(function() {
  419.                 $(this).css({ marginTop: (flexViewport - $(this).height()) / 2, marginBottom: (flexViewport - $(this).height()) / 2 })
  420.                 .find(".flex-caption").each(function(){
  421.                     $(this).css({top: ($(this).parent().height() - $(this).height()) / 2})
  422.                 })
  423.             });
  424.  
  425.             $(".flex-caption").delay(100).fadeIn(500)
  426.        },
  427.        before: function(slider) {
  428.             var flexViewport = $(".flex-viewport").height();
  429.             var $animatingTo = slider.slides.eq(slider.animatingTo);
  430.  
  431.             $animatingTo.find(".ef-slide-content").parent().each(function() {
  432.                 $(this)
  433.                 .css({ marginTop: (flexViewport - $(this).height()) / 2, marginBottom: (flexViewport - $(this).height()) / 2 });
  434.                 });
  435.  
  436.             $(".flex-caption").delay(100).css({display: "none"})
  437.        },
  438.        after: function(slider) {
  439.             $(".flex-caption").delay(100).fadeIn(500)
  440.        }
  441.     });
  442. });
  443. //]]>
  444.                 ';
  445.                 $js .= '</script>';
  446.  
  447.                 echo '<div class="main-ctrl-container">';
  448.                     echo '<div id="main-slider" class="clearfix">';
  449.                         echo '<ul class="slides">';
  450.                         foreach (self::$_vars['slides']['slides'] as $id => $slide) {
  451.                             $slide['url'] = (empty($slide['url'])) ? '#' : $slide['url'];
  452.                             echo '<li>';
  453.                                 echo '<div class="ef-slide-content">';
  454.                                     echo (!empty($slide['url']) AND $slide['url'] != '#') ? '<a href="' . $slide['url'] . '">' : '';
  455.                                         echo SG_HTML::image(wp_get_attachment_url($slide['img']));
  456.                                     echo (!empty($slide['url']) AND $slide['url'] != '#') ? '</a>' : '';
  457.                                     echo (!empty($slide['title']) OR !empty($slide['txt'])) ? '<div class="flex-caption">' : '';
  458.                                         echo (!empty($slide['title'])) ? '<div class="ef-big-text">' . strip_tags(__($slide['title'])) . '</div>' : '';
  459.                                         echo (!empty($slide['txt'])) ? '<div class="extras-descrp">' . nl2br(strip_tags(__($slide['txt']))) . '</div>' : '';
  460.                                     echo (!empty($slide['title']) OR !empty($slide['txt'])) ? '</div>' : '';
  461.                                 echo '</div>';
  462.                             echo '</li>';
  463.                         }
  464.                         echo '</ul>';
  465.                     echo '</div>';
  466.                 echo '</div>';
  467.                 echo $js;
  468.             } else {
  469.                 echo '<div class="main-ctrl-container ef-breadcrumbs"><div style="width:50%;margin:0 auto;">' . sg_message(__('No Slides in Slider', SG_TDN)) . '</div></div>';
  470.             }
  471.         } elseif (self::$_vars['show'] == 'full') {
  472.             if ($this->getSlidesCount() > 0) {
  473.  
  474.                 $imgs = '';
  475.                 foreach (self::$_vars['slides']['slides'] as $id => $slide) {
  476.                     $slide['url'] = (empty($slide['url'])) ? '#' : $slide['url'];
  477.                     $imgs .= '{image : "' . wp_get_attachment_url($slide['img']) . '", colors : "' . $slide['colors'] . '"';
  478.                     $imgs .= (!empty($slide['txt']) OR $slide['url'] != '#') ? ', title : "' : '';
  479.                    
  480.                     if( strpos($slide['txt'], ']') ){
  481.                         $imgs .= (!empty($slide['txt'])) ? '<div class=\"slidecaption-iner test\">' .  str_replace('"', '\"', str_replace(array("\r\n", "\n"), '', trim(__( do_shortcode($slide['txt']) ))))  . '</div>' : '';
  482.                     } else {
  483.                         $imgs .= (!empty($slide['txt'])) ? '<div class=\"slidecaption-iner\">' . strip_tags(str_replace('"', '\"', str_replace(array("\r\n", "\n"), '', trim(__($slide['txt'])))), '<h1><p><img><br>') . '</div>' : '';
  484.                     }                  
  485.                    
  486.                     $imgs .= ($slide['url'] != '#') ? '<a class=\"load-item ef-slide-link' . ((empty($slide['title'])) ? ' ef-empty' : '') . '\" href=\"' . $slide['url'] . '\">' . strip_tags(__($slide['title'])) . '</a>' : '';
  487.                     $imgs .= (!empty($slide['txt']) OR $slide['url'] != '#') ? '"' : '';
  488.                     $imgs .= '},';
  489.                 }
  490.  
  491.                 $js = '<script type="text/javascript">';
  492.                 $js .= '
  493. //<![CDATA[
  494. jQuery(document).ready(function($) {
  495.     var wpadminbarHeight = 0;
  496.     if ($("#wpadminbar").length) wpadminbarHeight = $("#wpadminbar").height();
  497.     $("#ef-header").attr("style", "height:" + ($(window).height() - wpadminbarHeight) + "px !important;");
  498.     $.supersized({
  499.         slide_interval      :   ' . self::$_vars['delay2'] . ',
  500.         transition          :   "' . self::$_vars['effect2'] . '",
  501.         transition_speed    :   ' . self::$_vars['animation_time2'] . ',
  502.         slide_links         :   "blank",
  503.         slides              :   [
  504.             ' . trim($imgs, ',') . '
  505.         ]
  506.     });
  507. });
  508. //]]>
  509.                 ';
  510.                 $js .= '</script>';
  511.  
  512.                 echo ($this->getSlidesCount() > 1) ? '<a id="prevslide" class="load-item"></a>' : '';
  513.                 echo ($this->getSlidesCount() > 1) ? '<a id="nextslide" class="load-item"></a>' : '';
  514.                 echo '<div id="slidecaption"></div>';
  515.                 echo '<div id="controls-wrapper" class="load-item">';
  516.                     echo '<div id="controls"><ul id="slide-list"></ul></div>';
  517.                 echo '</div>';
  518.                 echo $js;
  519.             } else {
  520.                 echo '<div class="main-ctrl-container ef-breadcrumbs"><div style="width:50%;margin:0 auto;">' . sg_message(__('No Slides in Slider', SG_TDN)) . '</div></div>';
  521.             }
  522.         }
  523.     }
  524.  
  525. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement