univ-pau-ics/build/router/controller/page.php

97 lines
1.8 KiB
PHP

<?php
namespace router\controller;
use \service\Config;
class page{
/* PRE-CALL
*
* @url<String> Calling URI
*
*/
public function __construct($url){
}
/* CALL
*
*/
public function home(){
/* [1] Fetch configuration
=========================================================*/
/* (1) Get config */
try{
$config = Config::loadCached();
/* (2) Error management */
}catch(\Exception $e){
die("An error occured. Please contact the developers.\n");
}
/* (3) Get the diplome list */
$diplomes = $config->getDiplomes();
/* [2] Display the links
=========================================================*/
echo "<table><thead style='font-weight: bold;'><tr><td>Diplome</td><td>Lessons' name</td><td>Location</td><td>View</td><td>Link</td><td>Last Update</td></tr></thead><tbody>";
foreach($diplomes as $id=>$data){
$name = $data[0];
$upda = $data[1];
$URI = $_SERVER['REQUEST_URI'];
$url = $_SERVER['HTTP_HOST'].$URI."ics/$id.ics";
$link = __ROOT__."/tmp/$id.ics";
// name
echo "<tr><td>$name</td>";
// link to correct lessons
echo "<td><a href='/lessons/$id'>Correct</a></td>";
echo "<td><a";
if( file_exists($link) )
echo " href='/ics/$id.ics'";
// link to correct location
echo "<td><a href='/location/$id'>Correct</a></td>";
echo "<td><a";
if( file_exists($link) )
echo " href='/ics/$id.ics'";
// link to view
echo "<td><a href='/view/$id'>View</a></td>";
echo "<td><a";
if( file_exists($link) )
echo " href='/ics/$id.ics'";
// link to .ics
echo ">https://$url</a></td>";
// update date
echo "<td>$upda</td>";
echo "</tr>";
}
echo "</tbody></table>";
}
/* POST-CALL
*
*/
public function __destruct(){
}
}