<?php

/**
 * @extension       Marlev Template
 * @author          Lev Milicenco<support@marlev.it>
 * @link            http://www.marlev.it
 * @copyright       Copyright 2022 marlev.it All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */
require_once JPATH_ROOT . '/administrator/components/com_tmarlevv2/src/Helper/loader.php';
use Marlev\Component\Tmarlevv2\Administrator\Helper\ml_layout;
use Joomla\CMS\Factory;
//for_use
defined('_JEXEC') or die;
function converter($n)
{
    return $n;
}

function array_map_recursive($input)
{
    $output = array();
    $input = (array)$input;
    foreach ($input as $key => $data) {
        if (is_object($data)) {
            $data = (array)$data;
        }
        if (is_array($data)) {
            $output[$key] = array_map_recursive($data);
        } else {
            $output[$key] =$data;
        }
    }
    return $output;
}

$input = Factory::getApplication()->input;
include JPATH_ADMINISTRATOR . '/components/com_tmarlevv2' . "/functions/layout.php";
$render = new ml_layout($this->layout, $this->load->template);
$tmconfig = $input->get("tmconfig", "", false);
$getter = json_decode($tmconfig);
?>
<div id="posconfig-loader">
    <?php foreach ($getter as $key) {
        $selected = (object)array_map_recursive($key->selected);
        $subposdata = (object)array_map_recursive($key->subposdata);
        echo $render->posconfig($key->parentid, $key->subpos, $selected, $subposdata, $key->subpos);
    } ?>
</div>


