A Complete Solution to Turkish Char Problem in Pligg

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 09-12-2008, 09:08 AM
ozlegolas's Avatar
Casual Pligger
Pligg Version: 1.0.4
 
Join Date: Apr 2008
Posts: 55
Hi all,
I want to explain how I overcame with Turkish char problem in Pligg 9.9.0.
I warn you these changes may not be optimum way of solving Turkish char problems and I don't guarantee that these changes definitely solve your problems and don't accept any responsibility. At least these solved my problems and I hope these solve your problems too. I advice you to backup your current files before changing them.
Firstly, I had special char problems in sef urls. I changed these special chars with the safe one.
For example:
http://mysite.com/Türkçe_Karakter_Problemi
is changed with
http://mysite.com/turkce-karakter-problemi

1)change libs/utils.php's encoding to UTF-8
2)in libs/utils.php line 249 find and replace
PHP Code:
function makeUrlFriendly($input) {
    global 
$db;

    
//$input = remove_error_creating_chars($input);
    
$output utf8_substr($input0240);
    
    
$output trim($output);    
    
$output html_entity_decode(htmlentities($outputENT_COMPAT'UTF-8'));

    
$output preg_replace("/\s/e" "_" $output);     // Replace spaces with underscores
    
$output str_replace("--""-"$output);      
    
$output str_replace("/"""$output);
    
$output str_replace("\\"""$output);
    
$output str_replace("'"""$output);      
    
$output str_replace(","""$output);      
    
$output str_replace(";"""$output);      
    
$output str_replace(":"""$output);      
    
$output str_replace(".""-"$output);      
    
$output str_replace("?"""$output);      
    
$output str_replace("=""-"$output);      
    
$output str_replace("+"""$output);      
    
$output str_replace("$"""$output);      
    
$output str_replace("&"""$output);      
    
$output str_replace("!"""$output);      
    
$output str_replace(">>""-"$output);      
    
$output str_replace(">""-"$output);      
    
$output str_replace("<<""-"$output);      
    
$output str_replace("<""-"$output);      
    
$output str_replace("*"""$output);      
    
$output str_replace(")"""$output);      
    
$output str_replace("("""$output);
    
$output str_replace("["""$output);
    
$output str_replace("]"""$output);
    
$output str_replace("^"""$output);
    
$output str_replace("%"""$output);
    
$output str_replace("»""-"$output);
    
$output str_replace("|"""$output);
    
$output str_replace("#"""$output);
    
$output str_replace("@"""$output);
    
$output str_replace("`"""$output);
    
$output str_replace("”"""$output);
    
$output str_replace("“"""$output);
    
$output str_replace("\""""$output);

    if(
function_exists('utils_makeUrlFriendly')) {
        
$output utils_makeUrlFriendly($output);
    }
   
    
// check to see if the story title already exists. If so, add an integer to the end of the title
    
$n $db->get_var("SELECT count(*) FROM " table_links " WHERE link_title_url like '$output%'");
    if (
$n 0) {
        return 
$output "-$n";}
    else {
        return 
$output;
    }

change with:
PHP Code:
function makeUrlFriendly($input) {
    global 
$db;

    
//$input = remove_error_creating_chars($input);
    
$input utf8_strtolower($input0240);
    
    
$output trim($input);    
    
//$output = html_entity_decode(htmlentities($output, ENT_COMPAT, 'UTF-8'));

    
$output preg_replace("/\s/e" "_" $output);     // Replace spaces with underscores
    
$output str_replace("--""-"$output);      
    
$output str_replace("/"""$output);
    
$output str_replace("\\"""$output);
    
$output str_replace("'"""$output);      
    
$output str_replace(","""$output);      
    
$output str_replace(";"""$output);      
    
$output str_replace(":"""$output);      
    
$output str_replace(".""-"$output);      
    
$output str_replace("?"""$output);      
    
$output str_replace("=""-"$output);      
    
$output str_replace("+"""$output);      
    
$output str_replace("$"""$output);      
    
$output str_replace("&"""$output);      
    
$output str_replace("!"""$output);      
    
$output str_replace(">>""-"$output);      
    
$output str_replace(">""-"$output);      
    
$output str_replace("<<""-"$output);      
    
$output str_replace("<""-"$output);      
    
$output str_replace("*"""$output);      
    
$output str_replace(")"""$output);      
    
$output str_replace("("""$output);
    
$output str_replace("["""$output);
    
$output str_replace("]"""$output);
    
$output str_replace("^"""$output);
    
$output str_replace("%"""$output);
    
$output str_replace("»""-"$output);
    
$output str_replace("|"""$output);
    
$output str_replace("#"""$output);
    
$output str_replace("@"""$output);
    
$output str_replace("`"""$output);
    
$output str_replace("”"""$output);
    
$output str_replace("“"""$output);
    
$output str_replace(" - ""-"$output);
    
$output str_replace("_""-"$output);
    
$output str_replace("---""-"$output);
    
$output str_replace("\""""$output);
    
$output str_replace("--""-"$output);
    
$output str_replace("&ccedil;""c"$output);
    
$output str_replace("ğ""g"$output);
    
$output str_replace("ı""i"$output);
    
$output str_replace("&ouml;""o"$output);
    
$output str_replace("ş""s"$output);
    
$output str_replace("&uuml;""u"$output);
    
$output str_replace("&Ccedil;""c"$output);
    
$output str_replace("Ğ""g"$output);
    
$output str_replace("İ""i"$output);
    
$output str_replace("&Ouml;""o"$output);
    
$output str_replace("Ş""s"$output);
    
$output str_replace("&Uuml;""u"$output);
    
$output str_replace("ç""c"$output);
    
$output str_replace("ğ""g"$output);
    
$output str_replace("ı""i"$output);
    
$output str_replace("ö""o"$output);
    
$output str_replace("ş""s"$output);
    
$output str_replace("ü""u"$output);
    
$output str_replace("Ç""c"$output);
    
$output str_replace("Ğ""g"$output);
    
$output str_replace("İ""i"$output);
    
$output str_replace("Ö""o"$output);
    
$output str_replace("Ş""s"$output);
    
$output str_replace("Ü""u"$output);
    
    if(
function_exists('utils_makeUrlFriendly')) {
        
$output utils_makeUrlFriendly($output);
    }
   
    
// check to see if the story title already exists. If so, add an integer to the end of the title
    
$n $db->get_var("SELECT count(*) FROM " table_links " WHERE link_title_url like '$output%'");
    if (
$n 0) {
        return 
$output "-$n";}
    else {
        return 
$output;
    }

3)in libs/utils.php line 335 find and replace:
PHP Code:
function makeCategoryFriendly($input) {

    
$input utf8_substr($input0240);

    
$output trim($input);

    
$output preg_replace("/\s/e"""$output);     // remove spaces
    
$output str_replace("_"""$output);
    
$output str_replace("--"""$output);
    
$output str_replace("'"""$output);
    
$output str_replace('"'''$output);
    
$output str_replace('&''_'$output);
    
$output str_replace('/''_'$output);
    
$output str_replace('!'''$output);
    
$output str_replace('?'''$output);
    
$output str_replace('$'''$output);
    
    if(
function_exists('utils_makeUrlFriendly')) {
        
$output utils_makeUrlFriendly($output);
    }
    
    return 
urlencode($output);       

with:
PHP Code:
function makeCategoryFriendly($input) {

    
$input utf8_strtolower($input0240);

    
$output trim($input);

    
$output preg_replace("/\s/e"""$output);     // remove spaces
    
$output str_replace("_"""$output);
    
$output str_replace("--"""$output);
    
$output str_replace("'"""$output);
    
$output str_replace('"'''$output);
    
$output str_replace('&''_'$output);
    
$output str_replace('/''_'$output);
    
$output str_replace('!'''$output);
    
$output str_replace('?'''$output);
    
$output str_replace('$'''$output);
    
$output str_replace("&ccedil;""c"$output);
    
$output str_replace("ğ""g"$output);
    
$output str_replace("ı""i"$output);
    
$output str_replace("&ouml;""o"$output);
    
$output str_replace("ş""s"$output);
    
$output str_replace("&uuml;""u"$output);
    
$output str_replace("&Ccedil;""c"$output);
    
$output str_replace("Ğ""g"$output);
    
$output str_replace("İ""i"$output);
    
$output str_replace("&Ouml;""o"$output);
    
$output str_replace("Ş""s"$output);
    
$output str_replace("&Uuml;""u"$output);
    
$output str_replace("ç""c"$output);
    
$output str_replace("ğ""g"$output);
    
$output str_replace("ı""i"$output);
    
$output str_replace("ö""o"$output);
    
$output str_replace("ş""s"$output);
    
$output str_replace("ü""u"$output);
    
$output str_replace("Ç""c"$output);
    
$output str_replace("Ğ""g"$output);
    
$output str_replace("İ""i"$output);
    
$output str_replace("Ö""o"$output);
    
$output str_replace("Ş""s"$output);
    
$output str_replace("Ü""u"$output);
    
    if(
function_exists('utils_makeUrlFriendly')) {
        
$output utils_makeUrlFriendly($output);
    }
    
    return 
$output;       

These changes should change urls that have turkish chars with the safe one. I did these changes about 4 months ago, so I may not remember all things I did. Your feedbacks would help me to complete changes if there are any incompletion.

Last edited by ozlegolas; 09-12-2008 at 09:52 AM.
Reply With Quote
  #2 (permalink)  
Old 09-12-2008, 09:37 AM
ozlegolas's Avatar
Casual Pligger
Pligg Version: 1.0.4
 
Join Date: Apr 2008
Posts: 55
If you have tags contain special chars like "türkçe" you have to do these changes to get correct results when you click on a tag.

1)Change your files'(that will contain Turkish chars) encoding to UTF-8
2) Do the things in this thread.
2)in libs/tags.php line 123 find:
PHP Code:
$tag_url str_replace(" ""+"$tag_url); // Steef 2k7-07 tag search fix 
after above add this:
PHP Code:
//***************Safe Tag Hack by Tuna********************
                
$tag_url str_replace("ç""c"$tag_url);
                
$tag_url str_replace("ğ""g"$tag_url);
                
$tag_url str_replace("ı""i"$tag_url);
                
$tag_url str_replace("ö""o"$tag_url);
                
$tag_url str_replace("ş""s"$tag_url);
                
$tag_url str_replace("ü""u"$tag_url);
                
//******************************************************* 
3)in libs/link.php about 565. line find and replace this:
PHP Code:
if(isset($tag_array[$i])){
                        if ( 
$URLMethod == ) { 
                            
$tags_url_array[$i] = my_pligg_base "/search.php?search=".urlencode(trim($tag_array[$i]))."&amp;tag=true";
                        } elseif ( 
$URLMethod == 2) {
                            
$tags_url_array[$i] = my_pligg_base "/tag/" urlencode(trim($tag_array[$i]));
                    }
                  } 
with this:
PHP Code:
if(isset($tag_array[$i])){
                    
                    
//***********Safe Tag Hack by Tuna********************************** 
                    
$replace_what = array("ç","ğ","ı","ö","ş","ü");
                    
$replace_with = array("c","g","i","o","s","u");
                    
$tag_arraySafestr_ireplace($replace_what,$replace_with,$tag_array);
                    
//******************************************************************** 
                        
if ( $URLMethod == ) { 
                            
$tags_url_array[$i] = my_pligg_base "/search.php?search=".urlencode(trim($tag_arraySafe[$i]))."&amp;tag=true";
                        } elseif ( 
$URLMethod == 2) {
                            
$tags_url_array[$i] = my_pligg_base "/tag/" urlencode(trim($tag_arraySafe[$i]));
                    }
                  } 
4)in /search.php line 58 find and replace this:
PHP Code:
// breadcrumbs and page title
$navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Search') . stripslashes($search->searchTerm);
$navwhere['link1'] = getmyurl('search'urlencode($search->searchTerm));
$main_smarty->assign('navbar_where'$navwhere);
$main_smarty->assign('posttitle'" / " $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Search') . stripslashes($search->searchTerm)); 
with this:
PHP Code:
//*********************NAVBAR SAFE TAG NAME HACK BY TUNA************************************************************************
//***********************************************************************************************************************************
$tag_name=$db->get_var("SELECT tag_words FROM " table_tags " WHERE `tag_safe` = '".stripslashes($search->searchTerm)."';");
if(
$tag_name==''){
$tag_name=stripslashes($search->searchTerm);

// breadcrumbs and page title
if(isset($_REQUEST['tag'])){
    
$search_name=$tag_name;
    
$navwhere['text1'] = 'Etiket: ' $tag_name;
    
$main_smarty->assign('posttitle'" / " $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Search') . $tag_name);
    
$navwhere['link1'] = getmyurl('tag'urlencode($search->searchTerm));
    
// pagename    
    
define('pagename''tag'); 
}
else{
    
$search_name=stripslashes($search->searchTerm);
    
$navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Search') . stripslashes($search->searchTerm);
    
$main_smarty->assign('posttitle'" / " $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Search') . stripslashes($search->searchTerm));
    
$navwhere['link1'] = getmyurl('search'urlencode($search->searchTerm));
    
// pagename    
    
define('pagename''search'); 
    
}
    
$main_smarty->assign('pagename'pagename);

    
$main_smarty->assign('navbar_where'$navwhere);
//**********************************************************************************************************
//********************************************************************************************************** 
If any problem occurs or these changes don't solve your problem let me know
Reply With Quote
  #3 (permalink)  
Old 09-12-2008, 09:50 AM
ozlegolas's Avatar
Casual Pligger
Pligg Version: 1.0.4
 
Join Date: Apr 2008
Posts: 55
Here are my files(libs/utils.php, libs/tags.php, libs/search.php, /search.php).

You can use them directly but I don't guarantee whether it works or not
Attached Files
File Type: rar tags-utils-search.rar (13.1 KB, 65 views)
Reply With Quote
  #4 (permalink)  
Old 09-12-2008, 03:32 PM
amsy's Avatar
New Pligger
Pligg Template: TheMissingpiec
 
Join Date: Jul 2007
Location: İstanbul
Posts: 20
very useful solution for the turkish char problem and only solution for about the this problem...

adamımsın dostum sayende başardık bu işi..

her türk pligg kullanıcısı bunu yapsın
Reply With Quote
  #5 (permalink)  
Old 09-13-2008, 05:41 AM
ozlegolas's Avatar
Casual Pligger
Pligg Version: 1.0.4
 
Join Date: Apr 2008
Posts: 55
Quote:
Originally Posted by amsy View Post
very useful solution for the turkish char problem and only solution for about the this problem...

adamımsın dostum sayende başardık bu işi..

her türk pligg kullanıcısı bunu yapsın
As far as I see, you have still Turkish char problems with the tags in link summary and tag titles, are you sure you did all things which I mentioned
Reply With Quote
  #6 (permalink)  
Old 10-13-2008, 04:19 AM
New Pligger
 
Join Date: Oct 2008
Posts: 1
sanırım yeni versiyonla uyumlu değil. Haberler sitesine 9.9.5'i kurdum ve dediklerinizi yaptım ama olmadı. units.php'nin kodlar değişmiş.

Last edited by filmist; 10-13-2008 at 06:52 AM.
Reply With Quote
  #7 (permalink)  
Old 10-13-2008, 11:59 AM
ozlegolas's Avatar
Casual Pligger
Pligg Version: 1.0.4
 
Join Date: Apr 2008
Posts: 55
I am using pligg 9.9.0 and didn't try it for 9.9.5, so I don't know whether it's applicable to 9.9.5 or not.
Reply With Quote
  #8 (permalink)  
Old 11-04-2008, 06:25 PM
Casual Pligger
Pligg Version: 9.9.5
Pligg Template: yget
 
Join Date: Aug 2007
Location: Turkey
Posts: 32
Quote:
Originally Posted by ozlegolas View Post
I am using pligg 9.9.0 and didn't try it for 9.9.5, so I don't know whether it's applicable to 9.9.5 or not.
İngilizce konuşabildiğini öğrenmemiz güzel oldu dostum
Reply With Quote
  #9 (permalink)  
Old 11-04-2008, 07:52 PM
Casual Pligger
Pligg Version: 9.9.5
Pligg Template: yget
 
Join Date: Aug 2007
Location: Turkey
Posts: 32
Birde sadece Türkçe konuşabilen birinden bir çözüm;

libs/db.php php dosyasını açın.

aşağıdaki satırı bulun. (Sayfanın en altındadır.)

$db = new ezSQL_mysql(EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST);

Hemen altına şu satırları ekleyin ve UTF8 kullanan Pligg'in keyfini yaşayın. Başka hiçbir dosyadada değişiklik yapmayın. Bu çözümden sonra Cache kullanıyorsanız sonucun ekranda görünmesi zaman alabilir. Cache süresinin dolmasını beklemeniz gerekebilir.

$db->query("SET NAMES 'UTF8'");
$db->query("SET CHARACTER SET 'UTF8'");
$db->query("SET COLLATION_CONNECTION='utf8_general_ci'");

Tablonuzu UTF8 yaptığınızı ve karakter karşılaştırmasını "utf8_general_ci" yaptığınızı varsayıyorum.
Reply With Quote
  #10 (permalink)  
Old 11-10-2008, 06:01 PM
Casual Pligger
 
Join Date: Oct 2008
Posts: 40
çok tesekkürler, keske pligg forumda türkçe grubu olsa..
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using index.php outside of pligg directory zeropaid Questions and Comments 5 02-11-2010 02:35 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development