Thread: Major Additions - Links and Downloads Manager
View Single Post
  #2766  
Old 12-19-2007, 12:29 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First.. it works great.. with 3.7 beta..

Second, i searched for multilanguage support.. for titles and descriptions.. and found somewhere in FAQ that it is not going to be supported..

So I came up with a very personal solution.. inspired by a very old hack by Joerg Z from the times where vbulletin 3.5 did not have the user profile fields phrased.. https://vborg.vbsupport.ru/showthread.php?t=98904

So i did some testing.. and it seems to work fine... but:

I only use l&d manager as a links database.. AND will never have more than 100 categories.. so i dont know what happens if it is used differently

What i'd be interested in.. is if someone knows if there is a drawback..

The principle:
When you create a cat, you enter a dummy name.. a placeholder with a dollar sign in front..
example for the category "Vbullentin Sites" you enter the name $vbull_sites_ll_name
- you do the same with description, and long description, paying attention that you have descriptive names.. example in our case: $vbull_sites_ll_desc and $vbull_sites_ll_long_desc

No special characters and no spaces in those names.. and a $ (dollar sign in front)

Now you create phrases for each entry name, description and long description..
They have to have the same varname as you entered for your category BUT without the $ dollar sign!!! .. .. in those phrases you enter the real text you want to have.. (you add those phrases in phrasemanager to group: local_links...

For this to work you need 2 file modifications..
1st..
open: local_links_include.php
and find:
PHP Code:
foreach ($linkscat as $catid => $thiscat) { 
below add:
PHP Code:
// language cats hack -------- start
    
$catname_multi trim($linkscat[$catid]['catname']);
    
$catdesc_multi trim($linkscat[$catid]['catdesc']);
    
$cattext_multi trim($linkscat[$catid]['cattext']);

    if(
substr($catname_multi,0,1) == '$' AND ($this_action != "addcat" OR $this_action != "editcat"))
    {
        
// we remove the '$'
        
$catname_multi substr($catname_multi,1);
        
// we get the phrase
        
$linkscat[$catid]['catname'] = (!empty($vbphrase[$catname_multi])) ? $vbphrase[$catname_multi] : $catname_multi;
    }
    if(
substr($catdesc_multi,0,1) == '$' AND ($this_action != "addcat" OR $this_action != "editcat"))
    {
        
// we remove the '$'
        
$catdesc_multi substr($catdesc_multi,1);
        
// we get the phrase
        
$linkscat[$catid]['catdesc'] = (!empty($vbphrase[$catdesc_multi])) ? $vbphrase[$catdesc_multi] : $catdesc_multi;
    }
    if(
substr($cattext_multi,0,1) == '$' AND ($this_action != "addcat" OR $this_action != "editcat"))
    {
        
// we remove the '$'
        
$cattext_multi substr($cattext_multi,1);
        
// we get the phrase
        
$linkscat[$catid]['cattext'] = (!empty($vbphrase[$cattext_multi])) ? $vbphrase[$cattext_multi] : $cattext_multi;
    }

// language cats hack -------- end 
then in the file local_links.php find:
PHP Code:
    $catname    htmlspecialchars_uni($linkscat[$viewcatid]["catname"]);
    
$catdesc    htmlspecialchars_uni($linkscat[$viewcatid]["catdesc"]);
    
$cattext    htmlspecialchars_uni($linkscat[$viewcatid]["cattext"]); 
and replace these 3 lines with:
PHP Code:
    // start multilang hack
    
$multilangcat $vbulletin->db->query_first("
        SELECT catname, catdesc, cattext
        FROM "
.THIS_TABLE."linkscat
        WHERE catid = '"
.$vbulletin->GPC['catid']."'
        "
);
    
//$catname    = htmlspecialchars_uni($linkscat[$viewcatid]["catname"]);
    
$catname $multilangcat['catname'];

    
//$catdesc    = htmlspecialchars_uni($linkscat[$viewcatid]["catdesc"]);
    
$catdesc $multilangcat['catdesc'];
    
//$cattext    = htmlspecialchars_uni($linkscat[$viewcatid]["cattext"]);
    
$cattext $multilangcat['cattext'];
    
// end multilang hack 
thats it...
as I said.. it seems to work.. and I will continue testing on my localhost as long as vb3.7 is still in beta...

What I'd be interested in... is if someone sees an obvious drawback...
Ok.. the cat editing is a pain.. but you do it only very seldomly.. (the extra query is only at catedit.. and only done by admin ==> me.. )

I forgot.. if the name or desc or long description do NOT start with a $ sign.. it works as designed for that cat.. so multilanguage is Not active for this cat..

I think its only a starting idea.. but surely needs to be overworked before usage..

Maybe there are better solutions.. but i didnt find any..
(more sophisticated would be to use the system vbull uses for user profile fields.. but that would require much more rewriting!!!) it basically does the same.. but creates the phrases when you enter the name.. and does the replacements in the background..

Felix

PS: this is just an idea i had while playing around.. it seems to work in my config.. but i would not use it in a production environment..
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01097 seconds
  • Memory Usage 1,829KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete