Go Back   Pligg CMS Forum > Pligg Development > Bug Report

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2006, 12:49 AM
New Pligger
 
Join Date: Dec 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Chinese word cut problem

At the last word of chinese characters pligg cannot correctly display the word.

See attached pictures, please remove this bug(the small squares).
Attached Thumbnails
chinese-word-cut-problem-queued-news.jpg   chinese-word-cut-problem-single_story.jpg  
Reply With Quote
  #2 (permalink)  
Old 12-13-2006, 04:22 AM
savant's Avatar
Constant Pligger
 
Join Date: Apr 2006
Location: UK
Posts: 1,218
Thanks: 64
Thanked 207 Times in 148 Posts
could you post some chinese text on the forum, so i can just copy them and test.

It might be some string functions that aren't aware of those characters.
__________________
Anatomy of the Pligg template Help needed
Reply With Quote
  #3 (permalink)  
Old 12-14-2006, 12:38 AM
New Pligger
 
Join Date: Dec 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by savant View Post
could you post some chinese text on the forum, so i can just copy them and test.

It might be some string functions that aren't aware of those characters.
Here we go:

汇聚&分享网络精彩影音资源&互动交友社区
雷区-迅雷雷区-雷区资源-免费下载——尽在www.leiqu.com!雷区是集网络资源交流和社区交友为一体的具有Web2.0特征的社区。

雷区尊重多元化文化、鼓励营造学习型的团队,我们致力于充分发挥个人的潜能、努力为员工提供最佳培训机会。 我们欢迎有创业精神的计算机专业优秀的人才加入我们。

*雷区论坛在升级AnyMedia播放器时由于操作失当导致数据库崩溃,现由专业人员努力恢复中,请广大雷 区积极参与到雷友集体博客的写作中来。
Reply With Quote
  #4 (permalink)  
Old 12-16-2006, 02:00 AM
New Pligger
 
Join Date: Dec 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Any progress to solve this problem?
Reply With Quote
  #5 (permalink)  
Old 12-18-2006, 04:46 AM
savant's Avatar
Constant Pligger
 
Join Date: Apr 2006
Location: UK
Posts: 1,218
Thanks: 64
Thanked 207 Times in 148 Posts
here's what i have found out.

if you try and change the link status(admin)
you will see the chinese characters properly without any weird symbols.
which means the database is ok.

now i will need to hunt which function is causing the weird characters.

link.php : fill_smarty function

$title_short = htmlspecialchars(wordwrap($this->title, 30, " ", 1));

this line is breaking the title. the wordwrap is the culprit.
__________________
Anatomy of the Pligg template Help needed

Last edited by savant; 12-18-2006 at 04:50 AM..
Reply With Quote
  #6 (permalink)  
Old 12-18-2006, 06:45 AM
savant's Avatar
Constant Pligger
 
Join Date: Apr 2006
Location: UK
Posts: 1,218
Thanks: 64
Thanked 207 Times in 148 Posts
next bit was to the get the links working.

Whenever i clicked on the title it would load an empty page.
To fix that problem i had to put an urlencode function on the url.

link.php > fill_smarty()
PHP Code:
$smarty->assign('title_url'urlencode($this->title_url));
        
$smarty->assign('enc_title_short'urlencode($title_short));
        if (
$this->title_url == ""){
            
$smarty->assign('story_url'getmyurl("story"$this->id)); // internal link to the comments page
        
} else {
            
$smarty->assign('story_url'getmyurl("storyURL"$this->category_safe_name(), urlencode($this->title_url), $this->id)); // internal link to the comments page
        

now when i click on the title, the page opens correctly.

same can be done to fix the breadcrumbs

Now the weird symbols in the summary is caused by substr here

PHP Code:
if($_POST['summarytext'] == ""){
                
$linkres->link_summary substr(strip_tags(trim($_POST['bodytext']), Story_Content_Tags_To_Allow), 0StorySummary_ContentTruncate 1);
            } else {
                
$linkres->link_summary strip_tags(trim($_POST['summarytext']), Story_Content_Tags_To_Allow);
                if(
strlen($linkres->link_summary) > StorySummary_ContentTruncate){
                    
loghack('SubmitAStory-SummaryGreaterThanLimit''username: ' $_POST["username"].'|email: '.$_POST["email"], true);
                    
$linkres->link_summary substr($linkres->link_summary0StorySummary_ContentTruncate 1);
                }
            } 
I have found this package called phputf8 which has string function which obey utf rules which works like a charm.

Before i commit anything i would like people to post more text like viegent to verify it works. thanks

Now about the tags, the chinese character isn't displayed poperly because of the use strlower. This was fixed using utf8_strlower().

in the tag cloud, urlencode did the trick.
__________________
Anatomy of the Pligg template Help needed

Last edited by savant; 12-18-2006 at 07:30 AM..
Reply With Quote
The Following 3 Users Say Thank You to savant For This Useful Post:
  #7 (permalink)  
Old 12-18-2006, 07:51 AM
savant's Avatar
Constant Pligger
 
Join Date: Apr 2006
Location: UK
Posts: 1,218
Thanks: 64
Thanked 207 Times in 148 Posts
thought i'd post this (evidence)

chinese-word-cut-problem-lang.jpg

from the top
Nepali (my language)
Korean
Chinese
__________________
Anatomy of the Pligg template Help needed
Reply With Quote
  #8 (permalink)  
Old 12-18-2006, 10:00 AM
athle's Avatar
Casual Pligger
 
Join Date: Oct 2006
Posts: 55
Thanks: 5
Thanked 26 Times in 6 Posts
thx for do those compatible work, it's very useful.
Reply With Quote
  #9 (permalink)  
Old 12-19-2006, 06:21 AM
New Pligger
 
Join Date: Dec 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks savant

I just know a littlle about code and I cannot understand all the modification above.

As I know my pligg version has changed $title_short = htmlspecialchars(wordwrap($this->title, 30, " ", 1)); to $title_short =$this->title

Please instruct me how to change new code.
Reply With Quote
  #10 (permalink)  
Old 12-19-2006, 06:24 AM
savant's Avatar
Constant Pligger
 
Join Date: Apr 2006
Location: UK
Posts: 1,218
Thanks: 64
Thanked 207 Times in 148 Posts
hey

1. Story.php

Replace (line 81)

PHP Code:
$navwhere['link2'] = getmyurl('storytitle'$link->title_url); 
With:

PHP Code:
$navwhere['link2'] = getmyurl('storytitle'urlencode($link->title_url)); 
2. libs/tags.php

Replace (line 12)
PHP Code:
return strtolower($string); 
With
PHP Code:
return utf8_strtolower($string); 
Replace (line 146)
PHP Code:
$tag_url[$tagnumber] = getmyurl('tag'$tag_name[$tagnumber]); 
With
PHP Code:
$tag_url[$tagnumber] = getmyurl('tag'urlencode($tag_name[$tagnumber])); 
3. /libs/link.php

Replace line 371
PHP Code:
$title_short htmlspecialchars(wordwrap($this->title30" "1)); 
With
PHP Code:
$title_short htmlspecialchars($this->title); 
Without the wrodwrap people can post longer titles which can ruin the page. I will try and get a utf8 wordwrap

Replace line 386
PHP Code:
$smarty->assign('title_url'$this->title_url); 
With
PHP Code:
$smarty->assign('title_url'urlencode($this->title_url)); 
Replace line 391
PHP Code:
$smarty->assign('story_url'getmyurl("storyURL"$this->category_safe_name(), $this->title_url$this->id)); // internal link to the comments page 
With
PHP Code:
$smarty->assign('story_url'getmyurl("storyURL"$this->category_safe_name(), urlencode($this->title_url), $this->id)); // internal link to the comments page 
4. editlink.php

Replace line 89
PHP Code:
$linkres->link_summary substr(strip_tags(trim($_POST['bodytext']), Story_Content_Tags_To_Allow), 0StorySummary_ContentTruncate 1); 
With
PHP Code:
$linkres->link_summary utf8_substr(strip_tags(trim($_POST['bodytext']), Story_Content_Tags_To_Allow), 0StorySummary_ContentTruncate 1); 
Replace line 94
PHP Code:
$linkres->link_summary substr($linkres->link_summary0StorySummary_ContentTruncate 1); 
With
PHP Code:
$linkres->link_summary utf8_substr($linkres->link_summary0StorySummary_ContentTruncate 1); 
5. Download this zip file and extract this in the /libs/ folder.
utf8.zip

6. config.php
Add
PHP Code:
include mnminclude.'utf8/utf8.php'
After
PHP Code:
include_once(mnmmodules 'modules_init.php'); 
Please try this and report back .

thanks
__________________
Anatomy of the Pligg template Help needed

Last edited by savant; 12-19-2006 at 06:50 AM..
Reply With Quote
The Following 3 Users Say Thank You to savant For This Useful Post:
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
中文乱码 problem with rss title and templates in chinese jackpu General Help 5 08-15-2008 05:22 AM
HELP: Chinese display problem wanderingcat General Help 3 07-18-2007 11:49 PM
a serious problem about databackup for Pligg Chinese Version KaneYoung Bug Report 1 07-18-2007 02:09 PM
Duplicate URLs Utf-8 Chinese categories problem in Pligg beta 9 build 693 tiwe Bug Report 2 02-10-2007 09:59 PM
Problem form doesn't work! nabil Bug Report 1 04-01-2006 08:53 PM


Search Engine Friendly URLs by vBSEO 3.2.0