Help dealing with dynamic JS and phpBB's system

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
User avatar
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Help dealing with dynamic JS and phpBB's system

Post by brunoais »

My first experimental development version (with just the testing basics) of the WYSIWYG editor is nearly complete.
At this moment, I still need to do some adjustments related to phpBB that I can't really find how to or I'm unsure if my idea on how to do it is a good one. They are as follows:
  1. I need to cache some of the javascript code that is produced while parsing. It must also output proper cache headers for the browser to cache.
  2. On each request, I need to output a set of variables that the code in 1. uses.
  3. Order of the output is important.
  4. Best way to generate javascript according to phpBB's philosophy.
For 1., I was thinking on having a new mode in posting.php that acts mostly the same as smilies, except it is control and setup data (in javascript) for the editor.
As part of my idea, when there's a new version, the URL to the file changes by changing a GET variable that is not read.
Does it make sense to use the template system for this? If so, how so?

For 2., I need to output a set of language variables (for example, the most common one being L_COLON), settings variables (e.g. S_VIEWFLASH and S_VIEWIMG) and other control variables. Is this just extra code in posting.php and template variables? Does it use any kind of features or functions (the question is related to this change made:
It is important to note that the number and name of the variables can change dynamically depending on the registered BBCode.

For 3., I need that the output follow a specific order: The general-purpose javascript has to be there first (contains reusable and static functions), then the output with the variables, then the output with the control and setup data. All of those must be accessible when DOMContentLoaded event is fired and the control and setup data must be added/executted after the editor's javascript and before the editor is started.

For 4., I'm currently generating the javascript by using ob_start() + js output w/ php embedded + ob_get_clean(). I'm not sure if this is the best method of doing it with phpBB but I don't know any other viable method (besides the obvious string concatenation). Is there any other method that is potentially better than this one or a method that is the right way for programs like phpBB? So far, the main advantage of the method I'm using is that the editor has all helpers to write the javascript while in the alternative I know, there's none.

For now, that's all.

Post Reply