r42719 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42718‎ | r42719 | r42720 >
Date:08:38, 28 October 2008
Author:river
Status:old
Tags:
Comment:
make MIDI rendering optional
Modified paths:
  • /trunk/extensions/ABC/ABC.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ABC/ABC.php
@@ -20,14 +20,16 @@
2121 # Example: $abcURL = "/wiki/abc";
2222 $abcURL = false;
2323
24 -# Path to the abcm2ps executable.
 24+# Path to the abcm2ps executable. Required.
2525 $abcm2ps = "/usr/bin/abcm2ps";
2626
27 -# Path to the ps2pdf executable.
 27+# Path to the ps2pdf executable. Required.
2828 $abcps2pdf = "/usr/bin/ps2pdf14";
2929
30 -# Path to the abc2midi executable.
31 -$abc2midi = "/usr/bin/abc2midi";
 30+# Path to the abc2midi executable. Optional; set this if you
 31+# want to enable MIDI rendering.
 32+#$abc2midi = "/usr/bin/abc2midi";
 33+$abc2midi = false;
3234
3335 $wgExtensionCredits['parserhooks'][] = array(
3436 'name' => 'ABC',
@@ -88,8 +90,9 @@
8991 return str_replace("\n", "<br />", htmlspecialchars($error));
9092 if (!abcCreatePDF($abc, $hash, $error))
9193 return str_replace("\n", "<br />", htmlspecialchars($error));
92 - if (!abcCreateMIDI($abc, $hash, $error))
93 - return str_replace("\n", "<br />", htmlspecialchars($error));
 94+ if ($abc2midi)
 95+ if (!abcCreateMIDI($abc, $hash, $error))
 96+ return str_replace("\n", "<br />", htmlspecialchars($error));
9497
9598 /*
9699 * Succeeded to create all the output formats, return the
@@ -103,14 +106,15 @@
104107 $e_pdfpath = htmlspecialchars("$abcURL/$hash.pdf");
105108 $e_midipath = htmlspecialchars("$abcURL/$hash.mid");
106109
107 - $e_abclink = "<a href=\"$e_abcpath\">" . wfMsg('abcabc') . "</a>";
108 - $e_pslink = "<a href=\"$e_pspath\">" . wfMsg('abcps') . "</a>";
109 - $e_pdflink = "<a href=\"$e_pdfpath\">" . wfMsg('abcpdf') . "</a>";
110 - $e_midilink = "<a href=\"$e_midipath\">" . wfMsg('abcmidi') . "</a>";
 110+ $links = array();
 111+ $links[] = "<a href=\"$e_abcpath\">" . wfMsg('abcabc') . "</a>";
 112+ $links[] = "<a href=\"$e_pspath\">" . wfMsg('abcps') . "</a>";
 113+ $links[] = "<a href=\"$e_pdfpath\">" . wfMsg('abcpdf') . "</a>";
 114+ if ($abc2midi)
 115+ $links[] = "<a href=\"$e_midipath\">" . wfMsg('abcmidi') . "</a>";
111116
112117 $e_dllinks = wfMsg('abcdownload') . " " .
113 - join(" " . wfMsg('abcsep') . " ",
114 - array($e_abclink, $e_pslink, $e_pdflink, $e_midilink));
 118+ join(" " . wfMsg('abcsep') . " ", $links);
115119
116120 $output = <<<EOF
117121 <div style="float: $float; border: solid 1px #aaaaaa; margin: 0.2em;" class="abc-music">

Status & tagging log