233 lines
7.7 KiB
PHP
233 lines
7.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\PageBuilder\Addons\Iconbox;
|
|
use App\Helpers\LanguageHelper;
|
|
use App\Helpers\SanitizeInput;
|
|
use App\PageBuilder\Fields\IconPicker;
|
|
use App\PageBuilder\Fields\Image;
|
|
use App\PageBuilder\Fields\Number;
|
|
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;
|
|
use App\ProductCategory;
|
|
|
|
class IconBoxGridThree extends PageBuilderBase
|
|
{
|
|
protected $a = 1;
|
|
use RepeaterHelper;
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function preview_image()
|
|
{
|
|
return 'service/grid-07.png';
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
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' => 'section_subtitle_'.$lang->slug,
|
|
'label' => __('Section Subtitle'),
|
|
'value' => $widget_saved_values['section_subtitle_' . $lang->slug] ?? null,
|
|
]);
|
|
$output .= Text::get([
|
|
'name' => 'section_title_'.$lang->slug,
|
|
'label' => __('Section Title'),
|
|
'value' => $widget_saved_values['section_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' => 'image_box_grid_five',
|
|
'fields' => [
|
|
[
|
|
'type' => RepeaterField::TEXT,
|
|
'name' => 'title',
|
|
'label' => __('Title')
|
|
],
|
|
[
|
|
'type' => RepeaterField::TEXT,
|
|
'name' => 'url',
|
|
'label' => __('Url'),
|
|
],
|
|
[
|
|
'type' => RepeaterField::ICON_PICKER,
|
|
'name' => 'icon',
|
|
'label' => __('Icon')
|
|
],
|
|
[
|
|
'type' => RepeaterField::SUMMERNOTE,
|
|
'name' => 'description',
|
|
'label' => __('Description')
|
|
],
|
|
]
|
|
]);
|
|
|
|
$output .= Select::get([
|
|
'name' => 'section_title_alignment',
|
|
'label' => __('Section Title Alignment'),
|
|
'options' => [
|
|
'left-align' => __('Left Align'),
|
|
'center-align' => __('Center Align'),
|
|
'right-align' => __('Right Align'),
|
|
],
|
|
'value' => $widget_saved_values['section_title_alignment'] ?? null,
|
|
'info' => __('set alignment of section title')
|
|
]);
|
|
$output .= Slider::get([
|
|
'name' => 'padding_top',
|
|
'label' => __('Padding Top'),
|
|
'value' => $widget_saved_values['padding_top'] ?? 110,
|
|
'max' => 200,
|
|
]);
|
|
$output .= Slider::get([
|
|
'name' => 'padding_bottom',
|
|
'label' => __('Padding Bottom'),
|
|
'value' => $widget_saved_values['padding_bottom'] ?? 110,
|
|
'max' => 200,
|
|
]);
|
|
|
|
// add padding option
|
|
|
|
$output .= $this->admin_form_submit_button();
|
|
$output .= $this->admin_form_end();
|
|
$output .= $this->admin_form_after();
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function frontend_render()
|
|
{
|
|
$settings = $this->get_settings();
|
|
$current_lang = LanguageHelper::user_lang_slug();
|
|
$section_title = SanitizeInput::esc_html($settings['section_title_'.$current_lang]);
|
|
$section_subtitle = SanitizeInput::esc_html($settings['section_subtitle_'.$current_lang]);
|
|
$padding_top = SanitizeInput::esc_html($settings['padding_top']);
|
|
$padding_bottom = SanitizeInput::esc_html($settings['padding_bottom']);
|
|
$section_title_alignment = SanitizeInput::esc_html($settings['section_title_alignment']);
|
|
|
|
$category_markup = '';
|
|
|
|
$this->args['settings'] = RepeaterField::remove_default_fields($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) {
|
|
|
|
$category_markup .= $this->render_slider_markup($index); // for multiple array index
|
|
}
|
|
} else {
|
|
$category_markup .= $this->render_slider_markup(); // for only one index of array
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$section_title_markup = '';
|
|
if (!empty($section_title)) {
|
|
$section_title_markup .= <<<HTML
|
|
<div class="row justify-content-between ">
|
|
<div class="col-lg-12">
|
|
<div class="section-title desktop-center margin-bottom-60 laywer-home {$section_title_alignment}">
|
|
<span class="subtitle">{$section_subtitle}</span>
|
|
<h2 class="title">{$section_title}</h2>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
HTML;
|
|
}
|
|
|
|
|
|
return <<<HTML
|
|
<div class="latest-cause-area" data-padding-top="{$padding_top}" data-padding-bottom="{$padding_bottom}">
|
|
<div class="container">
|
|
{$section_title_markup}
|
|
<div class="row">
|
|
{$category_markup}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
HTML;
|
|
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function addon_title()
|
|
{
|
|
return __('Icon Box Grid: 03');
|
|
}
|
|
|
|
private function render_slider_markup(int $index)
|
|
{
|
|
$settings = $this->get_settings();
|
|
|
|
$url = $this->get_repeater_field_value('url', $index, LanguageHelper::user_lang_slug());
|
|
$icon = $this->get_repeater_field_value('icon', $index, LanguageHelper::user_lang_slug());
|
|
$image = $this->get_repeater_field_value('image', $index, LanguageHelper::user_lang_slug());
|
|
$image_markup = render_image_markup_by_attachment_id($image);
|
|
$title = $this->get_repeater_field_value('title', $index, LanguageHelper::user_lang_slug());
|
|
$description = $this->get_repeater_field_value('description', $index, LanguageHelper::user_lang_slug());
|
|
$icon_markup = '';
|
|
$a = $this->a;
|
|
$a >= 6 ? $this->a = 1 : $this->a++;
|
|
if (!empty($icon)){
|
|
$icon_markup = <<<HTML
|
|
<div class="icon style-{$a}">
|
|
<i class="{$icon}"></i>
|
|
</div>
|
|
HTML;
|
|
|
|
}
|
|
$a = $this->a;
|
|
$a >= 6 ? $this->a = 1 : $this->a++;
|
|
|
|
return <<<HTML
|
|
<div class="col-lg-4 col-md-6">
|
|
<div class="cagency-single-what-we-cover-item margin-bottom-30">
|
|
{$icon_markup}
|
|
<div class="content">
|
|
<h4 class="title"><a href="{$url}">{$title}</a></h4>
|
|
<p>{$description}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
HTML;
|
|
|
|
}
|
|
} |