[G2] cyrillic problems in sidebar.tpl (matrix theme)

boyan7640

Joined: 2006-05-10
Posts: 5
Posted: Wed, 2006-05-10 15:57

OK, hello to all. I have some small cyrillic problems in my sidebar. I have got cyrillic characters in my gallery names and this part of code doesn't show them correctly:

Quote:
{foreach from=$theme.params.sidebarBlocks item=block}
{g->block type=$block.0 params=$block.1 class="gbBlock"}
{/foreach}

Everything is OK in my PostgreSQL database and I use UTF-8 encoding in it and default charset in apache2. The webpage is also UTF encoded. I am using bulgarian translation. The strange thing is that first part of this code work and show me correctly admin system menu for adding album, photo, edit and so on. But the second part of the sidebar ("Links to album/photo peers"), album hierarchy, is BAD. I made a screenshot for you friends. I don't know where to search in the code about this error.

[img]http://www.boyan-bg.com/images/misc/2006-05-10/Screenshot.png[/img]

OK, I hope for your help! Thanks!

AttachmentSize
Screenshot.png125.61 KB
 
boyan7640

Joined: 2006-05-10
Posts: 5
Posted: Sun, 2006-05-14 17:10

OK, I found this but it couldn't help me to solve the problem!

http://sourceforge.net/tracker/?group_id=7130&atid=107130&func=detail&aid=1164831

If someone see the error please write!

 
boyan7640

Joined: 2006-05-10
Posts: 5
Posted: Wed, 2006-05-17 11:03

OK, I found the problem in the core template in Gallery2 and more precisely in modules/core/templates/blocks/PeerList.tpl !

There are two smarty tags like this:

Quote:
{g->text text="%d. %s" arg1=$peer.peerIndex arg2=$title|markup:strip|entitytruncate:14}

They must be change to this:

Quote:
{g->text text="%d. %s" arg1=$peer.peerIndex arg2=$title|truncate:14}

Don't have time to completely undestand the problem (somewhere in smarty markup or strip, or entitytruncate).

I hope this will help to someone because I lost too much time to find it!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-05-19 16:19

I did a quick test and couldn't reproduce this.. more likely the problem is with entitytruncate and not markup:strip. If you can post your system info and the exact bytes of one such item title that has this problem, we might be able to track it down. But if your workaround is working, that's good.

 
boyan7640

Joined: 2006-05-10
Posts: 5
Posted: Tue, 2006-05-23 06:38

OK, you are right mindless. The markup:strip is not the problem but entitytruncate. I made a test and everything looks great with this:

Quote:
{g->text text="%d. %s" arg1=$peer.peerIndex arg2=$title|markup:strip|truncate:14}

OK, this is my system info:

Quote:
System Information
Gallery version 2.1.1
PHP version 5.1.2-gentoo apache2handler
Webserver Apache
Database postgres7 8.0.4 3 8.0.4
Toolkits Gd
Operating system Linux boychev 2.6.15-gentoo-r1 #1 SMP PREEMPT Mon Apr 3 22:52:02 EEST 2006 i686
Browser Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.3) Gecko/20060504 Fedora/1.5.0.3-1.1.fc5 Firefox/1.5.0.3 pango-text

I didn't understand this in your post:

Quote:
the exact bytes of one such item title that has this problem

Thank you!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-05-23 15:06

Put this at the top of themes/{yourtheme}/templates/photo.tpl

{php}$x=$this->_tpl_vars['theme']['item']['title'];
for ($i=0; $i<strlen($x); $i++) var_dump(ord($x[$i]));{/php}

Now visit a photo that would get its title improperly truncated (before your fix) and you'll see a bunch of "int(..)" strings on the page. Post those here.

 
boyan7640

Joined: 2006-05-10
Posts: 5
Posted: Thu, 2006-05-25 08:24

The problem is not in photo.tpl, but in sidebar.tpl and more precisely in modules/core/templates/blocks/PeerList.tpl !

I put this php code there and this is the result with entitytruncate (original) for photo with whole title "Язовира в местност:Туричка Черква (в заден план вр.Синаница)":

Quote:
ѐѐёΠΠѐґѐґ:ё...

int(208) int(175) int(208) int(183) int(208) int(190) int(208) int(178) int(208) int(184) int(209) int(128) int(208) int(176) int(32) int(208) int(178) int(32) int(208) int(188) int(208) int(181) int(209) int(129) int(209) int(130) int(208) int(189) int(208) int(190) int(209) int(129) int(209) int(130) int(58) int(208) int(162) int(209) int(131) int(209) int(128) int(208) int(184) int(209) int(135) int(208) int(186) int(208) int(176) int(32) int(208) int(167) int(208) int(181) int(209) int(128) int(208) int(186) int(208) int(178)

The same result with truncate(my fix) except the first row of course:

Quote:
Язовира в...

int(208) int(175) int(208) int(183) int(208) int(190) int(208) int(178) int(208) int(184) int(209) int(128) int(208) int(176) int(32) int(208) int(178) int(32) int(208) int(188) int(208) int(181) int(209) int(129) int(209) int(130) int(208) int(189) int(208) int(190) int(209) int(129) int(209) int(130) int(58) int(208) int(162) int(209) int(131) int(209) int(128) int(208) int(184) int(209) int(135) int(208) int(186) int(208) int(176) int(32) int(208) int(167) int(208) int(181) int(209) int(128) int(208) int(186) int(208) int(178)

OK, don't bother too much mindless, maybe the problem is only in my gallery, not big deal. Thank you for your efforts!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2006-05-25 15:56

Thanks.. I created $testStr with those bytes and couldn't reproduce the problem.

<p>{$testStr}</p>
<p>{$testStr|truncate:14}</p>
<p>{$testStr|truncate:15}</p>
<p>{$testStr|entitytruncate:8}</p>
<p>{$testStr|entitytruncate:9}</p>

Resulting output was:

Quote:
Язовира в местност:Туричка Черкв

Язови�...

Язовир...

Язови...

Язовир...

Maybe entitytruncate would work for you on a different PHP version or something.. otherwise your workaround is ok i guess.