Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Sky/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Sky/Section.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\View\Sky;

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

class Section extends Bootstrap
{
    public $title = '';

    public $subtitle = '';

    public $description = '';

    public $subtitle_location;
    public $description_location;
    
    public $section;

    public $class_options = array('section_class', 'section_bg', 'bg_gradient', 'bg_opacity', 'section_text', 'section_padding', 'section_margin', 'align');

    public function display()
    {
        $this->data = (array) $this->data;

        $this->subtitle_location = $this->config['subtitle_location'] ?? 1;
        $this->description_location = $this->config['description_location'] ?? 1;

        if (!empty($this->data['title']) && $this->config['show_title'])
        {
            $this->title = $this->html->h2($this->data['title'], array('class' => $this->config['title_class']));
        }

        if (!empty($this->data['subtitle']) && $this->config['show_subtitle'])
        {
            $this->subtitle = $this->html->div($this->data['subtitle'], array('class' => $this->config['subtitle_class']));
        }

        if (!empty($this->data['description']) && $this->config['show_description'])
        {
            $this->description = $this->html->div($this->data['description'], array('class' => $this->config['description_class']));
        }

        return $this->display_layout();
    }
    
    
    public function get_style()
    {
        $style = '';
        if ($this->config['bg_image'])
        {
            $image = HTMLHelper::cleanImageURL($this->config['bg_image']);
            $style .= 'background-image:url(\'' . $image->url . '\');background-size:cover;';

            // background-attachment: fixed or scroll
            $style .= $this->config['bg_attach'] ? 'background-attachment:' . $this->config['bg_attach'] . ';' : '';

            // background-blend-mode
            $style .= $this->config['bg_blend'] ? 'background-blend-mode:' . $this->config['bg_blend'] . ';' : '';

            // background-color
            $style .= $this->config['bg_color'] ? 'background-color:' . $this->config['bg_color'] . ';' : '';
        }

        return $style;
    }

    // override as id is optional for section
    public function get_id()
    {
        return $this->config['section_id'] ?? '';
    }

    // Display based on layout
    public function display_layout()
    {
        $output = '';

        $title_block = '';
        switch ($this->subtitle_location)
        {
            case 1 : // Subtitle Above
                $title_block .= $this->subtitle . $this->title;
                break;

            case 2 : // Subtitle Below
                $title_block .= $this->title . $this->subtitle;
                break;
        }

        switch ($this->description_location)
        {
            case 1 : // Below
                $output .= $title_block . $this->description;
                break;

            case 2 : // Right
                $output .= '<div class="row">';
                    $output .= '<div class="col">';
                        $output .= $title_block;
                    $output .= '</div>';
                    $output .= '<div class="col">';
                        $output .= $this->description;
                    $output .= '</div>';
                $output .= '</div>';
                break;
        }

        return $output;
    }
}