<?php
function BuildPage($page_title, $locations, $mainframe, $actions) {
//Using the template
include('classes/template.class.php');
$template = new Template('./templates');
$template->set_file('body', 'index.tpl');
//Setting the page Title
$template->set_var('PAGE_TITLE', $page_title);
//Creating top menu
$template->set_block('body', 'TOP_MENU','top_menu');
foreach ($locations as $name => $href) {
$template->set_var('HREF', $href);
$template->set_var('LABEL', htmlspecialchars($name));
$template->parse('top_menu', 'TOP_MENU', true);
}
//Inserting content :
$template->set_block('body', 'MAIN_FRAME','main_frame');
$template->set_block('MAIN_FRAME', 'SECTION', 'section');
foreach($mainframe as $title => $section) {
$append = false;
$template->set_var('TITLE',$title);
foreach($section as $subtitle => $content) {
$template->set_var('SUB_TITLE', htmlspecialchars($subtitle));
$template->set_var('CONTENT', $content);
$template->parse('section', 'SECTION', $append);
$append = true;
}
$template->parse('main_frame', 'MAIN_FRAME', true);
}
//Creating the side-menu :
$template->set_block('body', 'SIDE_MENU','side_menu');
$template->set_block('SIDE_MENU', 'MENU_CONTENT','menu_content');
foreach ($actions as $title => $sub_menu) {
$append = false;
$template->set_var('MENU_TITLE', htmlspecialchars($title));
foreach ($sub_menu as $caption => $action) {
$template->set_var('HREF', $action);
$template->set_var('LABEL', htmlspecialchars($caption));
$template->parse('menu_content', 'MENU_CONTENT', $append);
$append = true;
}
$template->parse('side_menu', 'SIDE_MENU', true);
}
$template->parse('parse', 'body', true);
$template->p('parse');
}
?>