178 lines
5.9 KiB
PHP
178 lines
5.9 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\PageBuilder\Addons\Process;
|
|
|
|
|
|
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\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 ProcessAreaStyleTwo 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 'process/style-02.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' => 'subtitle_'.$lang->slug,
|
|
'label' => __('Subtitle'),
|
|
'value' => $widget_saved_values['subtitle_' . $lang->slug] ?? null,
|
|
]);
|
|
$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 .= Repeater::get([
|
|
'multi_lang' => true,
|
|
'settings' => $widget_saved_values,
|
|
'id' => 'process_area_style_02',
|
|
'fields' => [
|
|
[
|
|
'type' => RepeaterField::TEXT,
|
|
'name' => 'title',
|
|
'label' => __('Title')
|
|
]
|
|
]
|
|
]);
|
|
|
|
$output .= Slider::get([
|
|
'name' => 'padding_top',
|
|
'label' => __('Padding Top'),
|
|
'value' => $widget_saved_values['padding_top'] ?? 120,
|
|
'max' => 500,
|
|
]);
|
|
$output .= Slider::get([
|
|
'name' => 'padding_bottom',
|
|
'label' => __('Padding Bottom'),
|
|
'value' => $widget_saved_values['padding_bottom'] ?? 120,
|
|
'max' => 500,
|
|
]);
|
|
$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();
|
|
$padding_top = SanitizeInput::esc_html($all_settings['padding_top']);
|
|
$padding_bottom = SanitizeInput::esc_html($all_settings['padding_bottom']);
|
|
$title = SanitizeInput::esc_html($all_settings['title_'.$current_lang]);
|
|
$subtitle = SanitizeInput::esc_html($all_settings['subtitle_'.$current_lang]);
|
|
|
|
$output = '<div class="process-area-wrap" data-padding-top="'.$padding_top.'" data-padding-bottom="'.$padding_bottom.'" >';
|
|
$output .='<div class="container">';
|
|
|
|
if (!empty($title)){
|
|
$output .= <<<HTML
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<div class="section-title desktop-center margin-bottom-60">
|
|
<span class="subtitle">{$subtitle}</span>
|
|
<h2 class="title">{$title}</h2>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
HTML;
|
|
}
|
|
|
|
$output .= ' <div class="row"><div class="col-lg-12"><ul class="cagency-work-process-list">';
|
|
$this->args['settings'] = RepeaterField::remove_default_fields($all_settings);
|
|
|
|
foreach ($this->args['settings'] as $key => $setting){
|
|
if (is_array($setting)){
|
|
$this->args['repeater'] = $setting;
|
|
$array_lang_item = $setting[array_key_last($setting)];
|
|
if (!empty($array_lang_item) && is_array($array_lang_item) && count($array_lang_item) > 0) {
|
|
foreach ($array_lang_item as $index => $value) {
|
|
|
|
$output .= $this->render_slider_markup($index); // for multiple array index
|
|
}
|
|
} else {
|
|
$output .= $this->render_slider_markup(); // for only one index of array
|
|
}
|
|
}
|
|
}
|
|
|
|
$output .= '</ul></div> </div></div></div>';
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* widget_title
|
|
* this method must have to implement by all widget to register widget title
|
|
* @since 1.0.0
|
|
* */
|
|
public function addon_title()
|
|
{
|
|
return __('Process Area: 02');
|
|
}
|
|
|
|
private function render_slider_markup(int $index = null): string
|
|
{
|
|
$title = $this->get_repeater_field_value('title', $index, LanguageHelper::user_lang_slug());
|
|
$number = $index+1;
|
|
return <<<HTML
|
|
<li class="single-work-process-item">
|
|
<div class="num-wrap style-{$number}">
|
|
<span class="number">{$number}</span>
|
|
</div>
|
|
<h4 class="title">{$title}</h4>
|
|
</li>
|
|
HTML;
|
|
|
|
}
|
|
|
|
|
|
} |