Source view improvements
This commit is contained in:
parent
9c65a9985e
commit
cf7358a3b0
47
chant.php
47
chant.php
|
|
@ -33,7 +33,7 @@ while ($s = $req1->fetch_assoc()) {
|
|||
} else {
|
||||
$p = $s['page'];
|
||||
}
|
||||
$c_p[] = array($s['source'], $s['page'], $p, $s['extent']);
|
||||
$c_p[] = array($s['source'], $s['page'], $p, intval($s['extent']), intval($s['sequence']));
|
||||
} else {
|
||||
$c_p[] = $c_s;
|
||||
}
|
||||
|
|
@ -67,8 +67,49 @@ if(count($c_p) > 0) {
|
|||
$source_label = "<i>".$sources[$s[0]]['title'].", ".$sources[$s[0]]['editor'].", ".$sources[$s[0]]['year']."</i>".($s[1]>''?", p. ".$s[1]:'');
|
||||
if (count($s) > 2) {
|
||||
echo '<li><a href="#source_'.$cnt.'">'.$source_label."</a></li>\n";
|
||||
$sources_img .= '<p><a name="source_'.$cnt.'">'.$source_label."</a><br />\n";
|
||||
for($i = 0; $i < $s[3]; $i++) {
|
||||
$sources_img .= '<p><a name="source_'.$cnt.'">'.$source_label."</a> ";
|
||||
$chants = array();
|
||||
$sql1 = 'SELECT * FROM '.db('chant_sources').' WHERE `source` = "'.$s[0].'" ORDER BY sequence ASC';
|
||||
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
|
||||
while($co = $req1->fetch_assoc()) {
|
||||
$chants[$co['page']][] = array(intval($co['chant_id']),intval($co['sequence']),intval($co['extent']));
|
||||
}
|
||||
$prev = false;
|
||||
if(array_search([$id,$s[4],$s[3]], $chants[$s[1]]) > 0) {
|
||||
$prev = $chants[$s[1]][array_search([$id,$s[4],$s[3]], $chants[$s[1]])-1];
|
||||
} elseif(is_array($sources[$s[0]]['pages'])) {
|
||||
$j = $s[2];
|
||||
while($j > 0) {
|
||||
$j--;
|
||||
if(array_key_exists($sources[$s[0]]['pages'][$j], $chants) && count($chants[$sources[$s[0]]['pages'][$j]]) > 0) {
|
||||
$prev = end($chants[$sources[$s[0]]['pages'][$j]]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uksort($chants, 'strnatcmp');
|
||||
// TODO
|
||||
}
|
||||
if($prev) $sources_img .= ' <a class="prevnext" href="chant.php?id='.$prev[0].'" title="Previous chant in this source" >◀</a>';
|
||||
$next = false;
|
||||
if(count($chants[$s[1]]) > 1 && array_search([$id,$s[4],$s[3]], $chants[$s[1]]) < count($chants[$s[1]])) {
|
||||
$next = $chants[$s[1]][array_search([$id,$s[4],$s[3]], $chants[$s[1]])+1];
|
||||
} elseif(is_array($sources[$s[0]]['pages'])) {
|
||||
$j = $s[2];
|
||||
while($j < count($sources[$s[0]]['pages'])) {
|
||||
$j++;
|
||||
if(array_key_exists($sources[$s[0]]['pages'][$j], $chants) && count($chants[$sources[$s[0]]['pages'][$j]]) > 0) {
|
||||
$next = $chants[$sources[$s[0]]['pages'][$j]][0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uksort($chants, 'strnatcmp');
|
||||
// TODO
|
||||
}
|
||||
if($next) $sources_img .= ' <a class="prevnext" href="chant.php?id='.$next[0].'" title="Next chant in this source" >▶</a>';
|
||||
$sources_img .= "<br />\n";
|
||||
for($i = 0; $i < max(1, $s[3]); $i++) {
|
||||
$sources_img .= '<img src="sources/'.$s[0].'/'.($s[2]+$i).'.png" alt="" /><br />'."\n";
|
||||
}
|
||||
$sources_img .= "</p>\n<hr />\n";
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ $req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->e
|
|||
while ($s = $req->fetch_assoc()) {
|
||||
$c_s[] = $s;
|
||||
}
|
||||
|
||||
if($id == 0 && array_key_exists('source', $_GET) && array_key_exists('page', $_GET)) {
|
||||
$c_s[] = ['source' => intval($_GET['source']), 'page' => $_GET['page'], 'sequence' => 0, 'extent' => 1];
|
||||
}
|
||||
$title = $c['incipit']?$c['incipit']:'New score';
|
||||
$custom_header = <<<HEADER
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
|
|
@ -87,7 +89,7 @@ if(!$logged_in) {
|
|||
}
|
||||
}
|
||||
foreach($s_p as $s) {
|
||||
$sql = 'INSERT into '.db('chant_sources').' VALUES ('.$id.','.$s['source'].',"'.$mysqli->real_escape_string($s['page']).'",'.intval($s['sequence']).','.intval($s['extent']).')';
|
||||
$sql = 'INSERT into '.db('chant_sources').' VALUES ('.$id.','.$s['source'].',"'.$mysqli->real_escape_string($s['page']).'",'.intval($s['sequence']).','.max(1,intval($s['extent'])).')';
|
||||
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
|
||||
}
|
||||
$t = time();
|
||||
|
|
@ -265,6 +267,14 @@ if(!$logged_in) {
|
|||
|
||||
echo '<p><input type="hidden" name="id" value="'.$id.'" /><input type="submit" /></p>';
|
||||
|
||||
foreach ($c_s as $s) {
|
||||
$source_label = "<i>".$sources[$s['source']]['title'].", ".$sources[$s['source']]['editor'].", ".$sources[$s['source']]['year']."</i>".($s['page']>''?", p. ".$s['page']:'');
|
||||
echo '<p>'.$source_label."<br />\n";
|
||||
for($i = 0; $i < max(1,$s['extent']); $i++) {
|
||||
echo '<img src="sources/'.$s['source'].'/'.(array_search($s['page'],$sources[$s['source']]['pages'])+$i).'.png" alt="" /><br />'."\n";
|
||||
}
|
||||
echo "</p>\n<hr />\n";
|
||||
}
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
|
|
|||
113
source.php
113
source.php
|
|
@ -21,49 +21,98 @@ if($s == "none") {
|
|||
$chants[$c['page']][] = array($c['chant_id'],$c['sequence'],$c['extent']);
|
||||
}
|
||||
}
|
||||
|
||||
$title = 'Sources - '.$sources[$s]['title'];
|
||||
if(array_key_exists($s, $sources)) {
|
||||
$title = 'Sources - '.$sources[$s]['year']." - ".$sources[$s]['editor']." - ".$sources[$s]['title'];
|
||||
} else {
|
||||
$title = 'Sources - no source';
|
||||
}
|
||||
include('include/header.php');
|
||||
echo "<h2>$title</h2>\n";
|
||||
echo "<table>\n<tr><th>Page</th><th>Incipit</th></tr>";
|
||||
if(is_array($sources[$s]['pages'])) {
|
||||
foreach($sources[$s]['pages'] as $p) {
|
||||
if(array_key_exists($p,$chants)) {
|
||||
if(array_key_exists('images', $_GET) && $_GET['images'] == '1') {
|
||||
$ipp = 25;
|
||||
if(is_array($sources[$s]['pages'])) {
|
||||
$np = count($sources[$s]['pages']);
|
||||
$start = array_key_exists('index', $_GET) ? intval($_GET['index']*$ipp) : 0;
|
||||
if($start > $np) $start = 0;
|
||||
$n = [];
|
||||
for($i = 0; $i < $np; $i += $ipp) {
|
||||
$n[$i] = ($i == $start) ? '' : '<a href="source.php?id='.$s.'&images=1&index='.($i/$ipp).'">';
|
||||
$n[$i] .= $sources[$s]['pages'][$i].'-'.$sources[$s]['pages'][min($i+$ipp-1, $np-1)];
|
||||
$n[$i] .= ($i == $start) ? '' : '</a>';
|
||||
}
|
||||
echo "<p><b>Pages</b> ".implode(' | ', $n)."</p>\n";
|
||||
echo "<table>\n<tr><th>Page</th><th>Incipit</th></tr>";
|
||||
for($i = $start; $i < min($start+$ipp, $np); $i++) {
|
||||
$p = $sources[$s]['pages'][$i];
|
||||
echo "<tr><td>$p</td><td>";
|
||||
echo "<ul class=\"incipit\">\n";
|
||||
$ch = $chants[$p];
|
||||
unset($chants[$p]);
|
||||
foreach($ch as $c) {
|
||||
$t = chant_from_id($c[0]);
|
||||
echo '<li class="usage-marker '.$t[0].'">';
|
||||
if($t[2]) {
|
||||
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
|
||||
} else {
|
||||
echo '<span class="todo">'.format_incipit($t[1]).'</span>';
|
||||
if(array_key_exists($p,$chants)) {
|
||||
$ch = $chants[$p];
|
||||
foreach($ch as $c) {
|
||||
$t = chant_from_id($c[0]);
|
||||
echo '<li class="usage-marker '.$t[0].'">';
|
||||
if($t[2]) {
|
||||
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
|
||||
} else {
|
||||
echo '<span class="todo">'.format_incipit($t[1]).'</span> (<a href="chant_edit.php?id='.$c[0].'">TODO</a>)';
|
||||
}
|
||||
echo "</li>\n";
|
||||
}
|
||||
echo "</li>\n";
|
||||
}
|
||||
echo '<li class="add-chant"><a href="chant_edit.php?source='.$s.'&page='.$p.'">Add chant</a></li>'."\n";
|
||||
echo "</ul>\n";
|
||||
echo "</td></tr>\n";
|
||||
echo "</td>\n";
|
||||
if(is_dir('./sources/'.$s)) {
|
||||
echo '<td><img src="sources/'.$s.'/'.$i.'.png" /></td>';
|
||||
}
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo "<p><b>Pages</b> ".implode(' | ', $n)."</p>\n";
|
||||
}
|
||||
} else {
|
||||
if(is_array($sources[$s]['pages'])) {
|
||||
echo '<p><a href="source.php?id='.$s.'&images=1">Show source images</a></p>'."\n";
|
||||
}
|
||||
echo "<table>\n<tr><th>Page</th><th>Incipit</th></tr>";
|
||||
if(is_array($sources[$s]['pages'])) {
|
||||
foreach($sources[$s]['pages'] as $p) {
|
||||
if(array_key_exists($p,$chants)) {
|
||||
echo "<tr><td>$p</td><td>";
|
||||
echo "<ul class=\"incipit\">\n";
|
||||
$ch = $chants[$p];
|
||||
unset($chants[$p]);
|
||||
foreach($ch as $c) {
|
||||
$t = chant_from_id($c[0]);
|
||||
echo '<li class="usage-marker '.$t[0].'">';
|
||||
if($t[2]) {
|
||||
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
|
||||
} else {
|
||||
echo '<span class="todo">'.format_incipit($t[1]).'</span>';
|
||||
}
|
||||
echo "</li>\n";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
uksort($chants, 'strnatcmp');
|
||||
foreach($chants as $p => $ch) {
|
||||
echo "<tr><td>$p</td><td><ul class=\"incipit\">";
|
||||
$l = array();
|
||||
foreach($ch as $c) {
|
||||
$t = chant_from_id($c[0]);
|
||||
$l[] = $t[1]."=-=".$t[0]."=-=".$c[0]."=-=".$c[1]."=-=".$c[2];
|
||||
uksort($chants, 'strnatcmp');
|
||||
foreach($chants as $p => $ch) {
|
||||
echo "<tr><td>$p</td><td><ul class=\"incipit\">";
|
||||
$l = array();
|
||||
foreach($ch as $c) {
|
||||
$t = chant_from_id($c[0]);
|
||||
$l[] = $t[1]."=-=".$t[0]."=-=".$c[0]."=-=".$c[1]."=-=".$c[2];
|
||||
}
|
||||
natcasesort($l);
|
||||
foreach($l as $ll) {
|
||||
$ll = explode('=-=',$ll);
|
||||
echo '<li class="usage-marker '.$ll[1].'"><a href="chant.php?id='.$ll[2].'">'.$ll[0]."</a></li>\n";
|
||||
}
|
||||
echo "</ul></td></tr>\n";
|
||||
}
|
||||
natcasesort($l);
|
||||
foreach($l as $ll) {
|
||||
$ll = explode('=-=',$ll);
|
||||
echo '<li class="usage-marker '.$ll[1].'"><a href="chant.php?id='.$ll[2].'">'.$ll[0]."</a></li>\n";
|
||||
}
|
||||
echo "</ul></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
include('include/footer.php');
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -180,6 +180,11 @@ ul.incipit li {
|
|||
padding-left:4px;
|
||||
}
|
||||
|
||||
.add-chant:before {
|
||||
content: "➕";
|
||||
padding-right:7px;
|
||||
}
|
||||
|
||||
.ky:before, .ky:after {
|
||||
color: #085abd;
|
||||
}
|
||||
|
|
@ -278,6 +283,10 @@ textarea.gabc {
|
|||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.prevnext {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* =Menu
|
||||
-------------------------------------------------------------- */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue