<?php


function MENU_INIT() {
	global $thiss,$CURRENT_MENU,$ARG1,$ARG1_VAL,$MENU_INIT;
	if (isset($_REQUEST['MENU_INIT'])) $MENU_INIT = $_REQUEST['MENU_INIT'];

	DETECT_TABLE_COLUMN();// TODO: $thiss tworzone na podstawie 'CURRENT_MENU' ustawianej w MENU_INIT, czyli dziala dla menu z poprzedniego requestu, powinno byc uruchomione po ustawieniu 'CURRENT_MENU' 8 linii nizej
	if ($MENU_INIT && $MENU_INIT != 'DOL') {
		if ($MENU_INIT != V::get('CURRENT_MENU', '', $_SESSION)) {
			$_SESSION['LAST_MENU'] = V::get('CURRENT_MENU', '', $_SESSION);
			$_SESSION['LAST1_MENU'] = V::get('LAST_MENU', '', $_SESSION);
		}
		$_SESSION['CURRENT_MENU'] = $MENU_INIT;
	}
	if ($_SESSION['DEBUG']) echo "<HR>CURRENT_MENU= $CURRENT_MENU ".V::get('CURRENT_MENU', '', $_SESSION)." $MENU_INIT<hr>";
	if (isset($_SESSION['CURRENT_MENU']) && $MENU_INIT != 'DOL') {
		SEF($_SESSION['CURRENT_MENU']);
		if (function_exists($_SESSION['CURRENT_MENU'])) {
			$_SESSION['CURRENT_MENU']($ARG1, $ARG1_VAL);
		} else {
			SE_Layout::menu();
			$errMsg = "Błąd funkcja nie istnieje (" . htmlspecialchars($_SESSION['CURRENT_MENU']) . ")";
			SE_Layout::loadTemplate('defaultPage', array('errMsg'=>$errMsg));
		}
	} else {
		if ($MENU_INIT != 'DOL') {
			SE_Layout::menu();
			SE_Layout::loadTemplate('defaultPage');
		}
	}
}
