Edition interface. Code is a big mess but is seems to work.

This commit is contained in:
Olivier Berten 2013-03-23 22:55:46 +01:00
parent 7b28c3b627
commit 21895b3200
9 changed files with 571 additions and 72 deletions

115
autoresize.jquery.js Normal file
View File

@ -0,0 +1,115 @@
/*!
* jQuery Textarea Auto-Resize Plugin
* http://www.beansandcurry.com/
*
* Copyright 2012, Beans & Curry
* Released under the MIT License
*/
(function ($) {
/* Auto-resize plugin */
$.fn.autoresize = function (options) {
var settings = $.extend({
debug: false,
}, options),
styles = [
'font-family',
'font-size',
'font-weight',
'font-style',
'letter-spacing',
'text-transform',
'word-spacing',
'text-indent',
'line-height',
'padding-top',
'padding-bottom'
];
/* Replaces line breaks with <br /> tags for the text entered in the textarea */
function textarea2div(text) {
var breakTag = '<br />';
return (text + '<br />~').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
return this.each(function () {
var $this = $(this),
mirror = $("<div></div>");
/* Disables scrollbars in the textarea */
$this.css('overflow', 'hidden');
/* Copy the styles from the textarea to the mirror */
$.each(styles, function (index, property) {
mirror.css(property, $this.css(property));
});
mirror.css({
'word-wrap': 'break-word',
'position': 'absolute',
'height': 'auto',
'width': $this.width()
})
if (settings.debug === false) {
/* Position the mirror outside of the screen */
mirror.css({
'top': '-999em',
'left': '-999em'
});
} else {
/* Position the mirror on the screen for debugging purposes */
mirror.css({
'top': '10px',
'left': '10px'
});
}
/* Copy any text that is in the textarea to the mirror */
mirror.html(textarea2div($this.val()));
/* Append the mirror to the body of your HTML */
$("body").append(mirror);
/* Make the textarea the same height as the mirror's height */
$this.height(mirror.height());
/* Use the textchange event to update the mirror's text and update the textarea's height */
/* Tip: You can add "transition: height .2s" to your textarea's CSS to get a nice animation when the height changes. */
$this.bind("textchange", function () {
mirror.html(textarea2div($this.val()));
$this.height(mirror.height());
});
});
};
/* Defining the 'textchange' event */
/* Part of this code was taken from ZURB's jQuery TextChange Plugin http://www.zurb.com/playground/jquery-text-change-custom-event */
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).data('lastValue', this.contentEditable === 'true' ? $(this).html() : $(this).val());
$(this).bind('keyup.textchange', $.event.special.textchange.handler);
$(this).bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {
$(this).unbind('.textchange');
},
handler: function (event) {
$.event.special.textchange.triggerIfChanged($(this));
},
delayedHandler: function (event) {
var element = $(this);
setTimeout(function () {
$.event.special.textchange.triggerIfChanged(element);
}, 25);
},
triggerIfChanged: function (element) {
var current = element[0].contentEditable === 'true' ? element.html() : element.val();
if (current !== element.data('lastValue')) {
element.trigger('textchange', [element.data('lastValue')]);
element.data('lastValue', current);
}
}
};
})(jQuery);

View File

@ -135,7 +135,7 @@ if($req1->num_rows > 0 || $c['transcriber'] > '') {
}
while ($m = $req1->fetch_assoc()) {
$user_info = get_userdata($m['user_id']);
echo "<li>".date("M d, Y",$m['time']).": ".$m['comment']." (".$user_info->display_name.")</li>\n";
echo "<li>".date("M d, Y",$m['time']).": ".$m['comment']." (".$user_info->display_name.') <a href="history.php?changeset='.$m['time'].'|'.$id.'|'.$m['user_id']."\">?</a></li>\n";
}
if($c['transcriber'] > '') {
echo "<li>Original transcriber: ".$c['transcriber']."</li>\n";

View File

@ -1,94 +1,448 @@
<?php
# This stops WordPress from complaining about array post fields
$mypost = $_POST;
$_POST = array();
#
include('include/db.php');
include('include/txt.php');
include('include/sources.php');
include('include/finediff.php');
if(array_key_exists("id", $_GET)) {
$id = intval($_GET['id']);
} else {
die('No id');
function makeimg($c) {
$tex = mgabc2tex($c);
if($tex) {
makeimgfiles($c['id'],$tex);
}
if($c['gabc_verses'] || $c['tex_verses']) {
$tex = mgabc2tex($c,True);
if($tex) {
makeimgfiles($c['id'],$tex,'.1verse');
}
}
}
$sql1 = 'SELECT * FROM '.db('chants').' WHERE id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$c = $req1->fetch_assoc();
if(!$c) {
function mkstemp($suffix) {
# based on http://stackoverflow.com/questions/8970913/create-a-temp-file-with-a-specific-extension-using-php
$attempts = 238328; // 62 x 62 x 62
$letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$length = strlen($letters) - 1;
for($count = 0; $count < $attempts; ++$count) {
$random = "";
for($p = 0; $p < 6; $p++) {
$random .= $letters[mt_rand(0, $length)];
}
$randomFile = sys_get_temp_dir().'/'.$random.$suffix;
if( !($fd = @fopen($randomFile, "x+")) )
continue;
return array($fd,$randomFile);
}
return False;
}
function gregorio($s,$i=1) {
$f = mkstemp('.gabc');
fwrite($f[0],"initial-style:".$i.";\n%%\n".$s);
fclose($f[0]);
chdir(dirname($f[1]));
exec('gregorio '.basename($f[1]));
unlink($f[1]);
$gf = substr($f[1],0,-5).'.tex';
$g = fopen($gf,'r');
$tex = fread($g,filesize($gf));
fclose($g);
unlink($gf);
$tex = substr($tex,0,-12)."\n\\relax\n";
if($i > 0) {
$tex = '\setspaceafterinitial{2.2mm plus 0em minus 0em}
\setspacebeforeinitial{2.2mm plus 0em minus 0em}
'.$tex;
} else {
$tex = '\setspaceafterinitial{0pt plus 0em minus 0em}%
\setspacebeforeinitial{0pt plus 0em minus 0em}%
'.$tex;
}
return $tex;
}
function mgabc2tex($c, $firstverse = False) {
$ann = array('al' => False,
'an' => 'Ant',
'ca' => 'Cant',
'co' => 'Comm',
'gr' => 'Grad',
'hy' => 'Hymn',
'in' => 'Intr',
'im' => False,
'ky' => False,
'of' => 'Offert',
'ps' => False,
're' => 'Resp',
'se' => 'Seq',
'tr' => 'Tract',
'va' => False);
#
# Document header
#
$tex = '% !TEX TS-program = lualatex
% !TEX encoding = UTF-8
\documentclass[12pt]{article}
\usepackage{geometry}
\geometry{paperwidth=16cm,paperheight=150cm}
\usepackage{gregoriotex}
\usepackage{fullpage}
\usepackage[latin]{babel}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Linux Libertine O}
\pagestyle{empty}
\begin{document}
\newcommand{\red}[1]{\textcolor{red}{#1}}
\newcommand{\black}[1]{\textcolor{black}{#1}}
\setlength{\parindent}{0pt}
\def\greinitialformat#1{
{\fontsize{38}{38}\selectfont #1}
}
\def\grebiginitialformat#1{
{\fontsize{144}{144}\selectfont #1}
}
';
if($c['commentary']) {
$tex .= '\commentary{{\small \emph{'.$c['commentary']."}}}\n";
$tex .= '\nolinebreak[4]'."\n";
}
if($ann[$c['office-part']]) {
$tex .= '\gresetfirstannotation{\small \textbf{'.$ann[$c['office-part']].".}}\n";
}
if($c['mode']) {
if($c['mode'] == 'p') {
$mode = "T. pereg.";
} else {
$mode = $c['mode'];
}
$tex .= '\gresetsecondannotation{\small \textbf{'.$mode.".}}\n";
}
#
# Parsing gabc
#
$g = json_decode($c['gabc']);
$i = $c['initial'];
if(is_array($g)) {
foreach($g as $l) {
if($l[0] == 'gabc') {
$tex .= gregorio($l[1],$i);
} else {
$tex .= "\\vspace{10pt}\n".$l[1]."\\par\n";
}
$i = 0;
}
} elseif($c['gabc_verses'] && !$firstverse) {
$tex .= gregorio($g."\n".$c['gabc_verses'],$i);
} elseif($c['tex_verses'] && !$firstverse) {
$tex .= gregorio($g,$i);
$tex .= "\\vspace{10pt}\n".$c['tex_verses']."\\par\n";
} else {
$tex .= gregorio($g,$i);
}
#
# Document footer
#
$tex .= '
\end{document}
';
return $tex;
}
function makeimgfiles($id, $tex, $suffix = '') {
$path = __DIR__.'/scores/';
$f = mkstemp('.tex');
fwrite($f[0],$tex);
fclose($f[0]);
chdir(dirname($f[1]));
exec('lualatex --interaction=nonstopmode '.basename($f[1]));
exec('convert -density 300 '.substr($f[1],0,-4).'.pdf -flatten -trim '.$path.'png/'.$id.$suffix.'.png');
chmod($path.'png/'.$id.$suffix.'.png', 0666);
exec('convert -resize 33.333333% '.$path.'png/'.$id.$suffix.'.png '.$path.$id.$suffix.'.png');
chmod($path.$id.$suffix.'.png', 0666);
exec('pdfcrop '.substr($f[1],0,-4).'.pdf '.$path.'pdf/'.$id.$suffix.'.pdf');
chmod($path.'pdf/'.$id.$suffix.'.pdf', 0666);
exec('gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -dCompatibilityLevel=1.3 -dEmbedAllFonts=true -dSubsetFonts=true -sOutputFile='.$path.'eps/'.$id.$suffix.'.eps '.$path.'pdf/'.$id.$suffix.'.pdf');
chmod($path.'eps/'.$id.$suffix.'.eps', 0666);
unlink($f[1]);
unlink(substr($f[1],0,-4).'.log');
unlink(substr($f[1],0,-4).'.aux');
unlink(substr($f[1],0,-4).'.gaux');
unlink(substr($f[1],0,-4).'.pdf');
}
if(array_key_exists("id", $_GET)||array_key_exists("id", $mypost)) {
$id = array_key_exists("id", $_GET)?intval($_GET['id']):intval($mypost['id']);
} else {
$id = '0';
}
$sql = 'SELECT * FROM '.db('chants').' WHERE id = '.$id;
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
$c = $req->fetch_assoc();
if(!$c && $id != '0') {
die('Wrong id');
}
$c_s = array();
$sql = 'SELECT * FROM '.db('chant_sources').' WHERE chant_id = '.$id;
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
while ($s = $req->fetch_assoc()) {
$c_s[] = $s;
}
$title = $c['incipit'];
$custom_header = <<<HEADER
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="autoresize.jquery.js"></script>
<script type="text/javascript" src="relCopy.min.js"></script>
<script type="text/javascript">
$(function () {
// Apply the autoresize plugin to your textarea
$("textarea").autoresize();
});
</script>
<script type="text/javascript">
$(function(){
var removeLink = ' <a href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false"><img src="list-remove.png" alt="Remove" /></a>';
$('a.add').relCopy({ append: removeLink});
});
</script>
HEADER;
include('include/header.php');
if(!$logged_in) {
echo "Please login";
} elseif(count($_POST) > 0) {
#$mysqli->query('INSERT into '.db('proofreading').' VALUES ('.$id.','.$_SESSION['user_id'].','.time().')') or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
echo '<p>Please <a href="wp-login.php?redirect_to='.urlencode('http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'&amp;reauth=1">login</a></p>';
} elseif($id == '0' && count($mypost) > 0) {
$gabc = array();
for($i=0;$i<count($mypost['type']);$i++) {
if($mypost['content'][$i] > '') {
$gabc[] = array($mypost['type'][$i],$mypost['content'][$i],array());
}
}
if(count($gabc) == 0) {
$mypost['gabc'] = NULL;
} elseif(count($gabc) == 1 && $gabc[0][0] == 'gabc') {
$mypost['gabc'] = str_replace('",[]]','",{}]', str_replace("\r","",json_encode($gabc[0][1], JSON_UNESCAPED_SLASHES)));
} else {
$mypost['gabc'] = str_replace('",[]]','",{}]', str_replace("\r","",json_encode($gabc, JSON_UNESCAPED_SLASHES)));
}
unset($mypost['type']);
unset($mypost['content']);
$s_p = array();
for($i=0;$i<count($mypost['source']);$i++) {
if($mypost['source'][$i] != '0') {
$s_p[] = array("chant_id" => (string)$id, "source" => $mypost['source'][$i], "page" => $mypost['page'][$i], "sequence" => $mypost['sequence'][$i], "extent" => $mypost['extent'][$i]);
}
}
unset($mypost['source']);
unset($mypost['page']);
unset($mypost['sequence']);
unset($mypost['extent']);
$mypost['gabc_verses'] = str_replace("\r","",$mypost['gabc_verses']);
$mypost['tex_verses'] = str_replace("\r","",$mypost['tex_verses']);
$sql = 'INSERT into '.db('chants').' (`incipit`) VALUES ("'.$mysqli->real_escape_string($mypost['incipit']).'")';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
$id = $mysqli->insert_id;
foreach(array('version','office-part','mode','mode_var','commentary','initial','transcriber','gabc','gabc_verses','tex_verses') as $k) {
if($mypost[$k] > '') {
$sql = 'UPDATE '.db('chants').' SET `'.$k.'` = "'.$mysqli->real_escape_string($mypost[$k]).'" WHERE `id` = '.$id;
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
}
}
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']).')';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
}
makeimg($mypost);
$t = time();
$uid = $current_user->ID;
$chgset = $t.'-'.$id.'-'.$uid;
$sql = 'INSERT into '.db('changesets').' VALUES ('.$uid.','.$id.','.$t.', "Added to the database")';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
header('Location: chant.php?id='.$id);
} elseif(count($mypost) > 3) {
$gabc = array();
for($i=0;$i<count($mypost['type']);$i++) {
if($mypost['content'][$i] > '') {
$gabc[] = array($mypost['type'][$i],$mypost['content'][$i],array());
}
}
if(count($gabc) == 0) {
$mypost['gabc'] = NULL;
} elseif(count($gabc) == 1 && $gabc[0][0] == 'gabc') {
$mypost['gabc'] = json_encode($gabc[0][1], JSON_UNESCAPED_SLASHES);
} else {
$mypost['gabc'] = json_encode($gabc, JSON_UNESCAPED_SLASHES);
}
unset($mypost['type']);
unset($mypost['content']);
$s_p = array();
for($i=0;$i<count($mypost['source']);$i++) {
if($mypost['source'][$i] != '0') {
$s_p[] = array("chant_id" => (string)$id, "source" => $mypost['source'][$i], "page" => $mypost['page'][$i], "sequence" => $mypost['sequence'][$i], "extent" => $mypost['extent'][$i]);
}
}
unset($mypost['source']);
unset($mypost['page']);
unset($mypost['sequence']);
unset($mypost['extent']);
$fields = array('id','incipit','version','office-part','mode','mode_var','commentary','initial','transcriber','gabc','gabc_verses','tex_verses');
$old = array();
$new = array();
foreach($fields as $f) {
$myfield = str_replace('",[]]','",{}]', str_replace("\r","",$mypost[$f]));
if($c[$f] != $myfield) {
$old[$f] = $c[$f];
$new[$f] = $myfield;
}
}
if($c_s != $s_p || count($old) > 0) {
$t = time();
$uid = $current_user->ID;
$chgset = $t.'|'.$id.'|'.$uid;
$sql = 'INSERT into '.db('changesets').' VALUES ('.$uid.','.$id.','.$t.', NULL)';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
$mod = False;
foreach($old as $k => $v) {
$sql = 'INSERT into '.db('changes').' VALUES ("'.$chgset.'","'.$k.'","'.$mysqli->real_escape_string($v).'")';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
$sql = 'UPDATE '.db('chants').' SET `'.$k.'` = "'.$mysqli->real_escape_string($new[$k]).'" WHERE `id` = '.$id;
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
if(in_array($k, array('office-part','mode','mode_var','commentary','initial','gabc','gabc_verses','tex_verses'))) {
$mod = True;
}
}
if($c_s != $s_p) {
$sql = 'DELETE FROM '.db('chant_sources').' WHERE `chant_id` = '.$id;
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
foreach($s_p as $s) {
$sql = 'INSERT into '.db('chant_sources').' VALUES ('.$s['chant_id'].','.$s['source'].',"'.$mysqli->real_escape_string($s['page']).'",'.intval($s['sequence']).','.intval($s['extent']).')';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
}
$sql = 'INSERT into '.db('changes').' VALUES ("'.$chgset.'","sources","'.$mysqli->real_escape_string(json_encode($c_s, JSON_UNESCAPED_SLASHES)).'")';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
}
if($mod) {
makeimg($mypost);
}
echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post"><input type="hidden" name="changeset" value="'.$chgset.'" />';
echo "<h4>Please describe your changes</h4>\n".'<input name="comment" style="width:640px" />'."<br />\n<input type=\"submit\" />\n</form>\n";
} else {
echo "<p>No changes made</p>";
}
} elseif(count($mypost) > 0) {
$chgset = explode('|',$mypost['changeset']);
$sql = 'UPDATE '.db('changesets').' SET `comment` = "'.$mysqli->real_escape_string($mypost['comment']).'" WHERE `user_id` = '.$chgset[2].' AND `chant_id` = '.$chgset[1].' AND `time` = '.$chgset[0];
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
header('Location: chant.php?id='.$id);
} else {
$c_p = array();
$sql1 = 'SELECT * FROM '.db('chant_sources').' WHERE chant_id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while ($s = $req1->fetch_assoc()) {
$c_s = array($s['source'], $s['page']);
if(is_dir('./sources/'.$s['source'])) {
if(is_array($sources[$s['source']]['pages'])) {
$p = array_search($s['page'],$sources[$s['source']]['pages']);
} else {
$p = $s['page'];
$gabc = json_decode($c['gabc']);
if(is_string($gabc)) {
$gabc = array(array('gabc', $gabc, array()),);
} elseif(empty($gabc)) {
$gabc = array(array('gabc', "(c4)", array()),);
}
$c_p[] = array($s['source'], $s['page'], $p, $s['extent']);
} else {
$c_p[] = $c_s;
}
}
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '<div id="score"><br />';
echo '<h4>Mode</h4><input name="annotation1" value="'.$c['mode'].'" size="3" /><input name="annotation2" value="'.$c['mode_var'].'" size="3" /><br />';
echo '<h4>Initial style<select name="office-part">';
echo '<option value="0">No initial</option>'."\n";
echo '<option value="1" selected>1-line initial</option>'."\n";
echo '<option value="2">2-lines initial</option>'."\n";
echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">';
echo '<div id="score">';
echo "<h4>Score</h4>";
$i = 0;
foreach($gabc as $g) {
echo '<p class="clone1'.($i>0?' copy'.$i:'').'">';
echo '<select name="type[]">';
echo '<option value="gabc"'.($g[0]=='gabc'?' selected="selected"':'').">GABC</option>\n";
echo '<option value="tex"'.($g[0]=='tex'?' selected="selected"':'').">TeX</option>\n";
echo "</select>\n";
echo '<h4>GABC</h4><textarea name="gabc" id="gabc">'.($c['gabc']>''?$c['gabc']:'(c4)').'</textarea>';
echo '<textarea name="content[]" class="gabc">'.$g[1].'</textarea>';
echo ($i>0?' <a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false"><img src="list-remove.png" alt="Remove" /></a>':'');
echo '</p>';
$i++;
}
echo '<a href="#" class="add" rel=".clone1"><img src="list-add.png" alt="Add more" /></a>';
echo "<h4>Hymn verses (GABC)</h4>\n";
echo '<textarea name="gabc_verses" class="gabc">'.$c['gabc_verses']."</textarea>\n";
echo "<h4>Hymn verses (TeX)</h4>\n";
echo '<textarea name="tex_verses" class="gabc">'.$c['tex_verses']."</textarea>\n";
echo '<br />&nbsp;</div>'."\n";
echo '<div id="info">
';
echo '<h4>Incipit</h4><input name="incipit" value="'.$c['incipit'].'" />
<h4>Usage</h4><select name="office-part">';
echo '<h4>Incipit</h4><input name="incipit" value="'.$c['incipit'].'" />'."\n";
echo '<h4>Version</h4><input name="version" value="'.$c['version'].'" />'."\n";
echo '<h4>Usage</h4><select name="office-part">'."\n";
echo '<option value="">Choose usage</option>'."\n";
foreach($txt['usage'] as $k => $v) {
echo '<option value="'.$k.'"'.($c['office-part']==$k?' selected':'').'>'.$v.'</option>'."\n";
echo '<option value="'.$k.'"'.($c['office-part']==$k?' selected="selected"':'').'>'.$v.'</option>'."\n";
}
echo "</select>\n";
echo "<h4>Mode</h4>\n";
echo '<input name="mode" value="'.$c['mode'].'" size="3" /> - Ending <input name="mode_var" value="'.$c['mode_var'].'" size="3" />'."\n";
echo '<h4>Commentary</h4><input name="commentary" value="'.$c['commentary'].'" />';
echo "<h4>Initial style</h4>\n";
echo '<select name="initial">'."\n";
echo '<option value="0">No initial</option>'."\n";
echo '<option value="1" selected="selected">1-line initial</option>'."\n";
echo '<option value="2">2-lines initial</option>'."\n";
echo "</select>\n";
echo '<h4>Original transcriber</h4><input name="transcriber" value="'.$c['transcriber'].'" />';
$sources_img = "";
if(count($c_p) > 0) {
echo "<h4>Sources</h4>\n<ul>\n";
$cnt = 1;
foreach($c_p as $s) {
$source_label = "<i>".$sources[$s[0]]['title'].", ".$sources[$s[0]]['year']."</i>, 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 .= '<img src="sources/'.$s[0].'/'.($s[2]+$i).'.png" alt="" /><br />'."\n";
function sources_box($so) {
global $sources;
$sources_box = '<select name="source[]">'."\n";
$sources_box .= '<option value="0">Choose source</option>'."\n";
foreach ($sources as $k => $s) {
$sources_box .= '<option value="'.$k.'"'.($k==$so?' selected="selected"':'').">".$s['year'].' - '.$s['title'].' ('.$s['editor'].")</option>\n";
}
$sources_img .= "</p>\n<hr />\n";
} else {
echo "<li>".$source_label."</li>\n";
$sources_box .= "</select>\n";
echo $sources_box;
}
$cnt += 1;
echo "<h4>Sources</h4>\n";
echo '<span style="margin-left:295px;">Page</span><span style="margin-left:40px;">Sequence</span><span style="margin-left:20px;">Extent</span>';
$i = 0;
foreach ($c_s as $s) {
echo '<p class="clone2'.($i>0?' copy'.$i:'').'">';
sources_box($s['source']);
echo "</select>\n";
echo '<input size="3" name="page[]" value="'.$s['page'].'" />';
echo '<input size="3" name="sequence[]" value="'.$s['sequence'].'" />';
echo '<input size="3" name="extent[]" value="'.$s['extent'].'" />';
echo ($i>0?' <a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false"><img src="list-remove.png" alt="Remove" /></a>':'');
echo '</p>';
$i++;
}
echo "</ul>\n";
if(count($c_s) == 0) {
echo '<p class="clone2">';
sources_box('0');
echo "</select>\n";
echo '<input size="5" name="page[]" />';
echo '<input size="5" name="extent[]" />';
echo '</p>';
}
echo "<hr />\n";
echo '<a href="#" class="add" rel=".clone2"><img src="list-add.png" alt="Add more" /></a>';
echo $sources_img;
echo '<p><input type="hidden" name="id" value="'.$id.'" /><input type="submit" /></p>';
echo "</div>\n";
echo "</form>\n";
}
include('include/footer.php');
?>

View File

@ -2,25 +2,25 @@
include('include/db.php');
include('include/finediff.php');
if(array_key_exists("id", $_GET)) {
$id = intval($_GET['id']);
if(array_key_exists("changeset", $_GET)) {
$chgset = explode('|',$_GET['changeset']);
} else {
die('No id');
die('No changeset');
}
$sql1 = 'SELECT * FROM '.db('chants').' WHERE id = '.$id;
$sql1 = 'SELECT * FROM '.db('chants').' WHERE id = '.intval($chgset[1]);
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$c = $req1->fetch_assoc();
$title = 'History - '.$c['incipit'];
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.db('changesets').' WHERE chant_id = '.$id.' ORDER BY time DESC';
$sql1 = 'SELECT * FROM '.db('changesets').' WHERE `user_id` = '.intval($chgset[2]).' AND `chant_id` = '.intval($chgset[1]).' AND `time` = '.intval($chgset[0]);
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while($m = $req1->fetch_assoc()) {
echo "<h4>".date("M d, Y",$m['time'])." (".username_from_id($m['user_id']).")</h4>\n";
$user_info = get_userdata($m['user_id']);
echo "<h4>".date("M d, Y",$m['time'])." (".$user_info->display_name.")</h4>\n";
echo "<p>".$m['comment']."</p>\n";
$sql2 = 'SELECT * FROM '.db('changes').' WHERE changeset = "'.$m['user_id'].'|'.$id.'|'.$m['time'].'" ORDER BY field';
$sql2 = 'SELECT * FROM '.db('changes').' WHERE changeset = "'.$mysqli->real_escape_string($_GET['changeset']).'" ORDER BY field';
$req2 = $mysqli->query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.$mysqli->error);
while($f = $req2->fetch_assoc()) {
echo '<p><i>'.$f['field']."</i><br />\n";

BIN
list-add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

BIN
list-remove.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

20
missing.php Normal file
View File

@ -0,0 +1,20 @@
<?php
include('include/db.php');
$title = 'TODO';
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.db('chants').' WHERE `gabc` IS NULL ORDER BY incipit ASC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
echo "<ul class=\"incipit\">\n";
while($c = $req1->fetch_assoc()) {
$incipit = $c['incipit']?format_incipit($c['incipit']):"===";
echo '<li class="usage-marker '.$c['office-part'].'">';
echo '<a href="chant.php?id='.$c['id'].'">'.$incipit."</a>";
echo ' <span class="version">('.$c['version'].")</span></li>\n";
}
echo "</ul>\n";
include('include/footer.php');
?>

2
relCopy.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
(function(a){a.fn.relCopy=function(e){var b=jQuery.extend({excludeSelector:".exclude",emptySelector:".empty",copyClass:"copy",append:"",clearInputs:!0,limit:0},e);b.limit=parseInt(b.limit);this.each(function(){a(this).click(function(){var f=a(this).attr("rel"),d=a(f).length;if(0!=b.limit&&d>=b.limit)return!1;var c=a(f+":first"),e=a(c).parent(),c=a(c).clone(!0).addClass(b.copyClass+d).append(b.append);b.excludeSelector&&a(c).find(b.excludeSelector).remove();b.emptySelector&&a(c).find(b.emptySelector).empty();
if(a(c).attr("id")){var g=a(c).attr("id")+(d+1);a(c).attr("id",g)}a(c).find("[id]").each(function(){var b=a(this).attr("id")+(d+1);a(this).attr("id",b)});b.clearInputs&&a(c).find(":input").each(function(){switch(a(this).attr("type")){case "button":break;case "reset":break;case "submit":break;case "checkbox":a(this).attr("checked","");break;default:a(this).val("")}});a(e).find(f+":last").after(c);return!1})});return this}})(jQuery);

View File

@ -238,9 +238,17 @@ del {
text-decoration: none;
}
textarea#gabc {
width: 440px;
height: 200px;
textarea.gabc {
width: 450px;
}
.clone1,.clone2 {
border-bottom: 1px dashed gray;
}
.edit {
float:right;
margin-right: 15px;
}
.alphabet {