Cyrillic charset

phpBB2 SEO Advanced mod Rewrite support forum.
This mods performs URL rewriting for phpBB, injecting categories, forums and topic titles in their URLs.

Moderator: Moderators

Cyrillic charset

Postby Cama » Sun Oct 26, 2008 1:21 am

Hello
Has read all forum, but and has not found the decision on wrong display of the text in the link. Though in in a file code phpbb_seo_class.php there is a point of setting of the charset. All the same does not work. Instead of the text, for example "soft" it is visible "1008-1031" etc..
Therefore I use simple the version =(
Thanks for your job, like me yours mods :)
Cama
 
Posts: 6
Joined: Sat Oct 25, 2008 11:01 pm

Advertisement

Postby dcz » Sun Oct 26, 2008 10:09 am

It's most lekely because the char-set you're using is not supported by htmlentities()

In such case, you could still implement some custom characters replacements in the format_url method (in phpbb_seo/phpbb_seo_class.php), but this only has a meaning if Latin chars can replace Cyrillic characters and stay meaningful.

With phpBB3, it would be simpler, all non Latin chars would just be trashed, allowing you to sometime use selected Latin keywords in titles and thus urls.
This is handy when for example talking about technical terms which are often in English, like css, mod_rewrite and so on. If not, the simple mod rewrite is the way to go ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby Cama » Sun Oct 26, 2008 1:30 pm

Ok. This problem has solved, has more correctly bypassed :)

After
Code: Select all
      $url = preg_replace("`\[.*\]`U","",$url);

To add
Code: Select all
      $url = str_replace( array('à', 'À'),'a', $url );
      $url = str_replace( array('á', 'Á'),'b', $url );
      $url = str_replace( array('â', 'Â'),'v', $url );
      $url = str_replace( array('ã', 'Ã'),'g', $url );
      $url = str_replace( array('ä', 'Ä'),'d', $url );
      $url = str_replace( array('å', 'Å'),'e', $url );
      $url = str_replace( array('¸', '¨'),'e', $url );
      $url = str_replace( array('æ', 'Æ'),'zh', $url );
      $url = str_replace( array('ç', 'Ç'),'z', $url );
      $url = str_replace( array('è', 'È'),'i', $url );
      $url = str_replace( array('ê', 'Ê'),'k', $url );
      $url = str_replace( array('ë', 'Ë'),'l', $url );
      $url = str_replace( array('ì', 'Ì'),'m', $url );
      $url = str_replace( array('í', 'Í'),'n', $url );
      $url = str_replace( array('î', 'Î'),'o', $url );
      $url = str_replace( array('ï', 'Ï'),'p', $url );
      $url = str_replace( array('ð', 'Ð'),'r', $url );
      $url = str_replace( array('ñ', 'Ñ'),'s', $url );
      $url = str_replace( array('ò', 'Ò'),'t', $url );
      $url = str_replace( array('ó', 'Ó'),'u', $url );
      $url = str_replace( array('ô', 'Ô'),'f', $url );
      $url = str_replace( array('õ', 'Õ'),'h', $url );
      $url = str_replace( array('ö', 'Ö'),'tc', $url );
      $url = str_replace( array('÷', '×'),'ch', $url );
      $url = str_replace( array('ø', 'Ø'),'sh', $url );
      $url = str_replace( array('ù', 'Ù'),'shch', $url );
      $url = str_replace( array('ú', 'Ú'),'', $url );
      $url = str_replace( array('û', 'Û'),'YI', $url );
      $url = str_replace( array('ü', 'Ü'),'', $url );
      $url = str_replace( array('ý', 'Ý'),'ye', $url );
      $url = str_replace( array('þ', 'Þ'),'yu', $url );
      $url = str_replace( array('ÿ', 'ß'),'ya', $url );

Cyrillics is replaced with a Latin. It can not ideal a variant, but works.

There are some more questions under the advanced version...

1. On an index, it is not replaced URL in the right column, there where link to last to a forum subject. On the version simple such problem was not.
2. In the version advanced many files in comparison with simple change. It for the sake of that that names of links would be changed? Or there is still what that corrections in updating improvement?

Thanks
Cama
 
Posts: 6
Joined: Sat Oct 25, 2008 11:01 pm

Postby dcz » Sun Oct 26, 2008 1:57 pm

You could optimize this a bit but this is the idea.

To optimize, you could use strtr() instead of str_replace(), somtehing like :
Code: Select all
   $find = "ÀÁÂÃÅàáâãåÒÓÔÕØòóôõøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛùúûÿÑñ";
   $replace = "AAAAAaaaaaOOOOOoooooEEEEeeeeCcIIIIiiiiUUUuuuyNn";
   $url = strtr($url,$find,$replace);


with the proper chars to replace. You'd still need to keep the str_replace method for letter replaced by two letters though, but it would be in the end faster.

I'm not sure to fully get the other matter you raised.
Are you using a mod that adds topic title on index and url are not rewritten there ?

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby Cama » Sun Oct 26, 2008 4:18 pm

(Advanced)On index. Column on the right "Last post". Link on topic looks so:
Code: Select all
viewtopic.php?t=2865


Simple version mod, look correctly
Code: Select all
topic2865.html

(Advanced)
Code: Select all
      if ( !empty($this->get_vars[POST_TOPIC_URL]) && !empty($this->seo_url['topic'][$this->get_vars[POST_TOPIC_URL]]) ) {

         $this->url = $this->seo_url['topic'][$this->get_vars[POST_TOPIC_URL]] . $this->seo_delim['topic'] . $this->get_vars[POST_TOPIC_URL] . $this->start . $this->seo_ext['topic'];


(Simple)
Code: Select all
      if ( !empty($this->get_vars[POST_TOPIC_URL]) ) {

         $this->url = $this->seo_static['topic'] . $this->get_vars[POST_TOPIC_URL] . $this->start . $this->seo_ext['topic'];

These lines differ in different versions, is visible in it the reason of incorrect display link in version Advaced.

****
Your version of substitution of symbols, a little it is not correct :) For example: "Ù" = "shch" to four letters :)

There is one variant, look it please -
Code: Select all
      function encodeToTranslit($st)
      {
         $st=strtr($st,"àáâãäå¸çèéêëìíîïðñòóôõüú", "abvgdeeziyklmnoprstufh''");
         $st=strtr($st,"ÀÁÂÃÄŨÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÜÚ", "ABVGDEEZIYKLMNOPRSTUFH''");
   
         $st=strtr($st,
               array(
                  "æ"=>"zh",    "ö"=>"ts",    "÷"=>"ch", "ø"=>"sh",
                  "ù"=>"shch",   "þ"=>"yu",    "ÿ"=>"ya", "û"=>"yi",
                  "ý"=>"ye",

                  "Æ"=>"ZH",    "Ö"=>"TS",    "×"=>"CH", "Ø"=>"SH",
                  "Ù"=>"SHCH",   "Þ"=>"YU",    "ß"=>"YA", "Û"=>"YI",
                   "Ý"=>"YE"
                  )
            );
         return $st;   
      }

Tried to use this function, but unsuccessfully...
Cama
 
Posts: 6
Joined: Sat Oct 25, 2008 11:01 pm

Postby dcz » Sun Nov 02, 2008 10:33 am

About the last link, it must only be because you installed a mod to display the last topic link on index, and that, in order to be able to inject the topic titles, you need to patch it.
If it's the today at yesterday at mod or a similar mod, you'll easily find a patch using the search page.
In advanced mode, we need to retrieve forum and topic title before append_sid is called to be able to perform the title injection.

About strtr, and as said, my example was just meant to demonstrate a possible use, that would lower the amount of str_replace calls. It's not adapted to your need and is not the only solution, especially if you will be often replacing one char with several. It's mainly meant to deal with all other cases with accents in a row.
Since you seems to know a bit about coding you may find interesting things about characters replacement in this thread : http://www.phpbb-seo.com/boards/advance ... t1229.html
It's concerning phpBB3, but the same type of code could easily be used in phpBB2, the idea is just to find a way to do all the replacement in one step, the method used will just set up a find and replacement array only once, while starting the class, and then use it in format_url.
The method start to become consistent on this post : http://www.phpbb-seo.com/boards/advance ... .html#9596

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB2 Advanced mod Rewrite

Who is online

Users browsing this forum: No registered users and 3 guests