Skip to content
Snippets Groups Projects
Commit 86881ec5 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Moved form to php, ready for include, better layout, etc.

parent d7c956f4
No related branches found
No related tags found
No related merge requests found
...@@ -179,7 +179,7 @@ echo \ ...@@ -179,7 +179,7 @@ echo \
| users of the group `$user') and run lilypond as: | users of the group `$user') and run lilypond as:
| sudo /$i/bin/lilypond -j$user,$user,$jaildir,/lilyhome lilyfile_relative_to_lilyhome.ly | sudo /$i/bin/lilypond -j$user,$user,$jaildir,/lilyhome lilyfile_relative_to_lilyhome.ly
| |
| If you want user `a' to be able to copy files to $lilyhome, then | If you want user 'a' to be able to copy files to $lilyhome, then
| simply add him to the $user group: | simply add him to the $user group:
| adduser a $user | adduser a $user
| |
......
...@@ -9,14 +9,10 @@ $lilyhome = "/lilyhome"; ...@@ -9,14 +9,10 @@ $lilyhome = "/lilyhome";
$lilyworkdir = "$lilyhome/empty_sheet"; $lilyworkdir = "$lilyhome/empty_sheet";
$ly_cmd = "/usr/bin/sudo /opt/lily2.14/bin/lilypond -j$user,$user,$lilymnt,$lilyhome --png --pdf -dpixmap-format=pngalpha -dresolution=20 "; $ly_cmd = "/usr/bin/sudo /opt/lily2.14/bin/lilypond -j$user,$user,$lilymnt,$lilyhome --png --pdf -dpixmap-format=pngalpha -dresolution=20 ";
// print "<p>basedir: $basedir</p>";
// print "<p>ly_cmd: $ly_cmd</p>";
include('smarty3/Smarty.class.php'); include('smarty3/Smarty.class.php');
$smarty = new Smarty(); $smarty = new Smarty();
// $smarty->setTemplateDir($basedir.'/smarty/templates');
// $smarty->setTemplateDir($basedir.'/smarty/templates');
$smarty->setCompileDir($basedir.'/smarty/templates_c'); $smarty->setCompileDir($basedir.'/smarty/templates_c');
$smarty->setCacheDir($basedir.'/smarty/cache'); $smarty->setCacheDir($basedir.'/smarty/cache');
$smarty->setConfigDir($basedir.'/smarty/configs'); $smarty->setConfigDir($basedir.'/smarty/configs');
...@@ -44,6 +40,13 @@ function robust_request_number ($parm, $default, $min, $max) { ...@@ -44,6 +40,13 @@ function robust_request_number ($parm, $default, $min, $max) {
return $default; return $default;
} }
} }
function robust_request_bool ($parm, $default) {
if (isset ($_REQUEST[$parm])) {
return $_REQUEST[$parm];
} else {
return $default;
}
}
// Score type: // Score type:
...@@ -120,6 +123,7 @@ $type = robust_request_string ("score_type", NULL); ...@@ -120,6 +123,7 @@ $type = robust_request_string ("score_type", NULL);
$psz = explode (" ", robust_request_string ("paper_size", "a4"), 2); $psz = explode (" ", robust_request_string ("paper_size", "a4"), 2);
$paper_size = array_shift ($psz); $paper_size = array_shift ($psz);
$orientation = "";
if ($psz) { if ($psz) {
$orientation = array_shift($psz); $orientation = array_shift($psz);
} }
...@@ -130,12 +134,16 @@ $pages = robust_request_number ("pages", 2, 1, 20); ...@@ -130,12 +134,16 @@ $pages = robust_request_number ("pages", 2, 1, 20);
$title = robust_request_string ("title", NULL); $title = robust_request_string ("title", NULL);
$subtitle = robust_request_string ("subtitle", NULL); $subtitle = robust_request_string ("subtitle", NULL);
$composer = robust_request_string ("composer", NULL); $composer = robust_request_string ("composer", NULL);
$arranger = robust_request_string ("composer", NULL);
$instrument = robust_request_string ("instrument", NULL); $instrument = robust_request_string ("instrument", NULL);
$metainfo = $title . $subtitle . $composer . $instrument; $header_space = robust_request_bool ("header_space", false);
$metainfo = $title . $subtitle . $composer . $instrument.$header_space;
$metahash = md5( $metainfo ); $metahash = md5( $metainfo );
//////// Use cache file name composed from the arguments //////// Use cache file name composed from the arguments
$out_file_basename = "Score_${type}_${paper_size}${orientation}_${staff_size}pt_${systems}Systems_${pages}Pages"; $out_file_basename = "Score_${type}_${paper_size}${orientation}_${staff_size}pt_${systems}Systems_${pages}Pages";
if ($header_space)
$out_file_basename .= "_Header";
if ($metainfo != "") if ($metainfo != "")
$out_file_basename .= "_${metahash}"; $out_file_basename .= "_${metahash}";
...@@ -189,7 +197,9 @@ $smarty->assign('pages', $pages); ...@@ -189,7 +197,9 @@ $smarty->assign('pages', $pages);
$smarty->assign('title', $title); $smarty->assign('title', $title);
$smarty->assign('subtitle', $subtitle) ; $smarty->assign('subtitle', $subtitle) ;
$smarty->assign('composer', $composer); $smarty->assign('composer', $composer);
$smarty->assign('arranger', $arranger);
$smarty->assign('instrument', $instrument); $smarty->assign('instrument', $instrument);
$smarty->assign('header_space', $header_space);
$smarty->assign('indent', ''); $smarty->assign('indent', '');
$smarty->assign('contents', $score_type); $smarty->assign('contents', $score_type);
...@@ -211,6 +221,7 @@ if (!file_exists ($pdf_file)) { ...@@ -211,6 +221,7 @@ if (!file_exists ($pdf_file)) {
// run it through lilypond to create the pdf // run it through lilypond to create the pdf
// As we are running inside the jail, we don't include $lilymnt in the pathes! // As we are running inside the jail, we don't include $lilymnt in the pathes!
$cmd = "$ly_cmd -o $base_file $ly_file 2>&1"; $cmd = "$ly_cmd -o $base_file $ly_file 2>&1";
// print "<p>Command: <pre>$cmd</pre></p>";
$lily_result = exec($cmd, $output, $retval); $lily_result = exec($cmd, $output, $retval);
} }
...@@ -233,7 +244,6 @@ if (isset ($_REQUEST["preview"])) { ...@@ -233,7 +244,6 @@ if (isset ($_REQUEST["preview"])) {
print ("The output from running lilypond is:\n<pre>"); print ("The output from running lilypond is:\n<pre>");
print_r ($output); print_r ($output);
print ("</pre>\n"); print ("</pre>\n");
// die ("Unable to create the score file. Wrong input or server error encountered.");
} }
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
#preview { border: 1px solid black; }
.vsep { background: darkgray; }
#previewdiv {
position: relative;
}
#loadingOverlay {
background-image: url('loading.gif');
position: absolute;
z-index: 1;
top: 40%;
left: 35%;
width: 32px;
height: 32px;
}
</style>
<script type="text/javascript">
<!--
function loadPreview () {
// Show loading overlay, will be hidden in onLoad handler of the image!
document.getElementById("loadingOverlay").style.visibility = "visible";
// Add all non-button form elements:
var src = "empty_sheet.php?preview=True";
var elt = document.score_form.elements;
for(var i=0; i < elt.length; i++)
{
if (elt[i].type != 'submit' && elt[i].type != 'reset') {
src += "&" + encodeURIComponent (elt[i].name) + "=" +
encodeURIComponent (elt[i].value);
}
}
document.getElementById("preview").src = src;
}
//-->
</script>
</head>
<body onLoad="javascript:loadPreview();">
<FORM action="empty_sheet.php" name="score_form" onreset="javascript:loadPreview();">
<table>
<TR>
<td><label for="paper_size">Paper size:</label></td>
<td><select name="paper_size" id="paper_size" onchange="javascript:loadPreview();">
<option value="a4" selected="selected">A4</option>
<option value="a5">A5</option>
<option value="a6">A6</option>
<option value="letter">US letter</option>
<option value="legal">Legal</option>
<option value="11x17">Ledger</option>
<option value="a4 landscape">A4 (landscape)</option>
<option value="a5 landscape">A5 (landscape)</option>
<option value="a6 landscape">A6 (landscape)</option>
<option value="letter landscape">US letter (landscape)</option>
<option value="legal landscape">Legal (landscape)</option>
<option value="11x17 landscape">Ledger (landscape)</option>
</select></td>
<td rowspan=5 class="vsep"></td>
<td rowspan=5 colspan=2 align=center>
<div id=previewdiv class="foo">
<div id="loadingOverlay"></div>
<img id=preview onLoad="javascript:document.getElementById('loadingOverlay').style.visibility = 'hidden';"/>
</div>
</td>
<!-- <td><INPUT type="checkbox" name="title_check" size="15" accesskey="t" onchange="document.score_form.title.disabled = !this.checked" id="title_check"><label for="title_check" >Title: </label></td> -->
<!-- <td><INPUT type="text" checked name="title" size="25" maxlength="100" id="title" disabled="true"></td> -->
</tr>
<tr>
<td><label for="staff_size">Staff size:</label></td>
<td><select name="staff_size" id="staff_size" onchange="javascript:loadPreview();">
<option value="11">11pt (Pocket scores)</option>
<option value="12.5">12.5pt</option>
<option value="14">14pt</option>
<option value="15">15pt</option>
<option value="16">16pt</option>
<option value="17">17pt</option>
<option value="18">18t</option>
<option value="19">19pt</option>
<option value="20" selected="selected">20pt (default)</option>
<option value="22">22</option>
<option></option>
</select></td>
<!-- <td><INPUT type="checkbox" name="subtitle_check" size="15" accesskey="c" onchange="document.score_form.subtitle.disabled = !this.checked" id="subtitle_check"><label for="subtitle_check" >Subtitle: </label></td> -->
<!-- <td><INPUT type="text" checked name="subtitle" size="25" maxlength="100" id="subtitle" disabled="true"></td> -->
</tr>
<tr>
<td><label for="systems">Systems/page:</label></td>
<td><select name="systems" id="systems" onchange="javascript:loadPreview();">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10" selected="selected">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select></td>
<!-- <td><INPUT type="checkbox" name="composer_check" size="15" accesskey="c" onchange="document.score_form.composer.disabled = !this.checked" id="composer_check"><label for="composer_check" >Composer: </label></td> -->
<!-- <td><INPUT type="text" checked name="composer" size="25" maxlength="100" id="composer" disabled="true"></td> -->
</tr>
<tr>
<td><label for="pages">Pages:</label></td>
<td><select name="pages" id="pages" onchange="javascript:loadPreview();">
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select></td>
<!-- <td><INPUT type="checkbox" name="instrument_check" size="15" accesskey="i" onchange="document.score_form.instrument.disabled = !this.checked" id="instrument_check"><label for="instrument_check" >Instrument: </label></td> -->
<!-- <td><INPUT type="text" checked name="instrument" size="25" maxlength="100" id="instrument" disabled="true"></td> -->
</tr>
<tr>
<td colspan=2>
<INPUT type="checkbox" name="header_check" id="header_check"><label for="header_check" >Reserve space for title</label>
</td>
</tr>
<tr><TD colspan=5><hr></TD></tr>
<tr>
<td valign=top><label for="score_type">Score type:</label></td>
<td colspan=4>
<SELECT name="score_type" id="score_type" style='width: 100%' size="20" onchange="javascript:loadPreview();">
<option value="S0" selected="selected">Single staff, no clef</option>
<option value="S">Single staff, treble clef</option>
<option value="Sb">Single staff, bass clef</option>
<option value="St">Single staff, tenor clef</option>
<option value="Sa">Single staff, alto clef</option>
<option disabled="disabled">---------</option>
<option value="P">Piano staff</option>
<option value="O">Organ staff</option>
<option disabled="disabled">---------</option>
<option value="Ch2">Choir, 2 staves (SA + TB)</option>
<option value="Ch4">Choir, 4 staves (S, A, T, B)</option>
<option disabled="disabled">---------</option>
<option value="Ch4P">Piano reduction for choir</option>
<option value="S0P">Piano reduction for single soloist</option>
<option disabled="disabled">---------</option>
<option value="[StSaSb]">String Trio</option>
<option value="[StStSaSb]">String Quartett</option>
<option value="[StSbP]">Piano Trio</option>
<option value="[StSaSbP]">Piano Quartett</option>
<option disabled="disabled">---------</option>
<option value="">Full Score, Chamber Orchestra</option>
<option value="[SSb][SS][Sb][{SS}SaSb]">Full Score, Symphonic Orchestra</option>
<option value="18">Full Score, Chamber Orchestra + Choir</option>
<option value="[SSb][SS][Sb][{SS}Sa]Ch4[Sb]">Full Score, Symphonic Orchestra + Choir</option>
</SELECT>
</td>
</tr>
<tr><TD colspan=5 align=center>
<INPUT type="submit" name="create_score" value="Create Score"><INPUT type="reset" value="Reset Values">
</TD></tr>
</table>
</FORM>
</body>
</html>
<div id="music_score_form">
<style type="text/css" >
#preview { border: 1px solid black; }
.vsep { background: darkgray; }
#previewdiv {
position: relative;
}
#loadingOverlay {
background-image: url('loading.gif');
position: absolute;
z-index: 1;
top: 40%;
left: 35%;
width: 32px;
height: 32px;
visibility: "hidden";
}
</style>
<script type="text/javascript">
function loadPreview () {
// Show loading overlay, will be hidden in onLoad handler of the image!
document.getElementById("loadingOverlay").style.visibility = "visible";
// Add all non-button form elements:
var src = "empty_sheet.php?preview=True";
var elt = document.score_form.elements;
for(var i=0; i < elt.length; i++){
if (elt[i].type != 'submit' && elt[i].type != 'reset') {
src += "&" + encodeURIComponent (elt[i].name) + "=" +
encodeURIComponent (elt[i].value);
}
}
document.getElementById("preview").src = src;
}
</script>
<?php
$paper_sizes = array(
"a4" => "A4",
"a5" => "A5",
"a6" => "A6",
"a4 landscape" => "A4 (landscape)",
"a5 landscape" => "A5 (landscape)",
"a6 landscape" => "A6 (landscape)",
"letter" => "US letter",
"legal" => "Legal",
"11x17" => "Ledger",
"letter landscape" => "US letter (landscape)",
"legal landscape" => "Legal (landscape)",
"11x17 landscape" => "Ledger (landscape)");
$paper_sizes_default = "a4";
$staff_sizes = array (
"11" => "11pt (Pocket scores)",
"12.5" => "12.5pt",
"14" => "14pt",
"15" => "15pt",
"16" => "16pt",
"17" => "17pt",
"18" => "18pt",
"19" => "19pt",
"20" => "20pt (default)",
"22" => "22pt");
$staff_sizes_default = "20";
$systems_max = 15;
$systems_default = 7;
$pages_max = 15;
$pages_default = 2;
$score_header_fields = array (
"title" => "Title",
"subtitle" => "Subtitle",
"composer" => "Composer",
"arranger" => "Arranger",
"instrument" => "Instrument");
$score_types = array (
"S0" => "Single staff, no clef",
"S" => "Single staff, treble clef",
"Sb" => "Single staff, bass clef",
"St" => "Single staff, tenor clef",
"Sa" => "Single staff, alto clef",
"sep1" => Null,
"P" => "Piano staff",
"O" => "Organ staff",
"sep2" => Null,
"Ch2" => "Choir, 2 staves (SA + TB)",
"Ch4" => "Choir, 4 staves (S, A, T, B)",
"sep3" => Null,
"Ch4P" => "Piano reduction for choir",
"S0P" => "Piano reduction for single soloist",
"sep4" => Null,
"[SSSb]" => "String Trio (2 V, Vc)",
"[SSaSb]" => "String Trio (V, Va, Vc)",
"[SStSaSb]" => "String Quartett",
"[StSbP]" => "Piano Trio",
"[StSaSbP]" => "Piano Quartett",
"sep5" => Null,
"" => "Full Score, Chamber Orchestra",
"[SSb][SS][Sb][{SS}SaSb]" => "Full Score, Symphonic Orchestra",
"" => "Full Score, Chamber Orchestra + Choir",
"[SSb][SS][Sb][{SS}Sa]Ch4[Sb]" => "Full Score, Symphonic Orchestra + Choir",
);
$score_types_default = "S0";
$fullheader = array_key_exists ("full", $_REQUEST);
$headercount = $fullheader ? count($score_header_fields) : 1;
function write_option ($optkey, $optlabel, $optdefault) {
$sel = ($optkey == $optdefault) ? ' selected="selected"' : '';
if ($optlabel) {
print (" <option value=\"$optkey\"$sel>$optlabel</option>\n");
} else {
print (" <option disabled=\"disabled\">---------</option>\n");
}
}
function write_headerfield ($field, $label) {
?>
<tr>
<td><INPUT type="checkbox" name="<?php echo $field ?>_check" size="15" onchange="loadPreview();document.score_form.<?php echo $field ?>.disabled = !this.checked" id="<?php echo $field ?>_check"><label for="<?php echo $field ?>_check" ><?php echo $label ?>: </label></td>
<td><INPUT type="text" checked name="<?php echo $field ?>" size="25" maxlength="100" id="<?php echo $field ?>" disabled="disabled" onchange="loadPreview();"></td>
</tr>
<?php
}
?>
<FORM action="empty_sheet.php" name="score_form" onreset="loadPreview();">
<table class="music_score_settings_table" >
<TR>
<td><label for="paper_size">Paper size:</label></td>
<td><select name="paper_size" id="paper_size" onchange="loadPreview();">
<?php
foreach ($paper_sizes as $i => $value) {
write_option ($i, $value, $paper_sizes_default);
}
?>
</select></td>
<td rowspan="<?php echo 4+$headercount?>" class="vsep"></td>
<td rowspan="<?php echo 4+$headercount?>" colspan=2 align=center class="previewcell">
<div id=previewdiv class="foo">
<div id="loadingOverlay"></div>
<img id=preview src="" onLoad="document.getElementById('loadingOverlay').style.visibility = 'hidden';" alt="PREVIEW">
</div>
</td>
</tr>
<tr>
<td><label for="staff_size">Staff size:</label></td>
<td><select name="staff_size" id="staff_size" onchange="loadPreview();">
<?php
foreach ($staff_sizes as $i => $value) {
write_option ($i, $value, $staff_sizes_default);
}
?>
</select></td>
</tr>
<tr>
<td><label for="systems">Systems/page:</label></td>
<td><select name="systems" id="systems" onchange="loadPreview();">
<?php
for ($i = 1; $i <= $systems_max; $i++) {
write_option ($i, $i, $systems_default);
}
?>
</select></td>
</tr>
<tr>
<td><label for="pages">Pages:</label></td>
<td><select name="pages" id="pages" onchange="loadPreview();">
<?php
for ($i = 1; $i <= $pages_max; $i++) {
write_option ($i, $i, $pages_default);
}
?>
</select></td>
</tr>
<?php
if ($fullheader) {
foreach ($score_header_fields as $i => $value) {
write_headerfield ($i, $value);
}
} else {
?>
<tr>
<td colspan="2">
<INPUT type="checkbox" name="header_space" id="header_space" onchange="loadPreview();"><label for="header_space" >Reserve space for title</label>
</td>
</tr>
<?php } ?>
<!-- <tr><TD colspan=5><hr></TD></tr> -->
<tr>
<td valign=top><label for="score_type">Score type:</label></td>
<td colspan=4>
<SELECT name="score_type" id="score_type" style='width: 100%' size="20" onchange="loadPreview();">
<?php
foreach ($score_types as $i => $value) {
write_option ($i, $value, $score_types_default);
}
?>
</SELECT>
</td>
</tr>
<tr><TD colspan=5 align=center>
<INPUT type="submit" name="create_score" value="Create Score"><INPUT type="reset" value="Reset Values">
</TD></tr>
</table>
</FORM>
<script type="text/javascript">
loadPreview ();
// document.getElementById('loadingOverlay').style.visibility = 'hidden';
</script>
</div>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Empty score sheet generator -- by Edition Kainhofer</title>
</head>
<?php
include ("empty_sheet_form.php");
?>
</body>
</html>
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
{{if $composer}} composer="{{$composer}}" {{if $composer}} composer="{{$composer}}"
{{/if}} {{/if}}
{{if $instrument}} instrument="{{$instrument}}" {{if $instrument}} instrument="{{$instrument}}"
{{/if}}
{{if $arranger}} arranger="{{$arranger}}"
{{/if}} {{/if}}
copyright="Created by Edition Kainhofer, http://www.edition-kainhofer.com/, using LilyPond 2.14" copyright="Created by Edition Kainhofer, http://www.edition-kainhofer.com/, using LilyPond 2.14"
} }
...@@ -21,6 +23,12 @@ ...@@ -21,6 +23,12 @@
ragged-last=##f ragged-last=##f
ragged-right=##f ragged-right=##f
#(set-paper-size "{{$paper_size}}"{{if $orientation}} '{{$orientation}}{{/if}}) #(set-paper-size "{{$paper_size}}"{{if $orientation}} '{{$orientation}}{{/if}})
top-system-spacing #'stretchability = #60
top-markup-spacing #'stretchability = #60
last-bottom-spacing #'stretchability = #60
system-system-spacing #'stretchability = #40
{{if $header_space}} bookTitleMarkup = \markup { \vspace #5 }
{{/if}}
} }
\layout { \layout {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment