diff --git a/chant.php b/chant.php
index ab60d9f..78bf01c 100644
--- a/chant.php
+++ b/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 = "".$sources[$s[0]]['title'].", ".$sources[$s[0]]['editor'].", ".$sources[$s[0]]['year']."".($s[1]>''?", p. ".$s[1]:'');
if (count($s) > 2) {
echo '
'.$source_label."\n";
- $sources_img .= ''.$source_label."
\n";
- for($i = 0; $i < $s[3]; $i++) {
+ $sources_img .= '
'.$source_label." ";
+ $chants = array();
+ $sql1 = 'SELECT * FROM '.db('chant_sources').' WHERE `source` = "'.$s[0].'" ORDER BY sequence ASC';
+ $req1 = $mysqli->query($sql1) or die('Erreur SQL !
'.$sql1.'
'.$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 .= ' ◀';
+ $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 .= ' ▶';
+ $sources_img .= "
\n";
+ for($i = 0; $i < max(1, $s[3]); $i++) {
$sources_img .= '.'.png)
'."\n";
}
$sources_img .= "
\n
\n";
diff --git a/chant_edit.php b/chant_edit.php
index 791e5e4..de5d209 100644
--- a/chant_edit.php
+++ b/chant_edit.php
@@ -24,7 +24,9 @@ $req = $mysqli->query($sql) or die('Erreur SQL !
'.$sql.'
'.$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 = <<
@@ -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 !
'.$sql.'
'.$mysqli->error);
}
$t = time();
@@ -265,6 +267,14 @@ if(!$logged_in) {
echo '';
+ foreach ($c_s as $s) {
+ $source_label = "".$sources[$s['source']]['title'].", ".$sources[$s['source']]['editor'].", ".$sources[$s['source']]['year']."".($s['page']>''?", p. ".$s['page']:'');
+ echo ''.$source_label."
\n";
+ for($i = 0; $i < max(1,$s['extent']); $i++) {
+ echo '+$i).'.png)
'."\n";
+ }
+ echo "
\n
\n";
+ }
echo "\n";
echo "\n";
}
diff --git a/source.php b/source.php
index 106a07a..2ad26c6 100644
--- a/source.php
+++ b/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 "$title
\n";
-echo "\n| Page | Incipit |
";
-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) ? '' : '';
+ $n[$i] .= $sources[$s]['pages'][$i].'-'.$sources[$s]['pages'][min($i+$ipp-1, $np-1)];
+ $n[$i] .= ($i == $start) ? '' : '';
+ }
+ echo "Pages ".implode(' | ', $n)."
\n";
+ echo "\n| Page | Incipit |
";
+ for($i = $start; $i < min($start+$ipp, $np); $i++) {
+ $p = $sources[$s]['pages'][$i];
echo "| $p | ";
echo "\n";
- $ch = $chants[$p];
- unset($chants[$p]);
- foreach($ch as $c) {
- $t = chant_from_id($c[0]);
- echo '- ';
- if($t[2]) {
- echo ''.format_incipit($t[1])."";
- } else {
- echo ''.format_incipit($t[1]).'';
+ if(array_key_exists($p,$chants)) {
+ $ch = $chants[$p];
+ foreach($ch as $c) {
+ $t = chant_from_id($c[0]);
+ echo '
- ';
+ if($t[2]) {
+ echo ''.format_incipit($t[1])."";
+ } else {
+ echo ''.format_incipit($t[1]).' (TODO)';
+ }
+ echo "
\n";
}
- echo "\n";
}
+ echo '- Add chant
'."\n";
echo " \n";
- echo " |
\n";
+ echo "\n";
+ if(is_dir('./sources/'.$s)) {
+ echo ' | ';
+ }
+ }
+ echo "
\n";
+ echo "Pages ".implode(' | ', $n)."
\n";
+ }
+} else {
+ if(is_array($sources[$s]['pages'])) {
+ echo 'Show source images
'."\n";
+ }
+ echo "\n| Page | Incipit |
";
+ if(is_array($sources[$s]['pages'])) {
+ foreach($sources[$s]['pages'] as $p) {
+ if(array_key_exists($p,$chants)) {
+ echo "| $p | ";
+ echo "\n";
+ $ch = $chants[$p];
+ unset($chants[$p]);
+ foreach($ch as $c) {
+ $t = chant_from_id($c[0]);
+ echo '- ';
+ if($t[2]) {
+ echo ''.format_incipit($t[1])."";
+ } else {
+ echo ''.format_incipit($t[1]).'';
+ }
+ echo "
\n";
+ }
+ echo " \n";
+ echo " |
\n";
+ }
}
}
-}
-uksort($chants, 'strnatcmp');
-foreach($chants as $p => $ch) {
- echo "| $p | |
\n";
+ echo "
\n";
}
-echo "
\n";
include('include/footer.php');
?>
diff --git a/style.css b/style.css
index a0d99dc..327e7f5 100644
--- a/style.css
+++ b/style.css
@@ -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
-------------------------------------------------------------- */