Your IP : 216.73.217.80


Current Path : /home/jlgagfroyt/www/plugins/system/articlesanywhere/src/Output/Data/
Upload File :
Current File : /home/jlgagfroyt/www/plugins/system/articlesanywhere/src/Output/Data/Div.php

<?php
/**
 * @package         Articles Anywhere
 * @version         13.0.2
 * 
 * @author          Peter van Westen <info@regularlabs.com>
 * @link            http://regularlabs.com
 * @copyright       Copyright © 2022 Regular Labs All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

namespace RegularLabs\Plugin\System\ArticlesAnywhere\Output\Data;

defined('_JEXEC') or die;

class Div extends Data
{
    public function get($key, $attributes)
    {
        $tag_attributes = [];

        if (isset($attributes->class))
        {
            $tag_attributes[] = 'class="' . $attributes->class . '"';
        }

        $style = [];

        if (isset($attributes->width))
        {
            if (is_numeric($attributes->width))
            {
                $attributes->width .= 'px';
            }
            $style[] = 'width:' . $attributes->width;
        }

        if (isset($attributes->height))
        {
            if (is_numeric($attributes->height))
            {
                $attributes->height .= 'px';
            }
            $style[] = 'height:' . $attributes->height;
        }

        if (isset($attributes->align))
        {
            $style[] = 'float:' . $attributes->align;
        }
        else if (isset($attributes->float))
        {
            $style[] = 'float:' . $attributes->float;
        }

        if ( ! empty($style))
        {
            $tag_attributes[] = 'style="' . implode(';', $style) . ';"';
        }

        if (empty($tag_attributes))
        {
            return '<div>';
        }

        return trim('<div ' . implode(' ', $tag_attributes)) . '>';
    }
}