
<?php
//for_use


/**
 *
 * @extension       Marlev - Template Manager
 * @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
 */
defined('_JEXEC') or die;

function defined_layout() {
    $layout = new \stdClass();

//Define sections
 $content = ['contentcontainer'];
    $layout->sections = ["content" => $content];

//DEFINIZIONI PARAMS PER MODIFICA SEZIONI
    $layout->positions['ml_body'] = array(
        "width" => "",
        "defpositions" => [""],
        "positions" => false,
        "innertop" => false,
        "innerbottom" => false,
        "params" => ["sections", "optionbody"]
    );

    foreach ($layout->sections as $key => $value) {
        //in key _section per fissare possibile assomiglianze con i moduli,
        //questa assegnazione e' per le sezioni
        $layout->positions[$key . '_section'] = array(
            "width" => "",
            "defpositions" => [""],
            "positions" => false,
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["sections", "container"]
        );
        //foreach per le sezioni delle posizioni
        foreach ($value as $vkey => $vvalue) {
            $layout->positions[$vvalue . '_subsection'] = array(
                "width" => "",
                "defpositions" => [""],
                "positions" => false,
                "innertop" => false,
                "innerbottom" => false,
                "params" => ["sections", "optionssection","child"]
            );
        }
    }
// Contunua con la variabile giu $incontent_sections
//DEFINIZIONI PARAMS PER POSIZIONI DEI MODUL
//START FOREACHS PER l'assegnazione dei parametri ai posizioni simili
    $default_4_moduli_attivi = ['position-1', 'position-2', 'position-3', 'position-4', 'position-5', 'position-6', 'position-7', 'position-8'];

    $layout->load = ["55afd6b24611c5b57694f71431c76c47", "f4a368bbc4b8200bc53b0fa7f7841d23"];
    foreach ($default_4_moduli_attivi as $key => $value) {
        $layout->positions[$value] = array(
            "width" => "container",
            "defpositions" => [$value . "-1", $value . "-2", $value . "-3", $value . "-4"],
            "positions" => false,
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["standard4col", "optionsfull"]//, "moveall"
        );
    }

    $default_inners_similar = ['incontent', 'bottomcontent', 'topcontent', 'copyright',"banner"];
    foreach ($default_inners_similar as $key => $value) {
        $layout->positions[$value] = array(
            "width" => "child-row-padding-0",
            "defpositions" => [$value . '-1', $value . '-2', $value . '-3', $value . '-4'],
            "positions" => false,
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["standard4col", "optionsfull"]//, "moveall"
        );
    }
//    $default = ["sitelogo"=>"logo","sitemenu"=>"menu","socialbtns"=>"socialbtn"];
//    foreach ($default as $key => $value) {
//        $layout->positions[$key] = array(
//            "width" => "child-row-padding-0",
//            "defpositions" => [$value],
//            "positions" => false,
//            "innertop" => false,
//            "innerbottom" => false,
//            "params" => ["menufull"]
//        );
//    }
//    foreach($default as $b=>$br) {
//        $layout->positions[$b.'_subsection'] = array(
//            "width" => "",
//            "defpositions" => [""],
//            "positions" => false,
//            "innertop" => false,
//            "innerbottom" => false,
//            "params" => ["sections", "optionssection"]
//        );
//    }
    //Aggiunta DEFINIZIONI PARAMS PER MODIFICA SEZIONI
    //$incontent_sections = array_merge($default, );
    foreach ($default_inners_similar as $vkey => $vvalue) {
        $layout->positions[$vvalue . '_subsection'] = array(
            "width" => "",
            "defpositions" => [""],
            "positions" => false,
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["sections", "optionssection"]
        );
    }
//    $layout->positions['logo_menu_subsection'] = array(
//        "width" => "",
//        "defpositions" => [""],
//        "positions" => false,
//        "innertop" => false,
//        "innerbottom" => false,
//        "params" => ["logo_menu_sub", "sections"]
//    );

    $left_inner = ['sitemenu'=>'menu','sitelogo'=>'logo','socialbtns'=>'socialbtn'];
    foreach($left_inner as $b=>$br){
        $layout->positions[$b] = array(
            "width" => "child-row-padding-0",
            "defpositions" => [$br],
            "positions" => [$br],
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["breadcrumbs","optionsfull"]
        );
    }
    foreach($left_inner as $b=>$br) {
        $layout->positions[$b.'_subsection'] = array(
            "width" => "",
            "defpositions" => [""],
            "positions" => false,
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["sections", "optionssection"]
        );
    }

    foreach (['logo', 'menu','socialbtn'] as $key => $value) {
        $layout->positions[$value] = array(
            "width" => "child-row-padding-0", //example row
            "defpositions" =>[$value],
            "positions" => [$value],
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["breadcrumbs"]
        );
    }
    //FINE


    $bread = ['breadcrumb'=>'breadcrumbs','breadcrumb-bottom'=>'breadcrumbs-bottom'];
    foreach($bread as $b=>$br){
        $layout->positions[$b] = array(
            "width" => "child-row-padding-0",
            "defpositions" => [$br],
            "positions" => [$br],
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["breadcrumbs","optionsfull"]
        );
    }
    foreach($bread as $b=>$br) {
        $layout->positions[$b.'_subsection'] = array(
            "width" => "",
            "defpositions" => [""],
            "positions" => false,
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["sections", "optionssection"]
        );
    }

    foreach (['breadcrumbs', 'breadcrumbs-bottom'] as $key => $value) {
        $layout->positions[$value] = array(
            "width" => "", //example row
            "defpositions" =>[$value],
            "positions" => [$value],
            "innertop" => false,
            "innerbottom" => false,
            "params" => ["breadcrumbs"]
        );
    }

    $layout->positions['contentcontainer'] = array(
        "width" => "container",
        "defpositions" => ["left", "content"],
        "positions" => ["left", "content"],
        "innertop" => false,
        "innerbottom" => false,
        "params" => ["menufull"]
    );
      $layout->positions['left'] = array(
        "width" => "container",
        "defpositions" => false,
        "positions" => false,
          "innertop" => false,
        "innerbottom" => ["sitelogo","sitemenu","socialbtns"],
        "params" => ["3", "optionsfull"]//, "moveall"
    );


//    foreach (['logo', 'menu','socialbtn'] as $key => $value) {
//        $layout->positions[$value] = array(
//            "width" => "child-row-padding-0", //example row
//            "defpositions" =>[$value],
//            "positions" => [$value],
//            "innertop" => false,
//            "innerbottom" => false,
//            "params" => ["breadcrumbs"]
//        );
//    }

//    $layout->positions['logo-container'] = array(
//        "width" => "",
//        "defpositions" => false,
//        "positions" => false,
//        "innertop" => ["sitelogo","sitemenu","socialbtns"],
//        "innerbottom" => false
//    );
//    $layout->positions['menu'] = array(
//        "width" => "",
//        "defpositions" => ["menu"],
//        "positions" => false,
//        "innertop" => false,
//        "innerbottom" => false,
//        "params" => ["logo"]
//    );
//  $layout->positions['logo'] = array(
//        "width" => "",
//        "defpositions" => ["logo"],
//        "positions" => false,
//        "innertop" => false,
//        "innerbottom" => false,
//        "params" => ["logo"]
//    );
//     $layout->positions['socialbtn'] = array(
//        "width" => "",
//        "defpositions" => ["socialbtn"],
//        "positions" => false,
//        "innertop" => false,
//        "innerbottom" => false,
//        "params" => ["logo"]
//    );
    $layout->positions['content'] = array(
        "width" => "container",
        "defpositions" => ["content"],
        "positions" => false,
        "innertop" => ["banner","breadcrumb", "topcontent"],
        "innerbottom" => ["incontent", "breadcrumb-bottom", "bottomcontent","copyright"],
        "params" => ["content", "optionsfull"]//, "moveall"
    );




    $layout->params['standard4col'] = array(
        "mobcollayout" => [12, 12, 12, 12],
        "tabcollayout" => [6, 6, 6, 6],
        "defcollayout" => [3, 3, 3, 3],
        "maxcols" => 120,
        "numeric_position" => true,
        "colchange" => true,
        "options" => true,
        "invisible" => true
    );
    $layout->params['3-9'] = array(
        "mobcollayout" => [12, 12],
        "tabcollayout" => [12, 12],
        "defcollayout" => [3, 9],
        "maxcols" => 2,
        "numeric_position" => false,
        "colchange" => true,
        "options" => true,
        "invisible" => false
    );
    $layout->params['9'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [9],
        "maxcols" => 1,
        "numeric_position" => false,
        "colchange" => true,
        "options" => true,
        "invisible" => false,
        "stile" => true,
        "font" => true
    );

    $layout->params['3'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [3],
        "maxcols" => 12,
        "numeric_position" => false,
        "colchange" => true,
        "options" => true,
        "invisible" => true,
        "stile" => true,
        "font" => true
    );
    $layout->params['menu'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [12],
        "maxcols" => 12,
        "numeric_position" => false,
        "colchange" => false,
        "options" => true,
        "effect" => true,
        "invisible" => false,
    );
       $layout->params['banner'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [9],
        "maxcols" => 1,
        "numeric_position" => false,
        "colchange" => true,
        "options" => true,
        "effect" => true,
        "invisible" => false,
    );

    $layout->params['logo'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [12],
        "maxcols" => 1,
        "numeric_position" => false,
        "colchange" => false,
        "options" => true,
        "effect" => true,
        "invisible" => false
    );


    $layout->params['menufull'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [12],
        "maxcols" => 12,
        "numeric_position" => false,
        "options" => false,
        "colchange" => false,
        "invisible" => false
    );

    $layout->params['content'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [9],
        "maxcols" => 12,
        "numeric_position" => false,
        "options" => true,
        "colchange" => true,
        "invisible" => true
    );
    $layout->params['sections'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [6],
        "maxcols" => 1,
        "numeric_position" => false,
        "options" => true,
        "colchange" => false,
        "invisible" => false
    );
    $layout->params['optionsfull'] = array(
        "effect" => true,
        "backgroundall" => true,
        "stile" => true,
        "shadow" => true,
        "font" => true
    );
    $layout->params['child'] = array(
        "child" => true,
    );
    $layout->params['optionssection'] = array(
        "backgroundall" => true,
        "stile" => true,
        "shadow" => true,
        "font" => true
    );
    $layout->params['container'] = array(
        "backgroundall" => true,
        "stile" => true,
        "font" => true
    );
    $layout->params['logo_menu_sub'] = array(
        "backgroundall" => true,
        "stile" => true,
        "shadow" => true
    );
    $layout->params['optionbody'] = array(
        "backgroundall" => true
    );
    $layout->params['breadcrumbs'] = array(
        "mobcollayout" => [12],
        "tabcollayout" => [12],
        "defcollayout" => [12],
        "maxcols" => 1,
        "numeric_position" => false,
        "colchange" => true,
        "options" => true,
        "invisible" => true,
    );



    //Static

    $layout->static['devices'] = ['pc' => 'pc', 'tablet' => 'tablet', 'mobile' => 'mobile'];
    //nomi di params, da aggiungere dopo ogni aggiunta
    $layout->static["avaiableoptions"] = ['container', 'optionsfull', 'optionssection', 'optionbody', "menu", "logo", "logo_menu_sub","banner"];
    $layout->static["truefalse"] = array(
        'numeric_position',
        'colchange',
        'invisible',
        'push',
        'pull',
        'offset'
    );
    //default positions utilizzato in template.php
    $layout->defaultpositions = ["logo", "content"];


//    $generate_forxml = array_merge($default_inners_similar,$default_4_moduli_attivi);
//    function generate_positions_xml($generate_forxml){
//        $write = '';
//        foreach($generate_forxml as $key=>$value){
//            for($i = 1; $i <=24; $i++){
//                $write .= '<position>'.$value.'-'.$i.'</position>'.PHP_EOL;
//            }
//        }
//        //file_put_contents("/var/www/html//positions.txt", $write);
//   }
//   generate_positions_xml($generate_forxml);
    return $layout;
}

