function initComponent()
 {
     $component = PBData::get('component');
     foreach ($component as $componentName => $componentData) {
         $path = PLUGIN_PAGE_BUILDER_COMPONENT_PATH . $componentName . '/class/PB.Component.' . $this->formatName($componentName) . '.class.php';
         if (is_file($path)) {
             PBInclude::includeFileFromDir(PLUGIN_PAGE_BUILDER_COMPONENT_PATH . $componentName . '/class/');
             $className = 'PBComponent' . $this->formatName($componentName);
             $Component = new $className();
             if (method_exists($Component, 'initCustomPostType')) {
                 $Component->initCustomPostType();
             }
             $this->componentData[$componentName] = $Component->init();
             if (method_exists($Component, 'initPublic')) {
                 $Component->initPublic();
             }
             $this->addShortcode($componentName, $Component, $this->componentData[$componentName]);
             $style = $Component->addStyle();
             if (is_array($style)) {
                 $this->library['style'] += $style;
             }
             $script = $Component->addScript();
             if (is_array($script)) {
                 $this->library['script'] += $script;
             }
         }
     }
 }
 function createResponse()
 {
     if (ob_get_contents()) {
         ob_clean();
     }
     $response = array();
     $response['error'] = 0;
     $response['field'] = array();
     $Validation = new PBValidation();
     $Session = new PBSession();
     $Session->create();
     $id = $_POST['id'];
     $formMetaData = $Session->getValue($this->getComponentId(), $id);
     if ($formMetaData === false) {
         exit;
     }
     $response['debug'] = $formMetaData['debug'];
     $response['reset'] = $formMetaData['reset'];
     if (!array_key_exists('field', $formMetaData)) {
         exit;
     }
     if (!is_array($formMetaData['field'])) {
         exit;
     }
     if (!count($formMetaData['field'])) {
         exit;
     }
     $response['notice']['error'] = $formMetaData['notice']['error'];
     $response['notice']['success'] = $formMetaData['notice']['success'];
     $replace = array();
     foreach ($formMetaData['field'] as $fieldIndex => $fieldData) {
         if ($fieldData['type'] == 'submit') {
             continue;
         }
         if (!array_key_exists($fieldIndex, $_POST)) {
             $response['error'] = 1;
             continue;
         }
         $value = $_POST[$fieldIndex];
         if ($Validation->isNotEmpty($fieldData['name'])) {
             if (!array_key_exists($fieldData['name'], $replace)) {
                 $replace[$fieldData['name']] = $value;
             }
         }
         if ($fieldData['type'] == 'email') {
             if ($Validation->isNotEmpty($value) || $fieldData['mandatory'] == 1) {
                 if (!$Validation->isEmailAddress($value)) {
                     $response['error'] = 1;
                     $response['field'][$fieldIndex]['notice'] = $fieldData['notice'];
                 }
             }
         } else {
             if ($fieldData['mandatory'] == 1) {
                 if ($Validation->isEmpty($value)) {
                     $response['error'] = 1;
                     $response['field'][$fieldIndex]['notice'] = $fieldData['notice'];
                 }
             }
         }
     }
     if ($response['error'] == 1) {
         PBHelper::ajaxResponse($response);
     }
     PBInclude::includeClass(PLUGIN_PAGE_BUILDER_LIBRARY_PATH . 'phpMailer/PHPMailerAutoload.php', array('PHPMailer'));
     $mail = new PHPMailer();
     $mail->CharSet = 'UTF-8';
     foreach ($replace as $index => $value) {
         $formMetaData['sender']['name'] = preg_replace('/\\(' . $index . '\\)/', $value, $formMetaData['sender']['name']);
         $formMetaData['sender']['email'] = preg_replace('/\\(' . $index . '\\)/', $value, $formMetaData['sender']['email']);
     }
     if ($Validation->isEmailAddress($formMetaData['sender']['email']) && $Validation->isNotEmpty($formMetaData['sender']['name'])) {
         $mail->SetFrom($formMetaData['sender']['email'], $formMetaData['sender']['name']);
         $mail->AddReplyTo($formMetaData['sender']['email'], $formMetaData['sender']['name']);
     }
     $mail->AddAddress($formMetaData['recipient']['email'], $formMetaData['recipient']['name']);
     $recipientAdditionalData = mb_split(';', $formMetaData['recipient']['additional']);
     foreach ($recipientAdditionalData as $value) {
         $recipientAdditional = mb_split(':', $value);
         PBHelper::removeUIndex($recipientAdditional, 0, 1);
         if ($Validation->isEmailAddress($recipientAdditional[1]) && $Validation->isNotEmpty($recipientAdditional[0])) {
             $mail->AddAddress($recipientAdditional[1], $recipientAdditional[0]);
         }
     }
     if ($formMetaData['debug'] == 1) {
         $mail->SMTPDebug = true;
     }
     if ($Validation->isNotEmpty($formMetaData['sender']['smtp_host'])) {
         $mail->IsSMTP();
         $mail->SMTPAuth = true;
         $mail->Port = $formMetaData['sender']['smtp_port'];
         $mail->Host = $formMetaData['sender']['smtp_host'];
         $mail->Username = $formMetaData['sender']['smtp_username'];
         $mail->Password = $formMetaData['sender']['smtp_password'];
         $mail->SMTPSecure = $formMetaData['sender']['smtp_secure_connection_type'];
     }
     $mail->Subject = $formMetaData['message_subject'];
     $value = array_map('htmlspecialchars', $replace);
     $body = $formMetaData['message_content'];
     foreach ($replace as $index => $value) {
         $body = preg_replace('/\\[' . $index . '\\]/', $value, $body);
     }
     $mail->MsgHTML(apply_filters('the_content', $body));
     if (!$mail->Send()) {
         $response['error'] = 1;
         PBHelper::ajaxResponse($response);
     }
     PBHelper::ajaxResponse($response);
 }
Beispiel #3
0
<?php

/******************************************************************************/
/******************************************************************************/
require_once plugin_dir_path(__FILE__) . 'define.php';
/******************************************************************************/
require_once PLUGIN_PAGE_BUILDER_CLASS_PATH . 'PB.File.class.php';
require_once PLUGIN_PAGE_BUILDER_CLASS_PATH . 'PB.Include.class.php';
require_once PLUGIN_PAGE_BUILDER_CLASS_PATH . 'PB.PageBuilder.class.php';
PBInclude::includeFileFromDir(PLUGIN_PAGE_BUILDER_CLASS_PATH);
/******************************************************************************/
/******************************************************************************/
 function includeLibrary($path)
 {
     PBInclude::includeFile(PLUGIN_PAGE_BUILDER_PATH . 'component/' . $this->getComponentId() . '/library/' . $path);
 }
    function processShortcodeLayout($attribute, $content, $tag)
    {
        $attribute = $this->processAttribute($tag, $attribute);
        $Border = new PBBorder();
        $Layout = new PBLayout();
        $Background = new PBBackground();
        $Validation = new PBValidation();
        $style = array();
        $option = array();
        if (!$Layout->isLayout($attribute['layout'])) {
            return;
        }
        if (!$Layout->isLayoutLine($attribute['layout_line'])) {
            return;
        }
        if (!$Validation->isBool($attribute['bg_parallax_enable'])) {
            return;
        }
        if (!$Validation->isBool($attribute['bg_parallax_mobile_enable'])) {
            return;
        }
        if (!$Validation->isNumber($attribute['bg_parallax_speed'], 0, 100)) {
            return;
        }
        if ($Validation->isColor($attribute['bg_color'])) {
            $style['background-color'] = PBColor::getColor($attribute['bg_color']);
        }
        if ($Validation->isNotEmpty($attribute['bg_position'])) {
            $style['background-position'] = $attribute['bg_position'];
        }
        if ($Validation->isNotEmpty($attribute['bg_repeat'])) {
            $style['background-repeat'] = $attribute['bg_repeat'];
        }
        if ($Validation->isNotEmpty($attribute['bg_image'])) {
            $style['background-image'] = 'url(\'' . $attribute['bg_image'] . '\')';
        }
        if ($Validation->isNotEmpty($attribute['bg_size_a'])) {
            if (array_key_exists($attribute['bg_size_a'], $Background->backgroundSize)) {
                if (in_array($attribute['bg_size_a'], array('length', 'percentage'))) {
                    if ($Validation->isNotEmpty($attribute['bg_size_b'])) {
                        $style['background-size'] = $attribute['bg_size_b'];
                    }
                } else {
                    $style['background-size'] = $attribute['bg_size_a'];
                }
            }
        }
        if (!$Validation->isBool($attribute['video_loop'])) {
            return;
        }
        if (!$Validation->isBool($attribute['video_muted'])) {
            return;
        }
        if (!$Validation->isBool($attribute['video_autoplay'])) {
            return;
        }
        if (!$Validation->isBool($attribute['video_control'])) {
            return;
        }
        if ($Validation->isNotEmpty($attribute['padding_top'])) {
            $style['padding-top'] = (int) $attribute['padding_top'] . 'px';
        }
        if ($Validation->isNotEmpty($attribute['padding_right'])) {
            $style['padding-right'] = (int) $attribute['padding_right'] . 'px';
        }
        if ($Validation->isNotEmpty($attribute['padding_bottom'])) {
            $style['padding-bottom'] = (int) $attribute['padding_bottom'] . 'px';
        }
        if ($Validation->isNotEmpty($attribute['padding_left'])) {
            $style['padding-left'] = (int) $attribute['padding_left'] . 'px';
        }
        if (array_key_exists($attribute['border_top_style'], $Border->style)) {
            $style['border-top-style'] = $attribute['border_top_style'];
        }
        if ($Validation->isNumber($attribute['border_top_width'], 0, 999)) {
            $style['border-top-width'] = $attribute['border_top_width'] . 'px';
        }
        if ($Validation->isColor($attribute['border_top_color'])) {
            $style['border-top-color'] = PBColor::getColor($attribute['border_top_color']);
        }
        if (array_key_exists($attribute['border_right_style'], $Border->style)) {
            $style['border-right-style'] = $attribute['border_right_style'];
        }
        if ($Validation->isNumber($attribute['border_right_width'], 0, 999)) {
            $style['border-right-width'] = $attribute['border_right_width'] . 'px';
        }
        if ($Validation->isColor($attribute['border_right_color'])) {
            $style['border-right-color'] = PBColor::getColor($attribute['border_right_color']);
        }
        if (array_key_exists($attribute['border_bottom_style'], $Border->style)) {
            $style['border-bottom-style'] = $attribute['border_bottom_style'];
        }
        if ($Validation->isNumber($attribute['border_bottom_width'], 0, 999)) {
            $style['border-bottom-width'] = $attribute['border_bottom_width'] . 'px';
        }
        if ($Validation->isColor($attribute['border_bottom_color'])) {
            $style['border-bottom-color'] = PBColor::getColor($attribute['border_bottom_color']);
        }
        if (array_key_exists($attribute['border_left_style'], $Border->style)) {
            $style['border-left-style'] = $attribute['border_left_style'];
        }
        if ($Validation->isNumber($attribute['border_left_width'], 0, 999)) {
            $style['border-left-width'] = $attribute['border_left_width'] . 'px';
        }
        if ($Validation->isColor($attribute['border_left_color'])) {
            $style['border-left-color'] = PBColor::getColor($attribute['border_left_color']);
        }
        /***/
        $MobileDetect = new Mobile_Detect();
        $mobile = (int) $MobileDetect->isMobile();
        /***/
        $videoHTML = null;
        $video = $Validation->isNotEmpty($attribute['video_format_webm']) || $Validation->isNotEmpty($attribute['video_format_ogg']) || $Validation->isNotEmpty($attribute['video_format_mp4']);
        if ($video && $attribute['video_mobile_enable'] != 1) {
            PBInclude::includeClass(PLUGIN_PAGE_BUILDER_LIBRARY_PATH . 'mobileDetect/Mobile_Detect.php', array('Mobile_Detect'));
            if ($mobile) {
                $video = false;
            }
        }
        if ($video) {
            $sourceHTML = null;
            $videoControlHTML = null;
            $videoAttributeHTML = null;
            if ($Validation->isNotEmpty($attribute['video_format_mp4'])) {
                $sourceHTML .= '<source type="video/mp4" src="' . esc_attr($attribute['video_format_mp4']) . '" />';
            }
            if ($Validation->isNotEmpty($attribute['video_format_webm'])) {
                $sourceHTML .= '<source type="video/webm" src="' . esc_attr($attribute['video_format_webm']) . '" />';
            }
            if ($Validation->isNotEmpty($attribute['video_format_ogg'])) {
                $sourceHTML .= '<source type="video/ogg" src="' . esc_attr($attribute['video_format_ogg']) . '" />';
            }
            if ($attribute['video_loop']) {
                $videoAttributeHTML .= ' loop';
            }
            if ($attribute['video_muted']) {
                $videoAttributeHTML .= ' muted';
            }
            if ($attribute['video_autoplay']) {
                $videoAttributeHTML .= ' autoplay';
            }
            if ($attribute['video_control'] == 1) {
                $videoControlHTML = '
					<div class="pb-line-video-control">
						<a href="#" class="pb-line-video-control-toggle-play pb-line-video-control-toggle-play-' . ($attribute['video_autoplay'] == 1 ? 'on' : 'off') . '"></a>
						<a href="#" class="pb-line-video-control-toggle-sound pb-line-video-control-toggle-sound-' . ($attribute['video_muted'] == 1 ? 'off' : 'on') . '"></a>
					</div>
				';
            }
            $videoHTML = '
				<div class="pb-line-video">
					<video preload="auto"' . $videoAttributeHTML . '>
						' . $sourceHTML . '
					</video>
				</div>
				' . $videoControlHTML . '
			';
        }
        /***/
        $overlay = false;
        $overlayHTML = null;
        if ($Validation->isColor($attribute['overlay_color'])) {
            $overlay = true;
            $overlayHTML = '<div class="pb-line-overlay" style="background-color:' . PBColor::getColor($attribute['overlay_color']) . '"></div>';
        }
        /***/
        $class = array(array('pb-line', 'pb-clear-fix', $attribute['css_class'], $video || $overlay ? 'pb-line-include-video' : null), array('pb-layout', $Layout->getLayoutCSSClass($attribute['layout']), 'pb-reset-list', 'pb-clear-fix'));
        if (in_array($attribute['layout_line'], array('boxed'))) {
            $class[0][] = 'pb-main';
        }
        if (in_array($attribute['layout_line'], array('boxed', 'wide', ''))) {
            $class[1][] = 'pb-main';
        }
        $key = array('bg_parallax_speed', 'bg_parallax_enable', 'bg_parallax_mobile_enable');
        foreach ($key as $index) {
            $option[$index] = $attribute[$index];
        }
        $id = PBHelper::createId('pb_line');
        $css = esc_attr($attribute['css_group']);
        if ($Validation->isNotEmpty($css)) {
            array_push($class[0], 'pb-line-css-group-' . $css);
        }
        PBComponentData::set('layout', 'index', 0);
        PBComponentData::set('layout', 'layout', $attribute['layout']);
        $html = '
			<div id="' . $id . '" ' . PBHelper::createClassAttribute($class[0]) . PBHelper::createStyleAttribute($style) . '>
				' . $videoHTML . '
				' . $overlayHTML . '
				<ul' . PBHelper::createClassAttribute($class[1]) . '>' . PLUGIN_PAGE_BUILDER_SHORTCODE_CONTENT . '</ul>
			</div>
			<div class="pb-script-tag">
				<script type="text/javascript">
					jQuery(document).ready(function($)
					{
						$("#' . $id . '").PBLayout(' . json_encode($option) . ',' . $mobile . ');
					});
				</script>
			</div>
		';
        return PBHelper::formatHTML($html, PBHelper::formatContent($content, true, false, false));
    }