Display updates

This commit is contained in:
Olivier Berten 2013-03-27 14:30:38 +01:00
parent 5270166521
commit fca462f3b4
3 changed files with 66 additions and 1 deletions

View File

@ -43,6 +43,26 @@ if($req1->num_rows > 0) {
echo "<li><a href=\"source.php?id=none\">No source</a></li>\n";
}
echo "</ul></div>\n";
echo '<div id="updates"><h4><a href="updates.php">Latest updates</a></h4>'."\n";
$sql1 = 'SELECT * FROM '.db('changesets').' ORDER BY `time` DESC LIMIT 10';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$mod = array();
while($m = $req1->fetch_assoc()) {
$d = date("Y-m-d",$m['time']);
if(!array_key_exists($d,$mod)) $mod[$d] = array();
$mod[$d][] = $m;
}
foreach($mod as $d => $ml) {
echo $d;
echo "<ul>\n";
foreach($ml as $m) {
$user_info = get_userdata($m['user_id']);
echo '<li><a href="chant.php?id='.$m['chant_id'].'">'.format_incipit(chant_from_id($m['chant_id'])[1])."</a><br />\n";
echo "<i>".$m['comment']."</i></li>\n";
}
echo "</ul><br />\n";
}
echo "</div>";
include('include/footer.php');
?>

View File

@ -60,7 +60,7 @@ td ul {
margin-bottom: 0px;
}
h4 + ul {
ul {
margin-top: 0px;
margin-bottom: 0px;
}
@ -137,6 +137,19 @@ h4 {
padding-left: 20px;
}
#updates {
position: absolute;
top: 15px;
right:15px;
width: 240px;
border: solid 1px #e6e6e6;
padding: 15px;
}
#updates h4 {
margin-top: 0px;
}
.version {
color: #999;
font-size: 8pt;

32
updates.php Normal file
View File

@ -0,0 +1,32 @@
<?php
include('include/db.php');
if(array_key_exists("days", $_GET)) {
$l = intval($_GET['days']);
} else {
$l = 15;
}
$title = 'Updates in the last '.$l.' days';
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.db('changesets').' WHERE `time` > '.(time() - ($l*24*60*60)).' ORDER BY `time` DESC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$mod = array();
while($m = $req1->fetch_assoc()) {
$d = date("Y-m-d",$m['time']);
if(!array_key_exists($d,$mod)) $mod[$d] = array();
$mod[$d][] = $m;
}
foreach($mod as $d => $ml) {
echo "<h4>".$d."</h4>\n";
echo "<ul>\n";
foreach($ml as $m) {
$user_info = get_userdata($m['user_id']);
echo "<li>".' <a href="chant.php?id='.$m['chant_id'].'">'.format_incipit(chant_from_id($m['chant_id'])[1])."</a><br />\n";
echo "<i>".$m['comment'].'</i> <span class="version">('.$user_info->display_name.")</span></li>\n";
}
echo "</ul>\n";
}
include('include/footer.php');
?>