<?php
  function generate_content_table($dir){
	$links = glob($dir . '/*');
	if(!$links) {
		return '';
	}
	$u = '<ul>';

	foreach($links as $link) {
	    //$link = utf8_decode($link);
	    $edited = filemtime($link);
	    $edited_formatted = date("d/m/y", $edited);
	    
	    $shortname = preg_replace("/_|-/", " ", basename($link));
	    
	    $u .= '<li><a href="' . $link . '">'  . $shortname . '</a> <span class="last_edit">(' .  $edited_formatted .  ")</span></li>\n";
	}

	$u .='</ul>';


	echo $u;
  }
  
  function list_info(array $infos) {
    if(!$infos) return;
    
   //echo "<ul>\n";
    $u = "";
    foreach($infos as $name =>$email) 
      $u .= "<a href=\"mailto:$email\">$name</a> og \n";
    
    echo substr($u, 0, -5);
    //echo "</ul>\n\n";
    
  }
  
/*
  function generate_content_table($dir){
	$links = glob($dir . '/*');
	if(!$links) {
		return '';
	}
	$u = '<table class="list">';

	foreach($links as $link) {
	    $link = utf8_decode($link);
	    $u .= '<tr><td><a href="' . $link . '">' . basename($link) . "</a></td> <td>col2</td> </tr>\n";
	}

	$u .='</table>';


	echo $u;

}	*/

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no" lang="no">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Mofoberg Systems</title>
	
	<link rel="stylesheet" href="reset.css" />
	<link rel="stylesheet" href="main.css" />
</head>
<body>
	<div id="page">
		<div id="page-top">

			
			<h1>Bachelorprosjektet vår 2010</h1><br />
			<h2>Gruppe 6E</h2>
		</div>
		
		<div id="page-content">
			<h2>Velkommen!</h2><p class="info">Dette er nettsidene til Gruppe 6E i bachelorprosjektet vår 2010</p>
			
			<div class="ulrow">
				<div class="licol left">

					<h3>Timelister</h3>
					<?php generate_content_table("timelister") ?>
				</div>
				
				<div class="licol right">
					<h3>Rapporter</h3>

					<?php generate_content_table("rapporter") ?>
				</div>
				<div class="clear-both"></div>

			</div>


			<div class="ulrow">
				<div class="licol left">
					<h3>Møteinnkallinger</h3>
					<?php generate_content_table("innkallinger") ?>
				</div>
				
				<div class="licol right">
					<h3>Møtereferater</h3>
					<?php generate_content_table("referat") ?>
				</div>

				<div class="clear-both"></div>
			</div>
			
		        
			<div id="page-footer">
			  Gruppemedlemmer: 
			  <?php
			    list_info(
				      array(
					    "Marius Foss" => "mariusfo@stud.hist.no",
					    "Bjørn Inge Berg" =>"biberg@stud.hist.no"
					   )
				     );
			    
			  ?>
			  
		        </div>
		  <div><a href="http://web.mafoberg.net/">Kontrollpanel</a></div>
		</div>
		
	</div>
</body>
</html>
