Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-11-2014, 12:55 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How does vBulletin make $vbphrase available to JavaScript?

Does anyone know how vBulletin passes phrases to JavaScript? For now I'm using a php file called with a script tag. Here's a sample of the code:

PHP Code:
<?php
require_once('./global.php');
header('Content-type: text/javascript');
header('Pragma:'); // VBIV-8269 
header('Cache-control: max-age=31536000');
header('Expires: ' gmdate("D, d M Y H:i:s"TIMENOW 31536000) . ' GMT');
define('VB_AREA''AdminCP');
define('THIS_SCRIPT''phrases');
?>

    fmPhrase = {
        fm_no_dir              : '<?php echo $vbphrase['fm_no_dir']; ?>',            
        fm_no_file             : '<?php echo $vbphrase['fm_no_file']; ?>',           
        fm_not_mult            : '<?php echo $vbphrase['fm_not_mult']; ?>',          
        fm_not_on_dir          : '<?php echo $vbphrase['fm_not_on_dir']; ?>',         
        fm_if_you_attempt      : '<?php echo $vbphrase['fm_if_you_attempt']; ?>',     
        fm_these_files         : '<?php echo $vbphrase['fm_these_files']; ?>',
           // etc
    }
If it was just a few phrases it could be handled with a short inline script in the head but there are dozens of phrases and settings and it's tiresome and tedious enough to phrase a project without having to add another pair to the phrase object every time.

Could someone point me to the file or function that handles this?
Reply With Quote
  #2  
Old 11-11-2014, 09:53 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not 100% sure, but I don't think there is any "magic" way of doing it. I think the phrases are written into the output either as js string constants or as html text which a js function then manipulates (like with the menus).
Reply With Quote
  #3  
Old 11-11-2014, 01:18 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

See includes/xml/js_safe_phrases.xml.

That seems to be part of some system that does what I want but I have no idea what file or function calls this.
Reply With Quote
  #4  
Old 11-11-2014, 02:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...didn't know that existed. But looking at the code in adminfunctions_language.php that uses that file, it looks like it's just a list of phrases that are adjusted for use in javascript (fetch_js_safe_string() in adminfunctions.php is called on each one to do some replacements). But other than that it doesn't seem to help. I checked where one of the phrases was used and it's for the ckeditor, and they seem to be output as a js function call that creates the editor.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:06 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03980 seconds
  • Memory Usage 2,193KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete