<?php
    namespace Pixebuilder\Element;
    
    // prevent direct file access
	if( !defined( 'ABSPATH' ) ) exit;
    
    class Divider extends Item{

        static function get_name(){
            return 'divider';
        }

        static function get_default(){
            return array( 
                'padding' => array(
                    'bottom' => '30px'
                )
            );
        }

        static function get_title(){
            return esc_html__('Divider', 'pixebuilder');
        }

        static function get_icon(){
            return 'divider';
        }
        
        static function render_content($settings){

            $text = empty($settings['text'])? '': $settings['text'];

            $ret = '';
            if( !empty($text['type']) && $text['type'] == 'text' && !empty($text['text']) ){
                $text_atts = array(
                    'typo-preset' => empty($text['typo'])? '': $text['typo']
                );

                $ret .= '<div class="pixe-divider-wrap" >';
                $ret .= (empty($text['alignment']) || $text['alignment'] != 'left')? '<div class="pixe-divider" ></div>': '';
                $ret .= '<div class="pixe-text" ' . pixe_get_data_atts($text_atts) . ' >' . $text['text'] . '</div>';
                $ret .= (empty($text['alignment']) || $text['alignment'] != 'right')? '<div class="pixe-divider" ></div>': '';
                $ret .= '</div>';
            }else if( !empty($text['type']) && $text['type'] == 'icon' && !empty($text['icon']) ){
                $ret .= '<div class="pixe-divider-wrap" >';
                $ret .= (empty($text['alignment']) || $text['alignment'] != 'left')? '<div class="pixe-divider" ></div>': '';
                $ret .= pixe_get_icon($text['icon']);
                $ret .= (empty($text['alignment']) || $text['alignment'] != 'right')? '<div class="pixe-divider" ></div>': '';
                $ret .= '</div>';
            }else{  
                $ret = '<div class="pixe-divider-wrap pixe-divider" ></div>';
            }

            return $ret;
        }

    }

    \Pixe_Builder::register_element('Pixebuilder\Element\Divider');
