<?php

/**
 * @extension       Marlev Template
 * @author          Lev Milicenco<support@marlev.it>
 * @link            http://www.marlev.it
 * @copyright       Copyright 2017 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 Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Marlev\Component\Tmarlevv2\Administrator\Helper\ml_layout;
//for_use
defined('_JEXEC') or die;

$input = Factory::getApplication()->input;
$post_class = $input->getString("loadclass");
$post_position = $input->getString("position");
$positionclass = $input->getString("blockclass");
$post_parentid = $input->getString("parentid");
$render = new ml_layout($this->layout,$this->load->template);
$ifdata = $render->elabora_posdata($post_position);

$selected = new \stdClass;
if ($ifdata != false) {
    $selected->tablet = $ifdata->tabcollayout[0];
    $selected->mobile = $ifdata->mobcollayout[0];
    $selected->pc = $ifdata->defcollayout[0];
    $posdata = $ifdata;
} else {
    $selected->tablet = 12;
    $selected->mobile = 12;
    $selected->pc = 3;
    $posdata = $render->elabora_posdata($post_parentid);
}
$modules = ml_layout::get_modules(array("$post_position"));

echo '<div id="load_' . $post_position . '" class="pos_' . $post_position . ' ' . $positionclass . ' col-md-' . $selected->pc . ' col-lg-' . $selected->pc . ' col-12 col-sm-12" data-mobile="' . $selected->mobile . '" data-tablet="' . $selected->tablet . '" data-pc="' . $selected->pc . '" data-position="' . $post_position . '"> ';


echo '<div style="padding: 2px"> <div class="show-position">';

echo '<div>'.$post_position.'</div>';
echo '<span class="options-block" id="posconfig-' . $post_position . '" data-parentid="pos_' . $post_parentid . '"  data-subpos="' . $post_position . '" data-export-type="position"><span class="edit-block-options"><a id="openoptions-' . $post_position . '" class="edit-options" data-funcs="nofuncs" title="' . Text::_("COM_TMARLEV_EDIT") . '" data-parentid="#edit-' . $post_position . '"  data-configid="#configid-' . $post_position . '" ><span class="icon-apply"></span></a></span></span>';
echo $render->posconfig($post_parentid, $post_position, $selected, $posdata,$post_position);
echo ml_layout::show_modules($post_position,$modules);
echo'&nbsp;&nbsp;<span class="colcancel"><span class="hasTooltip icon-cancel" title="' . Text::_('COM_TMARLEV_DELETE_THIS_COL') . '"></span></span>';
echo '</div></div></div>';
?>
