cms-token/@core/app/PageBuilder/Addons/ContactArea/ContactAreaStyleThree.php

153 lines
5.3 KiB
PHP

<?php
namespace App\PageBuilder\Addons\ContactArea;
use App\FormBuilder;
use App\Helpers\FormBuilderCustom;
use App\Helpers\LanguageHelper;
use App\Helpers\SanitizeInput;
use App\PageBuilder\Fields\IconPicker;
use App\PageBuilder\Fields\Image;
use App\PageBuilder\Fields\Repeater;
use App\PageBuilder\Fields\Select;
use App\PageBuilder\Fields\Slider;
use App\PageBuilder\Fields\Text;
use App\PageBuilder\Fields\Textarea;
use App\PageBuilder\Helpers\RepeaterField;
use App\PageBuilder\Helpers\Traits\RepeaterHelper;
use App\PageBuilder\PageBuilderBase;
class ContactAreaStyleThree extends PageBuilderBase
{
use RepeaterHelper;
/**
* preview_image
* this method must have to implement by all widget to show a preview image at admin panel so that user know about the design which he want to use
* @since 1.0.0
* */
public function preview_image()
{
return 'contact-area/03.png';
}
/**
* admin_render
* this method must have to implement by all widget to render admin panel widget content
* @since 1.0.0
* */
public function admin_render()
{
$output = $this->admin_form_before();
$output .= $this->admin_form_start();
$output .= $this->default_fields();
$widget_saved_values = $this->get_settings();
$output .= $this->admin_language_tab(); //have to start language tab from here on
$output .= $this->admin_language_tab_start();
$all_languages = LanguageHelper::all_languages();
foreach ($all_languages as $key => $lang) {
$output .= $this->admin_language_tab_content_start([
'class' => $key == 0 ? 'tab-pane fade show active' : 'tab-pane fade',
'id' => "nav-home-" . $lang->slug
]);
$output .= Text::get([
'name' => 'title_'.$lang->slug,
'label' => __('Title'),
'value' => $widget_saved_values['title_' . $lang->slug] ?? null,
]);
$output .= $this->admin_language_tab_content_end();
}
$output .= $this->admin_language_tab_end(); //have to end language tab
$output .= Text::get([
'name' => 'location',
'label' => __('Location'),
'value' => $widget_saved_values['location'] ?? null,
]);
$output .= Select::get([
'name' => 'custom_form_id',
'label' => __('Custom Form'),
'placeholder' => __('Select form'),
'options' => FormBuilder::all()->pluck('title','id')->toArray(),
'value' => $widget_saved_values['custom_form_id'] ?? []
]);
$output .= $this->admin_form_submit_button();
$output .= $this->admin_form_end();
$output .= $this->admin_form_after();
return $output;
}
/**
* frontend_render
* this method must have to implement by all widget to render frontend widget content
* @since 1.0.0
* */
public function frontend_render(): string
{
$all_settings = $this->get_settings();
$current_lang = LanguageHelper::user_lang_slug();
$location = SanitizeInput::esc_html($all_settings['location']);
$location = sprintf(
'<div class="elementor-custom-embed"><iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=%s&amp;t=m&amp;z=%d&amp;output=embed&amp;iwloc=near" aria-label="%s"></iframe></div>',
rawurlencode($location),
10,
$location
);
$custom_form_id = SanitizeInput::esc_html($all_settings['custom_form_id']);
$title = SanitizeInput::esc_html($all_settings['title_'.$current_lang]);
$custom_form_markup = FormBuilderCustom::render_form($custom_form_id,null,null,'boxed-btn','contact-page-form');
return <<<HTML
<div class="contact-section">
<div class="map-wrapper">
<div class="container-fluid p-0">
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="contact_map">
<div id="map">
{$location}
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="contact-wrapper margin-top-120 margin-bottom-120">
<div class="col-lg-10">
<div class="contact-info bg-white" style="padding: 30px !important;">
<div class="row">
<div class="col-md-12">
<div class="section-title">
<h4 class="title">{$title}</h4>
</div>
</div>
</div>
{$custom_form_markup}
</div>
</div>
</div>
</div>
</div>
</div>
HTML;
}
/**
* widget_title
* this method must have to implement by all widget to register widget title
* @since 1.0.0
* */
public function addon_title()
{
return __('Contact Area: 03');
}
}