<?php

defined('_JEXEC') or die('resticted aceess');

AddonParser::addAddon('sp_list_team_html', 'sp_list_team_html_addon');
AddonParser::addAddon('sp_list_team_html_item', 'sp_list_team_html_item_addon');

function sp_list_team_html_addon($atts, $content)
{

    $class = $titlehtml = $output = '';

    extract(spAddonAtts(array(
        'column' => '',
        "class" => '',
    ), $atts));
    $output .= '<div class="list-html-teams row ' . $class . '">';
    $columns = 12 / $column;
    preg_match_all('/\[[^\]]*\]/i', $content, $matches);
    if (isset($matches[0]) && count($matches[0] > 0)) {
        foreach ($matches[0] as $item) {
            $output .= '<div class="team_html_item col-md-' . $columns . ' col-sm-6 col-xs-12">';
            $output .= AddonParser::spDoAddon($item);
            $output .= '</div>';
        }
    } else {
        $output .= AddonParser::spDoAddon($content);
    }
    $output .= '</div>';

    return $output;

}

function sp_list_team_html_item_addon($atts)
{

    $output = $heading = '';

    extract(spAddonAtts(array(
        "image" => '',
        "title" => '',
        "subtitle" => '',
        "contenthtml" => '',
        "fb_link" => '',
        "tw_link" => '',
        "g_link" => '',
    ), $atts));

    if ($image) {
        $output .= '<div class="boxes-avata">';
        $output .= '<div class="avatar-inner hover_animate">
                                <img src="' . $image . '" alt="">
                            </div>';
        $output .= '</div>';
    }
    if ($title) {
        $output .= '<h4 class="name">'.$title.'</h4>';
    }
    if ($subtitle) {
        $output .= '<div class="subtitle">';
        $output .= $subtitle;
        $output .= '</div>';
    }
    $output .= '<div class="description">';
    $output .= $contenthtml;
    $output .= '</div>';
    $output .= '<div class="social_link">';
    if ($fb_link) $output .= '<a href="' . $fb_link . '"><i class="fa fa-facebook"></i></a>';
    if ($tw_link) $output .= '<a href="' . $tw_link . '"><i class="fa fa-twitter"></i></a>';
    if ($g_link) $output .= '<a href="' . $g_link . '"><i class="fa fa-google-plus"></i></a>';
    $output .= '</div>';



    return $output;

}