<?php
/**
 * The template for displaying all pages
 *
 * TODO REFACTORING HARD
 * MODEL -> VIEW -> SCENE
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package o66FsWp
 */

$br = '<br />';
$this_wordpress_context = $post->ID;

//LOGICA PRIMA DEL MODELLO? perchè?
//Perchè si, qui si fa il router, magari riesco ad includero per i cazzi sua, in ogni caso qui si prendono i valori dell'url

//IN TEORIA DA QUA IN POI THE VIEW
get_header();
echo '
<style>
pre h1 {font-size: 10px; max-width: 200px; max-height: 200px; overflow: hidden; display: none}
pre p {font-size: 6px; max-width: 200px; max-height: 200px; overflow: hidden; background-color: #21759b}
pre blockquote {font-size: 6px; max-width: 200px; max-height: 200px; overflow: hidden; display: none}
</style><div style="float: left; width: 66%; margin-left: 20%">
';
echo $br . '<- logic before rendering header ->' . $br.$br;
//esempio di model parent child nidificato
$addMe = get_post(8);
$addMe2 = get_post(12);
$addMe3 = get_post(15);

$oneSub = o66TheModel::createOneModelFromWpPostObject($addMe);
$twoSub = o66TheModel::createOneModelFromWpPostObject($addMe2);
$threeSub = o66TheModel::createOneModelFromWpPostObject($addMe3);
$primaryMenu = o66TheModel::createOneModelFromWpMenu('primary');

o66TheModel::appendOneModelToTheModel($primaryMenu);
o66TheModel::appendOneModelToTheModel($oneSub);
o66TheModel::appendOneModelToTheModel($twoSub, $oneSub->getID());
o66TheModel::appendOneModelToTheModel($threeSub, $twoSub->getID());


$tree = o66TheModel::getTheTreeModelArray();
//prent_r($tree);
$fields = o66TheModel::getTheModelFieldsArray();
$flat = o66TheModel::getTheModelFlatArray();

//$comp = o66TheViewClass::get_component('functional_test', $threeSub);
//echo $comp;
prent_r($tree);

//prent_r($post);
//$menu = get_term( $locations[$theme_location], 'nav_menu' );
//$menu_items = wp_get_nav_menu_items($menu->term_id);

?>
    </div>
    <div id="primary" class="content-area">
        <main id="main" class="site-main">

			<?php
			if ( have_posts() ) :

				if ( is_home() && ! is_front_page() ) :
					?>
                    <header>
                        <h1 class="page-title screen-reader-text">______</h1>
                    </header>
				<?php
				endif;

				/* Start the Loop */
				while ( have_posts() ) :
					the_post();

					function myfunction( $value, $key ) {
						var_dump( $key );
						echo "The key $key has the value $value<br>";
					}

					$a1 = array( "a" => "red", "b" => "green" );
					$a2 = array( 0 => $a1, 1 => "blue", 2 => "yellow" );
					array_walk_recursive( $a2, "myfunction" );
					var_dump($a2);


				endwhile;


			endif;
			?>

        </main><!-- #main -->
    </div><!-- #primary -->

<?php
//get_sidebar();
get_footer();