Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2010-02-25 18:13:31

Otomatic
FluxBB Donor
From: Paris - France
Registered: 2010-01-26
Posts: 220
Website

Cohabitation whole site iso-8859-1 with FluxBB 1.4 utf8

Hello,

I apologize for my wrong English.
My site (Sorry, only in French) (http://aviatechno.free.fr) has all pages with charset iso-8859-1.

Update from FluxBB 1.2.22 to FluxBB 1.4 (RC1 yet) poses two main problems :

- 1 - Transcoding the database from iso-8859-1 (latin1) to utf-8
With db_update.php and queries ALTER TABLE ... CONVERT TO CHARSET ... I think I have solved this problem. Moreover, db_update.php is improved each day...

- 2 - Having in the same site, pages in iso-8859-1 and others in utf-8
Indeed, all pages of my site (over 2,800) are iso-8859-1 as well as pages FluxBB 1.2.x forum that will have to be replaced by FluxBB 1.4 with utf-8 pages.
Integrating the forum into my site uses common files by include or require and it will be the same with FluxBB 1.4.
As it is totally out of question that I spend all my pages in utf-8, I discussed the issue of using files in either iso-8859-1 (baseline) or utf-8 and how to.
Integrating FluxBB 1.4 (It's the same with version 1.2.x) uses a file "FluxBB\include\user\menu_haut.php" called by main.tpl :

<pun_head>
</head>
<body>
<pun_include "menu_haut.php"> <!--modif oto ligne ajoutée -->
<div id="punwrap">
<div id="pun<pun_page>" class="pun">

As this file is only used by FluxBB, it may be hard coded in utf-8, but it uses six "cascaded" include files that are also used by a multitude of pages on my site and there is no question to move its in uft-8 or use utf-8 renamed copies because they can be updated frequently.
I searched for a permanent and automatic solution and I think I have found it.

In the file above integration (FluxBB\include\user\menu_haut.php), I defined a function named include_utf8:

// Change the charset of the file from iso-8859-1 to utf-8
// save the file recoded with added "utf8_" at the beginning of the name
// returns the changed file path. (In the directory cache of FluxBB)
// DOSSIER is the path to the root
function include_utf8($fichier) {
  $outfile = DOSSIER."fluxbb/cache/utf8_".basename($fichier);
  if (!file_exists($outfile))
    file_put_contents($outfile,iconv("ISO-8859-1","UTF-8",file_get_contents($fichier))); 
  return $outfile;
}
//First integration include
include(include_utf8('../vilgenis/inc/menu_h_vilgenis.php'));

The first file will be recoded utf8 before being included (But the original will not be changed or renamed).
In other files in "cascading include" (a includes b which includes c, which includes d...) just change the lines of the original inclusion as:

include('path_of_file');

by

if(function_exists('include_utf8')) include(include_utf8('path_of_file'));
else include('path_of_file');

Some might object that I could be include directly in the function include($outfile);
It is not possible, because it makes a big mess if the include occurs inside a function ; the code included will be considered part of the function and it loses the variable scope of that file that become local to function.
Results are here :
- Forum FluxBB 1.2.x iso-8859-1 : http://aviatechno.free.fr/punbb/
- Forum FluxBB 1.4 utf-8 : http://aviatechno.free.fr/fluxbb/


Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Ghandi
An error does not become truth by reason of multiplied propagation. Ghandi

Offline

#2 2010-07-14 14:26:31

Otomatic
FluxBB Donor
From: Paris - France
Registered: 2010-01-26
Posts: 220
Website

Re: Cohabitation whole site iso-8859-1 with FluxBB 1.4 utf8

Hello,

Due to questions raised by users and some thoughts and attempts, I greatly simplified to cohabit a site iso-8859-1 with FluxBB utf-8

Instead of changing all include files in cascade, it can simply change the call by using memory buffer and then perform the transcoding before posting.

So, the file "fluxbb\include\user\menu_haut.php" called by main.tpl containing:

include ('../vilgenis/inc/menu_h_vilgenis.php ');

is remplaced by:

//Change the charset of all cascading includes from iso-8859-1 to utf-8
function convert_iso_utf($buffer) {
  return utf8_encode($buffer);
}
ob_start("convert_iso_utf");
include('../vilgenis/inc/menu_h_vilgenis.php');
ob_end_flush();

Conclusion: we do not modify the original files and any changes will be reflected without having to delete the cache files because no more cache files.


Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Ghandi
An error does not become truth by reason of multiplied propagation. Ghandi

Offline

Board footer

Powered by FluxBB 1.4.8