Commit 055c08ed authored by Zot's avatar Zot

general cleanup of chord app

parent 39b93fba
......@@ -29,8 +29,6 @@ function chords_module() {}
function chords_content($a) {
$o .= '<h3>Guitar Chords</h3>';
$o .= 'The complete online guitar chord dictionary<br />';
$args = '';
$l = '';
......@@ -43,56 +41,37 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
$args .= ' lefty';
}
if((! strlen($args)) && (! stristr(basename($_SERVER['QUERY_STRING']),'chords')) && strlen(basename($_SERVER['QUERY_STRING'])))
$args = escapeshellarg(ucfirst(basename($_SERVER['QUERY_STRING'])));
$tunings = array("","openg", "opene", "dadgad");
$tnames = array("Em11 [Standard] (EADGBE)",
"G/D [Drop D] (DGDGBD)","Open E (EBEG#BE)","Dsus4 (DADGAD)");
$t = ((isset($_POST['tuning'])) ? $_POST['tuning'] : '');
if(isset($_POST['lefty']) && $_POST['lefty'] == '1')
$l = 'checked="checked"';
if((! $_POST['chord']) && argc() > 1) {
$_REQUEST['chord'] = argv(1);
$args = escapeshellarg(ucfirst(basename(argv(1))));
}
$ch = ((isset($_POST['chord'])) ? $_POST['chord'] : '');
$o .= <<< EOT
<form action="chords" method="post">
Chord name: (ex: Em7) <input type="text" name="chord" value="$ch" onfocus="this.select();" size="16" />
&nbsp;&nbsp;Tuning: <select name="tuning" size="5">
$tunings = [
'' => 'Em11 [Standard] (EADGBE)',
'openg' => 'G/D [Drop D] (DGDGBD)',
'opene' => 'Open E (EBEG#BE)',
'dadgad' => 'Dsus4 (DADGAD'
];
EOT;
for($x = 0; $x < count($tunings); $x ++) {
$o .= '<option value="'.$tunings[$x].'"'.
(($tunings[$x] == $t) ? 'selected="selected"' : '').
'>'.$tnames[$x].'</option>';
if(strlen($args)) {
$chords = '<pre>';
$chords .= shell_exec("addon/chords/chord ".$args);
$chords .= '</pre>';
}
else {
$o .= <<< EOT
</select>
Left-Handed: <input type="checkbox" name="lefty" value="1" $l />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<br /><br />
EOT;
if(strlen($args)) {
$o .= '<pre>';
$o .= shell_exec("addon/chords/chord ".$args);
$o .= '</pre>';
}
else {
$chords .= <<< EOT
$o .= <<< EOT
<p>
<p class="descriptive-text">
This is a fairly comprehensive and complete guitar chord dictionary which will list most of the available ways to play a certain chord, starting from the base of the fingerboard up to a few frets beyond the twelfth fret (beyond which everything repeats). A couple of non-standard tunings are provided for the benefit of slide players, etc.
<p />
<p>
<p class="descriptive-text">
Chord names start with a root note (A-G) and may include sharps (#) and flats (b). This software will parse most of the standard naming conventions such as maj, min, dim, sus(2 or 4), aug, with optional repeating elements.
</p>
<p>
<p class="descriptive-text">
Valid examples include A, A7, Am7, Amaj7, Amaj9, Ammaj7, Aadd4, Asus2Add4, E7b13b11 ...
</p>
Quick Reference:<br />
......@@ -100,22 +79,35 @@ Quick Reference:<br />
EOT;
$keys = array('A','Bb','B', 'C','Db','D','Eb','E','F','Gb','G','Ab');
$o .= '<table border="1">';
$o .= "<tr>";
$chords .= '<table border="1">';
$chords .= "<tr>";
foreach($keys as $k)
$o .= "<td><a href=\"chords/$k\"> $k </a></td>";
$o .= "</tr><tr>";
$chords .= "<td><a href=\"chords/$k\"> $k </a></td>";
$chords .= "</tr><tr>";
foreach($keys as $k)
$o .= "<td><a href=\"chords/{$k}m\"> {$k}m </a></td>";
$o .= "</tr><tr>";
$chords .= "<td><a href=\"chords/{$k}m\"> {$k}m </a></td>";
$chords .= "</tr><tr>";
foreach($keys as $k)
$o .= "<td><a href=\"chords/{$k}7\"> {$k}7 </a></td>";
$o .= "</tr>";
$o .= "</table>";
$chords .= "<td><a href=\"chords/{$k}7\"> {$k}7 </a></td>";
$chords .= "</tr>";
$chords .= "</table>";
}
return $o;
$o .= replace_macros(get_markup_template('chords.tpl','addon/chords'), [
'$header' => t('Guitar Chords'),
'$desc' => t('The complete online chord dictionary'),
'$chords' => $chords,
'$tuning' => [ 'tuning', t('Tuning'), $_POST['tuning'], '', $tunings ],
'$chord' => [ 'chord', t('Chord name: example: Em7'), $_REQUEST['chord'], '' ],
'$lefty' => [ 'lefty', t('Show for left handed stringing'), $_POST['lefty'], '' ],
'$submit' => t('Submit'),
]
);
return $o;
}
......
<h3>{{$header}}</h3>
<div>{{$desc}}</div>
<br /><br />
<form action="chords" method="post">
{{include file="field_input.tpl" field=$chord}}
{{include file="field_select.tpl" field=$tuning}}
{{include file="field_checkbox.tpl" field=$lefty}}
<input type="submit" name="submit" value={{$submit}} />
</form>
<br /><br />
{{$chords}}
<br />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment