usergallery doesn't show EXIF UTF8 usercomments properly

Found a bug? Tell us!!
Post Reply
vollkorn
Regular
Posts: 13
Joined: Mon Jul 30, 2007 2:52 pm

usergallery doesn't show EXIF UTF8 usercomments properly

Post by vollkorn »

Hi,

I use usergallery 2.40 with serendipity 1.1.3 and configured it to show EXIF date and usercomment. But the usercomment is written in UTF8 which is no problem with other applications and webpages so far (f-spot, flickr, picasa).
But the usergallery plugin can't show them properly. Have a look (preferable with firefox) at this page: http://vollkorn.cryptobitch.de/index.ph ... y[image]=4
Cheers
Jan Girlich
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Hmm. This is something I do not have a quick fix for.

I haven't really looked at the way the EXIF library is interacting with different fields, so I don't have a good idea off the top of my head.

To confuse matters, I am evaluating removing the EXIF library that is included with usergallery (PHP Metadata Toolkit, http://www.ozhiker.com/electronics/pjmt/) and moving to the internally bundled library to make life simpler, but I haven't done a whole lot of work on it yet.

This one will have to wait a little while... I need to do some homework to figure out the best way to move forward.
vollkorn
Regular
Posts: 13
Joined: Mon Jul 30, 2007 2:52 pm

Post by vollkorn »

So,
I had a look at serendipity_event_usergallery.php and though I'm not in to PHP I think the interesting part is about lines 918 to 940. All what we need to do is to look at the field number 37510 and handle it the right way, which means to check if the value starts with "Unicode" and if so strip this part of and convert the rest of the string to the appropriate characterset. This should solve the bug until the rearrangement of the EXIF-code arrives.

Could we work together on this?

Cheers
Jan
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Sure we can work on this together, if you like...

And you are spot on about what needs to happen to fix the current code...

I'll poke at it sometime in the next week or so... If you can come up with a solution I'd be happy to incorporate it.
vollkorn
Regular
Posts: 13
Joined: Mon Jul 30, 2007 2:52 pm

Post by vollkorn »

Okay, I found some time to work on this. But I don't know PHP, so I just had a look at some crash courses for PHP and at this page: http://www.randomchaos.com/documents/?s ... nd_unicode

I implemented the functions utf8_to_unicode() and unicode_to_entities() via copy'n'paste at line 19 in serendipity_event_usergallery.php and and changed the code roundabout at line 970 to this:

Code: Select all

foreach ($exif_arr_num_2 as $num2 => $value2)    {
    if (isset($exif[0][$num1]['Data'][0][$num2]['Text Value'])) {
        if ($exif[0][$num1]['Data'][0][$num2]['Text Value'] == '') { $exif_data[$value2] = 'Unknown'; }
        else {
            if ($num2 == 37510) {
                $exif_data[$value2] = unicode_to_entities(utf8_to_unicode($exif[0][$num1]['Data'][0][$num2]['Text Value']));
            } else {
                $exif_data[$value2] = exif[0][$num1]['Data'][0][$num2]['Text Value'];
            }
        }
    }
}
But I get this error message:
Fatal error: Call to undefined function unicode_to_entities() in /home/vollkorn/public_html/plugins/serendipity_event_usergallery/serendipity_event_usergallery.php on line 975
I absolutely have no idea what I did wrong, but apparently the crash courses haven't been enough to understand PHPs concept of function calls. Can you help me out with this?
If needed I can provide the full source. Please tell me how I should do this.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Sorry about getting to this so slowly... I'm just get run off my feet...

I have a feeling that you are running into a class/function scope issue.

If you have defined the functions inside the usergallery class you will need to reference the function with something like

Code: Select all

                $exif_data[$value2] = $this->unicode_to_entities($this->utf8_to_unicode($exif[0][$num1]['Data'][0][$num2]['Text Value'])); 
Note the "$this->function" syntax.

But I'm kind of guessing...
Post Reply