<?php

// ini_set('display_errors', 'on'); // zobrazeni PHP chybovych hlasek

$webdoc=Array
(
  "libraries_dir" => "../libraries/",
  "library_kernel" => "kernel.php",
  "library_template" => "template-smarty.php",
  "library_database" => "database-mysql.php",
  "library_navigation" => "navigation.php",
  "templates_dir" => "../templates/",
  "page_title" => "Document server",
  "tinyMCE_init" => "tinyMCE.init({ mode : 'textareas',  
                                    theme: 'advanced',
                                    languages: 'en',
                                    disk_cache: 'true',
                                    debug: 'false', 
                                    plugins : 'safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups',
                                    theme_advanced_buttons1 : 'save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect',
		                                theme_advanced_buttons2 : 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor',
		                                theme_advanced_buttons3 : 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,advhr,|,print,|,ltr,rtl,|,fullscreen',
                                    button_tile_map: 'true', 
                                    skin : 'o2k7' 
                                    })",
);

if (!isset($_POST["export"])) session_start();

require "$webdoc[libraries_dir]$webdoc[library_database]";
require "$webdoc[libraries_dir]$webdoc[library_kernel]";
require "$webdoc[libraries_dir]$webdoc[library_template]";

if (!$webdoc["database_connection"]=@database_connect())
{
  $webdoc["message"][]="Sorry, fail connect to database.";
  $webdoc["page_title"].=" - Database error";  
}

$webdoc["auth"]=$_SESSION["$webdoc[main_table]_auth"]; // prirazeni auth session kvuli zobrazeni menu pri korektnim prihlaseni
$webdoc["role_id"]=$_SESSION["$webdoc[main_table]_role_id"]; // prirazeni auth session kvuli zobrazeni menu pri korektnim prihlaseni

$template = new template();

if (isset($_GET["subpage1"])) $menu1_url[]="./"; else $menu1_url[]=""; $menu1_titles[]="Main page";
if ($_GET["subpage1"]!="requirements") $menu1_url[]="?subpage1=requirements"; else $menu1_url[]=""; $menu1_titles[]="Requirements";
if ($_GET["subpage1"]!="products") $menu1_url[]="?subpage1=products"; else $menu1_url[]=""; $menu1_titles[]="Products";
if ($_GET["subpage1"]!="tests") $menu1_url[]="?subpage1=tests"; else $menu1_url[]=""; $menu1_titles[]="Tests"; 
if ($_GET["subpage1"]!="test_run") $menu1_url[]="?subpage1=test_run"; else $menu1_url[]=""; $menu1_titles[]="Running tests";
if ($_GET["subpage1"]!="auth") $menu1_url[]="?subpage1=auth"; else $menu1_url[]=""; $menu1_titles[]="Auth";

$template->template_assign('menu1_url',$menu1_url);
$template->template_assign('menu1_titles',$menu1_titles);

kernel_require_script(1,"main-page");

$template->template_assign('webdoc',$webdoc);

$template->template_display('index.tpl');

if ($webdoc["database_connection"]) database_close();

?>