public static function parseDbArrayToCss($cssArray, $nl = "\n\r") { $css = ''; $deformations = self::get_deformation_css_tags(); $transparency = array('color' => 'color-transparency', 'background-color' => 'background-transparency', 'border-color' => 'border-transparency'); $check_parameters = array('border-width' => 'px', 'border-radius' => 'px', 'padding' => 'px', 'font-size' => 'px', 'line-height' => 'px'); foreach ($cssArray as $id => $attr) { $stripped = ''; if (strpos($attr['handle'], '.tp-caption') !== false) { $stripped = trim(str_replace('.tp-caption', '', $attr['handle'])); } $attr['advanced'] = json_decode($attr['advanced'], true); $styles = json_decode(str_replace("'", '"', $attr['params']), true); $styles_adv = $attr['advanced']['idle']; if ($stripped == '.News-Title') { /*echo '<pre>'; print_r($attr); echo '</pre>'; exit;*/ } $css .= $attr['handle']; if (!empty($stripped)) { $css .= ', ' . $stripped; } $css .= " {" . $nl; if (is_array($styles) || is_array($styles_adv)) { if (is_array($styles)) { foreach ($styles as $name => $style) { if (in_array($name, $deformations) && $name !== 'css_cursor') { continue; } if (!is_array($name) && isset($transparency[$name])) { //the style can have transparency! if (isset($styles[$transparency[$name]]) && $style !== 'transparent') { $style = RevSliderFunctions::hex2rgba($style, $styles[$transparency[$name]] * 100); } } if (!is_array($name) && isset($check_parameters[$name])) { $style = RevSliderFunctions::add_missing_val($style, $check_parameters[$name]); } if (is_array($style)) { $style = implode(' ', $style); } $ret = self::check_for_modifications($name, $style); if ($ret['name'] == 'cursor' && $ret['style'] == 'auto') { continue; } $css .= $ret['name'] . ':' . $ret['style'] . ";" . $nl; } } if (is_array($styles_adv)) { foreach ($styles_adv as $name => $style) { if (in_array($name, $deformations) && $name !== 'css_cursor') { continue; } if (is_array($style)) { $style = implode(' ', $style); } $ret = self::check_for_modifications($name, $style); if ($ret['name'] == 'cursor' && $ret['style'] == 'auto') { continue; } $css .= $ret['name'] . ':' . $ret['style'] . ";" . $nl; } } } $css .= "}" . $nl . $nl; //add hover $setting = json_decode($attr['settings'], true); if (isset($setting['hover']) && $setting['hover'] == 'true') { $hover = json_decode(str_replace("'", '"', $attr['hover']), true); $hover_adv = $attr['advanced']['hover']; if (is_array($hover) || is_array($hover_adv)) { $css .= $attr['handle'] . ":hover"; if (!empty($stripped)) { $css .= ', ' . $stripped . ':hover'; } $css .= " {" . $nl; if (is_array($hover)) { foreach ($hover as $name => $style) { if (in_array($name, $deformations) && $name !== 'css_cursor') { continue; } if (!is_array($name) && isset($transparency[$name])) { //the style can have transparency! if (isset($hover[$transparency[$name]]) && $style !== 'transparent') { $style = RevSliderFunctions::hex2rgba($style, $hover[$transparency[$name]] * 100); } } if (!is_array($name) && isset($check_parameters[$name])) { $style = RevSliderFunctions::add_missing_val($style, $check_parameters[$name]); } if (is_array($style)) { $style = implode(' ', $style); } $ret = self::check_for_modifications($name, $style); if ($ret['name'] == 'cursor' && $ret['style'] == 'auto') { continue; } $css .= $ret['name'] . ':' . $ret['style'] . ";" . $nl; } } if (is_array($hover_adv)) { foreach ($hover_adv as $name => $style) { if (in_array($name, $deformations) && $name !== 'css_cursor') { continue; } if (is_array($style)) { $style = implode(' ', $style); } $ret = self::check_for_modifications($name, $style); if ($ret['name'] == 'cursor' && $ret['style'] == 'auto') { continue; } $css .= $ret['name'] . ':' . $ret['style'] . ";" . $nl; } } $css .= "}" . $nl . $nl; } } } return $css; }
public static function parseDbArrayToCss($cssArray, $nl = "\n\r") { $css = ''; $deformations = self::get_deformation_css_tags(); $transparency = array('color' => 'color-transparency', 'background-color' => 'background-transparency', 'border-color' => 'border-transparency'); foreach ($cssArray as $id => $attr) { $stripped = ''; if (strpos($attr['handle'], '.tp-caption') !== false) { $stripped = trim(str_replace('.tp-caption', '', $attr['handle'])); } $attr['advanced'] = json_decode($attr['advanced'], true); $styles = json_decode(str_replace("'", '"', $attr['params']), true); $styles_adv = $attr['advanced']['idle']; $css .= $attr['handle']; if (!empty($stripped)) { $css .= ', ' . $stripped; } $css .= " {" . $nl; if (is_array($styles) || is_array($styles_adv)) { if (is_array($styles)) { foreach ($styles as $name => $style) { if (in_array($name, $deformations)) { continue; } if (!is_array($name) && isset($transparency[$name])) { //the style can have transparency! if (isset($styles[$transparency[$name]]) && $style !== 'transparent') { $style = RevSliderFunctions::hex2rgba($style, $styles[$transparency[$name]] * 100); } } if (is_array($style)) { $style = implode(' ', $style); } $css .= $name . ':' . $style . ";" . $nl; } } if (is_array($styles_adv)) { foreach ($styles_adv as $name => $style) { if (in_array($name, $deformations)) { continue; } if (is_array($style)) { $style = implode(' ', $style); } $css .= $name . ':' . $style . ";" . $nl; } } } $css .= "}" . $nl . $nl; //add hover $setting = json_decode($attr['settings'], true); if (@$setting['hover'] == 'true') { $hover = json_decode(str_replace("'", '"', $attr['hover']), true); $hover_adv = $attr['advanced']['hover']; if (is_array($hover) || is_array($hover_adv)) { $css .= $attr['handle'] . ":hover"; if (!empty($stripped)) { $css .= ', ' . $stripped . ':hover'; } $css .= " {" . $nl; if (is_array($hover)) { foreach ($hover as $name => $style) { if (in_array($name, $deformations)) { continue; } if (!is_array($name) && isset($transparency[$name])) { //the style can have transparency! if (isset($hover[$transparency[$name]]) && $style !== 'transparent') { $style = RevSliderFunctions::hex2rgba($style, $hover[$transparency[$name]] * 100); } } if (is_array($style)) { $style = implode(' ', $style); } $css .= $name . ':' . $style . ";" . $nl; } } if (is_array($hover_adv)) { foreach ($hover_adv as $name => $style) { if (in_array($name, $deformations)) { continue; } if (is_array($style)) { $style = implode(' ', $style); } $css .= $name . ':' . $style . ";" . $nl; } } $css .= "}" . $nl . $nl; } } } return $css; }
/** * * put html slider on the html page. * @param $data - mixed, can be ID ot Alias. */ public function putSliderBase($sliderID, $gal_ids = array(), $markup_export = false, $settings = array(), $order = array()) { $this->markup_export = $markup_export; try { $slver = apply_filters('revslider_remove_version', RevSliderGlobals::SLIDER_REVISION); self::$sliderSerial++; $this->slider = new RevSlider(); if ($sliderID !== '-99') { $this->slider->initByMixed($sliderID); } else { //do default $this->slider->initByMixed($sliderID); } //modify settings if there are any special settings given through the shortcode if (!empty($settings)) { $this->modify_settings($settings); } //modify settings for admin preview mode if ($this->previewMode == true) { $this->modifyPreviewModeSettings(); } //set slider language $isWpmlExists = RevSliderWpml::isWpmlExists(); $useWpml = $this->slider->getParam("use_wpml", "off"); if ($isWpmlExists && $useWpml == "on") { if ($this->previewMode == false) { $this->sliderLang = RevSliderFunctionsWP::getCurrentLangCode(); } } //edit html before slider $htmlBeforeSlider = ""; if ($markup_export === true) { $htmlBeforeSlider .= '<!-- FONT -->'; } if ($this->slider->getParam("load_googlefont", "false") == "true") { $googleFont = $this->slider->getParam("google_font"); if (is_array($googleFont)) { foreach ($googleFont as $key => $font) { } } else { $htmlBeforeSlider .= RevSliderOperations::getCleanFontImport($googleFont); } } $gfonts = $this->slider->getParam("google_font", array()); if (!empty($gfonts) && is_array($gfonts)) { foreach ($gfonts as $gf) { $gf = str_replace(array('"', '+'), array('', ' '), $gf); $htmlBeforeSlider .= RevSliderOperations::getCleanFontImport($gf); } } //add all google fonts of layers $gfsubsets = $this->slider->getParam("subsets", array()); $gf = $this->slider->getUsedFonts(false); foreach ($gf as $gfk => $gfv) { $tcf = $gfk . ':'; if (!empty($gfv['variants'])) { $mgfirst = true; foreach ($gfv['variants'] as $mgvk => $mgvv) { if (!$mgfirst) { $tcf .= ','; } $tcf .= $mgvk; $mgfirst = false; } } if (!empty($gfv['subsets'])) { $mgfirst = true; foreach ($gfv['subsets'] as $ssk => $ssv) { if (array_search(esc_attr($gfk . '+' . $ssv), $gfsubsets) !== false) { if ($mgfirst) { $tcf .= '&subset='; } if (!$mgfirst) { $tcf .= ','; } $tcf .= $ssv; $mgfirst = false; } } } $htmlBeforeSlider .= RevSliderOperations::getCleanFontImport($tcf); } if ($markup_export === true) { $htmlBeforeSlider .= '<!-- /FONT -->'; } //pub js to body handle if ($this->slider->getParam("js_to_body", "false") == "true") { $operations = new RevSliderOperations(); $arrValues = $operations->getGeneralSettingsValues(); $enable_logs = RevSliderFunctions::getVal($arrValues, "enable_logs", 'off'); if ($markup_export === true) { $htmlBeforeSlider .= '<!-- SCRIPTINCLUDE -->'; } if ($enable_logs == 'on') { $urlIncludeJS = RS_PLUGIN_URL . 'public/assets/js/jquery.themepunch.enablelog.js?rev=' . $slver; $htmlBeforeSlider .= '<script type="text/javascript" src="' . $urlIncludeJS . '"></script>'; } $urlIncludeJS = RS_PLUGIN_URL . 'public/assets/js/jquery.themepunch.tools.min.js?rev=' . $slver; $htmlBeforeSlider .= '<script type="text/javascript" src="' . $urlIncludeJS . '"></script>'; $urlIncludeJS = RS_PLUGIN_URL . 'public/assets/js/jquery.themepunch.revolution.min.js?rev=' . $slver; $htmlBeforeSlider .= '<script type="text/javascript" src="' . $urlIncludeJS . '"></script>'; if ($markup_export === true) { $htmlBeforeSlider .= '<!-- /SCRIPTINCLUDE -->'; } } //the initial id can be alias $sliderID = $this->slider->getID(); $bannerWidth = $this->slider->getParam("width", null, RevSlider::VALIDATE_NUMERIC, "Slider Width"); $bannerHeight = $this->slider->getParam("height", null, RevSlider::VALIDATE_NUMERIC, "Slider Height"); $sliderType = $this->slider->getParam("slider_type"); $slider_type = $this->slider->getParam("slider-type"); //set wrapper height $wrapperHeigh = 0; $wrapperHeigh += $this->slider->getParam("height"); //add thumb height if ($this->slider->getParam('enable_thumbnails', 'off') == 'on') { $wrapperHeigh += $this->slider->getParam('thumb_height'); } $slider_id = $this->slider->getParam('slider_id', ''); if (trim($slider_id) !== '') { $this->sliderHtmlID = $slider_id; } else { $this->sliderHtmlID = 'rev_slider_' . $sliderID . '_' . self::$sliderSerial; } $this->sliderHtmlID_wrapper = $this->sliderHtmlID . '_wrapper'; $containerStyle = ""; $sliderPosition = $this->slider->getParam("position", "center"); $do_overflow = ''; //set position: if ($sliderType != "fullscreen") { switch ($sliderPosition) { case "center": default: $containerStyle .= "margin:0px auto;"; break; case "left": $containerStyle .= "float:left;"; break; case "right": $containerStyle .= "float:right;"; break; } if ($this->slider->getParam('main_overflow_hidden', 'on') == 'on') { $do_overflow = ' tp-overflow-hidden'; } } //add background color $backgroundColor = esc_attr(trim($this->slider->getParam('background_color'))); if (!empty($backgroundColor)) { $containerStyle .= 'background-color:' . $backgroundColor . ';'; } //set padding $containerStyle .= 'padding:' . esc_attr($this->slider->getParam('padding', '0')) . 'px;'; //set margin: if ($sliderType != 'fullscreen') { if ($sliderPosition != 'center') { $containerStyle .= 'margin-left:' . esc_attr($this->slider->getParam('margin_left', '0', RevSlider::FORCE_NUMERIC)) . 'px;'; $containerStyle .= 'margin-right:' . esc_attr($this->slider->getParam('margin_right', '0', RevSlider::FORCE_NUMERIC)) . 'px;'; } $containerStyle .= 'margin-top:' . esc_attr($this->slider->getParam('margin_top', '0', RevSlider::FORCE_NUMERIC)) . 'px;'; $containerStyle .= 'margin-bottom:' . esc_attr($this->slider->getParam('margin_bottom', '0', RevSlider::FORCE_NUMERIC)) . 'px;'; } //set height and width: $bannerStyle = 'display:none;'; //add background image (to banner style) $showBackgroundImage = $this->slider->getParam('show_background_image', 'off'); if ($showBackgroundImage == 'true' || $showBackgroundImage == 'on') { $backgroundImage = esc_attr($this->slider->getParam('background_image')); $backgroundFit = esc_attr($this->slider->getParam('bg_fit', $this->slider->getParam('def-background_fit', 'cover'))); $backgroundRepeat = esc_attr($this->slider->getParam('bg_repeat', $this->slider->getParam('def-bg_repeat', 'no-repeat'))); $backgroundPosition = esc_attr($this->slider->getParam('bg_position', $this->slider->getParam('def-bg_position', 'center center'))); if (!empty($backgroundImage)) { $containerStyle .= "background-image:url(" . $backgroundImage . ");background-repeat:" . $backgroundRepeat . ";background-size:" . $backgroundFit . ";background-position:" . $backgroundPosition . ";"; } } //set wrapper and slider class: $sliderWrapperClass = "rev_slider_wrapper"; $sliderClass = "rev_slider"; switch ($sliderType) { case "responsitive": //@since 5.0: obsolete now, was custom //@since 5.0: obsolete now, was custom case "fixed": //@since 5.0: obsolete now //@since 5.0: obsolete now case 'auto': case 'fullwidth': $sliderWrapperClass .= " fullwidthbanner-container"; $sliderClass .= " fullwidthabanner"; // KRISZTIAN REMOVED SOME LINE //$bannerStyle .= "max-height:".$bannerHeight."px;height:".$bannerHeight."px;"; //$containerStyle .= "max-height:".$bannerHeight."px;"; break; case 'fullscreen': $sliderWrapperClass .= " fullscreen-container"; $sliderClass .= " fullscreenbanner"; break; default: $bannerStyle .= "height:" . $bannerHeight . "px;width:" . $bannerWidth . "px;"; $containerStyle .= "height:" . $bannerHeight . "px;width:" . $bannerWidth . "px;"; break; } $maxWidth = $this->slider->getParam('max_width', '0', RevSlider::FORCE_NUMERIC); if ($maxWidth > 0 && $this->slider->getParam('slider_type') == 'auto') { $containerStyle .= 'max-width:' . $maxWidth . 'px;'; } $htmlTimerBar = ""; $enable_progressbar = $this->slider->getParam('enable_progressbar', 'on'); $timerBar = $this->slider->getParam('show_timerbar', 'top'); $progress_height = $this->slider->getParam('progress_height', '5'); $progress_opa = $this->slider->getParam('progress_opa', '15'); $progressbar_color = $this->slider->getParam('progressbar_color', '#000000'); if ($enable_progressbar !== 'on' || $slider_type == 'hero') { $timerBar = 'hide'; } $progress_style = ' style="height: ' . esc_attr($progress_height) . 'px; background-color: ' . RevSliderFunctions::hex2rgba($progressbar_color, $progress_opa) . ';"'; switch ($timerBar) { case "top": $htmlTimerBar = '<div class="tp-bannertimer"' . $progress_style . '></div>'; break; case "bottom": $htmlTimerBar = '<div class="tp-bannertimer tp-bottom"' . $progress_style . '></div>'; break; case "hide": $htmlTimerBar = '<div class="tp-bannertimer tp-bottom" style="visibility: hidden !important;"></div>'; break; } //check inner / outer border $paddingType = $this->slider->getParam("padding_type", "outer"); if ($paddingType == "inner") { $sliderWrapperClass .= " tp_inner_padding"; } global $revSliderVersion; $add_alias = ''; if (is_super_admin() || is_admin_bar_showing()) { if (current_user_can('edit_theme_options')) { $add_alias = ' data-alias="' . esc_attr($this->slider->getAlias()) . '"'; } } echo $htmlBeforeSlider . "\n"; echo '<div id="' . $this->sliderHtmlID_wrapper . '" class="' . $sliderWrapperClass . '"' . $add_alias; $show_alternate = $this->slider->getParam("show_alternative_type", "off"); if ($show_alternate !== 'off') { $show_alternate_image = $this->slider->getParam("show_alternate_image", ""); echo ' data-aimg="' . $show_alternate_image . '" '; if ($show_alternate == 'mobile' || $show_alternate == 'mobile-ie8') { echo ' data-amobile="enabled" '; } else { echo ' data-amobile="disabled" '; } if ($show_alternate == 'mobile-ie8' || $show_alternate == 'ie8') { echo ' data-aie8="enabled" '; } else { echo ' data-aie8="disabled" '; } } echo ' style="' . $containerStyle . '">' . "\n"; echo '<!-- START REVOLUTION SLIDER ' . $revSliderVersion . ' ' . $sliderType . ' mode -->' . "\n"; echo ' <div id="' . $this->sliderHtmlID . '"'; echo ' class="' . $sliderClass . $do_overflow . '"'; echo ' style="' . $bannerStyle . '"'; echo ' data-version="' . $revSliderVersion . '">' . "\n"; echo $this->putSlides($gal_ids, $order); echo $htmlTimerBar; echo ' </div>' . "\n"; $this->putJS($markup_export); echo '</div>'; echo '<!-- END REVOLUTION SLIDER -->'; } catch (Exception $e) { $message = $e->getMessage(); $this->putErrorMessage($message); } }
/** * change rgb, rgba and hex to rgba like 120,130,50,0.5 (no () and rgb/rgba) * @since: 5.2.0 **/ public function convert_any_rgb_or_rgba($css, $type) { if (strpos($css, 'rgb') !== false) { //$css = explode(')', explode('(', $css)[1])[0]; $css_1 = explode('(', $css); $css_2 = explode(')', $css_1[1]); $css = $css_2[0]; } else { if ($type === "color-rgba") { $css = RevSliderFunctions::hex2rgba($css, false, true); } else { $css = RevSliderFunctions::hex2rgba($css, false, true, true); } } if ($type === "color-rgba" && count(explode(',', $css)) < 4) { $css .= ',1'; } return $css; }