Brian Wolff has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63266


Change subject: Make score work with multi-page files
......................................................................

Make score work with multi-page files

Score was looking for files of the form "foo-1.png", "foo-2.png"
where really it should have been looking for "foo-page1.png".
(Someone should double check that it isn't just my install of
lilypond being broken or something).

Also there was a variable name mismatch in the multipage handling
code.

I'm not sure if it really is appropriate to have "Page 1" in the
alt text. I can't imagine what a blind person would do with that
info, however I left it there. I also added the page number to
title, as its mildly useful as a tooltip.

As an aside, I'm not sure if it would make sense to add a sanity
check somewhere - only copy over a max 5000 pages or something.

Change-Id: I09f1fca86a38655dfc1583835c3e59823a08653c
---
M Score.body.php
1 file changed, 15 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score 
refs/changes/66/63266/1

diff --git a/Score.body.php b/Score.body.php
index 3240550..bdebf0d 100644
--- a/Score.body.php
+++ b/Score.body.php
@@ -407,7 +407,7 @@
 
                        /* Generate PNG and MIDI files if necessary */
                        $imageFileName = "{$options['file_name_prefix']}.png";
-                       $multi1FileName = 
"{$options['file_name_prefix']}-1.png";
+                       $multi1FileName = 
"{$options['file_name_prefix']}-page1.png";
                        $midiFileName = "{$options['file_name_prefix']}.midi";
                        if (
                                ( 
@@ -458,19 +458,22 @@
                                        'src' => 
"{$options['dest_url']}/$imageFileName",
                                        'alt' => $code,
                                ) );
-                       } elseif ( isset( $existingFiles[$multi1Path] ) ) { // 
@fixme: $multi1Path is undefined
+                       } elseif ( isset( $existingFiles[$multi1FileName] ) ) {
                                $link = '';
                                for ( $i = 1; ; ++$i ) {
-                                       $fileName = 
"{$options['file_name_prefix']}-$i.png";
+                                       $fileName = 
"{$options['file_name_prefix']}-page$i.png";
                                        if ( !isset( $existingFiles[$fileName] 
) ) {
                                                break;
                                        }
+                                       $pageNumb = wfMessage( 'score-page' )
+                                               ->inContentLanguage()
+                                               ->numParams( $i )
+                                               ->plain();
+
                                        $link .= Html::rawElement( 'img', array(
                                                'src' => 
"{$options['dest_url']}/$fileName",
-                                               'alt' => wfMessage( 
'score-page' )
-                                                       ->inContentLanguage()
-                                                       ->numParams( $i )
-                                                       ->plain()
+                                               'alt' => $pageNumb,
+                                               'title' => $pageNumb
                                        ) );
                                }
                        } else {
@@ -604,11 +607,11 @@
                                self::trimImage( $factoryImage, 
$factoryImageTrimmed );
                        } else {
                                for ( $i = 1; ; ++$i ) {
-                                       $src = "$factoryDirectory/file-$i.png";
+                                       $src = 
"$factoryDirectory/file-page$i.png";
                                        if ( !file_exists( $src ) ) {
                                                break;
                                        }
-                                       $dest = 
"$factoryDirectory/file-$i-trimmed.png";
+                                       $dest = 
"$factoryDirectory/file-page$i-trimmed.png";
                                        self::trimImage( $src, $dest );
                                }
                        }
@@ -653,14 +656,14 @@
                } else {
                        for ( $i = 1; ; ++$i ) {
                                if ( $wgScoreTrim ) {
-                                       $src = 
"$factoryDirectory/file-$i-trimmed.png";
+                                       $src = 
"$factoryDirectory/file-page$i-trimmed.png";
                                } else {
-                                       $src = "$factoryDirectory/file-$i.png";
+                                       $src = 
"$factoryDirectory/file-page$i.png";
                                }
                                if ( !file_exists( $src ) ) {
                                        break;
                                }
-                               $dstFileName = 
"{$options['file_name_prefix']}-$i.png";
+                               $dstFileName = 
"{$options['file_name_prefix']}-page$i.png";
                                $dest = 
"{$options['dest_storage_path']}/$dstFileName";
                                $ops[] = array(
                                        'op' => 'store',

-- 
To view, visit https://gerrit.wikimedia.org/r/63266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I09f1fca86a38655dfc1583835c3e59823a08653c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Score
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to