Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Raven's RavenNuke(tm) v2.00.00 - v2.02.00 Distro
Author Message
Susann
Moderator


Joined: Dec 19, 2004
Posts: 3191
Location: Germany:Moderator German NukeSentinel Support

PostPosted: Sun May 21, 2006 6:39 am Reply with quote

Guardian

so you can easily learn some other languages too.Smile

As I said it´s fixed if I rename from themes/ DeepBlue the folder forums then I get the phpBB button for the language which I choose in my profile.

Styles and themes are really interesting.The problem is that´s all so time-consuming but I got my text back for the style fisubice in the forum and in the administration too only the path to the images is wrong somewhere.
 
View user's profile Send private message
fkelly
Former Moderator in Good Standing


Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Sun May 21, 2006 2:44 pm Reply with quote

Well, to bring everyone up to date, it seems like sticking the files in /modules/forums/templates is not what is wanted because it subverts the goal of having the forum template (aka theme) automatically match the Nuke theme if there is a forum "area" in /themes/selected_theme/forums.

So I got to looking at why the language selection wasn't working. I put some diagnostics into functions.php and echoed them out in the index.php of both the forums and the forums/admin. And sure enough despite switching both my site (Nuke) and forums to german the language was showing as english.

The code in functions.php that makes this selection is:

Code:
      $img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';

   $diagnostics .=  ' $img_lang  ' . $img_lang . ' board_config_lang ' . $board_config['default_lang'];


This can be found towards the bottom of the setup_style function. The diagnostics variable is something I added, obviously. I was perplexed to see that the $board_config value for default language remained english even after I had switched it on both the Nuke preferences screen and the forums admin screen. So I looked further and found in the function init_userprefs the following:

Code:
   function init_userprefs($userdata)

{
   global $board_config, $theme, $images;
   global $template, $lang, $phpEx, $phpbb_root_path;
   global $nav_links;

   if ( $userdata['user_id'] != ANONYMOUS )
   {
      if ( !empty($userdata['user_lang']))
      {
         $board_config['default_lang'] = $userdata['user_lang'];
      }


So if the userdata array value of user_lang was not empty the board config would get reset to whatever was in userdata. So where did this come from? Well in the function get_userdata there is the following sql:

Code:
   $sql = "SELECT *

                FROM " . USERS_TABLE . "
      WHERE ";
   $sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" .  str_replace("\'", "''", $user) . "'" ) . " AND user_id <> " . ANONYMOUS;   


So what's the value for the field 'user_lang' in the users table? Well looking back to Raven's load SQL in the installation directory of RN we find:

Quote:
`user_lang` varchar(255) NOT NULL default 'english',


during the creation of the users table.

So what I'm thinking is happening here is that the language setting is being overridden by what's in the users table. And I don't see any immediate way to fix that in your_account either but that's another whole path of investigation. I have to leave it here for the day.
 
View user's profile Send private message Visit poster's website
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Sun May 21, 2006 9:38 pm Reply with quote

DeepBlue theme works for me fine with the exception of the the 'New Topic' icon.
Everything else seems to be in german including the other images with text on them.
I'll have to re check the path to where that image is stored to see if it is being picked up correctly or missing from the german images folder.
- still find it weird having the site in one language and the forums in another lol
 
View user's profile Send private message Send e-mail
Susann
PostPosted: Mon May 22, 2006 5:10 am Reply with quote

Quote:
still find it weird having the site in one language and the forums in another

Let me know if you want to check my multilingual website.I use DeepBlue there.English and German is allowed in the forum and a small part is in French. I´ll give you the link via pm.
 
fkelly
PostPosted: Mon May 22, 2006 12:01 pm Reply with quote

I'm trying to step thru how languages get selected kind of systematically and I would appreciate any comments that others with more experience might have on my interpretation of the code. First, just to recapitulate a bit, there is a field called user_lang in the users table that's getting set to 'english' in the load process. I've also found that it's hardcoded to 'english' in the create_first function of admin.php. And as I indicated I believe that this value overrides any other values that are selected in functions.php.

So, I started trying to trace back how languages are managed. In mainfile.php there is a function called get_lang which I'll quote in entirety because it's short:

Code:
function get_lang($module) {

   global $currentlang, $language;
   if ($module == 'admin' AND $module != 'Forums') {
      if (file_exists('admin/language/lang-'.$currentlang.'.php')) {
         include_once('admin/language/lang-'.$currentlang.'.php');
      } elseif (file_exists('admin/language/lang-'.$language.'.php')) {
         include_once('admin/language/lang-'.$language.'.php');
      }
   } else {
      if (file_exists('modules/'.$module.'/language/lang-'.$currentlang.'.php')) {
         include_once('modules/'.$module.'/language/lang-'.$currentlang.'.php');
      } elseif (file_exists('modules/'.$module.'/language/lang-'.$language.'.php')) {
         include_once('modules/'.$module.'/language/lang-'.$language.'.php');
      }
   }
}


Now assuming that we aren't in the admin or forums modules we will fall thru to the "else". And if we are in forums we'll look for /modules/forums/language/a_language.php. Right? Now this immediately creates a problem because in the RN distribution, in modules/forums/language there is an english.php file but no other language.php files. So if the site language is anything other than english or the currentlanguage is the appropriate language.php file will not be executed. The result of this will be that constants for many of the functions within the Forums will not be set for non-English languages.

Does this make sense as a reading of the code? I don't want to go trudging off down another "dead end". Should there be language.php files in the forums for the other languages or is there another way that their functionality gets carried out?
 
fkelly
PostPosted: Mon May 22, 2006 2:07 pm Reply with quote

I just found a way to delete the user_lang field in users table (set it to null instead of 'english'). Now the language preferences work great in forums. I can see the German topics icon too. As I've mentioned above I have diagnostics running on my test site and no matter what I was doing it was retaining english as the language until I managed to reset that field to null. Try it, you'll like it and if you have phpmyadmin it's easy (I wasn't so lucky). I don't see any way to reset that field using standard Nuke but maybe I'm missing it.
 
Susann
PostPosted: Mon May 22, 2006 3:20 pm Reply with quote

I use in modules/forums/language the german files and folder too because you can t change the board language into another language in your forum profile without this.

There are so many languages available at:
Only registered users can see links on this board! Get registered or login!

and for the German language there are different files depends on the form of address.

The problem with some languages is that they are not up-to-date e.g. Hebrew or Welsh and if you use such an old language file with 2.0.20 your get only the half of the functions.
 
Guardian2003
PostPosted: Tue May 23, 2006 11:38 am Reply with quote

fkelly, I'm not sure that modification to the table is needed.
Using the current SVN I have the German language working just by uploading the 2 German folders into the subSilver template directory.
The only issue I am having at the moment is with the 'New Post' icon which refuses to change.

However, you have raised some very valuable information which does need to be investigated further.
 
fkelly
PostPosted: Wed May 24, 2006 11:48 am Reply with quote

Guardian, sorry it took me two days to get to this but (since we are being multi-lingual) I have to report au contraire.

Go on over to my test site:

Only registered users can see links on this board! Get registered or login!

This is basically a RN 2.02.02 site with a few of my changes in it but nothing that SHOULD affect this discussion. I have two normal users set up there a "plain" and a "plaingerman". Plain has her user_lang set to the default "english". I fixed plaingerman up with the user_lang set to null. Forums are presently configured to be german. If you log in as plain you will not be able to use the forums in german and you'll see the language is set to english. (There's some diagnostics printed on the forum screen showing the settings of templates and languages). If you log in as plaingerman you will be able to use the german forums. The passwords for both are "plain".

Ignore the size of the text in the forums. I'm experimenting with styles administration and I wanted to see when the styles changed and when they didn't. I'll have more to report on this later -- there's a very complex interplay between the bbthemes table, the css file and what's in the overall_header.tpl but I'll get to that later.

Feel free to experiment on that site; it's just for testing RN.
 
Guardian2003
PostPosted: Wed May 24, 2006 12:14 pm Reply with quote

I see you have the same issue with the 'New Topic' image but after comparing the your site to mine, it seems we both have the same result - but all I have done is uploaded the relevant language folder images.

It might be useful for diagnostices if we could echo out the following variables as well;
$current_template_images
$current_template_path
$current_template_images/{LANG}
I have a sneaky feeling this would be most enlightening Wink
 
fkelly
PostPosted: Wed May 24, 2006 9:34 pm Reply with quote

I'll stick those variables in later or tomorrow. Should be no problem. I was stumped when I saw your note because I had seen the new topic image in German. So I went over and tested and sure enough you were right. Then something struck me. Signed in as plaingerman I went over and changed my Nuke theme to Nukenews. That does away with having the default Forum theme be fisubice and sure enough when you go into Forums you get the German version of the new topic icon. Try it Smile

Where in the code this is happening is something else, I'll have to look further unless you find it first.
 
Guardian2003
PostPosted: Thu May 25, 2006 4:57 am Reply with quote

I think the issue is actually due to the way that phpBB was ported - I do not think the use of additional languages / styles was considered, at least as far as incorporating them into themes rather than Forum/templates.

As you can see from the file forums.cfg it references 'template' rather than 'theme'. Many other files operate under the assumption that that they are in modules/Forums/templates/xx rather than themes/xxxx/forums/ as you have confirmed with some of the code snippets you have posted.

In the case of the New Topic image (post.gif) it is referenced in forums.cfg as an invalid url made from the variable
$current_template_images/{LANG}/post.gif
forums.cfg is not in itself referenced by ANY file except overall_header.tpl

In therory then, in order to get multiple languages working as 'theme' languages I think we need to look at either $current_template_xx construct or the LANG place holder as one of both are out of synch with the 'themes' way of doing things.
 
fkelly
PostPosted: Thu May 25, 2006 7:42 am Reply with quote

Well Guardian, I just wanted you (and anyone else interested) to know that the diagnostics are out there, in spades. I may not have time to figure them all out right now but you should be able to see what is happening pretty well.

You could look at the functions.php code to see where they are being generated and I tried to make it quasi-self documenting but here's the actual code:

Code:
function setup_style($style)

{
   global $db, $prefix, $board_config, $template, $images, $phpbb_root_path, $name, $diagnostics;
        if($name == "Forums"){
                cookiedecode($user);
            $info=$db->sql_query("select * from ".$prefix."_bbconfig where config_name='default_style'");
            $get_info=$db->sql_fetchrow($info);
            $default_style=$get_info['config_value'];
            if($cookie[1] == "" AND $style != "$default_style") {
                $style = "$default_style";
            }
        }

   $sql = "SELECT *
      FROM " . THEMES_TABLE . "
                WHERE themes_id = '$style'";
 
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Could not query database for theme info');
   }

   if ( !($row = $db->sql_fetchrow($result)) )
   {
      message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
   }

        $ThemeSel = get_theme();
        $diagnostics = 'past get_theme of setup style function <br>';
        if (file_exists("themes/$ThemeSel/forums/index_body.tpl")) {
                $template_path = "themes/$ThemeSel/";
            $template_name = "forums";
            $template = new Template($template_path . $template_name, $board_config, $db);
            $diagnostics .= 'themes/themesel/forums/index_body-tpl found <br>';
            $diagnostics .= 'template path = ' . $template_path . '<br>';
             $diagnostics .= 'template name = ' . $template_name . '<br>';
              $diagnostics .= 'themesel = ' . $ThemeSel . '<br>';
        } else {
                      
           $template_path = 'templates/' ;
   $template_name = $row['template_name'] ;
            $template = new Template($phpbb_root_path . $template_path . $template_name, $board_config, $db);
            $diagnostics .= 'themes/themesel/forums/index_body-tpl NOT found <br>'; 
                 $diagnostics .= 'template path = ' . $template_path . '<br>';
                  $diagnostics .= 'template name = ' . $template_name . '<br>';
                $diagnostics .= 'themesel= ' . $ThemeSel .  '<br>';
        }
   if ( $template )
   {
      $current_template_path = $template_path . $template_name;
                $ThemeSel = get_theme();
                $diagnostics .= 'after test for if $template ' . '<br>';
                $diagnostics .=  'themesel = ' . $ThemeSel . '<br> ';
                $diagnostics .= 'current template path = ' .  $current_template_path . '<br>';
           
                if (file_exists("themes/$ThemeSel/$template_name/index_body.tpl")) {
                    include($template_path . $template_name . '/' . $template_name . '.cfg');
                } else {
      @include($phpbb_root_path . $template_path . $template_name . '/' . $template_name . '.cfg');
                }
      if ( !defined('TEMPLATE_CONFIG') )
      {
         message_die(CRITICAL_ERROR, "Could not open $template_name template config file", '', __LINE__, __FILE__);
      }

      $img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
   $diagnostics .=  ' $img_lang = ' . $img_lang . ' board_config_lang = ' . $board_config['default_lang'] . '<br>';
   $diagnostics .= 'in image while loop <br>';
      while( list($key, $value) = @each($images) )
      {
         $diagnostics .= 'key value from each$images ' . $key . ' ' . $value . '<br>';
         if ( !is_array($value) )
         {
            $images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
            $diagnostics .= 'img lang and value ' . $img_lang . ' ' . $value . '<br>';
         }
      }
   }

   return $row;
}


$images is an array that's being passed in from somewhere but I still need to track down where and how it is generated.

Work in progress.
 
fkelly
PostPosted: Thu May 25, 2006 7:52 am Reply with quote

That didn't take long. Switched default theme back to fisubice which makes forums theme also be fisubice. Diagnostics shows:

Quote:
current template path = themes/fisubice/forums
$img_lang = english board_config_lang = german


And that's because of the line of code:

Code:
      $img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';


And of course the fisubice theme is never in the phpbb_realpath so the img_lang will always get set to english. Then the images will always be found in the english directory when the variable $img_lang is used in the str_replace function in the image loop.

Time for a bike ride but I think a solution should not be beyond reach. We just need a different file exists test if we are using a "non-Forum" theme.
 
Guardian2003
PostPosted: Thu May 25, 2006 8:14 am Reply with quote

Or we could place somehing like
Code:
 define(THEME_FORUM, TRUE);
in the fisubice theme.php and use that as the logic check for an if/else.
Hmm, interesting.
 
Guardian2003
PostPosted: Thu May 25, 2006 9:10 am Reply with quote

Yes, the problem lies with functions.php
All the if/else logic seems to refer to templates not themes.
Removing index_body.tpl from themes/forubice/forums/ confirms
 
fkelly
PostPosted: Thu May 25, 2006 11:40 am Reply with quote

Yes, I haven't really focused on a solution yet but notice that if you sign in as "plain" which is a user who has user_lang set to english and then you go into forums you get:

Quote:
current template path = themes/fisubice/forums
$img_lang = english board_config_lang = english


in the diagnostics.

But if you sign in as plaingerman where the user_lang in the users table has been set to null then you get:

Quote:
current template path = themes/fisubice/forums
$img_lang = english board_config_lang = german


We'll have to research what else the field user_lang from the users table is used for but if possible we should change the default to null. If we can't do that then we'll need to program another exception. I have confirmed that changing your language in the select language interface block does nothing to this field.
 
fkelly
PostPosted: Thu May 25, 2006 1:52 pm Reply with quote

A question has arisen on getting the diagnostics to work. Aside from substituting in the setup style function I listed previously you need to modify the index.php for /forums (and optionally) the index.php for forums/admin.

Look in those files and find the line
Code:
$template->pparse('body');


Before it stick in the line(s):

Code:
echo 'diagnostics should be here <br>';

echo $diagnostics;


The display of diagnostics in the admin/index.php is a bit funky, it is in the left frame (but I just discovered you can make it wider) so I'd concentrate on the index.php of /forums.

Obviously you don't want to do this in a production environment.
 
fkelly
PostPosted: Thu May 25, 2006 2:26 pm Reply with quote

Darn it, this is driving me crazy. The diagnostics for the admin screen for forums are coming out differently than the ones for the forums/index.php.

The statements in question are:

Code:
        $ThemeSel = get_theme();

        $diagnostics = 'past get_theme of setup style function <br>';
        if (file_exists("themes/$ThemeSel/forums/index_body.tpl")) {
                $template_path = "themes/$ThemeSel/";
            $template_name = "forums";
            $template = new Template($template_path . $template_name, $board_config, $db);
            $diagnostics .= 'themes/themesel/forums/index_body-tpl found <br>';
            $diagnostics .= 'template path = ' . $template_path . '<br>';
             $diagnostics .= 'template name = ' . $template_name . '<br>';
              $diagnostics .= 'themesel = ' . $ThemeSel . '<br>';
        } else {
                      
           $template_path = 'templates/' ;
   $template_name = $row['template_name'] ;
            $template = new Template($phpbb_root_path . $template_path . $template_name, $board_config, $db);
            $diagnostics .= 'themes/themesel/forums/index_body-tpl NOT found <br>'; 
                 $diagnostics .= 'template path = ' . $template_path . '<br>';
                  $diagnostics .= 'template name = ' . $template_name . '<br>';
                $diagnostics .= 'themesel= ' . $ThemeSel .  '<br>';
        }


And the problem is that the file exists is being satisfied if you are in forums/index.php but not if you are in admin/index.php. I'm suspecting that maybe the path is being sent in differently to this function depending on where it's being called from but I'm not sure yet. In other words "themes/$ThemeSel/forums/index_body.tpl" is a relative path and it's being found in the context of forums/index.php but not in the context of /admin/index.php. But I know I'm being foggy on that.

The result is that the admin/index.php is always using the subsilver theme whereas the forums/index.php will use either fisubice or deepblue (the two nuke themes that have /forums directories if the users nuke theme is one of those two.

This is a deep hole. And once we trace down all the technical aspects of this there is going to have to be a discussion about what we want it to do. For instance, if a user chooses say German for a language in Nuke but the admin chooses English for the forum language do we show the forums in English or German. Or should we just make the Nuke preferences for language determine what the language of Forums is and do away with the language setting in forums? Or alternatively are there sites that value the ability to have Nuke in one language and forums in another? If there is a nice set of specs for all this somewhere I'd love to see them.
 
Susann
PostPosted: Thu May 25, 2006 6:21 pm Reply with quote

Normally you have the same language on the mainpage and in the forum. I think that´s standard and if you don´t choose the same language you can get different problems with your website in the search engines.

Also it doesn't make sense to have the forum in an other language, because the registered member can choose the preferred language in the forums profile.
 
fkelly
PostPosted: Thu May 25, 2006 8:08 pm Reply with quote

What I'm trying to ask is whether maybe we should just have languages set in the Nuke preferences on the admin screen for the whole system and disable the Forums preferences. That way the language would be automatically the same. Just set the bbconfig value at the same time you set the nuke config value in preferences.

But beyond that I'm really having a hard time understanding how Nuke handles language settings and where. There is a function called selectlanguage in mainfile and very similar functionality in block-Languages.php. The both read the language directory and present a drop down list of language selections based on the files that are in it. Then they apparently pass the results in a "get" to index.php. But for the life of me I can't see where index.php does anything with it. I'll keep looking but if anyone knows how this works and can help out it would be appreciated.
 
Guardian2003
PostPosted: Fri May 26, 2006 12:15 am Reply with quote

If I remember correctly, selectlanguage only sets the nuke language, forum language is handled independantly, possibly from dragging a setting out of $board_config
I think, we would need to 'force' the forum language (as far as user forum prefs go) at the same time the site language is selected in the users YA profile as well as when the 'default' nuke language is selected via ACP. This should give us a sort of consistent 'global' language selection whilst retaining the ability to change the forum language on a per user basis via their forum profile.
As Susann mentioned, it doesnt make sense to have nuke language set to one language whilst having the forum language set differently BUT we need to retain the forum language selection functions for the forums as 'there will always be one' that wants two different languages in use <sigh>.

fkelly - will try those files you sent shortly.
Yes the forum admin area seems to get handled differently yet again (see my SVN note).
 
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Sat Jul 08, 2006 12:41 am Reply with quote

Okay, so I think I may understand....

Case 1: No forums profile language selected, use the Nuke selected language default
Case 2: Forums profile language selected, use that

Is there any other cases?

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Guardian2003
PostPosted: Sat Jul 08, 2006 4:36 am Reply with quote

Yes I'm afraid so.
Case 2b: Forums profile language selected use that (where the users selected THEME has forum files).

NB The issue is not just with 'language' in a textual sense but also with the forum buttons (post.gif etc)
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Raven's RavenNuke(tm) v2.00.00 - v2.02.00 Distro

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©