Index: trunk/extensions/Score/Score.i18n.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | 'score-desc' => 'Adds a tag for rendering musical scores with LilyPond', |
39 | 39 | 'score-getcwderr' => 'Unable to obtain current working directory', |
40 | 40 | 'score-invalidlang' => 'Invalid score language lang="$1". Currently recognised languages are lang="lilypond" (the default) and lang="ABC".', |
| 41 | + 'score-invalidoggoverride' => 'The file you specified with override_ogg is invalid. Please specify the file name only, omit <nowiki>[[…]]</nowiki> and the "File:" prefix.', |
41 | 42 | 'score-noabcinput' => 'ABC source file $1 could not be created.', |
42 | 43 | 'score-nofactory' => 'Failed to create LilyPond factory directory.', |
43 | 44 | 'score-noinput' => 'Failed to create LilyPond input file $1.', |
— | — | @@ -47,6 +48,7 @@ |
48 | 49 | 'score-novorbislink' => 'Unable to generate Ogg/Vorbis link: $1', |
49 | 50 | 'score-oggconversionerr' => 'Unable to convert MIDI to Ogg/Vorbis: |
50 | 51 | $1', |
| 52 | + 'score-oggoverridenotfound' => 'The file you specified with override_ogg does not exist.', |
51 | 53 | 'score-page' => 'Page $1', |
52 | 54 | 'score-pregreplaceerr' => 'PCRE regular expression replacement failed', |
53 | 55 | 'score-readerr' => 'Unable to read file $1.', |
— | — | @@ -57,6 +59,7 @@ |
58 | 60 | Set <code>$wgScoreTrim=false</code> if this problem persists.', |
59 | 61 | 'score-versionerr' => 'Unable to obtain LilyPond version: |
60 | 62 | $1', |
| 63 | + 'score-vorbisoverrideogg' => 'You cannot request Ogg/Vorbis rendering and specify override_ogg at the same time.', |
61 | 64 | ); |
62 | 65 | |
63 | 66 | /** Message documentation (Message documentation) */ |
— | — | @@ -69,6 +72,7 @@ |
70 | 73 | 'score-desc' => '{{desc}}', |
71 | 74 | 'score-getcwderr' => 'Displayed if the extension cannot obtain the current working directory.', |
72 | 75 | 'score-invalidlang' => 'Displayed if the lang="…" attribute contains an unrecognised score language. $1 is the unrecognised language.', |
| 76 | + 'score-invalidoggoverride' => 'Displayed if the file specified with the override_ogg="…" attribute is invalid.', |
73 | 77 | 'score-noabcinput' => 'Displayed if an ABC source file could not be created for lang="ABC". $1 is the path to the file that could not be created.', |
74 | 78 | 'score-nofactory' => 'Displayed if the LilyPond/ImageMagick working directory cannot be created.', |
75 | 79 | 'score-noinput' => 'Displayed if the LilyPond input file cannot be created. $1 is the path to the input file.', |
— | — | @@ -78,6 +82,7 @@ |
79 | 83 | 'score-notexecutable' => 'Displayed if LilyPond binary cannot be executed. $1 is the path to the LilyPond binary.', |
80 | 84 | 'score-novorbislink' => 'Displayed if an Ogg/Vorbis link could not be generated. $1 is the explanation why.', |
81 | 85 | 'score-oggconversionerr' => 'Displayed if the MIDI to Ogg/Vorbis conversion failed. $1 is the error (generally big block of text in a pre tag)', |
| 86 | + 'score-oggoverridenotfound' => 'Displayed if the file specified with the override_ogg="…" attribute could not be found.', |
82 | 87 | 'score-page' => 'The word "Page" as used in pagination. $1 is the page number', |
83 | 88 | 'score-pregreplaceerr' => 'Displayed if a PCRE regular expression replacement failed.', |
84 | 89 | 'score-readerr' => 'Displayed if the extension could not read a file. $1 is the path to the file that could not be read.', |
— | — | @@ -85,6 +90,7 @@ |
86 | 91 | 'score-renameerr' => 'Displayed if moving the resultant files from the working environment to the upload directory fails.', |
87 | 92 | 'score-trimerr' => 'Displayed if the extension failed to trim an output image. $1 is the error (generally big block of text in a pre tag)', |
88 | 93 | 'score-versionerr' => 'Displayed if the extension failed to obtain the version string of LilyPond. $1 is the LilyPond stdout output generated by the attempt.', |
| 94 | + 'score-vorbisoverrideogg' => 'Displayed if both vorbis="1" and override_ogg="…" were specified.', |
89 | 95 | ); |
90 | 96 | |
91 | 97 | /** Danish (Dansk) |
Index: trunk/extensions/Score/README |
— | — | @@ -83,6 +83,17 @@ |
84 | 84 | Effect: If set to 1, the rendered image(s) will be embedded into a hyperlink |
85 | 85 | to an appropriate MIDI file. |
86 | 86 | |
| 87 | +* Attribute: override_ogg |
| 88 | + Allowed values: Known file name, that is, if override_ogg="name" is given, |
| 89 | + [[File:name]] is not a redlink. |
| 90 | + Effect: Embeds the media specified by the file name in the HTML below the |
| 91 | + score image(s). This is an alternative to the vorbis attribute (see |
| 92 | + below). It can, for example, be useful if you have a suitable |
| 93 | + Ogg/Vorbis file of superior quality compared with the auto-generated |
| 94 | + Ogg/Vorbis file the vorbis attribute yields. Of course, you can still |
| 95 | + omit both attributes in this case and add the file manually to the |
| 96 | + page, if you prefer. |
| 97 | + |
87 | 98 | * Attribute: raw |
88 | 99 | Allowed valued: 0 (default), 1 |
89 | 100 | Effect: If set to 1, the score code is interpreted as a complete LilyPond |
Index: trunk/extensions/Score/Score.body.php |
— | — | @@ -204,6 +204,20 @@ |
205 | 205 | throw new ScoreException( wfMessage( 'score-invalidlang', $options['lang'] ) ); |
206 | 206 | } |
207 | 207 | |
| 208 | + /* Override OGG file? */ |
| 209 | + if ( array_key_exists( 'override_ogg', $args ) ) { |
| 210 | + $t = Title::newFromText( $args['override_ogg'], NS_FILE ); |
| 211 | + if ( is_null( $t ) ) { |
| 212 | + throw new ScoreException( wfMessage( 'score-invalidoggoverride' ) ); |
| 213 | + } |
| 214 | + if ( !$t->isKnown() ) { |
| 215 | + throw new ScoreException( wfMessage( 'score-oggoverridenotfound' ) ); |
| 216 | + } |
| 217 | + $options['override_ogg'] = $args['override_ogg']; |
| 218 | + } else { |
| 219 | + $options['override_ogg'] = false; |
| 220 | + } |
| 221 | + |
208 | 222 | /* Vorbis rendering? */ |
209 | 223 | if ( array_key_exists( 'vorbis', $args ) ) { |
210 | 224 | $options['vorbis'] = $args['vorbis']; |
— | — | @@ -213,6 +227,9 @@ |
214 | 228 | if ( $options['vorbis'] && !( class_exists( 'OggHandler' ) && class_exists( 'OggAudioDisplay' ) ) ) { |
215 | 229 | throw new ScoreException( wfMessage( 'score-noogghandler' ) ); |
216 | 230 | } |
| 231 | + if ( $options['vorbis'] && ( $options['override_ogg'] !== false ) ) { |
| 232 | + throw new ScoreException( wfMessage( 'score-vorbisoverrideogg' ) ); |
| 233 | + } |
217 | 234 | |
218 | 235 | /* Midi rendering? */ |
219 | 236 | if ( array_key_exists( 'midi', $args ) ) { |
— | — | @@ -228,7 +245,7 @@ |
229 | 246 | $options['raw'] = false; |
230 | 247 | } |
231 | 248 | |
232 | | - $html = self::generateHTML( $code, $options ); |
| 249 | + $html = self::generateHTML( $parser, $code, $options ); |
233 | 250 | } catch ( ScoreException $e ) { |
234 | 251 | $html = "$e"; |
235 | 252 | } |
— | — | @@ -239,6 +256,7 @@ |
240 | 257 | /** |
241 | 258 | * Generates the HTML code for a score tag. |
242 | 259 | * |
| 260 | + * @param $parser Parser MediaWiki parser. |
243 | 261 | * @param $code score code. |
244 | 262 | * @param $options array of music rendering options. Available options keys are: |
245 | 263 | * * lang: score language, |
— | — | @@ -250,7 +268,7 @@ |
251 | 269 | * |
252 | 270 | * @throws ScoreException if an error occurs. |
253 | 271 | */ |
254 | | - private static function generateHTML( $code, $options ) { |
| 272 | + private static function generateHTML( &$parser, $code, $options ) { |
255 | 273 | global $wgUploadDirectory, $wgUploadPath, $wgTmpDirectory, $wgOut; |
256 | 274 | |
257 | 275 | $prof = new ScopedProfiling( __METHOD__ ); |
— | — | @@ -328,6 +346,13 @@ |
329 | 347 | throw new ScoreException( wfMessage( 'score-novorbislink', $e->getMessage() ), 0, $e ); |
330 | 348 | } |
331 | 349 | } |
| 350 | + if ( $options['override_ogg'] ) { |
| 351 | + try { |
| 352 | + $link .= $parser->recursiveTagParse( "[[File:{$options['override_ogg']}]]" ); |
| 353 | + } catch ( Exception $e ) { |
| 354 | + throw new ScoreException( wfMessage( 'score-novorbislink', $e->getMessage() ), 0, $e ); |
| 355 | + } |
| 356 | + } |
332 | 357 | } catch ( Exception $e ) { |
333 | 358 | self::eraseFactory( $factoryDirectory ); |
334 | 359 | throw $e; |