<?php
/**
 * @package DJ-Catalog2-Yootheme
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@m.herzberg
 */

use Joomla\CMS\Component\ComponentHelper;

$html = '';
$params = ComponentHelper::getParams('com_djcatalog2');
$app = \JFactory::getApplication();
$jinput = $app->input;
$user	= JFactory::getUser();
$groups	= $user->getAuthorisedViewLevels();
$categories = Djc2Categories::getInstance(array('state'=>'1', 'access'=>$groups));

// current category
$category = $categories->get((int) $jinput->getInt('cid',0));
$subcategories = null;
if (!empty($category)) {
    $subcategories = $category->getChildren();
    //$subcategories = $model->getSubCategories($category);
}
if($props['display_type'] == 'default_list'){
    ob_start();
    include __DIR__ . '/default_subcategories.php';
    $html .= ob_get_contents();
    ob_end_clean();
}
if ($props['display_type'] == 'standard_list'){
    ob_start();
    include __DIR__.'/standard_list.php';
    $html .= ob_get_contents();
    ob_end_clean();
}

$props['categories'] = $html;
if ($props['categories']) {
    $el = $this->el('div', [

        'class' => $this->expr([
            'uk-panel',
            'uk-margin[-{cart_margin}]-top {@!cart_margin: remove}',
            'uk-margin-remove-top {@cart_margin: remove}',
            'uk-margin-remove-bottom',
        ], $props),
    ]);

//Style position && size of an element
    $el->attr('style', [
        'position:{position_categories};' => ['position_categories' => $props['position_categories']],
        'left: {position_left_categories}px;' => ['position_left_categories' => $props['position_left_categories']],
        'right: {position_right_categories}px;' => ['position_right_categories' => $props['position_right_categories']],

  'top: {position_top_categories}px;' => ['position_top_categories' => $props['position_top_categories']],
        'bottom: {position_bottom_categories}px;' => ['position_bottom_categories' => $props['position_bottom_categories']],
        'z-index:{position_z_index_categories};' => ['position_z_index_categories' => $props['position_z_index_categories']],
        'width:{categories_width};' => ['categories_width' => $props['categories_width']],
        'height:{categories_height};' => ['categories_height' => $props['categories_height']],

    ], $props);


    echo $el($props, $attrs, $props['categories']);
}
?>

